ffi 1.0.9-x86-mingw32 → 1.0.12.pre-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.

Files changed (218) hide show
  1. data/Rakefile +16 -16
  2. data/ext/ffi_c/AbstractMemory.c +376 -14
  3. data/ext/ffi_c/AbstractMemory.h +8 -0
  4. data/ext/ffi_c/ArrayType.c +28 -0
  5. data/ext/ffi_c/Buffer.c +109 -25
  6. data/ext/ffi_c/Call.c +16 -5
  7. data/ext/ffi_c/ClosurePool.c +21 -8
  8. data/ext/ffi_c/DataConverter.c +29 -0
  9. data/ext/ffi_c/DynamicLibrary.c +71 -2
  10. data/ext/ffi_c/Function.c +122 -11
  11. data/ext/ffi_c/Function.h +6 -0
  12. data/ext/ffi_c/FunctionInfo.c +21 -1
  13. data/ext/ffi_c/LastError.c +24 -0
  14. data/ext/ffi_c/MappedType.c +22 -0
  15. data/ext/ffi_c/MemoryPointer.c +19 -1
  16. data/ext/ffi_c/MemoryPointer.h +6 -0
  17. data/ext/ffi_c/MethodHandle.c +26 -11
  18. data/ext/ffi_c/Platform.c +17 -3
  19. data/ext/ffi_c/Pointer.c +106 -0
  20. data/ext/ffi_c/Pointer.h +6 -0
  21. data/ext/ffi_c/Struct.c +10 -4
  22. data/ext/ffi_c/Struct.h +2 -1
  23. data/ext/ffi_c/StructByReference.c +8 -0
  24. data/ext/ffi_c/StructByValue.c +8 -0
  25. data/ext/ffi_c/StructLayout.c +8 -2
  26. data/ext/ffi_c/Thread.c +131 -1
  27. data/ext/ffi_c/Thread.h +6 -0
  28. data/ext/ffi_c/Type.c +111 -17
  29. data/ext/ffi_c/Types.c +9 -2
  30. data/ext/ffi_c/Types.h +4 -0
  31. data/ext/ffi_c/Variadic.c +13 -4
  32. data/ext/ffi_c/compat.h +8 -0
  33. data/ext/ffi_c/endian.h +10 -1
  34. data/ext/ffi_c/extconf.rb +51 -35
  35. data/ext/ffi_c/ffi.c +5 -0
  36. data/ext/ffi_c/libffi.darwin.mk +15 -15
  37. data/ext/ffi_c/libffi.gnu.mk +3 -3
  38. data/ext/ffi_c/libffi.mk +4 -4
  39. data/ext/ffi_c/libffi.vc.mk +26 -0
  40. data/ext/ffi_c/libffi.vc64.mk +26 -0
  41. data/ext/ffi_c/libffi/ChangeLog +541 -0
  42. data/ext/ffi_c/libffi/ChangeLog.libffi +13 -87
  43. data/ext/ffi_c/libffi/LICENSE +3 -3
  44. data/ext/ffi_c/libffi/Makefile.am +41 -32
  45. data/ext/ffi_c/libffi/Makefile.in +95 -66
  46. data/ext/ffi_c/libffi/Makefile.vc +141 -0
  47. data/ext/ffi_c/libffi/Makefile.vc64 +141 -0
  48. data/ext/ffi_c/libffi/README +40 -4
  49. data/ext/ffi_c/libffi/aclocal.m4 +729 -7854
  50. data/ext/ffi_c/libffi/build-ios.sh +67 -0
  51. data/ext/ffi_c/libffi/compile +11 -10
  52. data/ext/ffi_c/libffi/config.guess +4 -1
  53. data/ext/ffi_c/libffi/config.sub +6 -3
  54. data/ext/ffi_c/libffi/configure +6264 -6354
  55. data/ext/ffi_c/libffi/configure.ac +155 -63
  56. data/ext/ffi_c/libffi/depcomp +81 -35
  57. data/ext/ffi_c/libffi/doc/libffi.info +78 -18
  58. data/ext/ffi_c/libffi/doc/libffi.texi +64 -5
  59. data/ext/ffi_c/libffi/doc/stamp-vti +4 -4
  60. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  61. data/ext/ffi_c/libffi/fficonfig.h.in +18 -0
  62. data/ext/ffi_c/libffi/fficonfig.hw +57 -0
  63. data/ext/ffi_c/libffi/include/Makefile.in +21 -3
  64. data/ext/ffi_c/libffi/include/ffi.h.in +42 -14
  65. data/ext/ffi_c/libffi/include/ffi.h.vc +427 -0
  66. data/ext/ffi_c/libffi/include/ffi.h.vc64 +427 -0
  67. data/ext/ffi_c/libffi/include/ffi_common.h +9 -5
  68. data/ext/ffi_c/libffi/install-sh +364 -167
  69. data/ext/ffi_c/libffi/ltmain.sh +2599 -1369
  70. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +176 -0
  71. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +195 -0
  72. data/ext/ffi_c/libffi/m4/ax_check_compiler_flags.m4 +76 -0
  73. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +63 -0
  74. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +70 -0
  75. data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +300 -0
  76. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +215 -0
  77. data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +79 -0
  78. data/ext/ffi_c/libffi/m4/libtool.m4 +1239 -768
  79. data/ext/ffi_c/libffi/m4/ltoptions.m4 +7 -6
  80. data/ext/ffi_c/libffi/m4/ltversion.m4 +6 -6
  81. data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +9 -3
  82. data/ext/ffi_c/libffi/man/Makefile.in +21 -3
  83. data/ext/ffi_c/libffi/mdate-sh +0 -0
  84. data/ext/ffi_c/libffi/missing +60 -44
  85. data/ext/ffi_c/libffi/msvcc.sh +197 -0
  86. data/ext/ffi_c/libffi/src/alpha/osf.S +39 -18
  87. data/ext/ffi_c/libffi/src/arm/ffi.c +443 -24
  88. data/ext/ffi_c/libffi/src/arm/ffitarget.h +17 -1
  89. data/ext/ffi_c/libffi/src/arm/gentramp.sh +118 -0
  90. data/ext/ffi_c/libffi/src/arm/sysv.S +206 -15
  91. data/ext/ffi_c/libffi/src/arm/trampoline.S +4450 -0
  92. data/ext/ffi_c/libffi/src/avr32/ffi.c +4 -2
  93. data/ext/ffi_c/libffi/src/avr32/ffitarget.h +2 -2
  94. data/ext/ffi_c/libffi/src/closures.c +17 -35
  95. data/ext/ffi_c/libffi/src/cris/ffi.c +1 -1
  96. data/ext/ffi_c/libffi/src/cris/ffitarget.h +2 -2
  97. data/ext/ffi_c/libffi/src/dlmalloc.c +66 -4
  98. data/ext/ffi_c/libffi/src/frv/ffitarget.h +2 -6
  99. data/ext/ffi_c/libffi/src/ia64/ffi.c +7 -5
  100. data/ext/ffi_c/libffi/src/ia64/ffitarget.h +2 -2
  101. data/ext/ffi_c/libffi/src/java_raw_api.c +1 -1
  102. data/ext/ffi_c/libffi/src/m32r/ffitarget.h +2 -2
  103. data/ext/ffi_c/libffi/src/m68k/ffi.c +10 -0
  104. data/ext/ffi_c/libffi/src/m68k/ffitarget.h +2 -2
  105. data/ext/ffi_c/libffi/src/m68k/sysv.S +36 -0
  106. data/ext/ffi_c/libffi/src/mips/ffi.c +12 -5
  107. data/ext/ffi_c/libffi/src/mips/ffitarget.h +18 -11
  108. data/ext/ffi_c/libffi/src/mips/n32.S +4 -4
  109. data/ext/ffi_c/libffi/src/moxie/eabi.S +128 -0
  110. data/ext/ffi_c/libffi/src/moxie/ffi.c +276 -0
  111. data/ext/ffi_c/libffi/src/pa/ffi.c +7 -4
  112. data/ext/ffi_c/libffi/src/pa/ffitarget.h +6 -5
  113. data/ext/ffi_c/libffi/src/powerpc/aix.S +5 -1
  114. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +2 -0
  115. data/ext/ffi_c/libffi/src/powerpc/asm.h +1 -1
  116. data/ext/ffi_c/libffi/src/powerpc/darwin.S +215 -77
  117. data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +358 -100
  118. data/ext/ffi_c/libffi/src/powerpc/ffi.c +11 -5
  119. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +603 -172
  120. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +17 -4
  121. data/ext/ffi_c/libffi/src/prep_cif.c +16 -13
  122. data/ext/ffi_c/libffi/src/s390/ffitarget.h +4 -2
  123. data/ext/ffi_c/libffi/src/sh/ffitarget.h +2 -2
  124. data/ext/ffi_c/libffi/src/sh64/ffitarget.h +2 -2
  125. data/ext/ffi_c/libffi/src/sparc/ffi.c +55 -11
  126. data/ext/ffi_c/libffi/src/sparc/ffitarget.h +5 -3
  127. data/ext/ffi_c/libffi/src/x86/ffi.c +54 -92
  128. data/ext/ffi_c/libffi/src/x86/ffi64.c +17 -8
  129. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -14
  130. data/ext/ffi_c/libffi/src/x86/sysv.S +40 -26
  131. data/ext/ffi_c/libffi/src/x86/unix64.S +4 -0
  132. data/ext/ffi_c/libffi/src/x86/win32.S +379 -191
  133. data/ext/ffi_c/libffi/src/x86/win64.S +15 -7
  134. data/ext/ffi_c/libffi/testsuite/Makefile.am +1 -1
  135. data/ext/ffi_c/libffi/testsuite/Makefile.in +22 -4
  136. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +350 -0
  137. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +1 -5
  138. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +1 -1
  139. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +1 -1
  140. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +1 -0
  141. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +1 -0
  142. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +3 -0
  143. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +2 -2
  144. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +3 -0
  145. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +1 -1
  146. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +1 -1
  147. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +1 -0
  148. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +2 -3
  149. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +2 -1
  150. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +36 -0
  151. data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +17 -17
  152. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +1 -0
  153. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +1 -0
  154. data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +1 -1
  155. data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +1 -3
  156. data/ext/ffi_c/win32/stdint.h +199 -0
  157. data/gen/Rakefile +18 -2
  158. data/lib/1.8/ffi_c.so +0 -0
  159. data/lib/ffi.rb +13 -9
  160. data/lib/ffi/autopointer.rb +88 -26
  161. data/lib/ffi/enum.rb +42 -0
  162. data/lib/ffi/errno.rb +6 -1
  163. data/lib/ffi/ffi.rb +1 -0
  164. data/lib/ffi/io.rb +13 -2
  165. data/lib/ffi/library.rb +219 -24
  166. data/lib/ffi/memorypointer.rb +1 -33
  167. data/lib/ffi/platform.rb +21 -7
  168. data/lib/ffi/platform/arm-linux/types.conf +102 -0
  169. data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
  170. data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
  171. data/lib/ffi/platform/i486-gnu/types.conf +107 -0
  172. data/lib/ffi/platform/ia64-linux/types.conf +102 -0
  173. data/lib/ffi/platform/mips-linux/types.conf +102 -0
  174. data/lib/ffi/platform/mipsel-linux/types.conf +102 -0
  175. data/lib/ffi/platform/powerpc-linux/types.conf +100 -0
  176. data/lib/ffi/platform/s390-linux/types.conf +102 -0
  177. data/lib/ffi/platform/s390x-linux/types.conf +102 -0
  178. data/lib/ffi/platform/sparc-linux/types.conf +102 -0
  179. data/lib/ffi/platform/x86_64-freebsd/types.conf +126 -0
  180. data/lib/ffi/platform/x86_64-netbsd/types.conf +126 -0
  181. data/lib/ffi/pointer.rb +44 -0
  182. data/lib/ffi/struct.rb +2 -6
  183. data/lib/ffi/struct_layout_builder.rb +2 -1
  184. data/lib/ffi/tools/const_generator.rb +78 -26
  185. data/lib/ffi/tools/types_generator.rb +8 -1
  186. data/lib/ffi/types.rb +21 -1
  187. data/spec/ffi/async_callback_spec.rb +2 -2
  188. data/spec/ffi/bool_spec.rb +6 -6
  189. data/spec/ffi/buffer_spec.rb +23 -23
  190. data/spec/ffi/callback_spec.rb +101 -102
  191. data/spec/ffi/custom_type_spec.rb +20 -24
  192. data/spec/ffi/dup_spec.rb +7 -7
  193. data/spec/ffi/enum_spec.rb +127 -127
  194. data/spec/ffi/errno_spec.rb +2 -2
  195. data/spec/ffi/ffi_spec.rb +3 -3
  196. data/spec/ffi/function_spec.rb +10 -10
  197. data/spec/ffi/library_spec.rb +30 -12
  198. data/spec/ffi/managed_struct_spec.rb +4 -4
  199. data/spec/ffi/number_spec.rb +40 -40
  200. data/spec/ffi/pointer_spec.rb +21 -24
  201. data/spec/ffi/rbx/memory_pointer_spec.rb +17 -15
  202. data/spec/ffi/rbx/struct_spec.rb +2 -2
  203. data/spec/ffi/spec_helper.rb +1 -1
  204. data/spec/ffi/string_spec.rb +9 -9
  205. data/spec/ffi/strptr_spec.rb +3 -3
  206. data/spec/ffi/struct_callback_spec.rb +7 -7
  207. data/spec/ffi/struct_initialize_spec.rb +2 -2
  208. data/spec/ffi/struct_packed_spec.rb +6 -6
  209. data/spec/ffi/struct_spec.rb +94 -84
  210. data/spec/ffi/typedef_spec.rb +15 -4
  211. data/spec/ffi/union_spec.rb +3 -3
  212. data/spec/ffi/variadic_spec.rb +17 -14
  213. data/tasks/extension.rake +0 -1
  214. data/tasks/gem.rake +0 -1
  215. data/tasks/rdoc.rake +1 -1
  216. data/tasks/yard.rake +11 -0
  217. metadata +50 -11
  218. data/lib/1.9/ffi_c.so +0 -0
@@ -29,7 +29,7 @@ describe "Callback" do
29
29
  # cmp = proc do |p1, p2| args.push(p1.get_int(0)); args.push(p2.get_int(0)); 0; end
30
30
  # # this is a bit dodgey, as it relies on qsort passing the args in order
31
31
  # LibC.qsort(p, 2, 4, cmp)
32
- # args.should == [ 1, 2 ]
32
+ # args.should eq [ 1, 2 ]
33
33
  # end
34
34
  #
35
35
  # it "Block can be substituted for Callback as last argument" do
@@ -42,7 +42,7 @@ describe "Callback" do
42
42
  # args.push(p2.get_int(0))
43
43
  # 0
44
44
  # end
45
- # args.should == [ 1, 2 ]
45
+ # args.should eq [ 1, 2 ]
46
46
  # end
47
47
  module LibTest
48
48
  extend FFI::Library
@@ -87,7 +87,6 @@ describe "Callback" do
87
87
  attach_function :testCallbackVrU64, :testClosureVrLL, [ :cbVrU64 ], :ulong_long
88
88
  attach_function :testCallbackVrP, :testClosureVrP, [ :cbVrP ], :pointer
89
89
  attach_function :testCallbackVrY, :testClosureVrP, [ :cbVrY ], S8F32S32.ptr
90
- attach_function :testCallbackCrV, :testClosureBrV, [ :cbCrV, :char ], :void
91
90
  attach_function :testCallbackVrT, :testClosureVrT, [ :cbVrT ], S8F32S32.by_value
92
91
  attach_function :testCallbackTrV, :testClosureTrV, [ :cbTrV, S8F32S32.ptr ], :void
93
92
  attach_variable :cbVrS8, :gvar_pointer, :cbVrS8
@@ -96,142 +95,139 @@ describe "Callback" do
96
95
  attach_function :testOptionalCallbackCrV, :testOptionalClosureBrV, [ :cbCrV, :char ], :void
97
96
 
98
97
  end
99
- it "function with Callback plus another arg should raise error if no arg given" do
100
- lambda { LibTest.testCallbackCrV { |*a| }}.should raise_error
101
- end
102
98
  it "returning :char (0)" do
103
- LibTest.testCallbackVrS8 { 0 }.should == 0
99
+ LibTest.testCallbackVrS8 { 0 }.should eq 0
104
100
  end
105
101
  it "returning :char (127)" do
106
- LibTest.testCallbackVrS8 { 127 }.should == 127
102
+ LibTest.testCallbackVrS8 { 127 }.should eq 127
107
103
  end
108
104
  it "returning :char (-128)" do
109
- LibTest.testCallbackVrS8 { -128 }.should == -128
105
+ LibTest.testCallbackVrS8 { -128 }.should eq(-128)
110
106
  end
111
107
  # test wrap around
112
108
  it "returning :char (128)" do
113
- LibTest.testCallbackVrS8 { 128 }.should == -128
109
+ LibTest.testCallbackVrS8 { 128 }.should eq(-128)
114
110
  end
115
111
  it "returning :char (255)" do
116
- LibTest.testCallbackVrS8 { 0xff }.should == -1
112
+ LibTest.testCallbackVrS8 { 0xff }.should eq(-1)
117
113
  end
118
114
  it "returning :uchar (0)" do
119
- LibTest.testCallbackVrU8 { 0 }.should == 0
115
+ LibTest.testCallbackVrU8 { 0 }.should eq 0
120
116
  end
121
117
  it "returning :uchar (0xff)" do
122
- LibTest.testCallbackVrU8 { 0xff }.should == 0xff
118
+ LibTest.testCallbackVrU8 { 0xff }.should eq 0xff
123
119
  end
124
120
  it "returning :uchar (-1)" do
125
- LibTest.testCallbackVrU8 { -1 }.should == 0xff
121
+ LibTest.testCallbackVrU8 { -1 }.should eq 0xff
126
122
  end
127
123
  it "returning :uchar (128)" do
128
- LibTest.testCallbackVrU8 { 128 }.should == 128
124
+ LibTest.testCallbackVrU8 { 128 }.should eq 128
129
125
  end
130
126
  it "returning :uchar (-128)" do
131
- LibTest.testCallbackVrU8 { -128 }.should == 128
127
+ LibTest.testCallbackVrU8 { -128 }.should eq 128
132
128
  end
133
129
  it "returning :short (0)" do
134
- LibTest.testCallbackVrS16 { 0 }.should == 0
130
+ LibTest.testCallbackVrS16 { 0 }.should eq 0
135
131
  end
136
132
  it "returning :short (0x7fff)" do
137
- LibTest.testCallbackVrS16 { 0x7fff }.should == 0x7fff
133
+ LibTest.testCallbackVrS16 { 0x7fff }.should eq 0x7fff
138
134
  end
139
135
  # test wrap around
140
136
  it "returning :short (0x8000)" do
141
- LibTest.testCallbackVrS16 { 0x8000 }.should == -0x8000
137
+ LibTest.testCallbackVrS16 { 0x8000 }.should eq(-0x8000)
142
138
  end
143
139
  it "returning :short (0xffff)" do
144
- LibTest.testCallbackVrS16 { 0xffff }.should == -1
140
+ LibTest.testCallbackVrS16 { 0xffff }.should eq(-1)
145
141
  end
146
142
  it "returning :ushort (0)" do
147
- LibTest.testCallbackVrU16 { 0 }.should == 0
143
+ LibTest.testCallbackVrU16 { 0 }.should eq 0
148
144
  end
149
145
  it "returning :ushort (0x7fff)" do
150
- LibTest.testCallbackVrU16 { 0x7fff }.should == 0x7fff
146
+ LibTest.testCallbackVrU16 { 0x7fff }.should eq 0x7fff
151
147
  end
152
148
  it "returning :ushort (0x8000)" do
153
- LibTest.testCallbackVrU16 { 0x8000 }.should == 0x8000
149
+ LibTest.testCallbackVrU16 { 0x8000 }.should eq 0x8000
154
150
  end
155
151
  it "returning :ushort (0xffff)" do
156
- LibTest.testCallbackVrU16 { 0xffff }.should == 0xffff
152
+ LibTest.testCallbackVrU16 { 0xffff }.should eq 0xffff
157
153
  end
158
154
  it "returning :ushort (-1)" do
159
- LibTest.testCallbackVrU16 { -1 }.should == 0xffff
155
+ LibTest.testCallbackVrU16 { -1 }.should eq 0xffff
160
156
  end
161
157
  it "returning :int (0)" do
162
- LibTest.testCallbackVrS32 { 0 }.should == 0
158
+ LibTest.testCallbackVrS32 { 0 }.should eq 0
163
159
  end
164
160
  it "returning :int (0x7fffffff)" do
165
- LibTest.testCallbackVrS32 { 0x7fffffff }.should == 0x7fffffff
161
+ LibTest.testCallbackVrS32 { 0x7fffffff }.should eq 0x7fffffff
166
162
  end
167
163
  # test wrap around
168
164
  it "returning :int (-0x80000000)" do
169
- LibTest.testCallbackVrS32 { -0x80000000 }.should == -0x80000000
165
+ LibTest.testCallbackVrS32 { -0x80000000 }.should eq(-0x80000000)
170
166
  end
171
167
  it "returning :int (-1)" do
172
- LibTest.testCallbackVrS32 { -1 }.should == -1
168
+ LibTest.testCallbackVrS32 { -1 }.should eq(-1)
173
169
  end
174
170
  it "returning :uint (0)" do
175
- LibTest.testCallbackVrU32 { 0 }.should == 0
171
+ LibTest.testCallbackVrU32 { 0 }.should eq 0
176
172
  end
177
173
  it "returning :uint (0x7fffffff)" do
178
- LibTest.testCallbackVrU32 { 0x7fffffff }.should == 0x7fffffff
174
+ LibTest.testCallbackVrU32 { 0x7fffffff }.should eq 0x7fffffff
179
175
  end
180
176
  # test wrap around
181
177
  it "returning :uint (0x80000000)" do
182
- LibTest.testCallbackVrU32 { 0x80000000 }.should == 0x80000000
178
+ LibTest.testCallbackVrU32 { 0x80000000 }.should eq 0x80000000
183
179
  end
184
180
  it "returning :uint (0xffffffff)" do
185
- LibTest.testCallbackVrU32 { 0xffffffff }.should == 0xffffffff
181
+ LibTest.testCallbackVrU32 { 0xffffffff }.should eq 0xffffffff
186
182
  end
187
183
  it "returning :uint (-1)" do
188
- LibTest.testCallbackVrU32 { -1 }.should == 0xffffffff
184
+ LibTest.testCallbackVrU32 { -1 }.should eq 0xffffffff
189
185
  end
190
186
  it "returning :long (0)" do
191
- LibTest.testCallbackVrL { 0 }.should == 0
187
+ LibTest.testCallbackVrL { 0 }.should eq 0
192
188
  end
193
189
  it "returning :long (0x7fffffff)" do
194
- LibTest.testCallbackVrL { 0x7fffffff }.should == 0x7fffffff
190
+ LibTest.testCallbackVrL { 0x7fffffff }.should eq 0x7fffffff
195
191
  end
196
192
  # test wrap around
197
193
  it "returning :long (-0x80000000)" do
198
- LibTest.testCallbackVrL { -0x80000000 }.should == -0x80000000
194
+ LibTest.testCallbackVrL { -0x80000000 }.should eq(-0x80000000)
199
195
  end
200
196
  it "returning :long (-1)" do
201
- LibTest.testCallbackVrL { -1 }.should == -1
197
+ LibTest.testCallbackVrL { -1 }.should eq(-1)
202
198
  end
203
199
  it "returning :ulong (0)" do
204
- LibTest.testCallbackVrUL { 0 }.should == 0
200
+ LibTest.testCallbackVrUL { 0 }.should eq 0
205
201
  end
206
202
  it "returning :ulong (0x7fffffff)" do
207
- LibTest.testCallbackVrUL { 0x7fffffff }.should == 0x7fffffff
203
+ LibTest.testCallbackVrUL { 0x7fffffff }.should eq 0x7fffffff
208
204
  end
209
205
  # test wrap around
210
206
  it "returning :ulong (0x80000000)" do
211
- LibTest.testCallbackVrUL { 0x80000000 }.should == 0x80000000
207
+ LibTest.testCallbackVrUL { 0x80000000 }.should eq 0x80000000
212
208
  end
213
209
  it "returning :ulong (0xffffffff)" do
214
- LibTest.testCallbackVrUL { 0xffffffff }.should == 0xffffffff
210
+ LibTest.testCallbackVrUL { 0xffffffff }.should eq 0xffffffff
215
211
  end
216
212
  it "Callback returning :ulong (-1)" do
217
213
  if FFI::Platform::LONG_SIZE == 32
218
- LibTest.testCallbackVrUL { -1 }.should == 0xffffffff
214
+ LibTest.testCallbackVrUL { -1 }.should eq 0xffffffff
219
215
  else
220
- LibTest.testCallbackVrUL { -1 }.should == 0xffffffffffffffff
216
+ LibTest.testCallbackVrUL { -1 }.should eq 0xffffffffffffffff
221
217
  end
222
218
  end
223
219
  it "returning :long_long (0)" do
224
- LibTest.testCallbackVrS64 { 0 }.should == 0
220
+ LibTest.testCallbackVrS64 { 0 }.should eq 0
225
221
  end
226
222
  it "returning :long_long (0x7fffffffffffffff)" do
227
- LibTest.testCallbackVrS64 { 0x7fffffffffffffff }.should == 0x7fffffffffffffff
223
+ LibTest.testCallbackVrS64 { 0x7fffffffffffffff }.should eq 0x7fffffffffffffff
228
224
  end
229
225
  # test wrap around
230
226
  it "returning :long_long (-0x8000000000000000)" do
231
- LibTest.testCallbackVrS64 { -0x8000000000000000 }.should == -0x8000000000000000
227
+ LibTest.testCallbackVrS64 { -0x8000000000000000 }.should eq(-0x8000000000000000)
232
228
  end
233
229
  it "returning :long_long (-1)" do
234
- LibTest.testCallbackVrS64 { -1 }.should == -1
230
+ LibTest.testCallbackVrS64 { -1 }.should eq(-1)
235
231
  end
236
232
  it "returning bool" do
237
233
  LibTest.testCallbackVrZ { true }.should be_true
@@ -241,7 +237,7 @@ describe "Callback" do
241
237
  end
242
238
  it "returning :pointer (MemoryPointer)" do
243
239
  p = FFI::MemoryPointer.new :long
244
- LibTest.testCallbackVrP { p }.should == p
240
+ LibTest.testCallbackVrP { p }.should eq p
245
241
  end
246
242
 
247
243
 
@@ -251,9 +247,9 @@ describe "Callback" do
251
247
  s[:s32] = 0x1eefbeef
252
248
  s[:f32] = 1.234567
253
249
  ret = LibTest.testCallbackVrT { s }
254
- ret[:s8].should == s[:s8]
255
- ret[:f32].should == s[:f32]
256
- ret[:s32].should == s[:s32]
250
+ ret[:s8].should eq s[:s8]
251
+ ret[:f32].should eq s[:f32]
252
+ ret[:s32].should eq s[:s32]
257
253
 
258
254
  end
259
255
 
@@ -274,7 +270,7 @@ describe "Callback" do
274
270
  it "global variable" do
275
271
  proc = Proc.new { 0x1e }
276
272
  LibTest.cbVrS8 = proc
277
- LibTest.testGVarCallbackVrS8(LibTest.pVrS8).should == 0x1e
273
+ LibTest.testGVarCallbackVrS8(LibTest.pVrS8).should eq 0x1e
278
274
  end
279
275
 
280
276
  describe "When the callback is considered optional by the underlying library" do
@@ -288,9 +284,9 @@ describe "Callback" do
288
284
  module LibTest
289
285
  extend FFI::Library
290
286
  ffi_lib TestLibrary::PATH
291
- attach_function :testCallbackVrS8, :testClosureVrB, [ callback([ ], :char) ], :char
287
+ attach_function :testAnonymousCallbackVrS8, :testClosureVrB, [ callback([ ], :char) ], :char
292
288
  end
293
- LibTest.testCallbackVrS8 { 0 }.should == 0
289
+ LibTest.testAnonymousCallbackVrS8 { 0 }.should eq 0
294
290
  end
295
291
  end
296
292
 
@@ -328,7 +324,7 @@ describe "Callback" do
328
324
  end
329
325
 
330
326
  val = LibTest.testReturnsCallback(lookup_proc, 0x1234)
331
- val.should == 0x1234 * 2
327
+ val.should eq 0x1234 * 2
332
328
  lookup_proc_called.should be_true
333
329
  return_proc_called.should be_true
334
330
  end
@@ -339,7 +335,7 @@ describe "Callback" do
339
335
  ffi_lib TestLibrary::PATH
340
336
  callback :cb_return_type, [ :int ], :int
341
337
  callback :cb_lookup, [ ], :cb_return_type
342
- attach_function :testReturnsCallback, :testReturnsClosure, [ :cb_lookup, :int ], :int
338
+ attach_function :testReturnsCallback_2, :testReturnsClosure, [ :cb_lookup, :int ], :int
343
339
  end
344
340
  module MethodCallback
345
341
  def self.lookup
@@ -350,7 +346,7 @@ describe "Callback" do
350
346
  end
351
347
  end
352
348
 
353
- LibTest.testReturnsCallback(MethodCallback.method(:lookup), 0x1234).should == 0x2468
349
+ LibTest.testReturnsCallback_2(MethodCallback.method(:lookup), 0x1234).should eq 0x2468
354
350
  end
355
351
 
356
352
  it 'should not blow up when a callback takes a callback as argument' do
@@ -359,7 +355,7 @@ describe "Callback" do
359
355
  ffi_lib TestLibrary::PATH
360
356
  callback :cb_argument, [ :int ], :int
361
357
  callback :cb_with_cb_argument, [ :cb_argument, :int ], :int
362
- attach_function :testCallbackAsArgument, :testArgumentClosure, [ :cb_with_cb_argument, :int ], :int
358
+ attach_function :testCallbackAsArgument_2, :testArgumentClosure, [ :cb_with_cb_argument, :int ], :int
363
359
  end
364
360
  end
365
361
  it 'should be able to use the callback argument' do
@@ -381,7 +377,7 @@ describe "Callback" do
381
377
  cb.call(val)
382
378
  end
383
379
  val = LibTest.testCallbackAsArgument(callback_with_callback_arg, callback_arg, 0xff1)
384
- val.should == 0xff1 * 2
380
+ val.should eq 0xff1 * 2
385
381
  callback_arg_called.should be_true
386
382
  callback_with_callback_arg_called.should be_true
387
383
  end
@@ -393,7 +389,7 @@ describe "Callback" do
393
389
  attach_function :testReturnsFunctionPointer, [ ], :funcptr
394
390
  end
395
391
  f = LibTest.testReturnsFunctionPointer
396
- f.call(3).should == 6
392
+ f.call(3).should eq 6
397
393
  end
398
394
  end
399
395
 
@@ -444,86 +440,89 @@ describe "Callback with " do
444
440
  attach_function :testCallbackPrV, :testClosurePrV, [ :cbPrV, :pointer], :void
445
441
  attach_function :testCallbackYrV, :testClosurePrV, [ :cbYrV, S8F32S32.in ], :void
446
442
  end
443
+ it "function with Callback plus another arg should raise error if no arg given" do
444
+ lambda { LibTest.testCallbackCrV { |*a| }}.should raise_error
445
+ end
447
446
  it ":char (0) argument" do
448
447
  v = 0xdeadbeef
449
448
  LibTest.testCallbackCrV(0) { |i| v = i }
450
- v.should == 0
449
+ v.should eq 0
451
450
  end
452
451
  it ":char (127) argument" do
453
452
  v = 0xdeadbeef
454
453
  LibTest.testCallbackCrV(127) { |i| v = i }
455
- v.should == 127
454
+ v.should eq 127
456
455
  end
457
456
  it ":char (-128) argument" do
458
457
  v = 0xdeadbeef
459
458
  LibTest.testCallbackCrV(-128) { |i| v = i }
460
- v.should == -128
459
+ v.should eq(-128)
461
460
  end
462
461
  it ":char (-1) argument" do
463
462
  v = 0xdeadbeef
464
463
  LibTest.testCallbackCrV(-1) { |i| v = i }
465
- v.should == -1
464
+ v.should eq(-1)
466
465
  end
467
466
  it ":uchar (0) argument" do
468
467
  v = 0xdeadbeef
469
468
  LibTest.testCallbackU8rV(0) { |i| v = i }
470
- v.should == 0
469
+ v.should eq 0
471
470
  end
472
471
  it ":uchar (127) argument" do
473
472
  v = 0xdeadbeef
474
473
  LibTest.testCallbackU8rV(127) { |i| v = i }
475
- v.should == 127
474
+ v.should eq 127
476
475
  end
477
476
  it ":uchar (128) argument" do
478
477
  v = 0xdeadbeef
479
478
  LibTest.testCallbackU8rV(128) { |i| v = i }
480
- v.should == 128
479
+ v.should eq 128
481
480
  end
482
481
  it ":uchar (255) argument" do
483
482
  v = 0xdeadbeef
484
483
  LibTest.testCallbackU8rV(255) { |i| v = i }
485
- v.should == 255
484
+ v.should eq 255
486
485
  end
487
486
 
488
487
  it ":short (0) argument" do
489
488
  v = 0xdeadbeef
490
489
  LibTest.testCallbackSrV(0) { |i| v = i }
491
- v.should == 0
490
+ v.should eq 0
492
491
  end
493
492
  it ":short (0x7fff) argument" do
494
493
  v = 0xdeadbeef
495
494
  LibTest.testCallbackSrV(0x7fff) { |i| v = i }
496
- v.should == 0x7fff
495
+ v.should eq 0x7fff
497
496
  end
498
497
  it ":short (-0x8000) argument" do
499
498
  v = 0xdeadbeef
500
499
  LibTest.testCallbackSrV(-0x8000) { |i| v = i }
501
- v.should == -0x8000
500
+ v.should eq(-0x8000)
502
501
  end
503
502
  it ":short (-1) argument" do
504
503
  v = 0xdeadbeef
505
504
  LibTest.testCallbackSrV(-1) { |i| v = i }
506
- v.should == -1
505
+ v.should eq(-1)
507
506
  end
508
507
  it ":ushort (0) argument" do
509
508
  v = 0xdeadbeef
510
509
  LibTest.testCallbackU16rV(0) { |i| v = i }
511
- v.should == 0
510
+ v.should eq 0
512
511
  end
513
512
  it ":ushort (0x7fff) argument" do
514
513
  v = 0xdeadbeef
515
514
  LibTest.testCallbackU16rV(0x7fff) { |i| v = i }
516
- v.should == 0x7fff
515
+ v.should eq 0x7fff
517
516
  end
518
517
  it ":ushort (0x8000) argument" do
519
518
  v = 0xdeadbeef
520
519
  LibTest.testCallbackU16rV(0x8000) { |i| v = i }
521
- v.should == 0x8000
520
+ v.should eq 0x8000
522
521
  end
523
522
  it ":ushort (0xffff) argument" do
524
523
  v = 0xdeadbeef
525
524
  LibTest.testCallbackU16rV(0xffff) { |i| v = i }
526
- v.should == 0xffff
525
+ v.should eq 0xffff
527
526
  end
528
527
  it ":bool (true) argument" do
529
528
  v = false
@@ -533,107 +532,107 @@ describe "Callback with " do
533
532
  it ":int (0) argument" do
534
533
  v = 0xdeadbeef
535
534
  LibTest.testCallbackIrV(0) { |i| v = i }
536
- v.should == 0
535
+ v.should eq 0
537
536
  end
538
537
  it ":int (0x7fffffff) argument" do
539
538
  v = 0xdeadbeef
540
539
  LibTest.testCallbackIrV(0x7fffffff) { |i| v = i }
541
- v.should == 0x7fffffff
540
+ v.should eq 0x7fffffff
542
541
  end
543
542
  it ":int (-0x80000000) argument" do
544
543
  v = 0xdeadbeef
545
544
  LibTest.testCallbackIrV(-0x80000000) { |i| v = i }
546
- v.should == -0x80000000
545
+ v.should eq(-0x80000000)
547
546
  end
548
547
  it ":int (-1) argument" do
549
548
  v = 0xdeadbeef
550
549
  LibTest.testCallbackIrV(-1) { |i| v = i }
551
- v.should == -1
550
+ v.should eq(-1)
552
551
  end
553
552
  it ":uint (0) argument" do
554
553
  v = 0xdeadbeef
555
554
  LibTest.testCallbackU32rV(0) { |i| v = i }
556
- v.should == 0
555
+ v.should eq 0
557
556
  end
558
557
  it ":uint (0x7fffffff) argument" do
559
558
  v = 0xdeadbeef
560
559
  LibTest.testCallbackU32rV(0x7fffffff) { |i| v = i }
561
- v.should == 0x7fffffff
560
+ v.should eq 0x7fffffff
562
561
  end
563
562
  it ":uint (0x80000000) argument" do
564
563
  v = 0xdeadbeef
565
564
  LibTest.testCallbackU32rV(0x80000000) { |i| v = i }
566
- v.should == 0x80000000
565
+ v.should eq 0x80000000
567
566
  end
568
567
  it ":uint (0xffffffff) argument" do
569
568
  v = 0xdeadbeef
570
569
  LibTest.testCallbackU32rV(0xffffffff) { |i| v = i }
571
- v.should == 0xffffffff
570
+ v.should eq 0xffffffff
572
571
  end
573
572
  it ":long (0) argument" do
574
573
  v = 0xdeadbeef
575
574
  LibTest.testCallbackLrV(0) { |i| v = i }
576
- v.should == 0
575
+ v.should eq 0
577
576
  end
578
577
  it ":long (0x7fffffff) argument" do
579
578
  v = 0xdeadbeef
580
579
  LibTest.testCallbackLrV(0x7fffffff) { |i| v = i }
581
- v.should == 0x7fffffff
580
+ v.should eq 0x7fffffff
582
581
  end
583
582
  it ":long (-0x80000000) argument" do
584
583
  v = 0xdeadbeef
585
584
  LibTest.testCallbackLrV(-0x80000000) { |i| v = i }
586
- v.should == -0x80000000
585
+ v.should eq(-0x80000000)
587
586
  end
588
587
  it ":long (-1) argument" do
589
588
  v = 0xdeadbeef
590
589
  LibTest.testCallbackLrV(-1) { |i| v = i }
591
- v.should == -1
590
+ v.should eq(-1)
592
591
  end
593
592
  it ":ulong (0) argument" do
594
593
  v = 0xdeadbeef
595
594
  LibTest.testCallbackULrV(0) { |i| v = i }
596
- v.should == 0
595
+ v.should eq 0
597
596
  end
598
597
  it ":ulong (0x7fffffff) argument" do
599
598
  v = 0xdeadbeef
600
599
  LibTest.testCallbackULrV(0x7fffffff) { |i| v = i }
601
- v.should == 0x7fffffff
600
+ v.should eq 0x7fffffff
602
601
  end
603
602
  it ":ulong (0x80000000) argument" do
604
603
  v = 0xdeadbeef
605
604
  LibTest.testCallbackULrV(0x80000000) { |i| v = i }
606
- v.should == 0x80000000
605
+ v.should eq 0x80000000
607
606
  end
608
607
  it ":ulong (0xffffffff) argument" do
609
608
  v = 0xdeadbeef
610
609
  LibTest.testCallbackULrV(0xffffffff) { |i| v = i }
611
- v.should == 0xffffffff
610
+ v.should eq 0xffffffff
612
611
  end
613
612
  it ":long_long (0) argument" do
614
613
  v = 0xdeadbeef
615
614
  LibTest.testCallbackLLrV(0) { |i| v = i }
616
- v.should == 0
615
+ v.should eq 0
617
616
  end
618
617
  it ":long_long (0x7fffffffffffffff) argument" do
619
618
  v = 0xdeadbeef
620
619
  LibTest.testCallbackLLrV(0x7fffffffffffffff) { |i| v = i }
621
- v.should == 0x7fffffffffffffff
620
+ v.should eq 0x7fffffffffffffff
622
621
  end
623
622
  it ":long_long (-0x8000000000000000) argument" do
624
623
  v = 0xdeadbeef
625
624
  LibTest.testCallbackLLrV(-0x8000000000000000) { |i| v = i }
626
- v.should == -0x8000000000000000
625
+ v.should eq(-0x8000000000000000)
627
626
  end
628
627
  it ":long_long (-1) argument" do
629
628
  v = 0xdeadbeef
630
629
  LibTest.testCallbackLLrV(-1) { |i| v = i }
631
- v.should == -1
630
+ v.should eq(-1)
632
631
  end
633
632
  it ":string argument" do
634
633
  v = nil
635
634
  LibTest.testCallbackArV("Hello, World") { |i| v = i }
636
- v.should == "Hello, World"
635
+ v.should eq "Hello, World"
637
636
  end
638
637
  it ":string (nil) argument" do
639
638
  v = "Hello, World"
@@ -644,18 +643,18 @@ describe "Callback with " do
644
643
  v = nil
645
644
  magic = FFI::Pointer.new(0xdeadbeef)
646
645
  LibTest.testCallbackPrV(magic) { |i| v = i }
647
- v.should == magic
646
+ v.should eq magic
648
647
  end
649
648
  it ":pointer (nil) argument" do
650
649
  v = "Hello, World"
651
650
  LibTest.testCallbackPrV(nil) { |i| v = i }
652
- v.should == FFI::Pointer::NULL
651
+ v.should eq FFI::Pointer::NULL
653
652
  end
654
653
  it "struct by reference argument" do
655
654
  v = nil
656
655
  magic = LibTest::S8F32S32.new
657
656
  LibTest.testCallbackYrV(magic) { |i| v = i }
658
- v.class.should == magic.class
657
+ v.class.should eq magic.class
659
658
  v.pointer == magic.pointer
660
659
  end
661
660
 
@@ -663,7 +662,7 @@ describe "Callback with " do
663
662
  v = LibTest::S8F32S32.new
664
663
  LibTest.testCallbackYrV(nil) { |i| v = i }
665
664
  v.is_a?(FFI::Struct).should be_true
666
- v.pointer.should == FFI::Pointer::NULL
665
+ v.pointer.should eq FFI::Pointer::NULL
667
666
  end
668
667
 
669
668
  end # unless true