alinta-ffi 1.9.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. checksums.yaml +7 -0
  2. data/COPYING +49 -0
  3. data/LICENSE +24 -0
  4. data/README.md +112 -0
  5. data/Rakefile +243 -0
  6. data/ext/ffi_c/AbstractMemory.c +1109 -0
  7. data/ext/ffi_c/AbstractMemory.h +175 -0
  8. data/ext/ffi_c/ArrayType.c +162 -0
  9. data/ext/ffi_c/ArrayType.h +59 -0
  10. data/ext/ffi_c/Buffer.c +365 -0
  11. data/ext/ffi_c/Call.c +517 -0
  12. data/ext/ffi_c/Call.h +110 -0
  13. data/ext/ffi_c/ClosurePool.c +283 -0
  14. data/ext/ffi_c/ClosurePool.h +57 -0
  15. data/ext/ffi_c/DataConverter.c +91 -0
  16. data/ext/ffi_c/DynamicLibrary.c +339 -0
  17. data/ext/ffi_c/DynamicLibrary.h +98 -0
  18. data/ext/ffi_c/Function.c +998 -0
  19. data/ext/ffi_c/Function.h +87 -0
  20. data/ext/ffi_c/FunctionInfo.c +271 -0
  21. data/ext/ffi_c/LastError.c +184 -0
  22. data/ext/ffi_c/LastError.h +47 -0
  23. data/ext/ffi_c/LongDouble.c +63 -0
  24. data/ext/ffi_c/LongDouble.h +51 -0
  25. data/ext/ffi_c/MappedType.c +168 -0
  26. data/ext/ffi_c/MappedType.h +59 -0
  27. data/ext/ffi_c/MemoryPointer.c +197 -0
  28. data/ext/ffi_c/MemoryPointer.h +53 -0
  29. data/ext/ffi_c/MethodHandle.c +358 -0
  30. data/ext/ffi_c/MethodHandle.h +55 -0
  31. data/ext/ffi_c/Platform.c +129 -0
  32. data/ext/ffi_c/Platform.h +45 -0
  33. data/ext/ffi_c/Pointer.c +508 -0
  34. data/ext/ffi_c/Pointer.h +63 -0
  35. data/ext/ffi_c/Struct.c +829 -0
  36. data/ext/ffi_c/Struct.h +106 -0
  37. data/ext/ffi_c/StructByReference.c +190 -0
  38. data/ext/ffi_c/StructByReference.h +50 -0
  39. data/ext/ffi_c/StructByValue.c +150 -0
  40. data/ext/ffi_c/StructByValue.h +55 -0
  41. data/ext/ffi_c/StructLayout.c +698 -0
  42. data/ext/ffi_c/Thread.c +352 -0
  43. data/ext/ffi_c/Thread.h +95 -0
  44. data/ext/ffi_c/Type.c +397 -0
  45. data/ext/ffi_c/Type.h +62 -0
  46. data/ext/ffi_c/Types.c +139 -0
  47. data/ext/ffi_c/Types.h +89 -0
  48. data/ext/ffi_c/Variadic.c +304 -0
  49. data/ext/ffi_c/compat.h +78 -0
  50. data/ext/ffi_c/extconf.rb +71 -0
  51. data/ext/ffi_c/ffi.c +98 -0
  52. data/ext/ffi_c/libffi.bsd.mk +40 -0
  53. data/ext/ffi_c/libffi.darwin.mk +105 -0
  54. data/ext/ffi_c/libffi.gnu.mk +32 -0
  55. data/ext/ffi_c/libffi.mk +18 -0
  56. data/ext/ffi_c/libffi.vc.mk +26 -0
  57. data/ext/ffi_c/libffi.vc64.mk +26 -0
  58. data/ext/ffi_c/rbffi.h +57 -0
  59. data/ext/ffi_c/rbffi_endian.h +59 -0
  60. data/ext/ffi_c/win32/stdbool.h +8 -0
  61. data/ext/ffi_c/win32/stdint.h +201 -0
  62. data/ffi.gemspec +23 -0
  63. data/gen/Rakefile +30 -0
  64. data/lib/ffi.rb +20 -0
  65. data/lib/ffi/autopointer.rb +203 -0
  66. data/lib/ffi/buffer.rb +4 -0
  67. data/lib/ffi/callback.rb +4 -0
  68. data/lib/ffi/enum.rb +296 -0
  69. data/lib/ffi/errno.rb +43 -0
  70. data/lib/ffi/ffi.rb +44 -0
  71. data/lib/ffi/io.rb +62 -0
  72. data/lib/ffi/library.rb +590 -0
  73. data/lib/ffi/managedstruct.rb +84 -0
  74. data/lib/ffi/memorypointer.rb +1 -0
  75. data/lib/ffi/platform.rb +164 -0
  76. data/lib/ffi/platform/aarch64-linux/types.conf +104 -0
  77. data/lib/ffi/platform/arm-linux/types.conf +104 -0
  78. data/lib/ffi/platform/i386-cygwin/types.conf +3 -0
  79. data/lib/ffi/platform/i386-darwin/types.conf +100 -0
  80. data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
  81. data/lib/ffi/platform/i386-gnu/types.conf +107 -0
  82. data/lib/ffi/platform/i386-linux/types.conf +103 -0
  83. data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
  84. data/lib/ffi/platform/i386-openbsd/types.conf +128 -0
  85. data/lib/ffi/platform/i386-solaris/types.conf +122 -0
  86. data/lib/ffi/platform/i386-windows/types.conf +105 -0
  87. data/lib/ffi/platform/ia64-linux/types.conf +104 -0
  88. data/lib/ffi/platform/mips-linux/types.conf +102 -0
  89. data/lib/ffi/platform/mips64el-linux/types.conf +104 -0
  90. data/lib/ffi/platform/mipsel-linux/types.conf +102 -0
  91. data/lib/ffi/platform/powerpc-aix/types.conf +180 -0
  92. data/lib/ffi/platform/powerpc-darwin/types.conf +100 -0
  93. data/lib/ffi/platform/powerpc-linux/types.conf +100 -0
  94. data/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
  95. data/lib/ffi/platform/s390-linux/types.conf +102 -0
  96. data/lib/ffi/platform/s390x-linux/types.conf +102 -0
  97. data/lib/ffi/platform/sparc-linux/types.conf +102 -0
  98. data/lib/ffi/platform/sparc-solaris/types.conf +128 -0
  99. data/lib/ffi/platform/sparc64-linux/types.conf +102 -0
  100. data/lib/ffi/platform/sparcv9-solaris/types.conf +128 -0
  101. data/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
  102. data/lib/ffi/platform/x86_64-darwin/types.conf +126 -0
  103. data/lib/ffi/platform/x86_64-freebsd/types.conf +128 -0
  104. data/lib/ffi/platform/x86_64-linux/types.conf +102 -0
  105. data/lib/ffi/platform/x86_64-netbsd/types.conf +128 -0
  106. data/lib/ffi/platform/x86_64-openbsd/types.conf +134 -0
  107. data/lib/ffi/platform/x86_64-solaris/types.conf +122 -0
  108. data/lib/ffi/platform/x86_64-windows/types.conf +120 -0
  109. data/lib/ffi/pointer.rb +161 -0
  110. data/lib/ffi/struct.rb +371 -0
  111. data/lib/ffi/struct_layout_builder.rb +227 -0
  112. data/lib/ffi/tools/const_generator.rb +229 -0
  113. data/lib/ffi/tools/generator.rb +60 -0
  114. data/lib/ffi/tools/generator_task.rb +36 -0
  115. data/lib/ffi/tools/struct_generator.rb +194 -0
  116. data/lib/ffi/tools/types_generator.rb +134 -0
  117. data/lib/ffi/types.rb +194 -0
  118. data/lib/ffi/union.rb +43 -0
  119. data/lib/ffi/variadic.rb +78 -0
  120. data/lib/ffi/version.rb +4 -0
  121. data/libtest/Benchmark.c +52 -0
  122. data/libtest/BoolTest.c +34 -0
  123. data/libtest/BufferTest.c +31 -0
  124. data/libtest/ClosureTest.c +205 -0
  125. data/libtest/EnumTest.c +51 -0
  126. data/libtest/FunctionTest.c +70 -0
  127. data/libtest/GNUmakefile +149 -0
  128. data/libtest/GlobalVariable.c +62 -0
  129. data/libtest/LastErrorTest.c +21 -0
  130. data/libtest/NumberTest.c +132 -0
  131. data/libtest/PointerTest.c +63 -0
  132. data/libtest/ReferenceTest.c +23 -0
  133. data/libtest/StringTest.c +34 -0
  134. data/libtest/StructTest.c +243 -0
  135. data/libtest/UnionTest.c +43 -0
  136. data/libtest/VariadicTest.c +99 -0
  137. data/spec/ffi/LICENSE.SPECS +22 -0
  138. data/spec/ffi/async_callback_spec.rb +35 -0
  139. data/spec/ffi/bitmask_spec.rb +575 -0
  140. data/spec/ffi/bool_spec.rb +32 -0
  141. data/spec/ffi/buffer_spec.rb +279 -0
  142. data/spec/ffi/callback_spec.rb +773 -0
  143. data/spec/ffi/custom_param_type.rb +37 -0
  144. data/spec/ffi/custom_type_spec.rb +74 -0
  145. data/spec/ffi/dup_spec.rb +52 -0
  146. data/spec/ffi/enum_spec.rb +423 -0
  147. data/spec/ffi/errno_spec.rb +20 -0
  148. data/spec/ffi/ffi_spec.rb +28 -0
  149. data/spec/ffi/fixtures/Benchmark.c +52 -0
  150. data/spec/ffi/fixtures/BitmaskTest.c +51 -0
  151. data/spec/ffi/fixtures/BoolTest.c +34 -0
  152. data/spec/ffi/fixtures/BufferTest.c +31 -0
  153. data/spec/ffi/fixtures/ClosureTest.c +205 -0
  154. data/spec/ffi/fixtures/EnumTest.c +51 -0
  155. data/spec/ffi/fixtures/FunctionTest.c +142 -0
  156. data/spec/ffi/fixtures/GNUmakefile +149 -0
  157. data/spec/ffi/fixtures/GlobalVariable.c +62 -0
  158. data/spec/ffi/fixtures/LastErrorTest.c +21 -0
  159. data/spec/ffi/fixtures/NumberTest.c +132 -0
  160. data/spec/ffi/fixtures/PipeHelper.h +21 -0
  161. data/spec/ffi/fixtures/PipeHelperPosix.c +41 -0
  162. data/spec/ffi/fixtures/PipeHelperWindows.c +72 -0
  163. data/spec/ffi/fixtures/PointerTest.c +63 -0
  164. data/spec/ffi/fixtures/ReferenceTest.c +23 -0
  165. data/spec/ffi/fixtures/StringTest.c +34 -0
  166. data/spec/ffi/fixtures/StructTest.c +243 -0
  167. data/spec/ffi/fixtures/UnionTest.c +43 -0
  168. data/spec/ffi/fixtures/VariadicTest.c +99 -0
  169. data/spec/ffi/fixtures/classes.rb +438 -0
  170. data/spec/ffi/function_spec.rb +97 -0
  171. data/spec/ffi/io_spec.rb +16 -0
  172. data/spec/ffi/library_spec.rb +286 -0
  173. data/spec/ffi/long_double.rb +30 -0
  174. data/spec/ffi/managed_struct_spec.rb +68 -0
  175. data/spec/ffi/memorypointer_spec.rb +78 -0
  176. data/spec/ffi/number_spec.rb +247 -0
  177. data/spec/ffi/platform_spec.rb +114 -0
  178. data/spec/ffi/pointer_spec.rb +285 -0
  179. data/spec/ffi/rbx/attach_function_spec.rb +34 -0
  180. data/spec/ffi/rbx/memory_pointer_spec.rb +198 -0
  181. data/spec/ffi/rbx/spec_helper.rb +6 -0
  182. data/spec/ffi/rbx/struct_spec.rb +18 -0
  183. data/spec/ffi/spec_helper.rb +93 -0
  184. data/spec/ffi/string_spec.rb +118 -0
  185. data/spec/ffi/strptr_spec.rb +50 -0
  186. data/spec/ffi/struct_by_ref_spec.rb +43 -0
  187. data/spec/ffi/struct_callback_spec.rb +69 -0
  188. data/spec/ffi/struct_initialize_spec.rb +35 -0
  189. data/spec/ffi/struct_packed_spec.rb +50 -0
  190. data/spec/ffi/struct_spec.rb +882 -0
  191. data/spec/ffi/typedef_spec.rb +91 -0
  192. data/spec/ffi/union_spec.rb +67 -0
  193. data/spec/ffi/variadic_spec.rb +132 -0
  194. data/spec/spec.opts +4 -0
  195. metadata +309 -0
@@ -0,0 +1,91 @@
1
+ #
2
+ # This file is part of ruby-ffi.
3
+ # For licensing, see LICENSE.SPECS
4
+ #
5
+
6
+ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
+ describe "Custom type definitions" do
8
+ it "attach_function with custom typedef" do
9
+ module CustomTypedef
10
+ extend FFI::Library
11
+ ffi_lib TestLibrary::PATH
12
+ typedef :uint, :fubar_t
13
+ attach_function :ret_u32, [ :fubar_t ], :fubar_t
14
+ end
15
+ expect(CustomTypedef.ret_u32(0x12345678)).to eq(0x12345678)
16
+ end
17
+
18
+ it "variadic invoker with custom typedef" do
19
+ module VariadicCustomTypedef
20
+ extend FFI::Library
21
+ ffi_lib TestLibrary::PATH
22
+ typedef :uint, :fubar_t
23
+ attach_function :pack_varargs, [ :buffer_out, :string, :varargs ], :void
24
+ end
25
+ buf = FFI::Buffer.new :uint, 10
26
+ VariadicCustomTypedef.pack_varargs(buf, "i", :fubar_t, 0x12345678)
27
+ expect(buf.get_int64(0)).to eq(0x12345678)
28
+ end
29
+
30
+ it "Callback with custom typedef parameter" do
31
+ module CallbackCustomTypedef
32
+ extend FFI::Library
33
+ ffi_lib TestLibrary::PATH
34
+ typedef :uint, :fubar3_t
35
+ callback :cbIrV, [ :fubar3_t ], :void
36
+ attach_function :testCallbackU32rV, :testClosureIrV, [ :cbIrV, :fubar3_t ], :void
37
+ end
38
+ i = 0
39
+ CallbackCustomTypedef.testCallbackU32rV(0xdeadbeef) { |v| i = v }
40
+ expect(i).to eq(0xdeadbeef)
41
+ end
42
+ module StructCustomTypedef
43
+ extend FFI::Library
44
+ ffi_lib TestLibrary::PATH
45
+ typedef :uint, :fubar3_t
46
+ class S < FFI::Struct
47
+ layout :a, :fubar3_t
48
+ end
49
+ end
50
+
51
+ it "Struct with custom typedef field" do
52
+ s = StructCustomTypedef::S.new
53
+ s[:a] = 0x12345678
54
+ expect(s.pointer.get_uint(0)).to eq(0x12345678)
55
+ end
56
+
57
+ it "attach_function after a typedef should not reject normal types" do
58
+ expect do
59
+ Module.new do
60
+ extend FFI::Library
61
+ # enum() will insert a custom typedef called :foo for the enum
62
+ enum :foo, [ :a, :b ]
63
+ typedef :int, :bar
64
+
65
+ ffi_lib TestLibrary::PATH
66
+ begin
67
+ attach_function :ptr_ret_int32_t, [ :string, :foo ], :bar
68
+ rescue FFI::NotFoundError
69
+ # NetBSD uses #define instead of typedef for these
70
+ attach_function :ptr_ret_int32_t, :ptr_ret___int32_t, [ :string, :foo ], :bar
71
+ end
72
+ end
73
+ end.not_to raise_error
74
+ end
75
+
76
+ it "detects the correct type for size_t" do
77
+ expect do
78
+ Module.new do
79
+ extend FFI::Library
80
+ ffi_lib "c"
81
+ if FFI::Platform.windows?
82
+ # _read() is a function of msvcrt.dll
83
+ attach_function :_read, [:int, :pointer, :uint], :int
84
+ else
85
+ # read(2) is a standard UNIX function
86
+ attach_function :read, [:int, :pointer, :size_t], :ssize_t
87
+ end
88
+ end
89
+ end.not_to raise_error
90
+ end
91
+ end
@@ -0,0 +1,67 @@
1
+ #
2
+ # This file is part of ruby-ffi.
3
+ # For licensing, see LICENSE.SPECS
4
+ #
5
+
6
+ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
+
8
+ module LibTest
9
+ Types = {
10
+ 's8' => [:char, :c, 1],
11
+ 's16' => [:short, :s, 0xff0],
12
+ 's32' => [:int, :i, 0xff00],
13
+ 's64' => [:long_long, :j, 0xffff00],
14
+ 'long' => [:long, :l, 0xffff],
15
+ 'f32' => [:float, :f, 1.0001],
16
+ 'f64' => [:double, :d, 1.000000001]
17
+ }
18
+ class TestUnion < FFI::Union
19
+ layout( :a, [:char, 10],
20
+ :i, :int,
21
+ :f, :float,
22
+ :d, :double,
23
+ :s, :short,
24
+ :l, :long,
25
+ :j, :long_long,
26
+ :c, :char )
27
+ end
28
+ Types.keys.each do |k|
29
+ attach_function "union_align_#{k}", [ :pointer ], Types[k][0]
30
+ attach_function "union_make_union_with_#{k}", [ Types[k][0] ], :pointer
31
+ end
32
+ attach_function :union_size, [], :uint
33
+ end
34
+
35
+ describe 'Union' do
36
+ before do
37
+ @u = LibTest::TestUnion.new
38
+ end
39
+
40
+ it 'should place all the fields at offset 0' do
41
+ expect(LibTest::TestUnion.members.all? { |m| LibTest::TestUnion.offset_of(m) == 0 }).to be true
42
+ end
43
+ LibTest::Types.each do |k, type|
44
+ it "should correctly align/write a #{type[0]} value" do
45
+ @u[type[1]] = type[2]
46
+ if k == 'f32' or k == 'f64'
47
+ expect((@u[type[1]] - LibTest.send("union_align_#{k}", @u.to_ptr)).abs).to be < 0.00001
48
+ else
49
+ expect(@u[type[1]]).to eq(LibTest.send("union_align_#{k}", @u.to_ptr))
50
+ end
51
+ end
52
+ end
53
+ LibTest::Types.each do |k, type|
54
+ it "should read a #{type[0]} value from memory" do
55
+ @u = LibTest::TestUnion.new(LibTest.send("union_make_union_with_#{k}", type[2]))
56
+ if k == 'f32' or k == 'f64'
57
+ expect((@u[type[1]] - type[2]).abs).to be < 0.00001
58
+ else
59
+ expect(@u[type[1]]).to eq(type[2])
60
+ end
61
+ end
62
+ end
63
+
64
+ it 'should return a size equals to the size of the biggest field' do
65
+ expect(LibTest::TestUnion.size).to eq(LibTest.union_size)
66
+ end
67
+ end
@@ -0,0 +1,132 @@
1
+ #
2
+ # This file is part of ruby-ffi.
3
+ # For licensing, see LICENSE.SPECS
4
+ #
5
+
6
+ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
+
8
+ describe "Function with variadic arguments" do
9
+ module LibTest
10
+ extend FFI::Library
11
+ ffi_lib TestLibrary::PATH
12
+ enum :enum_type1, [:c1, :c2]
13
+ enum :enum_type2, [:c3, 42, :c4]
14
+ attach_function :pack_varargs, [ :buffer_out, :string, :varargs ], :void
15
+ attach_function :pack_varargs2, [ :buffer_out, :enum_type1, :string, :varargs ], :enum_type1
16
+
17
+ attach_function :testBlockingOpen, [ ], :pointer
18
+ attach_function :testBlockingRWva, [ :pointer, :char, :varargs ], :char, :blocking => true
19
+ attach_function :testBlockingWRva, [ :pointer, :char, :varargs ], :char, :blocking => true
20
+ attach_function :testBlockingClose, [ :pointer ], :void
21
+ end
22
+
23
+ it "takes enum arguments" do
24
+ buf = FFI::Buffer.new :long_long, 2
25
+ LibTest.pack_varargs(buf, "ii", :int, :c3, :int, :c4)
26
+ expect(buf.get_int64(0)).to eq(42)
27
+ expect(buf.get_int64(8)).to eq(43)
28
+ end
29
+
30
+ it "returns symbols for enums" do
31
+ buf = FFI::Buffer.new :long_long, 2
32
+ expect(LibTest.pack_varargs2(buf, :c1, "ii", :int, :c3, :int, :c4)).to eq(:c2)
33
+ end
34
+
35
+ it 'can wrap a blocking function with varargs' do
36
+ pending("not supported in 1.8") if RUBY_VERSION =~ /^1\.8\..*/
37
+ handle = LibTest.testBlockingOpen
38
+ expect(handle).not_to be_null
39
+ begin
40
+ thWR = Thread.new { LibTest.testBlockingWRva(handle, 63, :int, 40, :int, 23, :int, 0) }
41
+ thRW = Thread.new { LibTest.testBlockingRWva(handle, 64, :int, 40, :int, 24, :int, 0) }
42
+ expect(thWR.value).to eq(64)
43
+ expect(thRW.value).to eq(63)
44
+ ensure
45
+ LibTest.testBlockingClose(handle)
46
+ end
47
+ end
48
+
49
+ [ 0, 127, -128, -1 ].each do |i|
50
+ it "call variadic with (:char (#{i})) argument" do
51
+ buf = FFI::Buffer.new :long_long
52
+ LibTest.pack_varargs(buf, "c", :char, i)
53
+ expect(buf.get_int64(0)).to eq(i)
54
+ end
55
+ end
56
+
57
+ [ 0, 0x7f, 0x80, 0xff ].each do |i|
58
+ it "call variadic with (:uchar (#{i})) argument" do
59
+ buf = FFI::Buffer.new :long_long
60
+ LibTest.pack_varargs(buf, "C", :uchar, i)
61
+ expect(buf.get_int64(0)).to eq(i)
62
+ end
63
+ end
64
+
65
+ [ 0, 1.234567, 9.87654321 ].each do |v|
66
+ it "call variadic with (:float (#{v})) argument" do
67
+ buf = FFI::Buffer.new :long_long
68
+ LibTest.pack_varargs(buf, "f", :float, v.to_f)
69
+ expect(buf.get_float64(0)).to eq(v)
70
+ end
71
+ end
72
+
73
+ [ 0, 1.234567, 9.87654321 ].each do |v|
74
+ it "call variadic with (:double (#{v})) argument" do
75
+ buf = FFI::Buffer.new :long_long
76
+ LibTest.pack_varargs(buf, "f", :double, v.to_f)
77
+ expect(buf.get_float64(0)).to eq(v)
78
+ end
79
+ end
80
+
81
+ module Varargs
82
+ PACK_VALUES = {
83
+ 'c' => [ 0x12 ],
84
+ 'C' => [ 0x34 ],
85
+ 's' => [ 0x5678 ],
86
+ 'S' => [ 0x9abc ],
87
+ 'i' => [ 0x7654321f ],
88
+ 'I' => [ 0xfee1babe ],
89
+ 'l' => [ 0x1f2e3d4c ],
90
+ 'L' => [ 0xf7e8d9ca ],
91
+ 'j' => [ 0x1eafdeadbeefa1b2 ],
92
+ 'f' => [ 1.23456789 ],
93
+ 'd' => [ 9.87654321 ]
94
+ }
95
+
96
+ TYPE_MAP = {
97
+ 'c' => :char, 'C' => :uchar, 's' => :short, 'S' => :ushort,
98
+ 'i' => :int, 'I' => :uint, 'j' => :long_long, 'J' => :ulong_long,
99
+ 'l' => :long, 'L' => :ulong, 'f' => :float, 'd' => :double
100
+ }
101
+ end
102
+
103
+ def verify(p, off, v)
104
+ if v.kind_of?(Float)
105
+ expect(p.get_float64(off)).to eq(v)
106
+ else
107
+ expect(p.get_int64(off)).to eq(v)
108
+ end
109
+ end
110
+
111
+ Varargs::PACK_VALUES.keys.each do |t1|
112
+ Varargs::PACK_VALUES.keys.each do |t2|
113
+ Varargs::PACK_VALUES.keys.each do |t3|
114
+ Varargs::PACK_VALUES[t1].each do |v1|
115
+ Varargs::PACK_VALUES[t2].each do |v2|
116
+ Varargs::PACK_VALUES[t3].each do |v3|
117
+ fmt = "#{t1}#{t2}#{t3}"
118
+ params = [ Varargs::TYPE_MAP[t1], v1, Varargs::TYPE_MAP[t2], v2, Varargs::TYPE_MAP[t3], v3 ]
119
+ it "call(#{fmt}, #{params.join(',')})" do
120
+ buf = FFI::Buffer.new :long_long, 3
121
+ LibTest.pack_varargs(buf, fmt, *params)
122
+ verify(buf, 0, v1)
123
+ verify(buf, 8, v2)
124
+ verify(buf, 16, v3)
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,4 @@
1
+ --color
2
+ -w
3
+ --format
4
+ documentation
metadata ADDED
@@ -0,0 +1,309 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alinta-ffi
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.9.19
5
+ platform: ruby
6
+ authors:
7
+ - Wayne Meissner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-01-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '10.1'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '10.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler-dock
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.6.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubygems-tasks
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.2.4
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.2.4
83
+ description: Ruby FFI library
84
+ email: wmeissner@gmail.com
85
+ executables: []
86
+ extensions:
87
+ - ext/ffi_c/extconf.rb
88
+ extra_rdoc_files: []
89
+ files:
90
+ - COPYING
91
+ - LICENSE
92
+ - README.md
93
+ - Rakefile
94
+ - ext/ffi_c/AbstractMemory.c
95
+ - ext/ffi_c/AbstractMemory.h
96
+ - ext/ffi_c/ArrayType.c
97
+ - ext/ffi_c/ArrayType.h
98
+ - ext/ffi_c/Buffer.c
99
+ - ext/ffi_c/Call.c
100
+ - ext/ffi_c/Call.h
101
+ - ext/ffi_c/ClosurePool.c
102
+ - ext/ffi_c/ClosurePool.h
103
+ - ext/ffi_c/DataConverter.c
104
+ - ext/ffi_c/DynamicLibrary.c
105
+ - ext/ffi_c/DynamicLibrary.h
106
+ - ext/ffi_c/Function.c
107
+ - ext/ffi_c/Function.h
108
+ - ext/ffi_c/FunctionInfo.c
109
+ - ext/ffi_c/LastError.c
110
+ - ext/ffi_c/LastError.h
111
+ - ext/ffi_c/LongDouble.c
112
+ - ext/ffi_c/LongDouble.h
113
+ - ext/ffi_c/MappedType.c
114
+ - ext/ffi_c/MappedType.h
115
+ - ext/ffi_c/MemoryPointer.c
116
+ - ext/ffi_c/MemoryPointer.h
117
+ - ext/ffi_c/MethodHandle.c
118
+ - ext/ffi_c/MethodHandle.h
119
+ - ext/ffi_c/Platform.c
120
+ - ext/ffi_c/Platform.h
121
+ - ext/ffi_c/Pointer.c
122
+ - ext/ffi_c/Pointer.h
123
+ - ext/ffi_c/Struct.c
124
+ - ext/ffi_c/Struct.h
125
+ - ext/ffi_c/StructByReference.c
126
+ - ext/ffi_c/StructByReference.h
127
+ - ext/ffi_c/StructByValue.c
128
+ - ext/ffi_c/StructByValue.h
129
+ - ext/ffi_c/StructLayout.c
130
+ - ext/ffi_c/Thread.c
131
+ - ext/ffi_c/Thread.h
132
+ - ext/ffi_c/Type.c
133
+ - ext/ffi_c/Type.h
134
+ - ext/ffi_c/Types.c
135
+ - ext/ffi_c/Types.h
136
+ - ext/ffi_c/Variadic.c
137
+ - ext/ffi_c/compat.h
138
+ - ext/ffi_c/extconf.rb
139
+ - ext/ffi_c/ffi.c
140
+ - ext/ffi_c/libffi.bsd.mk
141
+ - ext/ffi_c/libffi.darwin.mk
142
+ - ext/ffi_c/libffi.gnu.mk
143
+ - ext/ffi_c/libffi.mk
144
+ - ext/ffi_c/libffi.vc.mk
145
+ - ext/ffi_c/libffi.vc64.mk
146
+ - ext/ffi_c/rbffi.h
147
+ - ext/ffi_c/rbffi_endian.h
148
+ - ext/ffi_c/win32/stdbool.h
149
+ - ext/ffi_c/win32/stdint.h
150
+ - ffi.gemspec
151
+ - gen/Rakefile
152
+ - lib/ffi.rb
153
+ - lib/ffi/autopointer.rb
154
+ - lib/ffi/buffer.rb
155
+ - lib/ffi/callback.rb
156
+ - lib/ffi/enum.rb
157
+ - lib/ffi/errno.rb
158
+ - lib/ffi/ffi.rb
159
+ - lib/ffi/io.rb
160
+ - lib/ffi/library.rb
161
+ - lib/ffi/managedstruct.rb
162
+ - lib/ffi/memorypointer.rb
163
+ - lib/ffi/platform.rb
164
+ - lib/ffi/platform/aarch64-linux/types.conf
165
+ - lib/ffi/platform/arm-linux/types.conf
166
+ - lib/ffi/platform/i386-cygwin/types.conf
167
+ - lib/ffi/platform/i386-darwin/types.conf
168
+ - lib/ffi/platform/i386-freebsd/types.conf
169
+ - lib/ffi/platform/i386-gnu/types.conf
170
+ - lib/ffi/platform/i386-linux/types.conf
171
+ - lib/ffi/platform/i386-netbsd/types.conf
172
+ - lib/ffi/platform/i386-openbsd/types.conf
173
+ - lib/ffi/platform/i386-solaris/types.conf
174
+ - lib/ffi/platform/i386-windows/types.conf
175
+ - lib/ffi/platform/ia64-linux/types.conf
176
+ - lib/ffi/platform/mips-linux/types.conf
177
+ - lib/ffi/platform/mips64el-linux/types.conf
178
+ - lib/ffi/platform/mipsel-linux/types.conf
179
+ - lib/ffi/platform/powerpc-aix/types.conf
180
+ - lib/ffi/platform/powerpc-darwin/types.conf
181
+ - lib/ffi/platform/powerpc-linux/types.conf
182
+ - lib/ffi/platform/powerpc64-linux/types.conf
183
+ - lib/ffi/platform/s390-linux/types.conf
184
+ - lib/ffi/platform/s390x-linux/types.conf
185
+ - lib/ffi/platform/sparc-linux/types.conf
186
+ - lib/ffi/platform/sparc-solaris/types.conf
187
+ - lib/ffi/platform/sparc64-linux/types.conf
188
+ - lib/ffi/platform/sparcv9-solaris/types.conf
189
+ - lib/ffi/platform/x86_64-cygwin/types.conf
190
+ - lib/ffi/platform/x86_64-darwin/types.conf
191
+ - lib/ffi/platform/x86_64-freebsd/types.conf
192
+ - lib/ffi/platform/x86_64-linux/types.conf
193
+ - lib/ffi/platform/x86_64-netbsd/types.conf
194
+ - lib/ffi/platform/x86_64-openbsd/types.conf
195
+ - lib/ffi/platform/x86_64-solaris/types.conf
196
+ - lib/ffi/platform/x86_64-windows/types.conf
197
+ - lib/ffi/pointer.rb
198
+ - lib/ffi/struct.rb
199
+ - lib/ffi/struct_layout_builder.rb
200
+ - lib/ffi/tools/const_generator.rb
201
+ - lib/ffi/tools/generator.rb
202
+ - lib/ffi/tools/generator_task.rb
203
+ - lib/ffi/tools/struct_generator.rb
204
+ - lib/ffi/tools/types_generator.rb
205
+ - lib/ffi/types.rb
206
+ - lib/ffi/union.rb
207
+ - lib/ffi/variadic.rb
208
+ - lib/ffi/version.rb
209
+ - libtest/Benchmark.c
210
+ - libtest/BoolTest.c
211
+ - libtest/BufferTest.c
212
+ - libtest/ClosureTest.c
213
+ - libtest/EnumTest.c
214
+ - libtest/FunctionTest.c
215
+ - libtest/GNUmakefile
216
+ - libtest/GlobalVariable.c
217
+ - libtest/LastErrorTest.c
218
+ - libtest/NumberTest.c
219
+ - libtest/PointerTest.c
220
+ - libtest/ReferenceTest.c
221
+ - libtest/StringTest.c
222
+ - libtest/StructTest.c
223
+ - libtest/UnionTest.c
224
+ - libtest/VariadicTest.c
225
+ - spec/ffi/LICENSE.SPECS
226
+ - spec/ffi/async_callback_spec.rb
227
+ - spec/ffi/bitmask_spec.rb
228
+ - spec/ffi/bool_spec.rb
229
+ - spec/ffi/buffer_spec.rb
230
+ - spec/ffi/callback_spec.rb
231
+ - spec/ffi/custom_param_type.rb
232
+ - spec/ffi/custom_type_spec.rb
233
+ - spec/ffi/dup_spec.rb
234
+ - spec/ffi/enum_spec.rb
235
+ - spec/ffi/errno_spec.rb
236
+ - spec/ffi/ffi_spec.rb
237
+ - spec/ffi/fixtures/Benchmark.c
238
+ - spec/ffi/fixtures/BitmaskTest.c
239
+ - spec/ffi/fixtures/BoolTest.c
240
+ - spec/ffi/fixtures/BufferTest.c
241
+ - spec/ffi/fixtures/ClosureTest.c
242
+ - spec/ffi/fixtures/EnumTest.c
243
+ - spec/ffi/fixtures/FunctionTest.c
244
+ - spec/ffi/fixtures/GNUmakefile
245
+ - spec/ffi/fixtures/GlobalVariable.c
246
+ - spec/ffi/fixtures/LastErrorTest.c
247
+ - spec/ffi/fixtures/NumberTest.c
248
+ - spec/ffi/fixtures/PipeHelper.h
249
+ - spec/ffi/fixtures/PipeHelperPosix.c
250
+ - spec/ffi/fixtures/PipeHelperWindows.c
251
+ - spec/ffi/fixtures/PointerTest.c
252
+ - spec/ffi/fixtures/ReferenceTest.c
253
+ - spec/ffi/fixtures/StringTest.c
254
+ - spec/ffi/fixtures/StructTest.c
255
+ - spec/ffi/fixtures/UnionTest.c
256
+ - spec/ffi/fixtures/VariadicTest.c
257
+ - spec/ffi/fixtures/classes.rb
258
+ - spec/ffi/function_spec.rb
259
+ - spec/ffi/io_spec.rb
260
+ - spec/ffi/library_spec.rb
261
+ - spec/ffi/long_double.rb
262
+ - spec/ffi/managed_struct_spec.rb
263
+ - spec/ffi/memorypointer_spec.rb
264
+ - spec/ffi/number_spec.rb
265
+ - spec/ffi/platform_spec.rb
266
+ - spec/ffi/pointer_spec.rb
267
+ - spec/ffi/rbx/attach_function_spec.rb
268
+ - spec/ffi/rbx/memory_pointer_spec.rb
269
+ - spec/ffi/rbx/spec_helper.rb
270
+ - spec/ffi/rbx/struct_spec.rb
271
+ - spec/ffi/spec_helper.rb
272
+ - spec/ffi/string_spec.rb
273
+ - spec/ffi/strptr_spec.rb
274
+ - spec/ffi/struct_by_ref_spec.rb
275
+ - spec/ffi/struct_callback_spec.rb
276
+ - spec/ffi/struct_initialize_spec.rb
277
+ - spec/ffi/struct_packed_spec.rb
278
+ - spec/ffi/struct_spec.rb
279
+ - spec/ffi/typedef_spec.rb
280
+ - spec/ffi/union_spec.rb
281
+ - spec/ffi/variadic_spec.rb
282
+ - spec/spec.opts
283
+ homepage: http://wiki.github.com/ffi/ffi
284
+ licenses:
285
+ - BSD-3-Clause
286
+ metadata: {}
287
+ post_install_message:
288
+ rdoc_options:
289
+ - "--exclude=ext/ffi_c/.*\\.o$"
290
+ - "--exclude=ffi_c\\.(bundle|so)$"
291
+ require_paths:
292
+ - lib
293
+ required_ruby_version: !ruby/object:Gem::Requirement
294
+ requirements:
295
+ - - ">="
296
+ - !ruby/object:Gem::Version
297
+ version: '1.9'
298
+ required_rubygems_version: !ruby/object:Gem::Requirement
299
+ requirements:
300
+ - - ">="
301
+ - !ruby/object:Gem::Version
302
+ version: '0'
303
+ requirements: []
304
+ rubyforge_project:
305
+ rubygems_version: 2.7.3
306
+ signing_key:
307
+ specification_version: 4
308
+ summary: Ruby FFI
309
+ test_files: []