summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortduehr <tduehr@gmail.com>2015-05-21 09:18:01 -0500
committertduehr <tduehr@gmail.com>2015-05-21 09:18:01 -0500
commit18fefbbbd25537e5f458ac794f297a09a0a619f3 (patch)
tree152a9fb5b699d4c0dec5f0279f42cafb346b8f49
parentf2e25402359dc6a8f6fa0039bdae579fb0ac9910 (diff)
downloadffi-18fefbbbd25537e5f458ac794f297a09a0a619f3.tar.gz
better native_type
-rw-r--r--lib/ffi/enum.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/ffi/enum.rb b/lib/ffi/enum.rb
index 1b0b898..0e84ba7 100644
--- a/lib/ffi/enum.rb
+++ b/lib/ffi/enum.rb
@@ -85,6 +85,7 @@ module FFI
include DataConverter
attr_reader :tag
+ attr_reader :native_type
# @overload initialize(info, tag=nil)
# @param [nil, Enumerable] info
@@ -94,7 +95,7 @@ module FFI
# @param [nil, Enumerable] info symbols and values for new Enum
# @param [nil, Symbol] tag name of new Enum
def initialize(*args)
- @native_type = args.shift if args.first.kind_of?(FFI::Type)
+ @native_type = args.first.kind_of?(FFI::Type) ? args.shift : Type::INT
info, @tag = *args
@kv_map = Hash.new
unless info.nil?
@@ -149,12 +150,6 @@ module FFI
alias to_h symbol_map
alias to_hash symbol_map
- # Get native type of Enum
- # @return [Type]
- def native_type
- @native_type || Type::INT
- end
-
# @param [Symbol, Integer, #to_int] val
# @param ctx unused
# @return [Integer] value of a enum symbol