alinta-ffi 1.9.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +49 -0
- data/LICENSE +24 -0
- data/README.md +112 -0
- data/Rakefile +243 -0
- data/ext/ffi_c/AbstractMemory.c +1109 -0
- data/ext/ffi_c/AbstractMemory.h +175 -0
- data/ext/ffi_c/ArrayType.c +162 -0
- data/ext/ffi_c/ArrayType.h +59 -0
- data/ext/ffi_c/Buffer.c +365 -0
- data/ext/ffi_c/Call.c +517 -0
- data/ext/ffi_c/Call.h +110 -0
- data/ext/ffi_c/ClosurePool.c +283 -0
- data/ext/ffi_c/ClosurePool.h +57 -0
- data/ext/ffi_c/DataConverter.c +91 -0
- data/ext/ffi_c/DynamicLibrary.c +339 -0
- data/ext/ffi_c/DynamicLibrary.h +98 -0
- data/ext/ffi_c/Function.c +998 -0
- data/ext/ffi_c/Function.h +87 -0
- data/ext/ffi_c/FunctionInfo.c +271 -0
- data/ext/ffi_c/LastError.c +184 -0
- data/ext/ffi_c/LastError.h +47 -0
- data/ext/ffi_c/LongDouble.c +63 -0
- data/ext/ffi_c/LongDouble.h +51 -0
- data/ext/ffi_c/MappedType.c +168 -0
- data/ext/ffi_c/MappedType.h +59 -0
- data/ext/ffi_c/MemoryPointer.c +197 -0
- data/ext/ffi_c/MemoryPointer.h +53 -0
- data/ext/ffi_c/MethodHandle.c +358 -0
- data/ext/ffi_c/MethodHandle.h +55 -0
- data/ext/ffi_c/Platform.c +129 -0
- data/ext/ffi_c/Platform.h +45 -0
- data/ext/ffi_c/Pointer.c +508 -0
- data/ext/ffi_c/Pointer.h +63 -0
- data/ext/ffi_c/Struct.c +829 -0
- data/ext/ffi_c/Struct.h +106 -0
- data/ext/ffi_c/StructByReference.c +190 -0
- data/ext/ffi_c/StructByReference.h +50 -0
- data/ext/ffi_c/StructByValue.c +150 -0
- data/ext/ffi_c/StructByValue.h +55 -0
- data/ext/ffi_c/StructLayout.c +698 -0
- data/ext/ffi_c/Thread.c +352 -0
- data/ext/ffi_c/Thread.h +95 -0
- data/ext/ffi_c/Type.c +397 -0
- data/ext/ffi_c/Type.h +62 -0
- data/ext/ffi_c/Types.c +139 -0
- data/ext/ffi_c/Types.h +89 -0
- data/ext/ffi_c/Variadic.c +304 -0
- data/ext/ffi_c/compat.h +78 -0
- data/ext/ffi_c/extconf.rb +71 -0
- data/ext/ffi_c/ffi.c +98 -0
- data/ext/ffi_c/libffi.bsd.mk +40 -0
- data/ext/ffi_c/libffi.darwin.mk +105 -0
- data/ext/ffi_c/libffi.gnu.mk +32 -0
- data/ext/ffi_c/libffi.mk +18 -0
- data/ext/ffi_c/libffi.vc.mk +26 -0
- data/ext/ffi_c/libffi.vc64.mk +26 -0
- data/ext/ffi_c/rbffi.h +57 -0
- data/ext/ffi_c/rbffi_endian.h +59 -0
- data/ext/ffi_c/win32/stdbool.h +8 -0
- data/ext/ffi_c/win32/stdint.h +201 -0
- data/ffi.gemspec +23 -0
- data/gen/Rakefile +30 -0
- data/lib/ffi.rb +20 -0
- data/lib/ffi/autopointer.rb +203 -0
- data/lib/ffi/buffer.rb +4 -0
- data/lib/ffi/callback.rb +4 -0
- data/lib/ffi/enum.rb +296 -0
- data/lib/ffi/errno.rb +43 -0
- data/lib/ffi/ffi.rb +44 -0
- data/lib/ffi/io.rb +62 -0
- data/lib/ffi/library.rb +590 -0
- data/lib/ffi/managedstruct.rb +84 -0
- data/lib/ffi/memorypointer.rb +1 -0
- data/lib/ffi/platform.rb +164 -0
- data/lib/ffi/platform/aarch64-linux/types.conf +104 -0
- data/lib/ffi/platform/arm-linux/types.conf +104 -0
- data/lib/ffi/platform/i386-cygwin/types.conf +3 -0
- data/lib/ffi/platform/i386-darwin/types.conf +100 -0
- data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
- data/lib/ffi/platform/i386-gnu/types.conf +107 -0
- data/lib/ffi/platform/i386-linux/types.conf +103 -0
- data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
- data/lib/ffi/platform/i386-openbsd/types.conf +128 -0
- data/lib/ffi/platform/i386-solaris/types.conf +122 -0
- data/lib/ffi/platform/i386-windows/types.conf +105 -0
- data/lib/ffi/platform/ia64-linux/types.conf +104 -0
- data/lib/ffi/platform/mips-linux/types.conf +102 -0
- data/lib/ffi/platform/mips64el-linux/types.conf +104 -0
- data/lib/ffi/platform/mipsel-linux/types.conf +102 -0
- data/lib/ffi/platform/powerpc-aix/types.conf +180 -0
- data/lib/ffi/platform/powerpc-darwin/types.conf +100 -0
- data/lib/ffi/platform/powerpc-linux/types.conf +100 -0
- data/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
- data/lib/ffi/platform/s390-linux/types.conf +102 -0
- data/lib/ffi/platform/s390x-linux/types.conf +102 -0
- data/lib/ffi/platform/sparc-linux/types.conf +102 -0
- data/lib/ffi/platform/sparc-solaris/types.conf +128 -0
- data/lib/ffi/platform/sparc64-linux/types.conf +102 -0
- data/lib/ffi/platform/sparcv9-solaris/types.conf +128 -0
- data/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +126 -0
- data/lib/ffi/platform/x86_64-freebsd/types.conf +128 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +102 -0
- data/lib/ffi/platform/x86_64-netbsd/types.conf +128 -0
- data/lib/ffi/platform/x86_64-openbsd/types.conf +134 -0
- data/lib/ffi/platform/x86_64-solaris/types.conf +122 -0
- data/lib/ffi/platform/x86_64-windows/types.conf +120 -0
- data/lib/ffi/pointer.rb +161 -0
- data/lib/ffi/struct.rb +371 -0
- data/lib/ffi/struct_layout_builder.rb +227 -0
- data/lib/ffi/tools/const_generator.rb +229 -0
- data/lib/ffi/tools/generator.rb +60 -0
- data/lib/ffi/tools/generator_task.rb +36 -0
- data/lib/ffi/tools/struct_generator.rb +194 -0
- data/lib/ffi/tools/types_generator.rb +134 -0
- data/lib/ffi/types.rb +194 -0
- data/lib/ffi/union.rb +43 -0
- data/lib/ffi/variadic.rb +78 -0
- data/lib/ffi/version.rb +4 -0
- data/libtest/Benchmark.c +52 -0
- data/libtest/BoolTest.c +34 -0
- data/libtest/BufferTest.c +31 -0
- data/libtest/ClosureTest.c +205 -0
- data/libtest/EnumTest.c +51 -0
- data/libtest/FunctionTest.c +70 -0
- data/libtest/GNUmakefile +149 -0
- data/libtest/GlobalVariable.c +62 -0
- data/libtest/LastErrorTest.c +21 -0
- data/libtest/NumberTest.c +132 -0
- data/libtest/PointerTest.c +63 -0
- data/libtest/ReferenceTest.c +23 -0
- data/libtest/StringTest.c +34 -0
- data/libtest/StructTest.c +243 -0
- data/libtest/UnionTest.c +43 -0
- data/libtest/VariadicTest.c +99 -0
- data/spec/ffi/LICENSE.SPECS +22 -0
- data/spec/ffi/async_callback_spec.rb +35 -0
- data/spec/ffi/bitmask_spec.rb +575 -0
- data/spec/ffi/bool_spec.rb +32 -0
- data/spec/ffi/buffer_spec.rb +279 -0
- data/spec/ffi/callback_spec.rb +773 -0
- data/spec/ffi/custom_param_type.rb +37 -0
- data/spec/ffi/custom_type_spec.rb +74 -0
- data/spec/ffi/dup_spec.rb +52 -0
- data/spec/ffi/enum_spec.rb +423 -0
- data/spec/ffi/errno_spec.rb +20 -0
- data/spec/ffi/ffi_spec.rb +28 -0
- data/spec/ffi/fixtures/Benchmark.c +52 -0
- data/spec/ffi/fixtures/BitmaskTest.c +51 -0
- data/spec/ffi/fixtures/BoolTest.c +34 -0
- data/spec/ffi/fixtures/BufferTest.c +31 -0
- data/spec/ffi/fixtures/ClosureTest.c +205 -0
- data/spec/ffi/fixtures/EnumTest.c +51 -0
- data/spec/ffi/fixtures/FunctionTest.c +142 -0
- data/spec/ffi/fixtures/GNUmakefile +149 -0
- data/spec/ffi/fixtures/GlobalVariable.c +62 -0
- data/spec/ffi/fixtures/LastErrorTest.c +21 -0
- data/spec/ffi/fixtures/NumberTest.c +132 -0
- data/spec/ffi/fixtures/PipeHelper.h +21 -0
- data/spec/ffi/fixtures/PipeHelperPosix.c +41 -0
- data/spec/ffi/fixtures/PipeHelperWindows.c +72 -0
- data/spec/ffi/fixtures/PointerTest.c +63 -0
- data/spec/ffi/fixtures/ReferenceTest.c +23 -0
- data/spec/ffi/fixtures/StringTest.c +34 -0
- data/spec/ffi/fixtures/StructTest.c +243 -0
- data/spec/ffi/fixtures/UnionTest.c +43 -0
- data/spec/ffi/fixtures/VariadicTest.c +99 -0
- data/spec/ffi/fixtures/classes.rb +438 -0
- data/spec/ffi/function_spec.rb +97 -0
- data/spec/ffi/io_spec.rb +16 -0
- data/spec/ffi/library_spec.rb +286 -0
- data/spec/ffi/long_double.rb +30 -0
- data/spec/ffi/managed_struct_spec.rb +68 -0
- data/spec/ffi/memorypointer_spec.rb +78 -0
- data/spec/ffi/number_spec.rb +247 -0
- data/spec/ffi/platform_spec.rb +114 -0
- data/spec/ffi/pointer_spec.rb +285 -0
- data/spec/ffi/rbx/attach_function_spec.rb +34 -0
- data/spec/ffi/rbx/memory_pointer_spec.rb +198 -0
- data/spec/ffi/rbx/spec_helper.rb +6 -0
- data/spec/ffi/rbx/struct_spec.rb +18 -0
- data/spec/ffi/spec_helper.rb +93 -0
- data/spec/ffi/string_spec.rb +118 -0
- data/spec/ffi/strptr_spec.rb +50 -0
- data/spec/ffi/struct_by_ref_spec.rb +43 -0
- data/spec/ffi/struct_callback_spec.rb +69 -0
- data/spec/ffi/struct_initialize_spec.rb +35 -0
- data/spec/ffi/struct_packed_spec.rb +50 -0
- data/spec/ffi/struct_spec.rb +882 -0
- data/spec/ffi/typedef_spec.rb +91 -0
- data/spec/ffi/union_spec.rb +67 -0
- data/spec/ffi/variadic_spec.rb +132 -0
- data/spec/spec.opts +4 -0
- metadata +309 -0
@@ -0,0 +1,134 @@
|
|
1
|
+
rbx.platform.typedef.__int8_t = char
|
2
|
+
rbx.platform.typedef.__uint8_t = uchar
|
3
|
+
rbx.platform.typedef.__int16_t = short
|
4
|
+
rbx.platform.typedef.__uint16_t = ushort
|
5
|
+
rbx.platform.typedef.__int32_t = int
|
6
|
+
rbx.platform.typedef.__uint32_t = uint
|
7
|
+
rbx.platform.typedef.__int64_t = long_long
|
8
|
+
rbx.platform.typedef.__uint64_t = ulong_long
|
9
|
+
rbx.platform.typedef.__int_least8_t = char
|
10
|
+
rbx.platform.typedef.__uint_least8_t = uchar
|
11
|
+
rbx.platform.typedef.__int_least16_t = short
|
12
|
+
rbx.platform.typedef.__uint_least16_t = ushort
|
13
|
+
rbx.platform.typedef.__int_least32_t = int
|
14
|
+
rbx.platform.typedef.__uint_least32_t = uint
|
15
|
+
rbx.platform.typedef.__int_least64_t = long_long
|
16
|
+
rbx.platform.typedef.__uint_least64_t = ulong_long
|
17
|
+
rbx.platform.typedef.__int_fast8_t = int
|
18
|
+
rbx.platform.typedef.__uint_fast8_t = uint
|
19
|
+
rbx.platform.typedef.__int_fast16_t = int
|
20
|
+
rbx.platform.typedef.__uint_fast16_t = uint
|
21
|
+
rbx.platform.typedef.__int_fast32_t = int
|
22
|
+
rbx.platform.typedef.__uint_fast32_t = uint
|
23
|
+
rbx.platform.typedef.__int_fast64_t = long_long
|
24
|
+
rbx.platform.typedef.__uint_fast64_t = ulong_long
|
25
|
+
rbx.platform.typedef.__intptr_t = long
|
26
|
+
rbx.platform.typedef.__uintptr_t = ulong
|
27
|
+
rbx.platform.typedef.__intmax_t = long_long
|
28
|
+
rbx.platform.typedef.__uintmax_t = ulong_long
|
29
|
+
rbx.platform.typedef.__register_t = long
|
30
|
+
rbx.platform.typedef.__vaddr_t = ulong
|
31
|
+
rbx.platform.typedef.__paddr_t = ulong
|
32
|
+
rbx.platform.typedef.__vsize_t = ulong
|
33
|
+
rbx.platform.typedef.__psize_t = ulong
|
34
|
+
rbx.platform.typedef.__ptrdiff_t = long
|
35
|
+
rbx.platform.typedef.__size_t = ulong
|
36
|
+
rbx.platform.typedef.__ssize_t = long
|
37
|
+
rbx.platform.typedef.__wchar_t = int
|
38
|
+
rbx.platform.typedef.__wint_t = int
|
39
|
+
rbx.platform.typedef.__rune_t = int
|
40
|
+
rbx.platform.typedef.__wctrans_t = pointer
|
41
|
+
rbx.platform.typedef.__wctype_t = pointer
|
42
|
+
rbx.platform.typedef.__blkcnt_t = long_long
|
43
|
+
rbx.platform.typedef.__blksize_t = int
|
44
|
+
rbx.platform.typedef.__clock_t = long_long
|
45
|
+
rbx.platform.typedef.__clockid_t = int
|
46
|
+
rbx.platform.typedef.__cpuid_t = ulong
|
47
|
+
rbx.platform.typedef.__dev_t = int
|
48
|
+
rbx.platform.typedef.__fixpt_t = uint
|
49
|
+
rbx.platform.typedef.__fsblkcnt_t = ulong_long
|
50
|
+
rbx.platform.typedef.__fsfilcnt_t = ulong_long
|
51
|
+
rbx.platform.typedef.__gid_t = uint
|
52
|
+
rbx.platform.typedef.__id_t = uint
|
53
|
+
rbx.platform.typedef.__in_addr_t = uint
|
54
|
+
rbx.platform.typedef.__in_port_t = ushort
|
55
|
+
rbx.platform.typedef.__ino_t = ulong_long
|
56
|
+
rbx.platform.typedef.__key_t = long
|
57
|
+
rbx.platform.typedef.__mode_t = uint
|
58
|
+
rbx.platform.typedef.__nlink_t = uint
|
59
|
+
rbx.platform.typedef.__off_t = long_long
|
60
|
+
rbx.platform.typedef.__pid_t = int
|
61
|
+
rbx.platform.typedef.__rlim_t = ulong_long
|
62
|
+
rbx.platform.typedef.__sa_family_t = uchar
|
63
|
+
rbx.platform.typedef.__segsz_t = int
|
64
|
+
rbx.platform.typedef.__socklen_t = uint
|
65
|
+
rbx.platform.typedef.__suseconds_t = long
|
66
|
+
rbx.platform.typedef.__swblk_t = int
|
67
|
+
rbx.platform.typedef.__time_t = long_long
|
68
|
+
rbx.platform.typedef.__timer_t = int
|
69
|
+
rbx.platform.typedef.__uid_t = uint
|
70
|
+
rbx.platform.typedef.__useconds_t = uint
|
71
|
+
rbx.platform.typedef.u_char = uchar
|
72
|
+
rbx.platform.typedef.u_short = ushort
|
73
|
+
rbx.platform.typedef.u_int = uint
|
74
|
+
rbx.platform.typedef.u_long = ulong
|
75
|
+
rbx.platform.typedef.unchar = uchar
|
76
|
+
rbx.platform.typedef.ushort = ushort
|
77
|
+
rbx.platform.typedef.uint = uint
|
78
|
+
rbx.platform.typedef.ulong = ulong
|
79
|
+
rbx.platform.typedef.cpuid_t = ulong
|
80
|
+
rbx.platform.typedef.register_t = long
|
81
|
+
rbx.platform.typedef.int8_t = char
|
82
|
+
rbx.platform.typedef.uint8_t = uchar
|
83
|
+
rbx.platform.typedef.int16_t = short
|
84
|
+
rbx.platform.typedef.uint16_t = ushort
|
85
|
+
rbx.platform.typedef.int32_t = int
|
86
|
+
rbx.platform.typedef.uint32_t = uint
|
87
|
+
rbx.platform.typedef.int64_t = long_long
|
88
|
+
rbx.platform.typedef.uint64_t = ulong_long
|
89
|
+
rbx.platform.typedef.u_int8_t = uchar
|
90
|
+
rbx.platform.typedef.u_int16_t = ushort
|
91
|
+
rbx.platform.typedef.u_int32_t = uint
|
92
|
+
rbx.platform.typedef.u_int64_t = ulong_long
|
93
|
+
rbx.platform.typedef.quad_t = long_long
|
94
|
+
rbx.platform.typedef.u_quad_t = ulong_long
|
95
|
+
rbx.platform.typedef.qaddr_t = pointer
|
96
|
+
rbx.platform.typedef.vaddr_t = ulong
|
97
|
+
rbx.platform.typedef.paddr_t = ulong
|
98
|
+
rbx.platform.typedef.vsize_t = ulong
|
99
|
+
rbx.platform.typedef.psize_t = ulong
|
100
|
+
rbx.platform.typedef.blkcnt_t = long_long
|
101
|
+
rbx.platform.typedef.blksize_t = int
|
102
|
+
rbx.platform.typedef.caddr_t = string
|
103
|
+
rbx.platform.typedef.daddr32_t = int
|
104
|
+
rbx.platform.typedef.daddr_t = long_long
|
105
|
+
rbx.platform.typedef.dev_t = int
|
106
|
+
rbx.platform.typedef.fixpt_t = uint
|
107
|
+
rbx.platform.typedef.gid_t = uint
|
108
|
+
rbx.platform.typedef.id_t = uint
|
109
|
+
rbx.platform.typedef.ino_t = ulong_long
|
110
|
+
rbx.platform.typedef.key_t = long
|
111
|
+
rbx.platform.typedef.mode_t = uint
|
112
|
+
rbx.platform.typedef.nlink_t = uint
|
113
|
+
rbx.platform.typedef.rlim_t = ulong_long
|
114
|
+
rbx.platform.typedef.segsz_t = int
|
115
|
+
rbx.platform.typedef.swblk_t = int
|
116
|
+
rbx.platform.typedef.uid_t = uint
|
117
|
+
rbx.platform.typedef.useconds_t = uint
|
118
|
+
rbx.platform.typedef.suseconds_t = long
|
119
|
+
rbx.platform.typedef.fsblkcnt_t = ulong_long
|
120
|
+
rbx.platform.typedef.fsfilcnt_t = ulong_long
|
121
|
+
rbx.platform.typedef.in_addr_t = uint
|
122
|
+
rbx.platform.typedef.in_port_t = ushort
|
123
|
+
rbx.platform.typedef.clock_t = long_long
|
124
|
+
rbx.platform.typedef.clockid_t = int
|
125
|
+
rbx.platform.typedef.pid_t = int
|
126
|
+
rbx.platform.typedef.size_t = ulong
|
127
|
+
rbx.platform.typedef.ssize_t = long
|
128
|
+
rbx.platform.typedef.time_t = long_long
|
129
|
+
rbx.platform.typedef.timer_t = int
|
130
|
+
rbx.platform.typedef.off_t = long_long
|
131
|
+
rbx.platform.typedef.__fd_mask = uint
|
132
|
+
rbx.platform.typedef.sigset_t = uint
|
133
|
+
rbx.platform.typedef.socklen_t = uint
|
134
|
+
rbx.platform.typedef.sa_family_t = uchar
|
@@ -0,0 +1,122 @@
|
|
1
|
+
rbx.platform.typedef.lock_t = uchar
|
2
|
+
rbx.platform.typedef.int8_t = char
|
3
|
+
rbx.platform.typedef.int16_t = short
|
4
|
+
rbx.platform.typedef.int32_t = int
|
5
|
+
rbx.platform.typedef.int64_t = long
|
6
|
+
rbx.platform.typedef.uint8_t = uchar
|
7
|
+
rbx.platform.typedef.uint16_t = ushort
|
8
|
+
rbx.platform.typedef.uint32_t = uint
|
9
|
+
rbx.platform.typedef.uint64_t = ulong
|
10
|
+
rbx.platform.typedef.intmax_t = long
|
11
|
+
rbx.platform.typedef.uintmax_t = ulong
|
12
|
+
rbx.platform.typedef.intptr_t = long
|
13
|
+
rbx.platform.typedef.uintptr_t = ulong
|
14
|
+
rbx.platform.typedef.int_fast8_t = char
|
15
|
+
rbx.platform.typedef.int_fast16_t = int
|
16
|
+
rbx.platform.typedef.int_fast32_t = int
|
17
|
+
rbx.platform.typedef.int_fast64_t = long
|
18
|
+
rbx.platform.typedef.uint_fast8_t = uchar
|
19
|
+
rbx.platform.typedef.uint_fast16_t = uint
|
20
|
+
rbx.platform.typedef.uint_fast32_t = uint
|
21
|
+
rbx.platform.typedef.uint_fast64_t = ulong
|
22
|
+
rbx.platform.typedef.int_least8_t = char
|
23
|
+
rbx.platform.typedef.int_least16_t = short
|
24
|
+
rbx.platform.typedef.int_least32_t = int
|
25
|
+
rbx.platform.typedef.int_least64_t = long
|
26
|
+
rbx.platform.typedef.uint_least8_t = uchar
|
27
|
+
rbx.platform.typedef.uint_least16_t = ushort
|
28
|
+
rbx.platform.typedef.uint_least32_t = uint
|
29
|
+
rbx.platform.typedef.uint_least64_t = ulong
|
30
|
+
rbx.platform.typedef.longlong_t = long_long
|
31
|
+
rbx.platform.typedef.u_longlong_t = ulong_long
|
32
|
+
rbx.platform.typedef.t_scalar_t = int
|
33
|
+
rbx.platform.typedef.t_uscalar_t = uint
|
34
|
+
rbx.platform.typedef.uchar_t = uchar
|
35
|
+
rbx.platform.typedef.ushort_t = ushort
|
36
|
+
rbx.platform.typedef.uint_t = uint
|
37
|
+
rbx.platform.typedef.ulong_t = ulong
|
38
|
+
rbx.platform.typedef.*caddr_t = char
|
39
|
+
rbx.platform.typedef.daddr_t = long
|
40
|
+
rbx.platform.typedef.cnt_t = short
|
41
|
+
rbx.platform.typedef.ptrdiff_t = long
|
42
|
+
rbx.platform.typedef.pfn_t = ulong
|
43
|
+
rbx.platform.typedef.pgcnt_t = ulong
|
44
|
+
rbx.platform.typedef.spgcnt_t = long
|
45
|
+
rbx.platform.typedef.use_t = uchar
|
46
|
+
rbx.platform.typedef.sysid_t = short
|
47
|
+
rbx.platform.typedef.index_t = short
|
48
|
+
rbx.platform.typedef.off_t = long
|
49
|
+
rbx.platform.typedef.off64_t = long
|
50
|
+
rbx.platform.typedef.ino_t = ulong
|
51
|
+
rbx.platform.typedef.blkcnt_t = long
|
52
|
+
rbx.platform.typedef.fsblkcnt_t = ulong
|
53
|
+
rbx.platform.typedef.fsfilcnt_t = ulong
|
54
|
+
rbx.platform.typedef.ino64_t = ulong
|
55
|
+
rbx.platform.typedef.blkcnt64_t = long
|
56
|
+
rbx.platform.typedef.fsblkcnt64_t = ulong
|
57
|
+
rbx.platform.typedef.fsfilcnt64_t = ulong
|
58
|
+
rbx.platform.typedef.blksize_t = int
|
59
|
+
rbx.platform.typedef.pad64_t = long
|
60
|
+
rbx.platform.typedef.upad64_t = ulong
|
61
|
+
rbx.platform.typedef.offset_t = long_long
|
62
|
+
rbx.platform.typedef.u_offset_t = ulong_long
|
63
|
+
rbx.platform.typedef.len_t = ulong_long
|
64
|
+
rbx.platform.typedef.diskaddr_t = ulong_long
|
65
|
+
rbx.platform.typedef.k_fltset_t = uint
|
66
|
+
rbx.platform.typedef.id_t = int
|
67
|
+
rbx.platform.typedef.lgrp_id_t = int
|
68
|
+
rbx.platform.typedef.useconds_t = uint
|
69
|
+
rbx.platform.typedef.suseconds_t = long
|
70
|
+
rbx.platform.typedef.major_t = uint
|
71
|
+
rbx.platform.typedef.minor_t = uint
|
72
|
+
rbx.platform.typedef.pri_t = short
|
73
|
+
rbx.platform.typedef.cpu_flag_t = ushort
|
74
|
+
rbx.platform.typedef.o_mode_t = ushort
|
75
|
+
rbx.platform.typedef.o_dev_t = short
|
76
|
+
rbx.platform.typedef.o_uid_t = ushort
|
77
|
+
rbx.platform.typedef.o_gid_t = ushort
|
78
|
+
rbx.platform.typedef.o_nlink_t = short
|
79
|
+
rbx.platform.typedef.o_pid_t = short
|
80
|
+
rbx.platform.typedef.o_ino_t = ushort
|
81
|
+
rbx.platform.typedef.key_t = int
|
82
|
+
rbx.platform.typedef.mode_t = uint
|
83
|
+
rbx.platform.typedef.uid_t = uint
|
84
|
+
rbx.platform.typedef.gid_t = uint
|
85
|
+
rbx.platform.typedef.datalink_id_t = uint
|
86
|
+
rbx.platform.typedef.taskid_t = int
|
87
|
+
rbx.platform.typedef.projid_t = int
|
88
|
+
rbx.platform.typedef.poolid_t = int
|
89
|
+
rbx.platform.typedef.zoneid_t = int
|
90
|
+
rbx.platform.typedef.ctid_t = int
|
91
|
+
rbx.platform.typedef.pthread_t = uint
|
92
|
+
rbx.platform.typedef.pthread_key_t = uint
|
93
|
+
rbx.platform.typedef.dev_t = ulong
|
94
|
+
rbx.platform.typedef.nlink_t = uint
|
95
|
+
rbx.platform.typedef.pid_t = int
|
96
|
+
rbx.platform.typedef.size_t = ulong
|
97
|
+
rbx.platform.typedef.ssize_t = long
|
98
|
+
rbx.platform.typedef.time_t = long
|
99
|
+
rbx.platform.typedef.clock_t = long
|
100
|
+
rbx.platform.typedef.clockid_t = int
|
101
|
+
rbx.platform.typedef.timer_t = int
|
102
|
+
rbx.platform.typedef.unchar = uchar
|
103
|
+
rbx.platform.typedef.ushort = ushort
|
104
|
+
rbx.platform.typedef.uint = uint
|
105
|
+
rbx.platform.typedef.ulong = ulong
|
106
|
+
rbx.platform.typedef.u_char = uchar
|
107
|
+
rbx.platform.typedef.u_short = ushort
|
108
|
+
rbx.platform.typedef.u_int = uint
|
109
|
+
rbx.platform.typedef.u_long = ulong
|
110
|
+
rbx.platform.typedef.hrtime_t = long_long
|
111
|
+
rbx.platform.typedef.fd_mask = long
|
112
|
+
rbx.platform.typedef.fds_mask = long
|
113
|
+
rbx.platform.typedef.sa_family_t = ushort
|
114
|
+
rbx.platform.typedef.socklen_t = uint
|
115
|
+
rbx.platform.typedef.nfds_t = ulong
|
116
|
+
rbx.platform.typedef.disp_lock_t = uchar
|
117
|
+
rbx.platform.typedef.model_t = uint
|
118
|
+
rbx.platform.typedef.in_port_t = ushort
|
119
|
+
rbx.platform.typedef.in_addr_t = uint
|
120
|
+
rbx.platform.typedef.ipaddr_t = uint
|
121
|
+
rbx.platform.typedef.rlim_t = ulong
|
122
|
+
rbx.platform.typedef.rlim64_t = ulong_long
|
@@ -0,0 +1,120 @@
|
|
1
|
+
rbx.platform.typedef.__int8_t = char
|
2
|
+
rbx.platform.typedef.__uint8_t = uchar
|
3
|
+
rbx.platform.typedef.__int16_t = short
|
4
|
+
rbx.platform.typedef.__uint16_t = ushort
|
5
|
+
rbx.platform.typedef.__int_least16_t = short
|
6
|
+
rbx.platform.typedef.__uint_least16_t = ushort
|
7
|
+
rbx.platform.typedef.__int32_t = int
|
8
|
+
rbx.platform.typedef.__uint32_t = uint
|
9
|
+
rbx.platform.typedef.__int_least32_t = int
|
10
|
+
rbx.platform.typedef.__uint_least32_t = uint
|
11
|
+
rbx.platform.typedef.__int64_t = long_long
|
12
|
+
rbx.platform.typedef.__uint64_t = ulong_long
|
13
|
+
rbx.platform.typedef._off_t = long
|
14
|
+
rbx.platform.typedef.__dev_t = short
|
15
|
+
rbx.platform.typedef.__uid_t = ushort
|
16
|
+
rbx.platform.typedef.__gid_t = ushort
|
17
|
+
rbx.platform.typedef._off64_t = long_long
|
18
|
+
rbx.platform.typedef.fpos_t = long_long
|
19
|
+
rbx.platform.typedef._fpos_t = long_long
|
20
|
+
rbx.platform.typedef._fpos64_t = long_long
|
21
|
+
rbx.platform.typedef._ssize_t = long_long
|
22
|
+
rbx.platform.typedef.wchar_t = ushort
|
23
|
+
rbx.platform.typedef.wint_t = uint
|
24
|
+
rbx.platform.typedef.wctype_t = ushort
|
25
|
+
rbx.platform.typedef.ptrdiff_t = long_long
|
26
|
+
rbx.platform.typedef.size_t = ulong_long
|
27
|
+
rbx.platform.typedef.__off_t = long
|
28
|
+
rbx.platform.typedef.__pid_t = int
|
29
|
+
rbx.platform.typedef.__loff_t = long_long
|
30
|
+
rbx.platform.typedef.u_char = uchar
|
31
|
+
rbx.platform.typedef.u_short = ushort
|
32
|
+
rbx.platform.typedef.u_int = uint
|
33
|
+
rbx.platform.typedef.u_long = ulong
|
34
|
+
rbx.platform.typedef.ushort = ushort
|
35
|
+
rbx.platform.typedef.uint = uint
|
36
|
+
rbx.platform.typedef.ulong = ulong
|
37
|
+
rbx.platform.typedef.clock_t = ulong
|
38
|
+
rbx.platform.typedef.time_t = long_long
|
39
|
+
rbx.platform.typedef.daddr_t = long
|
40
|
+
rbx.platform.typedef.caddr_t = string
|
41
|
+
rbx.platform.typedef.pid_t = int
|
42
|
+
rbx.platform.typedef.ssize_t = int
|
43
|
+
rbx.platform.typedef.nlink_t = ushort
|
44
|
+
rbx.platform.typedef.fd_mask = long
|
45
|
+
rbx.platform.typedef.clockid_t = ulong
|
46
|
+
rbx.platform.typedef.timer_t = ulong
|
47
|
+
rbx.platform.typedef.useconds_t = ulong
|
48
|
+
rbx.platform.typedef.suseconds_t = long
|
49
|
+
rbx.platform.typedef.int8_t = char
|
50
|
+
rbx.platform.typedef.int16_t = short
|
51
|
+
rbx.platform.typedef.int32_t = int
|
52
|
+
rbx.platform.typedef.int64_t = long_long
|
53
|
+
rbx.platform.typedef.uint8_t = uchar
|
54
|
+
rbx.platform.typedef.uint16_t = ushort
|
55
|
+
rbx.platform.typedef.uint32_t = uint
|
56
|
+
rbx.platform.typedef.uint64_t = ulong_long
|
57
|
+
rbx.platform.typedef.int_least8_t = char
|
58
|
+
rbx.platform.typedef.int_least16_t = short
|
59
|
+
rbx.platform.typedef.int_least32_t = int
|
60
|
+
rbx.platform.typedef.int_least64_t = long_long
|
61
|
+
rbx.platform.typedef.uint_least8_t = uchar
|
62
|
+
rbx.platform.typedef.uint_least16_t = ushort
|
63
|
+
rbx.platform.typedef.uint_least32_t = uint
|
64
|
+
rbx.platform.typedef.uint_least64_t = ulong_long
|
65
|
+
rbx.platform.typedef.int_fast8_t = char
|
66
|
+
rbx.platform.typedef.int_fast16_t = int
|
67
|
+
rbx.platform.typedef.int_fast32_t = int
|
68
|
+
rbx.platform.typedef.int_fast64_t = long_long
|
69
|
+
rbx.platform.typedef.uint_fast8_t = uchar
|
70
|
+
rbx.platform.typedef.uint_fast16_t = uint
|
71
|
+
rbx.platform.typedef.uint_fast32_t = uint
|
72
|
+
rbx.platform.typedef.uint_fast64_t = ulong_long
|
73
|
+
rbx.platform.typedef.intptr_t = long_long
|
74
|
+
rbx.platform.typedef.uintptr_t = ulong_long
|
75
|
+
rbx.platform.typedef.intmax_t = long_long
|
76
|
+
rbx.platform.typedef.uintmax_t = ulong_long
|
77
|
+
rbx.platform.typedef.off_t = long_long
|
78
|
+
rbx.platform.typedef.loff_t = long_long
|
79
|
+
rbx.platform.typedef.__dev16_t = short
|
80
|
+
rbx.platform.typedef.__dev32_t = ulong
|
81
|
+
rbx.platform.typedef._dev_t = uint
|
82
|
+
rbx.platform.typedef.dev_t = uint
|
83
|
+
rbx.platform.typedef.blksize_t = long
|
84
|
+
rbx.platform.typedef.__blkcnt32_t = long
|
85
|
+
rbx.platform.typedef.__blkcnt64_t = long_long
|
86
|
+
rbx.platform.typedef.blkcnt_t = long_long
|
87
|
+
rbx.platform.typedef.fsblkcnt_t = ulong
|
88
|
+
rbx.platform.typedef.fsfilcnt_t = ulong
|
89
|
+
rbx.platform.typedef.__uid16_t = ushort
|
90
|
+
rbx.platform.typedef.__uid32_t = ulong
|
91
|
+
rbx.platform.typedef.uid_t = ulong
|
92
|
+
rbx.platform.typedef.__gid16_t = ushort
|
93
|
+
rbx.platform.typedef.__gid32_t = ulong
|
94
|
+
rbx.platform.typedef.gid_t = ulong
|
95
|
+
rbx.platform.typedef.__ino32_t = ulong
|
96
|
+
rbx.platform.typedef.__ino64_t = ulong_long
|
97
|
+
rbx.platform.typedef.ino_t = ushort
|
98
|
+
rbx.platform.typedef._ino_t = ushort
|
99
|
+
rbx.platform.typedef.id_t = ulong
|
100
|
+
rbx.platform.typedef.key_t = long_long
|
101
|
+
rbx.platform.typedef.vm_offset_t = ulong
|
102
|
+
rbx.platform.typedef.vm_size_t = ulong
|
103
|
+
rbx.platform.typedef.u_int8_t = uchar
|
104
|
+
rbx.platform.typedef.u_int16_t = ushort
|
105
|
+
rbx.platform.typedef.u_int32_t = uint
|
106
|
+
rbx.platform.typedef.u_int64_t = ulong_long
|
107
|
+
rbx.platform.typedef.register_t = int
|
108
|
+
rbx.platform.typedef.*addr_t = char
|
109
|
+
rbx.platform.typedef.socklen_t = int
|
110
|
+
rbx.platform.typedef.sa_family_t = ushort
|
111
|
+
rbx.platform.typedef.__ULong = ulong
|
112
|
+
rbx.platform.typedef.sigset_t = ulong
|
113
|
+
rbx.platform.typedef.sig_atomic_t = int
|
114
|
+
rbx.platform.typedef.rlim_t = ulong
|
115
|
+
rbx.platform.typedef._sigset_t = ulong_long
|
116
|
+
rbx.platform.typedef.__time32_t = long
|
117
|
+
rbx.platform.typedef.__time64_t = long_long
|
118
|
+
rbx.platform.typedef.errno_t = int
|
119
|
+
rbx.platform.typedef._mode_t = ushort
|
120
|
+
rbx.platform.typedef.mode_t = ushort
|
data/lib/ffi/pointer.rb
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2008, 2009 Wayne Meissner
|
3
|
+
# Copyright (c) 2007, 2008 Evan Phoenix
|
4
|
+
#
|
5
|
+
# This file is part of ruby-ffi.
|
6
|
+
#
|
7
|
+
# All rights reserved.
|
8
|
+
#
|
9
|
+
# Redistribution and use in source and binary forms, with or without
|
10
|
+
# modification, are permitted provided that the following conditions are met:
|
11
|
+
#
|
12
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
13
|
+
# list of conditions and the following disclaimer.
|
14
|
+
# * Redistributions in binary form must reproduce the above copyright notice
|
15
|
+
# this list of conditions and the following disclaimer in the documentation
|
16
|
+
# and/or other materials provided with the distribution.
|
17
|
+
# * Neither the name of the Ruby FFI project nor the names of its contributors
|
18
|
+
# may be used to endorse or promote products derived from this software
|
19
|
+
# without specific prior written permission.
|
20
|
+
#
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
22
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
23
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
24
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
25
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
26
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
27
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
29
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#
|
32
|
+
|
33
|
+
require 'ffi/platform'
|
34
|
+
module FFI
|
35
|
+
class Pointer
|
36
|
+
|
37
|
+
# Pointer size
|
38
|
+
SIZE = Platform::ADDRESS_SIZE / 8
|
39
|
+
|
40
|
+
# Return the size of a pointer on the current platform, in bytes
|
41
|
+
# @return [Numeric]
|
42
|
+
def self.size
|
43
|
+
SIZE
|
44
|
+
end
|
45
|
+
|
46
|
+
# @param [nil,Numeric] len length of string to return
|
47
|
+
# @return [String]
|
48
|
+
# Read pointer's contents as a string, or the first +len+ bytes of the
|
49
|
+
# equivalent string if +len+ is not +nil+.
|
50
|
+
def read_string(len=nil)
|
51
|
+
if len
|
52
|
+
return '' if len == 0
|
53
|
+
get_bytes(0, len)
|
54
|
+
else
|
55
|
+
get_string(0)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# @param [Numeric] len length of string to return
|
60
|
+
# @return [String]
|
61
|
+
# Read the first +len+ bytes of pointer's contents as a string.
|
62
|
+
#
|
63
|
+
# Same as:
|
64
|
+
# ptr.read_string(len) # with len not nil
|
65
|
+
def read_string_length(len)
|
66
|
+
get_bytes(0, len)
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [String]
|
70
|
+
# Read pointer's contents as a string.
|
71
|
+
#
|
72
|
+
# Same as:
|
73
|
+
# ptr.read_string # with no len
|
74
|
+
def read_string_to_null
|
75
|
+
get_string(0)
|
76
|
+
end
|
77
|
+
|
78
|
+
# @param [String] str string to write
|
79
|
+
# @param [Numeric] len length of string to return
|
80
|
+
# @return [self]
|
81
|
+
# Write +len+ first bytes of +str+ in pointer's contents.
|
82
|
+
#
|
83
|
+
# Same as:
|
84
|
+
# ptr.write_string(str, len) # with len not nil
|
85
|
+
def write_string_length(str, len)
|
86
|
+
put_bytes(0, str, 0, len)
|
87
|
+
end
|
88
|
+
|
89
|
+
# @param [String] str string to write
|
90
|
+
# @param [Numeric] len length of string to return
|
91
|
+
# @return [self]
|
92
|
+
# Write +str+ in pointer's contents, or first +len+ bytes if
|
93
|
+
# +len+ is not +nil+.
|
94
|
+
def write_string(str, len=nil)
|
95
|
+
len = str.bytesize unless len
|
96
|
+
# Write the string data without NUL termination
|
97
|
+
put_bytes(0, str, 0, len)
|
98
|
+
end
|
99
|
+
|
100
|
+
# @param [Type] type type of data to read from pointer's contents
|
101
|
+
# @param [Symbol] reader method to send to +self+ to read +type+
|
102
|
+
# @param [Numeric] length
|
103
|
+
# @return [Array]
|
104
|
+
# Read an array of +type+ of length +length+.
|
105
|
+
# @example
|
106
|
+
# ptr.read_array_of_type(TYPE_UINT8, :get_uint8, 4) # -> [1, 2, 3, 4]
|
107
|
+
def read_array_of_type(type, reader, length)
|
108
|
+
ary = []
|
109
|
+
size = FFI.type_size(type)
|
110
|
+
tmp = self
|
111
|
+
length.times { |j|
|
112
|
+
ary << tmp.send(reader)
|
113
|
+
tmp += size unless j == length-1 # avoid OOB
|
114
|
+
}
|
115
|
+
ary
|
116
|
+
end
|
117
|
+
|
118
|
+
# @param [Type] type type of data to write to pointer's contents
|
119
|
+
# @param [Symbol] writer method to send to +self+ to write +type+
|
120
|
+
# @param [Array] ary
|
121
|
+
# @return [self]
|
122
|
+
# Write +ary+ in pointer's contents as +type+.
|
123
|
+
# @example
|
124
|
+
# ptr.write_array_of_type(TYPE_UINT8, :put_uint8, [1, 2, 3 ,4])
|
125
|
+
def write_array_of_type(type, writer, ary)
|
126
|
+
size = FFI.type_size(type)
|
127
|
+
tmp = self
|
128
|
+
ary.each_with_index {|i, j|
|
129
|
+
tmp.send(writer, i)
|
130
|
+
tmp += size unless j == ary.length-1 # avoid OOB
|
131
|
+
}
|
132
|
+
self
|
133
|
+
end
|
134
|
+
|
135
|
+
# @return [self]
|
136
|
+
def to_ptr
|
137
|
+
self
|
138
|
+
end
|
139
|
+
|
140
|
+
# @param [Symbol,Type] type of data to read
|
141
|
+
# @return [Object]
|
142
|
+
# Read pointer's contents as +type+
|
143
|
+
#
|
144
|
+
# Same as:
|
145
|
+
# ptr.get(type, 0)
|
146
|
+
def read(type)
|
147
|
+
get(type, 0)
|
148
|
+
end
|
149
|
+
|
150
|
+
# @param [Symbol,Type] type of data to read
|
151
|
+
# @param [Object] value to write
|
152
|
+
# @return [nil]
|
153
|
+
# Write +value+ of type +type+ to pointer's content
|
154
|
+
#
|
155
|
+
# Same as:
|
156
|
+
# ptr.put(type, 0)
|
157
|
+
def write(type, value)
|
158
|
+
put(type, 0, value)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|