ffi 1.1.2 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +456 -0
- data/COPYING +49 -0
- data/Gemfile +21 -0
- data/LICENSE +21 -11
- data/LICENSE.SPECS +22 -0
- data/README.md +137 -0
- data/Rakefile +166 -156
- data/ext/ffi_c/AbstractMemory.c +240 -140
- data/ext/ffi_c/AbstractMemory.h +25 -15
- data/ext/ffi_c/ArrayType.c +78 -29
- data/ext/ffi_c/ArrayType.h +22 -12
- data/ext/ffi_c/Buffer.c +121 -60
- data/ext/ffi_c/Call.c +184 -137
- data/ext/ffi_c/Call.h +46 -22
- data/ext/ffi_c/ClosurePool.c +101 -43
- data/ext/ffi_c/ClosurePool.h +24 -13
- data/ext/ffi_c/DynamicLibrary.c +139 -57
- data/ext/ffi_c/DynamicLibrary.h +70 -12
- data/ext/ffi_c/Function.c +372 -273
- data/ext/ffi_c/Function.h +25 -20
- data/ext/ffi_c/FunctionInfo.c +135 -49
- data/ext/ffi_c/LastError.c +97 -30
- data/ext/ffi_c/LastError.h +21 -12
- data/ext/ffi_c/LongDouble.c +15 -9
- data/ext/ffi_c/LongDouble.h +21 -16
- data/ext/ffi_c/MappedType.c +88 -38
- data/ext/ffi_c/MappedType.h +21 -14
- data/ext/ffi_c/MemoryPointer.c +91 -38
- data/ext/ffi_c/MemoryPointer.h +22 -19
- data/ext/ffi_c/MethodHandle.c +52 -51
- data/ext/ffi_c/MethodHandle.h +24 -14
- data/ext/ffi_c/Platform.c +28 -62
- data/ext/ffi_c/Platform.h +21 -12
- data/ext/ffi_c/Pointer.c +145 -86
- data/ext/ffi_c/Pointer.h +23 -19
- data/ext/ffi_c/Struct.c +363 -163
- data/ext/ffi_c/Struct.h +39 -21
- data/ext/ffi_c/StructByValue.c +72 -37
- data/ext/ffi_c/StructByValue.h +21 -12
- data/ext/ffi_c/StructLayout.c +308 -94
- data/ext/ffi_c/Thread.c +73 -270
- data/ext/ffi_c/Thread.h +32 -35
- data/ext/ffi_c/Type.c +147 -84
- data/ext/ffi_c/Type.h +27 -11
- data/ext/ffi_c/Types.c +40 -24
- data/ext/ffi_c/Types.h +24 -21
- data/ext/ffi_c/Variadic.c +148 -64
- data/ext/ffi_c/compat.h +45 -37
- data/ext/ffi_c/extconf.rb +86 -32
- data/ext/ffi_c/ffi.c +32 -21
- 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 +84 -0
- data/ext/ffi_c/libffi/.ci/ar-lib +270 -0
- data/ext/ffi_c/libffi/.ci/bfin-sim.exp +58 -0
- data/ext/ffi_c/libffi/.ci/build-cross-in-container.sh +18 -0
- data/ext/ffi_c/libffi/.ci/build-in-container.sh +10 -0
- data/ext/ffi_c/libffi/.ci/build.sh +124 -0
- data/ext/ffi_c/libffi/.ci/compile +351 -0
- data/ext/ffi_c/libffi/.ci/install.sh +78 -0
- data/ext/ffi_c/libffi/.ci/m32r-sim.exp +58 -0
- data/ext/ffi_c/libffi/.ci/moxie-sim.exp +60 -0
- data/ext/ffi_c/libffi/.ci/msvs-detect +1103 -0
- data/ext/ffi_c/libffi/.ci/or1k-sim.exp +58 -0
- data/ext/ffi_c/libffi/.ci/powerpc-eabisim.exp +58 -0
- data/ext/ffi_c/libffi/.ci/site.exp +29 -0
- data/ext/ffi_c/libffi/.ci/wine-sim.exp +55 -0
- data/ext/ffi_c/libffi/.circleci/config.yml +156 -0
- data/ext/ffi_c/libffi/.gitattributes +4 -0
- data/ext/ffi_c/libffi/.github/issue_template.md +10 -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 +46 -0
- data/ext/ffi_c/libffi/{ChangeLog → ChangeLog.old} +6366 -3559
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +353 -0
- data/ext/ffi_c/libffi/Makefile.am +131 -170
- data/ext/ffi_c/libffi/Makefile.in +1317 -1010
- data/ext/ffi_c/libffi/README.md +531 -0
- data/ext/ffi_c/libffi/acinclude.m4 +289 -4
- data/ext/ffi_c/libffi/autogen.sh +2 -0
- data/ext/ffi_c/libffi/compile +222 -17
- data/ext/ffi_c/libffi/config.guess +1033 -780
- data/ext/ffi_c/libffi/config.sub +1393 -1206
- data/ext/ffi_c/libffi/configure +16340 -10740
- data/ext/ffi_c/libffi/configure.ac +226 -271
- data/ext/ffi_c/libffi/configure.host +330 -4
- data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
- data/ext/ffi_c/libffi/doc/Makefile.in +818 -0
- data/ext/ffi_c/libffi/doc/libffi.texi +525 -79
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +41 -52
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +312 -0
- data/ext/ffi_c/libffi/include/Makefile.am +3 -3
- data/ext/ffi_c/libffi/include/Makefile.in +201 -79
- data/ext/ffi_c/libffi/include/ffi.h.in +190 -99
- data/ext/ffi_c/libffi/include/ffi_cfi.h +76 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +72 -14
- data/ext/ffi_c/libffi/include/tramp.h +45 -0
- data/ext/ffi_c/libffi/install-sh +231 -210
- data/ext/ffi_c/libffi/libffi.map.in +81 -0
- data/ext/ffi_c/libffi/libffi.pc.in +3 -2
- data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +997 -0
- data/ext/ffi_c/libffi/libtool-ldflags +106 -0
- data/ext/ffi_c/libffi/libtool-version +2 -2
- data/ext/ffi_c/libffi/ltmain.sh +3868 -2068
- data/ext/ffi_c/libffi/m4/asmcfi.m4 +13 -0
- data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +50 -0
- data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +47 -25
- data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +110 -147
- data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +53 -0
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +75 -19
- data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +8 -29
- data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +11 -9
- data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +104 -52
- data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +18 -8
- data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
- data/ext/ffi_c/libffi/m4/ax_require_defined.m4 +37 -0
- data/ext/ffi_c/libffi/make_sunver.pl +333 -0
- data/ext/ffi_c/libffi/man/Makefile.am +2 -2
- data/ext/ffi_c/libffi/man/Makefile.in +156 -57
- data/ext/ffi_c/libffi/man/ffi.3 +10 -0
- data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +6 -4
- data/ext/ffi_c/libffi/man/ffi_prep_cif_var.3 +73 -0
- data/ext/ffi_c/libffi/missing +153 -314
- 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/{include/ffi.h.vc64 → msvc_build/aarch64/aarch64_include/ffi.h} +151 -67
- data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/fficonfig.h +219 -0
- data/ext/ffi_c/libffi/msvcc.sh +176 -20
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +1142 -0
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +97 -0
- data/ext/ffi_c/libffi/src/aarch64/internal.h +100 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +695 -0
- data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
- data/ext/ffi_c/libffi/src/alpha/ffi.c +335 -98
- data/ext/ffi_c/libffi/src/alpha/ffitarget.h +10 -1
- data/ext/ffi_c/libffi/src/alpha/internal.h +23 -0
- data/ext/ffi_c/libffi/src/alpha/osf.S +161 -266
- data/ext/ffi_c/libffi/src/arc/arcompact.S +210 -0
- data/ext/ffi_c/libffi/src/arc/ffi.c +443 -0
- data/ext/ffi_c/libffi/src/arc/ffitarget.h +67 -0
- data/ext/ffi_c/libffi/src/arm/ffi.c +706 -513
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +32 -8
- data/ext/ffi_c/libffi/src/arm/internal.h +17 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +372 -413
- data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
- data/ext/ffi_c/libffi/src/avr32/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/bfin/ffi.c +196 -0
- data/ext/ffi_c/libffi/src/bfin/ffitarget.h +43 -0
- data/ext/ffi_c/libffi/src/bfin/sysv.S +179 -0
- data/ext/ffi_c/libffi/src/closures.c +565 -73
- data/ext/ffi_c/libffi/src/cris/ffi.c +10 -7
- data/ext/ffi_c/libffi/src/cris/ffitarget.h +6 -1
- 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/debug.c +8 -3
- data/ext/ffi_c/libffi/src/dlmalloc.c +23 -13
- data/ext/ffi_c/libffi/src/frv/ffi.c +2 -2
- data/ext/ffi_c/libffi/src/frv/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/ia64/ffi.c +47 -13
- data/ext/ffi_c/libffi/src/ia64/ffitarget.h +8 -2
- data/ext/ffi_c/libffi/src/ia64/unix.S +28 -3
- data/ext/ffi_c/libffi/src/java_raw_api.c +23 -5
- 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/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 +32 -15
- data/ext/ffi_c/libffi/src/m32r/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/m68k/ffi.c +87 -13
- data/ext/ffi_c/libffi/src/m68k/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/m68k/sysv.S +119 -32
- data/ext/ffi_c/libffi/src/m88k/ffi.c +400 -0
- data/ext/ffi_c/libffi/src/m88k/ffitarget.h +49 -0
- data/ext/ffi_c/libffi/src/m88k/obsd.S +209 -0
- data/ext/ffi_c/libffi/src/metag/ffi.c +330 -0
- data/ext/ffi_c/libffi/{fficonfig.hw → src/metag/ffitarget.h} +22 -26
- data/ext/ffi_c/libffi/src/metag/sysv.S +311 -0
- data/ext/ffi_c/libffi/src/microblaze/ffi.c +321 -0
- data/ext/ffi_c/libffi/src/microblaze/ffitarget.h +53 -0
- data/ext/ffi_c/libffi/src/microblaze/sysv.S +302 -0
- data/ext/ffi_c/libffi/src/mips/ffi.c +382 -101
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +23 -14
- data/ext/ffi_c/libffi/src/mips/n32.S +321 -89
- data/ext/ffi_c/libffi/src/mips/o32.S +211 -31
- data/ext/ffi_c/libffi/src/moxie/eabi.S +55 -82
- data/ext/ffi_c/libffi/src/moxie/ffi.c +100 -66
- data/ext/ffi_c/libffi/src/moxie/ffitarget.h +52 -0
- data/ext/ffi_c/libffi/src/nios2/ffi.c +304 -0
- data/ext/ffi_c/libffi/src/nios2/ffitarget.h +52 -0
- data/ext/ffi_c/libffi/src/nios2/sysv.S +136 -0
- data/ext/ffi_c/libffi/src/or1k/ffi.c +341 -0
- data/ext/ffi_c/libffi/src/or1k/ffitarget.h +58 -0
- data/ext/ffi_c/libffi/src/or1k/sysv.S +107 -0
- data/ext/ffi_c/libffi/src/pa/ffi.c +62 -108
- data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +28 -12
- data/ext/ffi_c/libffi/src/pa/hpux32.S +87 -38
- data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
- data/ext/ffi_c/libffi/src/pa/linux.S +109 -39
- data/ext/ffi_c/libffi/src/powerpc/aix.S +245 -7
- data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +253 -4
- data/ext/ffi_c/libffi/src/powerpc/asm.h +2 -2
- data/ext/ffi_c/libffi/src/powerpc/darwin.S +2 -7
- data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +22 -26
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +105 -1378
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +157 -52
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1153 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +105 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +923 -0
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +110 -45
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +191 -85
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +438 -108
- data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +138 -68
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +73 -119
- data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
- data/ext/ffi_c/libffi/src/prep_cif.c +131 -25
- data/ext/ffi_c/libffi/src/raw_api.c +18 -5
- data/ext/ffi_c/libffi/src/riscv/ffi.c +514 -0
- data/ext/ffi_c/libffi/src/riscv/ffitarget.h +69 -0
- data/ext/ffi_c/libffi/src/riscv/sysv.S +293 -0
- data/ext/ffi_c/libffi/src/s390/ffi.c +294 -318
- data/ext/ffi_c/libffi/src/s390/ffitarget.h +9 -1
- data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
- data/ext/ffi_c/libffi/src/s390/sysv.S +257 -366
- data/ext/ffi_c/libffi/src/sh/ffi.c +4 -3
- data/ext/ffi_c/libffi/src/sh/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/sh64/ffi.c +3 -2
- data/ext/ffi_c/libffi/src/sh64/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/sparc/ffi.c +326 -527
- data/ext/ffi_c/libffi/src/sparc/ffi64.c +630 -0
- data/ext/ffi_c/libffi/src/sparc/ffitarget.h +20 -7
- data/ext/ffi_c/libffi/src/sparc/internal.h +26 -0
- data/ext/ffi_c/libffi/src/sparc/v8.S +364 -234
- data/ext/ffi_c/libffi/src/sparc/v9.S +340 -207
- data/ext/ffi_c/libffi/src/tile/ffi.c +355 -0
- data/ext/ffi_c/libffi/src/tile/ffitarget.h +65 -0
- data/ext/ffi_c/libffi/src/tile/tile.S +360 -0
- data/ext/ffi_c/libffi/src/tramp.c +716 -0
- data/ext/ffi_c/libffi/src/types.c +48 -19
- data/ext/ffi_c/libffi/src/vax/elfbsd.S +195 -0
- data/ext/ffi_c/libffi/src/vax/ffi.c +276 -0
- data/ext/ffi_c/libffi/src/vax/ffitarget.h +49 -0
- 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/asmnames.h +30 -0
- data/ext/ffi_c/libffi/src/x86/ffi.c +686 -498
- data/ext/ffi_c/libffi/src/x86/ffi64.c +444 -129
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +79 -36
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +361 -0
- data/ext/ffi_c/libffi/src/x86/internal.h +43 -0
- data/ext/ffi_c/libffi/src/x86/internal64.h +36 -0
- data/ext/ffi_c/libffi/src/x86/sysv.S +1198 -394
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +998 -0
- data/ext/ffi_c/libffi/src/x86/unix64.S +585 -300
- data/ext/ffi_c/libffi/src/x86/win64.S +244 -458
- data/ext/ffi_c/libffi/src/x86/win64_intel.S +238 -0
- data/ext/ffi_c/libffi/src/xtensa/ffi.c +306 -0
- data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +57 -0
- data/ext/ffi_c/libffi/src/xtensa/sysv.S +268 -0
- data/ext/ffi_c/libffi/stamp-h.in +1 -0
- data/ext/ffi_c/libffi/testsuite/Makefile.am +80 -73
- data/ext/ffi_c/libffi/testsuite/Makefile.in +233 -117
- 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 +360 -28
- data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +22 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +28 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/README +78 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/alignof.h +50 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +63 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1746 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2885 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +747 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/align_mixed.c +46 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/align_stdcall.c +46 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +28 -6
- 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/err_bad_typedef.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +52 -42
- data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +3 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +15 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +4 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +110 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +6 -16
- data/ext/ffi_c/libffi/testsuite/libffi.call/many2.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_double.c +70 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_mixed.c +78 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +0 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/offsets.c +46 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/pr1172638.c +127 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +1 -1
- 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 +9 -10
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +55 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +9 -7
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +7 -7
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +7 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +9 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +9 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +9 -8
- 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/uninitialized.c +61 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +78 -0
- 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 +134 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +134 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +140 -0
- 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 +3 -2
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +21 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +7 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call/closure_stdcall.c → libffi.closures/closure_simple.c} +13 -16
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +22 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +26 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +28 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +33 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +8 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +25 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +40 -8
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +17 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +23 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +17 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +17 -4
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +113 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +26 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +17 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +33 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +29 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +32 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +28 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +43 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +29 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +18 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +18 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +18 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +24 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +44 -31
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +44 -9
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +22 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +22 -7
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +22 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +22 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +7 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +19 -10
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +4 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +14 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +32 -12
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_args.c +70 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c +55 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +5 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +6 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +6 -2
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +6 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +21 -9
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +3 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +125 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +3 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +49 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +7 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +41 -40
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +38 -15
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +9 -9
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +19 -6
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +137 -0
- 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.call → libffi.closures}/nested_struct2.c +15 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +15 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +14 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +14 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +17 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +14 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +17 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +17 -6
- 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.call → libffi.closures}/stret_large.c +7 -7
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +7 -7
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +6 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +6 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +8 -3
- data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.closures}/unwindtest.cc +4 -10
- data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.closures}/unwindtest_ffi_call.cc +4 -2
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex.inc +91 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct.inc +71 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va.inc +80 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_float.c +16 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.special/special.exp → libffi.complex/complex.exp} +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc +51 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_double.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_float.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/ffitest.h +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex.inc +78 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc +37 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1.inc +41 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2.inc +44 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/aa-direct.c +34 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/closure1.c +28 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/ffitest.h +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/go.exp +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/static-chain.h +19 -0
- data/ext/ffi_c/libffi.bsd.mk +13 -7
- data/ext/ffi_c/libffi.darwin.mk +25 -13
- data/ext/ffi_c/libffi.gnu.mk +4 -3
- data/ext/ffi_c/libffi.mk +11 -6
- data/ext/ffi_c/libffi.vc.mk +1 -1
- data/ext/ffi_c/libffi.vc64.mk +1 -1
- data/ext/ffi_c/rbffi.h +23 -15
- data/ext/ffi_c/rbffi_endian.h +11 -2
- data/ffi.gemspec +42 -0
- data/lib/ffi/abstract_memory.rb +44 -0
- data/lib/ffi/autopointer.rb +65 -68
- data/lib/ffi/compat.rb +43 -0
- data/lib/ffi/data_converter.rb +67 -0
- data/lib/ffi/dynamic_library.rb +118 -0
- data/lib/ffi/enum.rb +166 -25
- data/lib/ffi/errno.rb +21 -11
- data/lib/ffi/ffi.rb +28 -11
- data/lib/ffi/function.rb +71 -0
- data/lib/ffi/io.rb +25 -15
- data/lib/ffi/library.rb +227 -136
- data/lib/ffi/library_path.rb +109 -0
- data/lib/ffi/managedstruct.rb +64 -35
- 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 +181 -0
- data/lib/ffi/platform/aarch64-linux/types.conf +175 -0
- data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
- data/lib/ffi/platform/aarch64-windows/types.conf +52 -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/hppa1.1-linux/types.conf +178 -0
- data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
- data/lib/ffi/platform/i386-cygwin/types.conf +3 -0
- 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-linux/types.conf +77 -77
- data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
- data/lib/ffi/platform/i386-openbsd/types.conf +89 -87
- 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/loongarch64-linux/types.conf +141 -0
- data/lib/ffi/platform/mips-linux/types.conf +79 -79
- data/lib/ffi/platform/mips64-linux/types.conf +104 -0
- data/lib/ffi/platform/mips64el-linux/types.conf +104 -0
- data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
- data/lib/ffi/platform/mipsisa32r6-linux/types.conf +102 -0
- data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +102 -0
- data/lib/ffi/platform/mipsisa64r6-linux/types.conf +104 -0
- data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +104 -0
- 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 +104 -0
- 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/sparcv9-linux/types.conf +102 -0
- data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
- data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
- data/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +93 -63
- data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
- data/lib/ffi/platform/x86_64-freebsd/types.conf +90 -88
- 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 -87
- data/lib/ffi/platform/x86_64-openbsd/types.conf +100 -92
- data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
- data/lib/ffi/platform/x86_64-windows/types.conf +52 -0
- data/lib/ffi/platform.rb +91 -34
- data/lib/ffi/pointer.rb +78 -33
- data/lib/ffi/struct.rb +100 -66
- data/lib/ffi/struct_by_reference.rb +72 -0
- data/lib/ffi/struct_layout.rb +96 -0
- data/lib/ffi/struct_layout_builder.rb +84 -19
- data/lib/ffi/tools/const_generator.rb +11 -8
- data/lib/ffi/tools/generator.rb +48 -1
- data/lib/ffi/tools/generator_task.rb +13 -16
- data/lib/ffi/tools/struct_generator.rb +6 -5
- data/lib/ffi/tools/types_generator.rb +14 -10
- data/lib/ffi/types.rb +96 -51
- data/lib/ffi/union.rb +23 -12
- data/lib/ffi/variadic.rb +44 -29
- data/lib/ffi/version.rb +3 -0
- data/lib/ffi.rb +20 -8
- data/rakelib/ffi_gem_helper.rb +65 -0
- data/samples/getlogin.rb +8 -0
- data/samples/getpid.rb +8 -0
- data/samples/gettimeofday.rb +18 -0
- data/samples/hello.rb +8 -0
- data/samples/hello_ractor.rb +11 -0
- data/samples/inotify.rb +60 -0
- data/samples/pty.rb +75 -0
- data/samples/qsort.rb +20 -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 +508 -268
- metadata.gz.sig +1 -0
- data/History.txt +0 -1
- data/README.rdoc +0 -102
- data/ext/ffi_c/DataConverter.c +0 -91
- data/ext/ffi_c/Ffi_c.iml +0 -12
- data/ext/ffi_c/StructByReference.c +0 -158
- 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/libffi/Makefile.vc +0 -141
- data/ext/ffi_c/libffi/Makefile.vc64 +0 -141
- data/ext/ffi_c/libffi/README +0 -342
- data/ext/ffi_c/libffi/aclocal.m4 +0 -1873
- data/ext/ffi_c/libffi/build-ios.sh +0 -67
- data/ext/ffi_c/libffi/depcomp +0 -630
- data/ext/ffi_c/libffi/doc/libffi.info +0 -593
- data/ext/ffi_c/libffi/doc/stamp-vti +0 -4
- data/ext/ffi_c/libffi/include/ffi.h.vc +0 -427
- data/ext/ffi_c/libffi/m4/ax_check_compiler_flags.m4 +0 -76
- data/ext/ffi_c/libffi/m4/libtool.m4 +0 -7831
- data/ext/ffi_c/libffi/m4/ltoptions.m4 +0 -369
- data/ext/ffi_c/libffi/m4/ltsugar.m4 +0 -123
- data/ext/ffi_c/libffi/m4/ltversion.m4 +0 -23
- data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +0 -98
- data/ext/ffi_c/libffi/mdate-sh +0 -201
- data/ext/ffi_c/libffi/src/arm/gentramp.sh +0 -118
- data/ext/ffi_c/libffi/src/arm/trampoline.S +0 -4450
- data/ext/ffi_c/libffi/src/x86/darwin.S +0 -444
- data/ext/ffi_c/libffi/src/x86/darwin64.S +0 -416
- data/ext/ffi_c/libffi/src/x86/freebsd.S +0 -458
- data/ext/ffi_c/libffi/src/x86/win32.S +0 -1065
- data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +0 -300
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_win32.c +0 -63
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen_win32.c +0 -44
- data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +0 -96
- data/ext/ffi_c/libffi/texinfo.tex +0 -7210
- data/ext/ffi_c/win32/stdint.h +0 -199
- data/gen/Rakefile +0 -30
- data/lib/Lib.iml +0 -13
- data/spec/ffi/Ffi.iml +0 -12
- data/spec/ffi/async_callback_spec.rb +0 -46
- data/spec/ffi/bool_spec.rb +0 -40
- data/spec/ffi/buffer_spec.rb +0 -215
- data/spec/ffi/callback_spec.rb +0 -668
- data/spec/ffi/custom_param_type.rb +0 -47
- data/spec/ffi/custom_type_spec.rb +0 -85
- data/spec/ffi/dup_spec.rb +0 -65
- data/spec/ffi/enum_spec.rb +0 -227
- data/spec/ffi/errno_spec.rb +0 -29
- data/spec/ffi/ffi_spec.rb +0 -40
- data/spec/ffi/function_spec.rb +0 -87
- data/spec/ffi/library_spec.rb +0 -208
- data/spec/ffi/long_double.rb +0 -41
- data/spec/ffi/managed_struct_spec.rb +0 -72
- data/spec/ffi/number_spec.rb +0 -247
- data/spec/ffi/pointer_spec.rb +0 -214
- data/spec/ffi/rbx/attach_function_spec.rb +0 -28
- data/spec/ffi/rbx/memory_pointer_spec.rb +0 -111
- data/spec/ffi/rbx/spec_helper.rb +0 -1
- data/spec/ffi/rbx/struct_spec.rb +0 -13
- data/spec/ffi/spec_helper.rb +0 -35
- data/spec/ffi/string_spec.rb +0 -119
- data/spec/ffi/strptr_spec.rb +0 -61
- data/spec/ffi/struct_callback_spec.rb +0 -80
- data/spec/ffi/struct_initialize_spec.rb +0 -46
- data/spec/ffi/struct_packed_spec.rb +0 -62
- data/spec/ffi/struct_spec.rb +0 -719
- data/spec/ffi/typedef_spec.rb +0 -89
- data/spec/ffi/union_spec.rb +0 -76
- data/spec/ffi/variadic_spec.rb +0 -103
- data/spec/spec.opts +0 -4
- data/tasks/ann.rake +0 -80
- data/tasks/extension.rake +0 -32
- data/tasks/gem.rake +0 -199
- data/tasks/git.rake +0 -41
- data/tasks/notes.rake +0 -27
- data/tasks/post_load.rake +0 -34
- data/tasks/rdoc.rake +0 -50
- data/tasks/rubyforge.rake +0 -55
- data/tasks/setup.rb +0 -301
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -47
- data/tasks/test.rake +0 -40
- data/tasks/yard.rake +0 -11
- data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.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}/err_bad_abi.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
- data/lib/ffi/platform/{i486-gnu → i386-gnu}/types.conf +84 -84
data/spec/ffi/struct_spec.rb
DELETED
@@ -1,719 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# This file is part of ruby-ffi.
|
3
|
-
#
|
4
|
-
# This code is free software: you can redistribute it and/or modify it under
|
5
|
-
# the terms of the GNU Lesser General Public License version 3 only, as
|
6
|
-
# published by the Free Software Foundation.
|
7
|
-
#
|
8
|
-
# This code is distributed in the hope that it will be useful, but WITHOUT
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
11
|
-
# version 3 for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU Lesser General Public License
|
14
|
-
# version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
15
|
-
#
|
16
|
-
|
17
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
18
|
-
describe "Struct tests" do
|
19
|
-
StructTypes = {
|
20
|
-
's8' => :char,
|
21
|
-
's16' => :short,
|
22
|
-
's32' => :int,
|
23
|
-
's64' => :long_long,
|
24
|
-
'long' => :long,
|
25
|
-
'f32' => :float,
|
26
|
-
'f64' => :double
|
27
|
-
}
|
28
|
-
module LibTest
|
29
|
-
extend FFI::Library
|
30
|
-
ffi_lib TestLibrary::PATH
|
31
|
-
attach_function :ptr_ret_pointer, [ :pointer, :int], :string
|
32
|
-
attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
|
33
|
-
attach_function :ptr_from_address, [ :ulong ], :pointer
|
34
|
-
attach_function :string_equals, [ :string, :string ], :int
|
35
|
-
[ 's8', 's16', 's32', 's64', 'f32', 'f64', 'long' ].each do |t|
|
36
|
-
attach_function "struct_align_#{t}", [ :pointer ], StructTypes[t]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
class PointerMember < FFI::Struct
|
40
|
-
layout :pointer, :pointer
|
41
|
-
end
|
42
|
-
class StringMember < FFI::Struct
|
43
|
-
layout :string, :string
|
44
|
-
end
|
45
|
-
it "Struct#[:pointer]" do
|
46
|
-
magic = 0x12345678
|
47
|
-
mp = FFI::MemoryPointer.new :long
|
48
|
-
mp.put_long(0, magic)
|
49
|
-
smp = FFI::MemoryPointer.new :pointer
|
50
|
-
smp.put_pointer(0, mp)
|
51
|
-
s = PointerMember.new smp
|
52
|
-
s[:pointer].should eq mp
|
53
|
-
end
|
54
|
-
it "Struct#[:pointer].nil? for NULL value" do
|
55
|
-
magic = 0x12345678
|
56
|
-
mp = FFI::MemoryPointer.new :long
|
57
|
-
mp.put_long(0, magic)
|
58
|
-
smp = FFI::MemoryPointer.new :pointer
|
59
|
-
smp.put_pointer(0, nil)
|
60
|
-
s = PointerMember.new smp
|
61
|
-
s[:pointer].null?.should eq true
|
62
|
-
end
|
63
|
-
it "Struct#[:pointer]=" do
|
64
|
-
magic = 0x12345678
|
65
|
-
mp = FFI::MemoryPointer.new :long
|
66
|
-
mp.put_long(0, magic)
|
67
|
-
smp = FFI::MemoryPointer.new :pointer
|
68
|
-
s = PointerMember.new smp
|
69
|
-
s[:pointer] = mp
|
70
|
-
smp.get_pointer(0).should eq mp
|
71
|
-
end
|
72
|
-
it "Struct#[:pointer]=struct" do
|
73
|
-
smp = FFI::MemoryPointer.new :pointer
|
74
|
-
s = PointerMember.new smp
|
75
|
-
lambda { s[:pointer] = s }.should_not raise_error
|
76
|
-
end
|
77
|
-
it "Struct#[:pointer]=nil" do
|
78
|
-
smp = FFI::MemoryPointer.new :pointer
|
79
|
-
s = PointerMember.new smp
|
80
|
-
s[:pointer] = nil
|
81
|
-
smp.get_pointer(0).null?.should eq true
|
82
|
-
end
|
83
|
-
it "Struct#[:string]" do
|
84
|
-
magic = "test"
|
85
|
-
mp = FFI::MemoryPointer.new 1024
|
86
|
-
mp.put_string(0, magic)
|
87
|
-
smp = FFI::MemoryPointer.new :pointer
|
88
|
-
smp.put_pointer(0, mp)
|
89
|
-
s = StringMember.new smp
|
90
|
-
s[:string].should eq magic
|
91
|
-
end
|
92
|
-
it "Struct#[:string].nil? for NULL value" do
|
93
|
-
smp = FFI::MemoryPointer.new :pointer
|
94
|
-
smp.put_pointer(0, nil)
|
95
|
-
s = StringMember.new smp
|
96
|
-
s[:string].nil?.should eq true
|
97
|
-
end
|
98
|
-
it "Struct#layout works with :name, :type pairs" do
|
99
|
-
class PairLayout < FFI::Struct
|
100
|
-
layout :a, :int, :b, :long_long
|
101
|
-
end
|
102
|
-
ll_off = (FFI::TYPE_UINT64.alignment == 4 ? 4 : 8)
|
103
|
-
PairLayout.size.should eq(ll_off + 8)
|
104
|
-
mp = FFI::MemoryPointer.new(PairLayout.size)
|
105
|
-
s = PairLayout.new mp
|
106
|
-
s[:a] = 0x12345678
|
107
|
-
mp.get_int(0).should eq 0x12345678
|
108
|
-
s[:b] = 0xfee1deadbeef
|
109
|
-
mp.get_int64(ll_off).should eq 0xfee1deadbeef
|
110
|
-
end
|
111
|
-
it "Struct#layout works with :name, :type, offset tuples" do
|
112
|
-
class PairLayout < FFI::Struct
|
113
|
-
layout :a, :int, 0, :b, :long_long, 4
|
114
|
-
end
|
115
|
-
PairLayout.size.should eq(FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
|
116
|
-
mp = FFI::MemoryPointer.new(PairLayout.size)
|
117
|
-
s = PairLayout.new mp
|
118
|
-
s[:a] = 0x12345678
|
119
|
-
mp.get_int(0).should eq 0x12345678
|
120
|
-
s[:b] = 0xfee1deadbeef
|
121
|
-
mp.get_int64(4).should eq 0xfee1deadbeef
|
122
|
-
end
|
123
|
-
it "Struct#layout works with mixed :name,:type and :name,:type,offset" do
|
124
|
-
class MixedLayout < FFI::Struct
|
125
|
-
layout :a, :int, :b, :long_long, 4
|
126
|
-
end
|
127
|
-
MixedLayout.size.should eq(FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
|
128
|
-
mp = FFI::MemoryPointer.new(MixedLayout.size)
|
129
|
-
s = MixedLayout.new mp
|
130
|
-
s[:a] = 0x12345678
|
131
|
-
mp.get_int(0).should eq 0x12345678
|
132
|
-
s[:b] = 0xfee1deadbeef
|
133
|
-
mp.get_int64(4).should eq 0xfee1deadbeef
|
134
|
-
end
|
135
|
-
rb_maj, rb_min = RUBY_VERSION.split('.')
|
136
|
-
if rb_maj.to_i >= 1 && rb_min.to_i >= 9 || RUBY_PLATFORM =~ /java/
|
137
|
-
it "Struct#layout withs with a hash of :name => type" do
|
138
|
-
class HashLayout < FFI::Struct
|
139
|
-
layout :a => :int, :b => :long_long
|
140
|
-
end
|
141
|
-
ll_off = (FFI::TYPE_UINT64.alignment == 4? 4 : 8)
|
142
|
-
HashLayout.size.should eq(ll_off + 8)
|
143
|
-
mp = FFI::MemoryPointer.new(HashLayout.size)
|
144
|
-
s = HashLayout.new mp
|
145
|
-
s[:a] = 0x12345678
|
146
|
-
mp.get_int(0).should eq 0x12345678
|
147
|
-
s[:b] = 0xfee1deadbeef
|
148
|
-
mp.get_int64(ll_off).should eq 0xfee1deadbeef
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
it "subclass overrides initialize without calling super" do
|
153
|
-
class InitializeWithoutSuper < FFI::Struct
|
154
|
-
layout :a, :int, :b, :long_long, :d, [:double, 2]
|
155
|
-
|
156
|
-
def initialize(a, b)
|
157
|
-
self[:a] = a
|
158
|
-
self[:b] = b
|
159
|
-
self[:d][0] = 1.2
|
160
|
-
self[:d][1] = 3.4
|
161
|
-
end
|
162
|
-
|
163
|
-
end
|
164
|
-
s = InitializeWithoutSuper.new(0x1eefbeef, 0xdeadcafebabe)
|
165
|
-
s[:a].should eq 0x1eefbeef
|
166
|
-
s[:b].should eq 0xdeadcafebabe
|
167
|
-
end
|
168
|
-
|
169
|
-
it "Can use Struct subclass as parameter type" do
|
170
|
-
module StructParam
|
171
|
-
extend FFI::Library
|
172
|
-
ffi_lib TestLibrary::PATH
|
173
|
-
class TestStruct < FFI::Struct
|
174
|
-
layout :c, :char
|
175
|
-
end
|
176
|
-
attach_function :struct_field_s8, [ TestStruct.in ], :char
|
177
|
-
end
|
178
|
-
end
|
179
|
-
it "Can use Struct subclass as IN parameter type" do
|
180
|
-
module StructParam2
|
181
|
-
extend FFI::Library
|
182
|
-
ffi_lib TestLibrary::PATH
|
183
|
-
class TestStruct < FFI::Struct
|
184
|
-
layout :c, :char
|
185
|
-
end
|
186
|
-
attach_function :struct_field_s8, [ TestStruct.in ], :char
|
187
|
-
end
|
188
|
-
end
|
189
|
-
it "Can use Struct subclass as OUT parameter type" do
|
190
|
-
module StructParam3
|
191
|
-
extend FFI::Library
|
192
|
-
ffi_lib TestLibrary::PATH
|
193
|
-
class TestStruct < FFI::Struct
|
194
|
-
layout :c, :char
|
195
|
-
end
|
196
|
-
attach_function :struct_field_s8, [ TestStruct.out ], :char
|
197
|
-
end
|
198
|
-
end
|
199
|
-
it "can be passed directly as a :pointer parameter" do
|
200
|
-
class TestStruct < FFI::Struct
|
201
|
-
layout :i, :int
|
202
|
-
end
|
203
|
-
s = TestStruct.new
|
204
|
-
s[:i] = 0x12
|
205
|
-
LibTest.ptr_ret_int32_t(s, 0).should eq 0x12
|
206
|
-
end
|
207
|
-
it ":char member aligned correctly" do
|
208
|
-
class AlignChar < FFI::Struct
|
209
|
-
layout :c, :char, :v, :char
|
210
|
-
end
|
211
|
-
s = AlignChar.new
|
212
|
-
s[:v] = 0x12
|
213
|
-
LibTest.struct_align_s8(s.pointer).should eq 0x12
|
214
|
-
end
|
215
|
-
it ":short member aligned correctly" do
|
216
|
-
class AlignShort < FFI::Struct
|
217
|
-
layout :c, :char, :v, :short
|
218
|
-
end
|
219
|
-
s = AlignShort.alloc_in
|
220
|
-
s[:v] = 0x1234
|
221
|
-
LibTest.struct_align_s16(s.pointer).should eq 0x1234
|
222
|
-
end
|
223
|
-
it ":int member aligned correctly" do
|
224
|
-
class AlignInt < FFI::Struct
|
225
|
-
layout :c, :char, :v, :int
|
226
|
-
end
|
227
|
-
s = AlignInt.alloc_in
|
228
|
-
s[:v] = 0x12345678
|
229
|
-
LibTest.struct_align_s32(s.pointer).should eq 0x12345678
|
230
|
-
end
|
231
|
-
it ":long_long member aligned correctly" do
|
232
|
-
class AlignLongLong < FFI::Struct
|
233
|
-
layout :c, :char, :v, :long_long
|
234
|
-
end
|
235
|
-
s = AlignLongLong.alloc_in
|
236
|
-
s[:v] = 0x123456789abcdef0
|
237
|
-
LibTest.struct_align_s64(s.pointer).should eq 0x123456789abcdef0
|
238
|
-
end
|
239
|
-
it ":long member aligned correctly" do
|
240
|
-
class AlignLong < FFI::Struct
|
241
|
-
layout :c, :char, :v, :long
|
242
|
-
end
|
243
|
-
s = AlignLong.alloc_in
|
244
|
-
s[:v] = 0x12345678
|
245
|
-
LibTest.struct_align_long(s.pointer).should eq 0x12345678
|
246
|
-
end
|
247
|
-
it ":float member aligned correctly" do
|
248
|
-
class AlignFloat < FFI::Struct
|
249
|
-
layout :c, :char, :v, :float
|
250
|
-
end
|
251
|
-
s = AlignFloat.alloc_in
|
252
|
-
s[:v] = 1.23456
|
253
|
-
(LibTest.struct_align_f32(s.pointer) - 1.23456).abs.should < 0.00001
|
254
|
-
end
|
255
|
-
it ":double member aligned correctly" do
|
256
|
-
class AlignDouble < FFI::Struct
|
257
|
-
layout :c, :char, :v, :double
|
258
|
-
end
|
259
|
-
s = AlignDouble.alloc_in
|
260
|
-
s[:v] = 1.23456789
|
261
|
-
(LibTest.struct_align_f64(s.pointer) - 1.23456789).abs.should < 0.00000001
|
262
|
-
end
|
263
|
-
it ":ulong, :pointer struct" do
|
264
|
-
class ULPStruct < FFI::Struct
|
265
|
-
layout :ul, :ulong, :p, :pointer
|
266
|
-
end
|
267
|
-
s = ULPStruct.alloc_in
|
268
|
-
s[:ul] = 0xdeadbeef
|
269
|
-
s[:p] = LibTest.ptr_from_address(0x12345678)
|
270
|
-
s.pointer.get_ulong(0).should eq 0xdeadbeef
|
271
|
-
end
|
272
|
-
def test_num_field(type, v)
|
273
|
-
klass = Class.new(FFI::Struct)
|
274
|
-
klass.layout :v, type, :dummy, :long
|
275
|
-
|
276
|
-
s = klass.new
|
277
|
-
s[:v] = v
|
278
|
-
s.pointer.send("get_#{type.to_s}", 0).should eq v
|
279
|
-
s.pointer.send("put_#{type.to_s}", 0, 0)
|
280
|
-
s[:v].should eq 0
|
281
|
-
end
|
282
|
-
def self.int_field_test(type, values)
|
283
|
-
values.each do |v|
|
284
|
-
it "#{type} field r/w (#{v.to_s(16)})" do
|
285
|
-
test_num_field(type, v)
|
286
|
-
end
|
287
|
-
end
|
288
|
-
end
|
289
|
-
int_field_test(:char, [ 0, 127, -128, -1 ])
|
290
|
-
int_field_test(:uchar, [ 0, 0x7f, 0x80, 0xff ])
|
291
|
-
int_field_test(:short, [ 0, 0x7fff, -0x8000, -1 ])
|
292
|
-
int_field_test(:ushort, [ 0, 0x7fff, 0x8000, 0xffff ])
|
293
|
-
int_field_test(:int, [ 0, 0x7fffffff, -0x80000000, -1 ])
|
294
|
-
int_field_test(:uint, [ 0, 0x7fffffff, 0x80000000, 0xffffffff ])
|
295
|
-
int_field_test(:long_long, [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ])
|
296
|
-
int_field_test(:ulong_long, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ])
|
297
|
-
if FFI::Platform::LONG_SIZE == 32
|
298
|
-
int_field_test(:long, [ 0, 0x7fffffff, -0x80000000, -1 ])
|
299
|
-
int_field_test(:ulong, [ 0, 0x7fffffff, 0x80000000, 0xffffffff ])
|
300
|
-
else
|
301
|
-
int_field_test(:long, [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ])
|
302
|
-
int_field_test(:ulong, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ])
|
303
|
-
end
|
304
|
-
it ":float field r/w" do
|
305
|
-
klass = Class.new(FFI::Struct)
|
306
|
-
klass.layout :v, :float, :dummy, :long
|
307
|
-
|
308
|
-
s = klass.new
|
309
|
-
value = 1.23456
|
310
|
-
s[:v] = value
|
311
|
-
(s.pointer.get_float(0) - value).abs.should < 0.0001
|
312
|
-
end
|
313
|
-
it ":double field r/w" do
|
314
|
-
klass = Class.new(FFI::Struct)
|
315
|
-
klass.layout :v, :double, :dummy, :long
|
316
|
-
|
317
|
-
s = klass.new
|
318
|
-
value = 1.23456
|
319
|
-
s[:v] = value
|
320
|
-
(s.pointer.get_double(0) - value).abs.should < 0.0001
|
321
|
-
end
|
322
|
-
module EnumFields
|
323
|
-
extend FFI::Library
|
324
|
-
TestEnum = enum :test_enum, [:c1, 10, :c2, 20, :c3, 30, :c4, 40]
|
325
|
-
class TestStruct < FFI::Struct
|
326
|
-
layout :a, :int, :c, :test_enum,
|
327
|
-
:d, [ TestEnum, TestEnum.symbols.length ]
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
it ":enum field r/w" do
|
332
|
-
s = EnumFields::TestStruct.new
|
333
|
-
s[:c] = :c3
|
334
|
-
|
335
|
-
s.pointer.get_uint(FFI::Type::INT32.size).should eq 30
|
336
|
-
s[:c].should eq :c3
|
337
|
-
end
|
338
|
-
|
339
|
-
it "array of :enum field" do
|
340
|
-
s = EnumFields::TestStruct.new
|
341
|
-
EnumFields::TestEnum.symbols.each_with_index do |val, i|
|
342
|
-
s[:d][i] = val
|
343
|
-
end
|
344
|
-
|
345
|
-
EnumFields::TestEnum.symbols.each_with_index do |val, i|
|
346
|
-
s.pointer.get_uint(FFI::Type::INT32.size * (2 + i)).should eq EnumFields::TestEnum[val]
|
347
|
-
end
|
348
|
-
|
349
|
-
s[:d].each_with_index do |val, i|
|
350
|
-
val.should eq EnumFields::TestEnum.symbols[i]
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
module CallbackMember
|
355
|
-
extend FFI::Library
|
356
|
-
ffi_lib TestLibrary::PATH
|
357
|
-
callback :add, [ :int, :int ], :int
|
358
|
-
callback :sub, [ :int, :int ], :int
|
359
|
-
class TestStruct < FFI::Struct
|
360
|
-
layout :add, :add,
|
361
|
-
:sub, :sub
|
362
|
-
end
|
363
|
-
attach_function :struct_call_add_cb, [TestStruct.in, :int, :int], :int
|
364
|
-
attach_function :struct_call_sub_cb, [TestStruct.in, :int, :int], :int
|
365
|
-
end
|
366
|
-
it "Can have CallbackInfo struct field" do
|
367
|
-
s = CallbackMember::TestStruct.new
|
368
|
-
add_proc = lambda { |a, b| a+b }
|
369
|
-
sub_proc = lambda { |a, b| a-b }
|
370
|
-
s[:add] = add_proc
|
371
|
-
s[:sub] = sub_proc
|
372
|
-
CallbackMember.struct_call_add_cb(s, 40, 2).should eq 42
|
373
|
-
CallbackMember.struct_call_sub_cb(s, 44, 2).should eq 42
|
374
|
-
end
|
375
|
-
it "Can return its members as a list" do
|
376
|
-
class TestStruct < FFI::Struct
|
377
|
-
layout :a, :int, :b, :int, :c, :int
|
378
|
-
end
|
379
|
-
TestStruct.members.should include(:a, :b, :c)
|
380
|
-
end
|
381
|
-
it "Can return its instance members and values as lists" do
|
382
|
-
class TestStruct < FFI::Struct
|
383
|
-
layout :a, :int, :b, :int, :c, :int
|
384
|
-
end
|
385
|
-
s = TestStruct.new
|
386
|
-
s.members.should include(:a, :b, :c)
|
387
|
-
s[:a] = 1
|
388
|
-
s[:b] = 2
|
389
|
-
s[:c] = 3
|
390
|
-
s.values.should include(1, 2, 3)
|
391
|
-
end
|
392
|
-
it 'should return an ordered field/offset pairs array' do
|
393
|
-
class TestStruct < FFI::Struct
|
394
|
-
layout :a, :int, :b, :int, :c, :int
|
395
|
-
end
|
396
|
-
s = TestStruct.new
|
397
|
-
s.offsets.should eq [[:a, 0], [:b, 4], [:c, 8]]
|
398
|
-
TestStruct.offsets.should eq [[:a, 0], [:b, 4], [:c, 8]]
|
399
|
-
end
|
400
|
-
it "Struct#offset_of returns offset of field within struct" do
|
401
|
-
class TestStruct < FFI::Struct
|
402
|
-
layout :a, :int, :b, :int, :c, :int
|
403
|
-
end
|
404
|
-
TestStruct.offset_of(:a).should eq 0
|
405
|
-
TestStruct.offset_of(:b).should eq 4
|
406
|
-
TestStruct.offset_of(:c).should eq 8
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
describe FFI::Struct, ' with a nested struct field' do
|
411
|
-
module LibTest
|
412
|
-
extend FFI::Library
|
413
|
-
ffi_lib TestLibrary::PATH
|
414
|
-
class NestedStruct < FFI::Struct
|
415
|
-
layout :i, :int
|
416
|
-
end
|
417
|
-
class ContainerStruct < FFI::Struct
|
418
|
-
layout :first, :char, :ns, NestedStruct
|
419
|
-
end
|
420
|
-
attach_function :struct_align_nested_struct, [ :pointer ], :int
|
421
|
-
attach_function :struct_make_container_struct, [ :int ], :pointer
|
422
|
-
end
|
423
|
-
before do
|
424
|
-
@cs = LibTest::ContainerStruct.new
|
425
|
-
end
|
426
|
-
it 'should align correctly nested struct field' do
|
427
|
-
@cs[:ns][:i] = 123
|
428
|
-
LibTest.struct_align_nested_struct(@cs.to_ptr).should eq 123
|
429
|
-
end
|
430
|
-
it 'should correctly calculate Container size (in bytes)' do
|
431
|
-
LibTest::ContainerStruct.size.should eq 8
|
432
|
-
end
|
433
|
-
it 'should return a Struct object when the field is accessed' do
|
434
|
-
@cs[:ns].is_a?(FFI::Struct).should be_true
|
435
|
-
end
|
436
|
-
it 'should read a value from memory' do
|
437
|
-
@cs = LibTest::ContainerStruct.new(LibTest.struct_make_container_struct(123))
|
438
|
-
@cs[:ns][:i].should eq 123
|
439
|
-
end
|
440
|
-
it 'should write a value to memory' do
|
441
|
-
@cs = LibTest::ContainerStruct.new(LibTest.struct_make_container_struct(123))
|
442
|
-
@cs[:ns][:i] = 456
|
443
|
-
LibTest.struct_align_nested_struct(@cs.to_ptr).should eq 456
|
444
|
-
end
|
445
|
-
|
446
|
-
it 'should be able to assign struct instance to nested field' do
|
447
|
-
cs = LibTest::ContainerStruct.new(LibTest.struct_make_container_struct(123))
|
448
|
-
ns = LibTest::NestedStruct.new
|
449
|
-
ns[:i] = 567
|
450
|
-
cs[:ns] = ns
|
451
|
-
cs[:ns][:i].should eq 567
|
452
|
-
LibTest.struct_align_nested_struct(cs.to_ptr).should eq 567
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
describe FFI::Struct, ' with a nested array of structs' do
|
457
|
-
module InlineArrayOfStructs
|
458
|
-
extend FFI::Library
|
459
|
-
ffi_lib TestLibrary::PATH
|
460
|
-
class NestedStruct < FFI::Struct
|
461
|
-
layout :i, :int
|
462
|
-
end
|
463
|
-
class ContainerStruct < FFI::Struct
|
464
|
-
layout :first, :char, :ns, [ NestedStruct, 1 ]
|
465
|
-
end
|
466
|
-
attach_function :struct_align_nested_struct, [ :pointer ], :int
|
467
|
-
attach_function :struct_make_container_struct, [ :int ], :pointer
|
468
|
-
end
|
469
|
-
|
470
|
-
before do
|
471
|
-
@cs = InlineArrayOfStructs::ContainerStruct.new
|
472
|
-
end
|
473
|
-
|
474
|
-
it 'should align correctly nested struct field' do
|
475
|
-
@cs[:ns][0][:i] = 123
|
476
|
-
InlineArrayOfStructs.struct_align_nested_struct(@cs.to_ptr).should eq 123
|
477
|
-
end
|
478
|
-
|
479
|
-
it 'should correctly calculate Container size (in bytes)' do
|
480
|
-
InlineArrayOfStructs::ContainerStruct.size.should eq 8
|
481
|
-
end
|
482
|
-
|
483
|
-
it 'should return a Struct object when the field is accessed' do
|
484
|
-
@cs[:ns][0].is_a?(FFI::Struct).should be_true
|
485
|
-
end
|
486
|
-
|
487
|
-
it 'should read a value from memory' do
|
488
|
-
@cs = InlineArrayOfStructs::ContainerStruct.new(InlineArrayOfStructs.struct_make_container_struct(123))
|
489
|
-
@cs[:ns][0][:i].should eq 123
|
490
|
-
end
|
491
|
-
|
492
|
-
it 'should write a value to memory' do
|
493
|
-
@cs = InlineArrayOfStructs::ContainerStruct.new(InlineArrayOfStructs.struct_make_container_struct(123))
|
494
|
-
@cs[:ns][0][:i] = 456
|
495
|
-
InlineArrayOfStructs.struct_align_nested_struct(@cs.to_ptr).should eq 456
|
496
|
-
end
|
497
|
-
|
498
|
-
it 'should support Enumerable#each' do
|
499
|
-
@cs = InlineArrayOfStructs::ContainerStruct.new(InlineArrayOfStructs.struct_make_container_struct(123))
|
500
|
-
ints = []
|
501
|
-
@cs[:ns].each { |s| ints << s[:i] }
|
502
|
-
ints[0].should eq 123
|
503
|
-
end
|
504
|
-
end
|
505
|
-
|
506
|
-
describe FFI::Struct, ' by value' do
|
507
|
-
module LibTest
|
508
|
-
extend FFI::Library
|
509
|
-
ffi_lib TestLibrary::PATH
|
510
|
-
|
511
|
-
class S8S32 < FFI::Struct
|
512
|
-
layout :s8, :char, :s32, :int
|
513
|
-
end
|
514
|
-
|
515
|
-
class StructString < FFI::Struct
|
516
|
-
layout :bytes, :string, :len, :int
|
517
|
-
end
|
518
|
-
|
519
|
-
attach_function :struct_return_s8s32, [ ], S8S32.by_value
|
520
|
-
attach_function :struct_s8s32_set, [ :char, :int ], S8S32.by_value
|
521
|
-
attach_function :struct_s8s32_get_s8, [ S8S32.by_value ], :char
|
522
|
-
attach_function :struct_s8s32_get_s32, [ S8S32.by_value ], :int
|
523
|
-
attach_function :struct_s8s32_s32_ret_s32, [ S8S32.by_value, :int ], :int
|
524
|
-
attach_function :struct_s8s32_s64_ret_s64, [ S8S32.by_value, :long_long ], :long_long
|
525
|
-
attach_function :struct_s8s32_ret_s8s32, [ S8S32.by_value ], S8S32.by_value
|
526
|
-
attach_function :struct_s32_ptr_s32_s8s32_ret_s32, [ :int, :pointer, :int, S8S32.by_value ], :int
|
527
|
-
attach_function :struct_varargs_ret_struct_string, [ :int, :varargs ], StructString.by_value
|
528
|
-
end
|
529
|
-
|
530
|
-
it 'return using pre-set values' do
|
531
|
-
s = LibTest.struct_return_s8s32
|
532
|
-
s[:s8].should eq 0x7f
|
533
|
-
s[:s32].should eq 0x12345678
|
534
|
-
end
|
535
|
-
|
536
|
-
it 'return using passed in values' do
|
537
|
-
s = LibTest.struct_s8s32_set(123, 456789)
|
538
|
-
s[:s8].should eq 123
|
539
|
-
s[:s32].should eq 456789
|
540
|
-
end
|
541
|
-
|
542
|
-
it 'parameter' do
|
543
|
-
s = LibTest::S8S32.new
|
544
|
-
s[:s8] = 0x12
|
545
|
-
s[:s32] = 0x34567890
|
546
|
-
LibTest.struct_s8s32_get_s8(s).should eq 0x12
|
547
|
-
LibTest.struct_s8s32_get_s32(s).should eq 0x34567890
|
548
|
-
end
|
549
|
-
|
550
|
-
it 'parameter with following s32' do
|
551
|
-
s = LibTest::S8S32.new
|
552
|
-
s[:s8] = 0x12
|
553
|
-
s[:s32] = 0x34567890
|
554
|
-
|
555
|
-
LibTest.struct_s8s32_s32_ret_s32(s, 0x1eefdead).should eq 0x1eefdead
|
556
|
-
end
|
557
|
-
|
558
|
-
it 'parameter with following s64' do
|
559
|
-
s = LibTest::S8S32.new
|
560
|
-
s[:s8] = 0x12
|
561
|
-
s[:s32] = 0x34567890
|
562
|
-
end
|
563
|
-
|
564
|
-
it 'parameter with preceding s32,ptr,s32' do
|
565
|
-
s = LibTest::S8S32.new
|
566
|
-
s[:s8] = 0x12
|
567
|
-
s[:s32] = 0x34567890
|
568
|
-
out = LibTest::S8S32.new
|
569
|
-
LibTest.struct_s32_ptr_s32_s8s32_ret_s32(0x1000000, out, 0x1eafbeef, s).should eq 0x34567890
|
570
|
-
out[:s8].should eq s[:s8]
|
571
|
-
out[:s32].should eq s[:s32]
|
572
|
-
end
|
573
|
-
|
574
|
-
it 'parameter with preceding s32,string,s32' do
|
575
|
-
s = LibTest::S8S32.new
|
576
|
-
s[:s8] = 0x12
|
577
|
-
s[:s32] = 0x34567890
|
578
|
-
out = 0.chr * 32
|
579
|
-
LibTest.struct_s32_ptr_s32_s8s32_ret_s32(0x1000000, out, 0x1eafbeef, s).should eq 0x34567890
|
580
|
-
end
|
581
|
-
|
582
|
-
it 'parameter, returning struct by value' do
|
583
|
-
s = LibTest::S8S32.new
|
584
|
-
s[:s8] = 0x12
|
585
|
-
s[:s32] = 0x34567890
|
586
|
-
|
587
|
-
ret = LibTest.struct_s8s32_ret_s8s32(s)
|
588
|
-
ret[:s8].should eq s[:s8]
|
589
|
-
ret[:s32].should eq s[:s32]
|
590
|
-
end
|
591
|
-
|
592
|
-
it 'varargs returning a struct' do
|
593
|
-
string = "test"
|
594
|
-
s = LibTest.struct_varargs_ret_struct_string(4, :string, string)
|
595
|
-
s[:len].should eq string.length
|
596
|
-
s[:bytes].should eq string
|
597
|
-
end
|
598
|
-
end
|
599
|
-
|
600
|
-
describe FFI::Struct, ' with an array field' do
|
601
|
-
module LibTest
|
602
|
-
extend FFI::Library
|
603
|
-
ffi_lib TestLibrary::PATH
|
604
|
-
class StructWithArray < FFI::Struct
|
605
|
-
layout :first, :char, :a, [:int, 5]
|
606
|
-
end
|
607
|
-
attach_function :struct_make_struct_with_array, [:int, :int, :int, :int, :int], :pointer
|
608
|
-
attach_function :struct_field_array, [:pointer], :pointer
|
609
|
-
end
|
610
|
-
before do
|
611
|
-
@s = LibTest::StructWithArray.new
|
612
|
-
end
|
613
|
-
it 'should correctly calculate StructWithArray size (in bytes)' do
|
614
|
-
LibTest::StructWithArray.size.should eq 24
|
615
|
-
end
|
616
|
-
it 'should read values from memory' do
|
617
|
-
@s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
|
618
|
-
@s[:a].to_a.should eq [0, 1, 2, 3, 4]
|
619
|
-
end
|
620
|
-
# it 'should cache array object for successive calls' do
|
621
|
-
# @s[:a].object_id.should eq @s[:a].object_id
|
622
|
-
# end
|
623
|
-
it 'should return the number of elements in the array field' do
|
624
|
-
@s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
|
625
|
-
@s[:a].size.should eq 5
|
626
|
-
end
|
627
|
-
it 'should allow iteration through the array elements' do
|
628
|
-
@s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
|
629
|
-
@s[:a].each_with_index { |elem, i| elem.should eq i }
|
630
|
-
end
|
631
|
-
it 'should return the pointer to the array' do
|
632
|
-
@s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
|
633
|
-
@s[:a].to_ptr.should eq LibTest::struct_field_array(@s.to_ptr)
|
634
|
-
end
|
635
|
-
end
|
636
|
-
|
637
|
-
describe 'BuggedStruct' do
|
638
|
-
module LibTest
|
639
|
-
extend FFI::Library
|
640
|
-
ffi_lib TestLibrary::PATH
|
641
|
-
class BuggedStruct < FFI::Struct
|
642
|
-
layout :visible, :uchar,
|
643
|
-
:x, :uint,
|
644
|
-
:y, :uint,
|
645
|
-
:rx, :short,
|
646
|
-
:ry, :short,
|
647
|
-
:order, :uchar,
|
648
|
-
:size, :uchar
|
649
|
-
end
|
650
|
-
attach_function :bugged_struct_size, [], :uint
|
651
|
-
end
|
652
|
-
it 'should return its correct size' do
|
653
|
-
LibTest::BuggedStruct.size.should eq LibTest.bugged_struct_size
|
654
|
-
end
|
655
|
-
it "offsets within struct should be correct" do
|
656
|
-
LibTest::BuggedStruct.offset_of(:visible).should eq 0
|
657
|
-
LibTest::BuggedStruct.offset_of(:x).should eq 4
|
658
|
-
LibTest::BuggedStruct.offset_of(:y).should eq 8
|
659
|
-
LibTest::BuggedStruct.offset_of(:rx).should eq 12
|
660
|
-
LibTest::BuggedStruct.offset_of(:ry).should eq 14
|
661
|
-
LibTest::BuggedStruct.offset_of(:order).should eq 16
|
662
|
-
LibTest::BuggedStruct.offset_of(:size).should eq 17
|
663
|
-
end
|
664
|
-
it 'should return correct field/offset pairs' do
|
665
|
-
LibTest::BuggedStruct.offsets.sort do |a, b|
|
666
|
-
a[1] <=> b[1]
|
667
|
-
end.should eq [[:visible, 0], [:x, 4], [:y, 8], [:rx, 12], [:ry, 14], [:order, 16], [:size, 17]]
|
668
|
-
end
|
669
|
-
end
|
670
|
-
|
671
|
-
describe "Struct allocation" do
|
672
|
-
it "MemoryPointer.new(Struct, 2)" do
|
673
|
-
class S < FFI::Struct
|
674
|
-
layout :i, :uint
|
675
|
-
end
|
676
|
-
p = FFI::MemoryPointer.new(S, 2)
|
677
|
-
p.total.should eq 8
|
678
|
-
p.type_size.should eq 4
|
679
|
-
p.put_uint(4, 0xdeadbeef)
|
680
|
-
S.new(p[1])[:i].should eq 0xdeadbeef
|
681
|
-
p[1].address.should eq(p[0].address + 4)
|
682
|
-
end
|
683
|
-
|
684
|
-
it "Buffer.new(Struct, 2)" do
|
685
|
-
class S < FFI::Struct
|
686
|
-
layout :i, :uint
|
687
|
-
end
|
688
|
-
p = FFI::Buffer.new(S, 2)
|
689
|
-
p.total.should eq 8
|
690
|
-
p.type_size.should eq 4
|
691
|
-
p.put_uint(4, 0xdeadbeef)
|
692
|
-
S.new(p[1])[:i].should eq 0xdeadbeef
|
693
|
-
end
|
694
|
-
|
695
|
-
it "null? should be true when initialized with NULL pointer" do
|
696
|
-
class S < FFI::Struct
|
697
|
-
layout :i, :uint
|
698
|
-
end
|
699
|
-
S.new(FFI::Pointer::NULL).null?.should be_true
|
700
|
-
end
|
701
|
-
|
702
|
-
it "null? should be false when initialized with non-NULL pointer" do
|
703
|
-
class S < FFI::Struct
|
704
|
-
layout :i, :uint
|
705
|
-
end
|
706
|
-
S.new(FFI::MemoryPointer.new(S)).null?.should be_false
|
707
|
-
end
|
708
|
-
|
709
|
-
it "supports :bool as a struct member" do
|
710
|
-
lambda do
|
711
|
-
c = Class.new(FFI::Struct) do
|
712
|
-
layout :b, :bool
|
713
|
-
end
|
714
|
-
struct = c.new
|
715
|
-
struct[:b] = ! struct[:b]
|
716
|
-
end.should_not raise_error
|
717
|
-
end
|
718
|
-
|
719
|
-
end
|