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,227 @@
|
|
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
|
+
|
32
|
+
module FFI
|
33
|
+
|
34
|
+
# Build a {StructLayout struct layout}.
|
35
|
+
class StructLayoutBuilder
|
36
|
+
attr_reader :size
|
37
|
+
attr_reader :alignment
|
38
|
+
|
39
|
+
def initialize
|
40
|
+
@size = 0
|
41
|
+
@alignment = 1
|
42
|
+
@min_alignment = 1
|
43
|
+
@packed = false
|
44
|
+
@union = false
|
45
|
+
@fields = Array.new
|
46
|
+
end
|
47
|
+
|
48
|
+
# Set size attribute with +size+ only if +size+ is greater than attribute value.
|
49
|
+
# @param [Numeric] size
|
50
|
+
def size=(size)
|
51
|
+
@size = size if size > @size
|
52
|
+
end
|
53
|
+
|
54
|
+
# Set alignment attribute with +align+ only if it is greater than attribute value.
|
55
|
+
# @param [Numeric] align
|
56
|
+
def alignment=(align)
|
57
|
+
@alignment = align if align > @alignment
|
58
|
+
@min_alignment = align
|
59
|
+
end
|
60
|
+
|
61
|
+
# Set union attribute.
|
62
|
+
# Set to +true+ to build a {Union} instead of a {Struct}.
|
63
|
+
# @param [Boolean] is_union
|
64
|
+
# @return [is_union]
|
65
|
+
def union=(is_union)
|
66
|
+
@union = is_union
|
67
|
+
end
|
68
|
+
|
69
|
+
# Building a {Union} or a {Struct} ?
|
70
|
+
#
|
71
|
+
# @return [Boolean]
|
72
|
+
#
|
73
|
+
def union?
|
74
|
+
@union
|
75
|
+
end
|
76
|
+
|
77
|
+
# Set packed attribute
|
78
|
+
# @overload packed=(packed) Set alignment and packed attributes to
|
79
|
+
# +packed+.
|
80
|
+
#
|
81
|
+
# @param [Fixnum] packed
|
82
|
+
#
|
83
|
+
# @return [packed]
|
84
|
+
# @overload packed=(packed) Set packed attribute.
|
85
|
+
# @param packed
|
86
|
+
#
|
87
|
+
# @return [0,1]
|
88
|
+
#
|
89
|
+
def packed=(packed)
|
90
|
+
if packed.is_a?(Fixnum)
|
91
|
+
@alignment = packed
|
92
|
+
@packed = packed
|
93
|
+
else
|
94
|
+
@packed = packed ? 1 : 0
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
# List of number types
|
100
|
+
NUMBER_TYPES = [
|
101
|
+
Type::INT8,
|
102
|
+
Type::UINT8,
|
103
|
+
Type::INT16,
|
104
|
+
Type::UINT16,
|
105
|
+
Type::INT32,
|
106
|
+
Type::UINT32,
|
107
|
+
Type::LONG,
|
108
|
+
Type::ULONG,
|
109
|
+
Type::INT64,
|
110
|
+
Type::UINT64,
|
111
|
+
Type::FLOAT32,
|
112
|
+
Type::FLOAT64,
|
113
|
+
Type::LONGDOUBLE,
|
114
|
+
Type::BOOL,
|
115
|
+
]
|
116
|
+
|
117
|
+
# @param [String, Symbol] name name of the field
|
118
|
+
# @param [Array, DataConverter, Struct, StructLayout::Field, Symbol, Type] type type of the field
|
119
|
+
# @param [Numeric, nil] offset
|
120
|
+
# @return [self]
|
121
|
+
# Add a field to the builder.
|
122
|
+
# @note Setting +offset+ to +nil+ or +-1+ is equivalent to +0+.
|
123
|
+
def add(name, type, offset = nil)
|
124
|
+
|
125
|
+
if offset.nil? || offset == -1
|
126
|
+
offset = @union ? 0 : align(@size, @packed ? [ @packed, type.alignment ].min : [ @min_alignment, type.alignment ].max)
|
127
|
+
end
|
128
|
+
|
129
|
+
#
|
130
|
+
# If a FFI::Type type was passed in as the field arg, try and convert to a StructLayout::Field instance
|
131
|
+
#
|
132
|
+
field = type.is_a?(StructLayout::Field) ? type : field_for_type(name, offset, type)
|
133
|
+
@fields << field
|
134
|
+
@alignment = [ @alignment, field.alignment ].max unless @packed
|
135
|
+
@size = [ @size, field.size + (@union ? 0 : field.offset) ].max
|
136
|
+
|
137
|
+
return self
|
138
|
+
end
|
139
|
+
|
140
|
+
# @param (see #add)
|
141
|
+
# @return (see #add)
|
142
|
+
# Same as {#add}.
|
143
|
+
# @see #add
|
144
|
+
def add_field(name, type, offset = nil)
|
145
|
+
add(name, type, offset)
|
146
|
+
end
|
147
|
+
|
148
|
+
# @param (see #add)
|
149
|
+
# @return (see #add)
|
150
|
+
# Add a struct as a field to the builder.
|
151
|
+
def add_struct(name, type, offset = nil)
|
152
|
+
add(name, Type::Struct.new(type), offset)
|
153
|
+
end
|
154
|
+
|
155
|
+
# @param name (see #add)
|
156
|
+
# @param type (see #add)
|
157
|
+
# @param [Numeric] count array length
|
158
|
+
# @param offset (see #add)
|
159
|
+
# @return (see #add)
|
160
|
+
# Add an array as a field to the builder.
|
161
|
+
def add_array(name, type, count, offset = nil)
|
162
|
+
add(name, Type::Array.new(type, count), offset)
|
163
|
+
end
|
164
|
+
|
165
|
+
# @return [StructLayout]
|
166
|
+
# Build and return the struct layout.
|
167
|
+
def build
|
168
|
+
# Add tail padding if the struct is not packed
|
169
|
+
size = @packed ? @size : align(@size, @alignment)
|
170
|
+
|
171
|
+
layout = StructLayout.new(@fields, size, @alignment)
|
172
|
+
layout.__union! if @union
|
173
|
+
layout
|
174
|
+
end
|
175
|
+
|
176
|
+
private
|
177
|
+
|
178
|
+
# @param [Numeric] offset
|
179
|
+
# @param [Numeric] align
|
180
|
+
# @return [Numeric]
|
181
|
+
def align(offset, align)
|
182
|
+
align + ((offset - 1) & ~(align - 1));
|
183
|
+
end
|
184
|
+
|
185
|
+
# @param (see #add)
|
186
|
+
# @return [StructLayout::Field]
|
187
|
+
def field_for_type(name, offset, type)
|
188
|
+
field_class = case
|
189
|
+
when type.is_a?(Type::Function)
|
190
|
+
StructLayout::Function
|
191
|
+
|
192
|
+
when type.is_a?(Type::Struct)
|
193
|
+
StructLayout::InnerStruct
|
194
|
+
|
195
|
+
when type.is_a?(Type::Array)
|
196
|
+
StructLayout::Array
|
197
|
+
|
198
|
+
when type.is_a?(FFI::Enum)
|
199
|
+
StructLayout::Enum
|
200
|
+
|
201
|
+
when NUMBER_TYPES.include?(type)
|
202
|
+
StructLayout::Number
|
203
|
+
|
204
|
+
when type == Type::POINTER
|
205
|
+
StructLayout::Pointer
|
206
|
+
|
207
|
+
when type == Type::STRING
|
208
|
+
StructLayout::String
|
209
|
+
|
210
|
+
when type.is_a?(Class) && type < StructLayout::Field
|
211
|
+
type
|
212
|
+
|
213
|
+
when type.is_a?(DataConverter)
|
214
|
+
return StructLayout::Mapped.new(name, offset, Type::Mapped.new(type), field_for_type(name, offset, type.native_type))
|
215
|
+
|
216
|
+
when type.is_a?(Type::Mapped)
|
217
|
+
return StructLayout::Mapped.new(name, offset, type, field_for_type(name, offset, type.native_type))
|
218
|
+
|
219
|
+
else
|
220
|
+
raise TypeError, "invalid struct field type #{type.inspect}"
|
221
|
+
end
|
222
|
+
|
223
|
+
field_class.new(name, offset, type)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'open3'
|
3
|
+
|
4
|
+
module FFI
|
5
|
+
|
6
|
+
# ConstGenerator turns C constants into ruby values.
|
7
|
+
#
|
8
|
+
# @example a simple example for stdio
|
9
|
+
# cg = FFI::ConstGenerator.new('stdio') do |gen|
|
10
|
+
# gen.const(:SEEK_SET)
|
11
|
+
# gen.const('SEEK_CUR')
|
12
|
+
# gen.const('seek_end') # this constant does not exist
|
13
|
+
# end # #calculate called automatically at the end of the block
|
14
|
+
#
|
15
|
+
# cg['SEEK_SET'] # => 0
|
16
|
+
# cg['SEEK_CUR'] # => 1
|
17
|
+
# cg['seek_end'] # => nil
|
18
|
+
# cg.to_ruby # => "SEEK_SET = 0\nSEEK_CUR = 1\n# seek_end not available"
|
19
|
+
class ConstGenerator
|
20
|
+
@options = {}
|
21
|
+
attr_reader :constants
|
22
|
+
|
23
|
+
# Creates a new constant generator that uses +prefix+ as a name, and an
|
24
|
+
# options hash.
|
25
|
+
#
|
26
|
+
# The only option is +:required+, which if set to +true+ raises an error if a
|
27
|
+
# constant you have requested was not found.
|
28
|
+
#
|
29
|
+
# @param [#to_s] prefix
|
30
|
+
# @param [Hash] options
|
31
|
+
# @return
|
32
|
+
# @option options [Boolean] :required
|
33
|
+
# @overload initialize(prefix, options)
|
34
|
+
# @overload initialize(prefix, options) { |gen| ... }
|
35
|
+
# @yieldparam [ConstGenerator] gen new generator is passed to the block
|
36
|
+
# When passed a block, {#calculate} is automatically called at the end of
|
37
|
+
# the block, otherwise you must call it yourself.
|
38
|
+
def initialize(prefix = nil, options = {})
|
39
|
+
@includes = ['stdio.h', 'stddef.h']
|
40
|
+
@constants = {}
|
41
|
+
@prefix = prefix
|
42
|
+
|
43
|
+
@required = options[:required]
|
44
|
+
@options = options
|
45
|
+
|
46
|
+
if block_given? then
|
47
|
+
yield self
|
48
|
+
calculate self.class.options.merge(options)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
# Set class options
|
52
|
+
# These options are merged with {#initialize} options when it is called with a block.
|
53
|
+
# @param [Hash] options
|
54
|
+
# @return [Hash] class options
|
55
|
+
def self.options=(options)
|
56
|
+
@options = options
|
57
|
+
end
|
58
|
+
# Get class options.
|
59
|
+
# @return [Hash] class options
|
60
|
+
def self.options
|
61
|
+
@options
|
62
|
+
end
|
63
|
+
# @param [String] name
|
64
|
+
# @return constant value (converted if a +converter+ was defined).
|
65
|
+
# Access a constant by name.
|
66
|
+
def [](name)
|
67
|
+
@constants[name].converted_value
|
68
|
+
end
|
69
|
+
|
70
|
+
# Request the value for C constant +name+.
|
71
|
+
#
|
72
|
+
# @param [#to_s] name C constant name
|
73
|
+
# @param [String] format a printf format string to print the value out
|
74
|
+
# @param [String] cast a C cast for the value
|
75
|
+
# @param ruby_name alternate ruby name for {#to_ruby}
|
76
|
+
#
|
77
|
+
# @overload const(name, format=nil, cast='', ruby_name=nil, converter=nil)
|
78
|
+
# +converter+ is a Method or a Proc.
|
79
|
+
# @param [#call] converter convert the value from a string to the appropriate
|
80
|
+
# type for {#to_ruby}.
|
81
|
+
# @overload const(name, format=nil, cast='', ruby_name=nil) { |value| ... }
|
82
|
+
# Use a converter block. This block convert the value from a string to the
|
83
|
+
# appropriate type for {#to_ruby}.
|
84
|
+
# @yieldparam value constant value
|
85
|
+
def const(name, format = nil, cast = '', ruby_name = nil, converter = nil,
|
86
|
+
&converter_proc)
|
87
|
+
format ||= '%d'
|
88
|
+
cast ||= ''
|
89
|
+
|
90
|
+
if converter_proc and converter then
|
91
|
+
raise ArgumentError, "Supply only converter or converter block"
|
92
|
+
end
|
93
|
+
|
94
|
+
converter = converter_proc if converter.nil?
|
95
|
+
|
96
|
+
const = Constant.new name, format, cast, ruby_name, converter
|
97
|
+
@constants[name.to_s] = const
|
98
|
+
return const
|
99
|
+
end
|
100
|
+
|
101
|
+
# Calculate constants values.
|
102
|
+
# @param [Hash] options
|
103
|
+
# @option options [String] :cppflags flags for C compiler
|
104
|
+
# @return [nil]
|
105
|
+
# @raise if a constant is missing and +:required+ was set to +true+ (see {#initialize})
|
106
|
+
def calculate(options = {})
|
107
|
+
binary = File.join Dir.tmpdir, "rb_const_gen_bin_#{Process.pid}"
|
108
|
+
|
109
|
+
Tempfile.open("#{@prefix}.const_generator") do |f|
|
110
|
+
@includes.each do |inc|
|
111
|
+
f.puts "#include <#{inc}>"
|
112
|
+
end
|
113
|
+
f.puts "\nint main(int argc, char **argv)\n{"
|
114
|
+
|
115
|
+
@constants.each_value do |const|
|
116
|
+
f.puts <<-EOF
|
117
|
+
#ifdef #{const.name}
|
118
|
+
printf("#{const.name} #{const.format}\\n", #{const.cast}#{const.name});
|
119
|
+
#endif
|
120
|
+
EOF
|
121
|
+
end
|
122
|
+
|
123
|
+
f.puts "\n\treturn 0;\n}"
|
124
|
+
f.flush
|
125
|
+
|
126
|
+
output = `gcc #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -x c -Wall -Werror #{f.path} -o #{binary} 2>&1`
|
127
|
+
|
128
|
+
unless $?.success? then
|
129
|
+
output = output.split("\n").map { |l| "\t#{l}" }.join "\n"
|
130
|
+
raise "Compilation error generating constants #{@prefix}:\n#{output}"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
output = `#{binary}`
|
135
|
+
File.unlink(binary + (FFI::Platform.windows? ? ".exe" : ""))
|
136
|
+
output.each_line do |line|
|
137
|
+
line =~ /^(\S+)\s(.*)$/
|
138
|
+
const = @constants[$1]
|
139
|
+
const.value = $2
|
140
|
+
end
|
141
|
+
|
142
|
+
missing_constants = @constants.select do |name, constant|
|
143
|
+
constant.value.nil?
|
144
|
+
end.map { |name,| name }
|
145
|
+
|
146
|
+
if @required and not missing_constants.empty? then
|
147
|
+
raise "Missing required constants for #{@prefix}: #{missing_constants.join ', '}"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Dump constants to +io+.
|
152
|
+
# @param [#puts] io
|
153
|
+
# @return [nil]
|
154
|
+
def dump_constants(io)
|
155
|
+
@constants.each do |name, constant|
|
156
|
+
name = [@prefix, name].join '.' if @prefix
|
157
|
+
io.puts "#{name} = #{constant.converted_value}"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
# Outputs values for discovered constants. If the constant's value was
|
162
|
+
# not discovered it is not omitted.
|
163
|
+
# @return [String]
|
164
|
+
def to_ruby
|
165
|
+
@constants.sort_by { |name,| name }.map do |name, constant|
|
166
|
+
if constant.value.nil? then
|
167
|
+
"# #{name} not available"
|
168
|
+
else
|
169
|
+
constant.to_ruby
|
170
|
+
end
|
171
|
+
end.join "\n"
|
172
|
+
end
|
173
|
+
|
174
|
+
# Add additional C include file(s) to calculate constants from.
|
175
|
+
# @note +stdio.h+ and +stddef.h+ automatically included
|
176
|
+
# @param [List<String>, Array<String>] i include file(s)
|
177
|
+
# @return [Array<String>] array of include files
|
178
|
+
def include(*i)
|
179
|
+
@includes |= i.flatten
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
# This class hold constants for {ConstGenerator}
|
185
|
+
class ConstGenerator::Constant
|
186
|
+
|
187
|
+
attr_reader :name, :format, :cast
|
188
|
+
attr_accessor :value
|
189
|
+
|
190
|
+
# @param [#to_s] name
|
191
|
+
# @param [String] format a printf format string to print the value out
|
192
|
+
# @param [String] cast a C cast for the value
|
193
|
+
# @param ruby_name alternate ruby name for {#to_ruby}
|
194
|
+
# @param [#call] converter convert the value from a string to the appropriate
|
195
|
+
# type for {#to_ruby}.
|
196
|
+
def initialize(name, format, cast, ruby_name = nil, converter=nil)
|
197
|
+
@name = name
|
198
|
+
@format = format
|
199
|
+
@cast = cast
|
200
|
+
@ruby_name = ruby_name
|
201
|
+
@converter = converter
|
202
|
+
@value = nil
|
203
|
+
end
|
204
|
+
|
205
|
+
# Return constant value (converted if a +converter+ was defined).
|
206
|
+
# @return constant value.
|
207
|
+
def converted_value
|
208
|
+
if @converter
|
209
|
+
@converter.call(@value)
|
210
|
+
else
|
211
|
+
@value
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
# get constant ruby name
|
216
|
+
# @return [String]
|
217
|
+
def ruby_name
|
218
|
+
@ruby_name || @name
|
219
|
+
end
|
220
|
+
|
221
|
+
# Get an evaluable string from constant.
|
222
|
+
# @return [String]
|
223
|
+
def to_ruby
|
224
|
+
"#{ruby_name} = #{converted_value}"
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module FFI
|
2
|
+
|
3
|
+
# @private
|
4
|
+
class Generator
|
5
|
+
|
6
|
+
def initialize(ffi_name, rb_name, options = {})
|
7
|
+
@ffi_name = ffi_name
|
8
|
+
@rb_name = rb_name
|
9
|
+
@options = options
|
10
|
+
@name = File.basename rb_name, '.rb'
|
11
|
+
|
12
|
+
file = File.read @ffi_name
|
13
|
+
|
14
|
+
new_file = file.gsub(/^( *)@@@(.*?)@@@/m) do
|
15
|
+
@constants = []
|
16
|
+
@structs = []
|
17
|
+
|
18
|
+
indent = $1
|
19
|
+
original_lines = $2.count "\n"
|
20
|
+
|
21
|
+
instance_eval $2, @ffi_name, $`.count("\n")
|
22
|
+
|
23
|
+
new_lines = []
|
24
|
+
@constants.each { |c| new_lines << c.to_ruby }
|
25
|
+
@structs.each { |s| new_lines << s.generate_layout }
|
26
|
+
|
27
|
+
new_lines = new_lines.join("\n").split "\n" # expand multiline blocks
|
28
|
+
new_lines = new_lines.map { |line| indent + line }
|
29
|
+
|
30
|
+
padding = original_lines - new_lines.length
|
31
|
+
new_lines += [nil] * padding if padding >= 0
|
32
|
+
|
33
|
+
new_lines.join "\n"
|
34
|
+
end
|
35
|
+
|
36
|
+
open @rb_name, 'w' do |f|
|
37
|
+
f.puts "# This file is generated by rake. Do not edit."
|
38
|
+
f.puts
|
39
|
+
f.puts new_file
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def constants(options = {}, &block)
|
44
|
+
@constants << FFI::ConstGenerator.new(@name, @options.merge(options), &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
def struct(options = {}, &block)
|
48
|
+
@structs << FFI::StructGenerator.new(@name, @options.merge(options), &block)
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# Utility converter for constants
|
53
|
+
|
54
|
+
def to_s
|
55
|
+
proc { |obj| obj.to_s.inspect }
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
begin
|
2
|
+
require 'ffi/struct_generator'
|
3
|
+
require 'ffi/const_generator'
|
4
|
+
require 'ffi/generator'
|
5
|
+
rescue LoadError
|
6
|
+
# from Rakefile
|
7
|
+
require 'lib/ffi/struct_generator'
|
8
|
+
require 'lib/ffi/const_generator'
|
9
|
+
require 'lib/ffi/generator'
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rake'
|
13
|
+
require 'rake/tasklib'
|
14
|
+
require 'tempfile'
|
15
|
+
|
16
|
+
##
|
17
|
+
# Rake task that calculates C structs for FFI::Struct.
|
18
|
+
|
19
|
+
# @private
|
20
|
+
class FFI::Generator::Task < Rake::TaskLib
|
21
|
+
|
22
|
+
def initialize(rb_names)
|
23
|
+
task :clean do rm_f rb_names end
|
24
|
+
|
25
|
+
rb_names.each do |rb_name|
|
26
|
+
ffi_name = "#{rb_name}.ffi"
|
27
|
+
|
28
|
+
file rb_name => ffi_name do |t|
|
29
|
+
puts "Generating #{rb_name}..." if Rake.application.options.trace
|
30
|
+
|
31
|
+
FFI::Generator.new ffi_name, rb_name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|