ffi-extra 0.0.2 → 0.0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ffi/extra.rb +10 -2
- metadata +2 -2
data/lib/ffi/extra.rb
CHANGED
@@ -14,7 +14,7 @@ module FFI
|
|
14
14
|
def self.type_size (type)
|
15
15
|
type = FFI.find_type(type) if type.is_a?(Symbol)
|
16
16
|
|
17
|
-
if type.is_a?(Type::Builtin) || type.is_a?(Class) && type.ancestors.member?(FFI::Struct) || type.ancestors.member?(FFI::ManagedStruct)
|
17
|
+
if type.is_a?(Type::Builtin) || (type.is_a?(Class) && (type.ancestors.member?(FFI::Struct) || type.ancestors.member?(FFI::ManagedStruct)))
|
18
18
|
type.size
|
19
19
|
elsif type.respond_to? :from_native
|
20
20
|
type.native_type.size
|
@@ -100,7 +100,7 @@ module FFI
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
def read_array_of (
|
103
|
+
def read_array_of (type, number)
|
104
104
|
if type.is_a?(Symbol)
|
105
105
|
if respond_to? "read_array_of_#{type.downcase}"
|
106
106
|
return send "read_array_of_#{type.downcase}", number
|
@@ -150,3 +150,11 @@ module FFI
|
|
150
150
|
find_type(:size_t) rescue typedef(:ulong, :size_t)
|
151
151
|
find_type(:ssize_t) rescue typedef(:long, :ssize_t)
|
152
152
|
end
|
153
|
+
|
154
|
+
[Integer, String, NilClass, TrueClass, FalseClass, FFI::Pointer].each {|klass|
|
155
|
+
klass.instance_eval {
|
156
|
+
define_method :to_ffi do
|
157
|
+
self
|
158
|
+
end
|
159
|
+
}
|
160
|
+
}
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ffi-extra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- meh.
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-21 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ffi
|