ffi 1.9.25 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +212 -0
- data/Gemfile +3 -4
- data/README.md +38 -18
- data/Rakefile +55 -146
- data/ext/ffi_c/AbstractMemory.c +29 -34
- data/ext/ffi_c/Buffer.c +4 -9
- data/ext/ffi_c/Call.c +16 -49
- data/ext/ffi_c/Call.h +4 -7
- data/ext/ffi_c/ClosurePool.c +75 -25
- data/ext/ffi_c/ClosurePool.h +3 -1
- data/ext/ffi_c/DynamicLibrary.c +2 -7
- data/ext/ffi_c/Function.c +47 -131
- data/ext/ffi_c/Function.h +0 -4
- data/ext/ffi_c/FunctionInfo.c +3 -8
- data/ext/ffi_c/LastError.c +49 -8
- data/ext/ffi_c/LongDouble.c +12 -10
- data/ext/ffi_c/LongDouble.h +0 -4
- data/ext/ffi_c/MemoryPointer.c +3 -8
- data/ext/ffi_c/MemoryPointer.h +0 -4
- data/ext/ffi_c/MethodHandle.c +21 -31
- data/ext/ffi_c/MethodHandle.h +3 -2
- data/ext/ffi_c/Platform.c +3 -54
- data/ext/ffi_c/Pointer.c +25 -26
- data/ext/ffi_c/Pointer.h +0 -4
- data/ext/ffi_c/Struct.c +49 -56
- data/ext/ffi_c/Struct.h +12 -6
- data/ext/ffi_c/StructByValue.c +2 -7
- data/ext/ffi_c/StructLayout.c +22 -20
- data/ext/ffi_c/Thread.c +4 -228
- data/ext/ffi_c/Thread.h +1 -20
- data/ext/ffi_c/Type.c +1 -19
- data/ext/ffi_c/Type.h +0 -1
- data/ext/ffi_c/Types.c +7 -8
- data/ext/ffi_c/Types.h +3 -4
- data/ext/ffi_c/Variadic.c +23 -24
- data/ext/ffi_c/compat.h +4 -0
- data/ext/ffi_c/extconf.rb +53 -30
- data/ext/ffi_c/ffi.c +3 -8
- data/ext/ffi_c/libffi.darwin.mk +1 -1
- data/ext/ffi_c/libffi/.appveyor.yml +29 -13
- data/ext/ffi_c/libffi/.gitattributes +4 -0
- data/ext/ffi_c/libffi/.travis.yml +51 -2
- data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
- data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
- data/ext/ffi_c/libffi/.travis/build.sh +116 -8
- data/ext/ffi_c/libffi/.travis/install.sh +65 -16
- data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
- data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/site.exp +10 -1
- data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
- data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +5 -4
- data/ext/ffi_c/libffi/Makefile.am +56 -72
- data/ext/ffi_c/libffi/README.md +33 -8
- data/ext/ffi_c/libffi/config.guess +552 -331
- data/ext/ffi_c/libffi/config.sub +1321 -1306
- data/ext/ffi_c/libffi/configure.ac +37 -12
- data/ext/ffi_c/libffi/configure.host +56 -27
- data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
- data/ext/ffi_c/libffi/doc/libffi.texi +997 -0
- data/ext/ffi_c/libffi/doc/version.texi +4 -0
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +2 -4
- data/ext/ffi_c/libffi/include/ffi.h.in +19 -7
- data/ext/ffi_c/libffi/include/ffi_common.h +5 -1
- data/ext/ffi_c/libffi/libffi.map.in +8 -12
- data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/m4/asmcfi.m4 +1 -1
- data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
- data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
- data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
- data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
- data/ext/ffi_c/libffi/make_sunver.pl +333 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
- data/ext/ffi_c/libffi/msvcc.sh +38 -13
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +153 -69
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +19 -3
- data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +22 -9
- data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
- data/ext/ffi_c/libffi/src/arm/ffi.c +62 -5
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
- data/ext/ffi_c/libffi/src/arm/sysv.S +6 -4
- data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
- data/ext/ffi_c/libffi/src/closures.c +69 -14
- data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
- data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
- data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
- data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
- data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
- data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
- data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
- data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
- data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
- data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
- data/ext/ffi_c/libffi/src/moxie/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
- data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
- data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +211 -32
- data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +91 -28
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +81 -5
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
- data/ext/ffi_c/libffi/src/prep_cif.c +4 -2
- data/ext/ffi_c/libffi/src/riscv/ffi.c +42 -6
- data/ext/ffi_c/libffi/src/riscv/ffitarget.h +1 -0
- data/ext/ffi_c/libffi/src/riscv/sysv.S +86 -7
- data/ext/ffi_c/libffi/src/x86/ffi.c +29 -12
- data/ext/ffi_c/libffi/src/x86/ffi64.c +22 -11
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +20 -10
- data/ext/ffi_c/libffi/src/x86/sysv.S +105 -10
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
- data/ext/ffi_c/libffi/src/x86/unix64.S +100 -4
- data/ext/ffi_c/libffi/src/x86/win64.S +12 -3
- data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
- data/ext/ffi_c/libffi/testsuite/Makefile.am +114 -109
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +32 -8
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +3 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
- data/ext/ffi_c/rbffi.h +0 -2
- data/ffi.gemspec +13 -6
- data/lib/ffi.rb +10 -2
- data/lib/ffi/abstract_memory.rb +44 -0
- data/lib/ffi/autopointer.rb +1 -1
- data/lib/ffi/data_converter.rb +67 -0
- data/lib/ffi/ffi.rb +3 -0
- data/lib/ffi/io.rb +3 -3
- data/lib/ffi/library.rb +12 -8
- data/lib/ffi/managedstruct.rb +2 -2
- data/lib/ffi/platform.rb +34 -10
- data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
- data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
- data/lib/ffi/platform/aarch64-freebsd12/types.conf +128 -0
- data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
- data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
- data/lib/ffi/platform/arm-freebsd/types.conf +152 -0
- data/lib/ffi/platform/arm-freebsd12/types.conf +152 -0
- data/lib/ffi/platform/arm-linux/types.conf +110 -82
- data/lib/ffi/platform/i386-cygwin/types.conf +1 -1
- data/lib/ffi/platform/i386-darwin/types.conf +63 -63
- data/lib/ffi/platform/i386-freebsd/types.conf +89 -89
- data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
- data/lib/ffi/platform/i386-gnu/types.conf +84 -84
- data/lib/ffi/platform/i386-linux/types.conf +77 -77
- data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
- data/lib/ffi/platform/i386-openbsd/types.conf +89 -89
- data/lib/ffi/platform/i386-solaris/types.conf +96 -96
- data/lib/ffi/platform/i386-windows/types.conf +43 -96
- data/lib/ffi/platform/ia64-linux/types.conf +79 -79
- data/lib/ffi/platform/mips-linux/types.conf +79 -79
- data/lib/ffi/platform/mips64-linux/types.conf +81 -81
- data/lib/ffi/platform/mips64el-linux/types.conf +81 -81
- data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
- data/lib/ffi/platform/mipsisa32r6-linux/types.conf +79 -79
- data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +79 -79
- data/lib/ffi/platform/mipsisa64r6-linux/types.conf +81 -81
- data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +81 -81
- data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
- data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
- data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
- data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
- data/lib/ffi/platform/powerpc64-linux/types.conf +81 -81
- data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
- data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
- data/lib/ffi/platform/s390-linux/types.conf +79 -79
- data/lib/ffi/platform/s390x-linux/types.conf +79 -79
- data/lib/ffi/platform/sparc-linux/types.conf +79 -79
- data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
- data/lib/ffi/platform/sparc64-linux/types.conf +79 -79
- data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
- data/lib/ffi/platform/x86_64-cygwin/types.conf +1 -1
- data/lib/ffi/platform/x86_64-darwin/types.conf +88 -84
- data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
- data/lib/ffi/platform/x86_64-freebsd/types.conf +90 -90
- data/lib/ffi/platform/x86_64-freebsd12/types.conf +158 -0
- data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
- data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
- data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -89
- data/lib/ffi/platform/x86_64-openbsd/types.conf +86 -86
- data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
- data/lib/ffi/platform/x86_64-windows/types.conf +42 -110
- data/lib/ffi/pointer.rb +26 -20
- data/lib/ffi/struct.rb +13 -68
- data/lib/ffi/struct_by_reference.rb +72 -0
- data/lib/ffi/struct_layout.rb +96 -0
- data/lib/ffi/tools/const_generator.rb +5 -4
- data/lib/ffi/tools/generator.rb +47 -2
- data/lib/ffi/tools/generator_task.rb +13 -17
- data/lib/ffi/tools/struct_generator.rb +4 -4
- data/lib/ffi/tools/types_generator.rb +7 -4
- data/lib/ffi/types.rb +1 -1
- data/lib/ffi/variadic.rb +1 -10
- data/lib/ffi/version.rb +1 -1
- data/rakelib/ffi_gem_helper.rb +65 -0
- data/samples/getlogin.rb +1 -1
- data/samples/getpid.rb +1 -1
- data/samples/gettimeofday.rb +8 -8
- data/samples/hello.rb +2 -1
- data/samples/inotify.rb +1 -1
- data/samples/pty.rb +1 -2
- data/samples/qsort.rb +0 -1
- metadata +160 -122
- data/.gitignore +0 -22
- data/.gitmodules +0 -3
- data/.travis.yml +0 -52
- data/.yardopts +0 -5
- data/appveyor.yml +0 -22
- data/ext/ffi_c/DataConverter.c +0 -91
- data/ext/ffi_c/StructByReference.c +0 -190
- data/ext/ffi_c/StructByReference.h +0 -50
- data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
- data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
- data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
- data/ext/ffi_c/win32/stdbool.h +0 -8
- data/ext/ffi_c/win32/stdint.h +0 -201
- data/samples/sample_helper.rb +0 -6
data/ext/ffi_c/Thread.c
CHANGED
@@ -28,12 +28,7 @@
|
|
28
28
|
*/
|
29
29
|
|
30
30
|
#include <stddef.h>
|
31
|
-
#ifndef _MSC_VER
|
32
31
|
#include <stdbool.h>
|
33
|
-
#else
|
34
|
-
# include "win32/stdbool.h"
|
35
|
-
# include "win32/stdint.h"
|
36
|
-
#endif
|
37
32
|
|
38
33
|
#if defined(__CYGWIN__) || !defined(_WIN32)
|
39
34
|
# include <pthread.h>
|
@@ -70,13 +65,12 @@ rbffi_frame_current(void)
|
|
70
65
|
#endif
|
71
66
|
}
|
72
67
|
|
73
|
-
void
|
68
|
+
void
|
74
69
|
rbffi_frame_push(rbffi_frame_t* frame)
|
75
70
|
{
|
76
71
|
memset(frame, 0, sizeof(*frame));
|
77
|
-
frame->has_gvl = true;
|
78
72
|
frame->exc = Qnil;
|
79
|
-
|
73
|
+
|
80
74
|
#ifdef _WIN32
|
81
75
|
frame->prev = TlsGetValue(frame_thread_key);
|
82
76
|
TlsSetValue(frame_thread_key, frame);
|
@@ -87,7 +81,7 @@ rbffi_frame_push(rbffi_frame_t* frame)
|
|
87
81
|
#endif
|
88
82
|
}
|
89
83
|
|
90
|
-
void
|
84
|
+
void
|
91
85
|
rbffi_frame_pop(rbffi_frame_t* frame)
|
92
86
|
{
|
93
87
|
#ifdef _WIN32
|
@@ -97,224 +91,6 @@ rbffi_frame_pop(rbffi_frame_t* frame)
|
|
97
91
|
#endif
|
98
92
|
}
|
99
93
|
|
100
|
-
#if !(defined(HAVE_RB_THREAD_BLOCKING_REGION) || defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL))
|
101
|
-
|
102
|
-
#if !defined(_WIN32)
|
103
|
-
|
104
|
-
struct BlockingThread {
|
105
|
-
pthread_t tid;
|
106
|
-
VALUE (*fn)(void *);
|
107
|
-
void *data;
|
108
|
-
void (*ubf)(void *);
|
109
|
-
void *data2;
|
110
|
-
VALUE retval;
|
111
|
-
int wrfd;
|
112
|
-
int rdfd;
|
113
|
-
};
|
114
|
-
|
115
|
-
static void*
|
116
|
-
rbffi_blocking_thread(void* args)
|
117
|
-
{
|
118
|
-
struct BlockingThread* thr = (struct BlockingThread *) args;
|
119
|
-
char c = 1;
|
120
|
-
VALUE retval;
|
121
|
-
|
122
|
-
retval = (*thr->fn)(thr->data);
|
123
|
-
|
124
|
-
pthread_testcancel();
|
125
|
-
|
126
|
-
thr->retval = retval;
|
127
|
-
|
128
|
-
write(thr->wrfd, &c, sizeof(c));
|
129
|
-
|
130
|
-
return NULL;
|
131
|
-
}
|
132
|
-
|
133
|
-
static VALUE
|
134
|
-
wait_for_thread(void *data)
|
135
|
-
{
|
136
|
-
struct BlockingThread* thr = (struct BlockingThread *) data;
|
137
|
-
char c;
|
138
|
-
|
139
|
-
if (read(thr->rdfd, &c, 1) < 1) {
|
140
|
-
rb_thread_wait_fd(thr->rdfd);
|
141
|
-
while (read(thr->rdfd, &c, 1) < 1 && rb_io_wait_readable(thr->rdfd) == Qtrue) {
|
142
|
-
;
|
143
|
-
}
|
144
|
-
}
|
145
|
-
|
146
|
-
return Qnil;
|
147
|
-
}
|
148
|
-
|
149
|
-
static VALUE
|
150
|
-
cleanup_blocking_thread(void *data, VALUE exc)
|
151
|
-
{
|
152
|
-
struct BlockingThread* thr = (struct BlockingThread *) data;
|
153
|
-
|
154
|
-
if (thr->ubf != (void (*)(void *)) -1) {
|
155
|
-
(*thr->ubf)(thr->data2);
|
156
|
-
} else {
|
157
|
-
pthread_kill(thr->tid, SIGVTALRM);
|
158
|
-
}
|
159
|
-
|
160
|
-
return exc;
|
161
|
-
}
|
162
|
-
|
163
|
-
VALUE
|
164
|
-
rbffi_thread_blocking_region(VALUE (*func)(void *), void *data1, void (*ubf)(void *), void *data2)
|
165
|
-
{
|
166
|
-
struct BlockingThread* thr;
|
167
|
-
int fd[2];
|
168
|
-
VALUE exc;
|
169
|
-
|
170
|
-
if (pipe(fd) < 0) {
|
171
|
-
rb_raise(rb_eSystemCallError, "pipe(2) failed");
|
172
|
-
return Qnil;
|
173
|
-
}
|
174
|
-
fcntl(fd[0], F_SETFL, fcntl(fd[0], F_GETFL) | O_NONBLOCK);
|
175
|
-
|
176
|
-
thr = ALLOC_N(struct BlockingThread, 1);
|
177
|
-
thr->rdfd = fd[0];
|
178
|
-
thr->wrfd = fd[1];
|
179
|
-
thr->fn = func;
|
180
|
-
thr->data = data1;
|
181
|
-
thr->ubf = ubf;
|
182
|
-
thr->data2 = data2;
|
183
|
-
thr->retval = Qnil;
|
184
|
-
|
185
|
-
if (pthread_create(&thr->tid, NULL, rbffi_blocking_thread, thr) != 0) {
|
186
|
-
close(fd[0]);
|
187
|
-
close(fd[1]);
|
188
|
-
xfree(thr);
|
189
|
-
rb_raise(rb_eSystemCallError, "pipe(2) failed");
|
190
|
-
return Qnil;
|
191
|
-
}
|
192
|
-
|
193
|
-
exc = rb_rescue2(wait_for_thread, (VALUE) thr, cleanup_blocking_thread, (VALUE) thr,
|
194
|
-
rb_eException);
|
195
|
-
|
196
|
-
pthread_join(thr->tid, NULL);
|
197
|
-
close(fd[1]);
|
198
|
-
close(fd[0]);
|
199
|
-
xfree(thr);
|
200
|
-
|
201
|
-
if (exc != Qnil) {
|
202
|
-
rb_exc_raise(exc);
|
203
|
-
}
|
204
|
-
|
205
|
-
return thr->retval;
|
206
|
-
}
|
207
|
-
|
208
|
-
#else
|
209
|
-
/* win32 implementation */
|
210
|
-
|
211
|
-
struct BlockingThread {
|
212
|
-
HANDLE tid;
|
213
|
-
VALUE (*fn)(void *);
|
214
|
-
void *data;
|
215
|
-
void (*ubf)(void *);
|
216
|
-
void *data2;
|
217
|
-
VALUE retval;
|
218
|
-
int wrfd;
|
219
|
-
int rdfd;
|
220
|
-
};
|
221
|
-
|
222
|
-
static DWORD __stdcall
|
223
|
-
rbffi_blocking_thread(LPVOID args)
|
224
|
-
{
|
225
|
-
struct BlockingThread* thr = (struct BlockingThread *) args;
|
226
|
-
char c = 1;
|
227
|
-
VALUE retval;
|
228
|
-
|
229
|
-
retval = (*thr->fn)(thr->data);
|
230
|
-
thr->retval = retval;
|
231
|
-
|
232
|
-
write(thr->wrfd, &c, sizeof(c));
|
233
|
-
|
234
|
-
return 0;
|
235
|
-
}
|
236
|
-
|
237
|
-
static VALUE
|
238
|
-
wait_for_thread(void *data)
|
239
|
-
{
|
240
|
-
struct BlockingThread* thr = (struct BlockingThread *) data;
|
241
|
-
char c, res;
|
242
|
-
fd_set rfds;
|
243
|
-
|
244
|
-
FD_ZERO(&rfds);
|
245
|
-
FD_SET(thr->rdfd, &rfds);
|
246
|
-
rb_thread_select(thr->rdfd + 1, &rfds, NULL, NULL, NULL);
|
247
|
-
read(thr->rdfd, &c, 1);
|
248
|
-
return Qnil;
|
249
|
-
}
|
250
|
-
|
251
|
-
static VALUE
|
252
|
-
cleanup_blocking_thread(void *data, VALUE exc)
|
253
|
-
{
|
254
|
-
struct BlockingThread* thr = (struct BlockingThread *) data;
|
255
|
-
|
256
|
-
if (thr->ubf != (void (*)(void *)) -1) {
|
257
|
-
(*thr->ubf)(thr->data2);
|
258
|
-
} else {
|
259
|
-
TerminateThread(thr->tid, 0);
|
260
|
-
}
|
261
|
-
|
262
|
-
return exc;
|
263
|
-
}
|
264
|
-
|
265
|
-
VALUE
|
266
|
-
rbffi_thread_blocking_region(VALUE (*func)(void *), void *data1, void (*ubf)(void *), void *data2)
|
267
|
-
{
|
268
|
-
struct BlockingThread* thr;
|
269
|
-
int fd[2];
|
270
|
-
VALUE exc;
|
271
|
-
DWORD state;
|
272
|
-
DWORD res;
|
273
|
-
|
274
|
-
if (_pipe(fd, 1024, O_BINARY) == -1) {
|
275
|
-
rb_raise(rb_eSystemCallError, "_pipe() failed");
|
276
|
-
return Qnil;
|
277
|
-
}
|
278
|
-
|
279
|
-
thr = ALLOC_N(struct BlockingThread, 1);
|
280
|
-
thr->rdfd = fd[0];
|
281
|
-
thr->wrfd = fd[1];
|
282
|
-
thr->fn = func;
|
283
|
-
thr->data = data1;
|
284
|
-
thr->ubf = ubf;
|
285
|
-
thr->data2 = data2;
|
286
|
-
thr->retval = Qnil;
|
287
|
-
|
288
|
-
thr->tid = CreateThread(NULL, 0, rbffi_blocking_thread, thr, 0, NULL);
|
289
|
-
if (!thr->tid) {
|
290
|
-
close(fd[0]);
|
291
|
-
close(fd[1]);
|
292
|
-
xfree(thr);
|
293
|
-
rb_raise(rb_eSystemCallError, "CreateThread() failed");
|
294
|
-
return Qnil;
|
295
|
-
}
|
296
|
-
|
297
|
-
exc = rb_rescue2(wait_for_thread, (VALUE) thr, cleanup_blocking_thread, (VALUE) thr,
|
298
|
-
rb_eException);
|
299
|
-
|
300
|
-
/* The thread should be finished, already. */
|
301
|
-
WaitForSingleObject(thr->tid, INFINITE);
|
302
|
-
CloseHandle(thr->tid);
|
303
|
-
close(fd[1]);
|
304
|
-
close(fd[0]);
|
305
|
-
xfree(thr);
|
306
|
-
|
307
|
-
if (exc != Qnil) {
|
308
|
-
rb_exc_raise(exc);
|
309
|
-
}
|
310
|
-
|
311
|
-
return thr->retval;
|
312
|
-
}
|
313
|
-
|
314
|
-
#endif /* !_WIN32 */
|
315
|
-
|
316
|
-
#endif /* HAVE_RB_THREAD_BLOCKING_REGION */
|
317
|
-
|
318
94
|
#ifndef _WIN32
|
319
95
|
static struct thread_data* thread_data_init(void);
|
320
96
|
|
@@ -348,6 +124,6 @@ rbffi_Thread_Init(VALUE moduleFFI)
|
|
348
124
|
#ifdef _WIN32
|
349
125
|
frame_thread_key = TlsAlloc();
|
350
126
|
#else
|
351
|
-
pthread_key_create(&thread_data_key, thread_data_free);
|
127
|
+
pthread_key_create(&thread_data_key, thread_data_free);
|
352
128
|
#endif
|
353
129
|
}
|
data/ext/ffi_c/Thread.h
CHANGED
@@ -30,12 +30,7 @@
|
|
30
30
|
#ifndef RBFFI_THREAD_H
|
31
31
|
#define RBFFI_THREAD_H
|
32
32
|
|
33
|
-
#
|
34
|
-
# include <stdbool.h>
|
35
|
-
#else
|
36
|
-
# include "win32/stdbool.h"
|
37
|
-
# include "win32/stdint.h"
|
38
|
-
#endif
|
33
|
+
#include <stdbool.h>
|
39
34
|
#include <ruby.h>
|
40
35
|
#include "extconf.h"
|
41
36
|
|
@@ -66,7 +61,6 @@ typedef struct rbffi_frame {
|
|
66
61
|
struct thread_data* td;
|
67
62
|
#endif
|
68
63
|
struct rbffi_frame* prev;
|
69
|
-
bool has_gvl;
|
70
64
|
VALUE exc;
|
71
65
|
} rbffi_frame_t;
|
72
66
|
|
@@ -74,19 +68,6 @@ rbffi_frame_t* rbffi_frame_current(void);
|
|
74
68
|
void rbffi_frame_push(rbffi_frame_t* frame);
|
75
69
|
void rbffi_frame_pop(rbffi_frame_t* frame);
|
76
70
|
|
77
|
-
#ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
|
78
|
-
# define rbffi_thread_blocking_region rb_thread_call_without_gvl
|
79
|
-
|
80
|
-
#elif defined(HAVE_RB_THREAD_BLOCKING_REGION)
|
81
|
-
# define rbffi_thread_blocking_region rb_thread_blocking_region
|
82
|
-
|
83
|
-
#else
|
84
|
-
|
85
|
-
VALUE rbffi_thread_blocking_region(VALUE (*func)(void *), void *data1, void (*ubf)(void *), void *data2);
|
86
|
-
|
87
|
-
#endif
|
88
|
-
|
89
|
-
|
90
71
|
#ifdef __cplusplus
|
91
72
|
}
|
92
73
|
#endif
|
data/ext/ffi_c/Type.c
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
*/
|
29
29
|
|
30
30
|
#ifndef _MSC_VER
|
31
|
-
#include <sys/param.h>
|
31
|
+
# include <sys/param.h>
|
32
32
|
#endif
|
33
33
|
|
34
34
|
#include <sys/types.h>
|
@@ -235,24 +235,6 @@ rbffi_Type_Lookup(VALUE name)
|
|
235
235
|
return Qnil;
|
236
236
|
}
|
237
237
|
|
238
|
-
/**
|
239
|
-
* rbffi_Type_Find() is like rbffi_Type_Lookup, but an error is raised if the
|
240
|
-
* type is not found.
|
241
|
-
*/
|
242
|
-
VALUE
|
243
|
-
rbffi_Type_Find(VALUE name)
|
244
|
-
{
|
245
|
-
VALUE rbType = rbffi_Type_Lookup(name);
|
246
|
-
|
247
|
-
if (!RTEST(rbType)) {
|
248
|
-
VALUE s = rb_inspect(name);
|
249
|
-
rb_raise(rb_eTypeError, "invalid type, %s", RSTRING_PTR(s));
|
250
|
-
RB_GC_GUARD(s);
|
251
|
-
}
|
252
|
-
|
253
|
-
return rbType;
|
254
|
-
}
|
255
|
-
|
256
238
|
void
|
257
239
|
rbffi_Type_Init(VALUE moduleFFI)
|
258
240
|
{
|
data/ext/ffi_c/Type.h
CHANGED
data/ext/ffi_c/Types.c
CHANGED
@@ -80,15 +80,14 @@ rbffi_NativeValue_ToRuby(Type* type, VALUE rbType, const void* ptr)
|
|
80
80
|
return rbffi_longdouble_new(*(long double *) ptr);
|
81
81
|
|
82
82
|
case NATIVE_STRING:
|
83
|
-
return (*(void **) ptr != NULL) ?
|
83
|
+
return (*(void **) ptr != NULL) ? rb_str_new2(*(char **) ptr) : Qnil;
|
84
84
|
case NATIVE_POINTER:
|
85
85
|
return rbffi_Pointer_NewInstance(*(void **) ptr);
|
86
86
|
case NATIVE_BOOL:
|
87
87
|
return ((unsigned char) *(ffi_arg *) ptr) ? Qtrue : Qfalse;
|
88
|
-
|
89
|
-
case NATIVE_FUNCTION:
|
90
|
-
|
91
|
-
return *(void **) ptr != NULL
|
88
|
+
|
89
|
+
case NATIVE_FUNCTION: {
|
90
|
+
return *(void **) ptr != NULL
|
92
91
|
? rbffi_Function_NewInstance(rbType, rbffi_Pointer_NewInstance(*(void **) ptr))
|
93
92
|
: Qnil;
|
94
93
|
}
|
@@ -116,15 +115,15 @@ rbffi_NativeValue_ToRuby(Type* type, VALUE rbType, const void* ptr)
|
|
116
115
|
|
117
116
|
values[0] = rbffi_NativeValue_ToRuby(m->type, m->rbType, ptr);
|
118
117
|
values[1] = Qnil;
|
119
|
-
|
118
|
+
|
120
119
|
|
121
120
|
rbReturnValue = rb_funcall2(m->rbConverter, id_from_native, 2, values);
|
122
121
|
RB_GC_GUARD(values[0]);
|
123
122
|
RB_GC_GUARD(rbType);
|
124
|
-
|
123
|
+
|
125
124
|
return rbReturnValue;
|
126
125
|
}
|
127
|
-
|
126
|
+
|
128
127
|
default:
|
129
128
|
rb_raise(rb_eRuntimeError, "Unknown type: %d", type->nativeType);
|
130
129
|
return Qnil;
|
data/ext/ffi_c/Types.h
CHANGED
@@ -51,20 +51,19 @@ typedef enum {
|
|
51
51
|
NATIVE_FLOAT64,
|
52
52
|
NATIVE_LONGDOUBLE,
|
53
53
|
NATIVE_POINTER,
|
54
|
-
NATIVE_CALLBACK,
|
55
54
|
NATIVE_FUNCTION,
|
56
55
|
NATIVE_BUFFER_IN,
|
57
56
|
NATIVE_BUFFER_OUT,
|
58
57
|
NATIVE_BUFFER_INOUT,
|
59
58
|
NATIVE_CHAR_ARRAY,
|
60
59
|
NATIVE_BOOL,
|
61
|
-
|
60
|
+
|
62
61
|
/** An immutable string. Nul terminated, but only copies in to the native function */
|
63
62
|
NATIVE_STRING,
|
64
|
-
|
63
|
+
|
65
64
|
/** The function takes a variable number of arguments */
|
66
65
|
NATIVE_VARARGS,
|
67
|
-
|
66
|
+
|
68
67
|
/** Struct-by-value param or result */
|
69
68
|
NATIVE_STRUCT,
|
70
69
|
|
data/ext/ffi_c/Variadic.c
CHANGED
@@ -33,13 +33,8 @@
|
|
33
33
|
#include <sys/types.h>
|
34
34
|
|
35
35
|
#include <stdio.h>
|
36
|
-
#
|
37
|
-
#
|
38
|
-
# include <stdbool.h>
|
39
|
-
#else
|
40
|
-
# include "win32/stdbool.h"
|
41
|
-
# include "win32/stdint.h"
|
42
|
-
#endif
|
36
|
+
#include <stdint.h>
|
37
|
+
#include <stdbool.h>
|
43
38
|
#include <ruby.h>
|
44
39
|
|
45
40
|
#include <ffi.h>
|
@@ -173,7 +168,8 @@ variadic_invoke(VALUE self, VALUE parameterTypes, VALUE parameterValues)
|
|
173
168
|
ffi_type* ffiReturnType;
|
174
169
|
Type** paramTypes;
|
175
170
|
VALUE* argv;
|
176
|
-
|
171
|
+
VALUE* callbackParameters;
|
172
|
+
int paramCount = 0, fixedCount = 0, callbackCount = 0, i;
|
177
173
|
ffi_status ffiStatus;
|
178
174
|
rbffi_frame_t frame = { 0 };
|
179
175
|
|
@@ -187,11 +183,12 @@ variadic_invoke(VALUE self, VALUE parameterTypes, VALUE parameterValues)
|
|
187
183
|
params = ALLOCA_N(FFIStorage, paramCount);
|
188
184
|
ffiValues = ALLOCA_N(void*, paramCount);
|
189
185
|
argv = ALLOCA_N(VALUE, paramCount);
|
186
|
+
callbackParameters = ALLOCA_N(VALUE, paramCount);
|
190
187
|
retval = alloca(MAX(invoker->returnType->ffiType->size, FFI_SIZEOF_ARG));
|
191
188
|
|
192
189
|
for (i = 0; i < paramCount; ++i) {
|
193
190
|
VALUE rbType = rb_ary_entry(parameterTypes, i);
|
194
|
-
|
191
|
+
|
195
192
|
if (!rb_obj_is_kind_of(rbType, rbffi_TypeClass)) {
|
196
193
|
rb_raise(rb_eTypeError, "wrong type. Expected (FFI::Type)");
|
197
194
|
}
|
@@ -210,17 +207,25 @@ variadic_invoke(VALUE self, VALUE parameterTypes, VALUE parameterValues)
|
|
210
207
|
rbType = rb_const_get(rbffi_TypeClass, rb_intern("UINT32"));
|
211
208
|
Data_Get_Struct(rbType, Type, paramTypes[i]);
|
212
209
|
break;
|
213
|
-
|
210
|
+
|
214
211
|
case NATIVE_FLOAT32:
|
215
212
|
rbType = rb_const_get(rbffi_TypeClass, rb_intern("DOUBLE"));
|
216
213
|
Data_Get_Struct(rbType, Type, paramTypes[i]);
|
217
214
|
break;
|
218
215
|
|
216
|
+
case NATIVE_FUNCTION:
|
217
|
+
if (!rb_obj_is_kind_of(rbType, rbffi_FunctionTypeClass)) {
|
218
|
+
VALUE typeName = rb_funcall2(rbType, rb_intern("inspect"), 0, NULL);
|
219
|
+
rb_raise(rb_eTypeError, "Incorrect parameter type (%s)", RSTRING_PTR(typeName));
|
220
|
+
}
|
221
|
+
callbackParameters[callbackCount++] = rbType;
|
222
|
+
break;
|
223
|
+
|
219
224
|
default:
|
220
225
|
break;
|
221
226
|
}
|
222
|
-
|
223
|
-
|
227
|
+
|
228
|
+
|
224
229
|
ffiParamTypes[i] = paramTypes[i]->ffiType;
|
225
230
|
if (ffiParamTypes[i] == NULL) {
|
226
231
|
rb_raise(rb_eArgError, "Invalid parameter type #%x", paramTypes[i]->nativeType);
|
@@ -253,14 +258,10 @@ variadic_invoke(VALUE self, VALUE parameterTypes, VALUE parameterValues)
|
|
253
258
|
}
|
254
259
|
|
255
260
|
rbffi_SetupCallParams(paramCount, argv, -1, paramTypes, params,
|
256
|
-
ffiValues,
|
257
|
-
|
261
|
+
ffiValues, callbackParameters, callbackCount, invoker->rbEnums);
|
262
|
+
|
258
263
|
rbffi_frame_push(&frame);
|
259
|
-
|
260
|
-
/* In Call.c, blocking: true is supported on older ruby variants
|
261
|
-
* without rb_thread_call_without_gvl by allocating on the heap instead
|
262
|
-
* of the stack. Since this functionality is being added later,
|
263
|
-
* we’re skipping support for old rubies here. */
|
264
|
+
|
264
265
|
if(unlikely(invoker->blocking)) {
|
265
266
|
rbffi_blocking_call_t* bc;
|
266
267
|
bc = ALLOCA_N(rbffi_blocking_call_t, 1);
|
@@ -275,13 +276,11 @@ variadic_invoke(VALUE self, VALUE parameterTypes, VALUE parameterValues)
|
|
275
276
|
} else {
|
276
277
|
ffi_call(&cif, FFI_FN(invoker->function), retval, ffiValues);
|
277
278
|
}
|
278
|
-
|
279
|
-
ffi_call(&cif, FFI_FN(invoker->function), retval, ffiValues);
|
280
|
-
#endif
|
279
|
+
|
281
280
|
rbffi_frame_pop(&frame);
|
282
|
-
|
281
|
+
|
283
282
|
rbffi_save_errno();
|
284
|
-
|
283
|
+
|
285
284
|
if (RTEST(frame.exc) && frame.exc != Qnil) {
|
286
285
|
rb_exc_raise(frame.exc);
|
287
286
|
}
|