neelance / ffi_gen

A generator for Ruby FFI bindings, directly from header files via LLVM's Clang compiler
MIT License
88 stars 26 forks source link

Option to disable shorten_names. #14

Closed novogrammer closed 12 years ago

novogrammer commented 12 years ago

Short name may cause confusion.

neelance commented 12 years ago

Confusion where exactly? If you show me a good example, I will be happy to include this option.

novogrammer commented 12 years ago

The confusion occurs when I use an enum as global constant value,using FFI::Library.enum_value. And in case using unnamed enum, enum type can not be determined.

Here is an example.

//C code enum EnumA { EnumA_Default, EnumA_A, EnumA_B, }; enum EnumB { EnumB_A, EnumB_B, };

generated code

module Foo enum enum_a [ :default, 0, :a, 1, :b, 2 ]

enum enum_b [ :a, 0, :b, 1 ] end

OK

Foo.enum_type(:enum_a)[:default] # => 0 Foo.enum_type(:enum_a)[:a] # => 1 Foo.enum_type(:enum_a)[:b] # => 2

enum_value instead of enum_type

Foo.enum_value(:default) # => 0 Foo.enum_value(:a) # => 0 Foo.enum_value(:b) # => 1

novogrammer commented 12 years ago

I close pull request. Because it is not for general use.