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
@@ -8,6 +8,6 @@ describe FFI::Struct do
8
8
  it "allows setting fields" do
9
9
  t = Timeval.new
10
10
  t[:tv_sec] = 12
11
- t[:tv_sec].should == 12
11
+ t[:tv_sec].should eq 12
12
12
  end
13
- end
13
+ end
@@ -21,7 +21,7 @@ if RUBY_PLATFORM =~/java/
21
21
  $:.reject! { |p| p == libdir }
22
22
  else
23
23
  $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib"),
24
- File.join(File.dirname(__FILE__), "..", "..", "build", "#{Config::CONFIG['host_cpu''arch']}", "ffi_c", RUBY_VERSION)
24
+ File.join(File.dirname(__FILE__), "..", "..", "build", "#{RbConfig::CONFIG['host_cpu''arch']}", "ffi_c", RUBY_VERSION)
25
25
  end
26
26
  # puts "loadpath=#{$:.join(':')}"
27
27
  require "ffi"
@@ -29,7 +29,7 @@ describe "String tests" do
29
29
  mp = FFI::MemoryPointer.new 1024
30
30
  mp.put_string(0, "test\0")
31
31
  str = mp.get_string(0)
32
- str.tainted?.should == true
32
+ str.tainted?.should eq true
33
33
  end
34
34
  it "String returned by a method is tainted" do
35
35
  mp = FFI::MemoryPointer.new :pointer
@@ -37,8 +37,8 @@ describe "String tests" do
37
37
  sp.put_string(0, "test")
38
38
  mp.put_pointer(0, sp)
39
39
  str = StrLibTest.ptr_ret_pointer(mp, 0)
40
- str.should == "test"
41
- str.tainted?.should == true
40
+ str.should eq "test"
41
+ str.tainted?.should eq true
42
42
  end
43
43
  it "Poison null byte raises error" do
44
44
  s = "123\0abc"
@@ -49,15 +49,15 @@ describe "String tests" do
49
49
  str = "test"
50
50
  str.taint
51
51
  begin
52
- LibTest.string_equals(str, str).should == false
53
- rescue SecurityError => e
52
+ LibTest.string_equals(str, str).should eq false
53
+ rescue SecurityError
54
54
  end
55
55
  end if false
56
56
  it "casts nil as NULL pointer" do
57
57
  StrLibTest.string_dummy(nil)
58
58
  end
59
59
  it "return nil for NULL char*" do
60
- StrLibTest.string_null.should == nil
60
+ StrLibTest.string_null.should eq nil
61
61
  end
62
62
  it "reads an array of strings until encountering a NULL pointer" do
63
63
  strings = ["foo", "bar", "baz", "testing", "ffi"]
@@ -69,7 +69,7 @@ describe "String tests" do
69
69
  end
70
70
  ary.insert(3, nil)
71
71
  ptrary.write_array_of_pointer(ary)
72
- ptrary.get_array_of_string(0).should == ["foo", "bar", "baz"]
72
+ ptrary.get_array_of_string(0).should eq ["foo", "bar", "baz"]
73
73
  end
74
74
  it "reads an array of strings of the size specified, substituting nil when a pointer is NULL" do
75
75
  strings = ["foo", "bar", "baz", "testing", "ffi"]
@@ -81,7 +81,7 @@ describe "String tests" do
81
81
  end
82
82
  ary.insert(2, nil)
83
83
  ptrary.write_array_of_pointer(ary)
84
- ptrary.get_array_of_string(0, 4).should == ["foo", "bar", nil, "baz"]
84
+ ptrary.get_array_of_string(0, 4).should eq ["foo", "bar", nil, "baz"]
85
85
  end
86
86
  it "reads an array of strings, taking a memory offset parameter" do
87
87
  strings = ["foo", "bar", "baz", "testing", "ffi"]
@@ -92,7 +92,7 @@ describe "String tests" do
92
92
  a << f
93
93
  end
94
94
  ptrary.write_array_of_pointer(ary)
95
- ptrary.get_array_of_string(2 * FFI.type_size(:pointer), 3).should == ["baz", "testing", "ffi"]
95
+ ptrary.get_array_of_string(2 * FFI.type_size(:pointer), 3).should eq ["baz", "testing", "ffi"]
96
96
  end
97
97
  it "raises an IndexError when trying to read an array of strings out of bounds" do
98
98
  strings = ["foo", "bar", "baz", "testing", "ffi"]
@@ -20,7 +20,7 @@ describe "functions returning :strptr" do
20
20
 
21
21
  it "can attach function with :strptr return type" do
22
22
  lambda do
23
- m = Module.new do
23
+ Module.new do
24
24
  extend FFI::Library
25
25
  ffi_lib FFI::Library::LIBC
26
26
  if !FFI::Platform.windows?
@@ -51,11 +51,11 @@ describe "functions returning :strptr" do
51
51
 
52
52
  it "should return the correct value" do
53
53
  result = StrPtr.strdup("test")
54
- result[0].should == "test"
54
+ result[0].should eq "test"
55
55
  end
56
56
 
57
57
  it "should return non-NULL pointer" do
58
58
  result = StrPtr.strdup("test")
59
59
  result[1].null?.should be_false
60
60
  end
61
- end
61
+ end
@@ -18,7 +18,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
18
18
 
19
19
  describe FFI::Struct, ' with inline callback functions' do
20
20
  it 'should be able to define inline callback field' do
21
- module CallbackMember
21
+ module CallbackMember1
22
22
  extend FFI::Library
23
23
  ffi_lib TestLibrary::PATH
24
24
  DUMMY_CB = callback :dummy_cb, [ :int ], :int
@@ -33,7 +33,7 @@ describe FFI::Struct, ' with inline callback functions' do
33
33
  end
34
34
  end
35
35
  it 'should take methods as callbacks' do
36
- module CallbackMember
36
+ module CallbackMember2
37
37
  extend FFI::Library
38
38
  ffi_lib TestLibrary::PATH
39
39
  class TestStruct < FFI::Struct
@@ -50,14 +50,14 @@ describe FFI::Struct, ' with inline callback functions' do
50
50
  end
51
51
  end
52
52
 
53
- ts = CallbackMember::TestStruct.new
53
+ ts = CallbackMember2::TestStruct.new
54
54
  ts[:add] = StructCallbacks.method(:add)
55
55
 
56
- CallbackMember.struct_call_add_cb(ts, 1, 2).should == 3
56
+ CallbackMember2.struct_call_add_cb(ts, 1, 2).should eq 3
57
57
  end
58
58
 
59
59
  it 'should return callable object from []' do
60
- module CallbackMember
60
+ module CallbackMember3
61
61
  extend FFI::Library
62
62
  ffi_lib TestLibrary::PATH
63
63
  class TestStruct < FFI::Struct
@@ -69,12 +69,12 @@ describe FFI::Struct, ' with inline callback functions' do
69
69
  attach_function :struct_call_sub_cb, [TestStruct, :int, :int], :int
70
70
  end
71
71
 
72
- s = CallbackMember::TestStruct.new
72
+ s = CallbackMember3::TestStruct.new
73
73
  add = Proc.new { |a,b| a+b}
74
74
  s[:add] = add
75
75
  fn = s[:add]
76
76
  fn.respond_to?(:call).should be_true
77
- fn.call(1, 2).should == 3
77
+ fn.call(1, 2).should eq 3
78
78
  end
79
79
  end
80
80
 
@@ -26,7 +26,7 @@ describe FFI::Struct, ' with an initialize function' do
26
26
  self.magic = 42
27
27
  end
28
28
  end
29
- StructWithInitialize.new.magic.should == 42
29
+ StructWithInitialize.new.magic.should eq 42
30
30
  end
31
31
  end
32
32
 
@@ -41,6 +41,6 @@ describe FFI::ManagedStruct, ' with an initialize function' do
41
41
  end
42
42
  def self.release;end
43
43
  end
44
- ManagedStructWithInitialize.new.magic.should == 42
44
+ ManagedStructWithInitialize.new.magic.should eq 42
45
45
  end
46
46
  end
@@ -21,42 +21,42 @@ describe FFI::Struct do
21
21
  Class.new(FFI::Struct) do
22
22
  packed
23
23
  layout :c, :char, :i, :int
24
- end.size.should == 5
24
+ end.size.should eq 5
25
25
  end
26
26
 
27
27
  it "packed :char followed by :int should have alignment of 1" do
28
28
  Class.new(FFI::Struct) do
29
29
  packed
30
30
  layout :c, :char, :i, :int
31
- end.alignment.should == 1
31
+ end.alignment.should eq 1
32
32
  end
33
33
 
34
34
  it "packed(2) :char followed by :int should have size of 6" do
35
35
  Class.new(FFI::Struct) do
36
36
  packed 2
37
37
  layout :c, :char, :i, :int
38
- end.size.should == 6
38
+ end.size.should eq 6
39
39
  end
40
40
 
41
41
  it "packed(2) :char followed by :int should have alignment of 2" do
42
42
  Class.new(FFI::Struct) do
43
43
  packed 2
44
44
  layout :c, :char, :i, :int
45
- end.alignment.should == 2
45
+ end.alignment.should eq 2
46
46
  end
47
47
 
48
48
  it "packed :short followed by int should have size of 6" do
49
49
  Class.new(FFI::Struct) do
50
50
  packed
51
51
  layout :s, :short, :i, :int
52
- end.size.should == 6
52
+ end.size.should eq 6
53
53
  end
54
54
 
55
55
  it "packed :short followed by int should have alignment of 1" do
56
56
  Class.new(FFI::Struct) do
57
57
  packed
58
58
  layout :s, :short, :i, :int
59
- end.alignment.should == 1
59
+ end.alignment.should eq 1
60
60
  end
61
61
 
62
62
  end
@@ -49,7 +49,7 @@ describe "Struct tests" do
49
49
  smp = FFI::MemoryPointer.new :pointer
50
50
  smp.put_pointer(0, mp)
51
51
  s = PointerMember.new smp
52
- s[:pointer].should == mp
52
+ s[:pointer].should eq mp
53
53
  end
54
54
  it "Struct#[:pointer].nil? for NULL value" do
55
55
  magic = 0x12345678
@@ -58,7 +58,7 @@ describe "Struct tests" do
58
58
  smp = FFI::MemoryPointer.new :pointer
59
59
  smp.put_pointer(0, nil)
60
60
  s = PointerMember.new smp
61
- s[:pointer].null?.should == true
61
+ s[:pointer].null?.should eq true
62
62
  end
63
63
  it "Struct#[:pointer]=" do
64
64
  magic = 0x12345678
@@ -67,10 +67,9 @@ describe "Struct tests" do
67
67
  smp = FFI::MemoryPointer.new :pointer
68
68
  s = PointerMember.new smp
69
69
  s[:pointer] = mp
70
- smp.get_pointer(0).should == mp
70
+ smp.get_pointer(0).should eq mp
71
71
  end
72
72
  it "Struct#[:pointer]=struct" do
73
- magic = 0x12345678
74
73
  smp = FFI::MemoryPointer.new :pointer
75
74
  s = PointerMember.new smp
76
75
  lambda { s[:pointer] = s }.should_not raise_error
@@ -79,7 +78,7 @@ describe "Struct tests" do
79
78
  smp = FFI::MemoryPointer.new :pointer
80
79
  s = PointerMember.new smp
81
80
  s[:pointer] = nil
82
- smp.get_pointer(0).null?.should == true
81
+ smp.get_pointer(0).null?.should eq true
83
82
  end
84
83
  it "Struct#[:string]" do
85
84
  magic = "test"
@@ -88,50 +87,50 @@ describe "Struct tests" do
88
87
  smp = FFI::MemoryPointer.new :pointer
89
88
  smp.put_pointer(0, mp)
90
89
  s = StringMember.new smp
91
- s[:string].should == magic
90
+ s[:string].should eq magic
92
91
  end
93
92
  it "Struct#[:string].nil? for NULL value" do
94
93
  smp = FFI::MemoryPointer.new :pointer
95
94
  smp.put_pointer(0, nil)
96
95
  s = StringMember.new smp
97
- s[:string].nil?.should == true
96
+ s[:string].nil?.should eq true
98
97
  end
99
98
  it "Struct#layout works with :name, :type pairs" do
100
99
  class PairLayout < FFI::Struct
101
100
  layout :a, :int, :b, :long_long
102
101
  end
103
102
  ll_off = (FFI::TYPE_UINT64.alignment == 4 ? 4 : 8)
104
- PairLayout.size.should == (ll_off + 8)
103
+ PairLayout.size.should eq(ll_off + 8)
105
104
  mp = FFI::MemoryPointer.new(PairLayout.size)
106
105
  s = PairLayout.new mp
107
106
  s[:a] = 0x12345678
108
- mp.get_int(0).should == 0x12345678
107
+ mp.get_int(0).should eq 0x12345678
109
108
  s[:b] = 0xfee1deadbeef
110
- mp.get_int64(ll_off).should == 0xfee1deadbeef
109
+ mp.get_int64(ll_off).should eq 0xfee1deadbeef
111
110
  end
112
111
  it "Struct#layout works with :name, :type, offset tuples" do
113
112
  class PairLayout < FFI::Struct
114
113
  layout :a, :int, 0, :b, :long_long, 4
115
114
  end
116
- PairLayout.size.should == (FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
115
+ PairLayout.size.should eq(FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
117
116
  mp = FFI::MemoryPointer.new(PairLayout.size)
118
117
  s = PairLayout.new mp
119
118
  s[:a] = 0x12345678
120
- mp.get_int(0).should == 0x12345678
119
+ mp.get_int(0).should eq 0x12345678
121
120
  s[:b] = 0xfee1deadbeef
122
- mp.get_int64(4).should == 0xfee1deadbeef
121
+ mp.get_int64(4).should eq 0xfee1deadbeef
123
122
  end
124
123
  it "Struct#layout works with mixed :name,:type and :name,:type,offset" do
125
124
  class MixedLayout < FFI::Struct
126
125
  layout :a, :int, :b, :long_long, 4
127
126
  end
128
- MixedLayout.size.should == (FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
127
+ MixedLayout.size.should eq(FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
129
128
  mp = FFI::MemoryPointer.new(MixedLayout.size)
130
129
  s = MixedLayout.new mp
131
130
  s[:a] = 0x12345678
132
- mp.get_int(0).should == 0x12345678
131
+ mp.get_int(0).should eq 0x12345678
133
132
  s[:b] = 0xfee1deadbeef
134
- mp.get_int64(4).should == 0xfee1deadbeef
133
+ mp.get_int64(4).should eq 0xfee1deadbeef
135
134
  end
136
135
  rb_maj, rb_min = RUBY_VERSION.split('.')
137
136
  if rb_maj.to_i >= 1 && rb_min.to_i >= 9 || RUBY_PLATFORM =~ /java/
@@ -140,13 +139,13 @@ describe "Struct tests" do
140
139
  layout :a => :int, :b => :long_long
141
140
  end
142
141
  ll_off = (FFI::TYPE_UINT64.alignment == 4? 4 : 8)
143
- HashLayout.size.should == (ll_off + 8)
142
+ HashLayout.size.should eq(ll_off + 8)
144
143
  mp = FFI::MemoryPointer.new(HashLayout.size)
145
144
  s = HashLayout.new mp
146
145
  s[:a] = 0x12345678
147
- mp.get_int(0).should == 0x12345678
146
+ mp.get_int(0).should eq 0x12345678
148
147
  s[:b] = 0xfee1deadbeef
149
- mp.get_int64(ll_off).should == 0xfee1deadbeef
148
+ mp.get_int64(ll_off).should eq 0xfee1deadbeef
150
149
  end
151
150
  end
152
151
 
@@ -163,8 +162,8 @@ describe "Struct tests" do
163
162
 
164
163
  end
165
164
  s = InitializeWithoutSuper.new(0x1eefbeef, 0xdeadcafebabe)
166
- s[:a].should == 0x1eefbeef
167
- s[:b].should == 0xdeadcafebabe
165
+ s[:a].should eq 0x1eefbeef
166
+ s[:b].should eq 0xdeadcafebabe
168
167
  end
169
168
 
170
169
  it "Can use Struct subclass as parameter type" do
@@ -178,7 +177,7 @@ describe "Struct tests" do
178
177
  end
179
178
  end
180
179
  it "Can use Struct subclass as IN parameter type" do
181
- module StructParam
180
+ module StructParam2
182
181
  extend FFI::Library
183
182
  ffi_lib TestLibrary::PATH
184
183
  class TestStruct < FFI::Struct
@@ -188,7 +187,7 @@ describe "Struct tests" do
188
187
  end
189
188
  end
190
189
  it "Can use Struct subclass as OUT parameter type" do
191
- module StructParam
190
+ module StructParam3
192
191
  extend FFI::Library
193
192
  ffi_lib TestLibrary::PATH
194
193
  class TestStruct < FFI::Struct
@@ -203,7 +202,7 @@ describe "Struct tests" do
203
202
  end
204
203
  s = TestStruct.new
205
204
  s[:i] = 0x12
206
- LibTest.ptr_ret_int32_t(s, 0).should == 0x12
205
+ LibTest.ptr_ret_int32_t(s, 0).should eq 0x12
207
206
  end
208
207
  it ":char member aligned correctly" do
209
208
  class AlignChar < FFI::Struct
@@ -211,7 +210,7 @@ describe "Struct tests" do
211
210
  end
212
211
  s = AlignChar.new
213
212
  s[:v] = 0x12
214
- LibTest.struct_align_s8(s.pointer).should == 0x12
213
+ LibTest.struct_align_s8(s.pointer).should eq 0x12
215
214
  end
216
215
  it ":short member aligned correctly" do
217
216
  class AlignShort < FFI::Struct
@@ -219,7 +218,7 @@ describe "Struct tests" do
219
218
  end
220
219
  s = AlignShort.alloc_in
221
220
  s[:v] = 0x1234
222
- LibTest.struct_align_s16(s.pointer).should == 0x1234
221
+ LibTest.struct_align_s16(s.pointer).should eq 0x1234
223
222
  end
224
223
  it ":int member aligned correctly" do
225
224
  class AlignInt < FFI::Struct
@@ -227,7 +226,7 @@ describe "Struct tests" do
227
226
  end
228
227
  s = AlignInt.alloc_in
229
228
  s[:v] = 0x12345678
230
- LibTest.struct_align_s32(s.pointer).should == 0x12345678
229
+ LibTest.struct_align_s32(s.pointer).should eq 0x12345678
231
230
  end
232
231
  it ":long_long member aligned correctly" do
233
232
  class AlignLongLong < FFI::Struct
@@ -235,7 +234,7 @@ describe "Struct tests" do
235
234
  end
236
235
  s = AlignLongLong.alloc_in
237
236
  s[:v] = 0x123456789abcdef0
238
- LibTest.struct_align_s64(s.pointer).should == 0x123456789abcdef0
237
+ LibTest.struct_align_s64(s.pointer).should eq 0x123456789abcdef0
239
238
  end
240
239
  it ":long member aligned correctly" do
241
240
  class AlignLong < FFI::Struct
@@ -243,7 +242,7 @@ describe "Struct tests" do
243
242
  end
244
243
  s = AlignLong.alloc_in
245
244
  s[:v] = 0x12345678
246
- LibTest.struct_align_long(s.pointer).should == 0x12345678
245
+ LibTest.struct_align_long(s.pointer).should eq 0x12345678
247
246
  end
248
247
  it ":float member aligned correctly" do
249
248
  class AlignFloat < FFI::Struct
@@ -268,7 +267,7 @@ describe "Struct tests" do
268
267
  s = ULPStruct.alloc_in
269
268
  s[:ul] = 0xdeadbeef
270
269
  s[:p] = LibTest.ptr_from_address(0x12345678)
271
- s.pointer.get_ulong(0).should == 0xdeadbeef
270
+ s.pointer.get_ulong(0).should eq 0xdeadbeef
272
271
  end
273
272
  def test_num_field(type, v)
274
273
  klass = Class.new(FFI::Struct)
@@ -276,9 +275,9 @@ describe "Struct tests" do
276
275
 
277
276
  s = klass.new
278
277
  s[:v] = v
279
- s.pointer.send("get_#{type.to_s}", 0).should == v
278
+ s.pointer.send("get_#{type.to_s}", 0).should eq v
280
279
  s.pointer.send("put_#{type.to_s}", 0, 0)
281
- s[:v].should == 0
280
+ s[:v].should eq 0
282
281
  end
283
282
  def self.int_field_test(type, values)
284
283
  values.each do |v|
@@ -333,8 +332,8 @@ describe "Struct tests" do
333
332
  s = EnumFields::TestStruct.new
334
333
  s[:c] = :c3
335
334
 
336
- s.pointer.get_uint(FFI::Type::INT32.size).should == 30
337
- s[:c].should == :c3
335
+ s.pointer.get_uint(FFI::Type::INT32.size).should eq 30
336
+ s[:c].should eq :c3
338
337
  end
339
338
 
340
339
  it "array of :enum field" do
@@ -344,11 +343,11 @@ describe "Struct tests" do
344
343
  end
345
344
 
346
345
  EnumFields::TestEnum.symbols.each_with_index do |val, i|
347
- s.pointer.get_uint(FFI::Type::INT32.size * (2 + i)).should == EnumFields::TestEnum[val]
346
+ s.pointer.get_uint(FFI::Type::INT32.size * (2 + i)).should eq EnumFields::TestEnum[val]
348
347
  end
349
348
 
350
349
  s[:d].each_with_index do |val, i|
351
- val.should == EnumFields::TestEnum.symbols[i]
350
+ val.should eq EnumFields::TestEnum.symbols[i]
352
351
  end
353
352
  end
354
353
 
@@ -370,8 +369,8 @@ describe "Struct tests" do
370
369
  sub_proc = lambda { |a, b| a-b }
371
370
  s[:add] = add_proc
372
371
  s[:sub] = sub_proc
373
- CallbackMember.struct_call_add_cb(s, 40, 2).should == 42
374
- CallbackMember.struct_call_sub_cb(s, 44, 2).should == 42
372
+ CallbackMember.struct_call_add_cb(s, 40, 2).should eq 42
373
+ CallbackMember.struct_call_sub_cb(s, 44, 2).should eq 42
375
374
  end
376
375
  it "Can return its members as a list" do
377
376
  class TestStruct < FFI::Struct
@@ -395,16 +394,16 @@ describe "Struct tests" do
395
394
  layout :a, :int, :b, :int, :c, :int
396
395
  end
397
396
  s = TestStruct.new
398
- s.offsets.should == [[:a, 0], [:b, 4], [:c, 8]]
399
- TestStruct.offsets.should == [[:a, 0], [:b, 4], [:c, 8]]
397
+ s.offsets.should eq [[:a, 0], [:b, 4], [:c, 8]]
398
+ TestStruct.offsets.should eq [[:a, 0], [:b, 4], [:c, 8]]
400
399
  end
401
400
  it "Struct#offset_of returns offset of field within struct" do
402
401
  class TestStruct < FFI::Struct
403
402
  layout :a, :int, :b, :int, :c, :int
404
403
  end
405
- TestStruct.offset_of(:a).should == 0
406
- TestStruct.offset_of(:b).should == 4
407
- TestStruct.offset_of(:c).should == 8
404
+ TestStruct.offset_of(:a).should eq 0
405
+ TestStruct.offset_of(:b).should eq 4
406
+ TestStruct.offset_of(:c).should eq 8
408
407
  end
409
408
  end
410
409
 
@@ -426,22 +425,22 @@ describe FFI::Struct, ' with a nested struct field' do
426
425
  end
427
426
  it 'should align correctly nested struct field' do
428
427
  @cs[:ns][:i] = 123
429
- LibTest.struct_align_nested_struct(@cs.to_ptr).should == 123
428
+ LibTest.struct_align_nested_struct(@cs.to_ptr).should eq 123
430
429
  end
431
430
  it 'should correctly calculate Container size (in bytes)' do
432
- LibTest::ContainerStruct.size.should == 8
431
+ LibTest::ContainerStruct.size.should eq 8
433
432
  end
434
433
  it 'should return a Struct object when the field is accessed' do
435
434
  @cs[:ns].is_a?(FFI::Struct).should be_true
436
435
  end
437
436
  it 'should read a value from memory' do
438
437
  @cs = LibTest::ContainerStruct.new(LibTest.struct_make_container_struct(123))
439
- @cs[:ns][:i].should == 123
438
+ @cs[:ns][:i].should eq 123
440
439
  end
441
440
  it 'should write a value to memory' do
442
441
  @cs = LibTest::ContainerStruct.new(LibTest.struct_make_container_struct(123))
443
442
  @cs[:ns][:i] = 456
444
- LibTest.struct_align_nested_struct(@cs.to_ptr).should == 456
443
+ LibTest.struct_align_nested_struct(@cs.to_ptr).should eq 456
445
444
  end
446
445
  end
447
446
 
@@ -465,11 +464,11 @@ describe FFI::Struct, ' with a nested array of structs' do
465
464
 
466
465
  it 'should align correctly nested struct field' do
467
466
  @cs[:ns][0][:i] = 123
468
- InlineArrayOfStructs.struct_align_nested_struct(@cs.to_ptr).should == 123
467
+ InlineArrayOfStructs.struct_align_nested_struct(@cs.to_ptr).should eq 123
469
468
  end
470
469
 
471
470
  it 'should correctly calculate Container size (in bytes)' do
472
- InlineArrayOfStructs::ContainerStruct.size.should == 8
471
+ InlineArrayOfStructs::ContainerStruct.size.should eq 8
473
472
  end
474
473
 
475
474
  it 'should return a Struct object when the field is accessed' do
@@ -478,20 +477,20 @@ describe FFI::Struct, ' with a nested array of structs' do
478
477
 
479
478
  it 'should read a value from memory' do
480
479
  @cs = InlineArrayOfStructs::ContainerStruct.new(InlineArrayOfStructs.struct_make_container_struct(123))
481
- @cs[:ns][0][:i].should == 123
480
+ @cs[:ns][0][:i].should eq 123
482
481
  end
483
482
 
484
483
  it 'should write a value to memory' do
485
484
  @cs = InlineArrayOfStructs::ContainerStruct.new(InlineArrayOfStructs.struct_make_container_struct(123))
486
485
  @cs[:ns][0][:i] = 456
487
- InlineArrayOfStructs.struct_align_nested_struct(@cs.to_ptr).should == 456
486
+ InlineArrayOfStructs.struct_align_nested_struct(@cs.to_ptr).should eq 456
488
487
  end
489
488
 
490
489
  it 'should support Enumerable#each' do
491
490
  @cs = InlineArrayOfStructs::ContainerStruct.new(InlineArrayOfStructs.struct_make_container_struct(123))
492
491
  ints = []
493
492
  @cs[:ns].each { |s| ints << s[:i] }
494
- ints[0].should == 123
493
+ ints[0].should eq 123
495
494
  end
496
495
  end
497
496
 
@@ -519,22 +518,22 @@ describe FFI::Struct, ' by value' do
519
518
 
520
519
  it 'return using pre-set values' do
521
520
  s = LibTest.struct_return_s8s32
522
- s[:s8].should == 0x7f
523
- s[:s32].should == 0x12345678
521
+ s[:s8].should eq 0x7f
522
+ s[:s32].should eq 0x12345678
524
523
  end
525
524
 
526
525
  it 'return using passed in values' do
527
526
  s = LibTest.struct_s8s32_set(123, 456789)
528
- s[:s8].should == 123
529
- s[:s32].should == 456789
527
+ s[:s8].should eq 123
528
+ s[:s32].should eq 456789
530
529
  end
531
530
 
532
531
  it 'parameter' do
533
532
  s = LibTest::S8S32.new
534
533
  s[:s8] = 0x12
535
534
  s[:s32] = 0x34567890
536
- LibTest.struct_s8s32_get_s8(s).should == 0x12
537
- LibTest.struct_s8s32_get_s32(s).should == 0x34567890
535
+ LibTest.struct_s8s32_get_s8(s).should eq 0x12
536
+ LibTest.struct_s8s32_get_s32(s).should eq 0x34567890
538
537
  end
539
538
 
540
539
  it 'parameter with following s32' do
@@ -542,7 +541,7 @@ describe FFI::Struct, ' by value' do
542
541
  s[:s8] = 0x12
543
542
  s[:s32] = 0x34567890
544
543
 
545
- LibTest.struct_s8s32_s32_ret_s32(s, 0x1eefdead).should == 0x1eefdead
544
+ LibTest.struct_s8s32_s32_ret_s32(s, 0x1eefdead).should eq 0x1eefdead
546
545
  end
547
546
 
548
547
  it 'parameter with following s64' do
@@ -550,14 +549,14 @@ describe FFI::Struct, ' by value' do
550
549
  s[:s8] = 0x12
551
550
  s[:s32] = 0x34567890
552
551
 
553
- LibTest.struct_s8s32_s64_ret_s64(s, 0xdeadcafebabe).should == 0xdeadcafebabe
552
+ LibTest.struct_s8s32_s64_ret_s64(s, 0xdeadcafebabe).should eq 0xdeadcafebabe
554
553
  end
555
554
 
556
555
  it 'varargs returning a struct' do
557
556
  string = "test"
558
557
  s = LibTest.struct_varargs_ret_struct_string(4, :string, string)
559
- s[:len].should == string.length
560
- s[:bytes].should == string
558
+ s[:len].should eq string.length
559
+ s[:bytes].should eq string
561
560
  end
562
561
  end
563
562
 
@@ -575,26 +574,26 @@ describe FFI::Struct, ' with an array field' do
575
574
  @s = LibTest::StructWithArray.new
576
575
  end
577
576
  it 'should correctly calculate StructWithArray size (in bytes)' do
578
- LibTest::StructWithArray.size.should == 24
577
+ LibTest::StructWithArray.size.should eq 24
579
578
  end
580
579
  it 'should read values from memory' do
581
580
  @s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
582
- @s[:a].to_a.should == [0, 1, 2, 3, 4]
581
+ @s[:a].to_a.should eq [0, 1, 2, 3, 4]
583
582
  end
584
583
  # it 'should cache array object for successive calls' do
585
- # @s[:a].object_id.should == @s[:a].object_id
584
+ # @s[:a].object_id.should eq @s[:a].object_id
586
585
  # end
587
586
  it 'should return the number of elements in the array field' do
588
587
  @s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
589
- @s[:a].size.should == 5
588
+ @s[:a].size.should eq 5
590
589
  end
591
590
  it 'should allow iteration through the array elements' do
592
591
  @s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
593
- @s[:a].each_with_index { |elem, i| elem.should == i }
592
+ @s[:a].each_with_index { |elem, i| elem.should eq i }
594
593
  end
595
594
  it 'should return the pointer to the array' do
596
595
  @s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
597
- @s[:a].to_ptr.should == LibTest::struct_field_array(@s.to_ptr)
596
+ @s[:a].to_ptr.should eq LibTest::struct_field_array(@s.to_ptr)
598
597
  end
599
598
  end
600
599
 
@@ -614,21 +613,21 @@ describe 'BuggedStruct' do
614
613
  attach_function :bugged_struct_size, [], :uint
615
614
  end
616
615
  it 'should return its correct size' do
617
- LibTest::BuggedStruct.size.should == LibTest.bugged_struct_size
616
+ LibTest::BuggedStruct.size.should eq LibTest.bugged_struct_size
618
617
  end
619
618
  it "offsets within struct should be correct" do
620
- LibTest::BuggedStruct.offset_of(:visible).should == 0
621
- LibTest::BuggedStruct.offset_of(:x).should == 4
622
- LibTest::BuggedStruct.offset_of(:y).should == 8
623
- LibTest::BuggedStruct.offset_of(:rx).should == 12
624
- LibTest::BuggedStruct.offset_of(:ry).should == 14
625
- LibTest::BuggedStruct.offset_of(:order).should == 16
626
- LibTest::BuggedStruct.offset_of(:size).should == 17
619
+ LibTest::BuggedStruct.offset_of(:visible).should eq 0
620
+ LibTest::BuggedStruct.offset_of(:x).should eq 4
621
+ LibTest::BuggedStruct.offset_of(:y).should eq 8
622
+ LibTest::BuggedStruct.offset_of(:rx).should eq 12
623
+ LibTest::BuggedStruct.offset_of(:ry).should eq 14
624
+ LibTest::BuggedStruct.offset_of(:order).should eq 16
625
+ LibTest::BuggedStruct.offset_of(:size).should eq 17
627
626
  end
628
627
  it 'should return correct field/offset pairs' do
629
628
  LibTest::BuggedStruct.offsets.sort do |a, b|
630
629
  a[1] <=> b[1]
631
- end.should == [[:visible, 0], [:x, 4], [:y, 8], [:rx, 12], [:ry, 14], [:order, 16], [:size, 17]]
630
+ end.should eq [[:visible, 0], [:x, 4], [:y, 8], [:rx, 12], [:ry, 14], [:order, 16], [:size, 17]]
632
631
  end
633
632
  end
634
633
 
@@ -638,11 +637,11 @@ describe "Struct allocation" do
638
637
  layout :i, :uint
639
638
  end
640
639
  p = FFI::MemoryPointer.new(S, 2)
641
- p.total.should == 8
642
- p.type_size.should == 4
640
+ p.total.should eq 8
641
+ p.type_size.should eq 4
643
642
  p.put_uint(4, 0xdeadbeef)
644
- S.new(p[1])[:i].should == 0xdeadbeef
645
- p[1].address.should == (p[0].address + 4)
643
+ S.new(p[1])[:i].should eq 0xdeadbeef
644
+ p[1].address.should eq(p[0].address + 4)
646
645
  end
647
646
 
648
647
  it "Buffer.new(Struct, 2)" do
@@ -650,10 +649,10 @@ describe "Struct allocation" do
650
649
  layout :i, :uint
651
650
  end
652
651
  p = FFI::Buffer.new(S, 2)
653
- p.total.should == 8
654
- p.type_size.should == 4
652
+ p.total.should eq 8
653
+ p.type_size.should eq 4
655
654
  p.put_uint(4, 0xdeadbeef)
656
- S.new(p[1])[:i].should == 0xdeadbeef
655
+ S.new(p[1])[:i].should eq 0xdeadbeef
657
656
  end
658
657
 
659
658
  it "null? should be true when initialized with NULL pointer" do
@@ -669,4 +668,15 @@ describe "Struct allocation" do
669
668
  end
670
669
  S.new(FFI::MemoryPointer.new(S)).null?.should be_false
671
670
  end
671
+
672
+ it "supports :bool as a struct member" do
673
+ lambda do
674
+ c = Class.new(FFI::Struct) do
675
+ layout :b, :bool
676
+ end
677
+ struct = c.new
678
+ struct[:b] = ! struct[:b]
679
+ end.should_not raise_error
680
+ end
681
+
672
682
  end