yakg 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +27 -19
- data/VERSION +1 -1
- data/lib/yakg.rb +6 -6
- data/spec/spec_helper.rb +1 -3
- data/spec/yakg_spec.rb +13 -13
- data/vendor/gems/README.md +26 -20
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/COPYING +49 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/LICENSE +24 -0
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/README.md +7 -7
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/Rakefile +31 -41
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/ffi.gemspec +7 -6
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/autopointer.rb +24 -14
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/enum.rb +34 -22
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/errno.rb +43 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/ffi.rb +44 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/io.rb +62 -0
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/library.rb +79 -44
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/managedstruct.rb +29 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/platform/aarch64-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/platform/mips64el-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-darwin/types.conf +126 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-openbsd/types.conf +128 -0
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform.rb +35 -15
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/pointer.rb +22 -10
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/struct.rb +31 -14
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/struct_layout_builder.rb +46 -30
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/types.rb +24 -11
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/union.rb +43 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/variadic.rb +78 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi/version.rb +4 -0
- data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi.rb +1 -9
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/lib/ffi_c.bundle +0 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/Benchmark.c +52 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/BoolTest.c +34 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/BufferTest.c +31 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/ClosureTest.c +205 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/EnumTest.c +51 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/FunctionTest.c +70 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/GNUmakefile +149 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/GlobalVariable.c +62 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/LastErrorTest.c +21 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/NumberTest.c +132 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/PointerTest.c +63 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/ReferenceTest.c +23 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/StringTest.c +34 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/StructTest.c +243 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/UnionTest.c +43 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.10/libtest/VariadicTest.c +62 -0
- data/vendor/gems/ruby/2.0.0/specifications/ffi-1.9.10.gemspec +45 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/CHANGELOG +12 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/LICENSE +8 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/README.md +40 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation/array.rb +123 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation/base.rb +197 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation/boolean.rb +25 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation/data.rb +42 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation/date.rb +32 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation/dictionary.rb +114 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation/extensions.rb +158 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation/null.rb +11 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation/number.rb +98 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation/string.rb +91 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation/version.rb +4 -0
- data/vendor/gems/ruby/2.1.0/gems/corefoundation-0.2.0/lib/corefoundation.rb +13 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/COPYING +49 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/LICENSE +24 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/README.md +109 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/Rakefile +210 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/ffi.gemspec +23 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/gen/Rakefile +30 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/autopointer.rb +194 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/buffer.rb +4 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/callback.rb +4 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/enum.rb +174 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/errno.rb +43 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/ffi.rb +44 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/io.rb +62 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/library.rb +524 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/managedstruct.rb +84 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/memorypointer.rb +1 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/aarch64-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/arm-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/i386-cygwin/types.conf +3 -0
- data/vendor/gems/ruby/{2.0.0/gems/ffi-1.9.0/lib/ffi/platform/x86_64-darwin → 2.1.0/gems/ffi-1.9.10/lib/ffi/platform/i386-darwin}/types.conf +2 -2
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/i386-freebsd/types.conf +152 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/i386-gnu/types.conf +107 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/i386-linux/types.conf +103 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/i386-openbsd/types.conf +128 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/i386-solaris/types.conf +122 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/i386-windows/types.conf +105 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/ia64-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/mips-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/mips64el-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/mipsel-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/powerpc-aix/types.conf +180 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/powerpc-darwin/types.conf +100 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/powerpc-linux/types.conf +100 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/s390-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/s390x-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/sparc-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/sparc-solaris/types.conf +128 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/sparcv9-solaris/types.conf +128 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-darwin/types.conf +126 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-freebsd/types.conf +128 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-netbsd/types.conf +128 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-openbsd/types.conf +128 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-solaris/types.conf +122 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-windows/types.conf +27 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/platform.rb +159 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/pointer.rb +134 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/struct.rb +373 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/struct_layout_builder.rb +227 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/tools/const_generator.rb +229 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/tools/generator.rb +60 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/tools/generator_task.rb +36 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/tools/struct_generator.rb +194 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/tools/types_generator.rb +135 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/types.rb +190 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/union.rb +43 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/variadic.rb +78 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi/version.rb +4 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi.rb +20 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/lib/ffi_c.bundle +0 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/Benchmark.c +52 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/BoolTest.c +34 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/BufferTest.c +31 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/ClosureTest.c +205 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/EnumTest.c +51 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/FunctionTest.c +70 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/GNUmakefile +149 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/GlobalVariable.c +62 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/LastErrorTest.c +21 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/NumberTest.c +132 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/PointerTest.c +63 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/ReferenceTest.c +23 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/StringTest.c +34 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/StructTest.c +243 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/UnionTest.c +43 -0
- data/vendor/gems/ruby/2.1.0/gems/ffi-1.9.10/libtest/VariadicTest.c +62 -0
- data/vendor/gems/ruby/2.1.0/specifications/corefoundation-0.2.0.gemspec +45 -0
- data/vendor/gems/ruby/2.1.0/specifications/ffi-1.9.10.gemspec +49 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/CHANGELOG +12 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/LICENSE +8 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/README.md +40 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation/array.rb +123 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation/base.rb +197 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation/boolean.rb +25 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation/data.rb +42 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation/date.rb +32 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation/dictionary.rb +114 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation/extensions.rb +158 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation/null.rb +11 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation/number.rb +98 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation/string.rb +91 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation/version.rb +4 -0
- data/vendor/gems/ruby/2.2.0/gems/corefoundation-0.2.0/lib/corefoundation.rb +13 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/COPYING +49 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/LICENSE +24 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/README.md +109 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/Rakefile +210 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/ffi.gemspec +23 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/gen/Rakefile +30 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/autopointer.rb +194 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/buffer.rb +4 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/callback.rb +4 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/enum.rb +174 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/errno.rb +43 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/ffi.rb +44 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/io.rb +62 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/library.rb +524 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/managedstruct.rb +84 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/memorypointer.rb +1 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/aarch64-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/arm-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/i386-cygwin/types.conf +3 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/i386-darwin/types.conf +100 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/i386-freebsd/types.conf +152 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/i386-gnu/types.conf +107 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/i386-linux/types.conf +103 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/i386-netbsd/types.conf +126 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/i386-openbsd/types.conf +128 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/i386-solaris/types.conf +122 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/i386-windows/types.conf +105 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/ia64-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/mips-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/mips64el-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/mipsel-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/powerpc-aix/types.conf +180 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/powerpc-darwin/types.conf +100 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/powerpc-linux/types.conf +100 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/s390-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/s390x-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/sparc-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/sparc-solaris/types.conf +128 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/sparcv9-solaris/types.conf +128 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-darwin/types.conf +126 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-freebsd/types.conf +128 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-netbsd/types.conf +128 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-openbsd/types.conf +128 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-solaris/types.conf +122 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform/x86_64-windows/types.conf +27 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/platform.rb +159 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/pointer.rb +134 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/struct.rb +373 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/struct_layout_builder.rb +227 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/tools/const_generator.rb +229 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/tools/generator.rb +60 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/tools/generator_task.rb +36 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/tools/struct_generator.rb +194 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/tools/types_generator.rb +135 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/types.rb +190 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/union.rb +43 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/variadic.rb +78 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi/version.rb +4 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi.rb +20 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/lib/ffi_c.bundle +0 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/Benchmark.c +52 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/BoolTest.c +34 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/BufferTest.c +31 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/ClosureTest.c +205 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/EnumTest.c +51 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/FunctionTest.c +70 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/GNUmakefile +149 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/GlobalVariable.c +62 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/LastErrorTest.c +21 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/NumberTest.c +132 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/PointerTest.c +63 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/ReferenceTest.c +23 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/StringTest.c +34 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/StructTest.c +243 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/UnionTest.c +43 -0
- data/vendor/gems/ruby/2.2.0/gems/ffi-1.9.10/libtest/VariadicTest.c +62 -0
- data/vendor/gems/ruby/2.2.0/specifications/corefoundation-0.2.0.gemspec +45 -0
- data/vendor/gems/ruby/2.2.0/specifications/ffi-1.9.10.gemspec +49 -0
- data/yakg.gemspec +3 -3
- metadata +288 -83
- data/vendor/gems/Gemfile +0 -4
- data/vendor/gems/Gemfile.lock +0 -13
- data/vendor/gems/installit.sh +0 -65
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/COPYING +0 -674
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/COPYING.LESSER +0 -165
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/History.txt +0 -1
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/LICENSE +0 -14
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/gen/log +0 -1
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/lib/ffi/errno.rb +0 -33
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/lib/ffi/ffi.iml +0 -11
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/lib/ffi/ffi.rb +0 -33
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/lib/ffi/io.rb +0 -52
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/lib/ffi/union.rb +0 -32
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/lib/ffi/variadic.rb +0 -65
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/lib/ffi/version.rb +0 -4
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.9.0/lib/ffi_c.bundle +0 -0
- data/vendor/gems/ruby/2.0.0/specifications/ffi-1.9.0.gemspec +0 -42
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/gen/Rakefile +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/buffer.rb +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/callback.rb +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/memorypointer.rb +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/arm-linux/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/i386-cygwin/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/i386-darwin/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/i386-freebsd/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/i386-gnu/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/i386-linux/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/i386-netbsd/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/i386-openbsd/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/i386-solaris/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/i386-windows/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/ia64-linux/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/mips-linux/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/mipsel-linux/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/powerpc-aix/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/powerpc-darwin/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/powerpc-linux/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/s390-linux/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/s390x-linux/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/sparc-linux/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/sparc-solaris/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/sparcv9-solaris/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/x86_64-freebsd/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/x86_64-linux/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0/lib/ffi/platform/x86_64-openbsd → ffi-1.9.10/lib/ffi/platform/x86_64-netbsd}/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/x86_64-solaris/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/platform/x86_64-windows/types.conf +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/tools/const_generator.rb +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/tools/generator.rb +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/tools/generator_task.rb +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/tools/struct_generator.rb +0 -0
- /data/vendor/gems/ruby/2.0.0/gems/{ffi-1.9.0 → ffi-1.9.10}/lib/ffi/tools/types_generator.rb +0 -0
- /data/vendor/gems/ruby/{2.0.0/gems/ffi-1.9.0/lib/ffi/platform/x86_64-netbsd → 2.1.0/gems/ffi-1.9.10/lib/ffi/platform/i386-netbsd}/types.conf +0 -0
@@ -0,0 +1,524 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2008-2010 Wayne Meissner
|
3
|
+
#
|
4
|
+
# This file is part of ruby-ffi.
|
5
|
+
#
|
6
|
+
# All rights reserved.
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions are met:
|
10
|
+
#
|
11
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
12
|
+
# list of conditions and the following disclaimer.
|
13
|
+
# * Redistributions in binary form must reproduce the above copyright notice
|
14
|
+
# this list of conditions and the following disclaimer in the documentation
|
15
|
+
# and/or other materials provided with the distribution.
|
16
|
+
# * Neither the name of the Ruby FFI project nor the names of its contributors
|
17
|
+
# may be used to endorse or promote products derived from this software
|
18
|
+
# without specific prior written permission.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
24
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
26
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
27
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
28
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#
|
30
|
+
|
31
|
+
module FFI
|
32
|
+
CURRENT_PROCESS = USE_THIS_PROCESS_AS_LIBRARY = Object.new
|
33
|
+
|
34
|
+
# @param [#to_s] lib library name
|
35
|
+
# @return [String] library name formatted for current platform
|
36
|
+
# Transform a generic library name to a platform library name
|
37
|
+
# @example
|
38
|
+
# # Linux
|
39
|
+
# FFI.map_library_name 'c' # -> "libc.so.6"
|
40
|
+
# FFI.map_library_name 'jpeg' # -> "libjpeg.so"
|
41
|
+
# # Windows
|
42
|
+
# FFI.map_library_name 'c' # -> "msvcrt.dll"
|
43
|
+
# FFI.map_library_name 'jpeg' # -> "jpeg.dll"
|
44
|
+
def self.map_library_name(lib)
|
45
|
+
# Mangle the library name to reflect the native library naming conventions
|
46
|
+
lib = lib.to_s unless lib.kind_of?(String)
|
47
|
+
lib = Library::LIBC if lib == 'c'
|
48
|
+
|
49
|
+
if lib && File.basename(lib) == lib
|
50
|
+
lib = Platform::LIBPREFIX + lib unless lib =~ /^#{Platform::LIBPREFIX}/
|
51
|
+
r = Platform::IS_GNU ? "\\.so($|\\.[1234567890]+)" : "\\.#{Platform::LIBSUFFIX}$"
|
52
|
+
lib += ".#{Platform::LIBSUFFIX}" unless lib =~ /#{r}/
|
53
|
+
end
|
54
|
+
|
55
|
+
lib
|
56
|
+
end
|
57
|
+
|
58
|
+
# Exception raised when a function is not found in libraries
|
59
|
+
class NotFoundError < LoadError
|
60
|
+
def initialize(function, *libraries)
|
61
|
+
super("Function '#{function}' not found in [#{libraries[0].nil? ? 'current process' : libraries.join(", ")}]")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# This module is the base to use native functions.
|
66
|
+
#
|
67
|
+
# A basic usage may be:
|
68
|
+
# require 'ffi'
|
69
|
+
#
|
70
|
+
# module Hello
|
71
|
+
# extend FFI::Library
|
72
|
+
# ffi_lib FFI::Library::LIBC
|
73
|
+
# attach_function 'puts', [ :string ], :int
|
74
|
+
# end
|
75
|
+
#
|
76
|
+
# Hello.puts("Hello, World")
|
77
|
+
#
|
78
|
+
#
|
79
|
+
module Library
|
80
|
+
CURRENT_PROCESS = FFI::CURRENT_PROCESS
|
81
|
+
LIBC = FFI::Platform::LIBC
|
82
|
+
|
83
|
+
# @param mod extended object
|
84
|
+
# @return [nil]
|
85
|
+
# @raise {RuntimeError} if +mod+ is not a Module
|
86
|
+
# Test if extended object is a Module. If not, raise RuntimeError.
|
87
|
+
def self.extended(mod)
|
88
|
+
raise RuntimeError.new("must only be extended by module") unless mod.kind_of?(Module)
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
# @param [Array] names names of libraries to load
|
93
|
+
# @return [Array<DynamicLibrary>]
|
94
|
+
# @raise {LoadError} if a library cannot be opened
|
95
|
+
# Load native libraries.
|
96
|
+
def ffi_lib(*names)
|
97
|
+
raise LoadError.new("library names list must not be empty") if names.empty?
|
98
|
+
|
99
|
+
lib_flags = defined?(@ffi_lib_flags) ? @ffi_lib_flags : FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL
|
100
|
+
ffi_libs = names.map do |name|
|
101
|
+
|
102
|
+
if name == FFI::CURRENT_PROCESS
|
103
|
+
FFI::DynamicLibrary.open(nil, FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL)
|
104
|
+
|
105
|
+
else
|
106
|
+
libnames = (name.is_a?(::Array) ? name : [ name ]).map { |n| [ n, FFI.map_library_name(n) ].uniq }.flatten.compact
|
107
|
+
lib = nil
|
108
|
+
errors = {}
|
109
|
+
|
110
|
+
libnames.each do |libname|
|
111
|
+
begin
|
112
|
+
lib = FFI::DynamicLibrary.open(libname, lib_flags)
|
113
|
+
break if lib
|
114
|
+
|
115
|
+
rescue Exception => ex
|
116
|
+
ldscript = false
|
117
|
+
if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short|invalid file format)/
|
118
|
+
if File.read($1) =~ /(?:GROUP|INPUT) *\( *([^ \)]+)/
|
119
|
+
libname = $1
|
120
|
+
ldscript = true
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
if ldscript
|
125
|
+
retry
|
126
|
+
else
|
127
|
+
errors[libname] = ex
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
if lib.nil?
|
133
|
+
raise LoadError.new(errors.values.join(".\n"))
|
134
|
+
end
|
135
|
+
|
136
|
+
# return the found lib
|
137
|
+
lib
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
@ffi_libs = ffi_libs
|
142
|
+
end
|
143
|
+
|
144
|
+
# Set the calling convention for {#attach_function} and {#callback}
|
145
|
+
#
|
146
|
+
# @see http://en.wikipedia.org/wiki/Stdcall#stdcall
|
147
|
+
# @note +:stdcall+ is typically used for attaching Windows API functions
|
148
|
+
#
|
149
|
+
# @param [Symbol] convention one of +:default+, +:stdcall+
|
150
|
+
# @return [Symbol] the new calling convention
|
151
|
+
def ffi_convention(convention = nil)
|
152
|
+
@ffi_convention ||= :default
|
153
|
+
@ffi_convention = convention if convention
|
154
|
+
@ffi_convention
|
155
|
+
end
|
156
|
+
|
157
|
+
# @see #ffi_lib
|
158
|
+
# @return [Array<FFI::DynamicLibrary>] array of currently loaded FFI libraries
|
159
|
+
# @raise [LoadError] if no libraries have been loaded (using {#ffi_lib})
|
160
|
+
# Get FFI libraries loaded using {#ffi_lib}.
|
161
|
+
def ffi_libraries
|
162
|
+
raise LoadError.new("no library specified") if !defined?(@ffi_libs) || @ffi_libs.empty?
|
163
|
+
@ffi_libs
|
164
|
+
end
|
165
|
+
|
166
|
+
# Flags used in {#ffi_lib}.
|
167
|
+
#
|
168
|
+
# This map allows you to supply symbols to {#ffi_lib_flags} instead of
|
169
|
+
# the actual constants.
|
170
|
+
FlagsMap = {
|
171
|
+
:global => DynamicLibrary::RTLD_GLOBAL,
|
172
|
+
:local => DynamicLibrary::RTLD_LOCAL,
|
173
|
+
:lazy => DynamicLibrary::RTLD_LAZY,
|
174
|
+
:now => DynamicLibrary::RTLD_NOW
|
175
|
+
}
|
176
|
+
|
177
|
+
# Sets library flags for {#ffi_lib}.
|
178
|
+
#
|
179
|
+
# @example
|
180
|
+
# ffi_lib_flags(:lazy, :local) # => 5
|
181
|
+
#
|
182
|
+
# @param [Symbol, …] flags (see {FlagsMap})
|
183
|
+
# @return [Fixnum] the new value
|
184
|
+
def ffi_lib_flags(*flags)
|
185
|
+
@ffi_lib_flags = flags.inject(0) { |result, f| result | FlagsMap[f] }
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
##
|
190
|
+
# @overload attach_function(func, args, returns, options = {})
|
191
|
+
# @example attach function without an explicit name
|
192
|
+
# module Foo
|
193
|
+
# extend FFI::Library
|
194
|
+
# ffi_lib FFI::Library::LIBC
|
195
|
+
# attach_function :malloc, [:size_t], :pointer
|
196
|
+
# end
|
197
|
+
# # now callable via Foo.malloc
|
198
|
+
# @overload attach_function(name, func, args, returns, options = {})
|
199
|
+
# @example attach function with an explicit name
|
200
|
+
# module Bar
|
201
|
+
# extend FFI::Library
|
202
|
+
# ffi_lib FFI::Library::LIBC
|
203
|
+
# attach_function :c_malloc, :malloc, [:size_t], :pointer
|
204
|
+
# end
|
205
|
+
# # now callable via Bar.c_malloc
|
206
|
+
#
|
207
|
+
# Attach C function +func+ to this module.
|
208
|
+
#
|
209
|
+
#
|
210
|
+
# @param [#to_s] name name of ruby method to attach as
|
211
|
+
# @param [#to_s] func name of C function to attach
|
212
|
+
# @param [Array<Symbol>] args an array of types
|
213
|
+
# @param [Symbol] returns type of return value
|
214
|
+
# @option options [Boolean] :blocking (@blocking) set to true if the C function is a blocking call
|
215
|
+
# @option options [Symbol] :convention (:default) calling convention (see {#ffi_convention})
|
216
|
+
# @option options [FFI::Enums] :enums
|
217
|
+
# @option options [Hash] :type_map
|
218
|
+
#
|
219
|
+
# @return [FFI::VariadicInvoker]
|
220
|
+
#
|
221
|
+
# @raise [FFI::NotFoundError] if +func+ cannot be found in the attached libraries (see {#ffi_lib})
|
222
|
+
def attach_function(name, func, args, returns = nil, options = nil)
|
223
|
+
mname, a2, a3, a4, a5 = name, func, args, returns, options
|
224
|
+
cname, arg_types, ret_type, opts = (a4 && (a2.is_a?(String) || a2.is_a?(Symbol))) ? [ a2, a3, a4, a5 ] : [ mname.to_s, a2, a3, a4 ]
|
225
|
+
|
226
|
+
# Convert :foo to the native type
|
227
|
+
arg_types = arg_types.map { |e| find_type(e) }
|
228
|
+
options = {
|
229
|
+
:convention => ffi_convention,
|
230
|
+
:type_map => defined?(@ffi_typedefs) ? @ffi_typedefs : nil,
|
231
|
+
:blocking => defined?(@blocking) && @blocking,
|
232
|
+
:enums => defined?(@ffi_enums) ? @ffi_enums : nil,
|
233
|
+
}
|
234
|
+
|
235
|
+
@blocking = false
|
236
|
+
options.merge!(opts) if opts && opts.is_a?(Hash)
|
237
|
+
|
238
|
+
# Try to locate the function in any of the libraries
|
239
|
+
invokers = []
|
240
|
+
ffi_libraries.each do |lib|
|
241
|
+
if invokers.empty?
|
242
|
+
begin
|
243
|
+
function = nil
|
244
|
+
function_names(cname, arg_types).find do |fname|
|
245
|
+
function = lib.find_function(fname)
|
246
|
+
end
|
247
|
+
raise LoadError unless function
|
248
|
+
|
249
|
+
invokers << if arg_types.length > 0 && arg_types[arg_types.length - 1] == FFI::NativeType::VARARGS
|
250
|
+
VariadicInvoker.new(function, arg_types, find_type(ret_type), options)
|
251
|
+
|
252
|
+
else
|
253
|
+
Function.new(find_type(ret_type), arg_types, function, options)
|
254
|
+
end
|
255
|
+
|
256
|
+
rescue LoadError
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
invoker = invokers.compact.shift
|
261
|
+
raise FFI::NotFoundError.new(cname.to_s, ffi_libraries.map { |lib| lib.name }) unless invoker
|
262
|
+
|
263
|
+
invoker.attach(self, mname.to_s)
|
264
|
+
invoker
|
265
|
+
end
|
266
|
+
|
267
|
+
# @param [#to_s] name function name
|
268
|
+
# @param [Array] arg_types function's argument types
|
269
|
+
# @return [Array<String>]
|
270
|
+
# This function returns a list of possible names to lookup.
|
271
|
+
# @note Function names on windows may be decorated if they are using stdcall. See
|
272
|
+
# * http://en.wikipedia.org/wiki/Name_mangling#C_name_decoration_in_Microsoft_Windows
|
273
|
+
# * http://msdn.microsoft.com/en-us/library/zxk0tw93%28v=VS.100%29.aspx
|
274
|
+
# * http://en.wikibooks.org/wiki/X86_Disassembly/Calling_Conventions#STDCALL
|
275
|
+
# Note that decorated names can be overridden via def files. Also note that the
|
276
|
+
# windows api, although using, doesn't have decorated names.
|
277
|
+
def function_names(name, arg_types)
|
278
|
+
result = [name.to_s]
|
279
|
+
if ffi_convention == :stdcall
|
280
|
+
# Get the size of each parameter
|
281
|
+
size = arg_types.inject(0) do |mem, arg|
|
282
|
+
size = arg.size
|
283
|
+
# The size must be a multiple of 4
|
284
|
+
size += (4 - size) % 4
|
285
|
+
mem + size
|
286
|
+
end
|
287
|
+
|
288
|
+
result << "_#{name.to_s}@#{size}" # win32
|
289
|
+
result << "#{name.to_s}@#{size}" # win64
|
290
|
+
end
|
291
|
+
result
|
292
|
+
end
|
293
|
+
|
294
|
+
# @overload attach_variable(mname, cname, type)
|
295
|
+
# @param [#to_s] mname name of ruby method to attach as
|
296
|
+
# @param [#to_s] cname name of C variable to attach
|
297
|
+
# @param [DataConverter, Struct, Symbol, Type] type C variable's type
|
298
|
+
# @example
|
299
|
+
# module Bar
|
300
|
+
# extend FFI::Library
|
301
|
+
# ffi_lib 'my_lib'
|
302
|
+
# attach_variable :c_myvar, :myvar, :long
|
303
|
+
# end
|
304
|
+
# # now callable via Bar.c_myvar
|
305
|
+
# @overload attach_variable(cname, type)
|
306
|
+
# @param [#to_s] mname name of ruby method to attach as
|
307
|
+
# @param [DataConverter, Struct, Symbol, Type] type C variable's type
|
308
|
+
# @example
|
309
|
+
# module Bar
|
310
|
+
# extend FFI::Library
|
311
|
+
# ffi_lib 'my_lib'
|
312
|
+
# attach_variable :myvar, :long
|
313
|
+
# end
|
314
|
+
# # now callable via Bar.myvar
|
315
|
+
# @return [DynamicLibrary::Symbol]
|
316
|
+
# @raise {FFI::NotFoundError} if +cname+ cannot be found in libraries
|
317
|
+
#
|
318
|
+
# Attach C variable +cname+ to this module.
|
319
|
+
def attach_variable(mname, a1, a2 = nil)
|
320
|
+
cname, type = a2 ? [ a1, a2 ] : [ mname.to_s, a1 ]
|
321
|
+
address = nil
|
322
|
+
ffi_libraries.each do |lib|
|
323
|
+
begin
|
324
|
+
address = lib.find_variable(cname.to_s)
|
325
|
+
break unless address.nil?
|
326
|
+
rescue LoadError
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
raise FFI::NotFoundError.new(cname, ffi_libraries) if address.nil? || address.null?
|
331
|
+
if type.is_a?(Class) && type < FFI::Struct
|
332
|
+
# If it is a global struct, just attach directly to the pointer
|
333
|
+
s = type.new(address)
|
334
|
+
self.module_eval <<-code, __FILE__, __LINE__
|
335
|
+
@@ffi_gvar_#{mname} = s
|
336
|
+
def self.#{mname}
|
337
|
+
@@ffi_gvar_#{mname}
|
338
|
+
end
|
339
|
+
code
|
340
|
+
|
341
|
+
else
|
342
|
+
sc = Class.new(FFI::Struct)
|
343
|
+
sc.layout :gvar, find_type(type)
|
344
|
+
s = sc.new(address)
|
345
|
+
#
|
346
|
+
# Attach to this module as mname/mname=
|
347
|
+
#
|
348
|
+
self.module_eval <<-code, __FILE__, __LINE__
|
349
|
+
@@ffi_gvar_#{mname} = s
|
350
|
+
def self.#{mname}
|
351
|
+
@@ffi_gvar_#{mname}[:gvar]
|
352
|
+
end
|
353
|
+
def self.#{mname}=(value)
|
354
|
+
@@ffi_gvar_#{mname}[:gvar] = value
|
355
|
+
end
|
356
|
+
code
|
357
|
+
|
358
|
+
end
|
359
|
+
|
360
|
+
address
|
361
|
+
end
|
362
|
+
|
363
|
+
|
364
|
+
# @overload callback(name, params, ret)
|
365
|
+
# @param name callback name to add to type map
|
366
|
+
# @param [Array] params array of parameters' types
|
367
|
+
# @param [DataConverter, Struct, Symbol, Type] ret callback return type
|
368
|
+
# @overload callback(params, ret)
|
369
|
+
# @param [Array] params array of parameters' types
|
370
|
+
# @param [DataConverter, Struct, Symbol, Type] ret callback return type
|
371
|
+
# @return [FFI::CallbackInfo]
|
372
|
+
def callback(*args)
|
373
|
+
raise ArgumentError, "wrong number of arguments" if args.length < 2 || args.length > 3
|
374
|
+
name, params, ret = if args.length == 3
|
375
|
+
args
|
376
|
+
else
|
377
|
+
[ nil, args[0], args[1] ]
|
378
|
+
end
|
379
|
+
|
380
|
+
native_params = params.map { |e| find_type(e) }
|
381
|
+
raise ArgumentError, "callbacks cannot have variadic parameters" if native_params.include?(FFI::Type::VARARGS)
|
382
|
+
options = Hash.new
|
383
|
+
options[:convention] = ffi_convention
|
384
|
+
options[:enums] = @ffi_enums if defined?(@ffi_enums)
|
385
|
+
cb = FFI::CallbackInfo.new(find_type(ret), native_params, options)
|
386
|
+
|
387
|
+
# Add to the symbol -> type map (unless there was no name)
|
388
|
+
unless name.nil?
|
389
|
+
typedef cb, name
|
390
|
+
end
|
391
|
+
|
392
|
+
cb
|
393
|
+
end
|
394
|
+
|
395
|
+
# Register or get an already registered type definition.
|
396
|
+
#
|
397
|
+
# To register a new type definition, +old+ should be a {FFI::Type}. +add+
|
398
|
+
# is in this case the type definition.
|
399
|
+
#
|
400
|
+
# If +old+ is a {DataConverter}, a {Type::Mapped} is returned.
|
401
|
+
#
|
402
|
+
# If +old+ is +:enum+
|
403
|
+
# * and +add+ is an +Array+, a call to {#enum} is made with +add+ as single parameter;
|
404
|
+
# * in others cases, +info+ is used to create a named enum.
|
405
|
+
#
|
406
|
+
# If +old+ is a key for type map, #typedef get +old+ type definition.
|
407
|
+
#
|
408
|
+
# @param [DataConverter, Symbol, Type] old
|
409
|
+
# @param [Symbol] add
|
410
|
+
# @param [Symbol] info
|
411
|
+
# @return [FFI::Enum, FFI::Type]
|
412
|
+
def typedef(old, add, info=nil)
|
413
|
+
@ffi_typedefs = Hash.new unless defined?(@ffi_typedefs)
|
414
|
+
|
415
|
+
@ffi_typedefs[add] = if old.kind_of?(FFI::Type)
|
416
|
+
old
|
417
|
+
|
418
|
+
elsif @ffi_typedefs.has_key?(old)
|
419
|
+
@ffi_typedefs[old]
|
420
|
+
|
421
|
+
elsif old.is_a?(DataConverter)
|
422
|
+
FFI::Type::Mapped.new(old)
|
423
|
+
|
424
|
+
elsif old == :enum
|
425
|
+
if add.kind_of?(Array)
|
426
|
+
self.enum(add)
|
427
|
+
else
|
428
|
+
self.enum(info, add)
|
429
|
+
end
|
430
|
+
|
431
|
+
else
|
432
|
+
FFI.find_type(old)
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
# @overload enum(name, values)
|
437
|
+
# Create a named enum.
|
438
|
+
# @example
|
439
|
+
# enum :foo, [:zero, :one, :two] # named enum
|
440
|
+
# @param [Symbol] name name for new enum
|
441
|
+
# @param [Array] values values for enum
|
442
|
+
# @overload enum(*args)
|
443
|
+
# Create an unnamed enum.
|
444
|
+
# @example
|
445
|
+
# enum :zero, :one, :two # unnamed enum
|
446
|
+
# @param args values for enum
|
447
|
+
# @overload enum(values)
|
448
|
+
# Create an unnamed enum.
|
449
|
+
# @example
|
450
|
+
# enum [:zero, :one, :two] # unnamed enum, equivalent to above example
|
451
|
+
# @param [Array] values values for enum
|
452
|
+
# @overload enum(native_type, name, values)
|
453
|
+
# Create a named enum and specify the native type.
|
454
|
+
# @example
|
455
|
+
# enum FFI::Type::UINT64, :foo, [:zero, :one, :two] # named enum
|
456
|
+
# @param [FFI::Type] native_type native type for new enum
|
457
|
+
# @param [Symbol] name name for new enum
|
458
|
+
# @param [Array] values values for enum
|
459
|
+
# @overload enum(native_type, *args)
|
460
|
+
# Create an unnamed enum and specify the native type.
|
461
|
+
# @example
|
462
|
+
# enum FFI::Type::UINT64, :zero, :one, :two # unnamed enum
|
463
|
+
# @param [FFI::Type] native_type native type for new enum
|
464
|
+
# @param args values for enum
|
465
|
+
# @overload enum(native_type, values)
|
466
|
+
# Create an unnamed enum and specify the native type.
|
467
|
+
# @example
|
468
|
+
# enum Type::UINT64, [:zero, :one, :two] # unnamed enum, equivalent to above example
|
469
|
+
# @param [FFI::Type] native_type native type for new enum
|
470
|
+
# @param [Array] values values for enum
|
471
|
+
# @return [FFI::Enum]
|
472
|
+
# Create a new {FFI::Enum}.
|
473
|
+
def enum(*args)
|
474
|
+
native_type = args.first.kind_of?(FFI::Type) ? args.shift : nil
|
475
|
+
name, values = if args[0].kind_of?(Symbol) && args[1].kind_of?(Array)
|
476
|
+
[ args[0], args[1] ]
|
477
|
+
elsif args[0].kind_of?(Array)
|
478
|
+
[ nil, args[0] ]
|
479
|
+
else
|
480
|
+
[ nil, args ]
|
481
|
+
end
|
482
|
+
@ffi_enums = FFI::Enums.new unless defined?(@ffi_enums)
|
483
|
+
@ffi_enums << (e = native_type ? FFI::Enum.new(native_type, values, name) : FFI::Enum.new(values, name))
|
484
|
+
|
485
|
+
# If called as enum :foo, [ :zero, :one, :two ], add a typedef alias
|
486
|
+
typedef(e, name) if name
|
487
|
+
e
|
488
|
+
end
|
489
|
+
|
490
|
+
# @param name
|
491
|
+
# @return [FFI::Enum]
|
492
|
+
# Find an enum by name.
|
493
|
+
def enum_type(name)
|
494
|
+
@ffi_enums.find(name) if defined?(@ffi_enums)
|
495
|
+
end
|
496
|
+
|
497
|
+
# @param symbol
|
498
|
+
# @return [FFI::Enum]
|
499
|
+
# Find an enum by a symbol it contains.
|
500
|
+
def enum_value(symbol)
|
501
|
+
@ffi_enums.__map_symbol(symbol)
|
502
|
+
end
|
503
|
+
|
504
|
+
# @param [DataConverter, Type, Struct, Symbol] t type to find
|
505
|
+
# @return [Type]
|
506
|
+
# Find a type definition.
|
507
|
+
def find_type(t)
|
508
|
+
if t.kind_of?(Type)
|
509
|
+
t
|
510
|
+
|
511
|
+
elsif defined?(@ffi_typedefs) && @ffi_typedefs.has_key?(t)
|
512
|
+
@ffi_typedefs[t]
|
513
|
+
|
514
|
+
elsif t.is_a?(Class) && t < Struct
|
515
|
+
Type::POINTER
|
516
|
+
|
517
|
+
elsif t.is_a?(DataConverter)
|
518
|
+
# Add a typedef so next time the converter is used, it hits the cache
|
519
|
+
typedef Type::Mapped.new(t), t
|
520
|
+
|
521
|
+
end || FFI.find_type(t)
|
522
|
+
end
|
523
|
+
end
|
524
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Copyright (C) 2008 Mike Dalessio
|
2
|
+
#
|
3
|
+
# This file is part of ruby-ffi.
|
4
|
+
#
|
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
|
+
#
|
10
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
11
|
+
# list of conditions and the following disclaimer.
|
12
|
+
# * Redistributions in binary form must reproduce the above copyright notice
|
13
|
+
# this list of conditions and the following disclaimer in the documentation
|
14
|
+
# and/or other materials provided with the distribution.
|
15
|
+
# * Neither the name of the Ruby FFI project nor the names of its contributors
|
16
|
+
# may be used to endorse or promote products derived from this software
|
17
|
+
# without specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
23
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
25
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
26
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
27
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
|
30
|
+
module FFI
|
31
|
+
#
|
32
|
+
# FFI::ManagedStruct allows custom garbage-collection of your FFI::Structs.
|
33
|
+
#
|
34
|
+
# The typical use case would be when interacting with a library
|
35
|
+
# that has a nontrivial memory management design, such as a linked
|
36
|
+
# list or a binary tree.
|
37
|
+
#
|
38
|
+
# When the {Struct} instance is garbage collected, FFI::ManagedStruct will
|
39
|
+
# invoke the class's release() method during object finalization.
|
40
|
+
#
|
41
|
+
# @example Example usage:
|
42
|
+
# module MyLibrary
|
43
|
+
# ffi_lib "libmylibrary"
|
44
|
+
# attach_function :new_dlist, [], :pointer
|
45
|
+
# attach_function :destroy_dlist, [:pointer], :void
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# class DoublyLinkedList < FFI::ManagedStruct
|
49
|
+
# @@@
|
50
|
+
# struct do |s|
|
51
|
+
# s.name 'struct dlist'
|
52
|
+
# s.include 'dlist.h'
|
53
|
+
# s.field :head, :pointer
|
54
|
+
# s.field :tail, :pointer
|
55
|
+
# end
|
56
|
+
# @@@
|
57
|
+
#
|
58
|
+
# def self.release ptr
|
59
|
+
# MyLibrary.destroy_dlist(ptr)
|
60
|
+
# end
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
# begin
|
64
|
+
# ptr = DoublyLinkedList.new(MyLibrary.new_dlist)
|
65
|
+
# # do something with the list
|
66
|
+
# end
|
67
|
+
# # struct is out of scope, and will be GC'd using DoublyLinkedList#release
|
68
|
+
#
|
69
|
+
#
|
70
|
+
class ManagedStruct < FFI::Struct
|
71
|
+
|
72
|
+
# @overload initialize(pointer)
|
73
|
+
# @param [Pointer] pointer
|
74
|
+
# Create a new ManagedStruct which will invoke the class method #release on
|
75
|
+
# @overload initialize
|
76
|
+
# A new instance of FFI::ManagedStruct.
|
77
|
+
def initialize(pointer=nil)
|
78
|
+
raise NoMethodError, "release() not implemented for class #{self}" unless self.class.respond_to? :release
|
79
|
+
raise ArgumentError, "Must supply a pointer to memory for the Struct" unless pointer
|
80
|
+
super AutoPointer.new(pointer, self.class.method(:release))
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# This class is now implemented in C
|