crystal-lang / crystal_lib

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

Fix: CamelCased name w/ pointer to an opaque struct #46

Closed olbat closed 7 years ago

olbat commented 7 years ago

Such as in #42, typedef names of pointers to opaque structs like SomeName are transformed as Somename instead of SomeName.

Here is an example:

$ cat /tmp/test.h 
struct SomeOpaque;
typedef struct someOpaque someOpaqueReference;
someOpaqueReference *some_function();

$ cat test.cr 
@[Include("/tmp/test.h", prefix: ["some_"], remove_prefix: false)]
lib Test
end

$ crystal src/main.cr -- test.cr
lib Test
  fun function = some_function : Someopaquereference
  type Someopaquereference = Void*
end

With the patch:

$ crystal src/main.cr -- test.cr
lib Test
  fun function = some_function : SomeOpaqueReference
  type SomeOpaqueReference = Void*
end

_PS: I don't really get why the capitalize call was here since the declare_typedef function already handles this (maybe some code that was not updated after a refactoring ?), just let me know if this issue should be handled differently._

olbat commented 7 years ago


~~~I got this working with crystal `0.20.5`, but had some trouble running the specs with `0.21.0`, even without my patch `crystal spec` ~~~fails silently~~~ I get travis' error  (I'm using LLVM/clang `3.6` and the official docker image).~~~

See #45.
olbat commented 7 years ago

Tested with Cystal 0.21.1 everything runs fine.

mverzilli commented 7 years ago

Thank you @olbat! I'll upgrade the CI to work against 0.21.1 and merge this if it passes.

olbat commented 7 years ago

Wonderful, thanks !