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
@@ -0,0 +1,26 @@
1
+ #ifndef _STRUCT_H
2
+ #define _STRUCT_H
3
+
4
+ #include "AbstractMemory.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ void rb_FFI_Struct_Init();
11
+
12
+ struct StructLayout;
13
+ typedef struct Struct {
14
+ struct StructLayout* layout;
15
+ AbstractMemory* pointer;
16
+ VALUE rbLayout;
17
+ VALUE rbPointer;
18
+ } Struct;
19
+
20
+ extern VALUE rb_FFI_Struct_class;
21
+ #ifdef __cplusplus
22
+ }
23
+ #endif
24
+
25
+ #endif /* _STRUCT_H */
26
+
@@ -0,0 +1,76 @@
1
+ #include <ruby.h>
2
+ #include "Pointer.h"
3
+ #include "Types.h"
4
+
5
+ ffi_type*
6
+ rb_FFI_NativeTypeToFFI(NativeType type)
7
+ {
8
+ switch (type) {
9
+ case NATIVE_VOID:
10
+ return &ffi_type_void;
11
+ case NATIVE_INT8:
12
+ return &ffi_type_sint8;
13
+ case NATIVE_UINT8:
14
+ return &ffi_type_uint8;
15
+ case NATIVE_INT16:
16
+ return &ffi_type_sint16;
17
+ case NATIVE_UINT16:
18
+ return &ffi_type_uint16;
19
+ case NATIVE_INT32:
20
+ return &ffi_type_sint32;
21
+ case NATIVE_UINT32:
22
+ return &ffi_type_uint32;
23
+ case NATIVE_INT64:
24
+ return &ffi_type_sint64;
25
+ case NATIVE_UINT64:
26
+ return &ffi_type_uint64;
27
+ case NATIVE_FLOAT32:
28
+ return &ffi_type_float;
29
+ case NATIVE_FLOAT64:
30
+ return &ffi_type_double;
31
+ case NATIVE_STRING:
32
+ case NATIVE_RBXSTRING:
33
+ case NATIVE_POINTER:
34
+ case NATIVE_BUFFER_IN:
35
+ case NATIVE_BUFFER_OUT:
36
+ case NATIVE_BUFFER_INOUT:
37
+ return &ffi_type_pointer;
38
+ default:
39
+ return NULL;
40
+ }
41
+ }
42
+
43
+ VALUE
44
+ rb_FFI_NativeValueToRuby(NativeType type, const void* ptr)
45
+ {
46
+ switch (type) {
47
+ case NATIVE_VOID:
48
+ return Qnil;
49
+ case NATIVE_INT8:
50
+ return INT2NUM((signed char) *(ffi_sarg *) ptr);
51
+ case NATIVE_INT16:
52
+ return INT2NUM((signed short) *(ffi_sarg *) ptr);
53
+ case NATIVE_INT32:
54
+ return INT2NUM((signed int) *(ffi_sarg *) ptr);
55
+ case NATIVE_UINT8:
56
+ return UINT2NUM((unsigned char) *(ffi_arg *) ptr);
57
+ case NATIVE_UINT16:
58
+ return UINT2NUM((unsigned short) *(ffi_arg *) ptr);
59
+ case NATIVE_UINT32:
60
+ return UINT2NUM((unsigned int) *(ffi_arg *) ptr);
61
+ case NATIVE_INT64:
62
+ return LL2NUM(*(signed long long *) ptr);
63
+ case NATIVE_UINT64:
64
+ return ULL2NUM(*(unsigned long long *) ptr);
65
+ case NATIVE_FLOAT32:
66
+ return rb_float_new(*(float *) ptr);
67
+ case NATIVE_FLOAT64:
68
+ return rb_float_new(*(double *) ptr);
69
+ case NATIVE_STRING:
70
+ return rb_tainted_str_new2(*(char **) ptr);
71
+ case NATIVE_POINTER:
72
+ return rb_FFI_Pointer_new(*(void **) ptr);
73
+ default:
74
+ rb_raise(rb_eRuntimeError, "Unknown type: %d", type);
75
+ }
76
+ }
@@ -1,44 +1,39 @@
1
- /*
2
- * File: Types.h
3
- * Author: wayne
4
- *
5
- * Created on September 9, 2008, 9:47 PM
6
- */
7
-
8
1
  #ifndef _TYPES_H
9
2
  #define _TYPES_H
10
3
 
11
4
  #ifdef __cplusplus
12
5
  extern "C" {
13
6
  #endif
14
-
7
+ #ifdef VOID
8
+ # undef VOID
9
+ #endif
15
10
  typedef enum {
16
- VOID,
17
- INT8,
18
- UINT8,
19
- INT16,
20
- UINT16,
21
- INT32,
22
- UINT32,
23
- INT64,
24
- UINT64,
25
- FLOAT32,
26
- FLOAT64,
27
- POINTER,
28
- CALLBACK,
29
- BUFFER_IN,
30
- BUFFER_OUT,
31
- BUFFER_INOUT,
32
- CHAR_ARRAY,
11
+ NATIVE_VOID,
12
+ NATIVE_INT8,
13
+ NATIVE_UINT8,
14
+ NATIVE_INT16,
15
+ NATIVE_UINT16,
16
+ NATIVE_INT32,
17
+ NATIVE_UINT32,
18
+ NATIVE_INT64,
19
+ NATIVE_UINT64,
20
+ NATIVE_FLOAT32,
21
+ NATIVE_FLOAT64,
22
+ NATIVE_POINTER,
23
+ NATIVE_CALLBACK,
24
+ NATIVE_BUFFER_IN,
25
+ NATIVE_BUFFER_OUT,
26
+ NATIVE_BUFFER_INOUT,
27
+ NATIVE_CHAR_ARRAY,
33
28
 
34
29
  /**
35
30
  * An immutable string. Nul terminated, but only copies in to the native function
36
31
  */
37
- STRING,
32
+ NATIVE_STRING,
38
33
  /** A Rubinus :string arg - copies data both ways, and nul terminates */
39
- RBXSTRING,
34
+ NATIVE_RBXSTRING,
40
35
  /** The function takes a variable number of arguments */
41
- VARARGS,
36
+ NATIVE_VARARGS,
42
37
  } NativeType;
43
38
 
44
39
  #include <ffi.h>
@@ -6,8 +6,8 @@
6
6
  #ifndef RARRAY_LEN
7
7
  # define RARRAY_LEN(ary) RARRAY(ary)->len
8
8
  #endif
9
- #ifndef RSTRING_LEN
10
- # define RSTRING_LEN(s) RSTRING(s)->len
9
+ #ifndef RARRAY_PTR
10
+ # define RARRAY_PTR(ary) RARRAY(ary)->ptr
11
11
  #endif
12
12
  #ifndef RSTRING_LEN
13
13
  # define RSTRING_LEN(s) RSTRING(s)->len
@@ -2,7 +2,7 @@
2
2
  require 'mkmf'
3
3
  require 'rbconfig'
4
4
  dir_config("ffi_c")
5
- IS_MAC = Config::CONFIG['host_os'] =~ /^darwin/
5
+ #IS_MAC = Config::CONFIG['host_os'] =~ /^darwin/
6
6
  #if IS_MAC
7
7
  # $CPPFLAGS << " -DMACOSX"
8
8
  # find_header("ffi.h", "/usr/include/ffi")
@@ -16,10 +16,15 @@ $defs << "-DHAVE_EXTCONF_H" if $defs.empty? # needed so create_header works
16
16
  create_makefile("ffi_c")
17
17
  create_header("extconf.h")
18
18
  File.open("Makefile", "a") do |mf|
19
- mf.puts "include $(srcdir)/ffi.mk"
20
- if Config::CONFIG['host_os'] =~ /darwin/
21
- mf.puts "include $(srcdir)/libffi.darwin.mk"
22
- else
23
- mf.puts "include $(srcdir)/libffi.mk"
19
+ mf.puts "CPPFLAGS += -Werror -Wunused -Wformat"
20
+ unless libffi_ok
21
+ mf.puts "include $(srcdir)/ffi.mk"
22
+ mf.puts "LIBFFI_HOST=--host=#{Config::CONFIG['host_alias']}" if Config::CONFIG.has_key?("host_alias")
23
+ mf.puts "FFI_MMAP_EXEC=-DFFI_MMAP_EXEC_WRIT=#{Config::CONFIG['host_os'] =~ /win/ ? 0 : 1}"
24
+ if Config::CONFIG['host_os'] =~ /darwin/
25
+ mf.puts "include $(srcdir)/libffi.darwin.mk"
26
+ else
27
+ mf.puts "include $(srcdir)/libffi.mk"
28
+ end
24
29
  end
25
- end unless libffi_ok
30
+ end
@@ -0,0 +1,99 @@
1
+ #include <sys/types.h>
2
+ #include <stdio.h>
3
+ #include <ruby.h>
4
+
5
+ #include <ffi.h>
6
+
7
+ #include "rbffi.h"
8
+ #include "AbstractMemory.h"
9
+ #include "Pointer.h"
10
+ #include "MemoryPointer.h"
11
+ #include "AutoPointer.h"
12
+ #include "Struct.h"
13
+ #include "NativeLibrary.h"
14
+ #include "Platform.h"
15
+ #include "Types.h"
16
+
17
+
18
+ void Init_ffi_c();
19
+
20
+ static VALUE moduleFFI = Qnil;
21
+ static VALUE moduleNativeType = Qnil;
22
+ static VALUE typeMap = Qnil, sizeMap = Qnil;
23
+ static ID type_size_id = 0, size_id;
24
+
25
+ int
26
+ rb_FFI_type_size(VALUE type)
27
+ {
28
+ int t = TYPE(type);
29
+ if (t == T_FIXNUM || t == T_BIGNUM) {
30
+ return NUM2INT(type);
31
+ } else if (t == T_SYMBOL) {
32
+ /*
33
+ * Try looking up directly in the type and size maps
34
+ */
35
+ VALUE nType;
36
+ if ((nType = rb_hash_aref(typeMap, type)) != Qnil) {
37
+ VALUE nSize = rb_hash_aref(sizeMap, nType);
38
+ if (TYPE(nSize) == T_FIXNUM) {
39
+ return FIX2INT(nSize);
40
+ }
41
+ }
42
+ // Not found - call up to the ruby version to resolve
43
+ return rb_funcall(moduleFFI, rb_intern("type_size"), 1, &type);
44
+ } else {
45
+ return rb_funcall(type, size_id, 0, NULL);
46
+ }
47
+ }
48
+
49
+ void
50
+ Init_ffi_c() {
51
+ moduleFFI = rb_define_module("FFI");
52
+ rb_global_variable(&moduleFFI);
53
+ moduleNativeType = rb_define_module_under(moduleFFI, "NativeType");
54
+ rb_define_const(moduleFFI, "TypeDefs", typeMap = rb_hash_new());
55
+ rb_define_const(moduleFFI, "SizeTypes", sizeMap = rb_hash_new());
56
+ rb_global_variable(&typeMap);
57
+ rb_global_variable(&sizeMap);
58
+ type_size_id = rb_intern("type_size");
59
+ size_id = rb_intern("size");
60
+
61
+ rb_define_const(moduleNativeType, "VOID", INT2FIX(NATIVE_VOID));
62
+ rb_define_const(moduleNativeType, "INT8", INT2FIX(NATIVE_INT8));
63
+ rb_define_const(moduleNativeType, "UINT8", INT2FIX(NATIVE_UINT8));
64
+ rb_define_const(moduleNativeType, "INT16", INT2FIX(NATIVE_INT16));
65
+ rb_define_const(moduleNativeType, "UINT16", INT2FIX(NATIVE_UINT16));
66
+ rb_define_const(moduleNativeType, "INT32", INT2FIX(NATIVE_INT32));
67
+ rb_define_const(moduleNativeType, "UINT32", INT2FIX(NATIVE_UINT32));
68
+ rb_define_const(moduleNativeType, "INT64", INT2FIX(NATIVE_INT64));
69
+ rb_define_const(moduleNativeType, "UINT64", INT2FIX(NATIVE_UINT64));
70
+ rb_define_const(moduleNativeType, "FLOAT32", INT2FIX(NATIVE_FLOAT32));
71
+ rb_define_const(moduleNativeType, "FLOAT64", INT2FIX(NATIVE_FLOAT64));
72
+ rb_define_const(moduleNativeType, "POINTER", INT2FIX(NATIVE_POINTER));
73
+ rb_define_const(moduleNativeType, "STRING", INT2FIX(NATIVE_STRING));
74
+ rb_define_const(moduleNativeType, "RBXSTRING", INT2FIX(NATIVE_RBXSTRING));
75
+ rb_define_const(moduleNativeType, "CHAR_ARRAY", INT2FIX(NATIVE_CHAR_ARRAY));
76
+ rb_define_const(moduleNativeType, "BUFFER_IN", INT2FIX(NATIVE_BUFFER_IN));
77
+ rb_define_const(moduleNativeType, "BUFFER_OUT", INT2FIX(NATIVE_BUFFER_OUT));
78
+ rb_define_const(moduleNativeType, "BUFFER_INOUT", INT2FIX(NATIVE_BUFFER_INOUT));
79
+ rb_define_const(moduleNativeType, "VARARGS", INT2FIX(NATIVE_VARARGS));
80
+ if (sizeof(long) == 4) {
81
+ rb_define_const(moduleNativeType, "LONG", INT2FIX(NATIVE_INT32));
82
+ rb_define_const(moduleNativeType, "ULONG", INT2FIX(NATIVE_UINT32));
83
+ } else {
84
+ rb_define_const(moduleNativeType, "LONG", INT2FIX(NATIVE_INT64));
85
+ rb_define_const(moduleNativeType, "ULONG", INT2FIX(NATIVE_UINT64));
86
+ }
87
+ rb_FFI_Platform_Init();
88
+ rb_FFI_AbstractMemory_Init();
89
+ rb_FFI_Pointer_Init();
90
+ rb_FFI_AutoPointer_Init();
91
+ rb_FFI_NullPointer_Init();
92
+ rb_FFI_MemoryPointer_Init();
93
+ rb_FFI_Buffer_Init();
94
+ rb_FFI_Callback_Init();
95
+ rb_FFI_Struct_Init(0);
96
+ rb_FFI_NativeLibrary_Init();
97
+ rb_FFI_Invoker_Init();
98
+ }
99
+
@@ -0,0 +1,23 @@
1
+ # -*- makefile -*-
2
+
3
+ # CFLAGS += -Werror -Wformat
4
+ INCFLAGS += -I$(BUILD_DIR) -I$(LIBFFI_BUILD_DIR)/include
5
+ CPPFLAGS += -I$(BUILD_DIR) -I$(LIBFFI_BUILD_DIR)/include
6
+ # CPPFLAGS += -mwin32
7
+ LOCAL_LIBS += $(LIBFFI)
8
+ # LOCAL_LIBS += -lpthread
9
+
10
+ FFI_CFLAGS = $(FFI_MMAP_EXEC)
11
+ BUILD_DIR := $(shell pwd)
12
+ ifeq ($(srcdir),.)
13
+ LIBFFI_SRC_DIR := $(shell pwd)/$(srcdir)/libffi
14
+ else
15
+ LIBFFI_SRC_DIR := $(srcdir)/libffi
16
+ endif
17
+ LIBFFI_BUILD_DIR = $(BUILD_DIR)/libffi
18
+ LIBFFI = $(LIBFFI_BUILD_DIR)/.libs/libffi_convenience.a
19
+ FFI_CONFIGURE = $(LIBFFI_SRC_DIR)/configure --disable-static \
20
+ --with-pic=yes --disable-dependency-tracking
21
+
22
+ $(OBJS): $(LIBFFI)
23
+
@@ -0,0 +1,11 @@
1
+ # -*- makefile -*-
2
+
3
+ $(LIBFFI):
4
+ @mkdir -p $(LIBFFI_BUILD_DIR)
5
+ @if [ ! -f $(LIBFFI_BUILD_DIR)/Makefile ]; then \
6
+ echo "Configuring libffi"; \
7
+ cd $(LIBFFI_BUILD_DIR) && \
8
+ /usr/bin/env CC="$(CC)" LD="$(LD)" CFLAGS="$(FFI_CFLAGS)" \
9
+ /bin/sh $(FFI_CONFIGURE) $(LIBFFI_HOST) > /dev/null; \
10
+ fi
11
+ cd $(LIBFFI_BUILD_DIR) && $(MAKE)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes