ffi-extra 0.0.1 → 0.0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ffi/extra.rb +4 -4
- metadata +1 -1
data/lib/ffi/extra.rb
CHANGED
@@ -32,7 +32,7 @@ module FFI
|
|
32
32
|
def self.type_size (type)
|
33
33
|
type = FFI.find_type(type) if type.is_a?(Symbol)
|
34
34
|
|
35
|
-
if type.is_a?(
|
35
|
+
if type.is_a?(Type::Builtin) || type.is_a?(Class) && type.ancestors.member?(FFI::Struct) || type.ancestors.member?(FFI::ManagedStruct)
|
36
36
|
type.size
|
37
37
|
elsif type.respond_to? :from_native
|
38
38
|
type.native_type.size
|
@@ -91,10 +91,10 @@ module FFI
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
if type.is_a?(
|
95
|
-
type.new(self)
|
96
|
-
elsif type.is_a?(Type::Builtin)
|
94
|
+
if type.is_a?(Type::Builtin)
|
97
95
|
send "read_#{type.name.downcase}"
|
96
|
+
elsif type.is_a?(Class) && type.ancestors.member?(FFI::Struct) && !type.ancestors.member?(FFI::ManagedStruct)
|
97
|
+
type.new(self)
|
98
98
|
elsif type.respond_to? :from_native
|
99
99
|
type.from_native(typecast(type.native_type), nil)
|
100
100
|
else
|