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/callback_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"))
|
@@ -29,7 +18,7 @@ describe "Callback" do
|
|
29
18
|
# cmp = proc do |p1, p2| args.push(p1.get_int(0)); args.push(p2.get_int(0)); 0; end
|
30
19
|
# # this is a bit dodgey, as it relies on qsort passing the args in order
|
31
20
|
# LibC.qsort(p, 2, 4, cmp)
|
32
|
-
# args.should
|
21
|
+
# args.should == [ 1, 2 ]
|
33
22
|
# end
|
34
23
|
#
|
35
24
|
# it "Block can be substituted for Callback as last argument" do
|
@@ -42,7 +31,7 @@ describe "Callback" do
|
|
42
31
|
# args.push(p2.get_int(0))
|
43
32
|
# 0
|
44
33
|
# end
|
45
|
-
# args.should
|
34
|
+
# args.should == [ 1, 2 ]
|
46
35
|
# end
|
47
36
|
module LibTest
|
48
37
|
extend FFI::Library
|
@@ -96,138 +85,138 @@ describe "Callback" do
|
|
96
85
|
|
97
86
|
end
|
98
87
|
it "returning :char (0)" do
|
99
|
-
LibTest.testCallbackVrS8 { 0 }.should
|
88
|
+
LibTest.testCallbackVrS8 { 0 }.should == 0
|
100
89
|
end
|
101
90
|
it "returning :char (127)" do
|
102
|
-
LibTest.testCallbackVrS8 { 127 }.should
|
91
|
+
LibTest.testCallbackVrS8 { 127 }.should == 127
|
103
92
|
end
|
104
93
|
it "returning :char (-128)" do
|
105
|
-
LibTest.testCallbackVrS8 { -128 }.should
|
94
|
+
LibTest.testCallbackVrS8 { -128 }.should == -128
|
106
95
|
end
|
107
96
|
# test wrap around
|
108
97
|
it "returning :char (128)" do
|
109
|
-
LibTest.testCallbackVrS8 { 128 }.should
|
98
|
+
LibTest.testCallbackVrS8 { 128 }.should == -128
|
110
99
|
end
|
111
100
|
it "returning :char (255)" do
|
112
|
-
LibTest.testCallbackVrS8 { 0xff }.should
|
101
|
+
LibTest.testCallbackVrS8 { 0xff }.should == -1
|
113
102
|
end
|
114
103
|
it "returning :uchar (0)" do
|
115
|
-
LibTest.testCallbackVrU8 { 0 }.should
|
104
|
+
LibTest.testCallbackVrU8 { 0 }.should == 0
|
116
105
|
end
|
117
106
|
it "returning :uchar (0xff)" do
|
118
|
-
LibTest.testCallbackVrU8 { 0xff }.should
|
107
|
+
LibTest.testCallbackVrU8 { 0xff }.should == 0xff
|
119
108
|
end
|
120
109
|
it "returning :uchar (-1)" do
|
121
|
-
LibTest.testCallbackVrU8 { -1 }.should
|
110
|
+
LibTest.testCallbackVrU8 { -1 }.should == 0xff
|
122
111
|
end
|
123
112
|
it "returning :uchar (128)" do
|
124
|
-
LibTest.testCallbackVrU8 { 128 }.should
|
113
|
+
LibTest.testCallbackVrU8 { 128 }.should == 128
|
125
114
|
end
|
126
115
|
it "returning :uchar (-128)" do
|
127
|
-
LibTest.testCallbackVrU8 { -128 }.should
|
116
|
+
LibTest.testCallbackVrU8 { -128 }.should == 128
|
128
117
|
end
|
129
118
|
it "returning :short (0)" do
|
130
|
-
LibTest.testCallbackVrS16 { 0 }.should
|
119
|
+
LibTest.testCallbackVrS16 { 0 }.should == 0
|
131
120
|
end
|
132
121
|
it "returning :short (0x7fff)" do
|
133
|
-
LibTest.testCallbackVrS16 { 0x7fff }.should
|
122
|
+
LibTest.testCallbackVrS16 { 0x7fff }.should == 0x7fff
|
134
123
|
end
|
135
124
|
# test wrap around
|
136
125
|
it "returning :short (0x8000)" do
|
137
|
-
LibTest.testCallbackVrS16 { 0x8000 }.should
|
126
|
+
LibTest.testCallbackVrS16 { 0x8000 }.should == -0x8000
|
138
127
|
end
|
139
128
|
it "returning :short (0xffff)" do
|
140
|
-
LibTest.testCallbackVrS16 { 0xffff }.should
|
129
|
+
LibTest.testCallbackVrS16 { 0xffff }.should == -1
|
141
130
|
end
|
142
131
|
it "returning :ushort (0)" do
|
143
|
-
LibTest.testCallbackVrU16 { 0 }.should
|
132
|
+
LibTest.testCallbackVrU16 { 0 }.should == 0
|
144
133
|
end
|
145
134
|
it "returning :ushort (0x7fff)" do
|
146
|
-
LibTest.testCallbackVrU16 { 0x7fff }.should
|
135
|
+
LibTest.testCallbackVrU16 { 0x7fff }.should == 0x7fff
|
147
136
|
end
|
148
137
|
it "returning :ushort (0x8000)" do
|
149
|
-
LibTest.testCallbackVrU16 { 0x8000 }.should
|
138
|
+
LibTest.testCallbackVrU16 { 0x8000 }.should == 0x8000
|
150
139
|
end
|
151
140
|
it "returning :ushort (0xffff)" do
|
152
|
-
LibTest.testCallbackVrU16 { 0xffff }.should
|
141
|
+
LibTest.testCallbackVrU16 { 0xffff }.should == 0xffff
|
153
142
|
end
|
154
143
|
it "returning :ushort (-1)" do
|
155
|
-
LibTest.testCallbackVrU16 { -1 }.should
|
144
|
+
LibTest.testCallbackVrU16 { -1 }.should == 0xffff
|
156
145
|
end
|
157
146
|
it "returning :int (0)" do
|
158
|
-
LibTest.testCallbackVrS32 { 0 }.should
|
147
|
+
LibTest.testCallbackVrS32 { 0 }.should == 0
|
159
148
|
end
|
160
149
|
it "returning :int (0x7fffffff)" do
|
161
|
-
LibTest.testCallbackVrS32 { 0x7fffffff }.should
|
150
|
+
LibTest.testCallbackVrS32 { 0x7fffffff }.should == 0x7fffffff
|
162
151
|
end
|
163
152
|
# test wrap around
|
164
153
|
it "returning :int (-0x80000000)" do
|
165
|
-
LibTest.testCallbackVrS32 { -0x80000000 }.should
|
154
|
+
LibTest.testCallbackVrS32 { -0x80000000 }.should == -0x80000000
|
166
155
|
end
|
167
156
|
it "returning :int (-1)" do
|
168
|
-
LibTest.testCallbackVrS32 { -1 }.should
|
157
|
+
LibTest.testCallbackVrS32 { -1 }.should == -1
|
169
158
|
end
|
170
159
|
it "returning :uint (0)" do
|
171
|
-
LibTest.testCallbackVrU32 { 0 }.should
|
160
|
+
LibTest.testCallbackVrU32 { 0 }.should == 0
|
172
161
|
end
|
173
162
|
it "returning :uint (0x7fffffff)" do
|
174
|
-
LibTest.testCallbackVrU32 { 0x7fffffff }.should
|
163
|
+
LibTest.testCallbackVrU32 { 0x7fffffff }.should == 0x7fffffff
|
175
164
|
end
|
176
165
|
# test wrap around
|
177
166
|
it "returning :uint (0x80000000)" do
|
178
|
-
LibTest.testCallbackVrU32 { 0x80000000 }.should
|
167
|
+
LibTest.testCallbackVrU32 { 0x80000000 }.should == 0x80000000
|
179
168
|
end
|
180
169
|
it "returning :uint (0xffffffff)" do
|
181
|
-
LibTest.testCallbackVrU32 { 0xffffffff }.should
|
170
|
+
LibTest.testCallbackVrU32 { 0xffffffff }.should == 0xffffffff
|
182
171
|
end
|
183
172
|
it "returning :uint (-1)" do
|
184
|
-
LibTest.testCallbackVrU32 { -1 }.should
|
173
|
+
LibTest.testCallbackVrU32 { -1 }.should == 0xffffffff
|
185
174
|
end
|
186
175
|
it "returning :long (0)" do
|
187
|
-
LibTest.testCallbackVrL { 0 }.should
|
176
|
+
LibTest.testCallbackVrL { 0 }.should == 0
|
188
177
|
end
|
189
178
|
it "returning :long (0x7fffffff)" do
|
190
|
-
LibTest.testCallbackVrL { 0x7fffffff }.should
|
179
|
+
LibTest.testCallbackVrL { 0x7fffffff }.should == 0x7fffffff
|
191
180
|
end
|
192
181
|
# test wrap around
|
193
182
|
it "returning :long (-0x80000000)" do
|
194
|
-
LibTest.testCallbackVrL { -0x80000000 }.should
|
183
|
+
LibTest.testCallbackVrL { -0x80000000 }.should == -0x80000000
|
195
184
|
end
|
196
185
|
it "returning :long (-1)" do
|
197
|
-
LibTest.testCallbackVrL { -1 }.should
|
186
|
+
LibTest.testCallbackVrL { -1 }.should == -1
|
198
187
|
end
|
199
188
|
it "returning :ulong (0)" do
|
200
|
-
LibTest.testCallbackVrUL { 0 }.should
|
189
|
+
LibTest.testCallbackVrUL { 0 }.should == 0
|
201
190
|
end
|
202
191
|
it "returning :ulong (0x7fffffff)" do
|
203
|
-
LibTest.testCallbackVrUL { 0x7fffffff }.should
|
192
|
+
LibTest.testCallbackVrUL { 0x7fffffff }.should == 0x7fffffff
|
204
193
|
end
|
205
194
|
# test wrap around
|
206
195
|
it "returning :ulong (0x80000000)" do
|
207
|
-
LibTest.testCallbackVrUL { 0x80000000 }.should
|
196
|
+
LibTest.testCallbackVrUL { 0x80000000 }.should == 0x80000000
|
208
197
|
end
|
209
198
|
it "returning :ulong (0xffffffff)" do
|
210
|
-
LibTest.testCallbackVrUL { 0xffffffff }.should
|
199
|
+
LibTest.testCallbackVrUL { 0xffffffff }.should == 0xffffffff
|
211
200
|
end
|
212
201
|
it "Callback returning :ulong (-1)" do
|
213
202
|
if FFI::Platform::LONG_SIZE == 32
|
214
|
-
LibTest.testCallbackVrUL { -1 }.should
|
203
|
+
LibTest.testCallbackVrUL { -1 }.should == 0xffffffff
|
215
204
|
else
|
216
|
-
LibTest.testCallbackVrUL { -1 }.should
|
205
|
+
LibTest.testCallbackVrUL { -1 }.should == 0xffffffffffffffff
|
217
206
|
end
|
218
207
|
end
|
219
208
|
it "returning :long_long (0)" do
|
220
|
-
LibTest.testCallbackVrS64 { 0 }.should
|
209
|
+
LibTest.testCallbackVrS64 { 0 }.should == 0
|
221
210
|
end
|
222
211
|
it "returning :long_long (0x7fffffffffffffff)" do
|
223
|
-
LibTest.testCallbackVrS64 { 0x7fffffffffffffff }.should
|
212
|
+
LibTest.testCallbackVrS64 { 0x7fffffffffffffff }.should == 0x7fffffffffffffff
|
224
213
|
end
|
225
214
|
# test wrap around
|
226
215
|
it "returning :long_long (-0x8000000000000000)" do
|
227
|
-
LibTest.testCallbackVrS64 { -0x8000000000000000 }.should
|
216
|
+
LibTest.testCallbackVrS64 { -0x8000000000000000 }.should == -0x8000000000000000
|
228
217
|
end
|
229
218
|
it "returning :long_long (-1)" do
|
230
|
-
LibTest.testCallbackVrS64 { -1 }.should
|
219
|
+
LibTest.testCallbackVrS64 { -1 }.should == -1
|
231
220
|
end
|
232
221
|
it "returning bool" do
|
233
222
|
LibTest.testCallbackVrZ { true }.should be_true
|
@@ -237,7 +226,7 @@ describe "Callback" do
|
|
237
226
|
end
|
238
227
|
it "returning :pointer (MemoryPointer)" do
|
239
228
|
p = FFI::MemoryPointer.new :long
|
240
|
-
LibTest.testCallbackVrP { p }.should
|
229
|
+
LibTest.testCallbackVrP { p }.should == p
|
241
230
|
end
|
242
231
|
|
243
232
|
|
@@ -247,9 +236,9 @@ describe "Callback" do
|
|
247
236
|
s[:s32] = 0x1eefbeef
|
248
237
|
s[:f32] = 1.234567
|
249
238
|
ret = LibTest.testCallbackVrT { s }
|
250
|
-
ret[:s8].should
|
251
|
-
ret[:f32].should
|
252
|
-
ret[:s32].should
|
239
|
+
ret[:s8].should == s[:s8]
|
240
|
+
ret[:f32].should == s[:f32]
|
241
|
+
ret[:s32].should == s[:s32]
|
253
242
|
|
254
243
|
end
|
255
244
|
|
@@ -270,7 +259,7 @@ describe "Callback" do
|
|
270
259
|
it "global variable" do
|
271
260
|
proc = Proc.new { 0x1e }
|
272
261
|
LibTest.cbVrS8 = proc
|
273
|
-
LibTest.testGVarCallbackVrS8(LibTest.pVrS8).should
|
262
|
+
LibTest.testGVarCallbackVrS8(LibTest.pVrS8).should == 0x1e
|
274
263
|
end
|
275
264
|
|
276
265
|
describe "When the callback is considered optional by the underlying library" do
|
@@ -286,7 +275,7 @@ describe "Callback" do
|
|
286
275
|
ffi_lib TestLibrary::PATH
|
287
276
|
attach_function :testAnonymousCallbackVrS8, :testClosureVrB, [ callback([ ], :char) ], :char
|
288
277
|
end
|
289
|
-
LibTest.testAnonymousCallbackVrS8 { 0 }.should
|
278
|
+
LibTest.testAnonymousCallbackVrS8 { 0 }.should == 0
|
290
279
|
end
|
291
280
|
end
|
292
281
|
|
@@ -324,7 +313,7 @@ describe "Callback" do
|
|
324
313
|
end
|
325
314
|
|
326
315
|
val = LibTest.testReturnsCallback(lookup_proc, 0x1234)
|
327
|
-
val.should
|
316
|
+
val.should == 0x1234 * 2
|
328
317
|
lookup_proc_called.should be_true
|
329
318
|
return_proc_called.should be_true
|
330
319
|
end
|
@@ -346,7 +335,7 @@ describe "Callback" do
|
|
346
335
|
end
|
347
336
|
end
|
348
337
|
|
349
|
-
LibTest.testReturnsCallback_2(MethodCallback.method(:lookup), 0x1234).should
|
338
|
+
LibTest.testReturnsCallback_2(MethodCallback.method(:lookup), 0x1234).should == 0x2468
|
350
339
|
end
|
351
340
|
|
352
341
|
it 'should not blow up when a callback takes a callback as argument' do
|
@@ -377,7 +366,7 @@ describe "Callback" do
|
|
377
366
|
cb.call(val)
|
378
367
|
end
|
379
368
|
val = LibTest.testCallbackAsArgument(callback_with_callback_arg, callback_arg, 0xff1)
|
380
|
-
val.should
|
369
|
+
val.should == 0xff1 * 2
|
381
370
|
callback_arg_called.should be_true
|
382
371
|
callback_with_callback_arg_called.should be_true
|
383
372
|
end
|
@@ -389,7 +378,7 @@ describe "Callback" do
|
|
389
378
|
attach_function :testReturnsFunctionPointer, [ ], :funcptr
|
390
379
|
end
|
391
380
|
f = LibTest.testReturnsFunctionPointer
|
392
|
-
f.call(3).should
|
381
|
+
f.call(3).should == 6
|
393
382
|
end
|
394
383
|
end
|
395
384
|
|
@@ -446,83 +435,83 @@ describe "Callback with " do
|
|
446
435
|
it ":char (0) argument" do
|
447
436
|
v = 0xdeadbeef
|
448
437
|
LibTest.testCallbackCrV(0) { |i| v = i }
|
449
|
-
v.should
|
438
|
+
v.should == 0
|
450
439
|
end
|
451
440
|
it ":char (127) argument" do
|
452
441
|
v = 0xdeadbeef
|
453
442
|
LibTest.testCallbackCrV(127) { |i| v = i }
|
454
|
-
v.should
|
443
|
+
v.should == 127
|
455
444
|
end
|
456
445
|
it ":char (-128) argument" do
|
457
446
|
v = 0xdeadbeef
|
458
447
|
LibTest.testCallbackCrV(-128) { |i| v = i }
|
459
|
-
v.should
|
448
|
+
v.should == -128
|
460
449
|
end
|
461
450
|
it ":char (-1) argument" do
|
462
451
|
v = 0xdeadbeef
|
463
452
|
LibTest.testCallbackCrV(-1) { |i| v = i }
|
464
|
-
v.should
|
453
|
+
v.should == -1
|
465
454
|
end
|
466
455
|
it ":uchar (0) argument" do
|
467
456
|
v = 0xdeadbeef
|
468
457
|
LibTest.testCallbackU8rV(0) { |i| v = i }
|
469
|
-
v.should
|
458
|
+
v.should == 0
|
470
459
|
end
|
471
460
|
it ":uchar (127) argument" do
|
472
461
|
v = 0xdeadbeef
|
473
462
|
LibTest.testCallbackU8rV(127) { |i| v = i }
|
474
|
-
v.should
|
463
|
+
v.should == 127
|
475
464
|
end
|
476
465
|
it ":uchar (128) argument" do
|
477
466
|
v = 0xdeadbeef
|
478
467
|
LibTest.testCallbackU8rV(128) { |i| v = i }
|
479
|
-
v.should
|
468
|
+
v.should == 128
|
480
469
|
end
|
481
470
|
it ":uchar (255) argument" do
|
482
471
|
v = 0xdeadbeef
|
483
472
|
LibTest.testCallbackU8rV(255) { |i| v = i }
|
484
|
-
v.should
|
473
|
+
v.should == 255
|
485
474
|
end
|
486
475
|
|
487
476
|
it ":short (0) argument" do
|
488
477
|
v = 0xdeadbeef
|
489
478
|
LibTest.testCallbackSrV(0) { |i| v = i }
|
490
|
-
v.should
|
479
|
+
v.should == 0
|
491
480
|
end
|
492
481
|
it ":short (0x7fff) argument" do
|
493
482
|
v = 0xdeadbeef
|
494
483
|
LibTest.testCallbackSrV(0x7fff) { |i| v = i }
|
495
|
-
v.should
|
484
|
+
v.should == 0x7fff
|
496
485
|
end
|
497
486
|
it ":short (-0x8000) argument" do
|
498
487
|
v = 0xdeadbeef
|
499
488
|
LibTest.testCallbackSrV(-0x8000) { |i| v = i }
|
500
|
-
v.should
|
489
|
+
v.should == -0x8000
|
501
490
|
end
|
502
491
|
it ":short (-1) argument" do
|
503
492
|
v = 0xdeadbeef
|
504
493
|
LibTest.testCallbackSrV(-1) { |i| v = i }
|
505
|
-
v.should
|
494
|
+
v.should == -1
|
506
495
|
end
|
507
496
|
it ":ushort (0) argument" do
|
508
497
|
v = 0xdeadbeef
|
509
498
|
LibTest.testCallbackU16rV(0) { |i| v = i }
|
510
|
-
v.should
|
499
|
+
v.should == 0
|
511
500
|
end
|
512
501
|
it ":ushort (0x7fff) argument" do
|
513
502
|
v = 0xdeadbeef
|
514
503
|
LibTest.testCallbackU16rV(0x7fff) { |i| v = i }
|
515
|
-
v.should
|
504
|
+
v.should == 0x7fff
|
516
505
|
end
|
517
506
|
it ":ushort (0x8000) argument" do
|
518
507
|
v = 0xdeadbeef
|
519
508
|
LibTest.testCallbackU16rV(0x8000) { |i| v = i }
|
520
|
-
v.should
|
509
|
+
v.should == 0x8000
|
521
510
|
end
|
522
511
|
it ":ushort (0xffff) argument" do
|
523
512
|
v = 0xdeadbeef
|
524
513
|
LibTest.testCallbackU16rV(0xffff) { |i| v = i }
|
525
|
-
v.should
|
514
|
+
v.should == 0xffff
|
526
515
|
end
|
527
516
|
it ":bool (true) argument" do
|
528
517
|
v = false
|
@@ -532,107 +521,107 @@ describe "Callback with " do
|
|
532
521
|
it ":int (0) argument" do
|
533
522
|
v = 0xdeadbeef
|
534
523
|
LibTest.testCallbackIrV(0) { |i| v = i }
|
535
|
-
v.should
|
524
|
+
v.should == 0
|
536
525
|
end
|
537
526
|
it ":int (0x7fffffff) argument" do
|
538
527
|
v = 0xdeadbeef
|
539
528
|
LibTest.testCallbackIrV(0x7fffffff) { |i| v = i }
|
540
|
-
v.should
|
529
|
+
v.should == 0x7fffffff
|
541
530
|
end
|
542
531
|
it ":int (-0x80000000) argument" do
|
543
532
|
v = 0xdeadbeef
|
544
533
|
LibTest.testCallbackIrV(-0x80000000) { |i| v = i }
|
545
|
-
v.should
|
534
|
+
v.should == -0x80000000
|
546
535
|
end
|
547
536
|
it ":int (-1) argument" do
|
548
537
|
v = 0xdeadbeef
|
549
538
|
LibTest.testCallbackIrV(-1) { |i| v = i }
|
550
|
-
v.should
|
539
|
+
v.should == -1
|
551
540
|
end
|
552
541
|
it ":uint (0) argument" do
|
553
542
|
v = 0xdeadbeef
|
554
543
|
LibTest.testCallbackU32rV(0) { |i| v = i }
|
555
|
-
v.should
|
544
|
+
v.should == 0
|
556
545
|
end
|
557
546
|
it ":uint (0x7fffffff) argument" do
|
558
547
|
v = 0xdeadbeef
|
559
548
|
LibTest.testCallbackU32rV(0x7fffffff) { |i| v = i }
|
560
|
-
v.should
|
549
|
+
v.should == 0x7fffffff
|
561
550
|
end
|
562
551
|
it ":uint (0x80000000) argument" do
|
563
552
|
v = 0xdeadbeef
|
564
553
|
LibTest.testCallbackU32rV(0x80000000) { |i| v = i }
|
565
|
-
v.should
|
554
|
+
v.should == 0x80000000
|
566
555
|
end
|
567
556
|
it ":uint (0xffffffff) argument" do
|
568
557
|
v = 0xdeadbeef
|
569
558
|
LibTest.testCallbackU32rV(0xffffffff) { |i| v = i }
|
570
|
-
v.should
|
559
|
+
v.should == 0xffffffff
|
571
560
|
end
|
572
561
|
it ":long (0) argument" do
|
573
562
|
v = 0xdeadbeef
|
574
563
|
LibTest.testCallbackLrV(0) { |i| v = i }
|
575
|
-
v.should
|
564
|
+
v.should == 0
|
576
565
|
end
|
577
566
|
it ":long (0x7fffffff) argument" do
|
578
567
|
v = 0xdeadbeef
|
579
568
|
LibTest.testCallbackLrV(0x7fffffff) { |i| v = i }
|
580
|
-
v.should
|
569
|
+
v.should == 0x7fffffff
|
581
570
|
end
|
582
571
|
it ":long (-0x80000000) argument" do
|
583
572
|
v = 0xdeadbeef
|
584
573
|
LibTest.testCallbackLrV(-0x80000000) { |i| v = i }
|
585
|
-
v.should
|
574
|
+
v.should == -0x80000000
|
586
575
|
end
|
587
576
|
it ":long (-1) argument" do
|
588
577
|
v = 0xdeadbeef
|
589
578
|
LibTest.testCallbackLrV(-1) { |i| v = i }
|
590
|
-
v.should
|
579
|
+
v.should == -1
|
591
580
|
end
|
592
581
|
it ":ulong (0) argument" do
|
593
582
|
v = 0xdeadbeef
|
594
583
|
LibTest.testCallbackULrV(0) { |i| v = i }
|
595
|
-
v.should
|
584
|
+
v.should == 0
|
596
585
|
end
|
597
586
|
it ":ulong (0x7fffffff) argument" do
|
598
587
|
v = 0xdeadbeef
|
599
588
|
LibTest.testCallbackULrV(0x7fffffff) { |i| v = i }
|
600
|
-
v.should
|
589
|
+
v.should == 0x7fffffff
|
601
590
|
end
|
602
591
|
it ":ulong (0x80000000) argument" do
|
603
592
|
v = 0xdeadbeef
|
604
593
|
LibTest.testCallbackULrV(0x80000000) { |i| v = i }
|
605
|
-
v.should
|
594
|
+
v.should == 0x80000000
|
606
595
|
end
|
607
596
|
it ":ulong (0xffffffff) argument" do
|
608
597
|
v = 0xdeadbeef
|
609
598
|
LibTest.testCallbackULrV(0xffffffff) { |i| v = i }
|
610
|
-
v.should
|
599
|
+
v.should == 0xffffffff
|
611
600
|
end
|
612
601
|
it ":long_long (0) argument" do
|
613
602
|
v = 0xdeadbeef
|
614
603
|
LibTest.testCallbackLLrV(0) { |i| v = i }
|
615
|
-
v.should
|
604
|
+
v.should == 0
|
616
605
|
end
|
617
606
|
it ":long_long (0x7fffffffffffffff) argument" do
|
618
607
|
v = 0xdeadbeef
|
619
608
|
LibTest.testCallbackLLrV(0x7fffffffffffffff) { |i| v = i }
|
620
|
-
v.should
|
609
|
+
v.should == 0x7fffffffffffffff
|
621
610
|
end
|
622
611
|
it ":long_long (-0x8000000000000000) argument" do
|
623
612
|
v = 0xdeadbeef
|
624
613
|
LibTest.testCallbackLLrV(-0x8000000000000000) { |i| v = i }
|
625
|
-
v.should
|
614
|
+
v.should == -0x8000000000000000
|
626
615
|
end
|
627
616
|
it ":long_long (-1) argument" do
|
628
617
|
v = 0xdeadbeef
|
629
618
|
LibTest.testCallbackLLrV(-1) { |i| v = i }
|
630
|
-
v.should
|
619
|
+
v.should == -1
|
631
620
|
end
|
632
621
|
it ":string argument" do
|
633
622
|
v = nil
|
634
623
|
LibTest.testCallbackArV("Hello, World") { |i| v = i }
|
635
|
-
v.should
|
624
|
+
v.should == "Hello, World"
|
636
625
|
end
|
637
626
|
it ":string (nil) argument" do
|
638
627
|
v = "Hello, World"
|
@@ -643,18 +632,18 @@ describe "Callback with " do
|
|
643
632
|
v = nil
|
644
633
|
magic = FFI::Pointer.new(0xdeadbeef)
|
645
634
|
LibTest.testCallbackPrV(magic) { |i| v = i }
|
646
|
-
v.should
|
635
|
+
v.should == magic
|
647
636
|
end
|
648
637
|
it ":pointer (nil) argument" do
|
649
638
|
v = "Hello, World"
|
650
639
|
LibTest.testCallbackPrV(nil) { |i| v = i }
|
651
|
-
v.should
|
640
|
+
v.should == FFI::Pointer::NULL
|
652
641
|
end
|
653
642
|
it "struct by reference argument" do
|
654
643
|
v = nil
|
655
644
|
magic = LibTest::S8F32S32.new
|
656
645
|
LibTest.testCallbackYrV(magic) { |i| v = i }
|
657
|
-
v.class.should
|
646
|
+
v.class.should == magic.class
|
658
647
|
v.pointer == magic.pointer
|
659
648
|
end
|
660
649
|
|
@@ -662,7 +651,7 @@ describe "Callback with " do
|
|
662
651
|
v = LibTest::S8F32S32.new
|
663
652
|
LibTest.testCallbackYrV(nil) { |i| v = i }
|
664
653
|
v.is_a?(FFI::Struct).should be_true
|
665
|
-
v.pointer.should
|
654
|
+
v.pointer.should == FFI::Pointer::NULL
|
666
655
|
end
|
667
656
|
|
668
657
|
it "varargs parameters are rejected" do
|