ffi 0.2.0 → 0.3.0

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 (305) hide show
  1. data/README.rdoc +19 -0
  2. data/Rakefile +65 -55
  3. data/ext/{AbstractMemory.c → ffi_c/AbstractMemory.c} +67 -40
  4. data/ext/{AbstractMemory.h → ffi_c/AbstractMemory.h} +10 -8
  5. data/ext/{AutoPointer.c → ffi_c/AutoPointer.c} +17 -8
  6. data/ext/{AutoPointer.h → ffi_c/AutoPointer.h} +0 -0
  7. data/ext/ffi_c/Buffer.c +136 -0
  8. data/ext/{Callback.c → ffi_c/Callback.c} +60 -35
  9. data/ext/{Callback.h → ffi_c/Callback.h} +1 -7
  10. data/ext/{Invoker.c → ffi_c/Invoker.c} +472 -102
  11. data/ext/ffi_c/MemoryPointer.c +146 -0
  12. data/ext/{MemoryPointer.h → ffi_c/MemoryPointer.h} +2 -7
  13. data/ext/ffi_c/NativeLibrary.c +149 -0
  14. data/ext/{NativeLibrary.h → ffi_c/NativeLibrary.h} +0 -0
  15. data/ext/ffi_c/NullPointer.c +104 -0
  16. data/ext/{Platform.c → ffi_c/Platform.c} +0 -0
  17. data/ext/{Platform.h → ffi_c/Platform.h} +0 -7
  18. data/ext/{Pointer.c → ffi_c/Pointer.c} +35 -15
  19. data/ext/{Pointer.h → ffi_c/Pointer.h} +4 -2
  20. data/ext/ffi_c/Struct.c +542 -0
  21. data/ext/ffi_c/Struct.h +26 -0
  22. data/ext/ffi_c/Types.c +76 -0
  23. data/ext/{Types.h → ffi_c/Types.h} +23 -28
  24. data/ext/{compat.h → ffi_c/compat.h} +2 -2
  25. data/ext/{extconf.rb → ffi_c/extconf.rb} +12 -7
  26. data/ext/ffi_c/ffi.c +99 -0
  27. data/ext/ffi_c/ffi.mk +23 -0
  28. data/ext/{libffi.darwin.mk → ffi_c/libffi.darwin.mk} +0 -0
  29. data/ext/ffi_c/libffi.mk +11 -0
  30. data/ext/{libffi → ffi_c/libffi}/ChangeLog +0 -0
  31. data/ext/{libffi → ffi_c/libffi}/ChangeLog.libffi +0 -0
  32. data/ext/{libffi → ffi_c/libffi}/ChangeLog.libgcj +0 -0
  33. data/ext/{libffi → ffi_c/libffi}/ChangeLog.v1 +0 -0
  34. data/ext/{libffi → ffi_c/libffi}/LICENSE +0 -0
  35. data/ext/{libffi → ffi_c/libffi}/Makefile.am +0 -0
  36. data/ext/{libffi → ffi_c/libffi}/Makefile.in +0 -0
  37. data/ext/{libffi → ffi_c/libffi}/README +0 -0
  38. data/ext/{libffi → ffi_c/libffi}/TODO +0 -0
  39. data/ext/{libffi → ffi_c/libffi}/acinclude.m4 +0 -0
  40. data/ext/{libffi → ffi_c/libffi}/aclocal.m4 +0 -0
  41. data/ext/{libffi → ffi_c/libffi}/compile +0 -0
  42. data/ext/{libffi → ffi_c/libffi}/config.guess +0 -0
  43. data/ext/{libffi → ffi_c/libffi}/config.sub +0 -0
  44. data/ext/{libffi → ffi_c/libffi}/configure +0 -0
  45. data/ext/{libffi → ffi_c/libffi}/configure.ac +0 -0
  46. data/ext/{libffi → ffi_c/libffi}/configure.host +0 -0
  47. data/ext/{libffi → ffi_c/libffi}/depcomp +0 -0
  48. data/ext/{libffi → ffi_c/libffi}/doc/libffi.info +0 -0
  49. data/ext/{libffi → ffi_c/libffi}/doc/libffi.texi +0 -0
  50. data/ext/{libffi → ffi_c/libffi}/doc/stamp-vti +0 -0
  51. data/ext/{libffi → ffi_c/libffi}/doc/version.texi +0 -0
  52. data/ext/{libffi → ffi_c/libffi}/fficonfig.h.in +0 -0
  53. data/ext/{libffi → ffi_c/libffi}/include/Makefile.am +0 -0
  54. data/ext/{libffi → ffi_c/libffi}/include/Makefile.in +0 -0
  55. data/ext/{libffi → ffi_c/libffi}/include/ffi.h.in +0 -0
  56. data/ext/{libffi → ffi_c/libffi}/include/ffi_common.h +0 -0
  57. data/ext/{libffi → ffi_c/libffi}/install-sh +0 -0
  58. data/ext/{libffi → ffi_c/libffi}/libffi.pc.in +0 -0
  59. data/ext/{libffi → ffi_c/libffi}/libtool-version +0 -0
  60. data/ext/{libffi → ffi_c/libffi}/ltcf-c.sh +0 -0
  61. data/ext/{libffi → ffi_c/libffi}/ltcf-cxx.sh +0 -0
  62. data/ext/{libffi → ffi_c/libffi}/ltcf-gcj.sh +0 -0
  63. data/ext/{libffi → ffi_c/libffi}/ltconfig +0 -0
  64. data/ext/{libffi → ffi_c/libffi}/ltmain.sh +0 -0
  65. data/ext/{libffi → ffi_c/libffi}/man/Makefile.am +0 -0
  66. data/ext/{libffi → ffi_c/libffi}/man/Makefile.in +0 -0
  67. data/ext/{libffi → ffi_c/libffi}/man/ffi.3 +0 -0
  68. data/ext/{libffi → ffi_c/libffi}/man/ffi_call.3 +0 -0
  69. data/ext/{libffi → ffi_c/libffi}/man/ffi_prep_cif.3 +0 -0
  70. data/ext/{libffi → ffi_c/libffi}/mdate-sh +0 -0
  71. data/ext/{libffi → ffi_c/libffi}/missing +0 -0
  72. data/ext/{libffi → ffi_c/libffi}/mkinstalldirs +0 -0
  73. data/ext/{libffi → ffi_c/libffi}/src/alpha/ffi.c +0 -0
  74. data/ext/{libffi → ffi_c/libffi}/src/alpha/ffitarget.h +0 -0
  75. data/ext/{libffi → ffi_c/libffi}/src/alpha/osf.S +0 -0
  76. data/ext/{libffi → ffi_c/libffi}/src/arm/ffi.c +0 -0
  77. data/ext/{libffi → ffi_c/libffi}/src/arm/ffitarget.h +0 -0
  78. data/ext/{libffi → ffi_c/libffi}/src/arm/sysv.S +0 -0
  79. data/ext/{libffi → ffi_c/libffi}/src/closures.c +0 -0
  80. data/ext/{libffi → ffi_c/libffi}/src/cris/ffi.c +0 -0
  81. data/ext/{libffi → ffi_c/libffi}/src/cris/ffitarget.h +0 -0
  82. data/ext/{libffi → ffi_c/libffi}/src/cris/sysv.S +0 -0
  83. data/ext/{libffi → ffi_c/libffi}/src/debug.c +0 -0
  84. data/ext/{libffi → ffi_c/libffi}/src/dlmalloc.c +0 -0
  85. data/ext/{libffi → ffi_c/libffi}/src/frv/eabi.S +0 -0
  86. data/ext/{libffi → ffi_c/libffi}/src/frv/ffi.c +0 -0
  87. data/ext/{libffi → ffi_c/libffi}/src/frv/ffitarget.h +0 -0
  88. data/ext/{libffi → ffi_c/libffi}/src/ia64/ffi.c +0 -0
  89. data/ext/{libffi → ffi_c/libffi}/src/ia64/ffitarget.h +0 -0
  90. data/ext/{libffi → ffi_c/libffi}/src/ia64/ia64_flags.h +0 -0
  91. data/ext/{libffi → ffi_c/libffi}/src/ia64/unix.S +0 -0
  92. data/ext/{libffi → ffi_c/libffi}/src/java_raw_api.c +0 -0
  93. data/ext/{libffi → ffi_c/libffi}/src/m32r/ffi.c +0 -0
  94. data/ext/{libffi → ffi_c/libffi}/src/m32r/ffitarget.h +0 -0
  95. data/ext/{libffi → ffi_c/libffi}/src/m32r/sysv.S +0 -0
  96. data/ext/{libffi → ffi_c/libffi}/src/m68k/ffi.c +0 -0
  97. data/ext/{libffi → ffi_c/libffi}/src/m68k/ffitarget.h +0 -0
  98. data/ext/{libffi → ffi_c/libffi}/src/m68k/sysv.S +0 -0
  99. data/ext/{libffi → ffi_c/libffi}/src/mips/ffi.c +0 -0
  100. data/ext/{libffi → ffi_c/libffi}/src/mips/ffitarget.h +0 -0
  101. data/ext/{libffi → ffi_c/libffi}/src/mips/n32.S +0 -0
  102. data/ext/{libffi → ffi_c/libffi}/src/mips/o32.S +0 -0
  103. data/ext/{libffi → ffi_c/libffi}/src/pa/ffi.c +0 -0
  104. data/ext/{libffi → ffi_c/libffi}/src/pa/ffitarget.h +0 -0
  105. data/ext/{libffi → ffi_c/libffi}/src/pa/hpux32.S +0 -0
  106. data/ext/{libffi → ffi_c/libffi}/src/pa/linux.S +0 -0
  107. data/ext/{libffi → ffi_c/libffi}/src/powerpc/aix.S +0 -0
  108. data/ext/{libffi → ffi_c/libffi}/src/powerpc/aix_closure.S +0 -0
  109. data/ext/{libffi → ffi_c/libffi}/src/powerpc/asm.h +0 -0
  110. data/ext/{libffi → ffi_c/libffi}/src/powerpc/darwin.S +0 -0
  111. data/ext/{libffi → ffi_c/libffi}/src/powerpc/darwin_closure.S +0 -0
  112. data/ext/{libffi → ffi_c/libffi}/src/powerpc/ffi.c +0 -0
  113. data/ext/{libffi → ffi_c/libffi}/src/powerpc/ffi_darwin.c +0 -0
  114. data/ext/{libffi → ffi_c/libffi}/src/powerpc/ffitarget.h +0 -0
  115. data/ext/{libffi → ffi_c/libffi}/src/powerpc/linux64.S +0 -0
  116. data/ext/{libffi → ffi_c/libffi}/src/powerpc/linux64_closure.S +0 -0
  117. data/ext/{libffi → ffi_c/libffi}/src/powerpc/ppc_closure.S +0 -0
  118. data/ext/{libffi → ffi_c/libffi}/src/powerpc/sysv.S +0 -0
  119. data/ext/{libffi → ffi_c/libffi}/src/prep_cif.c +0 -0
  120. data/ext/{libffi → ffi_c/libffi}/src/raw_api.c +0 -0
  121. data/ext/{libffi → ffi_c/libffi}/src/s390/ffi.c +0 -0
  122. data/ext/{libffi → ffi_c/libffi}/src/s390/ffitarget.h +0 -0
  123. data/ext/{libffi → ffi_c/libffi}/src/s390/sysv.S +0 -0
  124. data/ext/{libffi → ffi_c/libffi}/src/sh/ffi.c +0 -0
  125. data/ext/{libffi → ffi_c/libffi}/src/sh/ffitarget.h +0 -0
  126. data/ext/{libffi → ffi_c/libffi}/src/sh/sysv.S +0 -0
  127. data/ext/{libffi → ffi_c/libffi}/src/sh64/ffi.c +0 -0
  128. data/ext/{libffi → ffi_c/libffi}/src/sh64/ffitarget.h +0 -0
  129. data/ext/{libffi → ffi_c/libffi}/src/sh64/sysv.S +0 -0
  130. data/ext/{libffi → ffi_c/libffi}/src/sparc/ffi.c +0 -0
  131. data/ext/{libffi → ffi_c/libffi}/src/sparc/ffitarget.h +0 -0
  132. data/ext/{libffi → ffi_c/libffi}/src/sparc/v8.S +0 -0
  133. data/ext/{libffi → ffi_c/libffi}/src/sparc/v9.S +0 -0
  134. data/ext/{libffi → ffi_c/libffi}/src/types.c +0 -0
  135. data/ext/{libffi → ffi_c/libffi}/src/x86/darwin.S +0 -0
  136. data/ext/{libffi → ffi_c/libffi}/src/x86/darwin64.S +0 -0
  137. data/ext/{libffi → ffi_c/libffi}/src/x86/ffi.c +0 -0
  138. data/ext/{libffi → ffi_c/libffi}/src/x86/ffi64.c +0 -0
  139. data/ext/{libffi → ffi_c/libffi}/src/x86/ffitarget.h +0 -0
  140. data/ext/{libffi → ffi_c/libffi}/src/x86/freebsd.S +0 -0
  141. data/ext/{libffi → ffi_c/libffi}/src/x86/sysv.S +0 -0
  142. data/ext/{libffi → ffi_c/libffi}/src/x86/unix64.S +0 -0
  143. data/ext/{libffi → ffi_c/libffi}/src/x86/win32.S +0 -0
  144. data/ext/{libffi → ffi_c/libffi}/testsuite/Makefile.am +0 -0
  145. data/ext/{libffi → ffi_c/libffi}/testsuite/Makefile.in +0 -0
  146. data/ext/{libffi → ffi_c/libffi}/testsuite/config/default.exp +0 -0
  147. data/ext/{libffi → ffi_c/libffi}/testsuite/lib/libffi-dg.exp +0 -0
  148. data/ext/{libffi → ffi_c/libffi}/testsuite/lib/target-libpath.exp +0 -0
  149. data/ext/{libffi → ffi_c/libffi}/testsuite/lib/wrapper.exp +0 -0
  150. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/call.exp +0 -0
  151. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/closure_fn0.c +0 -0
  152. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/closure_fn1.c +0 -0
  153. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/closure_fn2.c +0 -0
  154. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/closure_fn3.c +0 -0
  155. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/closure_fn4.c +0 -0
  156. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/closure_fn5.c +0 -0
  157. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/closure_fn6.c +0 -0
  158. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/closure_stdcall.c +0 -0
  159. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_12byte.c +0 -0
  160. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_16byte.c +0 -0
  161. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_18byte.c +0 -0
  162. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_19byte.c +0 -0
  163. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_1_1byte.c +0 -0
  164. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_20byte.c +0 -0
  165. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_20byte1.c +0 -0
  166. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_24byte.c +0 -0
  167. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_2byte.c +0 -0
  168. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_3_1byte.c +0 -0
  169. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_3byte1.c +0 -0
  170. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_3byte2.c +0 -0
  171. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_4_1byte.c +0 -0
  172. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_4byte.c +0 -0
  173. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_5_1_byte.c +0 -0
  174. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_5byte.c +0 -0
  175. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_64byte.c +0 -0
  176. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_6_1_byte.c +0 -0
  177. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_6byte.c +0 -0
  178. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_7_1_byte.c +0 -0
  179. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_7byte.c +0 -0
  180. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_8byte.c +0 -0
  181. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_9byte1.c +0 -0
  182. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_9byte2.c +0 -0
  183. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_align_double.c +0 -0
  184. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_align_float.c +0 -0
  185. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_align_longdouble.c +0 -0
  186. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_align_pointer.c +0 -0
  187. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_align_sint16.c +0 -0
  188. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_align_sint32.c +0 -0
  189. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_align_sint64.c +0 -0
  190. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_align_uint16.c +0 -0
  191. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_align_uint32.c +0 -0
  192. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_align_uint64.c +0 -0
  193. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_double.c +0 -0
  194. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_float.c +0 -0
  195. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_multi_schar.c +0 -0
  196. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_multi_sshort.c +0 -0
  197. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_multi_sshortchar.c +0 -0
  198. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_multi_uchar.c +0 -0
  199. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_multi_ushort.c +0 -0
  200. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_multi_ushortchar.c +0 -0
  201. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_schar.c +0 -0
  202. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_sint.c +0 -0
  203. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_sshort.c +0 -0
  204. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_uchar.c +0 -0
  205. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_uint.c +0 -0
  206. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_ulonglong.c +0 -0
  207. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/cls_ushort.c +0 -0
  208. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/ffitest.h +0 -0
  209. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/float.c +0 -0
  210. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/float1.c +0 -0
  211. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/float2.c +0 -0
  212. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/float3.c +0 -0
  213. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/float4.c +0 -0
  214. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/many.c +0 -0
  215. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/many_win32.c +0 -0
  216. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/negint.c +0 -0
  217. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/nested_struct.c +0 -0
  218. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/nested_struct1.c +0 -0
  219. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/nested_struct10.c +0 -0
  220. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/nested_struct2.c +0 -0
  221. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/nested_struct3.c +0 -0
  222. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/nested_struct4.c +0 -0
  223. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/nested_struct5.c +0 -0
  224. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/nested_struct6.c +0 -0
  225. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/nested_struct7.c +0 -0
  226. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/nested_struct8.c +0 -0
  227. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/nested_struct9.c +0 -0
  228. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/problem1.c +0 -0
  229. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/promotion.c +0 -0
  230. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/pyobjc-tc.c +0 -0
  231. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_dbl.c +0 -0
  232. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_dbl1.c +0 -0
  233. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_dbl2.c +0 -0
  234. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_fl.c +0 -0
  235. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_fl1.c +0 -0
  236. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_fl2.c +0 -0
  237. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_fl3.c +0 -0
  238. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_ldl.c +0 -0
  239. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_ll.c +0 -0
  240. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_ll1.c +0 -0
  241. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_sc.c +0 -0
  242. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_sl.c +0 -0
  243. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_uc.c +0 -0
  244. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/return_ul.c +0 -0
  245. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/strlen.c +0 -0
  246. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/strlen_win32.c +0 -0
  247. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/struct1.c +0 -0
  248. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/struct2.c +0 -0
  249. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/struct3.c +0 -0
  250. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/struct4.c +0 -0
  251. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/struct5.c +0 -0
  252. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/struct6.c +0 -0
  253. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/struct7.c +0 -0
  254. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/struct8.c +0 -0
  255. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.call/struct9.c +0 -0
  256. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.special/ffitestcxx.h +0 -0
  257. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.special/special.exp +0 -0
  258. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.special/unwindtest.cc +0 -0
  259. data/ext/{libffi → ffi_c/libffi}/testsuite/libffi.special/unwindtest_ffi_call.cc +0 -0
  260. data/ext/{libffi → ffi_c/libffi}/texinfo.tex +0 -0
  261. data/ext/{rbffi.h → ffi_c/rbffi.h} +1 -8
  262. data/lib/ffi/autopointer.rb +7 -7
  263. data/lib/ffi/buffer.rb +0 -25
  264. data/lib/ffi/ffi.rb +1 -0
  265. data/lib/ffi/library.rb +103 -37
  266. data/lib/ffi/memorypointer.rb +25 -28
  267. data/lib/ffi/platform.rb +2 -2
  268. data/lib/ffi/pointer.rb +21 -7
  269. data/lib/ffi/struct.rb +161 -179
  270. data/lib/ffi/types.rb +3 -3
  271. data/lib/ffi/union.rb +17 -0
  272. data/nbproject/configurations.xml +98 -88
  273. data/samples/hello.rb +1 -2
  274. data/samples/sample_helper.rb +6 -0
  275. data/{specs → spec/ffi}/buffer_spec.rb +0 -0
  276. data/{specs → spec/ffi}/callback_spec.rb +114 -89
  277. data/{specs → spec/ffi}/errno_spec.rb +0 -0
  278. data/spec/ffi/library_spec.rb +144 -0
  279. data/{specs → spec/ffi}/managed_struct_spec.rb +12 -1
  280. data/{specs → spec/ffi}/number_spec.rb +34 -16
  281. data/{specs → spec/ffi}/pointer_spec.rb +46 -2
  282. data/{specs → spec/ffi}/rbx/attach_function_spec.rb +2 -1
  283. data/{specs → spec/ffi}/rbx/memory_pointer_spec.rb +19 -19
  284. data/{specs → spec/ffi}/rbx/spec_helper.rb +0 -0
  285. data/{specs → spec/ffi}/rbx/struct_spec.rb +0 -0
  286. data/spec/ffi/spec_helper.rb +13 -0
  287. data/{specs → spec/ffi}/string_spec.rb +8 -0
  288. data/spec/ffi/struct_spec.rb +453 -0
  289. data/{specs → spec/ffi}/typedef_spec.rb +3 -3
  290. data/spec/ffi/union_spec.rb +60 -0
  291. data/{specs → spec/ffi}/variadic_spec.rb +0 -0
  292. data/spec/spec.opts +4 -0
  293. metadata +356 -334
  294. data/README +0 -0
  295. data/ext/Buffer.c +0 -98
  296. data/ext/MemoryPointer.c +0 -99
  297. data/ext/NativeLibrary.c +0 -90
  298. data/ext/Types.c +0 -76
  299. data/ext/ffi.c +0 -64
  300. data/ext/ffi.mk +0 -24
  301. data/ext/libffi.mk +0 -10
  302. data/gen/Rakefile +0 -12
  303. data/specs/library_spec.rb +0 -55
  304. data/specs/spec_helper.rb +0 -9
  305. data/specs/struct_spec.rb +0 -223
File without changes
@@ -0,0 +1,144 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
+ describe "Library" do
3
+ it "attach_function with no library specified" do
4
+ lambda {
5
+ Module.new do |m|
6
+ m.extend FFI::Library
7
+ attach_function :getpid, [ ], :uint
8
+ end
9
+ }.should_not raise_error
10
+ end
11
+ it "attach_function :getpid from this process" do
12
+ lambda {
13
+ Module.new do |m|
14
+ m.extend FFI::Library
15
+ attach_function :getpid, [ ], :uint
16
+ end.getpid.should == Process.pid
17
+ }.should_not raise_error
18
+ end
19
+ it "attach_function :getpid from [ 'c', 'libc.so.6'] " do
20
+ lambda {
21
+ Module.new do |m|
22
+ m.extend FFI::Library
23
+ ffi_lib 'c', 'libc.so.6'
24
+ attach_function :getpid, [ ], :uint
25
+ end.getpid.should == Process.pid
26
+ }.should_not raise_error
27
+ end
28
+ it "attach_function :getpid from [ 'libc.so.6', 'c' ] " do
29
+ lambda {
30
+ Module.new do |m|
31
+ m.extend FFI::Library
32
+ ffi_lib 'libc.so.6', 'c'
33
+ attach_function :getpid, [ ], :uint
34
+ end.getpid.should == Process.pid
35
+ }.should_not raise_error
36
+ end
37
+ it "attach_function :getpid from [ 'libfubar.so.0xdeadbeef', nil, 'c' ] " do
38
+ lambda {
39
+ Module.new do |m|
40
+ m.extend FFI::Library
41
+ ffi_lib 'libfubar.so.0xdeadbeef', nil, 'c'
42
+ attach_function :getpid, [ ], :uint
43
+ end.getpid.should == Process.pid
44
+ }.should_not raise_error
45
+ end
46
+ it "attach_function :getpid from [ 'libfubar.so.0xdeadbeef' ] " do
47
+ lambda {
48
+ Module.new do |m|
49
+ m.extend FFI::Library
50
+ ffi_lib 'libfubar.so.0xdeadbeef'
51
+ attach_function :getpid, [ ], :uint
52
+ end.getpid.should == Process.pid
53
+ }.should raise_error(LoadError)
54
+ end
55
+ def gvar_lib(name, type)
56
+ Module.new do |m|
57
+ m.extend FFI::Library
58
+ ffi_lib TestLibrary::PATH
59
+ attach_variable :gvar, "gvar_#{name}", type
60
+ attach_function :get, "gvar_#{name}_get", [], type
61
+ attach_function :set, "gvar_#{name}_set", [ type ], :void
62
+ end
63
+ end
64
+ def gvar_test(name, type, val)
65
+ lib = gvar_lib(name, type)
66
+ lib.set(val)
67
+ lib.gvar.should == val
68
+ lib.set(0)
69
+ lib.gvar = val
70
+ lib.get.should == val
71
+ end
72
+ [ 0, 127, -128, -1 ].each do |i|
73
+ it ":char variable" do
74
+ gvar_test("s8", :char, i)
75
+ end
76
+ end
77
+ [ 0, 0x7f, 0x80, 0xff ].each do |i|
78
+ it ":uchar variable" do
79
+ gvar_test("u8", :uchar, i)
80
+ end
81
+ end
82
+ [ 0, 0x7fff, -0x8000, -1 ].each do |i|
83
+ it ":short variable" do
84
+ gvar_test("s16", :short, i)
85
+ end
86
+ end
87
+ [ 0, 0x7fff, 0x8000, 0xffff ].each do |i|
88
+ it ":ushort variable" do
89
+ gvar_test("u16", :ushort, i)
90
+ end
91
+ end
92
+ [ 0, 0x7fffffff, -0x80000000, -1 ].each do |i|
93
+ it ":int variable" do
94
+ gvar_test("s32", :int, i)
95
+ end
96
+ end
97
+ [ 0, 0x7fffffff, 0x80000000, 0xffffffff ].each do |i|
98
+ it ":uint variable" do
99
+ gvar_test("u32", :uint, i)
100
+ end
101
+ end
102
+ [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ].each do |i|
103
+ it ":long_long variable" do
104
+ gvar_test("s64", :long_long, i)
105
+ end
106
+ end
107
+ [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ].each do |i|
108
+ it ":ulong_long variable" do
109
+ gvar_test("u64", :ulong_long, i)
110
+ end
111
+ end
112
+ if FFI::Platform::LONG_SIZE == 32
113
+ [ 0, 0x7fffffff, -0x80000000, -1 ].each do |i|
114
+ it ":long variable" do
115
+ gvar_test("long", :long, i)
116
+ end
117
+ end
118
+ [ 0, 0x7fffffff, 0x80000000, 0xffffffff ].each do |i|
119
+ it ":ulong variable" do
120
+ gvar_test("ulong", :ulong, i)
121
+ end
122
+ end
123
+ else
124
+ [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ].each do |i|
125
+ it ":long variable" do
126
+ gvar_test("long", :long, i)
127
+ end
128
+ end
129
+ [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ].each do |i|
130
+ it ":ulong variable" do
131
+ gvar_test("ulong", :ulong, i)
132
+ end
133
+ end
134
+ end
135
+ it "Pointer variable" do
136
+ lib = gvar_lib("pointer", :pointer)
137
+ val = FFI::MemoryPointer.new :long
138
+ lib.set(val)
139
+ lib.gvar.should == val
140
+ lib.set(nil)
141
+ lib.gvar = val
142
+ lib.get.should == val
143
+ end
144
+ end
@@ -8,12 +8,23 @@ describe "Managed Struct" do
8
8
  attach_function :ptr_from_address, [ FFI::Platform::ADDRESS_SIZE == 32 ? :uint : :ulong_long ], :pointer
9
9
  end
10
10
  it "should raise an error if release() is not defined" do
11
- class NoRelease < FFI::ManagedStruct ; end
11
+ class NoRelease < FFI::ManagedStruct ; layout :i, :int; end
12
12
  lambda { NoRelease.new(LibTest.ptr_from_address(0x12345678)) }.should raise_error(NoMethodError)
13
13
  end
14
14
 
15
+ it "should be the right class" do
16
+ class WhatClassAmI < FFI::ManagedStruct
17
+ layout :i, :int
18
+ def self.release
19
+ end
20
+ end
21
+
22
+ WhatClassAmI.new(LibTest.ptr_from_address(0x12345678)).class.should == WhatClassAmI
23
+ end
24
+
15
25
  it "should release memory properly" do
16
26
  class PleaseReleaseMe < FFI::ManagedStruct
27
+ layout :i, :int
17
28
  @@count = 0
18
29
  def self.release
19
30
  @@count += 1
@@ -3,55 +3,61 @@ describe "Function with primitive integer arguments" do
3
3
  module LibTest
4
4
  extend FFI::Library
5
5
  ffi_lib TestLibrary::PATH
6
- attach_function :ret_int8_t, [ :char ], :char
7
- attach_function :ret_u_int8_t, [ :uchar ], :uchar
8
- attach_function :ret_int16_t, [ :short ], :short
9
- attach_function :ret_u_int16_t, [ :ushort ], :ushort
10
- attach_function :ret_int32_t, [ :int ], :int
11
- attach_function :ret_u_int32_t, [ :uint ], :uint
12
- attach_function :ret_int64_t, [ :long_long ], :long_long
13
- attach_function :ret_u_int64_t, [ :ulong_long ], :ulong_long
6
+ attach_function :ret_s8, [ :char ], :char
7
+ attach_function :ret_u8, [ :uchar ], :uchar
8
+ attach_function :ret_s16, [ :short ], :short
9
+ attach_function :ret_u16, [ :ushort ], :ushort
10
+ attach_function :ret_s32, [ :int ], :int
11
+ attach_function :ret_u32, [ :uint ], :uint
12
+ attach_function :ret_s64, [ :long_long ], :long_long
13
+ attach_function :ret_u64, [ :ulong_long ], :ulong_long
14
14
  attach_function :ret_long, [ :long ], :long
15
15
  attach_function :ret_ulong, [ :ulong ], :ulong
16
+ attach_function :set_s8, [ :char ], :void
17
+ attach_function :get_s8, [ ], :char
18
+ attach_function :set_float, [ :float ], :void
19
+ attach_function :get_float, [ ], :float
20
+ attach_function :set_double, [ :double ], :void
21
+ attach_function :get_double, [ ], :double
16
22
  end
17
23
  [ 0, 127, -128, -1 ].each do |i|
18
24
  it ":char call(:char (#{i}))" do
19
- LibTest.ret_int8_t(i).should == i
25
+ LibTest.ret_s8(i).should == i
20
26
  end
21
27
  end
22
28
  [ 0, 0x7f, 0x80, 0xff ].each do |i|
23
29
  it ":uchar call(:uchar (#{i}))" do
24
- LibTest.ret_u_int8_t(i).should == i
30
+ LibTest.ret_u8(i).should == i
25
31
  end
26
32
  end
27
33
  [ 0, 0x7fff, -0x8000, -1 ].each do |i|
28
34
  it ":short call(:short (#{i}))" do
29
- LibTest.ret_int16_t(i).should == i
35
+ LibTest.ret_s16(i).should == i
30
36
  end
31
37
  end
32
38
  [ 0, 0x7fff, 0x8000, 0xffff ].each do |i|
33
39
  it ":ushort call(:ushort (#{i}))" do
34
- LibTest.ret_u_int16_t(i).should == i
40
+ LibTest.ret_u16(i).should == i
35
41
  end
36
42
  end
37
43
  [ 0, 0x7fffffff, -0x80000000, -1 ].each do |i|
38
44
  it ":int call(:int (#{i}))" do
39
- LibTest.ret_int32_t(i).should == i
45
+ LibTest.ret_s32(i).should == i
40
46
  end
41
47
  end
42
48
  [ 0, 0x7fffffff, 0x80000000, 0xffffffff ].each do |i|
43
49
  it ":uint call(:uint (#{i}))" do
44
- LibTest.ret_u_int32_t(i).should == i
50
+ LibTest.ret_u32(i).should == i
45
51
  end
46
52
  end
47
53
  [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ].each do |i|
48
54
  it ":long_long call(:long_long (#{i}))" do
49
- LibTest.ret_int64_t(i).should == i
55
+ LibTest.ret_s64(i).should == i
50
56
  end
51
57
  end
52
58
  [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ].each do |i|
53
59
  it ":ulong_long call(:ulong_long (#{i}))" do
54
- LibTest.ret_u_int64_t(i).should == i
60
+ LibTest.ret_u64(i).should == i
55
61
  end
56
62
  end
57
63
  if FFI::Platform::LONG_SIZE == 32
@@ -76,6 +82,18 @@ describe "Function with primitive integer arguments" do
76
82
  LibTest.ret_ulong(i).should == i
77
83
  end
78
84
  end
85
+ [ 0.0, 0.1, 1.1, 1.23 ].each do |f|
86
+ it ":float call(:double (#{f}))" do
87
+ LibTest.set_float(f)
88
+ (LibTest.get_float - f).abs.should < 0.001
89
+ end
90
+ end
91
+ [ 0.0, 0.1, 1.1, 1.23 ].each do |f|
92
+ it ":double call(:double (#{f}))" do
93
+ LibTest.set_double(f)
94
+ (LibTest.get_double - f).abs.should < 0.001
95
+ end
96
+ end
79
97
  end
80
98
  end
81
99
  describe "Integer parameter range checking" do
@@ -3,6 +3,8 @@ require 'delegate'
3
3
  module LibTest
4
4
  attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
5
5
  attach_function :ptr_from_address, [ FFI::Platform::ADDRESS_SIZE == 32 ? :uint : :ulong_long ], :pointer
6
+ attach_function :ptr_set_pointer, [ :pointer, :int, :pointer ], :void
7
+ attach_function :ptr_ret_pointer, [ :pointer, :int ], :pointer
6
8
  end
7
9
  describe "Pointer" do
8
10
  include FFI
@@ -15,7 +17,7 @@ describe "Pointer" do
15
17
  end
16
18
  end
17
19
  it "Any object implementing #to_ptr can be passed as a :pointer parameter" do
18
- memory = MemoryPointer.new :long_long
20
+ memory = FFI::MemoryPointer.new :long_long
19
21
  magic = 0x12345678
20
22
  memory.put_int32(0, magic)
21
23
  tp = ToPtrTest.new(memory)
@@ -31,7 +33,7 @@ describe "Pointer" do
31
33
  end
32
34
  end
33
35
  it "A DelegateClass(Pointer) can be passed as a :pointer parameter" do
34
- memory = MemoryPointer.new :long_long
36
+ memory = FFI::MemoryPointer.new :long_long
35
37
  magic = 0x12345678
36
38
  memory.put_int32(0, magic)
37
39
  ptr = PointerDelegate.new(memory)
@@ -43,6 +45,48 @@ describe "Pointer" do
43
45
  it "Bignum cannot be used as a Pointer argument" do
44
46
  lambda { LibTest.ptr_ret_int32(0xfee1deadbeefcafebabe, 0) }.should raise_error
45
47
  end
48
+
49
+ describe "pointer type methods" do
50
+
51
+ describe "#read_pointer" do
52
+ memory = FFI::MemoryPointer.new :pointer
53
+ LibTest.ptr_set_pointer(memory, 0, LibTest.ptr_from_address(0xdeadbeef))
54
+ memory.read_pointer.address.should == 0xdeadbeef
55
+ end
56
+
57
+ describe "#write_pointer" do
58
+ memory = FFI::MemoryPointer.new :pointer
59
+ memory.write_pointer(LibTest.ptr_from_address(0xdeadbeef))
60
+ LibTest.ptr_ret_pointer(memory, 0).address.should == 0xdeadbeef
61
+ end
62
+
63
+ describe "#read_array_of_pointer" do
64
+ values = [0x12345678, 0xfeedf00d, 0xdeadbeef]
65
+ memory = FFI::MemoryPointer.new :pointer, values.size
66
+ values.each_with_index do |address, j|
67
+ LibTest.ptr_set_pointer(memory, j * FFI.type_size(:pointer), LibTest.ptr_from_address(address))
68
+ end
69
+ array = memory.read_array_of_pointer(values.size)
70
+ values.each_with_index do |address, j|
71
+ array[j].address.should == address
72
+ end
73
+ end
74
+
75
+ describe "#write_array_of_pointer" do
76
+ values = [0x12345678, 0xfeedf00d, 0xdeadbeef]
77
+ memory = FFI::MemoryPointer.new :pointer, values.size
78
+ memory.write_array_of_pointer(values.map { |address| LibTest.ptr_from_address(address) })
79
+ array = []
80
+ values.each_with_index do |address, j|
81
+ array << LibTest.ptr_ret_pointer(memory, j * FFI.type_size(:pointer))
82
+ end
83
+ values.each_with_index do |address, j|
84
+ array[j].address.should == address
85
+ end
86
+ end
87
+
88
+ end
89
+
46
90
  end
47
91
 
48
92
  describe "AutoPointer" do
@@ -23,4 +23,5 @@ describe FFI::Library, "#attach_function" do
23
23
  t[:tv_sec].should be_kind_of(Numeric)
24
24
  t[:tv_usec].should be_kind_of(Numeric)
25
25
  end
26
- end
26
+ end
27
+
@@ -7,101 +7,101 @@ module CTest
7
7
  attach_function :strcat, [:pointer, :pointer], :pointer
8
8
  end
9
9
 
10
- describe MemoryPointer do
10
+ describe "MemoryPointer" do
11
11
  it "makes a pointer from a string" do
12
- m = MemoryPointer.from_string("FFI is Awesome")
12
+ m = FFI::MemoryPointer.from_string("FFI is Awesome")
13
13
  m.type_size.should == 15
14
14
  end
15
15
 
16
16
  it "reads back a string" do
17
- m = MemoryPointer.from_string("FFI is Awesome")
17
+ m = FFI::MemoryPointer.from_string("FFI is Awesome")
18
18
  m.read_string.should == "FFI is Awesome"
19
19
  end
20
20
 
21
21
  it "reads back a string from an Array of ints" do
22
- m = MemoryPointer.new(:int, 4)
22
+ m = FFI::MemoryPointer.new(:int, 4)
23
23
  m.write_array_of_int([541673030, 1092645737, 1869833591, 538994029])
24
24
  m.read_string(16).should == "FFI is Awesome "
25
25
  end
26
26
 
27
27
  it "makes a pointer for a certain number of bytes" do
28
- m = MemoryPointer.new(8)
28
+ m = FFI::MemoryPointer.new(8)
29
29
  m.write_array_of_int([1,2])
30
30
  m.read_array_of_int(2).should == [1,2]
31
31
  end
32
32
 
33
33
  it "allows access to an element of the pointer (as an array)" do
34
- m = MemoryPointer.new(:int, 2)
34
+ m = FFI::MemoryPointer.new(:int, 2)
35
35
  m.write_array_of_int([1,2])
36
36
  m[0].read_int.should == 1
37
37
  m[1].read_int.should == 2
38
38
  end
39
39
 
40
40
  it "allows writing as an int" do
41
- m = MemoryPointer.new(:int)
41
+ m = FFI::MemoryPointer.new(:int)
42
42
  m.write_int(1)
43
43
  m.read_int.should == 1
44
44
  end
45
45
 
46
46
  it "allows writing as a long" do
47
- m = MemoryPointer.new(:long)
47
+ m = FFI::MemoryPointer.new(:long)
48
48
  m.write_long(10)
49
49
  m.read_long.should == 10
50
50
  end
51
51
 
52
52
  it "raises an error if you try putting a long into a pointer of size 1" do
53
- m = MemoryPointer.new(1)
53
+ m = FFI::MemoryPointer.new(1)
54
54
  lambda { m.write_long(10) }.should raise_error
55
55
  end
56
56
 
57
57
  it "raises an error if you try putting an int into a pointer of size 1" do
58
- m = MemoryPointer.new(1)
58
+ m = FFI::MemoryPointer.new(1)
59
59
  lambda { m.write_int(10) }.should raise_error
60
60
  end
61
61
  # it "does not raise IndexError for opaque pointers" do
62
- # m = MemoryPointer.new(8)
63
- # p2 = MemoryPointer.new(1024)
62
+ # m = FFI::MemoryPointer.new(8)
63
+ # p2 = FFI::MemoryPointer.new(1024)
64
64
  # m.write_long(p2.address)
65
65
  # p = m.read_pointer
66
66
  # lambda { p.write_int(10) }.should_not raise_error
67
67
  # end
68
68
 
69
69
  it "makes a pointer for a certain type" do
70
- m = MemoryPointer.new(:int)
70
+ m = FFI::MemoryPointer.new(:int)
71
71
  m.write_int(10)
72
72
  m.read_int.should == 10
73
73
  end
74
74
 
75
75
  it "makes a memory pointer for a number of a certain type" do
76
- m = MemoryPointer.new(:int, 2)
76
+ m = FFI::MemoryPointer.new(:int, 2)
77
77
  m.write_array_of_int([1,2])
78
78
  m.read_array_of_int(2).should == [1,2]
79
79
  end
80
80
 
81
81
  it "makes a pointer for an object responding to #size" do
82
- m = MemoryPointer.new(Struct.new(:size).new(8))
82
+ m = FFI::MemoryPointer.new(Struct.new(:size).new(8))
83
83
  m.write_array_of_int([1,2])
84
84
  m.read_array_of_int(2).should == [1,2]
85
85
  end
86
86
 
87
87
  it "makes a pointer for a number of an object responding to #size" do
88
- m = MemoryPointer.new(Struct.new(:size).new(4), 2)
88
+ m = FFI::MemoryPointer.new(Struct.new(:size).new(4), 2)
89
89
  m.write_array_of_int([1,2])
90
90
  m.read_array_of_int(2).should == [1,2]
91
91
  end
92
92
  it "MemoryPointer#address returns correct value" do
93
- m = MemoryPointer.new(:long_long)
93
+ m = FFI::MemoryPointer.new(:long_long)
94
94
  magic = 0x12345678
95
95
  m.write_long(magic)
96
96
  m.read_pointer.address.should == magic
97
97
  end
98
98
  it "MemoryPointer#null? returns true for zero value" do
99
- m = MemoryPointer.new(:long_long)
99
+ m = FFI::MemoryPointer.new(:long_long)
100
100
  m.write_long(0)
101
101
  m.read_pointer.null?.should == true
102
102
  end
103
103
  it "MemoryPointer#null? returns false for non-zero value" do
104
- m = MemoryPointer.new(:long_long)
104
+ m = FFI::MemoryPointer.new(:long_long)
105
105
  m.write_long(0x12345678)
106
106
  m.read_pointer.null?.should == false
107
107
  end