ffi 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ffi might be problematic. Click here for more details.
- data/Rakefile +13 -13
- data/ext/ffi_c/AbstractMemory.c +1 -1
- data/ext/ffi_c/compat.h +2 -2
- data/ext/ffi_c/extconf.rb +3 -3
- data/lib/ffi/library.rb +10 -8
- data/lib/ffi/platform.rb +0 -2
- data/lib/ffi/struct.rb +1 -5
- data/lib/ffi/tools/const_generator.rb +10 -13
- data/spec/ffi/async_callback_spec.rb +2 -2
- data/spec/ffi/bool_spec.rb +6 -6
- data/spec/ffi/buffer_spec.rb +23 -23
- data/spec/ffi/callback_spec.rb +101 -102
- data/spec/ffi/custom_type_spec.rb +20 -24
- data/spec/ffi/dup_spec.rb +7 -7
- data/spec/ffi/enum_spec.rb +127 -127
- data/spec/ffi/errno_spec.rb +2 -2
- data/spec/ffi/ffi_spec.rb +3 -3
- data/spec/ffi/function_spec.rb +10 -10
- data/spec/ffi/library_spec.rb +30 -12
- data/spec/ffi/managed_struct_spec.rb +4 -4
- data/spec/ffi/number_spec.rb +40 -40
- data/spec/ffi/pointer_spec.rb +21 -24
- data/spec/ffi/rbx/memory_pointer_spec.rb +17 -17
- data/spec/ffi/rbx/struct_spec.rb +2 -2
- data/spec/ffi/spec_helper.rb +1 -1
- data/spec/ffi/string_spec.rb +9 -9
- data/spec/ffi/strptr_spec.rb +3 -3
- data/spec/ffi/struct_callback_spec.rb +7 -7
- data/spec/ffi/struct_initialize_spec.rb +2 -2
- data/spec/ffi/struct_packed_spec.rb +6 -6
- data/spec/ffi/struct_spec.rb +85 -85
- data/spec/ffi/typedef_spec.rb +4 -4
- data/spec/ffi/union_spec.rb +3 -3
- data/spec/ffi/variadic_spec.rb +17 -14
- data/tasks/rdoc.rake +1 -1
- metadata +4 -4
data/spec/ffi/typedef_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe "Custom type definitions" do
|
|
23
23
|
typedef :uint, :fubar_t
|
24
24
|
attach_function :ret_u32, [ :fubar_t ], :fubar_t
|
25
25
|
end
|
26
|
-
CustomTypedef.ret_u32(0x12345678).should
|
26
|
+
CustomTypedef.ret_u32(0x12345678).should eq 0x12345678
|
27
27
|
end
|
28
28
|
it "variadic invoker with custom typedef" do
|
29
29
|
module VariadicCustomTypedef
|
@@ -34,7 +34,7 @@ describe "Custom type definitions" do
|
|
34
34
|
end
|
35
35
|
buf = FFI::Buffer.new :uint, 10
|
36
36
|
VariadicCustomTypedef.pack_varargs(buf, "i", :fubar_t, 0x12345678)
|
37
|
-
buf.get_int64(0).should
|
37
|
+
buf.get_int64(0).should eq 0x12345678
|
38
38
|
end
|
39
39
|
it "Callback with custom typedef parameter" do
|
40
40
|
module CallbackCustomTypedef
|
@@ -46,7 +46,7 @@ describe "Custom type definitions" do
|
|
46
46
|
end
|
47
47
|
i = 0
|
48
48
|
CallbackCustomTypedef.testCallbackU32rV(0xdeadbeef) { |v| i = v }
|
49
|
-
i.should
|
49
|
+
i.should eq 0xdeadbeef
|
50
50
|
end
|
51
51
|
module StructCustomTypedef
|
52
52
|
extend FFI::Library
|
@@ -59,7 +59,7 @@ describe "Custom type definitions" do
|
|
59
59
|
it "Struct with custom typedef field" do
|
60
60
|
s = StructCustomTypedef::S.new
|
61
61
|
s[:a] = 0x12345678
|
62
|
-
s.pointer.get_uint(0).should
|
62
|
+
s.pointer.get_uint(0).should eq 0x12345678
|
63
63
|
end
|
64
64
|
|
65
65
|
it "attach_function after a typedef should not reject normal types" do
|
data/spec/ffi/union_spec.rb
CHANGED
@@ -56,7 +56,7 @@ describe 'Union' do
|
|
56
56
|
if k == 'f32' or k == 'f64'
|
57
57
|
(@u[type[1]] - LibTest.send("union_align_#{k}", @u.to_ptr)).abs.should < 0.00001
|
58
58
|
else
|
59
|
-
@u[type[1]].should
|
59
|
+
@u[type[1]].should eq LibTest.send("union_align_#{k}", @u.to_ptr)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -66,11 +66,11 @@ describe 'Union' do
|
|
66
66
|
if k == 'f32' or k == 'f64'
|
67
67
|
(@u[type[1]] - type[2]).abs.should < 0.00001
|
68
68
|
else
|
69
|
-
@u[type[1]].should
|
69
|
+
@u[type[1]].should eq type[2]
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
73
|
it 'should return a size equals to the size of the biggest field' do
|
74
|
-
LibTest::TestUnion.size.should
|
74
|
+
LibTest::TestUnion.size.should eq LibTest.union_size
|
75
75
|
end
|
76
76
|
end
|
data/spec/ffi/variadic_spec.rb
CHANGED
@@ -25,30 +25,31 @@ describe "Function with variadic arguments" do
|
|
25
25
|
it "call variadic with (:char (#{i})) argument" do
|
26
26
|
buf = FFI::Buffer.new :long_long
|
27
27
|
LibTest.pack_varargs(buf, "c", :char, i)
|
28
|
-
buf.get_int64(0).should
|
28
|
+
buf.get_int64(0).should eq i
|
29
29
|
end
|
30
30
|
end
|
31
31
|
[ 0, 0x7f, 0x80, 0xff ].each do |i|
|
32
32
|
it "call variadic with (:uchar (#{i})) argument" do
|
33
33
|
buf = FFI::Buffer.new :long_long
|
34
34
|
LibTest.pack_varargs(buf, "C", :uchar, i)
|
35
|
-
buf.get_int64(0).should
|
35
|
+
buf.get_int64(0).should eq i
|
36
36
|
end
|
37
37
|
end
|
38
38
|
[ 0, 1.234567, 9.87654321 ].each do |v|
|
39
39
|
it "call variadic with (:float (#{v})) argument" do
|
40
40
|
buf = FFI::Buffer.new :long_long
|
41
41
|
LibTest.pack_varargs(buf, "f", :float, v.to_f)
|
42
|
-
buf.get_float64(0).should
|
42
|
+
buf.get_float64(0).should eq v
|
43
43
|
end
|
44
44
|
end
|
45
45
|
[ 0, 1.234567, 9.87654321 ].each do |v|
|
46
46
|
it "call variadic with (:double (#{v})) argument" do
|
47
47
|
buf = FFI::Buffer.new :long_long
|
48
48
|
LibTest.pack_varargs(buf, "f", :double, v.to_f)
|
49
|
-
buf.get_float64(0).should
|
49
|
+
buf.get_float64(0).should eq v
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
52
53
|
module Varargs
|
53
54
|
PACK_VALUES = {
|
54
55
|
'c' => [ 0x12 ],
|
@@ -68,14 +69,16 @@ describe "Function with variadic arguments" do
|
|
68
69
|
'i' => :int, 'I' => :uint, 'j' => :long_long, 'J' => :ulong_long,
|
69
70
|
'l' => :long, 'L' => :ulong, 'f' => :float, 'd' => :double
|
70
71
|
}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
end
|
73
|
+
|
74
|
+
def verify(p, off, v)
|
75
|
+
if v.kind_of?(Float)
|
76
|
+
p.get_float64(off).should eq v
|
77
|
+
else
|
78
|
+
p.get_int64(off).should eq v
|
77
79
|
end
|
78
80
|
end
|
81
|
+
|
79
82
|
Varargs::PACK_VALUES.keys.each do |t1|
|
80
83
|
Varargs::PACK_VALUES.keys.each do |t2|
|
81
84
|
Varargs::PACK_VALUES.keys.each do |t3|
|
@@ -87,9 +90,9 @@ describe "Function with variadic arguments" do
|
|
87
90
|
it "call(#{fmt}, #{params.join(',')})" do
|
88
91
|
buf = FFI::Buffer.new :long_long, 3
|
89
92
|
LibTest.pack_varargs(buf, fmt, *params)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
+
verify(buf, 0, v1)
|
94
|
+
verify(buf, 8, v2)
|
95
|
+
verify(buf, 16, v3)
|
93
96
|
end
|
94
97
|
end
|
95
98
|
end
|
@@ -97,4 +100,4 @@ describe "Function with variadic arguments" do
|
|
97
100
|
end
|
98
101
|
end
|
99
102
|
end
|
100
|
-
end
|
103
|
+
end
|
data/tasks/rdoc.rake
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 11
|
10
|
+
version: 1.0.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Wayne Meissner
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-11-13 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: |-
|