ffi 1.15.4 → 1.16.3
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 +90 -0
- data/Gemfile +1 -1
- data/README.md +3 -2
- data/Rakefile +28 -11
- data/ext/ffi_c/AbstractMemory.c +60 -36
- data/ext/ffi_c/AbstractMemory.h +3 -2
- data/ext/ffi_c/ArrayType.c +49 -13
- data/ext/ffi_c/ArrayType.h +1 -0
- data/ext/ffi_c/Buffer.c +86 -29
- data/ext/ffi_c/Call.c +18 -7
- data/ext/ffi_c/DynamicLibrary.c +89 -26
- data/ext/ffi_c/Function.c +244 -98
- data/ext/ffi_c/Function.h +1 -0
- data/ext/ffi_c/FunctionInfo.c +80 -24
- data/ext/ffi_c/LastError.c +25 -7
- data/ext/ffi_c/MappedType.c +66 -23
- data/ext/ffi_c/MappedType.h +0 -2
- data/ext/ffi_c/MemoryPointer.c +34 -7
- data/ext/ffi_c/MethodHandle.c +3 -1
- data/ext/ffi_c/Pointer.c +68 -29
- data/ext/ffi_c/Pointer.h +1 -0
- data/ext/ffi_c/Struct.c +155 -80
- data/ext/ffi_c/Struct.h +7 -4
- data/ext/ffi_c/StructByValue.c +48 -16
- data/ext/ffi_c/StructLayout.c +117 -48
- data/ext/ffi_c/Type.c +104 -36
- data/ext/ffi_c/Type.h +3 -1
- data/ext/ffi_c/Types.c +1 -1
- data/ext/ffi_c/Variadic.c +65 -23
- 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/.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 +460 -0
- data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +171 -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 +92 -34
- data/ext/ffi_c/libffi/README.md +144 -104
- 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 +4567 -3822
- data/ext/ffi_c/libffi/configure.ac +64 -28
- data/ext/ffi_c/libffi/configure.host +25 -6
- 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 +54 -50
- data/ext/ffi_c/libffi/include/ffi_cfi.h +21 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +29 -0
- data/ext/ffi_c/libffi/include/tramp.h +45 -0
- data/ext/ffi_c/libffi/libtool-version +2 -2
- data/ext/ffi_c/libffi/ltmain.sh +512 -315
- 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 +1 -1
- data/ext/ffi_c/libffi/msvcc.sh +1 -1
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +146 -42
- data/ext/ffi_c/libffi/src/aarch64/internal.h +32 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +134 -42
- 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 +133 -47
- data/ext/ffi_c/libffi/src/dlmalloc.c +5 -0
- 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 +621 -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 +240 -65
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +7 -0
- data/ext/ffi_c/libffi/src/mips/n32.S +137 -28
- 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_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 +16 -0
- data/ext/ffi_c/libffi/src/tramp.c +716 -0
- data/ext/ffi_c/libffi/src/wasm32/ffi.c +934 -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 +43 -0
- 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 +127 -114
- data/ext/ffi_c/libffi/testsuite/Makefile.in +136 -120
- 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 +80 -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/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.gnu.mk +2 -2
- data/ext/ffi_c/rbffi.h +1 -1
- data/ffi.gemspec +3 -3
- data/lib/ffi/autopointer.rb +7 -22
- data/lib/ffi/compat.rb +43 -0
- data/lib/ffi/data_converter.rb +2 -2
- data/lib/ffi/dynamic_library.rb +89 -0
- data/lib/ffi/enum.rb +18 -11
- data/lib/ffi/ffi.rb +3 -0
- data/lib/ffi/function.rb +71 -0
- data/lib/ffi/library.rb +55 -71
- data/lib/ffi/library_path.rb +109 -0
- data/lib/ffi/managedstruct.rb +1 -1
- 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/struct.rb +2 -1
- data/lib/ffi/struct_layout.rb +1 -1
- data/lib/ffi/struct_layout_builder.rb +1 -1
- data/lib/ffi/tools/const_generator.rb +5 -4
- data/lib/ffi/types.rb +32 -6
- data/lib/ffi/variadic.rb +19 -8
- data/lib/ffi/version.rb +1 -1
- data/rakelib/ffi_gem_helper.rb +1 -1
- data/samples/hello_ractor.rb +11 -0
- data/samples/qsort_ractor.rb +28 -0
- data.tar.gz.sig +0 -0
- metadata +103 -28
- metadata.gz.sig +0 -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/ext/ffi_c/Struct.c
CHANGED
@@ -61,13 +61,29 @@ typedef struct InlineArray_ {
|
|
61
61
|
} InlineArray;
|
62
62
|
|
63
63
|
|
64
|
-
static void struct_mark(
|
65
|
-
static void
|
64
|
+
static void struct_mark(void *data);
|
65
|
+
static void struct_compact(void *data);
|
66
|
+
static void struct_free(void *data);
|
67
|
+
static size_t struct_memsize(const void *);
|
66
68
|
static VALUE struct_class_layout(VALUE klass);
|
67
|
-
static void struct_malloc(Struct* s);
|
68
|
-
static void inline_array_mark(
|
69
|
-
static void
|
70
|
-
|
69
|
+
static void struct_malloc(VALUE self, Struct* s);
|
70
|
+
static void inline_array_mark(void *);
|
71
|
+
static void inline_array_compact(void *);
|
72
|
+
static size_t inline_array_memsize(const void *);
|
73
|
+
static void store_reference_value(VALUE self, StructField* f, Struct* s, VALUE value);
|
74
|
+
|
75
|
+
const rb_data_type_t rbffi_struct_data_type = { /* extern */
|
76
|
+
.wrap_struct_name = "FFI::Struct",
|
77
|
+
.function = {
|
78
|
+
.dmark = struct_mark,
|
79
|
+
.dfree = struct_free,
|
80
|
+
.dsize = struct_memsize,
|
81
|
+
ffi_compact_callback( struct_compact )
|
82
|
+
},
|
83
|
+
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
84
|
+
// macro to update VALUE references, as to trigger write barriers.
|
85
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | FFI_RUBY_TYPED_FROZEN_SHAREABLE
|
86
|
+
};
|
71
87
|
VALUE rbffi_StructClass = Qnil;
|
72
88
|
|
73
89
|
VALUE rbffi_StructInlineArrayClass = Qnil;
|
@@ -79,17 +95,19 @@ static ID id_get = 0, id_put = 0, id_to_ptr = 0, id_to_s = 0, id_layout = 0;
|
|
79
95
|
static inline char*
|
80
96
|
memory_address(VALUE self)
|
81
97
|
{
|
82
|
-
|
98
|
+
AbstractMemory *mem;
|
99
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, mem);
|
100
|
+
return mem->address;
|
83
101
|
}
|
84
102
|
|
85
103
|
static VALUE
|
86
104
|
struct_allocate(VALUE klass)
|
87
105
|
{
|
88
106
|
Struct* s;
|
89
|
-
VALUE obj =
|
107
|
+
VALUE obj = TypedData_Make_Struct(klass, Struct, &rbffi_struct_data_type, s);
|
90
108
|
|
91
|
-
s->rbPointer
|
92
|
-
s->rbLayout
|
109
|
+
RB_OBJ_WRITE(obj, &s->rbPointer, Qnil);
|
110
|
+
RB_OBJ_WRITE(obj, &s->rbLayout, Qnil);
|
93
111
|
|
94
112
|
return obj;
|
95
113
|
}
|
@@ -108,28 +126,29 @@ struct_initialize(int argc, VALUE* argv, VALUE self)
|
|
108
126
|
VALUE rbPointer = Qnil, rest = Qnil, klass = CLASS_OF(self);
|
109
127
|
int nargs;
|
110
128
|
|
111
|
-
|
129
|
+
TypedData_Get_Struct(self, Struct, &rbffi_struct_data_type, s);
|
112
130
|
|
113
131
|
nargs = rb_scan_args(argc, argv, "01*", &rbPointer, &rest);
|
114
132
|
|
115
133
|
/* Call up into ruby code to adjust the layout */
|
116
134
|
if (nargs > 1) {
|
117
|
-
|
135
|
+
VALUE rbLayout = rb_apply(CLASS_OF(self), id_layout, rest);
|
136
|
+
RB_OBJ_WRITE(self, &s->rbLayout, rbLayout);
|
118
137
|
} else {
|
119
|
-
s->rbLayout
|
138
|
+
RB_OBJ_WRITE(self, &s->rbLayout, struct_class_layout(klass));
|
120
139
|
}
|
121
140
|
|
122
141
|
if (!rb_obj_is_kind_of(s->rbLayout, rbffi_StructLayoutClass)) {
|
123
142
|
rb_raise(rb_eRuntimeError, "Invalid Struct layout");
|
124
143
|
}
|
125
144
|
|
126
|
-
|
145
|
+
TypedData_Get_Struct(s->rbLayout, StructLayout, &rbffi_struct_layout_data_type, s->layout);
|
127
146
|
|
128
147
|
if (rbPointer != Qnil) {
|
129
148
|
s->pointer = MEMORY(rbPointer);
|
130
|
-
s->rbPointer
|
149
|
+
RB_OBJ_WRITE(self, &s->rbPointer, rbPointer);
|
131
150
|
} else {
|
132
|
-
struct_malloc(s);
|
151
|
+
struct_malloc(self, s);
|
133
152
|
}
|
134
153
|
|
135
154
|
return self;
|
@@ -146,13 +165,13 @@ struct_initialize_copy(VALUE self, VALUE other)
|
|
146
165
|
Struct* src;
|
147
166
|
Struct* dst;
|
148
167
|
|
149
|
-
|
150
|
-
|
168
|
+
TypedData_Get_Struct(self, Struct, &rbffi_struct_data_type, dst);
|
169
|
+
TypedData_Get_Struct(other, Struct, &rbffi_struct_data_type, src);
|
151
170
|
if (dst == src) {
|
152
171
|
return self;
|
153
172
|
}
|
154
173
|
|
155
|
-
dst->rbLayout
|
174
|
+
RB_OBJ_WRITE(self, &dst->rbLayout, src->rbLayout);
|
156
175
|
dst->layout = src->layout;
|
157
176
|
|
158
177
|
/*
|
@@ -161,17 +180,22 @@ struct_initialize_copy(VALUE self, VALUE other)
|
|
161
180
|
* be longer than just this struct.
|
162
181
|
*/
|
163
182
|
if (src->pointer->address != NULL) {
|
164
|
-
dst->rbPointer
|
183
|
+
RB_OBJ_WRITE(self, &dst->rbPointer, rbffi_MemoryPointer_NewInstance(1, src->layout->size, false));
|
165
184
|
dst->pointer = MEMORY(dst->rbPointer);
|
166
185
|
memcpy(dst->pointer->address, src->pointer->address, src->layout->size);
|
167
186
|
} else {
|
168
|
-
dst->rbPointer
|
187
|
+
RB_OBJ_WRITE(self, &dst->rbPointer, src->rbPointer);
|
169
188
|
dst->pointer = src->pointer;
|
170
189
|
}
|
171
190
|
|
172
191
|
if (src->layout->referenceFieldCount > 0) {
|
192
|
+
size_t index;
|
193
|
+
|
173
194
|
dst->rbReferences = ALLOC_N(VALUE, dst->layout->referenceFieldCount);
|
174
195
|
memcpy(dst->rbReferences, src->rbReferences, dst->layout->referenceFieldCount * sizeof(VALUE));
|
196
|
+
for ( index = 0; index < dst->layout->referenceFieldCount; index++) {
|
197
|
+
RB_OBJ_WRITTEN(self, Qundef, &dst->rbReferences[index]);
|
198
|
+
}
|
175
199
|
}
|
176
200
|
|
177
201
|
return self;
|
@@ -196,14 +220,15 @@ struct_class_layout(VALUE klass)
|
|
196
220
|
static StructLayout*
|
197
221
|
struct_layout(VALUE self)
|
198
222
|
{
|
199
|
-
Struct* s
|
223
|
+
Struct* s;
|
224
|
+
TypedData_Get_Struct(self, Struct, &rbffi_struct_data_type, s);
|
200
225
|
if (s->layout != NULL) {
|
201
226
|
return s->layout;
|
202
227
|
}
|
203
228
|
|
204
229
|
if (s->layout == NULL) {
|
205
|
-
s->rbLayout
|
206
|
-
|
230
|
+
RB_OBJ_WRITE(self, &s->rbLayout, struct_class_layout(CLASS_OF(self)));
|
231
|
+
TypedData_Get_Struct(s->rbLayout, StructLayout, &rbffi_struct_layout_data_type, s->layout);
|
207
232
|
}
|
208
233
|
|
209
234
|
return s->layout;
|
@@ -213,52 +238,76 @@ static Struct*
|
|
213
238
|
struct_validate(VALUE self)
|
214
239
|
{
|
215
240
|
Struct* s;
|
216
|
-
|
241
|
+
TypedData_Get_Struct(self, Struct, &rbffi_struct_data_type, s);
|
217
242
|
|
218
243
|
if (struct_layout(self) == NULL) {
|
219
244
|
rb_raise(rb_eRuntimeError, "struct layout == null");
|
220
245
|
}
|
221
246
|
|
222
247
|
if (s->pointer == NULL) {
|
223
|
-
struct_malloc(s);
|
248
|
+
struct_malloc(self, s);
|
224
249
|
}
|
225
250
|
|
226
251
|
return s;
|
227
252
|
}
|
228
253
|
|
229
254
|
static void
|
230
|
-
struct_malloc(Struct* s)
|
255
|
+
struct_malloc(VALUE self, Struct* s)
|
231
256
|
{
|
232
257
|
if (s->rbPointer == Qnil) {
|
233
|
-
s->rbPointer
|
234
|
-
|
258
|
+
RB_OBJ_WRITE(self, &s->rbPointer, rbffi_MemoryPointer_NewInstance(s->layout->size, 1, true));
|
235
259
|
} else if (!rb_obj_is_kind_of(s->rbPointer, rbffi_AbstractMemoryClass)) {
|
236
260
|
rb_raise(rb_eRuntimeError, "invalid pointer in struct");
|
237
261
|
}
|
238
262
|
|
239
|
-
s->
|
263
|
+
TypedData_Get_Struct(s->rbPointer, AbstractMemory, &rbffi_abstract_memory_data_type, s->pointer);
|
240
264
|
}
|
241
265
|
|
242
266
|
static void
|
243
|
-
struct_mark(
|
267
|
+
struct_mark(void *data)
|
244
268
|
{
|
245
|
-
|
246
|
-
|
269
|
+
Struct *s = (Struct *)data;
|
270
|
+
rb_gc_mark_movable(s->rbPointer);
|
271
|
+
rb_gc_mark_movable(s->rbLayout);
|
247
272
|
if (s->rbReferences != NULL) {
|
248
|
-
|
273
|
+
size_t index;
|
274
|
+
for (index = 0; index < s->layout->referenceFieldCount; index++) {
|
275
|
+
rb_gc_mark_movable(s->rbReferences[index]);
|
276
|
+
}
|
277
|
+
}
|
278
|
+
}
|
279
|
+
|
280
|
+
static void
|
281
|
+
struct_compact(void *data)
|
282
|
+
{
|
283
|
+
Struct *s = (Struct *)data;
|
284
|
+
ffi_gc_location(s->rbPointer);
|
285
|
+
ffi_gc_location(s->rbLayout);
|
286
|
+
if (s->rbReferences != NULL) {
|
287
|
+
size_t index;
|
288
|
+
for (index = 0; index < s->layout->referenceFieldCount; index++) {
|
289
|
+
ffi_gc_location(s->rbReferences[index]);
|
290
|
+
}
|
249
291
|
}
|
250
292
|
}
|
251
293
|
|
252
294
|
static void
|
253
|
-
struct_free(
|
295
|
+
struct_free(void *data)
|
254
296
|
{
|
297
|
+
Struct *s = (Struct *)data;
|
255
298
|
xfree(s->rbReferences);
|
256
299
|
xfree(s);
|
257
300
|
}
|
258
301
|
|
302
|
+
static size_t
|
303
|
+
struct_memsize(const void *data)
|
304
|
+
{
|
305
|
+
const Struct *s = (const Struct *)data;
|
306
|
+
return sizeof(Struct) + (s->layout->referenceFieldCount * sizeof(VALUE));
|
307
|
+
}
|
259
308
|
|
260
309
|
static void
|
261
|
-
store_reference_value(StructField* f, Struct* s, VALUE value)
|
310
|
+
store_reference_value(VALUE self, StructField* f, Struct* s, VALUE value)
|
262
311
|
{
|
263
312
|
if (unlikely(f->referenceIndex == -1)) {
|
264
313
|
rb_raise(rb_eRuntimeError, "put_reference_value called for non-reference type");
|
@@ -268,11 +317,11 @@ store_reference_value(StructField* f, Struct* s, VALUE value)
|
|
268
317
|
int i;
|
269
318
|
s->rbReferences = ALLOC_N(VALUE, s->layout->referenceFieldCount);
|
270
319
|
for (i = 0; i < s->layout->referenceFieldCount; ++i) {
|
271
|
-
s->rbReferences[i]
|
320
|
+
RB_OBJ_WRITE(self, &s->rbReferences[i], Qnil);
|
272
321
|
}
|
273
322
|
}
|
274
323
|
|
275
|
-
s->rbReferences[f->referenceIndex]
|
324
|
+
RB_OBJ_WRITE(self, &s->rbReferences[f->referenceIndex], value);
|
276
325
|
}
|
277
326
|
|
278
327
|
|
@@ -290,8 +339,8 @@ struct_field(Struct* s, VALUE fieldName)
|
|
290
339
|
rb_raise(rb_eArgError, "No such field '%s'", StringValueCStr(str));
|
291
340
|
}
|
292
341
|
/* Write the retrieved coder to the cache */
|
293
|
-
p_ce->fieldName
|
294
|
-
|
342
|
+
RB_OBJ_WRITE(s->rbLayout, &p_ce->fieldName, fieldName);
|
343
|
+
TypedData_Get_Struct(rbField, StructField, &rbffi_struct_field_data_type, p_ce->field);
|
295
344
|
}
|
296
345
|
|
297
346
|
return p_ce->field;
|
@@ -311,10 +360,7 @@ struct_aref(VALUE self, VALUE fieldName)
|
|
311
360
|
s = struct_validate(self);
|
312
361
|
|
313
362
|
f = struct_field(s, fieldName);
|
314
|
-
if (f->
|
315
|
-
return (*f->get)(f, s);
|
316
|
-
|
317
|
-
} else if (f->memoryOp != NULL) {
|
363
|
+
if (f->memoryOp != NULL) {
|
318
364
|
return (*f->memoryOp->get)(s->pointer, f->offset);
|
319
365
|
|
320
366
|
} else {
|
@@ -337,13 +383,11 @@ struct_aset(VALUE self, VALUE fieldName, VALUE value)
|
|
337
383
|
Struct* s;
|
338
384
|
StructField* f;
|
339
385
|
|
386
|
+
rb_check_frozen(self);
|
340
387
|
s = struct_validate(self);
|
341
388
|
|
342
389
|
f = struct_field(s, fieldName);
|
343
|
-
if (f->
|
344
|
-
(*f->put)(f, s, value);
|
345
|
-
|
346
|
-
} else if (f->memoryOp != NULL) {
|
390
|
+
if (f->memoryOp != NULL) {
|
347
391
|
|
348
392
|
(*f->memoryOp->put)(s->pointer, f->offset, value);
|
349
393
|
|
@@ -357,7 +401,7 @@ struct_aset(VALUE self, VALUE fieldName, VALUE value)
|
|
357
401
|
}
|
358
402
|
|
359
403
|
if (f->referenceRequired) {
|
360
|
-
store_reference_value(f, s, value);
|
404
|
+
store_reference_value(self, f, s, value);
|
361
405
|
}
|
362
406
|
|
363
407
|
return value;
|
@@ -376,6 +420,7 @@ struct_set_pointer(VALUE self, VALUE pointer)
|
|
376
420
|
StructLayout* layout;
|
377
421
|
AbstractMemory* memory;
|
378
422
|
|
423
|
+
rb_check_frozen(self);
|
379
424
|
if (!rb_obj_is_kind_of(pointer, rbffi_AbstractMemoryClass)) {
|
380
425
|
rb_raise(rb_eTypeError, "wrong argument type %s (expected Pointer or Buffer)",
|
381
426
|
rb_obj_classname(pointer));
|
@@ -383,8 +428,8 @@ struct_set_pointer(VALUE self, VALUE pointer)
|
|
383
428
|
}
|
384
429
|
|
385
430
|
|
386
|
-
|
387
|
-
|
431
|
+
TypedData_Get_Struct(self, Struct, &rbffi_struct_data_type, s);
|
432
|
+
TypedData_Get_Struct(pointer, AbstractMemory, &rbffi_abstract_memory_data_type, memory);
|
388
433
|
layout = struct_layout(self);
|
389
434
|
|
390
435
|
if ((int) layout->base.ffiType->size > memory->size) {
|
@@ -393,7 +438,7 @@ struct_set_pointer(VALUE self, VALUE pointer)
|
|
393
438
|
}
|
394
439
|
|
395
440
|
s->pointer = MEMORY(pointer);
|
396
|
-
s->rbPointer
|
441
|
+
RB_OBJ_WRITE(self, &s->rbPointer, pointer);
|
397
442
|
rb_ivar_set(self, id_pointer_ivar, pointer);
|
398
443
|
|
399
444
|
return self;
|
@@ -409,7 +454,7 @@ struct_get_pointer(VALUE self)
|
|
409
454
|
{
|
410
455
|
Struct* s;
|
411
456
|
|
412
|
-
|
457
|
+
TypedData_Get_Struct(self, Struct, &rbffi_struct_data_type, s);
|
413
458
|
|
414
459
|
return s->rbPointer;
|
415
460
|
}
|
@@ -424,15 +469,16 @@ static VALUE
|
|
424
469
|
struct_set_layout(VALUE self, VALUE layout)
|
425
470
|
{
|
426
471
|
Struct* s;
|
427
|
-
|
472
|
+
TypedData_Get_Struct(self, Struct, &rbffi_struct_data_type, s);
|
428
473
|
|
474
|
+
rb_check_frozen(self);
|
429
475
|
if (!rb_obj_is_kind_of(layout, rbffi_StructLayoutClass)) {
|
430
476
|
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
|
431
477
|
rb_obj_classname(layout), rb_class2name(rbffi_StructLayoutClass));
|
432
478
|
return Qnil;
|
433
479
|
}
|
434
480
|
|
435
|
-
|
481
|
+
TypedData_Get_Struct(layout, StructLayout, &rbffi_struct_layout_data_type, s->layout);
|
436
482
|
rb_ivar_set(self, id_layout_ivar, layout);
|
437
483
|
|
438
484
|
return self;
|
@@ -448,7 +494,7 @@ struct_get_layout(VALUE self)
|
|
448
494
|
{
|
449
495
|
Struct* s;
|
450
496
|
|
451
|
-
|
497
|
+
TypedData_Get_Struct(self, Struct, &rbffi_struct_data_type, s);
|
452
498
|
|
453
499
|
return s->rbLayout;
|
454
500
|
}
|
@@ -463,7 +509,7 @@ struct_null_p(VALUE self)
|
|
463
509
|
{
|
464
510
|
Struct* s;
|
465
511
|
|
466
|
-
|
512
|
+
TypedData_Get_Struct(self, Struct, &rbffi_struct_data_type, s);
|
467
513
|
|
468
514
|
return s->pointer->address == NULL ? Qtrue : Qfalse;
|
469
515
|
}
|
@@ -476,7 +522,7 @@ struct_order(int argc, VALUE* argv, VALUE self)
|
|
476
522
|
{
|
477
523
|
Struct* s;
|
478
524
|
|
479
|
-
|
525
|
+
TypedData_Get_Struct(self, Struct, &rbffi_struct_data_type, s);
|
480
526
|
if (argc == 0) {
|
481
527
|
return rb_funcall(s->rbPointer, rb_intern("order"), 0);
|
482
528
|
|
@@ -489,24 +535,52 @@ struct_order(int argc, VALUE* argv, VALUE self)
|
|
489
535
|
}
|
490
536
|
}
|
491
537
|
|
538
|
+
static const rb_data_type_t inline_array_data_type = {
|
539
|
+
.wrap_struct_name = "FFI::Struct::InlineArray",
|
540
|
+
.function = {
|
541
|
+
.dmark = inline_array_mark,
|
542
|
+
.dfree = RUBY_TYPED_DEFAULT_FREE,
|
543
|
+
.dsize = inline_array_memsize,
|
544
|
+
ffi_compact_callback( inline_array_compact )
|
545
|
+
},
|
546
|
+
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
547
|
+
// macro to update VALUE references, as to trigger write barriers.
|
548
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | FFI_RUBY_TYPED_FROZEN_SHAREABLE
|
549
|
+
};
|
550
|
+
|
492
551
|
static VALUE
|
493
552
|
inline_array_allocate(VALUE klass)
|
494
553
|
{
|
495
554
|
InlineArray* array;
|
496
555
|
VALUE obj;
|
497
556
|
|
498
|
-
obj =
|
499
|
-
array->
|
500
|
-
array->
|
557
|
+
obj = TypedData_Make_Struct(klass, InlineArray, &inline_array_data_type, array);
|
558
|
+
RB_OBJ_WRITE(obj, &array->rbMemory, Qnil);
|
559
|
+
RB_OBJ_WRITE(obj, &array->rbField, Qnil);
|
501
560
|
|
502
561
|
return obj;
|
503
562
|
}
|
504
563
|
|
505
564
|
static void
|
506
|
-
inline_array_mark(
|
565
|
+
inline_array_mark(void *data)
|
566
|
+
{
|
567
|
+
InlineArray *array = (InlineArray *)data;
|
568
|
+
rb_gc_mark_movable(array->rbField);
|
569
|
+
rb_gc_mark_movable(array->rbMemory);
|
570
|
+
}
|
571
|
+
|
572
|
+
static void
|
573
|
+
inline_array_compact(void *data)
|
574
|
+
{
|
575
|
+
InlineArray *array = (InlineArray *)data;
|
576
|
+
ffi_gc_location(array->rbField);
|
577
|
+
ffi_gc_location(array->rbMemory);
|
578
|
+
}
|
579
|
+
|
580
|
+
static size_t
|
581
|
+
inline_array_memsize(const void *data)
|
507
582
|
{
|
508
|
-
|
509
|
-
rb_gc_mark(array->rbMemory);
|
583
|
+
return sizeof(InlineArray);
|
510
584
|
}
|
511
585
|
|
512
586
|
/*
|
@@ -521,14 +595,14 @@ inline_array_initialize(VALUE self, VALUE rbMemory, VALUE rbField)
|
|
521
595
|
{
|
522
596
|
InlineArray* array;
|
523
597
|
|
524
|
-
|
525
|
-
array->rbMemory
|
526
|
-
array->rbField
|
598
|
+
TypedData_Get_Struct(self, InlineArray, &inline_array_data_type, array);
|
599
|
+
RB_OBJ_WRITE(self, &array->rbMemory, rbMemory);
|
600
|
+
RB_OBJ_WRITE(self, &array->rbField, rbField);
|
527
601
|
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
602
|
+
TypedData_Get_Struct(rbMemory, AbstractMemory, &rbffi_abstract_memory_data_type, array->memory);
|
603
|
+
TypedData_Get_Struct(rbField, StructField, &rbffi_struct_field_data_type, array->field);
|
604
|
+
TypedData_Get_Struct(array->field->rbType, ArrayType, &rbffi_array_type_data_type, array->arrayType);
|
605
|
+
TypedData_Get_Struct(array->arrayType->rbComponentType, Type, &rbffi_type_data_type, array->componentType);
|
532
606
|
|
533
607
|
array->op = get_memory_op(array->componentType);
|
534
608
|
if (array->op == NULL && array->componentType->nativeType == NATIVE_MAPPED) {
|
@@ -550,7 +624,7 @@ inline_array_size(VALUE self)
|
|
550
624
|
{
|
551
625
|
InlineArray* array;
|
552
626
|
|
553
|
-
|
627
|
+
TypedData_Get_Struct(self, InlineArray, &inline_array_data_type, array);
|
554
628
|
|
555
629
|
return UINT2NUM(((ArrayType *) array->field->type)->length);
|
556
630
|
}
|
@@ -575,7 +649,7 @@ inline_array_aref(VALUE self, VALUE rbIndex)
|
|
575
649
|
{
|
576
650
|
InlineArray* array;
|
577
651
|
|
578
|
-
|
652
|
+
TypedData_Get_Struct(self, InlineArray, &inline_array_data_type, array);
|
579
653
|
|
580
654
|
if (array->op != NULL) {
|
581
655
|
VALUE rbNativeValue = array->op->get(array->memory,
|
@@ -611,7 +685,8 @@ inline_array_aset(VALUE self, VALUE rbIndex, VALUE rbValue)
|
|
611
685
|
{
|
612
686
|
InlineArray* array;
|
613
687
|
|
614
|
-
|
688
|
+
rb_check_frozen(self);
|
689
|
+
TypedData_Get_Struct(self, InlineArray, &inline_array_data_type, array);
|
615
690
|
|
616
691
|
if (array->op != NULL) {
|
617
692
|
if (unlikely(array->componentType->nativeType == NATIVE_MAPPED)) {
|
@@ -633,7 +708,7 @@ inline_array_aset(VALUE self, VALUE rbIndex, VALUE rbValue)
|
|
633
708
|
checkWrite(array->memory);
|
634
709
|
checkBounds(array->memory, offset, array->componentType->ffiType->size);
|
635
710
|
|
636
|
-
|
711
|
+
TypedData_Get_Struct(rbValue, Struct, &rbffi_struct_data_type, s);
|
637
712
|
checkRead(s->pointer);
|
638
713
|
checkBounds(s->pointer, 0, array->componentType->ffiType->size);
|
639
714
|
|
@@ -641,7 +716,7 @@ inline_array_aset(VALUE self, VALUE rbIndex, VALUE rbValue)
|
|
641
716
|
|
642
717
|
} else {
|
643
718
|
ArrayType* arrayType;
|
644
|
-
|
719
|
+
TypedData_Get_Struct(array->field->rbType, ArrayType, &rbffi_array_type_data_type, arrayType);
|
645
720
|
|
646
721
|
rb_raise(rb_eArgError, "set not supported for %s", rb_obj_classname(arrayType->rbComponentType));
|
647
722
|
return Qnil;
|
@@ -661,7 +736,7 @@ inline_array_each(VALUE self)
|
|
661
736
|
|
662
737
|
int i;
|
663
738
|
|
664
|
-
|
739
|
+
TypedData_Get_Struct(self, InlineArray, &inline_array_data_type, array);
|
665
740
|
|
666
741
|
for (i = 0; i < array->length; ++i) {
|
667
742
|
rb_yield(inline_array_aref(self, INT2FIX(i)));
|
@@ -682,7 +757,7 @@ inline_array_to_a(VALUE self)
|
|
682
757
|
VALUE obj;
|
683
758
|
int i;
|
684
759
|
|
685
|
-
|
760
|
+
TypedData_Get_Struct(self, InlineArray, &inline_array_data_type, array);
|
686
761
|
obj = rb_ary_new2(array->length);
|
687
762
|
|
688
763
|
|
@@ -705,7 +780,7 @@ inline_array_to_s(VALUE self)
|
|
705
780
|
InlineArray* array;
|
706
781
|
VALUE argv[2];
|
707
782
|
|
708
|
-
|
783
|
+
TypedData_Get_Struct(self, InlineArray, &inline_array_data_type, array);
|
709
784
|
|
710
785
|
if (array->componentType->nativeType != NATIVE_INT8 && array->componentType->nativeType != NATIVE_UINT8) {
|
711
786
|
VALUE dummy = Qnil;
|
@@ -728,7 +803,7 @@ inline_array_to_ptr(VALUE self)
|
|
728
803
|
{
|
729
804
|
InlineArray* array;
|
730
805
|
|
731
|
-
|
806
|
+
TypedData_Get_Struct(self, InlineArray, &inline_array_data_type, array);
|
732
807
|
|
733
808
|
return rb_funcall(array->rbMemory, rb_intern("slice"), 2,
|
734
809
|
UINT2NUM(array->field->offset), UINT2NUM(array->arrayType->base.ffiType->size));
|
data/ext/ffi_c/Struct.h
CHANGED
@@ -42,6 +42,9 @@ extern "C" {
|
|
42
42
|
|
43
43
|
extern void rbffi_Struct_Init(VALUE ffiModule);
|
44
44
|
extern void rbffi_StructLayout_Init(VALUE ffiModule);
|
45
|
+
extern const rb_data_type_t rbffi_struct_layout_data_type;
|
46
|
+
extern const rb_data_type_t rbffi_struct_field_data_type;
|
47
|
+
|
45
48
|
typedef struct StructField_ StructField;
|
46
49
|
typedef struct StructLayout_ StructLayout;
|
47
50
|
typedef struct Struct_ Struct;
|
@@ -56,9 +59,6 @@ extern "C" {
|
|
56
59
|
VALUE rbType;
|
57
60
|
VALUE rbName;
|
58
61
|
|
59
|
-
VALUE (*get)(StructField* field, Struct* s);
|
60
|
-
void (*put)(StructField* field, Struct* s, VALUE value);
|
61
|
-
|
62
62
|
MemoryOp* memoryOp;
|
63
63
|
};
|
64
64
|
|
@@ -75,11 +75,12 @@ extern "C" {
|
|
75
75
|
* This avoids full ruby hash lookups for repeated lookups.
|
76
76
|
*/
|
77
77
|
#define FIELD_CACHE_LOOKUP(this, sym) ( &(this)->cache_row[((sym) >> 8) & 0xff] )
|
78
|
+
#define FIELD_CACHE_ROWS 0x100
|
78
79
|
|
79
80
|
struct field_cache_entry {
|
80
81
|
VALUE fieldName;
|
81
82
|
StructField *field;
|
82
|
-
} cache_row[
|
83
|
+
} cache_row[FIELD_CACHE_ROWS];
|
83
84
|
|
84
85
|
/** The number of reference tracking fields in this struct */
|
85
86
|
int referenceFieldCount;
|
@@ -98,6 +99,8 @@ extern "C" {
|
|
98
99
|
VALUE rbPointer;
|
99
100
|
};
|
100
101
|
|
102
|
+
extern const rb_data_type_t rbffi_struct_data_type;
|
103
|
+
extern const rb_data_type_t rbffi_struct_field_data_type;
|
101
104
|
extern VALUE rbffi_StructClass, rbffi_StructLayoutClass;
|
102
105
|
extern VALUE rbffi_StructLayoutFieldClass, rbffi_StructLayoutFunctionFieldClass;
|
103
106
|
extern VALUE rbffi_StructLayoutArrayFieldClass;
|