ffi 1.15.5 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +118 -0
- data/Gemfile +10 -3
- data/README.md +4 -3
- data/Rakefile +25 -10
- data/ext/ffi_c/AbstractMemory.c +99 -74
- data/ext/ffi_c/AbstractMemory.h +3 -2
- data/ext/ffi_c/ArrayType.c +51 -15
- data/ext/ffi_c/ArrayType.h +1 -0
- data/ext/ffi_c/Buffer.c +90 -33
- data/ext/ffi_c/Call.c +29 -12
- data/ext/ffi_c/Call.h +3 -2
- data/ext/ffi_c/DynamicLibrary.c +90 -27
- data/ext/ffi_c/Function.c +244 -98
- data/ext/ffi_c/Function.h +1 -0
- data/ext/ffi_c/FunctionInfo.c +81 -25
- data/ext/ffi_c/LastError.c +29 -11
- data/ext/ffi_c/MappedType.c +66 -23
- data/ext/ffi_c/MappedType.h +0 -2
- data/ext/ffi_c/MemoryPointer.c +36 -9
- data/ext/ffi_c/MethodHandle.c +3 -1
- data/ext/ffi_c/Pointer.c +82 -40
- data/ext/ffi_c/Pointer.h +1 -0
- data/ext/ffi_c/Struct.c +166 -84
- data/ext/ffi_c/Struct.h +7 -4
- data/ext/ffi_c/StructByValue.c +48 -16
- data/ext/ffi_c/StructLayout.c +130 -61
- data/ext/ffi_c/Type.c +120 -51
- data/ext/ffi_c/Type.h +3 -1
- data/ext/ffi_c/Types.c +8 -2
- data/ext/ffi_c/Types.h +0 -1
- data/ext/ffi_c/Variadic.c +71 -26
- data/ext/ffi_c/compat.h +22 -22
- data/ext/ffi_c/extconf.rb +19 -2
- data/ext/ffi_c/ffi.c +4 -0
- data/ext/ffi_c/libffi/.allow-ai-service +0 -0
- data/ext/ffi_c/libffi/.appveyor/site.exp +16 -0
- data/ext/ffi_c/libffi/.appveyor/unix-noexec.exp +7 -0
- data/ext/ffi_c/libffi/.appveyor.yml +27 -9
- data/ext/ffi_c/libffi/.ci/build-cross-in-container.sh +18 -0
- data/ext/ffi_c/libffi/{.travis → .ci}/build-in-container.sh +4 -6
- data/ext/ffi_c/libffi/.ci/build.sh +124 -0
- data/ext/ffi_c/libffi/{.travis → .ci}/install.sh +14 -7
- data/ext/ffi_c/libffi/.ci/msvs-detect +1103 -0
- data/ext/ffi_c/libffi/{.travis → .ci}/site.exp +5 -3
- data/ext/ffi_c/libffi/.circleci/config.yml +156 -0
- data/ext/ffi_c/libffi/.github/workflows/build.yml +479 -0
- data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +172 -0
- data/ext/ffi_c/libffi/.gitignore +10 -2
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/Makefile.am +12 -5
- data/ext/ffi_c/libffi/Makefile.in +118 -51
- data/ext/ffi_c/libffi/README.md +150 -105
- data/ext/ffi_c/libffi/acinclude.m4 +10 -112
- data/ext/ffi_c/libffi/compile +348 -0
- data/ext/ffi_c/libffi/config.guess +623 -556
- data/ext/ffi_c/libffi/config.sub +75 -34
- data/ext/ffi_c/libffi/configure +4571 -3830
- data/ext/ffi_c/libffi/configure.ac +64 -28
- data/ext/ffi_c/libffi/configure.host +26 -7
- data/ext/ffi_c/libffi/doc/Makefile.in +9 -6
- data/ext/ffi_c/libffi/doc/libffi.texi +82 -33
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +12 -47
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +163 -52
- data/ext/ffi_c/libffi/include/Makefile.am +1 -1
- data/ext/ffi_c/libffi/include/Makefile.in +10 -9
- data/ext/ffi_c/libffi/include/ffi.h.in +55 -60
- data/ext/ffi_c/libffi/include/ffi_cfi.h +21 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +33 -2
- data/ext/ffi_c/libffi/include/tramp.h +45 -0
- data/ext/ffi_c/libffi/install-sh +92 -69
- data/ext/ffi_c/libffi/libffi.map.in +5 -0
- data/ext/ffi_c/libffi/libtool-version +2 -2
- data/ext/ffi_c/libffi/ltmain.sh +518 -333
- data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +18 -14
- data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +108 -72
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +76 -45
- data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
- data/ext/ffi_c/libffi/man/Makefile.in +9 -6
- data/ext/ffi_c/libffi/missing +1 -1
- data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +2 -2
- data/ext/ffi_c/libffi/msvcc.sh +1 -1
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +172 -55
- data/ext/ffi_c/libffi/src/aarch64/internal.h +32 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +331 -87
- data/ext/ffi_c/libffi/src/arc/arcompact.S +169 -94
- data/ext/ffi_c/libffi/src/arc/ffi.c +325 -148
- data/ext/ffi_c/libffi/src/arc/ffitarget.h +14 -0
- data/ext/ffi_c/libffi/src/arm/ffi.c +62 -17
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +3 -3
- data/ext/ffi_c/libffi/src/arm/internal.h +10 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +113 -42
- data/ext/ffi_c/libffi/src/closures.c +136 -50
- data/ext/ffi_c/libffi/src/debug.c +2 -2
- data/ext/ffi_c/libffi/src/dlmalloc.c +6 -1
- data/ext/ffi_c/libffi/src/ia64/ffi.c +12 -0
- data/ext/ffi_c/libffi/src/ia64/unix.S +20 -2
- data/ext/ffi_c/libffi/src/loongarch64/ffi.c +624 -0
- data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +82 -0
- data/ext/ffi_c/libffi/src/loongarch64/sysv.S +327 -0
- data/ext/ffi_c/libffi/src/m32r/ffi.c +31 -14
- data/ext/ffi_c/libffi/src/mips/ffi.c +250 -67
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +7 -0
- data/ext/ffi_c/libffi/src/mips/n32.S +193 -33
- data/ext/ffi_c/libffi/src/mips/o32.S +61 -4
- data/ext/ffi_c/libffi/src/moxie/ffi.c +47 -22
- data/ext/ffi_c/libffi/src/or1k/ffi.c +25 -12
- data/ext/ffi_c/libffi/src/pa/ffi.c +32 -33
- data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +22 -8
- data/ext/ffi_c/libffi/src/pa/hpux32.S +83 -36
- data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
- data/ext/ffi_c/libffi/src/pa/linux.S +82 -35
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +36 -24
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1 -1
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +2 -0
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +2 -0
- data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
- data/ext/ffi_c/libffi/src/prep_cif.c +22 -2
- data/ext/ffi_c/libffi/src/riscv/ffi.c +37 -4
- data/ext/ffi_c/libffi/src/sparc/ffi64.c +23 -1
- data/ext/ffi_c/libffi/src/tramp.c +716 -0
- data/ext/ffi_c/libffi/src/types.c +4 -6
- data/ext/ffi_c/libffi/src/wasm32/ffi.c +947 -0
- data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
- data/ext/ffi_c/libffi/src/x86/ffi.c +99 -37
- data/ext/ffi_c/libffi/src/x86/ffi64.c +67 -12
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +9 -5
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +44 -1
- data/ext/ffi_c/libffi/src/x86/internal.h +14 -0
- data/ext/ffi_c/libffi/src/x86/internal64.h +14 -0
- data/ext/ffi_c/libffi/src/x86/sysv.S +172 -38
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +91 -88
- data/ext/ffi_c/libffi/src/x86/unix64.S +96 -6
- data/ext/ffi_c/libffi/src/x86/win64.S +20 -7
- data/ext/ffi_c/libffi/src/xtensa/ffi.c +16 -8
- data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +4 -0
- data/ext/ffi_c/libffi/src/xtensa/sysv.S +26 -16
- data/ext/ffi_c/libffi/testsuite/Makefile.am +79 -114
- data/ext/ffi_c/libffi/testsuite/Makefile.in +89 -121
- data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +54 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +63 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +86 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +48 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/test.html +7 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +51 -0
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +43 -21
- data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +5 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback2.c +108 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback3.c +114 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback4.c +119 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +28 -3
- data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +60 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +8 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +63 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +65 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +65 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +67 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +67 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +93 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +61 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +63 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +90 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -119
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +220 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +154 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +15 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn0.c +3 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn1.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn2.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn3.c +21 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn4.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn5.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn6.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_loc_fn0.c +7 -6
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_simple.c +6 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_12byte.c +18 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_16byte.c +22 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_18byte.c +24 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_19byte.c +29 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_1_1byte.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte1.c +21 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_24byte.c +35 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_2byte.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3_1byte.c +19 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte1.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte2.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +18 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4_1byte.c +22 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4byte.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5_1_byte.c +29 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5byte.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_64byte.c +24 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6_1_byte.c +28 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6byte.c +24 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7_1_byte.c +39 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7byte.c +25 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_8byte.c +14 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte1.c +14 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte2.c +14 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_double.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_float.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble.c +20 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split.c +40 -25
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split2.c +40 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_pointer.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint16.c +18 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint32.c +18 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint64.c +18 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint16.c +18 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint32.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint64.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +3 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_double_va.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_float.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble.c +11 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble_va.c +22 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_schar.c +5 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshort.c +6 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_uchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c +6 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer.c +5 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer_stack.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_schar.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sint.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sshort.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulonglong.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -138
- data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +21 -21
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct.c +32 -9
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct1.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct10.c +12 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +21 -5
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +115 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct2.c +10 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct3.c +10 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct4.c +9 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct5.c +9 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct6.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct7.c +9 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct8.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct9.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +102 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +101 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium2.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c +6 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +2 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +1 -0
- data/ext/ffi_c/libffi.bsd.mk +2 -2
- data/ext/ffi_c/libffi.darwin.mk +2 -2
- data/ext/ffi_c/libffi.gnu.mk +2 -2
- data/ext/ffi_c/rbffi.h +1 -1
- data/ffi.gemspec +3 -3
- data/lib/ffi/autopointer.rb +8 -31
- data/lib/ffi/compat.rb +43 -0
- data/lib/ffi/data_converter.rb +2 -2
- data/lib/ffi/dynamic_library.rb +118 -0
- data/lib/ffi/enum.rb +18 -12
- data/lib/ffi/ffi.rb +3 -0
- data/lib/ffi/function.rb +71 -0
- data/lib/ffi/io.rb +2 -2
- data/lib/ffi/library.rb +72 -88
- data/lib/ffi/library_path.rb +109 -0
- data/lib/ffi/managedstruct.rb +1 -1
- data/lib/ffi/platform/aarch64-linux/types.conf +74 -3
- data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
- data/lib/ffi/platform/hppa1.1-linux/types.conf +178 -0
- data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
- data/lib/ffi/platform/loongarch64-linux/types.conf +141 -0
- data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
- data/lib/ffi/platform.rb +15 -13
- data/lib/ffi/pointer.rb +6 -6
- data/lib/ffi/struct.rb +6 -5
- data/lib/ffi/struct_layout.rb +3 -3
- data/lib/ffi/struct_layout_builder.rb +9 -9
- data/lib/ffi/types.rb +65 -37
- data/lib/ffi/variadic.rb +19 -8
- data/lib/ffi/version.rb +1 -1
- data/samples/hello_ractor.rb +11 -0
- data/samples/qsort_ractor.rb +28 -0
- data/sig/ffi/abstract_memory.rbs +165 -0
- data/sig/ffi/auto_pointer.rbs +27 -0
- data/sig/ffi/buffer.rbs +18 -0
- data/sig/ffi/data_converter.rbs +10 -0
- data/sig/ffi/dynamic_library.rbs +9 -0
- data/sig/ffi/enum.rbs +38 -0
- data/sig/ffi/function.rbs +39 -0
- data/sig/ffi/library.rbs +42 -0
- data/sig/ffi/native_type.rbs +86 -0
- data/sig/ffi/pointer.rbs +42 -0
- data/sig/ffi/struct.rbs +76 -0
- data/sig/ffi/struct_by_reference.rbs +11 -0
- data/sig/ffi/struct_by_value.rbs +7 -0
- data/sig/ffi/struct_layout.rbs +9 -0
- data/sig/ffi/struct_layout_builder.rbs +5 -0
- data/sig/ffi/type.rbs +39 -0
- data/sig/ffi.rbs +26 -0
- data.tar.gz.sig +0 -0
- metadata +122 -28
- metadata.gz.sig +1 -0
- data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +0 -14
- data/ext/ffi_c/libffi/.travis/build.sh +0 -142
- data/ext/ffi_c/libffi/.travis.yml +0 -83
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar_va.c +0 -44
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort_va.c +0 -44
- /data/ext/ffi_c/libffi/{.travis → .ci}/ar-lib +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/bfin-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/compile +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/m32r-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/moxie-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/or1k-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/powerpc-eabisim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/wine-sim.exp +0 -0
- /data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
- /data/lib/ffi/platform/{sparc64-linux → sparcv9-linux}/types.conf +0 -0
data/lib/ffi/platform.rb
CHANGED
@@ -29,13 +29,15 @@
|
|
29
29
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#
|
30
30
|
|
31
31
|
require 'rbconfig'
|
32
|
+
require_relative 'compat'
|
33
|
+
|
32
34
|
module FFI
|
33
35
|
class PlatformError < LoadError; end
|
34
36
|
|
35
37
|
# This module defines different constants and class methods to play with
|
36
38
|
# various platforms.
|
37
39
|
module Platform
|
38
|
-
OS = case RbConfig::CONFIG['host_os'].downcase
|
40
|
+
OS = FFI.make_shareable(case RbConfig::CONFIG['host_os'].downcase
|
39
41
|
when /linux/
|
40
42
|
"linux"
|
41
43
|
when /darwin/
|
@@ -54,13 +56,13 @@ module FFI
|
|
54
56
|
"windows"
|
55
57
|
else
|
56
58
|
RbConfig::CONFIG['host_os'].downcase
|
57
|
-
end
|
59
|
+
end)
|
58
60
|
|
59
61
|
OSVERSION = RbConfig::CONFIG['host_os'].gsub(/[^\d]/, '').to_i
|
60
62
|
|
61
|
-
CPU = RbConfig::CONFIG['host_cpu']
|
63
|
+
CPU = FFI.make_shareable(RbConfig::CONFIG['host_cpu'])
|
62
64
|
|
63
|
-
ARCH = case CPU.downcase
|
65
|
+
ARCH = FFI.make_shareable(case CPU.downcase
|
64
66
|
when /amd64|x86_64|x64/
|
65
67
|
"x86_64"
|
66
68
|
when /i\d86|x86|i86pc/
|
@@ -81,7 +83,7 @@ module FFI
|
|
81
83
|
end
|
82
84
|
else
|
83
85
|
RbConfig::CONFIG['host_cpu']
|
84
|
-
end
|
86
|
+
end)
|
85
87
|
|
86
88
|
private
|
87
89
|
# @param [String) os
|
@@ -105,21 +107,21 @@ module FFI
|
|
105
107
|
# Add the version for known ABI breaks
|
106
108
|
name_version = "12" if IS_FREEBSD && OSVERSION >= 12 # 64-bit inodes
|
107
109
|
|
108
|
-
NAME = "#{ARCH}-#{OS}#{name_version}"
|
109
|
-
CONF_DIR = File.join(File.dirname(__FILE__), 'platform', NAME)
|
110
|
+
NAME = FFI.make_shareable("#{ARCH}-#{OS}#{name_version}")
|
111
|
+
CONF_DIR = FFI.make_shareable(File.join(File.dirname(__FILE__), 'platform', NAME))
|
110
112
|
|
111
113
|
public
|
112
114
|
|
113
|
-
LIBPREFIX = case OS
|
115
|
+
LIBPREFIX = FFI.make_shareable(case OS
|
114
116
|
when /windows|msys/
|
115
117
|
''
|
116
118
|
when /cygwin/
|
117
119
|
'cyg'
|
118
120
|
else
|
119
121
|
'lib'
|
120
|
-
end
|
122
|
+
end)
|
121
123
|
|
122
|
-
LIBSUFFIX = case OS
|
124
|
+
LIBSUFFIX = FFI.make_shareable(case OS
|
123
125
|
when /darwin/
|
124
126
|
'dylib'
|
125
127
|
when /linux|bsd|solaris/
|
@@ -129,9 +131,9 @@ module FFI
|
|
129
131
|
else
|
130
132
|
# Punt and just assume a sane unix (i.e. anything but AIX)
|
131
133
|
'so'
|
132
|
-
end
|
134
|
+
end)
|
133
135
|
|
134
|
-
LIBC = if IS_WINDOWS
|
136
|
+
LIBC = FFI.make_shareable(if IS_WINDOWS
|
135
137
|
crtname = RbConfig::CONFIG["RUBY_SO_NAME"][/msvc\w+/] || 'ucrtbase'
|
136
138
|
"#{crtname}.dll"
|
137
139
|
elsif IS_GNU
|
@@ -143,7 +145,7 @@ module FFI
|
|
143
145
|
"msys-2.0.dll"
|
144
146
|
else
|
145
147
|
"#{LIBPREFIX}c.#{LIBSUFFIX}"
|
146
|
-
end
|
148
|
+
end)
|
147
149
|
|
148
150
|
LITTLE_ENDIAN = 1234 unless defined?(LITTLE_ENDIAN)
|
149
151
|
BIG_ENDIAN = 4321 unless defined?(BIG_ENDIAN)
|
data/lib/ffi/pointer.rb
CHANGED
@@ -45,12 +45,12 @@ module FFI
|
|
45
45
|
SIZE = Platform::ADDRESS_SIZE / 8 unless const_defined?(:SIZE)
|
46
46
|
|
47
47
|
# Return the size of a pointer on the current platform, in bytes
|
48
|
-
# @return [
|
48
|
+
# @return [Integer]
|
49
49
|
def self.size
|
50
50
|
SIZE
|
51
51
|
end unless respond_to?(:size)
|
52
52
|
|
53
|
-
# @param [nil,
|
53
|
+
# @param [nil,Integer] len length of string to return
|
54
54
|
# @return [String]
|
55
55
|
# Read pointer's contents as a string, or the first +len+ bytes of the
|
56
56
|
# equivalent string if +len+ is not +nil+.
|
@@ -63,7 +63,7 @@ module FFI
|
|
63
63
|
end
|
64
64
|
end unless method_defined?(:read_string)
|
65
65
|
|
66
|
-
# @param [
|
66
|
+
# @param [Integer] len length of string to return
|
67
67
|
# @return [String]
|
68
68
|
# Read the first +len+ bytes of pointer's contents as a string.
|
69
69
|
#
|
@@ -83,7 +83,7 @@ module FFI
|
|
83
83
|
end unless method_defined?(:read_string_to_null)
|
84
84
|
|
85
85
|
# @param [String] str string to write
|
86
|
-
# @param [
|
86
|
+
# @param [Integer] len length of string to return
|
87
87
|
# @return [self]
|
88
88
|
# Write +len+ first bytes of +str+ in pointer's contents.
|
89
89
|
#
|
@@ -94,7 +94,7 @@ module FFI
|
|
94
94
|
end unless method_defined?(:write_string_length)
|
95
95
|
|
96
96
|
# @param [String] str string to write
|
97
|
-
# @param [
|
97
|
+
# @param [Integer] len length of string to return
|
98
98
|
# @return [self]
|
99
99
|
# Write +str+ in pointer's contents, or first +len+ bytes if
|
100
100
|
# +len+ is not +nil+.
|
@@ -106,7 +106,7 @@ module FFI
|
|
106
106
|
|
107
107
|
# @param [Type] type type of data to read from pointer's contents
|
108
108
|
# @param [Symbol] reader method to send to +self+ to read +type+
|
109
|
-
# @param [
|
109
|
+
# @param [Integer] length
|
110
110
|
# @return [Array]
|
111
111
|
# Read an array of +type+ of length +length+.
|
112
112
|
# @example
|
data/lib/ffi/struct.rb
CHANGED
@@ -41,12 +41,12 @@ module FFI
|
|
41
41
|
class Struct
|
42
42
|
|
43
43
|
# Get struct size
|
44
|
-
# @return [
|
44
|
+
# @return [Integer]
|
45
45
|
def size
|
46
46
|
self.class.size
|
47
47
|
end
|
48
48
|
|
49
|
-
# @return [
|
49
|
+
# @return [Integer] Struct alignment
|
50
50
|
def alignment
|
51
51
|
self.class.alignment
|
52
52
|
end
|
@@ -87,13 +87,13 @@ module FFI
|
|
87
87
|
end
|
88
88
|
|
89
89
|
# Get struct size
|
90
|
-
# @return [
|
90
|
+
# @return [Integer]
|
91
91
|
def self.size
|
92
92
|
defined?(@layout) ? @layout.size : defined?(@size) ? @size : 0
|
93
93
|
end
|
94
94
|
|
95
95
|
# set struct size
|
96
|
-
# @param [
|
96
|
+
# @param [Integer] size
|
97
97
|
# @return [size]
|
98
98
|
def self.size=(size)
|
99
99
|
raise ArgumentError, "Size already set" if defined?(@size) || defined?(@layout)
|
@@ -203,9 +203,10 @@ module FFI
|
|
203
203
|
# :field3, :string
|
204
204
|
# end
|
205
205
|
def layout(*spec)
|
206
|
-
warn "[DEPRECATION] Struct layout is already defined for class #{self.inspect}. Redefinition as in #{caller[0]} will be disallowed in ffi-2.0." if defined?(@layout)
|
207
206
|
return @layout if spec.size == 0
|
208
207
|
|
208
|
+
warn "[DEPRECATION] Struct layout is already defined for class #{self.inspect}. Redefinition as in #{caller[0]} will be disallowed in ffi-2.0." if defined?(@layout)
|
209
|
+
|
209
210
|
builder = StructLayoutBuilder.new
|
210
211
|
builder.union = self < Union
|
211
212
|
builder.packed = @packed if defined?(@packed)
|
data/lib/ffi/struct_layout.rb
CHANGED
@@ -35,13 +35,13 @@ module FFI
|
|
35
35
|
|
36
36
|
class StructLayout
|
37
37
|
|
38
|
-
# @return [Array<Array(Symbol,
|
38
|
+
# @return [Array<Array(Symbol, Integer)>
|
39
39
|
# Get an array of tuples (field name, offset of the field).
|
40
40
|
def offsets
|
41
41
|
members.map { |m| [ m, self[m].offset ] }
|
42
42
|
end
|
43
43
|
|
44
|
-
# @return [
|
44
|
+
# @return [Integer]
|
45
45
|
# Get the offset of a field.
|
46
46
|
def offset_of(field_name)
|
47
47
|
self[field_name].offset
|
@@ -80,8 +80,8 @@ module FFI
|
|
80
80
|
|
81
81
|
class Mapped < Field
|
82
82
|
def initialize(name, offset, type, orig_field)
|
83
|
-
super(name, offset, type)
|
84
83
|
@orig_field = orig_field
|
84
|
+
super(name, offset, type)
|
85
85
|
end
|
86
86
|
|
87
87
|
def get(ptr)
|
@@ -46,13 +46,13 @@ module FFI
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# Set size attribute with +size+ only if +size+ is greater than attribute value.
|
49
|
-
# @param [
|
49
|
+
# @param [Integer] size
|
50
50
|
def size=(size)
|
51
51
|
@size = size if size > @size
|
52
52
|
end
|
53
53
|
|
54
54
|
# Set alignment attribute with +align+ only if it is greater than attribute value.
|
55
|
-
# @param [
|
55
|
+
# @param [Integer] align
|
56
56
|
def alignment=(align)
|
57
57
|
@alignment = align if align > @alignment
|
58
58
|
@min_alignment = align
|
@@ -78,7 +78,7 @@ module FFI
|
|
78
78
|
# @overload packed=(packed) Set alignment and packed attributes to
|
79
79
|
# +packed+.
|
80
80
|
#
|
81
|
-
# @param [
|
81
|
+
# @param [Integer] packed
|
82
82
|
#
|
83
83
|
# @return [packed]
|
84
84
|
# @overload packed=(packed) Set packed attribute.
|
@@ -112,11 +112,11 @@ module FFI
|
|
112
112
|
Type::FLOAT64,
|
113
113
|
Type::LONGDOUBLE,
|
114
114
|
Type::BOOL,
|
115
|
-
]
|
115
|
+
].freeze
|
116
116
|
|
117
117
|
# @param [String, Symbol] name name of the field
|
118
118
|
# @param [Array, DataConverter, Struct, StructLayout::Field, Symbol, Type] type type of the field
|
119
|
-
# @param [
|
119
|
+
# @param [Integer, nil] offset
|
120
120
|
# @return [self]
|
121
121
|
# Add a field to the builder.
|
122
122
|
# @note Setting +offset+ to +nil+ or +-1+ is equivalent to +0+.
|
@@ -154,7 +154,7 @@ module FFI
|
|
154
154
|
|
155
155
|
# @param name (see #add)
|
156
156
|
# @param type (see #add)
|
157
|
-
# @param [
|
157
|
+
# @param [Integer] count array length
|
158
158
|
# @param offset (see #add)
|
159
159
|
# @return (see #add)
|
160
160
|
# Add an array as a field to the builder.
|
@@ -175,9 +175,9 @@ module FFI
|
|
175
175
|
|
176
176
|
private
|
177
177
|
|
178
|
-
# @param [
|
179
|
-
# @param [
|
180
|
-
# @return [
|
178
|
+
# @param [Integer] offset
|
179
|
+
# @param [Integer] align
|
180
|
+
# @return [Integer]
|
181
181
|
def align(offset, align)
|
182
182
|
align + ((offset - 1) & ~(align - 1));
|
183
183
|
end
|
data/lib/ffi/types.rb
CHANGED
@@ -33,40 +33,73 @@
|
|
33
33
|
# see {file:README}
|
34
34
|
module FFI
|
35
35
|
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
# Unless custom_typedefs already defined in the C-ext?
|
37
|
+
unless defined?(custom_typedefs)
|
38
|
+
# Truffleruby and JRuby don't support Ractor so far.
|
39
|
+
# So they don't need separation between builtin and custom types.
|
40
|
+
def self.custom_typedefs
|
41
|
+
TypeDefs
|
42
|
+
end
|
43
|
+
writable_typemap = true
|
42
44
|
end
|
43
45
|
|
44
|
-
|
45
|
-
def self.add_typedef(old, add)
|
46
|
-
typedef old, add
|
47
|
-
end
|
46
|
+
class << self
|
48
47
|
|
48
|
+
private :custom_typedefs
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
# @param [Type, DataConverter, Symbol] old type definition used by {FFI.find_type}
|
51
|
+
# @param [Symbol] add new type definition's name to add
|
52
|
+
# @return [Type]
|
53
|
+
# Add a definition type to type definitions.
|
54
|
+
#
|
55
|
+
# The type definition is local per Ractor.
|
56
|
+
def typedef(old, add)
|
57
|
+
tm = custom_typedefs
|
58
|
+
tm[add] = find_type(old)
|
59
|
+
end
|
60
|
+
|
61
|
+
# (see FFI.typedef)
|
62
|
+
def add_typedef(old, add)
|
63
|
+
typedef old, add
|
64
|
+
end
|
59
65
|
|
60
|
-
|
61
|
-
|
66
|
+
private def __typedef(old, add)
|
67
|
+
TypeDefs[add] = find_type(old, TypeDefs)
|
68
|
+
end
|
62
69
|
|
63
|
-
|
64
|
-
|
70
|
+
# @param [Type, DataConverter, Symbol] name
|
71
|
+
# @param [Hash] type_map if nil, {FFI::TypeDefs} is used
|
72
|
+
# @return [Type]
|
73
|
+
# Find a type in +type_map+ ({FFI::TypeDefs}, by default) from
|
74
|
+
# a type objet, a type name (symbol). If +name+ is a {DataConverter},
|
75
|
+
# a new {Type::Mapped} is created.
|
76
|
+
def find_type(name, type_map = nil)
|
77
|
+
if name.is_a?(Type)
|
78
|
+
name
|
79
|
+
|
80
|
+
elsif type_map&.has_key?(name)
|
81
|
+
type_map[name]
|
82
|
+
|
83
|
+
elsif (tm=custom_typedefs).has_key?(name)
|
84
|
+
tm[name]
|
85
|
+
|
86
|
+
elsif TypeDefs.has_key?(name)
|
87
|
+
TypeDefs[name]
|
88
|
+
|
89
|
+
elsif name.is_a?(DataConverter)
|
90
|
+
# Add a typedef so next time the converter is used, it hits the cache
|
91
|
+
tm = (type_map || custom_typedefs)
|
92
|
+
tm[name] = Type::Mapped.new(name)
|
93
|
+
else
|
94
|
+
raise TypeError, "unable to resolve type '#{name}'"
|
95
|
+
end
|
96
|
+
end
|
65
97
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
98
|
+
# @param type +type+ is an instance of class accepted by {FFI.find_type}
|
99
|
+
# @return [Integer]
|
100
|
+
# Get +type+ size, in bytes.
|
101
|
+
def type_size(type)
|
102
|
+
find_type(type).size
|
70
103
|
end
|
71
104
|
end
|
72
105
|
|
@@ -168,14 +201,7 @@ module FFI
|
|
168
201
|
end
|
169
202
|
end
|
170
203
|
|
171
|
-
|
172
|
-
|
173
|
-
# @param type +type+ is an instance of class accepted by {FFI.find_type}
|
174
|
-
# @return [Numeric]
|
175
|
-
# Get +type+ size, in bytes.
|
176
|
-
def self.type_size(type)
|
177
|
-
find_type(type).size
|
178
|
-
end
|
204
|
+
__typedef(StrPtrConverter, :strptr)
|
179
205
|
|
180
206
|
# Load all the platform dependent types
|
181
207
|
begin
|
@@ -184,11 +210,13 @@ module FFI
|
|
184
210
|
f.each_line { |line|
|
185
211
|
if line.index(prefix) == 0
|
186
212
|
new_type, orig_type = line.chomp.slice(prefix.length..-1).split(/\s*=\s*/)
|
187
|
-
|
213
|
+
__typedef(orig_type.to_sym, new_type.to_sym)
|
188
214
|
end
|
189
215
|
}
|
190
216
|
end
|
191
|
-
|
217
|
+
__typedef :pointer, :caddr_t
|
192
218
|
rescue Errno::ENOENT
|
193
219
|
end
|
220
|
+
|
221
|
+
FFI.make_shareable(TypeDefs) unless writable_typemap
|
194
222
|
end
|
data/lib/ffi/variadic.rb
CHANGED
@@ -54,16 +54,27 @@ module FFI
|
|
54
54
|
invoker = self
|
55
55
|
params = "*args"
|
56
56
|
call = "call"
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
57
|
+
mname = mname.to_sym
|
58
|
+
mod.module_eval <<-code, __FILE__, __LINE__
|
59
|
+
@ffi_functions = {} unless defined?(@ffi_functions)
|
60
|
+
@ffi_functions[#{mname.inspect}] = invoker
|
61
|
+
|
62
|
+
def self.#{mname}(#{params})
|
63
|
+
@ffi_functions[#{mname.inspect}].#{call}(#{params})
|
64
|
+
end
|
65
|
+
|
66
|
+
define_method(#{mname.inspect}, &method(#{mname.inspect}))
|
65
67
|
code
|
66
68
|
invoker
|
67
69
|
end
|
70
|
+
|
71
|
+
# Retrieve Array of parameter types
|
72
|
+
#
|
73
|
+
# This method returns an Array of FFI types accepted as function parameters.
|
74
|
+
#
|
75
|
+
# @return [Array<FFI::Type>]
|
76
|
+
def param_types
|
77
|
+
[*@fixed, Type::Builtin::VARARGS]
|
78
|
+
end
|
68
79
|
end
|
69
80
|
end
|
data/lib/ffi/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
module LibC
|
4
|
+
extend FFI::Library
|
5
|
+
ffi_lib FFI::Library::LIBC
|
6
|
+
callback :qsort_cmp, [ :pointer, :pointer ], :int
|
7
|
+
attach_function :qsort, [ :pointer, :ulong, :ulong, :qsort_cmp ], :int
|
8
|
+
|
9
|
+
freeze # Freeze the module variables, so that it can be shared across ractors.
|
10
|
+
end
|
11
|
+
|
12
|
+
p = FFI::MemoryPointer.new(:int, 3)
|
13
|
+
p.put_array_of_int32(0, [ 2, 3, 1 ]) # Write some unsorted data into the memory
|
14
|
+
# Ractor.make_shareable(p) # freeze the pointer to be shared between ractors instead of copied
|
15
|
+
puts "main -ptr=#{p.inspect}"
|
16
|
+
res = Ractor.new(p) do |p|
|
17
|
+
puts "ractor-ptr=#{p.inspect}"
|
18
|
+
puts "Before qsort #{p.get_array_of_int32(0, 3).join(', ')}"
|
19
|
+
LibC.qsort(p, 3, 4) do |p1, p2|
|
20
|
+
i1 = p1.get_int32(0)
|
21
|
+
i2 = p2.get_int32(0)
|
22
|
+
puts "In block: comparing #{i1} and #{i2}"
|
23
|
+
i1 < i2 ? -1 : i1 > i2 ? 1 : 0
|
24
|
+
end
|
25
|
+
puts "After qsort #{p.get_array_of_int32(0, 3).join(', ')}"
|
26
|
+
end.take
|
27
|
+
|
28
|
+
puts "After ractor termination #{p.get_array_of_int32(0, 3).join(', ')}"
|
@@ -0,0 +1,165 @@
|
|
1
|
+
module FFI
|
2
|
+
class AbstractMemory
|
3
|
+
interface _Size
|
4
|
+
def size: () -> Integer
|
5
|
+
end
|
6
|
+
include _Size
|
7
|
+
type type_size = Integer | _Size | Symbol
|
8
|
+
|
9
|
+
type order_out = :big | :little
|
10
|
+
type order_in = order_out | :network
|
11
|
+
|
12
|
+
def []: (Integer idx) -> instance
|
13
|
+
def clear: () -> self
|
14
|
+
def freeze: ...
|
15
|
+
def get: (ffi_type type, Integer offset) -> top
|
16
|
+
def put: (ffi_type type, Integer offset, top value) -> nil
|
17
|
+
def size_limit?: () -> bool
|
18
|
+
def type_size: () -> Integer
|
19
|
+
alias total size
|
20
|
+
|
21
|
+
def get_int8: (Integer offset) -> Integer
|
22
|
+
def get_int16: (Integer offset) -> Integer
|
23
|
+
def get_int32: (Integer offset) -> Integer
|
24
|
+
def get_int64: (Integer offset) -> Integer
|
25
|
+
def get_uint8: (Integer offset) -> Integer
|
26
|
+
def get_uint16: (Integer offset) -> Integer
|
27
|
+
def get_uint32: (Integer offset) -> Integer
|
28
|
+
def get_uint64: (Integer offset) -> Integer
|
29
|
+
def get_char: (Integer offset) -> Integer
|
30
|
+
def get_short: (Integer offset) -> Integer
|
31
|
+
def get_int: (Integer offset) -> Integer
|
32
|
+
def get_long_long: (Integer offset) -> Integer
|
33
|
+
def get_float32: (Integer offset) -> Float
|
34
|
+
def get_float64: (Integer offset) -> Float
|
35
|
+
def get_pointer: (Integer offset) -> Pointer
|
36
|
+
def get_bytes: (Integer offset, Integer length) -> String
|
37
|
+
def get_string: (Integer offset, ?Integer? length) -> String
|
38
|
+
alias get_float get_float32
|
39
|
+
alias get_double get_float64
|
40
|
+
|
41
|
+
def put_int8: (Integer offset, int value) -> self
|
42
|
+
def put_int16: (Integer offset, int value) -> self
|
43
|
+
def put_int32: (Integer offset, int value) -> self
|
44
|
+
def put_int64: (Integer offset, int value) -> self
|
45
|
+
def put_uint8: (Integer offset, int value) -> self
|
46
|
+
def put_uint16: (Integer offset, int value) -> self
|
47
|
+
def put_uint32: (Integer offset, int value) -> self
|
48
|
+
def put_uint64: (Integer offset, int value) -> self
|
49
|
+
def put_char: (Integer offset, int value) -> self
|
50
|
+
def put_short: (Integer offset, int value) -> self
|
51
|
+
def put_int: (Integer offset, int value) -> self
|
52
|
+
def put_long_long: (Integer offset, int value) -> self
|
53
|
+
def put_float32: (Integer offset, Numeric value) -> self
|
54
|
+
def put_float64: (Integer offset, Numeric value) -> self
|
55
|
+
def put_pointer: (Integer offset, pointer value) -> self
|
56
|
+
def put_bytes: (Integer offset, String str, ?Integer index, ?Integer? length) -> self
|
57
|
+
def put_string: (Integer offset, String value) -> self
|
58
|
+
alias put_float put_float32
|
59
|
+
alias put_double put_float64
|
60
|
+
|
61
|
+
def read_int8: () -> Integer
|
62
|
+
def read_int16: () -> Integer
|
63
|
+
def read_int32: () -> Integer
|
64
|
+
def read_int64: () -> Integer
|
65
|
+
def read_uint8: () -> Integer
|
66
|
+
def read_uint16: () -> Integer
|
67
|
+
def read_uint32: () -> Integer
|
68
|
+
def read_uint64: () -> Integer
|
69
|
+
def read_char: () -> Integer
|
70
|
+
def read_short: () -> Integer
|
71
|
+
def read_int: () -> Integer
|
72
|
+
def read_long_long: () -> Integer
|
73
|
+
def read_float: () -> Float
|
74
|
+
def read_double: () -> Float
|
75
|
+
def read_pointer: () -> Pointer
|
76
|
+
def read_bytes: (Integer length) -> String
|
77
|
+
|
78
|
+
def write_int8: (int value) -> self
|
79
|
+
def write_int16: (int value) -> self
|
80
|
+
def write_int32: (int value) -> self
|
81
|
+
def write_int64: (int value) -> self
|
82
|
+
def write_uint8: (int value) -> self
|
83
|
+
def write_uint16: (int value) -> self
|
84
|
+
def write_uint32: (int value) -> self
|
85
|
+
def write_uint64: (int value) -> self
|
86
|
+
def write_char: (int value) -> self
|
87
|
+
def write_short: (int value) -> self
|
88
|
+
def write_int: (int value) -> self
|
89
|
+
def write_long_long: (int value) -> self
|
90
|
+
def write_float: (Numeric value) -> self
|
91
|
+
def write_double: (Numeric value) -> self
|
92
|
+
def write_pointer: (pointer value) -> self
|
93
|
+
def write_bytes: (String str, ?Integer index, ?Integer? length) -> self
|
94
|
+
|
95
|
+
def get_array_of_int8: (Integer offset, Integer length) -> Array[Integer]
|
96
|
+
def get_array_of_int16: (Integer offset, Integer length) -> Array[Integer]
|
97
|
+
def get_array_of_int32: (Integer offset, Integer length) -> Array[Integer]
|
98
|
+
def get_array_of_int64: (Integer offset, Integer length) -> Array[Integer]
|
99
|
+
def get_array_of_uint8: (Integer offset, Integer length) -> Array[Integer]
|
100
|
+
def get_array_of_uint16: (Integer offset, Integer length) -> Array[Integer]
|
101
|
+
def get_array_of_uint32: (Integer offset, Integer length) -> Array[Integer]
|
102
|
+
def get_array_of_uint64: (Integer offset, Integer length) -> Array[Integer]
|
103
|
+
def get_array_of_char: (Integer offset, Integer length) -> Array[Integer]
|
104
|
+
def get_array_of_short: (Integer offset, Integer length) -> Array[Integer]
|
105
|
+
def get_array_of_int: (Integer offset, Integer length) -> Array[Integer]
|
106
|
+
def get_array_of_long_long: (Integer offset, Integer length) -> Array[Integer]
|
107
|
+
def get_array_of_float32: (Integer offset, Integer length) -> Array[Float]
|
108
|
+
def get_array_of_float64: (Integer offset, Integer length) -> Array[Float]
|
109
|
+
def get_array_of_pointer: (Integer offset, Integer length) -> Array[Pointer]
|
110
|
+
def get_array_of_string: (Integer offset, ?Integer? count) -> Array[String?]
|
111
|
+
alias get_array_of_float get_array_of_float32
|
112
|
+
alias get_array_of_double get_array_of_float64
|
113
|
+
|
114
|
+
def put_array_of_int8: (Integer offset, Array[int] ary) -> self
|
115
|
+
def put_array_of_int16: (Integer offset, Array[int] ary) -> self
|
116
|
+
def put_array_of_int32: (Integer offset, Array[int] ary) -> self
|
117
|
+
def put_array_of_int64: (Integer offset, Array[int] ary) -> self
|
118
|
+
def put_array_of_uint8: (Integer offset, Array[int] ary) -> self
|
119
|
+
def put_array_of_uint16: (Integer offset, Array[int] ary) -> self
|
120
|
+
def put_array_of_uint32: (Integer offset, Array[int] ary) -> self
|
121
|
+
def put_array_of_uint64: (Integer offset, Array[int] ary) -> self
|
122
|
+
def put_array_of_char: (Integer offset, Array[int] ary) -> self
|
123
|
+
def put_array_of_short: (Integer offset, Array[int] ary) -> self
|
124
|
+
def put_array_of_int: (Integer offset, Array[int] ary) -> self
|
125
|
+
def put_array_of_long_long: (Integer offset, Array[int] ary) -> self
|
126
|
+
def put_array_of_float32: (Integer offset, Array[Numeric] ary) -> self
|
127
|
+
def put_array_of_float64: (Integer offset, Array[Numeric] ary) -> self
|
128
|
+
def put_array_of_pointer: (Integer offset, Array[pointer] ary) -> self
|
129
|
+
alias put_array_of_float put_array_of_float32
|
130
|
+
alias put_array_of_double put_array_of_float64
|
131
|
+
|
132
|
+
def read_array_of_int8: (Integer length) -> Array[Integer]
|
133
|
+
def read_array_of_int16: (Integer length) -> Array[Integer]
|
134
|
+
def read_array_of_int32: (Integer length) -> Array[Integer]
|
135
|
+
def read_array_of_int64: (Integer length) -> Array[Integer]
|
136
|
+
def read_array_of_uint8: (Integer length) -> Array[Integer]
|
137
|
+
def read_array_of_uint16: (Integer length) -> Array[Integer]
|
138
|
+
def read_array_of_uint32: (Integer length) -> Array[Integer]
|
139
|
+
def read_array_of_uint64: (Integer length) -> Array[Integer]
|
140
|
+
def read_array_of_char: (Integer length) -> Array[Integer]
|
141
|
+
def read_array_of_short: (Integer length) -> Array[Integer]
|
142
|
+
def read_array_of_int: (Integer length) -> Array[Integer]
|
143
|
+
def read_array_of_long_long: (Integer length) -> Array[Integer]
|
144
|
+
def read_array_of_float: (Integer length) -> Array[Float]
|
145
|
+
def read_array_of_double: (Integer length) -> Array[Float]
|
146
|
+
def read_array_of_pointer: (Integer length) -> Array[Pointer]
|
147
|
+
def read_array_of_string: (?Integer? count) -> Array[String?]
|
148
|
+
|
149
|
+
def write_array_of_int8: (Array[int] ary) -> self
|
150
|
+
def write_array_of_int16: (Array[int] ary) -> self
|
151
|
+
def write_array_of_int32: (Array[int] ary) -> self
|
152
|
+
def write_array_of_int64: (Array[int] ary) -> self
|
153
|
+
def write_array_of_uint8: (Array[int] ary) -> self
|
154
|
+
def write_array_of_uint16: (Array[int] ary) -> self
|
155
|
+
def write_array_of_uint32: (Array[int] ary) -> self
|
156
|
+
def write_array_of_uint64: (Array[int] ary) -> self
|
157
|
+
def write_array_of_char: (Array[int] ary) -> self
|
158
|
+
def write_array_of_short: (Array[int] ary) -> self
|
159
|
+
def write_array_of_int: (Array[int] ary) -> self
|
160
|
+
def write_array_of_long_long: (Array[int] ary) -> self
|
161
|
+
def write_array_of_float: (Array[Numeric] ary) -> self
|
162
|
+
def write_array_of_double: (Array[Numeric] ary) -> self
|
163
|
+
def write_array_of_pointer: (Array[pointer] ary) -> self
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module FFI
|
2
|
+
class AutoPointer < Pointer
|
3
|
+
class Releaser
|
4
|
+
attr_accessor autorelease: boolish
|
5
|
+
interface _Proc[P < Pointer]
|
6
|
+
def call: (P) -> void
|
7
|
+
end
|
8
|
+
def initialize: [P < Pointer] (P ptr, _Proc[P] proc) -> void
|
9
|
+
|
10
|
+
def call: (*untyped) -> void
|
11
|
+
def free: () -> nil
|
12
|
+
def release: (Pointer ptr) -> void
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize: (Pointer pointer, Method | ^(self) -> void | Releaser::_Proc[self] callable) -> self
|
16
|
+
# | (Pointer pointer) { (self) -> void } -> self # https://github.com/ffi/ffi/issues/1071
|
17
|
+
| (Pointer pointer) -> self # where class < `def self.release: (instance pointer) -> void`
|
18
|
+
|
19
|
+
extend DataConverter[Pointer, instance, nil]
|
20
|
+
def self.from_native: ...
|
21
|
+
def self.native_type: () -> Type::Builtin
|
22
|
+
|
23
|
+
def autorelease?: ...
|
24
|
+
def autorelease=: ...
|
25
|
+
def free: () -> nil
|
26
|
+
end
|
27
|
+
end
|