ffi 0.5.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ffi might be problematic. Click here for more details.
- data/LICENSE +51 -0
- data/README.rdoc +69 -0
- data/Rakefile +191 -0
- data/ext/ffi_c/AbstractMemory.c +489 -0
- data/ext/ffi_c/AbstractMemory.h +160 -0
- data/ext/ffi_c/ArrayType.c +129 -0
- data/ext/ffi_c/ArrayType.h +58 -0
- data/ext/ffi_c/AutoPointer.c +61 -0
- data/ext/ffi_c/AutoPointer.h +18 -0
- data/ext/ffi_c/Buffer.c +187 -0
- data/ext/ffi_c/Call.c +853 -0
- data/ext/ffi_c/Call.h +86 -0
- data/ext/ffi_c/ClosurePool.c +302 -0
- data/ext/ffi_c/ClosurePool.h +29 -0
- data/ext/ffi_c/DynamicLibrary.c +216 -0
- data/ext/ffi_c/DynamicLibrary.h +22 -0
- data/ext/ffi_c/Function.c +478 -0
- data/ext/ffi_c/Function.h +80 -0
- data/ext/ffi_c/FunctionInfo.c +221 -0
- data/ext/ffi_c/LastError.c +159 -0
- data/ext/ffi_c/LastError.h +18 -0
- data/ext/ffi_c/MemoryPointer.c +178 -0
- data/ext/ffi_c/MemoryPointer.h +20 -0
- data/ext/ffi_c/MethodHandle.c +346 -0
- data/ext/ffi_c/MethodHandle.h +53 -0
- data/ext/ffi_c/Platform.c +59 -0
- data/ext/ffi_c/Platform.h +16 -0
- data/ext/ffi_c/Pointer.c +224 -0
- data/ext/ffi_c/Pointer.h +49 -0
- data/ext/ffi_c/Struct.c +770 -0
- data/ext/ffi_c/Struct.h +80 -0
- data/ext/ffi_c/StructByValue.c +140 -0
- data/ext/ffi_c/StructByValue.h +53 -0
- data/ext/ffi_c/StructLayout.c +450 -0
- data/ext/ffi_c/Type.c +329 -0
- data/ext/ffi_c/Type.h +57 -0
- data/ext/ffi_c/Types.c +103 -0
- data/ext/ffi_c/Types.h +85 -0
- data/ext/ffi_c/Variadic.c +260 -0
- data/ext/ffi_c/compat.h +72 -0
- data/ext/ffi_c/endian.h +40 -0
- data/ext/ffi_c/extconf.rb +30 -0
- data/ext/ffi_c/ffi.c +82 -0
- data/ext/ffi_c/libffi.bsd.mk +34 -0
- data/ext/ffi_c/libffi.darwin.mk +75 -0
- data/ext/ffi_c/libffi.gnu.mk +29 -0
- data/ext/ffi_c/libffi.mk +13 -0
- data/ext/ffi_c/libffi/ChangeLog +3243 -0
- data/ext/ffi_c/libffi/ChangeLog.libffi +347 -0
- data/ext/ffi_c/libffi/ChangeLog.libgcj +40 -0
- data/ext/ffi_c/libffi/ChangeLog.v1 +764 -0
- data/ext/ffi_c/libffi/LICENSE +21 -0
- data/ext/ffi_c/libffi/Makefile.am +177 -0
- data/ext/ffi_c/libffi/Makefile.in +1640 -0
- data/ext/ffi_c/libffi/README +328 -0
- data/ext/ffi_c/libffi/TODO +1 -0
- data/ext/ffi_c/libffi/acinclude.m4 +92 -0
- data/ext/ffi_c/libffi/aclocal.m4 +7516 -0
- data/ext/ffi_c/libffi/compile +142 -0
- data/ext/ffi_c/libffi/config.guess +1516 -0
- data/ext/ffi_c/libffi/config.sub +1626 -0
- data/ext/ffi_c/libffi/configure +24414 -0
- data/ext/ffi_c/libffi/configure.ac +365 -0
- data/ext/ffi_c/libffi/configure.host +11 -0
- data/ext/ffi_c/libffi/depcomp +584 -0
- data/ext/ffi_c/libffi/doc/libffi.info +533 -0
- data/ext/ffi_c/libffi/doc/libffi.texi +541 -0
- data/ext/ffi_c/libffi/doc/stamp-vti +4 -0
- data/ext/ffi_c/libffi/doc/version.texi +4 -0
- data/ext/ffi_c/libffi/fficonfig.h.in +160 -0
- data/ext/ffi_c/libffi/include/Makefile.am +9 -0
- data/ext/ffi_c/libffi/include/Makefile.in +422 -0
- data/ext/ffi_c/libffi/include/ffi.h.in +393 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +98 -0
- data/ext/ffi_c/libffi/install-sh +323 -0
- data/ext/ffi_c/libffi/libffi.pc.in +10 -0
- data/ext/ffi_c/libffi/libtool-version +29 -0
- data/ext/ffi_c/libffi/ltcf-c.sh +861 -0
- data/ext/ffi_c/libffi/ltcf-cxx.sh +1069 -0
- data/ext/ffi_c/libffi/ltcf-gcj.sh +700 -0
- data/ext/ffi_c/libffi/ltconfig +2862 -0
- data/ext/ffi_c/libffi/ltmain.sh +6930 -0
- data/ext/ffi_c/libffi/man/Makefile.am +8 -0
- data/ext/ffi_c/libffi/man/Makefile.in +395 -0
- data/ext/ffi_c/libffi/man/ffi.3 +31 -0
- data/ext/ffi_c/libffi/man/ffi_call.3 +103 -0
- data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +66 -0
- data/ext/ffi_c/libffi/mdate-sh +201 -0
- data/ext/ffi_c/libffi/missing +353 -0
- data/ext/ffi_c/libffi/mkinstalldirs +158 -0
- data/ext/ffi_c/libffi/src/alpha/ffi.c +284 -0
- data/ext/ffi_c/libffi/src/alpha/ffitarget.h +48 -0
- data/ext/ffi_c/libffi/src/alpha/osf.S +366 -0
- data/ext/ffi_c/libffi/src/arm/ffi.c +309 -0
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +49 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +299 -0
- data/ext/ffi_c/libffi/src/closures.c +596 -0
- data/ext/ffi_c/libffi/src/cris/ffi.c +383 -0
- data/ext/ffi_c/libffi/src/cris/ffitarget.h +51 -0
- data/ext/ffi_c/libffi/src/cris/sysv.S +215 -0
- data/ext/ffi_c/libffi/src/debug.c +59 -0
- data/ext/ffi_c/libffi/src/dlmalloc.c +5099 -0
- data/ext/ffi_c/libffi/src/frv/eabi.S +128 -0
- data/ext/ffi_c/libffi/src/frv/ffi.c +292 -0
- data/ext/ffi_c/libffi/src/frv/ffitarget.h +61 -0
- data/ext/ffi_c/libffi/src/ia64/ffi.c +580 -0
- data/ext/ffi_c/libffi/src/ia64/ffitarget.h +50 -0
- data/ext/ffi_c/libffi/src/ia64/ia64_flags.h +40 -0
- data/ext/ffi_c/libffi/src/ia64/unix.S +560 -0
- data/ext/ffi_c/libffi/src/java_raw_api.c +359 -0
- data/ext/ffi_c/libffi/src/m32r/ffi.c +232 -0
- data/ext/ffi_c/libffi/src/m32r/ffitarget.h +48 -0
- data/ext/ffi_c/libffi/src/m32r/sysv.S +121 -0
- data/ext/ffi_c/libffi/src/m68k/ffi.c +278 -0
- data/ext/ffi_c/libffi/src/m68k/ffitarget.h +49 -0
- data/ext/ffi_c/libffi/src/m68k/sysv.S +234 -0
- data/ext/ffi_c/libffi/src/mips/ffi.c +926 -0
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +202 -0
- data/ext/ffi_c/libffi/src/mips/n32.S +534 -0
- data/ext/ffi_c/libffi/src/mips/o32.S +381 -0
- data/ext/ffi_c/libffi/src/pa/ffi.c +709 -0
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +77 -0
- data/ext/ffi_c/libffi/src/pa/hpux32.S +368 -0
- data/ext/ffi_c/libffi/src/pa/linux.S +357 -0
- data/ext/ffi_c/libffi/src/powerpc/aix.S +225 -0
- data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +247 -0
- data/ext/ffi_c/libffi/src/powerpc/asm.h +125 -0
- data/ext/ffi_c/libffi/src/powerpc/darwin.S +245 -0
- data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +317 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +1429 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +800 -0
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +118 -0
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +187 -0
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +236 -0
- data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +327 -0
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +230 -0
- data/ext/ffi_c/libffi/src/prep_cif.c +174 -0
- data/ext/ffi_c/libffi/src/raw_api.c +254 -0
- data/ext/ffi_c/libffi/src/s390/ffi.c +780 -0
- data/ext/ffi_c/libffi/src/s390/ffitarget.h +60 -0
- data/ext/ffi_c/libffi/src/s390/sysv.S +434 -0
- data/ext/ffi_c/libffi/src/sh/ffi.c +716 -0
- data/ext/ffi_c/libffi/src/sh/ffitarget.h +49 -0
- data/ext/ffi_c/libffi/src/sh/sysv.S +850 -0
- data/ext/ffi_c/libffi/src/sh64/ffi.c +453 -0
- data/ext/ffi_c/libffi/src/sh64/ffitarget.h +53 -0
- data/ext/ffi_c/libffi/src/sh64/sysv.S +530 -0
- data/ext/ffi_c/libffi/src/sparc/ffi.c +610 -0
- data/ext/ffi_c/libffi/src/sparc/ffitarget.h +66 -0
- data/ext/ffi_c/libffi/src/sparc/v8.S +272 -0
- data/ext/ffi_c/libffi/src/sparc/v9.S +307 -0
- data/ext/ffi_c/libffi/src/types.c +77 -0
- data/ext/ffi_c/libffi/src/x86/darwin.S +443 -0
- data/ext/ffi_c/libffi/src/x86/darwin64.S +416 -0
- data/ext/ffi_c/libffi/src/x86/ffi.c +475 -0
- data/ext/ffi_c/libffi/src/x86/ffi64.c +572 -0
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +90 -0
- data/ext/ffi_c/libffi/src/x86/freebsd.S +458 -0
- data/ext/ffi_c/libffi/src/x86/sysv.S +437 -0
- data/ext/ffi_c/libffi/src/x86/unix64.S +418 -0
- data/ext/ffi_c/libffi/src/x86/win32.S +391 -0
- data/ext/ffi_c/libffi/testsuite/Makefile.am +71 -0
- data/ext/ffi_c/libffi/testsuite/Makefile.in +447 -0
- data/ext/ffi_c/libffi/testsuite/config/default.exp +1 -0
- data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +289 -0
- data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +263 -0
- data/ext/ffi_c/libffi/testsuite/lib/wrapper.exp +45 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c +97 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c +89 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c +89 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c +90 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c +97 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c +98 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_stdcall.c +72 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +102 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +103 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +104 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +110 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +97 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +101 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +121 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +98 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +103 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +98 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +98 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c +106 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +98 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +117 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +106 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +132 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +121 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +107 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +125 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +105 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +96 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +98 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +101 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +100 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +101 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +100 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c +51 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c +51 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c +82 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c +82 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +94 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c +82 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +94 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c +52 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c +50 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c +50 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c +50 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c +51 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +54 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c +51 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float.c +59 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +58 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +72 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float4.c +62 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +69 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_win32.c +63 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +53 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +160 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +169 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +141 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +118 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +119 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +119 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +120 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +139 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +119 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +139 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +139 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/problem1.c +98 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/promotion.c +59 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/pyobjc-tc.c +114 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +35 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl1.c +43 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl2.c +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl.c +35 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl1.c +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl2.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl3.c +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +34 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll.c +41 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +38 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +38 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +38 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +44 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen_win32.c +44 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +65 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +67 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +59 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +63 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +65 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +64 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +74 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +80 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +67 -0
- data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +38 -0
- data/ext/ffi_c/libffi/testsuite/libffi.special/unwindtest.cc +123 -0
- data/ext/ffi_c/libffi/testsuite/libffi.special/unwindtest_ffi_call.cc +53 -0
- data/ext/ffi_c/libffi/texinfo.tex +7482 -0
- data/ext/ffi_c/rbffi.h +26 -0
- data/gen/Rakefile +12 -0
- data/lib/1.8/ffi_c.so +0 -0
- data/lib/1.9/ffi_c.so +0 -0
- data/lib/ffi.rb +11 -0
- data/lib/ffi/autopointer.rb +61 -0
- data/lib/ffi/buffer.rb +0 -0
- data/lib/ffi/callback.rb +10 -0
- data/lib/ffi/enum.rb +78 -0
- data/lib/ffi/errno.rb +8 -0
- data/lib/ffi/ffi.rb +99 -0
- data/lib/ffi/io.rb +21 -0
- data/lib/ffi/library.rb +218 -0
- data/lib/ffi/managedstruct.rb +55 -0
- data/lib/ffi/memorypointer.rb +73 -0
- data/lib/ffi/platform.rb +88 -0
- data/lib/ffi/pointer.rb +119 -0
- data/lib/ffi/struct.rb +183 -0
- data/lib/ffi/tools/const_generator.rb +177 -0
- data/lib/ffi/tools/generator.rb +58 -0
- data/lib/ffi/tools/generator_task.rb +35 -0
- data/lib/ffi/tools/struct_generator.rb +194 -0
- data/lib/ffi/tools/types_generator.rb +123 -0
- data/lib/ffi/types.rb +153 -0
- data/lib/ffi/union.rb +12 -0
- data/lib/ffi/variadic.rb +25 -0
- data/spec/ffi/bool_spec.rb +24 -0
- data/spec/ffi/buffer_spec.rb +202 -0
- data/spec/ffi/callback_spec.rb +591 -0
- data/spec/ffi/enum_spec.rb +164 -0
- data/spec/ffi/errno_spec.rb +13 -0
- data/spec/ffi/function_spec.rb +73 -0
- data/spec/ffi/library_spec.rb +148 -0
- data/spec/ffi/managed_struct_spec.rb +56 -0
- data/spec/ffi/number_spec.rb +231 -0
- data/spec/ffi/pointer_spec.rb +195 -0
- data/spec/ffi/rbx/attach_function_spec.rb +27 -0
- data/spec/ffi/rbx/memory_pointer_spec.rb +102 -0
- data/spec/ffi/rbx/spec_helper.rb +1 -0
- data/spec/ffi/rbx/struct_spec.rb +13 -0
- data/spec/ffi/spec_helper.rb +17 -0
- data/spec/ffi/string_spec.rb +103 -0
- data/spec/ffi/struct_callback_spec.rb +64 -0
- data/spec/ffi/struct_initialize_spec.rb +30 -0
- data/spec/ffi/struct_spec.rb +529 -0
- data/spec/ffi/typedef_spec.rb +48 -0
- data/spec/ffi/union_spec.rb +60 -0
- data/spec/ffi/variadic_spec.rb +84 -0
- data/spec/spec.opts +4 -0
- metadata +396 -0
@@ -0,0 +1,591 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
|
+
|
3
|
+
describe "Callback" do
|
4
|
+
# module LibC
|
5
|
+
# extend FFI::Library
|
6
|
+
# callback :qsort_cmp, [ :pointer, :pointer ], :int
|
7
|
+
# attach_function :qsort, [ :pointer, :int, :int, :qsort_cmp ], :int
|
8
|
+
# end
|
9
|
+
# it "arguments get passed correctly" do
|
10
|
+
# p = MemoryPointer.new(:int, 2)
|
11
|
+
# p.put_array_of_int32(0, [ 1 , 2 ])
|
12
|
+
# args = []
|
13
|
+
# cmp = proc do |p1, p2| args.push(p1.get_int(0)); args.push(p2.get_int(0)); 0; end
|
14
|
+
# # this is a bit dodgey, as it relies on qsort passing the args in order
|
15
|
+
# LibC.qsort(p, 2, 4, cmp)
|
16
|
+
# args.should == [ 1, 2 ]
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# it "Block can be substituted for Callback as last argument" do
|
20
|
+
# p = MemoryPointer.new(:int, 2)
|
21
|
+
# p.put_array_of_int32(0, [ 1 , 2 ])
|
22
|
+
# args = []
|
23
|
+
# # this is a bit dodgey, as it relies on qsort passing the args in order
|
24
|
+
# LibC.qsort(p, 2, 4) do |p1, p2|
|
25
|
+
# args.push(p1.get_int(0))
|
26
|
+
# args.push(p2.get_int(0))
|
27
|
+
# 0
|
28
|
+
# end
|
29
|
+
# args.should == [ 1, 2 ]
|
30
|
+
# end
|
31
|
+
module LibTest
|
32
|
+
extend FFI::Library
|
33
|
+
ffi_lib TestLibrary::PATH
|
34
|
+
callback :cbVrS8, [ ], :char
|
35
|
+
callback :cbVrU8, [ ], :uchar
|
36
|
+
callback :cbVrS16, [ ], :short
|
37
|
+
callback :cbVrU16, [ ], :ushort
|
38
|
+
callback :cbVrS32, [ ], :int
|
39
|
+
callback :cbVrU32, [ ], :uint
|
40
|
+
callback :cbVrL, [ ], :long
|
41
|
+
callback :cbVrUL, [ ], :ulong
|
42
|
+
callback :cbVrS64, [ ], :long_long
|
43
|
+
callback :cbVrU64, [ ], :ulong_long
|
44
|
+
callback :cbVrP, [], :pointer
|
45
|
+
callback :cbVrZ, [], :bool
|
46
|
+
callback :cbCrV, [ :char ], :void
|
47
|
+
callback :cbSrV, [ :short ], :void
|
48
|
+
callback :cbIrV, [ :int ], :void
|
49
|
+
callback :cbLrV, [ :long ], :void
|
50
|
+
callback :cbULrV, [ :ulong ], :void
|
51
|
+
callback :cbLrV, [ :long_long ], :void
|
52
|
+
|
53
|
+
attach_function :testCallbackVrS8, :testClosureVrB, [ :cbVrS8 ], :char
|
54
|
+
attach_function :testCallbackVrU8, :testClosureVrB, [ :cbVrU8 ], :uchar
|
55
|
+
attach_function :testCallbackVrS16, :testClosureVrS, [ :cbVrS16 ], :short
|
56
|
+
attach_function :testCallbackVrU16, :testClosureVrS, [ :cbVrU16 ], :ushort
|
57
|
+
attach_function :testCallbackVrS32, :testClosureVrI, [ :cbVrS32 ], :int
|
58
|
+
attach_function :testCallbackVrU32, :testClosureVrI, [ :cbVrU32 ], :uint
|
59
|
+
attach_function :testCallbackVrL, :testClosureVrL, [ :cbVrL ], :long
|
60
|
+
attach_function :testCallbackVrZ, :testClosureVrZ, [ :cbVrZ ], :bool
|
61
|
+
attach_function :testCallbackVrUL, :testClosureVrL, [ :cbVrUL ], :ulong
|
62
|
+
attach_function :testCallbackVrS64, :testClosureVrLL, [ :cbVrS64 ], :long_long
|
63
|
+
attach_function :testCallbackVrU64, :testClosureVrLL, [ :cbVrU64 ], :ulong_long
|
64
|
+
attach_function :testCallbackVrP, :testClosureVrP, [ :cbVrP ], :pointer
|
65
|
+
attach_function :testCallbackCrV, :testClosureBrV, [ :cbCrV, :char ], :void
|
66
|
+
attach_variable :cbVrS8, :gvar_pointer, :cbVrS8
|
67
|
+
attach_variable :pVrS8, :gvar_pointer, :pointer
|
68
|
+
attach_function :testGVarCallbackVrS8, :testClosureVrB, [ :pointer ], :char
|
69
|
+
attach_function :testOptionalCallbackCrV, :testOptionalClosureBrV, [ :cbCrV, :char ], :void
|
70
|
+
|
71
|
+
end
|
72
|
+
it "function with Callback plus another arg should raise error if no arg given" do
|
73
|
+
lambda { LibTest.testCallbackCrV { |*a| }}.should raise_error
|
74
|
+
end
|
75
|
+
it "returning :char (0)" do
|
76
|
+
LibTest.testCallbackVrS8 { 0 }.should == 0
|
77
|
+
end
|
78
|
+
it "returning :char (127)" do
|
79
|
+
LibTest.testCallbackVrS8 { 127 }.should == 127
|
80
|
+
end
|
81
|
+
it "returning :char (-128)" do
|
82
|
+
LibTest.testCallbackVrS8 { -128 }.should == -128
|
83
|
+
end
|
84
|
+
# test wrap around
|
85
|
+
it "returning :char (128)" do
|
86
|
+
LibTest.testCallbackVrS8 { 128 }.should == -128
|
87
|
+
end
|
88
|
+
it "returning :char (255)" do
|
89
|
+
LibTest.testCallbackVrS8 { 0xff }.should == -1
|
90
|
+
end
|
91
|
+
it "returning :uchar (0)" do
|
92
|
+
LibTest.testCallbackVrU8 { 0 }.should == 0
|
93
|
+
end
|
94
|
+
it "returning :uchar (0xff)" do
|
95
|
+
LibTest.testCallbackVrU8 { 0xff }.should == 0xff
|
96
|
+
end
|
97
|
+
it "returning :uchar (-1)" do
|
98
|
+
LibTest.testCallbackVrU8 { -1 }.should == 0xff
|
99
|
+
end
|
100
|
+
it "returning :uchar (128)" do
|
101
|
+
LibTest.testCallbackVrU8 { 128 }.should == 128
|
102
|
+
end
|
103
|
+
it "returning :uchar (-128)" do
|
104
|
+
LibTest.testCallbackVrU8 { -128 }.should == 128
|
105
|
+
end
|
106
|
+
it "returning :short (0)" do
|
107
|
+
LibTest.testCallbackVrS16 { 0 }.should == 0
|
108
|
+
end
|
109
|
+
it "returning :short (0x7fff)" do
|
110
|
+
LibTest.testCallbackVrS16 { 0x7fff }.should == 0x7fff
|
111
|
+
end
|
112
|
+
# test wrap around
|
113
|
+
it "returning :short (0x8000)" do
|
114
|
+
LibTest.testCallbackVrS16 { 0x8000 }.should == -0x8000
|
115
|
+
end
|
116
|
+
it "returning :short (0xffff)" do
|
117
|
+
LibTest.testCallbackVrS16 { 0xffff }.should == -1
|
118
|
+
end
|
119
|
+
it "returning :ushort (0)" do
|
120
|
+
LibTest.testCallbackVrU16 { 0 }.should == 0
|
121
|
+
end
|
122
|
+
it "returning :ushort (0x7fff)" do
|
123
|
+
LibTest.testCallbackVrU16 { 0x7fff }.should == 0x7fff
|
124
|
+
end
|
125
|
+
it "returning :ushort (0x8000)" do
|
126
|
+
LibTest.testCallbackVrU16 { 0x8000 }.should == 0x8000
|
127
|
+
end
|
128
|
+
it "returning :ushort (0xffff)" do
|
129
|
+
LibTest.testCallbackVrU16 { 0xffff }.should == 0xffff
|
130
|
+
end
|
131
|
+
it "returning :ushort (-1)" do
|
132
|
+
LibTest.testCallbackVrU16 { -1 }.should == 0xffff
|
133
|
+
end
|
134
|
+
it "returning :int (0)" do
|
135
|
+
LibTest.testCallbackVrS32 { 0 }.should == 0
|
136
|
+
end
|
137
|
+
it "returning :int (0x7fffffff)" do
|
138
|
+
LibTest.testCallbackVrS32 { 0x7fffffff }.should == 0x7fffffff
|
139
|
+
end
|
140
|
+
# test wrap around
|
141
|
+
it "returning :int (-0x80000000)" do
|
142
|
+
LibTest.testCallbackVrS32 { -0x80000000 }.should == -0x80000000
|
143
|
+
end
|
144
|
+
it "returning :int (-1)" do
|
145
|
+
LibTest.testCallbackVrS32 { -1 }.should == -1
|
146
|
+
end
|
147
|
+
it "returning :uint (0)" do
|
148
|
+
LibTest.testCallbackVrU32 { 0 }.should == 0
|
149
|
+
end
|
150
|
+
it "returning :uint (0x7fffffff)" do
|
151
|
+
LibTest.testCallbackVrU32 { 0x7fffffff }.should == 0x7fffffff
|
152
|
+
end
|
153
|
+
# test wrap around
|
154
|
+
it "returning :uint (0x80000000)" do
|
155
|
+
LibTest.testCallbackVrU32 { 0x80000000 }.should == 0x80000000
|
156
|
+
end
|
157
|
+
it "returning :uint (0xffffffff)" do
|
158
|
+
LibTest.testCallbackVrU32 { 0xffffffff }.should == 0xffffffff
|
159
|
+
end
|
160
|
+
it "returning :uint (-1)" do
|
161
|
+
LibTest.testCallbackVrU32 { -1 }.should == 0xffffffff
|
162
|
+
end
|
163
|
+
it "returning :long (0)" do
|
164
|
+
LibTest.testCallbackVrL { 0 }.should == 0
|
165
|
+
end
|
166
|
+
it "returning :long (0x7fffffff)" do
|
167
|
+
LibTest.testCallbackVrL { 0x7fffffff }.should == 0x7fffffff
|
168
|
+
end
|
169
|
+
# test wrap around
|
170
|
+
it "returning :long (-0x80000000)" do
|
171
|
+
LibTest.testCallbackVrL { -0x80000000 }.should == -0x80000000
|
172
|
+
end
|
173
|
+
it "returning :long (-1)" do
|
174
|
+
LibTest.testCallbackVrL { -1 }.should == -1
|
175
|
+
end
|
176
|
+
it "returning :ulong (0)" do
|
177
|
+
LibTest.testCallbackVrUL { 0 }.should == 0
|
178
|
+
end
|
179
|
+
it "returning :ulong (0x7fffffff)" do
|
180
|
+
LibTest.testCallbackVrUL { 0x7fffffff }.should == 0x7fffffff
|
181
|
+
end
|
182
|
+
# test wrap around
|
183
|
+
it "returning :ulong (0x80000000)" do
|
184
|
+
LibTest.testCallbackVrUL { 0x80000000 }.should == 0x80000000
|
185
|
+
end
|
186
|
+
it "returning :ulong (0xffffffff)" do
|
187
|
+
LibTest.testCallbackVrUL { 0xffffffff }.should == 0xffffffff
|
188
|
+
end
|
189
|
+
it "Callback returning :ulong (-1)" do
|
190
|
+
if FFI::Platform::LONG_SIZE == 32
|
191
|
+
LibTest.testCallbackVrUL { -1 }.should == 0xffffffff
|
192
|
+
else
|
193
|
+
LibTest.testCallbackVrUL { -1 }.should == 0xffffffffffffffff
|
194
|
+
end
|
195
|
+
end
|
196
|
+
it "returning :long_long (0)" do
|
197
|
+
LibTest.testCallbackVrS64 { 0 }.should == 0
|
198
|
+
end
|
199
|
+
it "returning :long_long (0x7fffffffffffffff)" do
|
200
|
+
LibTest.testCallbackVrS64 { 0x7fffffffffffffff }.should == 0x7fffffffffffffff
|
201
|
+
end
|
202
|
+
# test wrap around
|
203
|
+
it "returning :long_long (-0x8000000000000000)" do
|
204
|
+
LibTest.testCallbackVrS64 { -0x8000000000000000 }.should == -0x8000000000000000
|
205
|
+
end
|
206
|
+
it "returning :long_long (-1)" do
|
207
|
+
LibTest.testCallbackVrS64 { -1 }.should == -1
|
208
|
+
end
|
209
|
+
it "returning bool" do
|
210
|
+
LibTest.testCallbackVrZ { true }.should be_true
|
211
|
+
end
|
212
|
+
it "returning :pointer (nil)" do
|
213
|
+
LibTest.testCallbackVrP { nil }.null?.should be_true
|
214
|
+
end
|
215
|
+
it "returning :pointer (MemoryPointer)" do
|
216
|
+
p = FFI::MemoryPointer.new :long
|
217
|
+
LibTest.testCallbackVrP { p }.should == p
|
218
|
+
end
|
219
|
+
|
220
|
+
it "global variable" do
|
221
|
+
proc = Proc.new { 0x1e }
|
222
|
+
LibTest.cbVrS8 = proc
|
223
|
+
LibTest.testGVarCallbackVrS8(LibTest.pVrS8).should == 0x1e
|
224
|
+
end
|
225
|
+
|
226
|
+
describe "When the callback is considered optional by the underlying library" do
|
227
|
+
it "should handle receiving 'nil' in place of the closure" do
|
228
|
+
LibTest.testOptionalCallbackCrV(nil, 13)
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
describe 'when inlined' do
|
233
|
+
it 'could be anonymous' do
|
234
|
+
module LibTest
|
235
|
+
extend FFI::Library
|
236
|
+
ffi_lib TestLibrary::PATH
|
237
|
+
attach_function :testCallbackVrS8, :testClosureVrB, [ callback([ ], :char) ], :char
|
238
|
+
end
|
239
|
+
LibTest.testCallbackVrS8 { 0 }.should == 0
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
describe "as return value" do
|
244
|
+
|
245
|
+
it "should not blow up when a callback is defined that returns a callback" do
|
246
|
+
module LibTest
|
247
|
+
extend FFI::Library
|
248
|
+
ffi_lib TestLibrary::PATH
|
249
|
+
callback :cb_return_type_1, [ :short ], :short
|
250
|
+
callback :cb_lookup_1, [ :short ], :cb_return_type_1
|
251
|
+
attach_function :testReturnsCallback_1, :testReturnsClosure, [ :cb_lookup_1, :short ], :cb_return_type_1
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should return a callback" do
|
256
|
+
module LibTest
|
257
|
+
extend FFI::Library
|
258
|
+
ffi_lib TestLibrary::PATH
|
259
|
+
callback :cb_return_type, [ :int ], :int
|
260
|
+
callback :cb_lookup, [ ], :cb_return_type
|
261
|
+
attach_function :testReturnsCallback, :testReturnsClosure, [ :cb_lookup, :int ], :int
|
262
|
+
end
|
263
|
+
|
264
|
+
lookup_proc_called = false
|
265
|
+
return_proc_called = false
|
266
|
+
|
267
|
+
return_proc = Proc.new do |a|
|
268
|
+
return_proc_called = true
|
269
|
+
a * 2
|
270
|
+
end
|
271
|
+
lookup_proc = Proc.new do
|
272
|
+
lookup_proc_called = true
|
273
|
+
return_proc
|
274
|
+
end
|
275
|
+
|
276
|
+
val = LibTest.testReturnsCallback(lookup_proc, 0x1234)
|
277
|
+
val.should == 0x1234 * 2
|
278
|
+
lookup_proc_called.should be_true
|
279
|
+
return_proc_called.should be_true
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should return a method callback" do
|
283
|
+
module LibTest
|
284
|
+
extend FFI::Library
|
285
|
+
ffi_lib TestLibrary::PATH
|
286
|
+
callback :cb_return_type, [ :int ], :int
|
287
|
+
callback :cb_lookup, [ ], :cb_return_type
|
288
|
+
attach_function :testReturnsCallback, :testReturnsClosure, [ :cb_lookup, :int ], :int
|
289
|
+
end
|
290
|
+
module MethodCallback
|
291
|
+
def self.lookup
|
292
|
+
method(:perform)
|
293
|
+
end
|
294
|
+
def self.perform num
|
295
|
+
num * 2
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
LibTest.testReturnsCallback(MethodCallback.method(:lookup), 0x1234).should == 0x2468
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'should not blow up when a callback takes a callback as argument' do
|
303
|
+
module LibTest
|
304
|
+
extend FFI::Library
|
305
|
+
ffi_lib TestLibrary::PATH
|
306
|
+
callback :cb_argument, [ :int ], :int
|
307
|
+
callback :cb_with_cb_argument, [ :cb_argument, :int ], :int
|
308
|
+
attach_function :testCallbackAsArgument, :testArgumentClosure, [ :cb_with_cb_argument, :int ], :int
|
309
|
+
end
|
310
|
+
end
|
311
|
+
it 'should be able to use the callback argument' do
|
312
|
+
module LibTest
|
313
|
+
extend FFI::Library
|
314
|
+
ffi_lib TestLibrary::PATH
|
315
|
+
callback :cb_argument, [ :int ], :int
|
316
|
+
callback :cb_with_cb_argument, [ :cb_argument, :int ], :int
|
317
|
+
attach_function :testCallbackAsArgument, :testArgumentClosure, [ :cb_with_cb_argument, :cb_argument, :int ], :int
|
318
|
+
end
|
319
|
+
callback_arg_called = false
|
320
|
+
callback_with_callback_arg_called = false
|
321
|
+
callback_arg = Proc.new do |val|
|
322
|
+
callback_arg_called = true
|
323
|
+
val * 2
|
324
|
+
end
|
325
|
+
callback_with_callback_arg = Proc.new do |cb, val|
|
326
|
+
callback_with_callback_arg_called = true
|
327
|
+
cb.call(val)
|
328
|
+
end
|
329
|
+
val = LibTest.testCallbackAsArgument(callback_with_callback_arg, callback_arg, 0xff1)
|
330
|
+
val.should == 0xff1 * 2
|
331
|
+
callback_arg_called.should be_true
|
332
|
+
callback_with_callback_arg_called.should be_true
|
333
|
+
end
|
334
|
+
it 'function returns callable object' do
|
335
|
+
module LibTest
|
336
|
+
extend FFI::Library
|
337
|
+
ffi_lib TestLibrary::PATH
|
338
|
+
callback :funcptr, [ :int ], :int
|
339
|
+
attach_function :testReturnsFunctionPointer, [ ], :funcptr
|
340
|
+
end
|
341
|
+
f = LibTest.testReturnsFunctionPointer
|
342
|
+
f.call(3).should == 6
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
end
|
347
|
+
describe "Callback with " do
|
348
|
+
#
|
349
|
+
# Test callbacks that take an argument, returning void
|
350
|
+
#
|
351
|
+
module LibTest
|
352
|
+
extend FFI::Library
|
353
|
+
ffi_lib TestLibrary::PATH
|
354
|
+
callback :cbS8rV, [ :char ], :void
|
355
|
+
callback :cbU8rV, [ :uchar ], :void
|
356
|
+
callback :cbS16rV, [ :short ], :void
|
357
|
+
callback :cbU16rV, [ :ushort ], :void
|
358
|
+
|
359
|
+
callback :cbZrV, [ :bool ], :void
|
360
|
+
callback :cbS32rV, [ :int ], :void
|
361
|
+
callback :cbU32rV, [ :uint ], :void
|
362
|
+
|
363
|
+
callback :cbLrV, [ :long ], :void
|
364
|
+
callback :cbULrV, [ :ulong ], :void
|
365
|
+
callback :cbArV, [ :string ], :void
|
366
|
+
callback :cbPrV, [ :pointer], :void
|
367
|
+
|
368
|
+
callback :cbS64rV, [ :long_long ], :void
|
369
|
+
attach_function :testCallbackCrV, :testClosureBrV, [ :cbS8rV, :char ], :void
|
370
|
+
attach_function :testCallbackU8rV, :testClosureBrV, [ :cbU8rV, :uchar ], :void
|
371
|
+
attach_function :testCallbackSrV, :testClosureSrV, [ :cbS16rV, :short ], :void
|
372
|
+
attach_function :testCallbackU16rV, :testClosureSrV, [ :cbU16rV, :ushort ], :void
|
373
|
+
attach_function :testCallbackZrV, :testClosureZrV, [ :cbZrV, :bool ], :void
|
374
|
+
attach_function :testCallbackIrV, :testClosureIrV, [ :cbS32rV, :int ], :void
|
375
|
+
attach_function :testCallbackU32rV, :testClosureIrV, [ :cbU32rV, :uint ], :void
|
376
|
+
|
377
|
+
attach_function :testCallbackLrV, :testClosureLrV, [ :cbLrV, :long ], :void
|
378
|
+
attach_function :testCallbackULrV, :testClosureULrV, [ :cbULrV, :ulong ], :void
|
379
|
+
|
380
|
+
attach_function :testCallbackLLrV, :testClosureLLrV, [ :cbS64rV, :long_long ], :void
|
381
|
+
attach_function :testCallbackArV, :testClosurePrV, [ :cbArV, :string ], :void
|
382
|
+
attach_function :testCallbackPrV, :testClosurePrV, [ :cbPrV, :pointer], :void
|
383
|
+
end
|
384
|
+
it ":char (0) argument" do
|
385
|
+
v = 0xdeadbeef
|
386
|
+
LibTest.testCallbackCrV(0) { |i| v = i }
|
387
|
+
v.should == 0
|
388
|
+
end
|
389
|
+
it ":char (127) argument" do
|
390
|
+
v = 0xdeadbeef
|
391
|
+
LibTest.testCallbackCrV(127) { |i| v = i }
|
392
|
+
v.should == 127
|
393
|
+
end
|
394
|
+
it ":char (-128) argument" do
|
395
|
+
v = 0xdeadbeef
|
396
|
+
LibTest.testCallbackCrV(-128) { |i| v = i }
|
397
|
+
v.should == -128
|
398
|
+
end
|
399
|
+
it ":char (-1) argument" do
|
400
|
+
v = 0xdeadbeef
|
401
|
+
LibTest.testCallbackCrV(-1) { |i| v = i }
|
402
|
+
v.should == -1
|
403
|
+
end
|
404
|
+
it ":uchar (0) argument" do
|
405
|
+
v = 0xdeadbeef
|
406
|
+
LibTest.testCallbackU8rV(0) { |i| v = i }
|
407
|
+
v.should == 0
|
408
|
+
end
|
409
|
+
it ":uchar (127) argument" do
|
410
|
+
v = 0xdeadbeef
|
411
|
+
LibTest.testCallbackU8rV(127) { |i| v = i }
|
412
|
+
v.should == 127
|
413
|
+
end
|
414
|
+
it ":uchar (128) argument" do
|
415
|
+
v = 0xdeadbeef
|
416
|
+
LibTest.testCallbackU8rV(128) { |i| v = i }
|
417
|
+
v.should == 128
|
418
|
+
end
|
419
|
+
it ":uchar (255) argument" do
|
420
|
+
v = 0xdeadbeef
|
421
|
+
LibTest.testCallbackU8rV(255) { |i| v = i }
|
422
|
+
v.should == 255
|
423
|
+
end
|
424
|
+
|
425
|
+
it ":short (0) argument" do
|
426
|
+
v = 0xdeadbeef
|
427
|
+
LibTest.testCallbackSrV(0) { |i| v = i }
|
428
|
+
v.should == 0
|
429
|
+
end
|
430
|
+
it ":short (0x7fff) argument" do
|
431
|
+
v = 0xdeadbeef
|
432
|
+
LibTest.testCallbackSrV(0x7fff) { |i| v = i }
|
433
|
+
v.should == 0x7fff
|
434
|
+
end
|
435
|
+
it ":short (-0x8000) argument" do
|
436
|
+
v = 0xdeadbeef
|
437
|
+
LibTest.testCallbackSrV(-0x8000) { |i| v = i }
|
438
|
+
v.should == -0x8000
|
439
|
+
end
|
440
|
+
it ":short (-1) argument" do
|
441
|
+
v = 0xdeadbeef
|
442
|
+
LibTest.testCallbackSrV(-1) { |i| v = i }
|
443
|
+
v.should == -1
|
444
|
+
end
|
445
|
+
it ":ushort (0) argument" do
|
446
|
+
v = 0xdeadbeef
|
447
|
+
LibTest.testCallbackU16rV(0) { |i| v = i }
|
448
|
+
v.should == 0
|
449
|
+
end
|
450
|
+
it ":ushort (0x7fff) argument" do
|
451
|
+
v = 0xdeadbeef
|
452
|
+
LibTest.testCallbackU16rV(0x7fff) { |i| v = i }
|
453
|
+
v.should == 0x7fff
|
454
|
+
end
|
455
|
+
it ":ushort (0x8000) argument" do
|
456
|
+
v = 0xdeadbeef
|
457
|
+
LibTest.testCallbackU16rV(0x8000) { |i| v = i }
|
458
|
+
v.should == 0x8000
|
459
|
+
end
|
460
|
+
it ":ushort (0xffff) argument" do
|
461
|
+
v = 0xdeadbeef
|
462
|
+
LibTest.testCallbackU16rV(0xffff) { |i| v = i }
|
463
|
+
v.should == 0xffff
|
464
|
+
end
|
465
|
+
it ":bool (true) argument" do
|
466
|
+
v = false
|
467
|
+
LibTest.testCallbackZrV(true) { |i| v = i }
|
468
|
+
v.should be_true
|
469
|
+
end
|
470
|
+
it ":int (0) argument" do
|
471
|
+
v = 0xdeadbeef
|
472
|
+
LibTest.testCallbackIrV(0) { |i| v = i }
|
473
|
+
v.should == 0
|
474
|
+
end
|
475
|
+
it ":int (0x7fffffff) argument" do
|
476
|
+
v = 0xdeadbeef
|
477
|
+
LibTest.testCallbackIrV(0x7fffffff) { |i| v = i }
|
478
|
+
v.should == 0x7fffffff
|
479
|
+
end
|
480
|
+
it ":int (-0x80000000) argument" do
|
481
|
+
v = 0xdeadbeef
|
482
|
+
LibTest.testCallbackIrV(-0x80000000) { |i| v = i }
|
483
|
+
v.should == -0x80000000
|
484
|
+
end
|
485
|
+
it ":int (-1) argument" do
|
486
|
+
v = 0xdeadbeef
|
487
|
+
LibTest.testCallbackIrV(-1) { |i| v = i }
|
488
|
+
v.should == -1
|
489
|
+
end
|
490
|
+
it ":uint (0) argument" do
|
491
|
+
v = 0xdeadbeef
|
492
|
+
LibTest.testCallbackU32rV(0) { |i| v = i }
|
493
|
+
v.should == 0
|
494
|
+
end
|
495
|
+
it ":uint (0x7fffffff) argument" do
|
496
|
+
v = 0xdeadbeef
|
497
|
+
LibTest.testCallbackU32rV(0x7fffffff) { |i| v = i }
|
498
|
+
v.should == 0x7fffffff
|
499
|
+
end
|
500
|
+
it ":uint (0x80000000) argument" do
|
501
|
+
v = 0xdeadbeef
|
502
|
+
LibTest.testCallbackU32rV(0x80000000) { |i| v = i }
|
503
|
+
v.should == 0x80000000
|
504
|
+
end
|
505
|
+
it ":uint (0xffffffff) argument" do
|
506
|
+
v = 0xdeadbeef
|
507
|
+
LibTest.testCallbackU32rV(0xffffffff) { |i| v = i }
|
508
|
+
v.should == 0xffffffff
|
509
|
+
end
|
510
|
+
it ":long (0) argument" do
|
511
|
+
v = 0xdeadbeef
|
512
|
+
LibTest.testCallbackLrV(0) { |i| v = i }
|
513
|
+
v.should == 0
|
514
|
+
end
|
515
|
+
it ":long (0x7fffffff) argument" do
|
516
|
+
v = 0xdeadbeef
|
517
|
+
LibTest.testCallbackLrV(0x7fffffff) { |i| v = i }
|
518
|
+
v.should == 0x7fffffff
|
519
|
+
end
|
520
|
+
it ":long (-0x80000000) argument" do
|
521
|
+
v = 0xdeadbeef
|
522
|
+
LibTest.testCallbackLrV(-0x80000000) { |i| v = i }
|
523
|
+
v.should == -0x80000000
|
524
|
+
end
|
525
|
+
it ":long (-1) argument" do
|
526
|
+
v = 0xdeadbeef
|
527
|
+
LibTest.testCallbackLrV(-1) { |i| v = i }
|
528
|
+
v.should == -1
|
529
|
+
end
|
530
|
+
it ":ulong (0) argument" do
|
531
|
+
v = 0xdeadbeef
|
532
|
+
LibTest.testCallbackULrV(0) { |i| v = i }
|
533
|
+
v.should == 0
|
534
|
+
end
|
535
|
+
it ":ulong (0x7fffffff) argument" do
|
536
|
+
v = 0xdeadbeef
|
537
|
+
LibTest.testCallbackULrV(0x7fffffff) { |i| v = i }
|
538
|
+
v.should == 0x7fffffff
|
539
|
+
end
|
540
|
+
it ":ulong (0x80000000) argument" do
|
541
|
+
v = 0xdeadbeef
|
542
|
+
LibTest.testCallbackULrV(0x80000000) { |i| v = i }
|
543
|
+
v.should == 0x80000000
|
544
|
+
end
|
545
|
+
it ":ulong (0xffffffff) argument" do
|
546
|
+
v = 0xdeadbeef
|
547
|
+
LibTest.testCallbackULrV(0xffffffff) { |i| v = i }
|
548
|
+
v.should == 0xffffffff
|
549
|
+
end
|
550
|
+
it ":long_long (0) argument" do
|
551
|
+
v = 0xdeadbeef
|
552
|
+
LibTest.testCallbackLLrV(0) { |i| v = i }
|
553
|
+
v.should == 0
|
554
|
+
end
|
555
|
+
it ":long_long (0x7fffffffffffffff) argument" do
|
556
|
+
v = 0xdeadbeef
|
557
|
+
LibTest.testCallbackLLrV(0x7fffffffffffffff) { |i| v = i }
|
558
|
+
v.should == 0x7fffffffffffffff
|
559
|
+
end
|
560
|
+
it ":long_long (-0x8000000000000000) argument" do
|
561
|
+
v = 0xdeadbeef
|
562
|
+
LibTest.testCallbackLLrV(-0x8000000000000000) { |i| v = i }
|
563
|
+
v.should == -0x8000000000000000
|
564
|
+
end
|
565
|
+
it ":long_long (-1) argument" do
|
566
|
+
v = 0xdeadbeef
|
567
|
+
LibTest.testCallbackLLrV(-1) { |i| v = i }
|
568
|
+
v.should == -1
|
569
|
+
end
|
570
|
+
it ":string argument" do
|
571
|
+
v = nil
|
572
|
+
LibTest.testCallbackArV("Hello, World") { |i| v = i }
|
573
|
+
v.should == "Hello, World"
|
574
|
+
end
|
575
|
+
it ":string (nil) argument" do
|
576
|
+
v = "Hello, World"
|
577
|
+
LibTest.testCallbackArV(nil) { |i| v = i }
|
578
|
+
v.should be_nil
|
579
|
+
end
|
580
|
+
it ":pointer argument" do
|
581
|
+
v = nil
|
582
|
+
magic = FFI::Pointer.new(0xdeadbeef)
|
583
|
+
LibTest.testCallbackPrV(magic) { |i| v = i }
|
584
|
+
v.should == magic
|
585
|
+
end
|
586
|
+
it ":pointer (nil) argument" do
|
587
|
+
v = "Hello, World"
|
588
|
+
LibTest.testCallbackPrV(nil) { |i| v = i }
|
589
|
+
v.should == FFI::Pointer::NULL
|
590
|
+
end
|
591
|
+
end # unless true
|