ffi 1.2.1-x86-mingw32 → 1.3.0-x86-mingw32
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/README.md +10 -5
- data/ext/ffi_c/ArrayType.c +6 -2
- data/ext/ffi_c/Buffer.c +3 -1
- data/ext/ffi_c/Call.c +12 -21
- data/ext/ffi_c/FunctionInfo.c +27 -2
- data/ext/ffi_c/MappedType.c +1 -2
- data/ext/ffi_c/MemoryPointer.c +35 -4
- data/ext/ffi_c/Pointer.c +5 -4
- data/ext/ffi_c/Struct.c +125 -8
- data/ext/ffi_c/StructByReference.c +33 -0
- data/ext/ffi_c/StructByValue.c +2 -2
- data/ext/ffi_c/StructLayout.c +135 -1
- data/ext/ffi_c/Type.c +1 -0
- data/ext/ffi_c/extconf.rb +1 -1
- data/ffi.gemspec +1 -1
- data/lib/1.8/ffi_c.so +0 -0
- data/lib/1.9/ffi_c.so +0 -0
- data/lib/ffi.rb +2 -1
- data/lib/ffi/library.rb +2 -0
- data/lib/ffi/managedstruct.rb +37 -37
- data/lib/ffi/struct.rb +74 -1
- data/lib/ffi/struct_layout_builder.rb +50 -1
- data/lib/ffi/tools/generator.rb +2 -0
- data/lib/ffi/tools/generator_task.rb +1 -0
- data/lib/ffi/tools/types_generator.rb +2 -0
- data/libtest/Benchmark.c +1 -15
- data/libtest/BoolTest.c +2 -16
- data/libtest/BufferTest.c +3 -17
- data/libtest/ClosureTest.c +1 -15
- data/libtest/EnumTest.c +1 -15
- data/libtest/FunctionTest.c +2 -16
- data/libtest/GlobalVariable.c +2 -16
- data/libtest/LastErrorTest.c +2 -16
- data/libtest/NumberTest.c +1 -15
- data/libtest/PointerTest.c +1 -15
- data/libtest/ReferenceTest.c +1 -15
- data/libtest/StringTest.c +1 -15
- data/libtest/StructTest.c +1 -15
- data/libtest/UnionTest.c +1 -15
- data/libtest/VariadicTest.c +2 -16
- data/spec/ffi/async_callback_spec.rb +3 -14
- data/spec/ffi/bool_spec.rb +7 -18
- data/spec/ffi/buffer_spec.rb +26 -37
- data/spec/ffi/callback_spec.rb +96 -107
- data/spec/ffi/custom_param_type.rb +2 -13
- data/spec/ffi/custom_type_spec.rb +1 -12
- data/spec/ffi/dup_spec.rb +7 -18
- data/spec/ffi/enum_spec.rb +128 -139
- data/spec/ffi/errno_spec.rb +2 -13
- data/spec/ffi/ffi_spec.rb +4 -15
- data/spec/ffi/function_spec.rb +6 -17
- data/spec/ffi/library_spec.rb +26 -26
- data/spec/ffi/long_double.rb +1 -12
- data/spec/ffi/managed_struct_spec.rb +3 -18
- data/spec/ffi/number_spec.rb +32 -43
- data/spec/ffi/pointer_spec.rb +7 -22
- 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 +10 -12
- data/spec/ffi/string_spec.rb +9 -20
- data/spec/ffi/strptr_spec.rb +2 -13
- data/spec/ffi/struct_callback_spec.rb +3 -14
- data/spec/ffi/struct_initialize_spec.rb +3 -14
- data/spec/ffi/struct_packed_spec.rb +7 -18
- data/spec/ffi/struct_spec.rb +93 -104
- data/spec/ffi/typedef_spec.rb +5 -16
- data/spec/ffi/union_spec.rb +4 -15
- data/spec/ffi/variadic_spec.rb +7 -18
- metadata +4 -4
data/spec/ffi/typedef_spec.rb
CHANGED
@@ -1,17 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# This file is part of ruby-ffi.
|
3
|
-
#
|
4
|
-
# This code is free software: you can redistribute it and/or modify it under
|
5
|
-
# the terms of the GNU Lesser General Public License version 3 only, as
|
6
|
-
# published by the Free Software Foundation.
|
7
|
-
#
|
8
|
-
# This code is distributed in the hope that it will be useful, but WITHOUT
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
11
|
-
# version 3 for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU Lesser General Public License
|
14
|
-
# version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
3
|
+
# For licensing, see LICENSE.SPECS
|
15
4
|
#
|
16
5
|
|
17
6
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
@@ -23,7 +12,7 @@ describe "Custom type definitions" do
|
|
23
12
|
typedef :uint, :fubar_t
|
24
13
|
attach_function :ret_u32, [ :fubar_t ], :fubar_t
|
25
14
|
end
|
26
|
-
CustomTypedef.ret_u32(0x12345678).should
|
15
|
+
CustomTypedef.ret_u32(0x12345678).should == 0x12345678
|
27
16
|
end
|
28
17
|
it "variadic invoker with custom typedef" do
|
29
18
|
module VariadicCustomTypedef
|
@@ -34,7 +23,7 @@ describe "Custom type definitions" do
|
|
34
23
|
end
|
35
24
|
buf = FFI::Buffer.new :uint, 10
|
36
25
|
VariadicCustomTypedef.pack_varargs(buf, "i", :fubar_t, 0x12345678)
|
37
|
-
buf.get_int64(0).should
|
26
|
+
buf.get_int64(0).should == 0x12345678
|
38
27
|
end
|
39
28
|
it "Callback with custom typedef parameter" do
|
40
29
|
module CallbackCustomTypedef
|
@@ -46,7 +35,7 @@ describe "Custom type definitions" do
|
|
46
35
|
end
|
47
36
|
i = 0
|
48
37
|
CallbackCustomTypedef.testCallbackU32rV(0xdeadbeef) { |v| i = v }
|
49
|
-
i.should
|
38
|
+
i.should == 0xdeadbeef
|
50
39
|
end
|
51
40
|
module StructCustomTypedef
|
52
41
|
extend FFI::Library
|
@@ -59,7 +48,7 @@ describe "Custom type definitions" do
|
|
59
48
|
it "Struct with custom typedef field" do
|
60
49
|
s = StructCustomTypedef::S.new
|
61
50
|
s[:a] = 0x12345678
|
62
|
-
s.pointer.get_uint(0).should
|
51
|
+
s.pointer.get_uint(0).should == 0x12345678
|
63
52
|
end
|
64
53
|
|
65
54
|
it "attach_function after a typedef should not reject normal types" do
|
data/spec/ffi/union_spec.rb
CHANGED
@@ -1,17 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# This file is part of ruby-ffi.
|
3
|
-
#
|
4
|
-
# This code is free software: you can redistribute it and/or modify it under
|
5
|
-
# the terms of the GNU Lesser General Public License version 3 only, as
|
6
|
-
# published by the Free Software Foundation.
|
7
|
-
#
|
8
|
-
# This code is distributed in the hope that it will be useful, but WITHOUT
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
11
|
-
# version 3 for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU Lesser General Public License
|
14
|
-
# version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
3
|
+
# For licensing, see LICENSE.SPECS
|
15
4
|
#
|
16
5
|
|
17
6
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
@@ -56,7 +45,7 @@ describe 'Union' do
|
|
56
45
|
if k == 'f32' or k == 'f64'
|
57
46
|
(@u[type[1]] - LibTest.send("union_align_#{k}", @u.to_ptr)).abs.should < 0.00001
|
58
47
|
else
|
59
|
-
@u[type[1]].should
|
48
|
+
@u[type[1]].should == LibTest.send("union_align_#{k}", @u.to_ptr)
|
60
49
|
end
|
61
50
|
end
|
62
51
|
end
|
@@ -66,11 +55,11 @@ describe 'Union' do
|
|
66
55
|
if k == 'f32' or k == 'f64'
|
67
56
|
(@u[type[1]] - type[2]).abs.should < 0.00001
|
68
57
|
else
|
69
|
-
@u[type[1]].should
|
58
|
+
@u[type[1]].should == type[2]
|
70
59
|
end
|
71
60
|
end
|
72
61
|
end
|
73
62
|
it 'should return a size equals to the size of the biggest field' do
|
74
|
-
LibTest::TestUnion.size.should
|
63
|
+
LibTest::TestUnion.size.should == LibTest.union_size
|
75
64
|
end
|
76
65
|
end
|
data/spec/ffi/variadic_spec.rb
CHANGED
@@ -1,17 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# This file is part of ruby-ffi.
|
3
|
-
#
|
4
|
-
# This code is free software: you can redistribute it and/or modify it under
|
5
|
-
# the terms of the GNU Lesser General Public License version 3 only, as
|
6
|
-
# published by the Free Software Foundation.
|
7
|
-
#
|
8
|
-
# This code is distributed in the hope that it will be useful, but WITHOUT
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
11
|
-
# version 3 for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU Lesser General Public License
|
14
|
-
# version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
3
|
+
# For licensing, see LICENSE.SPECS
|
15
4
|
#
|
16
5
|
|
17
6
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
@@ -25,28 +14,28 @@ describe "Function with variadic arguments" do
|
|
25
14
|
it "call variadic with (:char (#{i})) argument" do
|
26
15
|
buf = FFI::Buffer.new :long_long
|
27
16
|
LibTest.pack_varargs(buf, "c", :char, i)
|
28
|
-
buf.get_int64(0).should
|
17
|
+
buf.get_int64(0).should == i
|
29
18
|
end
|
30
19
|
end
|
31
20
|
[ 0, 0x7f, 0x80, 0xff ].each do |i|
|
32
21
|
it "call variadic with (:uchar (#{i})) argument" do
|
33
22
|
buf = FFI::Buffer.new :long_long
|
34
23
|
LibTest.pack_varargs(buf, "C", :uchar, i)
|
35
|
-
buf.get_int64(0).should
|
24
|
+
buf.get_int64(0).should == i
|
36
25
|
end
|
37
26
|
end
|
38
27
|
[ 0, 1.234567, 9.87654321 ].each do |v|
|
39
28
|
it "call variadic with (:float (#{v})) argument" do
|
40
29
|
buf = FFI::Buffer.new :long_long
|
41
30
|
LibTest.pack_varargs(buf, "f", :float, v.to_f)
|
42
|
-
buf.get_float64(0).should
|
31
|
+
buf.get_float64(0).should == v
|
43
32
|
end
|
44
33
|
end
|
45
34
|
[ 0, 1.234567, 9.87654321 ].each do |v|
|
46
35
|
it "call variadic with (:double (#{v})) argument" do
|
47
36
|
buf = FFI::Buffer.new :long_long
|
48
37
|
LibTest.pack_varargs(buf, "f", :double, v.to_f)
|
49
|
-
buf.get_float64(0).should
|
38
|
+
buf.get_float64(0).should == v
|
50
39
|
end
|
51
40
|
end
|
52
41
|
|
@@ -73,9 +62,9 @@ describe "Function with variadic arguments" do
|
|
73
62
|
|
74
63
|
def verify(p, off, v)
|
75
64
|
if v.kind_of?(Float)
|
76
|
-
p.get_float64(off).should
|
65
|
+
p.get_float64(off).should == v
|
77
66
|
else
|
78
|
-
p.get_int64(off).should
|
67
|
+
p.get_int64(off).should == v
|
79
68
|
end
|
80
69
|
end
|
81
70
|
|
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: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 1.3.0
|
11
11
|
platform: x86-mingw32
|
12
12
|
authors:
|
13
13
|
- Wayne Meissner
|