ffi 1.16.3 → 1.17.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +42 -0
- data/Gemfile +9 -2
- data/README.md +1 -1
- data/Rakefile +17 -5
- data/lib/ffi/autopointer.rb +1 -9
- data/lib/ffi/dynamic_library.rb +34 -5
- data/lib/ffi/enum.rb +0 -1
- data/lib/ffi/function.rb +1 -1
- data/lib/ffi/io.rb +2 -2
- data/lib/ffi/library.rb +23 -23
- data/lib/ffi/platform/aarch64-linux/types.conf +74 -3
- data/lib/ffi/pointer.rb +6 -6
- data/lib/ffi/struct.rb +4 -4
- data/lib/ffi/struct_layout.rb +2 -2
- data/lib/ffi/struct_layout_builder.rb +8 -8
- data/lib/ffi/types.rb +51 -49
- data/lib/ffi/version.rb +1 -1
- 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 +34 -532
- metadata.gz.sig +0 -0
- data/ext/ffi_c/AbstractMemory.c +0 -1128
- data/ext/ffi_c/AbstractMemory.h +0 -176
- data/ext/ffi_c/ArrayType.c +0 -198
- data/ext/ffi_c/ArrayType.h +0 -60
- data/ext/ffi_c/Buffer.c +0 -417
- data/ext/ffi_c/Call.c +0 -498
- data/ext/ffi_c/Call.h +0 -107
- data/ext/ffi_c/ClosurePool.c +0 -333
- data/ext/ffi_c/ClosurePool.h +0 -59
- data/ext/ffi_c/DynamicLibrary.c +0 -397
- data/ext/ffi_c/DynamicLibrary.h +0 -98
- data/ext/ffi_c/Function.c +0 -1063
- data/ext/ffi_c/Function.h +0 -84
- data/ext/ffi_c/FunctionInfo.c +0 -322
- data/ext/ffi_c/LastError.c +0 -243
- data/ext/ffi_c/LastError.h +0 -47
- data/ext/ffi_c/LongDouble.c +0 -65
- data/ext/ffi_c/LongDouble.h +0 -47
- data/ext/ffi_c/MappedType.c +0 -211
- data/ext/ffi_c/MappedType.h +0 -57
- data/ext/ffi_c/MemoryPointer.c +0 -219
- data/ext/ffi_c/MemoryPointer.h +0 -49
- data/ext/ffi_c/MethodHandle.c +0 -350
- data/ext/ffi_c/MethodHandle.h +0 -56
- data/ext/ffi_c/Platform.c +0 -78
- data/ext/ffi_c/Platform.h +0 -45
- data/ext/ffi_c/Pointer.c +0 -546
- data/ext/ffi_c/Pointer.h +0 -60
- data/ext/ffi_c/Struct.c +0 -897
- data/ext/ffi_c/Struct.h +0 -115
- data/ext/ffi_c/StructByValue.c +0 -177
- data/ext/ffi_c/StructByValue.h +0 -55
- data/ext/ffi_c/StructLayout.c +0 -769
- data/ext/ffi_c/Thread.c +0 -129
- data/ext/ffi_c/Thread.h +0 -76
- data/ext/ffi_c/Type.c +0 -447
- data/ext/ffi_c/Type.h +0 -63
- data/ext/ffi_c/Types.c +0 -138
- data/ext/ffi_c/Types.h +0 -88
- data/ext/ffi_c/Variadic.c +0 -345
- data/ext/ffi_c/compat.h +0 -82
- data/ext/ffi_c/extconf.rb +0 -115
- data/ext/ffi_c/ffi.c +0 -97
- data/ext/ffi_c/libffi/.appveyor/site.exp +0 -16
- data/ext/ffi_c/libffi/.appveyor/unix-noexec.exp +0 -7
- data/ext/ffi_c/libffi/.appveyor.yml +0 -84
- data/ext/ffi_c/libffi/.ci/ar-lib +0 -270
- data/ext/ffi_c/libffi/.ci/bfin-sim.exp +0 -58
- data/ext/ffi_c/libffi/.ci/build-cross-in-container.sh +0 -18
- data/ext/ffi_c/libffi/.ci/build-in-container.sh +0 -10
- data/ext/ffi_c/libffi/.ci/build.sh +0 -124
- data/ext/ffi_c/libffi/.ci/compile +0 -351
- data/ext/ffi_c/libffi/.ci/install.sh +0 -78
- data/ext/ffi_c/libffi/.ci/m32r-sim.exp +0 -58
- data/ext/ffi_c/libffi/.ci/moxie-sim.exp +0 -60
- data/ext/ffi_c/libffi/.ci/msvs-detect +0 -1103
- data/ext/ffi_c/libffi/.ci/or1k-sim.exp +0 -58
- data/ext/ffi_c/libffi/.ci/powerpc-eabisim.exp +0 -58
- data/ext/ffi_c/libffi/.ci/site.exp +0 -29
- data/ext/ffi_c/libffi/.ci/wine-sim.exp +0 -55
- data/ext/ffi_c/libffi/.circleci/config.yml +0 -156
- data/ext/ffi_c/libffi/.gitattributes +0 -4
- data/ext/ffi_c/libffi/.github/issue_template.md +0 -10
- data/ext/ffi_c/libffi/.github/workflows/build.yml +0 -460
- data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +0 -171
- data/ext/ffi_c/libffi/.gitignore +0 -46
- data/ext/ffi_c/libffi/ChangeLog.old +0 -7407
- data/ext/ffi_c/libffi/LICENSE +0 -21
- data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +0 -353
- data/ext/ffi_c/libffi/Makefile.am +0 -157
- data/ext/ffi_c/libffi/Makefile.in +0 -2127
- data/ext/ffi_c/libffi/README.md +0 -526
- data/ext/ffi_c/libffi/acinclude.m4 +0 -377
- data/ext/ffi_c/libffi/autogen.sh +0 -2
- data/ext/ffi_c/libffi/compile +0 -348
- data/ext/ffi_c/libffi/config.guess +0 -1754
- data/ext/ffi_c/libffi/config.sub +0 -1892
- data/ext/ffi_c/libffi/configure +0 -22791
- data/ext/ffi_c/libffi/configure.ac +0 -451
- data/ext/ffi_c/libffi/configure.host +0 -337
- data/ext/ffi_c/libffi/doc/Makefile.am +0 -3
- data/ext/ffi_c/libffi/doc/Makefile.in +0 -818
- data/ext/ffi_c/libffi/doc/libffi.texi +0 -1046
- data/ext/ffi_c/libffi/doc/version.texi +0 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +0 -188
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +0 -312
- data/ext/ffi_c/libffi/include/Makefile.am +0 -9
- data/ext/ffi_c/libffi/include/Makefile.in +0 -609
- data/ext/ffi_c/libffi/include/ffi.h.in +0 -527
- data/ext/ffi_c/libffi/include/ffi_cfi.h +0 -76
- data/ext/ffi_c/libffi/include/ffi_common.h +0 -182
- data/ext/ffi_c/libffi/include/tramp.h +0 -45
- data/ext/ffi_c/libffi/install-sh +0 -541
- data/ext/ffi_c/libffi/libffi.map.in +0 -76
- data/ext/ffi_c/libffi/libffi.pc.in +0 -11
- data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +0 -997
- data/ext/ffi_c/libffi/libtool-ldflags +0 -106
- data/ext/ffi_c/libffi/libtool-version +0 -29
- data/ext/ffi_c/libffi/ltmain.sh +0 -11448
- data/ext/ffi_c/libffi/m4/asmcfi.m4 +0 -13
- data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +0 -50
- data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +0 -198
- data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +0 -158
- data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +0 -53
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +0 -119
- data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +0 -49
- data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +0 -302
- data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +0 -267
- data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +0 -89
- data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +0 -51
- data/ext/ffi_c/libffi/m4/ax_require_defined.m4 +0 -37
- data/ext/ffi_c/libffi/make_sunver.pl +0 -333
- data/ext/ffi_c/libffi/man/Makefile.am +0 -8
- data/ext/ffi_c/libffi/man/Makefile.in +0 -565
- data/ext/ffi_c/libffi/man/ffi.3 +0 -41
- data/ext/ffi_c/libffi/man/ffi_call.3 +0 -103
- data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +0 -68
- data/ext/ffi_c/libffi/man/ffi_prep_cif_var.3 +0 -73
- data/ext/ffi_c/libffi/missing +0 -215
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +0 -33
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +0 -130
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +0 -57
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +0 -4
- data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +0 -511
- data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/fficonfig.h +0 -219
- data/ext/ffi_c/libffi/msvcc.sh +0 -353
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +0 -1129
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +0 -97
- data/ext/ffi_c/libffi/src/aarch64/internal.h +0 -100
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +0 -543
- data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +0 -506
- data/ext/ffi_c/libffi/src/alpha/ffi.c +0 -521
- data/ext/ffi_c/libffi/src/alpha/ffitarget.h +0 -57
- data/ext/ffi_c/libffi/src/alpha/internal.h +0 -23
- data/ext/ffi_c/libffi/src/alpha/osf.S +0 -282
- data/ext/ffi_c/libffi/src/arc/arcompact.S +0 -210
- data/ext/ffi_c/libffi/src/arc/ffi.c +0 -443
- data/ext/ffi_c/libffi/src/arc/ffitarget.h +0 -67
- data/ext/ffi_c/libffi/src/arm/ffi.c +0 -921
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +0 -89
- data/ext/ffi_c/libffi/src/arm/internal.h +0 -17
- data/ext/ffi_c/libffi/src/arm/sysv.S +0 -456
- data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +0 -311
- data/ext/ffi_c/libffi/src/avr32/ffi.c +0 -423
- data/ext/ffi_c/libffi/src/avr32/ffitarget.h +0 -55
- data/ext/ffi_c/libffi/src/avr32/sysv.S +0 -208
- data/ext/ffi_c/libffi/src/bfin/ffi.c +0 -196
- data/ext/ffi_c/libffi/src/bfin/ffitarget.h +0 -43
- data/ext/ffi_c/libffi/src/bfin/sysv.S +0 -179
- data/ext/ffi_c/libffi/src/closures.c +0 -1107
- data/ext/ffi_c/libffi/src/cris/ffi.c +0 -386
- data/ext/ffi_c/libffi/src/cris/ffitarget.h +0 -56
- data/ext/ffi_c/libffi/src/cris/sysv.S +0 -215
- data/ext/ffi_c/libffi/src/csky/ffi.c +0 -395
- data/ext/ffi_c/libffi/src/csky/ffitarget.h +0 -63
- data/ext/ffi_c/libffi/src/csky/sysv.S +0 -371
- data/ext/ffi_c/libffi/src/debug.c +0 -64
- data/ext/ffi_c/libffi/src/dlmalloc.c +0 -5171
- data/ext/ffi_c/libffi/src/frv/eabi.S +0 -128
- data/ext/ffi_c/libffi/src/frv/ffi.c +0 -292
- data/ext/ffi_c/libffi/src/frv/ffitarget.h +0 -62
- data/ext/ffi_c/libffi/src/ia64/ffi.c +0 -616
- data/ext/ffi_c/libffi/src/ia64/ffitarget.h +0 -56
- data/ext/ffi_c/libffi/src/ia64/ia64_flags.h +0 -40
- data/ext/ffi_c/libffi/src/ia64/unix.S +0 -585
- data/ext/ffi_c/libffi/src/java_raw_api.c +0 -374
- data/ext/ffi_c/libffi/src/kvx/asm.h +0 -5
- data/ext/ffi_c/libffi/src/kvx/ffi.c +0 -273
- data/ext/ffi_c/libffi/src/kvx/ffitarget.h +0 -75
- data/ext/ffi_c/libffi/src/kvx/sysv.S +0 -127
- data/ext/ffi_c/libffi/src/loongarch64/ffi.c +0 -621
- data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +0 -82
- data/ext/ffi_c/libffi/src/loongarch64/sysv.S +0 -327
- data/ext/ffi_c/libffi/src/m32r/ffi.c +0 -249
- data/ext/ffi_c/libffi/src/m32r/ffitarget.h +0 -53
- data/ext/ffi_c/libffi/src/m32r/sysv.S +0 -121
- data/ext/ffi_c/libffi/src/m68k/ffi.c +0 -362
- data/ext/ffi_c/libffi/src/m68k/ffitarget.h +0 -54
- data/ext/ffi_c/libffi/src/m68k/sysv.S +0 -357
- data/ext/ffi_c/libffi/src/m88k/ffi.c +0 -400
- data/ext/ffi_c/libffi/src/m88k/ffitarget.h +0 -49
- data/ext/ffi_c/libffi/src/m88k/obsd.S +0 -209
- data/ext/ffi_c/libffi/src/metag/ffi.c +0 -330
- data/ext/ffi_c/libffi/src/metag/ffitarget.h +0 -53
- data/ext/ffi_c/libffi/src/metag/sysv.S +0 -311
- data/ext/ffi_c/libffi/src/microblaze/ffi.c +0 -321
- data/ext/ffi_c/libffi/src/microblaze/ffitarget.h +0 -53
- data/ext/ffi_c/libffi/src/microblaze/sysv.S +0 -302
- data/ext/ffi_c/libffi/src/mips/ffi.c +0 -1309
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +0 -251
- data/ext/ffi_c/libffi/src/mips/n32.S +0 -772
- data/ext/ffi_c/libffi/src/mips/o32.S +0 -561
- data/ext/ffi_c/libffi/src/moxie/eabi.S +0 -101
- data/ext/ffi_c/libffi/src/moxie/ffi.c +0 -310
- data/ext/ffi_c/libffi/src/moxie/ffitarget.h +0 -52
- data/ext/ffi_c/libffi/src/nios2/ffi.c +0 -304
- data/ext/ffi_c/libffi/src/nios2/ffitarget.h +0 -52
- data/ext/ffi_c/libffi/src/nios2/sysv.S +0 -136
- data/ext/ffi_c/libffi/src/or1k/ffi.c +0 -341
- data/ext/ffi_c/libffi/src/or1k/ffitarget.h +0 -58
- data/ext/ffi_c/libffi/src/or1k/sysv.S +0 -107
- data/ext/ffi_c/libffi/src/pa/ffi.c +0 -673
- data/ext/ffi_c/libffi/src/pa/ffi64.c +0 -614
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +0 -94
- data/ext/ffi_c/libffi/src/pa/hpux32.S +0 -417
- data/ext/ffi_c/libffi/src/pa/hpux64.S +0 -681
- data/ext/ffi_c/libffi/src/pa/linux.S +0 -427
- data/ext/ffi_c/libffi/src/powerpc/aix.S +0 -566
- data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +0 -694
- data/ext/ffi_c/libffi/src/powerpc/asm.h +0 -125
- data/ext/ffi_c/libffi/src/powerpc/darwin.S +0 -378
- data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +0 -571
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +0 -175
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +0 -1452
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +0 -1153
- data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +0 -105
- data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +0 -923
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +0 -204
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +0 -293
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +0 -566
- data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +0 -397
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +0 -173
- data/ext/ffi_c/libffi/src/powerpc/t-aix +0 -5
- data/ext/ffi_c/libffi/src/prep_cif.c +0 -283
- data/ext/ffi_c/libffi/src/raw_api.c +0 -267
- data/ext/ffi_c/libffi/src/riscv/ffi.c +0 -514
- data/ext/ffi_c/libffi/src/riscv/ffitarget.h +0 -69
- data/ext/ffi_c/libffi/src/riscv/sysv.S +0 -293
- data/ext/ffi_c/libffi/src/s390/ffi.c +0 -756
- data/ext/ffi_c/libffi/src/s390/ffitarget.h +0 -70
- data/ext/ffi_c/libffi/src/s390/internal.h +0 -11
- data/ext/ffi_c/libffi/src/s390/sysv.S +0 -325
- data/ext/ffi_c/libffi/src/sh/ffi.c +0 -717
- data/ext/ffi_c/libffi/src/sh/ffitarget.h +0 -54
- data/ext/ffi_c/libffi/src/sh/sysv.S +0 -850
- data/ext/ffi_c/libffi/src/sh64/ffi.c +0 -469
- data/ext/ffi_c/libffi/src/sh64/ffitarget.h +0 -58
- data/ext/ffi_c/libffi/src/sh64/sysv.S +0 -539
- data/ext/ffi_c/libffi/src/sparc/ffi.c +0 -468
- data/ext/ffi_c/libffi/src/sparc/ffi64.c +0 -624
- data/ext/ffi_c/libffi/src/sparc/ffitarget.h +0 -81
- data/ext/ffi_c/libffi/src/sparc/internal.h +0 -26
- data/ext/ffi_c/libffi/src/sparc/v8.S +0 -443
- data/ext/ffi_c/libffi/src/sparc/v9.S +0 -440
- data/ext/ffi_c/libffi/src/tile/ffi.c +0 -355
- data/ext/ffi_c/libffi/src/tile/ffitarget.h +0 -65
- data/ext/ffi_c/libffi/src/tile/tile.S +0 -360
- data/ext/ffi_c/libffi/src/tramp.c +0 -716
- data/ext/ffi_c/libffi/src/types.c +0 -108
- data/ext/ffi_c/libffi/src/vax/elfbsd.S +0 -195
- data/ext/ffi_c/libffi/src/vax/ffi.c +0 -276
- data/ext/ffi_c/libffi/src/vax/ffitarget.h +0 -49
- data/ext/ffi_c/libffi/src/wasm32/ffi.c +0 -934
- data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +0 -62
- data/ext/ffi_c/libffi/src/x86/asmnames.h +0 -30
- data/ext/ffi_c/libffi/src/x86/ffi.c +0 -832
- data/ext/ffi_c/libffi/src/x86/ffi64.c +0 -950
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +0 -164
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +0 -361
- data/ext/ffi_c/libffi/src/x86/internal.h +0 -43
- data/ext/ffi_c/libffi/src/x86/internal64.h +0 -36
- data/ext/ffi_c/libffi/src/x86/sysv.S +0 -1272
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +0 -998
- data/ext/ffi_c/libffi/src/x86/unix64.S +0 -711
- data/ext/ffi_c/libffi/src/x86/win64.S +0 -254
- data/ext/ffi_c/libffi/src/x86/win64_intel.S +0 -238
- data/ext/ffi_c/libffi/src/xtensa/ffi.c +0 -306
- data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +0 -57
- data/ext/ffi_c/libffi/src/xtensa/sysv.S +0 -268
- data/ext/ffi_c/libffi/stamp-h.in +0 -1
- data/ext/ffi_c/libffi/testsuite/Makefile.am +0 -135
- data/ext/ffi_c/libffi/testsuite/Makefile.in +0 -664
- data/ext/ffi_c/libffi/testsuite/config/default.exp +0 -1
- data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +0 -54
- data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +0 -63
- data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +0 -80
- data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +0 -48
- data/ext/ffi_c/libffi/testsuite/emscripten/test.html +0 -7
- data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +0 -51
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +0 -682
- data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +0 -283
- data/ext/ffi_c/libffi/testsuite/lib/wrapper.exp +0 -45
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +0 -28
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/README +0 -78
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/alignof.h +0 -50
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +0 -63
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +0 -1746
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +0 -2885
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +0 -747
- data/ext/ffi_c/libffi/testsuite/libffi.call/align_mixed.c +0 -46
- data/ext/ffi_c/libffi/testsuite/libffi.call/align_stdcall.c +0 -46
- data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +0 -41
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +0 -54
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +0 -26
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +0 -163
- data/ext/ffi_c/libffi/testsuite/libffi.call/float.c +0 -59
- data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +0 -60
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +0 -61
- data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +0 -74
- data/ext/ffi_c/libffi/testsuite/libffi.call/float4.c +0 -62
- data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +0 -110
- data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +0 -59
- data/ext/ffi_c/libffi/testsuite/libffi.call/many2.c +0 -57
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_double.c +0 -70
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_mixed.c +0 -78
- data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +0 -52
- data/ext/ffi_c/libffi/testsuite/libffi.call/offsets.c +0 -46
- data/ext/ffi_c/libffi/testsuite/libffi.call/pr1172638.c +0 -127
- data/ext/ffi_c/libffi/testsuite/libffi.call/promotion.c +0 -59
- data/ext/ffi_c/libffi/testsuite/libffi.call/pyobjc_tc.c +0 -114
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +0 -36
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl1.c +0 -43
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl2.c +0 -42
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl.c +0 -35
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl1.c +0 -36
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl2.c +0 -49
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl3.c +0 -42
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +0 -34
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll.c +0 -41
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +0 -48
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +0 -36
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +0 -42
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +0 -38
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +0 -42
- data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +0 -60
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +0 -43
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +0 -49
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +0 -49
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +0 -55
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +0 -67
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +0 -57
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +0 -67
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +0 -60
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +0 -64
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +0 -66
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +0 -64
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +0 -74
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +0 -81
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +0 -68
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +0 -63
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +0 -65
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +0 -65
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +0 -67
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +0 -67
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +0 -93
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +0 -61
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +0 -63
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +0 -90
- data/ext/ffi_c/libffi/testsuite/libffi.call/uninitialized.c +0 -61
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +0 -78
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +0 -220
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +0 -154
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +0 -134
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +0 -134
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +0 -140
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +0 -67
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn0.c +0 -90
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn1.c +0 -83
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn2.c +0 -83
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn3.c +0 -102
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn4.c +0 -91
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn5.c +0 -94
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn6.c +0 -92
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_loc_fn0.c +0 -96
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_simple.c +0 -61
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_12byte.c +0 -112
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_16byte.c +0 -117
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_18byte.c +0 -120
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_19byte.c +0 -131
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_1_1byte.c +0 -93
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte.c +0 -109
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte1.c +0 -113
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_24byte.c +0 -145
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_2byte.c +0 -103
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3_1byte.c +0 -114
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte1.c +0 -103
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte2.c +0 -103
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +0 -113
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4_1byte.c +0 -120
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4byte.c +0 -103
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5_1_byte.c +0 -137
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5byte.c +0 -116
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_64byte.c +0 -148
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6_1_byte.c +0 -140
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6byte.c +0 -121
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7_1_byte.c +0 -155
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7byte.c +0 -121
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_8byte.c +0 -102
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte1.c +0 -103
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte2.c +0 -103
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_double.c +0 -111
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_float.c +0 -109
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble.c +0 -111
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split.c +0 -147
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split2.c +0 -152
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_pointer.c +0 -113
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint16.c +0 -108
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint32.c +0 -106
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint64.c +0 -109
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint16.c +0 -108
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint32.c +0 -109
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint64.c +0 -111
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +0 -68
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_double.c +0 -43
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_double_va.c +0 -69
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_float.c +0 -46
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble.c +0 -115
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble_va.c +0 -80
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_args.c +0 -70
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c +0 -55
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_schar.c +0 -78
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshort.c +0 -79
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +0 -94
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_uchar.c +0 -99
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c +0 -78
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +0 -94
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer.c +0 -79
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer_stack.c +0 -152
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_schar.c +0 -47
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sint.c +0 -44
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sshort.c +0 -45
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +0 -125
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar.c +0 -45
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint.c +0 -47
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +0 -49
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +0 -49
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulonglong.c +0 -49
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort.c +0 -46
- data/ext/ffi_c/libffi/testsuite/libffi.closures/err_bad_abi.c +0 -36
- data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +0 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +0 -343
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct.c +0 -175
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct1.c +0 -161
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct10.c +0 -146
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +0 -137
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +0 -86
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +0 -115
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct2.c +0 -119
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct3.c +0 -120
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct4.c +0 -120
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct5.c +0 -121
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct6.c +0 -142
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct7.c +0 -120
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct8.c +0 -142
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct9.c +0 -142
- data/ext/ffi_c/libffi/testsuite/libffi.closures/problem1.c +0 -90
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +0 -86
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +0 -102
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +0 -101
- data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_large.c +0 -145
- data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_large2.c +0 -148
- data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium.c +0 -124
- data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium2.c +0 -125
- data/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c +0 -75
- data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +0 -118
- data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +0 -55
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex.inc +0 -91
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_double.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_float.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc +0 -42
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_double.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_float.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_longdouble.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct.inc +0 -71
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_double.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_float.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va.inc +0 -80
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_double.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_float.c +0 -16
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.exp +0 -36
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc +0 -51
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_double.inc +0 -7
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_float.inc +0 -7
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc +0 -7
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_double.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_float.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +0 -86
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_longdouble.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/ffitest.h +0 -1
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex.inc +0 -78
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_double.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_float.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_longdouble.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc +0 -37
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1.inc +0 -41
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_double.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_float.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_longdouble.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2.inc +0 -44
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_double.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_float.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_longdouble.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_double.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_float.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_longdouble.c +0 -10
- data/ext/ffi_c/libffi/testsuite/libffi.go/aa-direct.c +0 -34
- data/ext/ffi_c/libffi/testsuite/libffi.go/closure1.c +0 -28
- data/ext/ffi_c/libffi/testsuite/libffi.go/ffitest.h +0 -1
- data/ext/ffi_c/libffi/testsuite/libffi.go/go.exp +0 -36
- data/ext/ffi_c/libffi/testsuite/libffi.go/static-chain.h +0 -19
- data/ext/ffi_c/libffi.bsd.mk +0 -40
- data/ext/ffi_c/libffi.darwin.mk +0 -105
- data/ext/ffi_c/libffi.gnu.mk +0 -32
- data/ext/ffi_c/libffi.mk +0 -18
- data/ext/ffi_c/libffi.vc.mk +0 -26
- data/ext/ffi_c/libffi.vc64.mk +0 -26
- data/ext/ffi_c/rbffi.h +0 -55
- data/ext/ffi_c/rbffi_endian.h +0 -59
data/ext/ffi_c/Pointer.c
DELETED
|
@@ -1,546 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2008, 2009, Wayne Meissner
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2008-2013, Ruby FFI project contributors
|
|
5
|
-
* All rights reserved.
|
|
6
|
-
*
|
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
|
8
|
-
* modification, are permitted provided that the following conditions are met:
|
|
9
|
-
* * Redistributions of source code must retain the above copyright
|
|
10
|
-
* notice, this list of conditions and the following disclaimer.
|
|
11
|
-
* * Redistributions in binary form must reproduce the above copyright
|
|
12
|
-
* notice, this list of conditions and the following disclaimer in the
|
|
13
|
-
* documentation and/or other materials provided with the distribution.
|
|
14
|
-
* * Neither the name of the Ruby FFI project nor the
|
|
15
|
-
* names of its contributors may be used to endorse or promote products
|
|
16
|
-
* derived from this software without specific prior written permission.
|
|
17
|
-
*
|
|
18
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
19
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
-
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
22
|
-
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23
|
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
24
|
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
25
|
-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
27
|
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#include <stdint.h>
|
|
31
|
-
#include <stdbool.h>
|
|
32
|
-
#include <limits.h>
|
|
33
|
-
#include <ruby.h>
|
|
34
|
-
#include "rbffi.h"
|
|
35
|
-
#include "rbffi_endian.h"
|
|
36
|
-
#include "compat.h"
|
|
37
|
-
#include "AbstractMemory.h"
|
|
38
|
-
#include "Pointer.h"
|
|
39
|
-
|
|
40
|
-
#define POINTER(obj) rbffi_AbstractMemory_Cast((obj), &rbffi_pointer_data_type)
|
|
41
|
-
|
|
42
|
-
VALUE rbffi_PointerClass = Qnil;
|
|
43
|
-
VALUE rbffi_NullPointerSingleton = Qnil;
|
|
44
|
-
|
|
45
|
-
static void ptr_release(void *data);
|
|
46
|
-
static void ptr_mark(void *data);
|
|
47
|
-
static void ptr_compact(void *data);
|
|
48
|
-
static size_t ptr_memsize(const void *data);
|
|
49
|
-
|
|
50
|
-
const rb_data_type_t rbffi_pointer_data_type = { /* extern */
|
|
51
|
-
.wrap_struct_name = "FFI::Pointer",
|
|
52
|
-
.function = {
|
|
53
|
-
.dmark = ptr_mark,
|
|
54
|
-
.dfree = ptr_release,
|
|
55
|
-
.dsize = ptr_memsize,
|
|
56
|
-
ffi_compact_callback( ptr_compact )
|
|
57
|
-
},
|
|
58
|
-
.parent = &rbffi_abstract_memory_data_type,
|
|
59
|
-
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
|
60
|
-
// macro to update VALUE references, as to trigger write barriers.
|
|
61
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | FFI_RUBY_TYPED_FROZEN_SHAREABLE
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
VALUE
|
|
65
|
-
rbffi_Pointer_NewInstance(void* addr)
|
|
66
|
-
{
|
|
67
|
-
Pointer* p;
|
|
68
|
-
VALUE obj;
|
|
69
|
-
|
|
70
|
-
if (addr == NULL) {
|
|
71
|
-
return rbffi_NullPointerSingleton;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
obj = TypedData_Make_Struct(rbffi_PointerClass, Pointer, &rbffi_pointer_data_type, p);
|
|
75
|
-
p->memory.address = addr;
|
|
76
|
-
p->memory.size = LONG_MAX;
|
|
77
|
-
p->memory.flags = (addr == NULL) ? 0 : (MEM_RD | MEM_WR);
|
|
78
|
-
p->memory.typeSize = 1;
|
|
79
|
-
RB_OBJ_WRITE(obj, &p->rbParent, Qnil);
|
|
80
|
-
|
|
81
|
-
return obj;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
static VALUE
|
|
85
|
-
ptr_allocate(VALUE klass)
|
|
86
|
-
{
|
|
87
|
-
Pointer* p;
|
|
88
|
-
VALUE obj;
|
|
89
|
-
|
|
90
|
-
obj = TypedData_Make_Struct(klass, Pointer, &rbffi_pointer_data_type, p);
|
|
91
|
-
RB_OBJ_WRITE(obj, &p->rbParent, Qnil);
|
|
92
|
-
p->memory.flags = MEM_RD | MEM_WR;
|
|
93
|
-
|
|
94
|
-
return obj;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/*
|
|
98
|
-
* @overload initialize(pointer)
|
|
99
|
-
* @param [Pointer] pointer another pointer to initialize from
|
|
100
|
-
* Create a new pointer from another {Pointer}.
|
|
101
|
-
* @overload initialize(type, address)
|
|
102
|
-
* @param [Type] type type for pointer
|
|
103
|
-
* @param [Integer] address base address for pointer
|
|
104
|
-
* Create a new pointer from a {Type} and a base address
|
|
105
|
-
* @return [self]
|
|
106
|
-
* A new instance of Pointer.
|
|
107
|
-
*/
|
|
108
|
-
static VALUE
|
|
109
|
-
ptr_initialize(int argc, VALUE* argv, VALUE self)
|
|
110
|
-
{
|
|
111
|
-
Pointer* p;
|
|
112
|
-
VALUE rbType = Qnil, rbAddress = Qnil;
|
|
113
|
-
int typeSize = 1;
|
|
114
|
-
|
|
115
|
-
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, p);
|
|
116
|
-
|
|
117
|
-
switch (rb_scan_args(argc, argv, "11", &rbType, &rbAddress)) {
|
|
118
|
-
case 1:
|
|
119
|
-
rbAddress = rbType;
|
|
120
|
-
typeSize = 1;
|
|
121
|
-
break;
|
|
122
|
-
case 2:
|
|
123
|
-
typeSize = rbffi_type_size(rbType);
|
|
124
|
-
break;
|
|
125
|
-
default:
|
|
126
|
-
rb_raise(rb_eArgError, "Invalid arguments");
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
switch (TYPE(rbAddress)) {
|
|
130
|
-
case T_FIXNUM:
|
|
131
|
-
case T_BIGNUM:
|
|
132
|
-
p->memory.address = (void*) (uintptr_t) NUM2ULL(rbAddress);
|
|
133
|
-
p->memory.size = LONG_MAX;
|
|
134
|
-
if (p->memory.address == NULL) {
|
|
135
|
-
p->memory.flags = 0;
|
|
136
|
-
}
|
|
137
|
-
break;
|
|
138
|
-
|
|
139
|
-
default:
|
|
140
|
-
if (rb_obj_is_kind_of(rbAddress, rbffi_PointerClass)) {
|
|
141
|
-
Pointer* orig;
|
|
142
|
-
|
|
143
|
-
RB_OBJ_WRITE(self, &p->rbParent, rbAddress);
|
|
144
|
-
TypedData_Get_Struct(rbAddress, Pointer, &rbffi_pointer_data_type, orig);
|
|
145
|
-
p->memory = orig->memory;
|
|
146
|
-
} else {
|
|
147
|
-
rb_raise(rb_eTypeError, "wrong argument type, expected Integer or FFI::Pointer");
|
|
148
|
-
}
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
p->memory.typeSize = typeSize;
|
|
153
|
-
|
|
154
|
-
return self;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/*
|
|
158
|
-
* call-seq: ptr.initialize_copy(other)
|
|
159
|
-
* @param [Pointer] other source for cloning or dupping
|
|
160
|
-
* @return [self]
|
|
161
|
-
* @raise {RuntimeError} if +other+ is an unbounded memory area, or is unreadable/unwritable
|
|
162
|
-
* @raise {NoMemError} if failed to allocate memory for new object
|
|
163
|
-
* DO NOT CALL THIS METHOD.
|
|
164
|
-
*
|
|
165
|
-
* This method is internally used by #dup and #clone. Memory content is copied from +other+.
|
|
166
|
-
*/
|
|
167
|
-
static VALUE
|
|
168
|
-
ptr_initialize_copy(VALUE self, VALUE other)
|
|
169
|
-
{
|
|
170
|
-
AbstractMemory* src;
|
|
171
|
-
Pointer* dst;
|
|
172
|
-
|
|
173
|
-
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, dst);
|
|
174
|
-
src = POINTER(other);
|
|
175
|
-
if (src->size == LONG_MAX) {
|
|
176
|
-
rb_raise(rb_eRuntimeError, "cannot duplicate unbounded memory area");
|
|
177
|
-
return Qnil;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if ((dst->memory.flags & (MEM_RD | MEM_WR)) != (MEM_RD | MEM_WR)) {
|
|
181
|
-
rb_raise(rb_eRuntimeError, "cannot duplicate unreadable/unwritable memory area");
|
|
182
|
-
return Qnil;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (dst->storage != NULL) {
|
|
186
|
-
xfree(dst->storage);
|
|
187
|
-
dst->storage = NULL;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
dst->storage = xmalloc(src->size + 7);
|
|
191
|
-
if (dst->storage == NULL) {
|
|
192
|
-
rb_raise(rb_eNoMemError, "failed to allocate memory size=%lu bytes", src->size);
|
|
193
|
-
return Qnil;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
dst->allocated = true;
|
|
197
|
-
dst->autorelease = true;
|
|
198
|
-
dst->memory.address = (void *) (((uintptr_t) dst->storage + 0x7) & (uintptr_t) ~0x7ULL);
|
|
199
|
-
dst->memory.size = src->size;
|
|
200
|
-
dst->memory.typeSize = src->typeSize;
|
|
201
|
-
|
|
202
|
-
/* finally, copy the actual memory contents */
|
|
203
|
-
memcpy(dst->memory.address, src->address, src->size);
|
|
204
|
-
|
|
205
|
-
return self;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
static VALUE
|
|
209
|
-
slice(VALUE self, long offset, long size)
|
|
210
|
-
{
|
|
211
|
-
AbstractMemory* ptr;
|
|
212
|
-
Pointer* p;
|
|
213
|
-
VALUE retval;
|
|
214
|
-
|
|
215
|
-
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, ptr);
|
|
216
|
-
checkBounds(ptr, offset, size == LONG_MAX ? 1 : size);
|
|
217
|
-
|
|
218
|
-
retval = TypedData_Make_Struct(rbffi_PointerClass, Pointer, &rbffi_pointer_data_type, p);
|
|
219
|
-
|
|
220
|
-
p->memory.address = ptr->address + offset;
|
|
221
|
-
p->memory.size = size;
|
|
222
|
-
p->memory.flags = ptr->flags;
|
|
223
|
-
p->memory.typeSize = ptr->typeSize;
|
|
224
|
-
RB_OBJ_WRITE(retval, &p->rbParent, self);
|
|
225
|
-
|
|
226
|
-
return retval;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/*
|
|
230
|
-
* Document-method: +
|
|
231
|
-
* call-seq: ptr + offset
|
|
232
|
-
* @param [Numeric] offset
|
|
233
|
-
* @return [Pointer]
|
|
234
|
-
* Return a new {Pointer} from an existing pointer and an +offset+.
|
|
235
|
-
*/
|
|
236
|
-
static VALUE
|
|
237
|
-
ptr_plus(VALUE self, VALUE offset)
|
|
238
|
-
{
|
|
239
|
-
AbstractMemory* ptr;
|
|
240
|
-
long off = NUM2LONG(offset);
|
|
241
|
-
|
|
242
|
-
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, ptr);
|
|
243
|
-
|
|
244
|
-
return slice(self, off, ptr->size == LONG_MAX ? LONG_MAX : ptr->size - off);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/*
|
|
248
|
-
* call-seq: ptr.slice(offset, length)
|
|
249
|
-
* @param [Numeric] offset
|
|
250
|
-
* @param [Numeric] length
|
|
251
|
-
* @return [Pointer]
|
|
252
|
-
* Return a new {Pointer} from an existing one. This pointer points on same contents
|
|
253
|
-
* from +offset+ for a length +length+.
|
|
254
|
-
*/
|
|
255
|
-
static VALUE
|
|
256
|
-
ptr_slice(VALUE self, VALUE rbOffset, VALUE rbLength)
|
|
257
|
-
{
|
|
258
|
-
return slice(self, NUM2LONG(rbOffset), NUM2LONG(rbLength));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/*
|
|
262
|
-
* call-seq: ptr.inspect
|
|
263
|
-
* @return [String]
|
|
264
|
-
* Inspect pointer object.
|
|
265
|
-
*/
|
|
266
|
-
static VALUE
|
|
267
|
-
ptr_inspect(VALUE self)
|
|
268
|
-
{
|
|
269
|
-
char buf[100];
|
|
270
|
-
Pointer* ptr;
|
|
271
|
-
|
|
272
|
-
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
|
273
|
-
|
|
274
|
-
if (ptr->memory.size != LONG_MAX) {
|
|
275
|
-
snprintf(buf, sizeof(buf), "#<%s address=%p size=%lu>",
|
|
276
|
-
rb_obj_classname(self), ptr->memory.address, ptr->memory.size);
|
|
277
|
-
} else {
|
|
278
|
-
snprintf(buf, sizeof(buf), "#<%s address=%p>", rb_obj_classname(self), ptr->memory.address);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return rb_str_new2(buf);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/*
|
|
285
|
-
* Document-method: null?
|
|
286
|
-
* call-seq: ptr.null?
|
|
287
|
-
* @return [Boolean]
|
|
288
|
-
* Return +true+ if +self+ is a {NULL} pointer.
|
|
289
|
-
*/
|
|
290
|
-
static VALUE
|
|
291
|
-
ptr_null_p(VALUE self)
|
|
292
|
-
{
|
|
293
|
-
Pointer* ptr;
|
|
294
|
-
|
|
295
|
-
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
|
296
|
-
|
|
297
|
-
return ptr->memory.address == NULL ? Qtrue : Qfalse;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/*
|
|
301
|
-
* Document-method: ==
|
|
302
|
-
* call-seq: ptr == other
|
|
303
|
-
* @param [Pointer] other
|
|
304
|
-
* Check equality between +self+ and +other+. Equality is tested on {#address}.
|
|
305
|
-
*/
|
|
306
|
-
static VALUE
|
|
307
|
-
ptr_equals(VALUE self, VALUE other)
|
|
308
|
-
{
|
|
309
|
-
Pointer* ptr;
|
|
310
|
-
|
|
311
|
-
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
|
312
|
-
|
|
313
|
-
if (NIL_P(other)) {
|
|
314
|
-
return ptr->memory.address == NULL ? Qtrue : Qfalse;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
return ptr->memory.address == POINTER(other)->address ? Qtrue : Qfalse;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/*
|
|
321
|
-
* call-seq: ptr.address
|
|
322
|
-
* @return [Numeric] pointer's base address
|
|
323
|
-
* Return +self+'s base address (alias: #to_i).
|
|
324
|
-
*/
|
|
325
|
-
static VALUE
|
|
326
|
-
ptr_address(VALUE self)
|
|
327
|
-
{
|
|
328
|
-
Pointer* ptr;
|
|
329
|
-
|
|
330
|
-
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
|
331
|
-
|
|
332
|
-
return ULL2NUM((uintptr_t) ptr->memory.address);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
#if BYTE_ORDER == LITTLE_ENDIAN
|
|
336
|
-
# define SWAPPED_ORDER BIG_ENDIAN
|
|
337
|
-
#else
|
|
338
|
-
# define SWAPPED_ORDER LITTLE_ENDIAN
|
|
339
|
-
#endif
|
|
340
|
-
|
|
341
|
-
/*
|
|
342
|
-
* Get or set +self+'s endianness
|
|
343
|
-
* @overload order
|
|
344
|
-
* @return [:big, :little] endianness of +self+
|
|
345
|
-
* @overload order(order)
|
|
346
|
-
* @param [Symbol] order endianness to set (+:little+, +:big+ or +:network+). +:big+ and +:network+
|
|
347
|
-
* are synonymous.
|
|
348
|
-
* @return a new pointer with the new order
|
|
349
|
-
*/
|
|
350
|
-
static VALUE
|
|
351
|
-
ptr_order(int argc, VALUE* argv, VALUE self)
|
|
352
|
-
{
|
|
353
|
-
Pointer* ptr;
|
|
354
|
-
|
|
355
|
-
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
|
356
|
-
if (argc == 0) {
|
|
357
|
-
int order = (ptr->memory.flags & MEM_SWAP) == 0 ? BYTE_ORDER : SWAPPED_ORDER;
|
|
358
|
-
return order == BIG_ENDIAN ? ID2SYM(rb_intern("big")) : ID2SYM(rb_intern("little"));
|
|
359
|
-
} else {
|
|
360
|
-
VALUE rbOrder = Qnil;
|
|
361
|
-
int order = BYTE_ORDER;
|
|
362
|
-
|
|
363
|
-
if (rb_scan_args(argc, argv, "1", &rbOrder) < 1) {
|
|
364
|
-
rb_raise(rb_eArgError, "need byte order");
|
|
365
|
-
}
|
|
366
|
-
if (SYMBOL_P(rbOrder)) {
|
|
367
|
-
ID id = SYM2ID(rbOrder);
|
|
368
|
-
if (id == rb_intern("little")) {
|
|
369
|
-
order = LITTLE_ENDIAN;
|
|
370
|
-
|
|
371
|
-
} else if (id == rb_intern("big") || id == rb_intern("network")) {
|
|
372
|
-
order = BIG_ENDIAN;
|
|
373
|
-
} else {
|
|
374
|
-
rb_raise(rb_eArgError, "unknown byte order");
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
if (order != BYTE_ORDER) {
|
|
378
|
-
Pointer* p2;
|
|
379
|
-
VALUE retval = slice(self, 0, ptr->memory.size);
|
|
380
|
-
|
|
381
|
-
TypedData_Get_Struct(retval, Pointer, &rbffi_pointer_data_type, p2);
|
|
382
|
-
p2->memory.flags |= MEM_SWAP;
|
|
383
|
-
return retval;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
return self;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
/*
|
|
392
|
-
* call-seq: ptr.free
|
|
393
|
-
* @return [self]
|
|
394
|
-
* Free memory pointed by +self+.
|
|
395
|
-
*/
|
|
396
|
-
static VALUE
|
|
397
|
-
ptr_free(VALUE self)
|
|
398
|
-
{
|
|
399
|
-
Pointer* ptr;
|
|
400
|
-
|
|
401
|
-
rb_check_frozen(self);
|
|
402
|
-
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
|
403
|
-
|
|
404
|
-
if (ptr->allocated) {
|
|
405
|
-
if (ptr->storage != NULL) {
|
|
406
|
-
xfree(ptr->storage);
|
|
407
|
-
ptr->storage = NULL;
|
|
408
|
-
}
|
|
409
|
-
ptr->allocated = false;
|
|
410
|
-
|
|
411
|
-
} else {
|
|
412
|
-
VALUE caller = rb_funcall(rb_funcall(Qnil, rb_intern("caller"), 0), rb_intern("first"), 0);
|
|
413
|
-
|
|
414
|
-
rb_warn("calling free on non allocated pointer %s from %s", RSTRING_PTR(ptr_inspect(self)), RSTRING_PTR(rb_str_to_str(caller)));
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
return self;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
static VALUE
|
|
421
|
-
ptr_type_size(VALUE self)
|
|
422
|
-
{
|
|
423
|
-
Pointer* ptr;
|
|
424
|
-
|
|
425
|
-
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
|
426
|
-
|
|
427
|
-
return INT2NUM(ptr->memory.typeSize);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/*
|
|
431
|
-
* call-seq: ptr.autorelease = autorelease
|
|
432
|
-
* @param [Boolean] autorelease
|
|
433
|
-
* @return [Boolean] +autorelease+
|
|
434
|
-
* Set +autorelease+ attribute. See also Autorelease section.
|
|
435
|
-
*/
|
|
436
|
-
static VALUE
|
|
437
|
-
ptr_autorelease(VALUE self, VALUE autorelease)
|
|
438
|
-
{
|
|
439
|
-
Pointer* ptr;
|
|
440
|
-
|
|
441
|
-
rb_check_frozen(self);
|
|
442
|
-
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
|
443
|
-
ptr->autorelease = autorelease == Qtrue;
|
|
444
|
-
|
|
445
|
-
return autorelease;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
/*
|
|
449
|
-
* call-seq: ptr.autorelease?
|
|
450
|
-
* @return [Boolean]
|
|
451
|
-
* Get +autorelease+ attribute. See also Autorelease section.
|
|
452
|
-
*/
|
|
453
|
-
static VALUE
|
|
454
|
-
ptr_autorelease_p(VALUE self)
|
|
455
|
-
{
|
|
456
|
-
Pointer* ptr;
|
|
457
|
-
|
|
458
|
-
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
|
459
|
-
|
|
460
|
-
return ptr->autorelease ? Qtrue : Qfalse;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
static void
|
|
465
|
-
ptr_release(void *data)
|
|
466
|
-
{
|
|
467
|
-
Pointer *ptr = (Pointer *)data;
|
|
468
|
-
if (ptr->autorelease && ptr->allocated && ptr->storage != NULL) {
|
|
469
|
-
xfree(ptr->storage);
|
|
470
|
-
ptr->storage = NULL;
|
|
471
|
-
}
|
|
472
|
-
xfree(ptr);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
static void
|
|
476
|
-
ptr_mark(void *data)
|
|
477
|
-
{
|
|
478
|
-
Pointer *ptr = (Pointer *)data;
|
|
479
|
-
rb_gc_mark_movable(ptr->rbParent);
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
static void
|
|
483
|
-
ptr_compact(void *data)
|
|
484
|
-
{
|
|
485
|
-
Pointer *ptr = (Pointer *)data;
|
|
486
|
-
ffi_gc_location(ptr->rbParent);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
static size_t
|
|
490
|
-
ptr_memsize(const void *data)
|
|
491
|
-
{
|
|
492
|
-
const Pointer *ptr = (const Pointer *)data;
|
|
493
|
-
size_t memsize = sizeof(Pointer);
|
|
494
|
-
if (ptr->allocated) {
|
|
495
|
-
memsize += ptr->memory.size;
|
|
496
|
-
}
|
|
497
|
-
return memsize;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
void
|
|
501
|
-
rbffi_Pointer_Init(VALUE moduleFFI)
|
|
502
|
-
{
|
|
503
|
-
VALUE rbNullAddress = ULL2NUM(0);
|
|
504
|
-
VALUE ffi_AbstractMemory = rbffi_AbstractMemoryClass;
|
|
505
|
-
|
|
506
|
-
/*
|
|
507
|
-
* Document-class: FFI::Pointer < FFI::AbstractMemory
|
|
508
|
-
* Pointer class is used to manage C pointers with ease. A {Pointer} object is defined by his
|
|
509
|
-
* {#address} (as a C pointer). It permits additions with an integer for pointer arithmetic.
|
|
510
|
-
*
|
|
511
|
-
* == Autorelease
|
|
512
|
-
* By default a pointer object frees its content when it's garbage collected.
|
|
513
|
-
* Therefore it's usually not necessary to call {#free} explicit.
|
|
514
|
-
* This behaviour may be changed with {#autorelease=} method.
|
|
515
|
-
* If it's set to +false+, the memory isn't freed by the garbage collector, but stays valid until +free()+ is called on C level or when the process terminates.
|
|
516
|
-
*/
|
|
517
|
-
rbffi_PointerClass = rb_define_class_under(moduleFFI, "Pointer", ffi_AbstractMemory);
|
|
518
|
-
/*
|
|
519
|
-
* Document-variable: Pointer
|
|
520
|
-
*/
|
|
521
|
-
rb_global_variable(&rbffi_PointerClass);
|
|
522
|
-
|
|
523
|
-
rb_define_alloc_func(rbffi_PointerClass, ptr_allocate);
|
|
524
|
-
rb_define_method(rbffi_PointerClass, "initialize", ptr_initialize, -1);
|
|
525
|
-
rb_define_method(rbffi_PointerClass, "initialize_copy", ptr_initialize_copy, 1);
|
|
526
|
-
rb_define_method(rbffi_PointerClass, "inspect", ptr_inspect, 0);
|
|
527
|
-
rb_define_method(rbffi_PointerClass, "to_s", ptr_inspect, 0);
|
|
528
|
-
rb_define_method(rbffi_PointerClass, "+", ptr_plus, 1);
|
|
529
|
-
rb_define_method(rbffi_PointerClass, "slice", ptr_slice, 2);
|
|
530
|
-
rb_define_method(rbffi_PointerClass, "null?", ptr_null_p, 0);
|
|
531
|
-
rb_define_method(rbffi_PointerClass, "address", ptr_address, 0);
|
|
532
|
-
rb_define_alias(rbffi_PointerClass, "to_i", "address");
|
|
533
|
-
rb_define_method(rbffi_PointerClass, "==", ptr_equals, 1);
|
|
534
|
-
rb_define_method(rbffi_PointerClass, "order", ptr_order, -1);
|
|
535
|
-
rb_define_method(rbffi_PointerClass, "autorelease=", ptr_autorelease, 1);
|
|
536
|
-
rb_define_method(rbffi_PointerClass, "autorelease?", ptr_autorelease_p, 0);
|
|
537
|
-
rb_define_method(rbffi_PointerClass, "free", ptr_free, 0);
|
|
538
|
-
rb_define_method(rbffi_PointerClass, "type_size", ptr_type_size, 0);
|
|
539
|
-
|
|
540
|
-
rbffi_NullPointerSingleton = rb_class_new_instance(1, &rbNullAddress, rbffi_PointerClass);
|
|
541
|
-
/*
|
|
542
|
-
* NULL pointer
|
|
543
|
-
*/
|
|
544
|
-
rb_define_const(rbffi_PointerClass, "NULL", rbffi_NullPointerSingleton);
|
|
545
|
-
}
|
|
546
|
-
|
data/ext/ffi_c/Pointer.h
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2008, 2009, Wayne Meissner
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2008-2013, Ruby FFI project contributors
|
|
5
|
-
* All rights reserved.
|
|
6
|
-
*
|
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
|
8
|
-
* modification, are permitted provided that the following conditions are met:
|
|
9
|
-
* * Redistributions of source code must retain the above copyright
|
|
10
|
-
* notice, this list of conditions and the following disclaimer.
|
|
11
|
-
* * Redistributions in binary form must reproduce the above copyright
|
|
12
|
-
* notice, this list of conditions and the following disclaimer in the
|
|
13
|
-
* documentation and/or other materials provided with the distribution.
|
|
14
|
-
* * Neither the name of the Ruby FFI project nor the
|
|
15
|
-
* names of its contributors may be used to endorse or promote products
|
|
16
|
-
* derived from this software without specific prior written permission.
|
|
17
|
-
*
|
|
18
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
19
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
-
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
22
|
-
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23
|
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
24
|
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
25
|
-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
27
|
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef RBFFI_POINTER_H
|
|
31
|
-
#define RBFFI_POINTER_H
|
|
32
|
-
|
|
33
|
-
# include <stdbool.h>
|
|
34
|
-
|
|
35
|
-
#ifdef __cplusplus
|
|
36
|
-
extern "C" {
|
|
37
|
-
#endif
|
|
38
|
-
|
|
39
|
-
#include "AbstractMemory.h"
|
|
40
|
-
|
|
41
|
-
extern void rbffi_Pointer_Init(VALUE moduleFFI);
|
|
42
|
-
extern VALUE rbffi_Pointer_NewInstance(void* addr);
|
|
43
|
-
extern const rb_data_type_t rbffi_pointer_data_type;
|
|
44
|
-
extern VALUE rbffi_PointerClass;
|
|
45
|
-
extern VALUE rbffi_NullPointerSingleton;
|
|
46
|
-
|
|
47
|
-
typedef struct Pointer {
|
|
48
|
-
AbstractMemory memory;
|
|
49
|
-
VALUE rbParent;
|
|
50
|
-
char* storage; /* start of malloc area */
|
|
51
|
-
bool autorelease;
|
|
52
|
-
bool allocated;
|
|
53
|
-
} Pointer;
|
|
54
|
-
|
|
55
|
-
#ifdef __cplusplus
|
|
56
|
-
}
|
|
57
|
-
#endif
|
|
58
|
-
|
|
59
|
-
#endif /* RBFFI_POINTER_H */
|
|
60
|
-
|