ffi 0.5.4-x86-mingw32 → 0.6.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ffi might be problematic. Click here for more details.
- data/History.txt +102 -0
- data/LICENSE +1 -27
- data/Rakefile +4 -12
- data/ext/ffi_c/AbstractMemory.c +6 -8
- data/ext/ffi_c/AbstractMemory.h +23 -21
- data/ext/ffi_c/AutoPointer.c +0 -1
- data/ext/ffi_c/Buffer.c +23 -8
- data/ext/ffi_c/Call.c +31 -3
- data/ext/ffi_c/Call.h +5 -1
- data/ext/ffi_c/DynamicLibrary.c +0 -1
- data/ext/ffi_c/Function.c +22 -4
- data/ext/ffi_c/MemoryPointer.c +2 -3
- data/ext/ffi_c/Pointer.c +23 -9
- data/ext/ffi_c/Struct.c +227 -79
- data/ext/ffi_c/Struct.h +16 -7
- data/ext/ffi_c/StructLayout.c +92 -55
- data/ext/ffi_c/Type.c +5 -22
- data/ext/ffi_c/Type.h +1 -1
- data/ext/ffi_c/Types.c +9 -3
- data/ext/ffi_c/Types.h +2 -0
- data/ext/ffi_c/extconf.rb +11 -7
- data/ext/ffi_c/libffi.gnu.mk +1 -1
- data/ext/ffi_c/libffi.mk +1 -1
- data/ext/ffi_c/libffi/ChangeLog +900 -84
- data/ext/ffi_c/libffi/ChangeLog.libffi +311 -0
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/Makefile.am +14 -4
- data/ext/ffi_c/libffi/Makefile.in +362 -211
- data/ext/ffi_c/libffi/README +70 -92
- data/ext/ffi_c/libffi/aclocal.m4 +6068 -4586
- data/ext/ffi_c/libffi/config.guess +125 -143
- data/ext/ffi_c/libffi/config.sub +103 -27
- data/ext/ffi_c/libffi/configure +11340 -18473
- data/ext/ffi_c/libffi/configure.ac +43 -4
- data/ext/ffi_c/libffi/doc/libffi.info +15 -15
- data/ext/ffi_c/libffi/doc/libffi.texi +1 -1
- data/ext/ffi_c/libffi/doc/stamp-vti +4 -4
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +24 -3
- data/ext/ffi_c/libffi/include/Makefile.am +1 -1
- data/ext/ffi_c/libffi/include/Makefile.in +97 -50
- data/ext/ffi_c/libffi/include/ffi.h.in +8 -2
- data/ext/ffi_c/libffi/include/ffi_common.h +24 -0
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/ltmain.sh +7346 -5870
- data/ext/ffi_c/libffi/m4/libtool.m4 +7360 -0
- data/ext/ffi_c/libffi/m4/ltoptions.m4 +368 -0
- data/ext/ffi_c/libffi/m4/ltsugar.m4 +123 -0
- data/ext/ffi_c/libffi/m4/ltversion.m4 +23 -0
- data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +92 -0
- data/ext/ffi_c/libffi/man/Makefile.in +115 -62
- data/ext/ffi_c/libffi/man/ffi_call.3 +3 -3
- data/ext/ffi_c/libffi/missing +15 -8
- data/ext/ffi_c/libffi/src/arm/sysv.S +15 -8
- data/ext/ffi_c/libffi/src/avr32/ffi.c +421 -0
- data/ext/ffi_c/libffi/src/avr32/ffitarget.h +50 -0
- data/ext/ffi_c/libffi/src/avr32/sysv.S +208 -0
- data/ext/ffi_c/libffi/src/closures.c +47 -10
- data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/java_raw_api.c +0 -3
- data/ext/ffi_c/libffi/src/mips/ffi.c +135 -32
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +37 -4
- data/ext/ffi_c/libffi/src/mips/n32.S +67 -10
- data/ext/ffi_c/libffi/src/mips/o32.S +8 -8
- data/ext/ffi_c/libffi/src/pa/ffi.c +7 -0
- data/ext/ffi_c/libffi/src/powerpc/aix.S +163 -64
- data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +308 -112
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +20 -7
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +208 -80
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +11 -3
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +12 -23
- data/ext/ffi_c/libffi/src/s390/sysv.S +1 -1
- data/ext/ffi_c/libffi/src/sh/sysv.S +9 -9
- data/ext/ffi_c/libffi/src/sh64/ffi.c +37 -22
- data/ext/ffi_c/libffi/src/sh64/sysv.S +23 -14
- data/ext/ffi_c/libffi/src/sparc/ffi.c +21 -6
- data/ext/ffi_c/libffi/src/sparc/v8.S +55 -14
- data/ext/ffi_c/libffi/src/x86/darwin.S +10 -9
- data/ext/ffi_c/libffi/src/x86/ffi.c +293 -86
- data/ext/ffi_c/libffi/src/x86/ffi64.c +73 -19
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +30 -0
- data/ext/ffi_c/libffi/src/x86/sysv.S +21 -4
- data/ext/ffi_c/libffi/src/x86/unix64.S +8 -4
- data/ext/ffi_c/libffi/src/x86/win32.S +633 -147
- data/ext/ffi_c/libffi/src/x86/win64.S +460 -0
- data/ext/ffi_c/libffi/testsuite/Makefile.am +63 -54
- data/ext/ffi_c/libffi/testsuite/Makefile.in +112 -77
- data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +12 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c +7 -14
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_loc_fn0.c +95 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_stdcall.c +6 -14
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +134 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +117 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +11 -17
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_dbls_struct.c +66 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c +4 -13
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +105 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +74 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +140 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +8 -16
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +37 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +25 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +31 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +2 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +342 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/problem1.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large.c +145 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large2.c +148 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium.c +124 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +124 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c +70 -0
- data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +4 -5
- data/ext/ffi_c/libffi/testsuite/libffi.special/unwindtest.cc +17 -16
- data/ext/ffi_c/libffi/texinfo.tex +155 -427
- data/gen/Rakefile +4 -2
- data/lib/1.8/ffi_c.so +0 -0
- data/lib/1.9/ffi_c.so +0 -0
- data/lib/ffi/autopointer.rb +79 -20
- data/lib/ffi/callback.rb +4 -10
- data/lib/ffi/enum.rb +28 -0
- data/lib/ffi/ffi.rb +1 -0
- data/lib/ffi/io.rb +28 -0
- data/lib/ffi/library.rb +237 -182
- data/lib/ffi/memorypointer.rb +28 -62
- data/lib/ffi/platform.rb +27 -0
- data/lib/ffi/pointer.rb +28 -0
- data/lib/ffi/struct.rb +55 -1
- data/lib/ffi/types.rb +29 -0
- data/lib/ffi/variadic.rb +29 -0
- data/spec/ffi/library_spec.rb +31 -5
- data/spec/ffi/rbx/attach_function_spec.rb +2 -1
- data/spec/ffi/rbx/memory_pointer_spec.rb +2 -1
- data/spec/ffi/spec_helper.rb +5 -1
- data/spec/ffi/struct_spec.rb +82 -0
- data/tasks/ann.rake +80 -0
- data/tasks/extension.rake +25 -0
- data/tasks/gem.rake +200 -0
- data/tasks/git.rake +41 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +50 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +300 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- metadata +312 -279
- data/ext/ffi_c/libffi/TODO +0 -1
- data/ext/ffi_c/libffi/ltcf-c.sh +0 -861
- data/ext/ffi_c/libffi/ltcf-cxx.sh +0 -1069
- data/ext/ffi_c/libffi/ltcf-gcj.sh +0 -700
- data/ext/ffi_c/libffi/ltconfig +0 -2862
- data/ext/ffi_c/libffi/mkinstalldirs +0 -158
data/History.txt
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
== 0.5.0 / 2009-10-06
|
2
|
+
|
3
|
+
* Major improvements
|
4
|
+
* New Function class
|
5
|
+
* Structs can be passed and returned by value
|
6
|
+
* Implement a custom trampoline for x86_64, resulting in roughly 30% speedup
|
7
|
+
* Improve dispatch of functions which take (0..6) char/short/int/long/pointer arguments by between 50% and 200% on x86_64
|
8
|
+
* Callbacks are now approximately 100% faster on x86_64
|
9
|
+
* Minor improvements
|
10
|
+
* Add support for MacOSX Snow Leopard
|
11
|
+
* Improve support for Windows releasing fat binaries on rubyforge
|
12
|
+
* Better introspection in structs:
|
13
|
+
* Add StructLayout::Field#type, size, offset, alignment and name
|
14
|
+
methods
|
15
|
+
* Add StructLayout#fields which returns an array of
|
16
|
+
StructLayout::Field objects
|
17
|
+
* Add automagic deducing of library name from module name.
|
18
|
+
Idea and prototype implementation from Matt Hulse
|
19
|
+
* Callback fields in structs can now be both read and written
|
20
|
+
* Add a bunch of new benchmarks
|
21
|
+
* Lots of refactoring
|
22
|
+
* Experimental features
|
23
|
+
* blocking functions (i.e. native code that blocks the thread) support
|
24
|
+
* Bug fixes
|
25
|
+
* Fix RUBY-FFI_43 (rake gem dependency)
|
26
|
+
|
27
|
+
== 0.4.0 / 2009-08-05
|
28
|
+
|
29
|
+
* Major improvements
|
30
|
+
* Add support for boolean types
|
31
|
+
* Add support for methods as callbacks
|
32
|
+
* Add FFI::IO.read as described in JRUBY-3636
|
33
|
+
* Minor improvements
|
34
|
+
* Add Pointer::NULL constant
|
35
|
+
* Add AbstractMemory#get_array_of_string()
|
36
|
+
* Implement Pointer.new(address) and Pointer.new(:type, address)
|
37
|
+
* Bug fixes
|
38
|
+
* Fix RUBY_FFI-38
|
39
|
+
* Fix issues related to 1.9.1 build
|
40
|
+
* Fix issues related to OSX build
|
41
|
+
* Fix issues related to FreeBSD build
|
42
|
+
* Fix issues related to OpenSolaris build
|
43
|
+
|
44
|
+
== 0.3.5 / 2009-05-08
|
45
|
+
|
46
|
+
* Bug fixes
|
47
|
+
* Fix RUBY_FFI-17
|
48
|
+
* Fix RUBY_FFI-21
|
49
|
+
|
50
|
+
== 0.3.4 / 2009-05-01
|
51
|
+
|
52
|
+
* Minor improvements
|
53
|
+
* Add return statements to functions that call rb_raise(), in case
|
54
|
+
rb_raise is not declared noreturn, to avoid gcc warnings.
|
55
|
+
|
56
|
+
== 0.3.3 / 2009-04-27
|
57
|
+
|
58
|
+
* Minor improvements
|
59
|
+
* Implement RUBY_FFI-16 - Add support for anonymous callbacks
|
60
|
+
* Add support for callback parameters in callbacks
|
61
|
+
* Add support for function pointer return values
|
62
|
+
* Callbacks can now coerce proc objects into function pointers for
|
63
|
+
return values.
|
64
|
+
* Implement FFI::Type and FFI::Type::Builtin
|
65
|
+
* Add support for enumerations
|
66
|
+
* Bug fixes
|
67
|
+
* Fix RUBY_FFI-19
|
68
|
+
* Fix RUBY_FFI-15
|
69
|
+
|
70
|
+
== 0.3.2 / 2009-05-01
|
71
|
+
|
72
|
+
* Bug fixes
|
73
|
+
* Fix JRUBY-3527 by passing RTLD_GLOBAL instead of RTLD_LOCAL
|
74
|
+
|
75
|
+
== 0.3.1 / 2009-03-23
|
76
|
+
|
77
|
+
* Bug fixes
|
78
|
+
* Correctly save errno/GetLastError after each call.
|
79
|
+
|
80
|
+
== 0.3.0 / 2009-03-19
|
81
|
+
|
82
|
+
* Switch compilation to rake-compiler
|
83
|
+
* Makes cross-compilation from linux -> win32 super easy
|
84
|
+
* win32 support is available now, but highly experimental
|
85
|
+
* Performance improvements
|
86
|
+
* struct field access approx 3x faster than 0.2.0
|
87
|
+
* function invocation approx 20% faster than 0.2.0
|
88
|
+
* A bunch of minor improvements
|
89
|
+
* Struct instances can now be passed as :pointer parameters without calling
|
90
|
+
Struct#pointer
|
91
|
+
* Support for array struct members
|
92
|
+
* Structs are now padded correctly to the alignment of the struct's
|
93
|
+
largest field
|
94
|
+
* Global library variables
|
95
|
+
* Callbacks in global library variables
|
96
|
+
* Strings passed in as :string arguments are scrubbed to avoid
|
97
|
+
poison-null-byte attacks.
|
98
|
+
* Union support
|
99
|
+
* nil can be passed as a :string argument (passed as NULL)
|
100
|
+
* Structs can now be fields inside another struct
|
101
|
+
* Lots of internal cleanups and refactorings.
|
102
|
+
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2008,
|
1
|
+
Copyright (c) 2008, 2009 Ruby FFI contributors
|
2
2
|
All rights reserved.
|
3
3
|
|
4
4
|
Redistribution and use in source and binary forms, with or without
|
@@ -23,29 +23,3 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
23
23
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
24
24
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
25
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
-
|
27
|
-
Copyright (c) 2007, Evan Phoenix
|
28
|
-
All rights reserved.
|
29
|
-
|
30
|
-
Redistribution and use in source and binary forms, with or without
|
31
|
-
modification, are permitted provided that the following conditions are met:
|
32
|
-
|
33
|
-
* Redistributions of source code must retain the above copyright notice, this
|
34
|
-
list of conditions and the following disclaimer.
|
35
|
-
* Redistributions in binary form must reproduce the above copyright notice
|
36
|
-
this list of conditions and the following disclaimer in the documentation
|
37
|
-
and/or other materials provided with the distribution.
|
38
|
-
* Neither the name of the Evan Phoenix nor the names of its contributors
|
39
|
-
may be used to endorse or promote products derived from this software
|
40
|
-
without specific prior written permission.
|
41
|
-
|
42
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
43
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
44
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
45
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
46
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
47
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
48
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
49
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
50
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
51
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/Rakefile
CHANGED
@@ -12,16 +12,7 @@ require 'date'
|
|
12
12
|
require 'fileutils'
|
13
13
|
require 'rbconfig'
|
14
14
|
|
15
|
-
|
16
|
-
require 'bones'
|
17
|
-
Bones.setup
|
18
|
-
rescue LoadError
|
19
|
-
begin
|
20
|
-
load 'tasks/setup.rb'
|
21
|
-
rescue LoadError
|
22
|
-
raise RuntimeError, '### please install the "bones" gem ###'
|
23
|
-
end
|
24
|
-
end
|
15
|
+
load 'tasks/setup.rb'
|
25
16
|
|
26
17
|
LIBEXT = case Config::CONFIG['host_os'].downcase
|
27
18
|
when /darwin/
|
@@ -84,7 +75,7 @@ PROJ.name = 'ffi'
|
|
84
75
|
PROJ.authors = 'Wayne Meissner'
|
85
76
|
PROJ.email = 'wmeissner@gmail.com'
|
86
77
|
PROJ.url = 'http://wiki.github.com/ffi/ffi'
|
87
|
-
PROJ.version = '0.
|
78
|
+
PROJ.version = '0.6.3'
|
88
79
|
PROJ.rubyforge.name = 'ffi'
|
89
80
|
PROJ.readme_file = 'README.rdoc'
|
90
81
|
|
@@ -97,7 +88,7 @@ PROJ.ann.email[:server] = 'smtp.gmail.com'
|
|
97
88
|
|
98
89
|
# Gem specifications
|
99
90
|
PROJ.gem.need_tar = false
|
100
|
-
PROJ.gem.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{ext,gen,lib,spec}/**/*")
|
91
|
+
PROJ.gem.files = %w(History.txt LICENSE README.rdoc Rakefile) + Dir.glob("{ext,gen,lib,spec,tasks}/**/*")
|
101
92
|
PROJ.gem.platform = Gem::Platform::RUBY
|
102
93
|
|
103
94
|
# Override Mr. Bones autogenerated extensions and force ours in
|
@@ -156,6 +147,7 @@ task :distclean => :clobber do
|
|
156
147
|
FileUtils.rm_rf(Dir["lib/**/ffi_c.#{Config::CONFIG['DLEXT']}"])
|
157
148
|
FileUtils.rm_rf('lib/1.8')
|
158
149
|
FileUtils.rm_rf('lib/1.9')
|
150
|
+
FileUtils.rm_rf('lib/ffi/types.conf')
|
159
151
|
FileUtils.rm_rf('conftest.dSYM')
|
160
152
|
FileUtils.rm_rf('pkg')
|
161
153
|
end
|
data/ext/ffi_c/AbstractMemory.c
CHANGED
@@ -49,7 +49,6 @@ memory_allocate(VALUE klass)
|
|
49
49
|
AbstractMemory* memory;
|
50
50
|
VALUE obj;
|
51
51
|
obj = Data_Make_Struct(klass, AbstractMemory, NULL, -1, memory);
|
52
|
-
memory->ops = &rbffi_AbstractMemoryOps;
|
53
52
|
memory->access = MEM_RD | MEM_WR;
|
54
53
|
|
55
54
|
return obj;
|
@@ -137,6 +136,8 @@ NUM_OP(int32, int32_t, NUM2INT, INT2NUM);
|
|
137
136
|
NUM_OP(uint32, uint32_t, NUM2UINT, UINT2NUM);
|
138
137
|
NUM_OP(int64, int64_t, NUM2LL, LL2NUM);
|
139
138
|
NUM_OP(uint64, uint64_t, NUM2ULL, ULL2NUM);
|
139
|
+
NUM_OP(long, long, NUM2LONG, LONG2NUM);
|
140
|
+
NUM_OP(ulong, unsigned long, NUM2ULONG, ULONG2NUM);
|
140
141
|
NUM_OP(float32, float, NUM2DBL, rb_float_new);
|
141
142
|
NUM_OP(float64, double, NUM2DBL, rb_float_new);
|
142
143
|
|
@@ -227,7 +228,7 @@ memory_get_array_of_string(int argc, VALUE* argv, VALUE self)
|
|
227
228
|
|
228
229
|
} else {
|
229
230
|
checkBounds(ptr, off, sizeof (char*));
|
230
|
-
for ( ; off < ptr->size - sizeof (void *); off += sizeof (void *)) {
|
231
|
+
for ( ; off < ptr->size - (long) sizeof (void *); off += (long) sizeof (void *)) {
|
231
232
|
const char* strptr = *(const char**) (ptr->address + off);
|
232
233
|
if (strptr == NULL) {
|
233
234
|
break;
|
@@ -400,6 +401,8 @@ MemoryOps rbffi_AbstractMemoryOps = {
|
|
400
401
|
.uint32 = &memory_op_uint32,
|
401
402
|
.int64 = &memory_op_int64,
|
402
403
|
.uint64 = &memory_op_uint64,
|
404
|
+
.slong = &memory_op_long,
|
405
|
+
.ulong = &memory_op_ulong,
|
403
406
|
.float32 = &memory_op_float32,
|
404
407
|
.float64 = &memory_op_float64,
|
405
408
|
.pointer = &memory_op_pointer,
|
@@ -433,6 +436,7 @@ rbffi_AbstractMemory_Init(VALUE moduleFFI)
|
|
433
436
|
INT(int16);
|
434
437
|
INT(int32);
|
435
438
|
INT(int64);
|
439
|
+
INT(long);
|
436
440
|
|
437
441
|
#define ALIAS(name, old) \
|
438
442
|
rb_define_alias(classMemory, "put_" #name, "put_" #old); \
|
@@ -449,12 +453,6 @@ rbffi_AbstractMemory_Init(VALUE moduleFFI)
|
|
449
453
|
ALIAS(int, int32);
|
450
454
|
ALIAS(long_long, int64);
|
451
455
|
|
452
|
-
if (sizeof(long) == 4) {
|
453
|
-
ALIAS(long, int32);
|
454
|
-
} else {
|
455
|
-
ALIAS(long, int64);
|
456
|
-
}
|
457
|
-
|
458
456
|
rb_define_method(classMemory, "put_float32", memory_put_float32, 2);
|
459
457
|
rb_define_method(classMemory, "get_float32", memory_get_float32, 1);
|
460
458
|
rb_define_alias(classMemory, "put_float", "put_float32");
|
data/ext/ffi_c/AbstractMemory.h
CHANGED
@@ -61,6 +61,8 @@ typedef struct {
|
|
61
61
|
MemoryOp* uint32;
|
62
62
|
MemoryOp* int64;
|
63
63
|
MemoryOp* uint64;
|
64
|
+
MemoryOp* slong;
|
65
|
+
MemoryOp* ulong;
|
64
66
|
MemoryOp* float32;
|
65
67
|
MemoryOp* float64;
|
66
68
|
MemoryOp* pointer;
|
@@ -72,9 +74,12 @@ struct AbstractMemory_ {
|
|
72
74
|
long size;
|
73
75
|
int access;
|
74
76
|
int typeSize;
|
75
|
-
MemoryOps* ops;
|
76
77
|
};
|
77
78
|
|
79
|
+
|
80
|
+
extern VALUE rbffi_AbstractMemoryClass;
|
81
|
+
extern MemoryOps rbffi_AbstractMemoryOps;
|
82
|
+
|
78
83
|
extern void rbffi_AbstractMemory_Init(VALUE ffiModule);
|
79
84
|
|
80
85
|
extern AbstractMemory* rbffi_AbstractMemory_Cast(VALUE obj, VALUE klass);
|
@@ -107,36 +112,37 @@ checkWrite(AbstractMemory* mem)
|
|
107
112
|
}
|
108
113
|
|
109
114
|
static inline MemoryOp*
|
110
|
-
|
115
|
+
get_memory_op(Type* type)
|
111
116
|
{
|
112
|
-
if (ptr == NULL || ptr->ops == NULL || type == NULL) {
|
113
|
-
return NULL;
|
114
|
-
}
|
115
117
|
switch (type->nativeType) {
|
116
118
|
case NATIVE_INT8:
|
117
|
-
return
|
119
|
+
return rbffi_AbstractMemoryOps.int8;
|
118
120
|
case NATIVE_UINT8:
|
119
|
-
return
|
121
|
+
return rbffi_AbstractMemoryOps.uint8;
|
120
122
|
case NATIVE_INT16:
|
121
|
-
return
|
123
|
+
return rbffi_AbstractMemoryOps.int16;
|
122
124
|
case NATIVE_UINT16:
|
123
|
-
return
|
125
|
+
return rbffi_AbstractMemoryOps.uint16;
|
124
126
|
case NATIVE_INT32:
|
125
|
-
return
|
127
|
+
return rbffi_AbstractMemoryOps.int32;
|
126
128
|
case NATIVE_UINT32:
|
127
|
-
return
|
129
|
+
return rbffi_AbstractMemoryOps.uint32;
|
128
130
|
case NATIVE_INT64:
|
129
|
-
return
|
131
|
+
return rbffi_AbstractMemoryOps.int64;
|
130
132
|
case NATIVE_UINT64:
|
131
|
-
return
|
133
|
+
return rbffi_AbstractMemoryOps.uint64;
|
134
|
+
case NATIVE_LONG:
|
135
|
+
return rbffi_AbstractMemoryOps.slong;
|
136
|
+
case NATIVE_ULONG:
|
137
|
+
return rbffi_AbstractMemoryOps.ulong;
|
132
138
|
case NATIVE_FLOAT32:
|
133
|
-
return
|
139
|
+
return rbffi_AbstractMemoryOps.float32;
|
134
140
|
case NATIVE_FLOAT64:
|
135
|
-
return
|
141
|
+
return rbffi_AbstractMemoryOps.float64;
|
136
142
|
case NATIVE_POINTER:
|
137
|
-
return
|
143
|
+
return rbffi_AbstractMemoryOps.pointer;
|
138
144
|
case NATIVE_STRING:
|
139
|
-
return
|
145
|
+
return rbffi_AbstractMemoryOps.strptr;
|
140
146
|
default:
|
141
147
|
return NULL;
|
142
148
|
}
|
@@ -148,10 +154,6 @@ memory_get_op(AbstractMemory* ptr, Type* type)
|
|
148
154
|
|
149
155
|
|
150
156
|
|
151
|
-
extern VALUE rbffi_AbstractMemoryClass;
|
152
|
-
extern MemoryOps rbffi_AbstractMemoryOps;
|
153
|
-
|
154
|
-
|
155
157
|
#ifdef __cplusplus
|
156
158
|
}
|
157
159
|
#endif
|
data/ext/ffi_c/AutoPointer.c
CHANGED
data/ext/ffi_c/Buffer.c
CHANGED
@@ -54,7 +54,6 @@ buffer_allocate(VALUE klass)
|
|
54
54
|
|
55
55
|
obj = Data_Make_Struct(klass, Buffer, NULL, buffer_release, buffer);
|
56
56
|
buffer->rbParent = Qnil;
|
57
|
-
buffer->memory.ops = &rbffi_AbstractMemoryOps;
|
58
57
|
buffer->memory.access = MEM_RD | MEM_WR;
|
59
58
|
|
60
59
|
return obj;
|
@@ -111,20 +110,18 @@ buffer_alloc_inout(int argc, VALUE* argv, VALUE klass)
|
|
111
110
|
}
|
112
111
|
|
113
112
|
static VALUE
|
114
|
-
|
113
|
+
slice(VALUE self, long offset, long len)
|
115
114
|
{
|
116
115
|
Buffer* ptr;
|
117
116
|
Buffer* result;
|
118
117
|
VALUE obj = Qnil;
|
119
|
-
|
120
|
-
|
118
|
+
|
121
119
|
Data_Get_Struct(self, Buffer, ptr);
|
122
|
-
checkBounds(&ptr->memory, offset,
|
120
|
+
checkBounds(&ptr->memory, offset, len);
|
123
121
|
|
124
122
|
obj = Data_Make_Struct(BufferClass, Buffer, buffer_mark, -1, result);
|
125
123
|
result->memory.address = ptr->memory.address + offset;
|
126
|
-
result->memory.size =
|
127
|
-
result->memory.ops = ptr->memory.ops;
|
124
|
+
result->memory.size = len;
|
128
125
|
result->memory.access = ptr->memory.access;
|
129
126
|
result->memory.typeSize = ptr->memory.typeSize;
|
130
127
|
result->rbParent = self;
|
@@ -132,6 +129,23 @@ buffer_plus(VALUE self, VALUE rbOffset)
|
|
132
129
|
return obj;
|
133
130
|
}
|
134
131
|
|
132
|
+
static VALUE
|
133
|
+
buffer_plus(VALUE self, VALUE rbOffset)
|
134
|
+
{
|
135
|
+
Buffer* ptr;
|
136
|
+
long offset = NUM2LONG(rbOffset);
|
137
|
+
|
138
|
+
Data_Get_Struct(self, Buffer, ptr);
|
139
|
+
|
140
|
+
return slice(self, offset, ptr->memory.size - offset);
|
141
|
+
}
|
142
|
+
|
143
|
+
static VALUE
|
144
|
+
buffer_slice(VALUE self, VALUE rbOffset, VALUE rbLength)
|
145
|
+
{
|
146
|
+
return slice(self, NUM2LONG(rbOffset), NUM2LONG(rbLength));
|
147
|
+
}
|
148
|
+
|
135
149
|
static VALUE
|
136
150
|
buffer_inspect(VALUE self)
|
137
151
|
{
|
@@ -153,7 +167,7 @@ buffer_free(VALUE self)
|
|
153
167
|
|
154
168
|
Data_Get_Struct(self, Buffer, ptr);
|
155
169
|
if (ptr->storage != NULL) {
|
156
|
-
|
170
|
+
xfree(ptr->storage);
|
157
171
|
ptr->storage = NULL;
|
158
172
|
}
|
159
173
|
|
@@ -185,4 +199,5 @@ rbffi_Buffer_Init(VALUE moduleFFI)
|
|
185
199
|
rb_define_method(BufferClass, "inspect", buffer_inspect, 0);
|
186
200
|
rb_define_alias(BufferClass, "length", "total");
|
187
201
|
rb_define_method(BufferClass, "+", buffer_plus, 1);
|
202
|
+
rb_define_method(BufferClass, "slice", buffer_slice, 2);
|
188
203
|
}
|
data/ext/ffi_c/Call.c
CHANGED
@@ -60,6 +60,7 @@
|
|
60
60
|
#define INT16_ADJ (4)
|
61
61
|
#define INT32_ADJ (4)
|
62
62
|
#define INT64_ADJ (8)
|
63
|
+
#define LONG_ADJ (sizeof(long))
|
63
64
|
#define FLOAT32_ADJ (4)
|
64
65
|
#define FLOAT64_ADJ (8)
|
65
66
|
#define ADDRESS_ADJ (sizeof(void *))
|
@@ -141,10 +142,10 @@ rbffi_SetupCallParams(int argc, VALUE* argv, int paramCount, NativeType* paramTy
|
|
141
142
|
|
142
143
|
case NATIVE_BOOL:
|
143
144
|
if (type != T_TRUE && type != T_FALSE) {
|
144
|
-
rb_raise(rb_eTypeError, "
|
145
|
+
rb_raise(rb_eTypeError, "wrong argument type (expected a boolean parameter)");
|
145
146
|
}
|
146
|
-
param->
|
147
|
-
ADJ(param,
|
147
|
+
param->s8 = argv[argidx++] == Qtrue;
|
148
|
+
ADJ(param, INT8);
|
148
149
|
break;
|
149
150
|
|
150
151
|
|
@@ -186,6 +187,17 @@ rbffi_SetupCallParams(int argc, VALUE* argv, int paramCount, NativeType* paramTy
|
|
186
187
|
++argidx;
|
187
188
|
break;
|
188
189
|
|
190
|
+
case NATIVE_LONG:
|
191
|
+
*(ffi_sarg *) param = NUM2LONG(argv[argidx]);
|
192
|
+
ADJ(param, LONG);
|
193
|
+
++argidx;
|
194
|
+
break;
|
195
|
+
|
196
|
+
case NATIVE_ULONG:
|
197
|
+
*(ffi_arg *) param = NUM2ULONG(argv[argidx]);
|
198
|
+
ADJ(param, LONG);
|
199
|
+
++argidx;
|
200
|
+
break;
|
189
201
|
|
190
202
|
case NATIVE_FLOAT32:
|
191
203
|
if (type != T_FLOAT && type != T_FIXNUM) {
|
@@ -431,6 +443,8 @@ rbffi_GetInvoker(FunctionType *fnInfo)
|
|
431
443
|
case NATIVE_UINT16:
|
432
444
|
case NATIVE_INT32:
|
433
445
|
case NATIVE_UINT32:
|
446
|
+
case NATIVE_LONG:
|
447
|
+
case NATIVE_ULONG:
|
434
448
|
#ifdef __x86_64__
|
435
449
|
case NATIVE_INT64:
|
436
450
|
case NATIVE_UINT64:
|
@@ -452,6 +466,8 @@ rbffi_GetInvoker(FunctionType *fnInfo)
|
|
452
466
|
case NATIVE_UINT16:
|
453
467
|
case NATIVE_INT32:
|
454
468
|
case NATIVE_UINT32:
|
469
|
+
case NATIVE_LONG:
|
470
|
+
case NATIVE_ULONG:
|
455
471
|
#ifdef __x86_64__
|
456
472
|
case NATIVE_INT64:
|
457
473
|
case NATIVE_UINT64:
|
@@ -536,6 +552,12 @@ rbffi_GetLongValue(int idx, VALUE* argv, FunctionType* fnInfo)
|
|
536
552
|
/* Special handling/checking for unsigned 32 bit integers */
|
537
553
|
return getUnsignedInt32(value, type);
|
538
554
|
|
555
|
+
case NATIVE_LONG:
|
556
|
+
return NUM2LONG(value);
|
557
|
+
|
558
|
+
case NATIVE_ULONG:
|
559
|
+
return NUM2ULONG(value);
|
560
|
+
|
539
561
|
#ifdef __x86_64__
|
540
562
|
case NATIVE_INT64:
|
541
563
|
if (type != T_FIXNUM && type != T_BIGNUM) {
|
@@ -609,6 +631,9 @@ returnL(FunctionType* fnInfo, L* result)
|
|
609
631
|
case NATIVE_INT32:
|
610
632
|
return INT2NUM(*(signed int *) result);
|
611
633
|
|
634
|
+
case NATIVE_LONG:
|
635
|
+
return LONG2NUM(*(signed long *) result);
|
636
|
+
|
612
637
|
case NATIVE_UINT8:
|
613
638
|
return UINT2NUM(*(unsigned char *) result);
|
614
639
|
|
@@ -618,6 +643,9 @@ returnL(FunctionType* fnInfo, L* result)
|
|
618
643
|
case NATIVE_UINT32:
|
619
644
|
return UINT2NUM(*(unsigned int *) result);
|
620
645
|
|
646
|
+
case NATIVE_ULONG:
|
647
|
+
return ULONG2NUM(*(unsigned long *) result);
|
648
|
+
|
621
649
|
#ifdef __x86_64__
|
622
650
|
case NATIVE_INT64:
|
623
651
|
return LL2NUM(*(signed long long *) result);
|