crystal-lang / crystal_lib

Automatic binding generator for native libraries in Crystal
138 stars 30 forks source link

Don't register same var twice. #27

Closed maiha closed 8 years ago

maiha commented 8 years ago

There is a problem that struct.var could be registered twice. The minimum example is

struct struct_foo { struct struct_bar* bar; };
struct struct_bar { int x; };
typedef struct struct_bar struct_bar;

In this case, visit_var_declaration is called twice about struct_bar.x on reference and definitioin. Then, our parser produces as following.

struct StructBar
  x : LibC::Int
  x : LibC::Int
end

This pr fixes it, and produces expected code.

struct StructBar
  x : LibC::Int
end

Thanks.

asterite commented 8 years ago

Looks good, thank you! :-)