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/callback_spec.rb
DELETED
@@ -1,668 +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
|
-
|
19
|
-
describe "Callback" do
|
20
|
-
# module LibC
|
21
|
-
# extend FFI::Library
|
22
|
-
# callback :qsort_cmp, [ :pointer, :pointer ], :int
|
23
|
-
# attach_function :qsort, [ :pointer, :int, :int, :qsort_cmp ], :int
|
24
|
-
# end
|
25
|
-
# it "arguments get passed correctly" do
|
26
|
-
# p = MemoryPointer.new(:int, 2)
|
27
|
-
# p.put_array_of_int32(0, [ 1 , 2 ])
|
28
|
-
# args = []
|
29
|
-
# cmp = proc do |p1, p2| args.push(p1.get_int(0)); args.push(p2.get_int(0)); 0; end
|
30
|
-
# # this is a bit dodgey, as it relies on qsort passing the args in order
|
31
|
-
# LibC.qsort(p, 2, 4, cmp)
|
32
|
-
# args.should eq [ 1, 2 ]
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# it "Block can be substituted for Callback as last argument" do
|
36
|
-
# p = MemoryPointer.new(:int, 2)
|
37
|
-
# p.put_array_of_int32(0, [ 1 , 2 ])
|
38
|
-
# args = []
|
39
|
-
# # this is a bit dodgey, as it relies on qsort passing the args in order
|
40
|
-
# LibC.qsort(p, 2, 4) do |p1, p2|
|
41
|
-
# args.push(p1.get_int(0))
|
42
|
-
# args.push(p2.get_int(0))
|
43
|
-
# 0
|
44
|
-
# end
|
45
|
-
# args.should eq [ 1, 2 ]
|
46
|
-
# end
|
47
|
-
module LibTest
|
48
|
-
extend FFI::Library
|
49
|
-
ffi_lib TestLibrary::PATH
|
50
|
-
class S8F32S32 < FFI::Struct
|
51
|
-
layout :s8, :char, :f32, :float, :s32, :int
|
52
|
-
end
|
53
|
-
|
54
|
-
callback :cbVrS8, [ ], :char
|
55
|
-
callback :cbVrU8, [ ], :uchar
|
56
|
-
callback :cbVrS16, [ ], :short
|
57
|
-
callback :cbVrU16, [ ], :ushort
|
58
|
-
callback :cbVrS32, [ ], :int
|
59
|
-
callback :cbVrU32, [ ], :uint
|
60
|
-
callback :cbVrL, [ ], :long
|
61
|
-
callback :cbVrUL, [ ], :ulong
|
62
|
-
callback :cbVrS64, [ ], :long_long
|
63
|
-
callback :cbVrU64, [ ], :ulong_long
|
64
|
-
callback :cbVrP, [], :pointer
|
65
|
-
callback :cbVrZ, [], :bool
|
66
|
-
callback :cbCrV, [ :char ], :void
|
67
|
-
callback :cbSrV, [ :short ], :void
|
68
|
-
callback :cbIrV, [ :int ], :void
|
69
|
-
callback :cbLrV, [ :long ], :void
|
70
|
-
callback :cbULrV, [ :ulong ], :void
|
71
|
-
callback :cbLrV, [ :long_long ], :void
|
72
|
-
callback :cbVrT, [ ], S8F32S32.by_value
|
73
|
-
callback :cbTrV, [ S8F32S32.by_value ], :void
|
74
|
-
callback :cbYrV, [ S8F32S32.ptr ], :void
|
75
|
-
callback :cbVrY, [ ], S8F32S32.ptr
|
76
|
-
|
77
|
-
attach_function :testCallbackVrS8, :testClosureVrB, [ :cbVrS8 ], :char
|
78
|
-
attach_function :testCallbackVrU8, :testClosureVrB, [ :cbVrU8 ], :uchar
|
79
|
-
attach_function :testCallbackVrS16, :testClosureVrS, [ :cbVrS16 ], :short
|
80
|
-
attach_function :testCallbackVrU16, :testClosureVrS, [ :cbVrU16 ], :ushort
|
81
|
-
attach_function :testCallbackVrS32, :testClosureVrI, [ :cbVrS32 ], :int
|
82
|
-
attach_function :testCallbackVrU32, :testClosureVrI, [ :cbVrU32 ], :uint
|
83
|
-
attach_function :testCallbackVrL, :testClosureVrL, [ :cbVrL ], :long
|
84
|
-
attach_function :testCallbackVrZ, :testClosureVrZ, [ :cbVrZ ], :bool
|
85
|
-
attach_function :testCallbackVrUL, :testClosureVrL, [ :cbVrUL ], :ulong
|
86
|
-
attach_function :testCallbackVrS64, :testClosureVrLL, [ :cbVrS64 ], :long_long
|
87
|
-
attach_function :testCallbackVrU64, :testClosureVrLL, [ :cbVrU64 ], :ulong_long
|
88
|
-
attach_function :testCallbackVrP, :testClosureVrP, [ :cbVrP ], :pointer
|
89
|
-
attach_function :testCallbackVrY, :testClosureVrP, [ :cbVrY ], S8F32S32.ptr
|
90
|
-
attach_function :testCallbackVrT, :testClosureVrT, [ :cbVrT ], S8F32S32.by_value
|
91
|
-
attach_function :testCallbackTrV, :testClosureTrV, [ :cbTrV, S8F32S32.ptr ], :void
|
92
|
-
attach_variable :cbVrS8, :gvar_pointer, :cbVrS8
|
93
|
-
attach_variable :pVrS8, :gvar_pointer, :pointer
|
94
|
-
attach_function :testGVarCallbackVrS8, :testClosureVrB, [ :pointer ], :char
|
95
|
-
attach_function :testOptionalCallbackCrV, :testOptionalClosureBrV, [ :cbCrV, :char ], :void
|
96
|
-
|
97
|
-
end
|
98
|
-
it "returning :char (0)" do
|
99
|
-
LibTest.testCallbackVrS8 { 0 }.should eq 0
|
100
|
-
end
|
101
|
-
it "returning :char (127)" do
|
102
|
-
LibTest.testCallbackVrS8 { 127 }.should eq 127
|
103
|
-
end
|
104
|
-
it "returning :char (-128)" do
|
105
|
-
LibTest.testCallbackVrS8 { -128 }.should eq(-128)
|
106
|
-
end
|
107
|
-
# test wrap around
|
108
|
-
it "returning :char (128)" do
|
109
|
-
LibTest.testCallbackVrS8 { 128 }.should eq(-128)
|
110
|
-
end
|
111
|
-
it "returning :char (255)" do
|
112
|
-
LibTest.testCallbackVrS8 { 0xff }.should eq(-1)
|
113
|
-
end
|
114
|
-
it "returning :uchar (0)" do
|
115
|
-
LibTest.testCallbackVrU8 { 0 }.should eq 0
|
116
|
-
end
|
117
|
-
it "returning :uchar (0xff)" do
|
118
|
-
LibTest.testCallbackVrU8 { 0xff }.should eq 0xff
|
119
|
-
end
|
120
|
-
it "returning :uchar (-1)" do
|
121
|
-
LibTest.testCallbackVrU8 { -1 }.should eq 0xff
|
122
|
-
end
|
123
|
-
it "returning :uchar (128)" do
|
124
|
-
LibTest.testCallbackVrU8 { 128 }.should eq 128
|
125
|
-
end
|
126
|
-
it "returning :uchar (-128)" do
|
127
|
-
LibTest.testCallbackVrU8 { -128 }.should eq 128
|
128
|
-
end
|
129
|
-
it "returning :short (0)" do
|
130
|
-
LibTest.testCallbackVrS16 { 0 }.should eq 0
|
131
|
-
end
|
132
|
-
it "returning :short (0x7fff)" do
|
133
|
-
LibTest.testCallbackVrS16 { 0x7fff }.should eq 0x7fff
|
134
|
-
end
|
135
|
-
# test wrap around
|
136
|
-
it "returning :short (0x8000)" do
|
137
|
-
LibTest.testCallbackVrS16 { 0x8000 }.should eq(-0x8000)
|
138
|
-
end
|
139
|
-
it "returning :short (0xffff)" do
|
140
|
-
LibTest.testCallbackVrS16 { 0xffff }.should eq(-1)
|
141
|
-
end
|
142
|
-
it "returning :ushort (0)" do
|
143
|
-
LibTest.testCallbackVrU16 { 0 }.should eq 0
|
144
|
-
end
|
145
|
-
it "returning :ushort (0x7fff)" do
|
146
|
-
LibTest.testCallbackVrU16 { 0x7fff }.should eq 0x7fff
|
147
|
-
end
|
148
|
-
it "returning :ushort (0x8000)" do
|
149
|
-
LibTest.testCallbackVrU16 { 0x8000 }.should eq 0x8000
|
150
|
-
end
|
151
|
-
it "returning :ushort (0xffff)" do
|
152
|
-
LibTest.testCallbackVrU16 { 0xffff }.should eq 0xffff
|
153
|
-
end
|
154
|
-
it "returning :ushort (-1)" do
|
155
|
-
LibTest.testCallbackVrU16 { -1 }.should eq 0xffff
|
156
|
-
end
|
157
|
-
it "returning :int (0)" do
|
158
|
-
LibTest.testCallbackVrS32 { 0 }.should eq 0
|
159
|
-
end
|
160
|
-
it "returning :int (0x7fffffff)" do
|
161
|
-
LibTest.testCallbackVrS32 { 0x7fffffff }.should eq 0x7fffffff
|
162
|
-
end
|
163
|
-
# test wrap around
|
164
|
-
it "returning :int (-0x80000000)" do
|
165
|
-
LibTest.testCallbackVrS32 { -0x80000000 }.should eq(-0x80000000)
|
166
|
-
end
|
167
|
-
it "returning :int (-1)" do
|
168
|
-
LibTest.testCallbackVrS32 { -1 }.should eq(-1)
|
169
|
-
end
|
170
|
-
it "returning :uint (0)" do
|
171
|
-
LibTest.testCallbackVrU32 { 0 }.should eq 0
|
172
|
-
end
|
173
|
-
it "returning :uint (0x7fffffff)" do
|
174
|
-
LibTest.testCallbackVrU32 { 0x7fffffff }.should eq 0x7fffffff
|
175
|
-
end
|
176
|
-
# test wrap around
|
177
|
-
it "returning :uint (0x80000000)" do
|
178
|
-
LibTest.testCallbackVrU32 { 0x80000000 }.should eq 0x80000000
|
179
|
-
end
|
180
|
-
it "returning :uint (0xffffffff)" do
|
181
|
-
LibTest.testCallbackVrU32 { 0xffffffff }.should eq 0xffffffff
|
182
|
-
end
|
183
|
-
it "returning :uint (-1)" do
|
184
|
-
LibTest.testCallbackVrU32 { -1 }.should eq 0xffffffff
|
185
|
-
end
|
186
|
-
it "returning :long (0)" do
|
187
|
-
LibTest.testCallbackVrL { 0 }.should eq 0
|
188
|
-
end
|
189
|
-
it "returning :long (0x7fffffff)" do
|
190
|
-
LibTest.testCallbackVrL { 0x7fffffff }.should eq 0x7fffffff
|
191
|
-
end
|
192
|
-
# test wrap around
|
193
|
-
it "returning :long (-0x80000000)" do
|
194
|
-
LibTest.testCallbackVrL { -0x80000000 }.should eq(-0x80000000)
|
195
|
-
end
|
196
|
-
it "returning :long (-1)" do
|
197
|
-
LibTest.testCallbackVrL { -1 }.should eq(-1)
|
198
|
-
end
|
199
|
-
it "returning :ulong (0)" do
|
200
|
-
LibTest.testCallbackVrUL { 0 }.should eq 0
|
201
|
-
end
|
202
|
-
it "returning :ulong (0x7fffffff)" do
|
203
|
-
LibTest.testCallbackVrUL { 0x7fffffff }.should eq 0x7fffffff
|
204
|
-
end
|
205
|
-
# test wrap around
|
206
|
-
it "returning :ulong (0x80000000)" do
|
207
|
-
LibTest.testCallbackVrUL { 0x80000000 }.should eq 0x80000000
|
208
|
-
end
|
209
|
-
it "returning :ulong (0xffffffff)" do
|
210
|
-
LibTest.testCallbackVrUL { 0xffffffff }.should eq 0xffffffff
|
211
|
-
end
|
212
|
-
it "Callback returning :ulong (-1)" do
|
213
|
-
if FFI::Platform::LONG_SIZE == 32
|
214
|
-
LibTest.testCallbackVrUL { -1 }.should eq 0xffffffff
|
215
|
-
else
|
216
|
-
LibTest.testCallbackVrUL { -1 }.should eq 0xffffffffffffffff
|
217
|
-
end
|
218
|
-
end
|
219
|
-
it "returning :long_long (0)" do
|
220
|
-
LibTest.testCallbackVrS64 { 0 }.should eq 0
|
221
|
-
end
|
222
|
-
it "returning :long_long (0x7fffffffffffffff)" do
|
223
|
-
LibTest.testCallbackVrS64 { 0x7fffffffffffffff }.should eq 0x7fffffffffffffff
|
224
|
-
end
|
225
|
-
# test wrap around
|
226
|
-
it "returning :long_long (-0x8000000000000000)" do
|
227
|
-
LibTest.testCallbackVrS64 { -0x8000000000000000 }.should eq(-0x8000000000000000)
|
228
|
-
end
|
229
|
-
it "returning :long_long (-1)" do
|
230
|
-
LibTest.testCallbackVrS64 { -1 }.should eq(-1)
|
231
|
-
end
|
232
|
-
it "returning bool" do
|
233
|
-
LibTest.testCallbackVrZ { true }.should be_true
|
234
|
-
end
|
235
|
-
it "returning :pointer (nil)" do
|
236
|
-
LibTest.testCallbackVrP { nil }.null?.should be_true
|
237
|
-
end
|
238
|
-
it "returning :pointer (MemoryPointer)" do
|
239
|
-
p = FFI::MemoryPointer.new :long
|
240
|
-
LibTest.testCallbackVrP { p }.should eq p
|
241
|
-
end
|
242
|
-
|
243
|
-
|
244
|
-
it "returning struct by value" do
|
245
|
-
s = LibTest::S8F32S32.new
|
246
|
-
s[:s8] = 0x12
|
247
|
-
s[:s32] = 0x1eefbeef
|
248
|
-
s[:f32] = 1.234567
|
249
|
-
ret = LibTest.testCallbackVrT { s }
|
250
|
-
ret[:s8].should eq s[:s8]
|
251
|
-
ret[:f32].should eq s[:f32]
|
252
|
-
ret[:s32].should eq s[:s32]
|
253
|
-
|
254
|
-
end
|
255
|
-
|
256
|
-
it "struct by value parameter" do
|
257
|
-
s = LibTest::S8F32S32.new
|
258
|
-
s[:s8] = 0x12
|
259
|
-
s[:s32] = 0x1eefbeef
|
260
|
-
s[:f32] = 1.234567
|
261
|
-
s2 = LibTest::S8F32S32.new
|
262
|
-
LibTest.testCallbackTrV(s) do |struct|
|
263
|
-
s2[:s8] = struct[:s8]
|
264
|
-
s2[:f32] = struct[:f32]
|
265
|
-
s2[:s32] = struct[:s32]
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
|
270
|
-
it "global variable" do
|
271
|
-
proc = Proc.new { 0x1e }
|
272
|
-
LibTest.cbVrS8 = proc
|
273
|
-
LibTest.testGVarCallbackVrS8(LibTest.pVrS8).should eq 0x1e
|
274
|
-
end
|
275
|
-
|
276
|
-
describe "When the callback is considered optional by the underlying library" do
|
277
|
-
it "should handle receiving 'nil' in place of the closure" do
|
278
|
-
LibTest.testOptionalCallbackCrV(nil, 13)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
describe 'when inlined' do
|
283
|
-
it 'could be anonymous' do
|
284
|
-
module LibTest
|
285
|
-
extend FFI::Library
|
286
|
-
ffi_lib TestLibrary::PATH
|
287
|
-
attach_function :testAnonymousCallbackVrS8, :testClosureVrB, [ callback([ ], :char) ], :char
|
288
|
-
end
|
289
|
-
LibTest.testAnonymousCallbackVrS8 { 0 }.should eq 0
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
describe "as return value" do
|
294
|
-
|
295
|
-
it "should not blow up when a callback is defined that returns a callback" do
|
296
|
-
module LibTest
|
297
|
-
extend FFI::Library
|
298
|
-
ffi_lib TestLibrary::PATH
|
299
|
-
callback :cb_return_type_1, [ :short ], :short
|
300
|
-
callback :cb_lookup_1, [ :short ], :cb_return_type_1
|
301
|
-
attach_function :testReturnsCallback_1, :testReturnsClosure, [ :cb_lookup_1, :short ], :cb_return_type_1
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
it "should return a callback" do
|
306
|
-
module LibTest
|
307
|
-
extend FFI::Library
|
308
|
-
ffi_lib TestLibrary::PATH
|
309
|
-
callback :cb_return_type, [ :int ], :int
|
310
|
-
callback :cb_lookup, [ ], :cb_return_type
|
311
|
-
attach_function :testReturnsCallback, :testReturnsClosure, [ :cb_lookup, :int ], :int
|
312
|
-
end
|
313
|
-
|
314
|
-
lookup_proc_called = false
|
315
|
-
return_proc_called = false
|
316
|
-
|
317
|
-
return_proc = Proc.new do |a|
|
318
|
-
return_proc_called = true
|
319
|
-
a * 2
|
320
|
-
end
|
321
|
-
lookup_proc = Proc.new do
|
322
|
-
lookup_proc_called = true
|
323
|
-
return_proc
|
324
|
-
end
|
325
|
-
|
326
|
-
val = LibTest.testReturnsCallback(lookup_proc, 0x1234)
|
327
|
-
val.should eq 0x1234 * 2
|
328
|
-
lookup_proc_called.should be_true
|
329
|
-
return_proc_called.should be_true
|
330
|
-
end
|
331
|
-
|
332
|
-
it "should return a method callback" do
|
333
|
-
module LibTest
|
334
|
-
extend FFI::Library
|
335
|
-
ffi_lib TestLibrary::PATH
|
336
|
-
callback :cb_return_type, [ :int ], :int
|
337
|
-
callback :cb_lookup, [ ], :cb_return_type
|
338
|
-
attach_function :testReturnsCallback_2, :testReturnsClosure, [ :cb_lookup, :int ], :int
|
339
|
-
end
|
340
|
-
module MethodCallback
|
341
|
-
def self.lookup
|
342
|
-
method(:perform)
|
343
|
-
end
|
344
|
-
def self.perform num
|
345
|
-
num * 2
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
LibTest.testReturnsCallback_2(MethodCallback.method(:lookup), 0x1234).should eq 0x2468
|
350
|
-
end
|
351
|
-
|
352
|
-
it 'should not blow up when a callback takes a callback as argument' do
|
353
|
-
module LibTest
|
354
|
-
extend FFI::Library
|
355
|
-
ffi_lib TestLibrary::PATH
|
356
|
-
callback :cb_argument, [ :int ], :int
|
357
|
-
callback :cb_with_cb_argument, [ :cb_argument, :int ], :int
|
358
|
-
attach_function :testCallbackAsArgument_2, :testArgumentClosure, [ :cb_with_cb_argument, :int ], :int
|
359
|
-
end
|
360
|
-
end
|
361
|
-
it 'should be able to use the callback argument' do
|
362
|
-
module LibTest
|
363
|
-
extend FFI::Library
|
364
|
-
ffi_lib TestLibrary::PATH
|
365
|
-
callback :cb_argument, [ :int ], :int
|
366
|
-
callback :cb_with_cb_argument, [ :cb_argument, :int ], :int
|
367
|
-
attach_function :testCallbackAsArgument, :testArgumentClosure, [ :cb_with_cb_argument, :cb_argument, :int ], :int
|
368
|
-
end
|
369
|
-
callback_arg_called = false
|
370
|
-
callback_with_callback_arg_called = false
|
371
|
-
callback_arg = Proc.new do |val|
|
372
|
-
callback_arg_called = true
|
373
|
-
val * 2
|
374
|
-
end
|
375
|
-
callback_with_callback_arg = Proc.new do |cb, val|
|
376
|
-
callback_with_callback_arg_called = true
|
377
|
-
cb.call(val)
|
378
|
-
end
|
379
|
-
val = LibTest.testCallbackAsArgument(callback_with_callback_arg, callback_arg, 0xff1)
|
380
|
-
val.should eq 0xff1 * 2
|
381
|
-
callback_arg_called.should be_true
|
382
|
-
callback_with_callback_arg_called.should be_true
|
383
|
-
end
|
384
|
-
it 'function returns callable object' do
|
385
|
-
module LibTest
|
386
|
-
extend FFI::Library
|
387
|
-
ffi_lib TestLibrary::PATH
|
388
|
-
callback :funcptr, [ :int ], :int
|
389
|
-
attach_function :testReturnsFunctionPointer, [ ], :funcptr
|
390
|
-
end
|
391
|
-
f = LibTest.testReturnsFunctionPointer
|
392
|
-
f.call(3).should eq 6
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
end
|
397
|
-
|
398
|
-
|
399
|
-
describe "Callback with " do
|
400
|
-
#
|
401
|
-
# Test callbacks that take an argument, returning void
|
402
|
-
#
|
403
|
-
module LibTest
|
404
|
-
extend FFI::Library
|
405
|
-
ffi_lib TestLibrary::PATH
|
406
|
-
|
407
|
-
class S8F32S32 < FFI::Struct
|
408
|
-
layout :s8, :char, :f32, :float, :s32, :int
|
409
|
-
end
|
410
|
-
|
411
|
-
callback :cbS8rV, [ :char ], :void
|
412
|
-
callback :cbU8rV, [ :uchar ], :void
|
413
|
-
callback :cbS16rV, [ :short ], :void
|
414
|
-
callback :cbU16rV, [ :ushort ], :void
|
415
|
-
|
416
|
-
callback :cbZrV, [ :bool ], :void
|
417
|
-
callback :cbS32rV, [ :int ], :void
|
418
|
-
callback :cbU32rV, [ :uint ], :void
|
419
|
-
|
420
|
-
callback :cbLrV, [ :long ], :void
|
421
|
-
callback :cbULrV, [ :ulong ], :void
|
422
|
-
callback :cbArV, [ :string ], :void
|
423
|
-
callback :cbPrV, [ :pointer], :void
|
424
|
-
callback :cbYrV, [ S8F32S32.ptr ], :void
|
425
|
-
|
426
|
-
callback :cbS64rV, [ :long_long ], :void
|
427
|
-
attach_function :testCallbackCrV, :testClosureBrV, [ :cbS8rV, :char ], :void
|
428
|
-
attach_function :testCallbackU8rV, :testClosureBrV, [ :cbU8rV, :uchar ], :void
|
429
|
-
attach_function :testCallbackSrV, :testClosureSrV, [ :cbS16rV, :short ], :void
|
430
|
-
attach_function :testCallbackU16rV, :testClosureSrV, [ :cbU16rV, :ushort ], :void
|
431
|
-
attach_function :testCallbackZrV, :testClosureZrV, [ :cbZrV, :bool ], :void
|
432
|
-
attach_function :testCallbackIrV, :testClosureIrV, [ :cbS32rV, :int ], :void
|
433
|
-
attach_function :testCallbackU32rV, :testClosureIrV, [ :cbU32rV, :uint ], :void
|
434
|
-
|
435
|
-
attach_function :testCallbackLrV, :testClosureLrV, [ :cbLrV, :long ], :void
|
436
|
-
attach_function :testCallbackULrV, :testClosureULrV, [ :cbULrV, :ulong ], :void
|
437
|
-
|
438
|
-
attach_function :testCallbackLLrV, :testClosureLLrV, [ :cbS64rV, :long_long ], :void
|
439
|
-
attach_function :testCallbackArV, :testClosurePrV, [ :cbArV, :string ], :void
|
440
|
-
attach_function :testCallbackPrV, :testClosurePrV, [ :cbPrV, :pointer], :void
|
441
|
-
attach_function :testCallbackYrV, :testClosurePrV, [ :cbYrV, S8F32S32.in ], :void
|
442
|
-
end
|
443
|
-
it "function with Callback plus another arg should raise error if no arg given" do
|
444
|
-
lambda { LibTest.testCallbackCrV { |*a| }}.should raise_error
|
445
|
-
end
|
446
|
-
it ":char (0) argument" do
|
447
|
-
v = 0xdeadbeef
|
448
|
-
LibTest.testCallbackCrV(0) { |i| v = i }
|
449
|
-
v.should eq 0
|
450
|
-
end
|
451
|
-
it ":char (127) argument" do
|
452
|
-
v = 0xdeadbeef
|
453
|
-
LibTest.testCallbackCrV(127) { |i| v = i }
|
454
|
-
v.should eq 127
|
455
|
-
end
|
456
|
-
it ":char (-128) argument" do
|
457
|
-
v = 0xdeadbeef
|
458
|
-
LibTest.testCallbackCrV(-128) { |i| v = i }
|
459
|
-
v.should eq(-128)
|
460
|
-
end
|
461
|
-
it ":char (-1) argument" do
|
462
|
-
v = 0xdeadbeef
|
463
|
-
LibTest.testCallbackCrV(-1) { |i| v = i }
|
464
|
-
v.should eq(-1)
|
465
|
-
end
|
466
|
-
it ":uchar (0) argument" do
|
467
|
-
v = 0xdeadbeef
|
468
|
-
LibTest.testCallbackU8rV(0) { |i| v = i }
|
469
|
-
v.should eq 0
|
470
|
-
end
|
471
|
-
it ":uchar (127) argument" do
|
472
|
-
v = 0xdeadbeef
|
473
|
-
LibTest.testCallbackU8rV(127) { |i| v = i }
|
474
|
-
v.should eq 127
|
475
|
-
end
|
476
|
-
it ":uchar (128) argument" do
|
477
|
-
v = 0xdeadbeef
|
478
|
-
LibTest.testCallbackU8rV(128) { |i| v = i }
|
479
|
-
v.should eq 128
|
480
|
-
end
|
481
|
-
it ":uchar (255) argument" do
|
482
|
-
v = 0xdeadbeef
|
483
|
-
LibTest.testCallbackU8rV(255) { |i| v = i }
|
484
|
-
v.should eq 255
|
485
|
-
end
|
486
|
-
|
487
|
-
it ":short (0) argument" do
|
488
|
-
v = 0xdeadbeef
|
489
|
-
LibTest.testCallbackSrV(0) { |i| v = i }
|
490
|
-
v.should eq 0
|
491
|
-
end
|
492
|
-
it ":short (0x7fff) argument" do
|
493
|
-
v = 0xdeadbeef
|
494
|
-
LibTest.testCallbackSrV(0x7fff) { |i| v = i }
|
495
|
-
v.should eq 0x7fff
|
496
|
-
end
|
497
|
-
it ":short (-0x8000) argument" do
|
498
|
-
v = 0xdeadbeef
|
499
|
-
LibTest.testCallbackSrV(-0x8000) { |i| v = i }
|
500
|
-
v.should eq(-0x8000)
|
501
|
-
end
|
502
|
-
it ":short (-1) argument" do
|
503
|
-
v = 0xdeadbeef
|
504
|
-
LibTest.testCallbackSrV(-1) { |i| v = i }
|
505
|
-
v.should eq(-1)
|
506
|
-
end
|
507
|
-
it ":ushort (0) argument" do
|
508
|
-
v = 0xdeadbeef
|
509
|
-
LibTest.testCallbackU16rV(0) { |i| v = i }
|
510
|
-
v.should eq 0
|
511
|
-
end
|
512
|
-
it ":ushort (0x7fff) argument" do
|
513
|
-
v = 0xdeadbeef
|
514
|
-
LibTest.testCallbackU16rV(0x7fff) { |i| v = i }
|
515
|
-
v.should eq 0x7fff
|
516
|
-
end
|
517
|
-
it ":ushort (0x8000) argument" do
|
518
|
-
v = 0xdeadbeef
|
519
|
-
LibTest.testCallbackU16rV(0x8000) { |i| v = i }
|
520
|
-
v.should eq 0x8000
|
521
|
-
end
|
522
|
-
it ":ushort (0xffff) argument" do
|
523
|
-
v = 0xdeadbeef
|
524
|
-
LibTest.testCallbackU16rV(0xffff) { |i| v = i }
|
525
|
-
v.should eq 0xffff
|
526
|
-
end
|
527
|
-
it ":bool (true) argument" do
|
528
|
-
v = false
|
529
|
-
LibTest.testCallbackZrV(true) { |i| v = i }
|
530
|
-
v.should be_true
|
531
|
-
end
|
532
|
-
it ":int (0) argument" do
|
533
|
-
v = 0xdeadbeef
|
534
|
-
LibTest.testCallbackIrV(0) { |i| v = i }
|
535
|
-
v.should eq 0
|
536
|
-
end
|
537
|
-
it ":int (0x7fffffff) argument" do
|
538
|
-
v = 0xdeadbeef
|
539
|
-
LibTest.testCallbackIrV(0x7fffffff) { |i| v = i }
|
540
|
-
v.should eq 0x7fffffff
|
541
|
-
end
|
542
|
-
it ":int (-0x80000000) argument" do
|
543
|
-
v = 0xdeadbeef
|
544
|
-
LibTest.testCallbackIrV(-0x80000000) { |i| v = i }
|
545
|
-
v.should eq(-0x80000000)
|
546
|
-
end
|
547
|
-
it ":int (-1) argument" do
|
548
|
-
v = 0xdeadbeef
|
549
|
-
LibTest.testCallbackIrV(-1) { |i| v = i }
|
550
|
-
v.should eq(-1)
|
551
|
-
end
|
552
|
-
it ":uint (0) argument" do
|
553
|
-
v = 0xdeadbeef
|
554
|
-
LibTest.testCallbackU32rV(0) { |i| v = i }
|
555
|
-
v.should eq 0
|
556
|
-
end
|
557
|
-
it ":uint (0x7fffffff) argument" do
|
558
|
-
v = 0xdeadbeef
|
559
|
-
LibTest.testCallbackU32rV(0x7fffffff) { |i| v = i }
|
560
|
-
v.should eq 0x7fffffff
|
561
|
-
end
|
562
|
-
it ":uint (0x80000000) argument" do
|
563
|
-
v = 0xdeadbeef
|
564
|
-
LibTest.testCallbackU32rV(0x80000000) { |i| v = i }
|
565
|
-
v.should eq 0x80000000
|
566
|
-
end
|
567
|
-
it ":uint (0xffffffff) argument" do
|
568
|
-
v = 0xdeadbeef
|
569
|
-
LibTest.testCallbackU32rV(0xffffffff) { |i| v = i }
|
570
|
-
v.should eq 0xffffffff
|
571
|
-
end
|
572
|
-
it ":long (0) argument" do
|
573
|
-
v = 0xdeadbeef
|
574
|
-
LibTest.testCallbackLrV(0) { |i| v = i }
|
575
|
-
v.should eq 0
|
576
|
-
end
|
577
|
-
it ":long (0x7fffffff) argument" do
|
578
|
-
v = 0xdeadbeef
|
579
|
-
LibTest.testCallbackLrV(0x7fffffff) { |i| v = i }
|
580
|
-
v.should eq 0x7fffffff
|
581
|
-
end
|
582
|
-
it ":long (-0x80000000) argument" do
|
583
|
-
v = 0xdeadbeef
|
584
|
-
LibTest.testCallbackLrV(-0x80000000) { |i| v = i }
|
585
|
-
v.should eq(-0x80000000)
|
586
|
-
end
|
587
|
-
it ":long (-1) argument" do
|
588
|
-
v = 0xdeadbeef
|
589
|
-
LibTest.testCallbackLrV(-1) { |i| v = i }
|
590
|
-
v.should eq(-1)
|
591
|
-
end
|
592
|
-
it ":ulong (0) argument" do
|
593
|
-
v = 0xdeadbeef
|
594
|
-
LibTest.testCallbackULrV(0) { |i| v = i }
|
595
|
-
v.should eq 0
|
596
|
-
end
|
597
|
-
it ":ulong (0x7fffffff) argument" do
|
598
|
-
v = 0xdeadbeef
|
599
|
-
LibTest.testCallbackULrV(0x7fffffff) { |i| v = i }
|
600
|
-
v.should eq 0x7fffffff
|
601
|
-
end
|
602
|
-
it ":ulong (0x80000000) argument" do
|
603
|
-
v = 0xdeadbeef
|
604
|
-
LibTest.testCallbackULrV(0x80000000) { |i| v = i }
|
605
|
-
v.should eq 0x80000000
|
606
|
-
end
|
607
|
-
it ":ulong (0xffffffff) argument" do
|
608
|
-
v = 0xdeadbeef
|
609
|
-
LibTest.testCallbackULrV(0xffffffff) { |i| v = i }
|
610
|
-
v.should eq 0xffffffff
|
611
|
-
end
|
612
|
-
it ":long_long (0) argument" do
|
613
|
-
v = 0xdeadbeef
|
614
|
-
LibTest.testCallbackLLrV(0) { |i| v = i }
|
615
|
-
v.should eq 0
|
616
|
-
end
|
617
|
-
it ":long_long (0x7fffffffffffffff) argument" do
|
618
|
-
v = 0xdeadbeef
|
619
|
-
LibTest.testCallbackLLrV(0x7fffffffffffffff) { |i| v = i }
|
620
|
-
v.should eq 0x7fffffffffffffff
|
621
|
-
end
|
622
|
-
it ":long_long (-0x8000000000000000) argument" do
|
623
|
-
v = 0xdeadbeef
|
624
|
-
LibTest.testCallbackLLrV(-0x8000000000000000) { |i| v = i }
|
625
|
-
v.should eq(-0x8000000000000000)
|
626
|
-
end
|
627
|
-
it ":long_long (-1) argument" do
|
628
|
-
v = 0xdeadbeef
|
629
|
-
LibTest.testCallbackLLrV(-1) { |i| v = i }
|
630
|
-
v.should eq(-1)
|
631
|
-
end
|
632
|
-
it ":string argument" do
|
633
|
-
v = nil
|
634
|
-
LibTest.testCallbackArV("Hello, World") { |i| v = i }
|
635
|
-
v.should eq "Hello, World"
|
636
|
-
end
|
637
|
-
it ":string (nil) argument" do
|
638
|
-
v = "Hello, World"
|
639
|
-
LibTest.testCallbackArV(nil) { |i| v = i }
|
640
|
-
v.should be_nil
|
641
|
-
end
|
642
|
-
it ":pointer argument" do
|
643
|
-
v = nil
|
644
|
-
magic = FFI::Pointer.new(0xdeadbeef)
|
645
|
-
LibTest.testCallbackPrV(magic) { |i| v = i }
|
646
|
-
v.should eq magic
|
647
|
-
end
|
648
|
-
it ":pointer (nil) argument" do
|
649
|
-
v = "Hello, World"
|
650
|
-
LibTest.testCallbackPrV(nil) { |i| v = i }
|
651
|
-
v.should eq FFI::Pointer::NULL
|
652
|
-
end
|
653
|
-
it "struct by reference argument" do
|
654
|
-
v = nil
|
655
|
-
magic = LibTest::S8F32S32.new
|
656
|
-
LibTest.testCallbackYrV(magic) { |i| v = i }
|
657
|
-
v.class.should eq magic.class
|
658
|
-
v.pointer == magic.pointer
|
659
|
-
end
|
660
|
-
|
661
|
-
it "struct by reference argument with nil value" do
|
662
|
-
v = LibTest::S8F32S32.new
|
663
|
-
LibTest.testCallbackYrV(nil) { |i| v = i }
|
664
|
-
v.is_a?(FFI::Struct).should be_true
|
665
|
-
v.pointer.should eq FFI::Pointer::NULL
|
666
|
-
end
|
667
|
-
|
668
|
-
end # unless true
|
@@ -1,47 +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
|
-
|
19
|
-
describe "functions with custom parameter types" do
|
20
|
-
before :each do
|
21
|
-
|
22
|
-
Custom_enum = Class.new do
|
23
|
-
extend FFI::DataConverter
|
24
|
-
ToNativeMap= { :a => 1, :b => 2 }
|
25
|
-
FromNativeMap = { 1 => :a, 2 => :b }
|
26
|
-
|
27
|
-
def self.native_type
|
28
|
-
@native_type_called = true
|
29
|
-
FFI::Type::INT32
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.to_native(val, ctx)
|
33
|
-
@to_native_called = true
|
34
|
-
ToNativeMap[val]
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.from_native(val, ctx)
|
38
|
-
@from_native_called = true
|
39
|
-
FromNativeMap[val]
|
40
|
-
end
|
41
|
-
def self.native_type_called?; @native_type_called; end
|
42
|
-
def self.from_native_called?; @from_native_called; end
|
43
|
-
def self.to_native_called?; @to_native_called; end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|