diff options
Diffstat (limited to 'lib/ffi/library.rb')
-rw-r--r-- | lib/ffi/library.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/ffi/library.rb b/lib/ffi/library.rb index 47a0fa8..9711d8e 100644 --- a/lib/ffi/library.rb +++ b/lib/ffi/library.rb @@ -447,6 +447,7 @@ module FFI # @return [FFI::Enum] # Create a new {FFI::Enum}. def enum(*args) + native_type = args.first.kind_of?(FFI::Type) ? args.shift : nil name, values = if args[0].kind_of?(Symbol) && args[1].kind_of?(Array) [ args[0], args[1] ] elsif args[0].kind_of?(Array) @@ -455,7 +456,7 @@ module FFI [ nil, args ] end @ffi_enums = FFI::Enums.new unless defined?(@ffi_enums) - @ffi_enums << (e = FFI::Enum.new(values, name)) + @ffi_enums << (e = native_type ? FFI::Enum.new(native_type, values, name) : FFI::Enum.new(values, name)) # If called as enum :foo, [ :zero, :one, :two ], add a typedef alias typedef(e, name) if name |