ffi 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ffi might be problematic. Click here for more details.
- data/Rakefile +3 -3
- data/ext/ffi_c/AbstractMemory.c +40 -3
- data/ext/ffi_c/AbstractMemory.h +2 -2
- data/ext/ffi_c/Buffer.c +28 -0
- data/ext/ffi_c/DynamicLibrary.c +17 -6
- data/ext/ffi_c/Function.c +20 -10
- data/ext/ffi_c/MemoryPointer.c +17 -27
- data/ext/ffi_c/Platform.c +17 -7
- data/ext/ffi_c/Pointer.c +103 -12
- data/ext/ffi_c/Pointer.h +9 -0
- data/ext/ffi_c/Struct.c +43 -1
- data/ext/ffi_c/StructLayout.c +2 -1
- data/lib/ffi/enum.rb +1 -3
- data/lib/ffi/platform.rb +1 -1
- data/lib/ffi/platform/i386-darwin/types.conf +100 -0
- data/lib/ffi/platform/i386-linux/types.conf +100 -0
- data/lib/ffi/platform/i386-openbsd/types.conf +126 -0
- data/lib/ffi/platform/i386-solaris/types.conf +122 -0
- data/lib/ffi/platform/i386-windows/types.conf +105 -0
- data/lib/ffi/platform/powerpc-aix/types.conf +180 -0
- data/lib/ffi/platform/powerpc-darwin/types.conf +100 -0
- data/lib/ffi/platform/sparc-solaris/types.conf +128 -0
- data/lib/ffi/platform/sparcv9-solaris/types.conf +128 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +100 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +100 -0
- data/lib/ffi/platform/x86_64-openbsd/types.conf +126 -0
- data/lib/ffi/platform/x86_64-solaris/types.conf +122 -0
- data/lib/ffi/struct.rb +1 -1
- data/lib/ffi/tools/generator.rb +1 -1
- data/lib/ffi/types.rb +2 -1
- data/spec/ffi/dup_spec.rb +65 -0
- data/spec/ffi/enum_spec.rb +28 -0
- data/spec/ffi/strptr_spec.rb +11 -2
- data/spec/ffi/struct_spec.rb +2 -2
- data/tasks/extension.rake +1 -1
- metadata +33 -24
- data/lib/ffi_c.bundle +0 -0
    
        data/spec/ffi/enum_spec.rb
    CHANGED
    
    | @@ -196,4 +196,32 @@ describe "All enums" do | |
| 196 196 | 
             
                enum[424242].should == :c15
         | 
| 197 197 | 
             
                enum[42424242].should == :c16
         | 
| 198 198 | 
             
              end
         | 
| 199 | 
            +
              it "return nil for values that don't have a symbol" do
         | 
| 200 | 
            +
                enum = TestEnum3.enum_type(:enum_type1)
         | 
| 201 | 
            +
                enum[-1].should == nil
         | 
| 202 | 
            +
                enum[4].should == nil
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                enum = TestEnum3.enum_type(:enum_type2)
         | 
| 205 | 
            +
                enum[0].should == nil
         | 
| 206 | 
            +
                enum[41].should == nil
         | 
| 207 | 
            +
                enum[46].should == nil
         | 
| 208 | 
            +
             | 
| 209 | 
            +
                enum = TestEnum3.enum_type(:enum_type3)
         | 
| 210 | 
            +
                enum[0].should == nil
         | 
| 211 | 
            +
                enum[41].should == nil
         | 
| 212 | 
            +
                enum[44].should == nil
         | 
| 213 | 
            +
                enum[4241].should == nil
         | 
| 214 | 
            +
                enum[4244].should == nil
         | 
| 215 | 
            +
             | 
| 216 | 
            +
                enum = TestEnum3.enum_type(:enum_type4)
         | 
| 217 | 
            +
                enum[0].should == nil
         | 
| 218 | 
            +
                enum[41].should == nil
         | 
| 219 | 
            +
                enum[43].should == nil
         | 
| 220 | 
            +
                enum[4241].should == nil
         | 
| 221 | 
            +
                enum[4243].should == nil
         | 
| 222 | 
            +
                enum[424241].should == nil
         | 
| 223 | 
            +
                enum[424243].should == nil
         | 
| 224 | 
            +
                enum[42424241].should == nil
         | 
| 225 | 
            +
                enum[42424243].should == nil
         | 
| 226 | 
            +
              end
         | 
| 199 227 | 
             
            end
         | 
    
        data/spec/ffi/strptr_spec.rb
    CHANGED
    
    | @@ -17,12 +17,17 @@ | |
| 17 17 | 
             
            require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
         | 
| 18 18 |  | 
| 19 19 | 
             
            describe "functions returning :strptr" do
         | 
| 20 | 
            +
             | 
| 20 21 | 
             
              it "can attach function with :strptr return type" do
         | 
| 21 22 | 
             
                lambda do
         | 
| 22 23 | 
             
                  m = Module.new do
         | 
| 23 24 | 
             
                    extend FFI::Library
         | 
| 24 25 | 
             
                    ffi_lib FFI::Library::LIBC
         | 
| 25 | 
            -
                     | 
| 26 | 
            +
                    if !FFI::Platform.windows?
         | 
| 27 | 
            +
                      attach_function :strdup, [ :string ], :strptr
         | 
| 28 | 
            +
                    else
         | 
| 29 | 
            +
                      attach_function :_strdup, [ :string ], :strptr
         | 
| 30 | 
            +
                    end
         | 
| 26 31 | 
             
                  end
         | 
| 27 32 | 
             
                end.should_not raise_error
         | 
| 28 33 | 
             
              end
         | 
| @@ -30,8 +35,12 @@ describe "functions returning :strptr" do | |
| 30 35 | 
             
              module StrPtr
         | 
| 31 36 | 
             
                extend FFI::Library
         | 
| 32 37 | 
             
                ffi_lib FFI::Library::LIBC
         | 
| 33 | 
            -
                attach_function :strdup, [ :string ], :strptr
         | 
| 34 38 | 
             
                attach_function :free, [ :pointer ], :void
         | 
| 39 | 
            +
                if !FFI::Platform.windows?
         | 
| 40 | 
            +
                  attach_function :strdup, [ :string ], :strptr
         | 
| 41 | 
            +
                else
         | 
| 42 | 
            +
                  attach_function :strdup, :_strdup, [ :string ], :strptr
         | 
| 43 | 
            +
                end
         | 
| 35 44 | 
             
              end
         | 
| 36 45 |  | 
| 37 46 | 
             
              it "should return [ String, Pointer ]" do
         | 
    
        data/spec/ffi/struct_spec.rb
    CHANGED
    
    | @@ -584,9 +584,9 @@ describe FFI::Struct, ' with an array field'  do | |
| 584 584 | 
             
            #  it 'should cache array object for successive calls' do
         | 
| 585 585 | 
             
            #    @s[:a].object_id.should == @s[:a].object_id
         | 
| 586 586 | 
             
            #  end
         | 
| 587 | 
            -
              it 'should return the  | 
| 587 | 
            +
              it 'should return the number of elements in the array field' do
         | 
| 588 588 | 
             
                @s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
         | 
| 589 | 
            -
                @s[:a].size.should ==  | 
| 589 | 
            +
                @s[:a].size.should == 5
         | 
| 590 590 | 
             
              end
         | 
| 591 591 | 
             
              it 'should allow iteration through the array elements' do
         | 
| 592 592 | 
             
                @s = LibTest::StructWithArray.new(LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
         | 
    
        data/tasks/extension.rake
    CHANGED
    
    | @@ -13,7 +13,7 @@ spec = Gem::Specification.new do |s| | |
| 13 13 | 
             
              s.extensions = %w(ext/ffi_c/extconf.rb gen/Rakefile)
         | 
| 14 14 | 
             
              s.require_path = 'lib'
         | 
| 15 15 | 
             
              s.files = PROJ.gem.files
         | 
| 16 | 
            -
              s.add_dependency *PROJ.gem.dependencies.flatten
         | 
| 16 | 
            +
              s.add_dependency *PROJ.gem.dependencies.flatten unless PROJ.gem.dependencies.empty?
         | 
| 17 17 | 
             
              PROJ.gem.extras.each do |msg, val|
         | 
| 18 18 | 
             
                case val
         | 
| 19 19 | 
             
                when Proc
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: ffi
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 5
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 1
         | 
| 8 8 | 
             
              - 0
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 1.0. | 
| 9 | 
            +
              - 9
         | 
| 10 | 
            +
              version: 1.0.9
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Wayne Meissner
         | 
| @@ -15,25 +15,10 @@ autorequire: | |
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date: 2011- | 
| 18 | 
            +
            date: 2011-05-22 00:00:00 +10:00
         | 
| 19 19 | 
             
            default_executable: 
         | 
| 20 | 
            -
            dependencies: 
         | 
| 21 | 
            -
             | 
| 22 | 
            -
              name: rake
         | 
| 23 | 
            -
              prerelease: false
         | 
| 24 | 
            -
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 25 | 
            -
                none: false
         | 
| 26 | 
            -
                requirements: 
         | 
| 27 | 
            -
                - - ">="
         | 
| 28 | 
            -
                  - !ruby/object:Gem::Version 
         | 
| 29 | 
            -
                    hash: 49
         | 
| 30 | 
            -
                    segments: 
         | 
| 31 | 
            -
                    - 0
         | 
| 32 | 
            -
                    - 8
         | 
| 33 | 
            -
                    - 7
         | 
| 34 | 
            -
                    version: 0.8.7
         | 
| 35 | 
            -
              type: :runtime
         | 
| 36 | 
            -
              version_requirements: *id001
         | 
| 20 | 
            +
            dependencies: []
         | 
| 21 | 
            +
             | 
| 37 22 | 
             
            description: |-
         | 
| 38 23 | 
             
              Ruby-FFI is a ruby extension for programmatically loading dynamic
         | 
| 39 24 | 
             
              libraries, binding functions within them, and calling those functions
         | 
| @@ -45,11 +30,22 @@ executables: [] | |
| 45 30 |  | 
| 46 31 | 
             
            extensions: 
         | 
| 47 32 | 
             
            - ext/ffi_c/extconf.rb
         | 
| 48 | 
            -
            - gen/Rakefile
         | 
| 49 33 | 
             
            extra_rdoc_files: 
         | 
| 50 34 | 
             
            - History.txt
         | 
| 51 35 | 
             
            - README.rdoc
         | 
| 52 | 
            -
            - lib/ | 
| 36 | 
            +
            - lib/ffi/platform/i386-darwin/types.conf
         | 
| 37 | 
            +
            - lib/ffi/platform/i386-linux/types.conf
         | 
| 38 | 
            +
            - lib/ffi/platform/i386-openbsd/types.conf
         | 
| 39 | 
            +
            - lib/ffi/platform/i386-solaris/types.conf
         | 
| 40 | 
            +
            - lib/ffi/platform/i386-windows/types.conf
         | 
| 41 | 
            +
            - lib/ffi/platform/powerpc-aix/types.conf
         | 
| 42 | 
            +
            - lib/ffi/platform/powerpc-darwin/types.conf
         | 
| 43 | 
            +
            - lib/ffi/platform/sparc-solaris/types.conf
         | 
| 44 | 
            +
            - lib/ffi/platform/sparcv9-solaris/types.conf
         | 
| 45 | 
            +
            - lib/ffi/platform/x86_64-darwin/types.conf
         | 
| 46 | 
            +
            - lib/ffi/platform/x86_64-linux/types.conf
         | 
| 47 | 
            +
            - lib/ffi/platform/x86_64-openbsd/types.conf
         | 
| 48 | 
            +
            - lib/ffi/platform/x86_64-solaris/types.conf
         | 
| 53 49 | 
             
            files: 
         | 
| 54 50 | 
             
            - History.txt
         | 
| 55 51 | 
             
            - LICENSE
         | 
| @@ -369,6 +365,19 @@ files: | |
| 369 365 | 
             
            - lib/ffi/managedstruct.rb
         | 
| 370 366 | 
             
            - lib/ffi/memorypointer.rb
         | 
| 371 367 | 
             
            - lib/ffi/platform.rb
         | 
| 368 | 
            +
            - lib/ffi/platform/i386-darwin/types.conf
         | 
| 369 | 
            +
            - lib/ffi/platform/i386-linux/types.conf
         | 
| 370 | 
            +
            - lib/ffi/platform/i386-openbsd/types.conf
         | 
| 371 | 
            +
            - lib/ffi/platform/i386-solaris/types.conf
         | 
| 372 | 
            +
            - lib/ffi/platform/i386-windows/types.conf
         | 
| 373 | 
            +
            - lib/ffi/platform/powerpc-aix/types.conf
         | 
| 374 | 
            +
            - lib/ffi/platform/powerpc-darwin/types.conf
         | 
| 375 | 
            +
            - lib/ffi/platform/sparc-solaris/types.conf
         | 
| 376 | 
            +
            - lib/ffi/platform/sparcv9-solaris/types.conf
         | 
| 377 | 
            +
            - lib/ffi/platform/x86_64-darwin/types.conf
         | 
| 378 | 
            +
            - lib/ffi/platform/x86_64-linux/types.conf
         | 
| 379 | 
            +
            - lib/ffi/platform/x86_64-openbsd/types.conf
         | 
| 380 | 
            +
            - lib/ffi/platform/x86_64-solaris/types.conf
         | 
| 372 381 | 
             
            - lib/ffi/pointer.rb
         | 
| 373 382 | 
             
            - lib/ffi/struct.rb
         | 
| 374 383 | 
             
            - lib/ffi/struct_layout_builder.rb
         | 
| @@ -380,13 +389,13 @@ files: | |
| 380 389 | 
             
            - lib/ffi/types.rb
         | 
| 381 390 | 
             
            - lib/ffi/union.rb
         | 
| 382 391 | 
             
            - lib/ffi/variadic.rb
         | 
| 383 | 
            -
            - lib/ffi_c.bundle
         | 
| 384 392 | 
             
            - spec/ffi/async_callback_spec.rb
         | 
| 385 393 | 
             
            - spec/ffi/bool_spec.rb
         | 
| 386 394 | 
             
            - spec/ffi/buffer_spec.rb
         | 
| 387 395 | 
             
            - spec/ffi/callback_spec.rb
         | 
| 388 396 | 
             
            - spec/ffi/custom_param_type.rb
         | 
| 389 397 | 
             
            - spec/ffi/custom_type_spec.rb
         | 
| 398 | 
            +
            - spec/ffi/dup_spec.rb
         | 
| 390 399 | 
             
            - spec/ffi/enum_spec.rb
         | 
| 391 400 | 
             
            - spec/ffi/errno_spec.rb
         | 
| 392 401 | 
             
            - spec/ffi/ffi_spec.rb
         | 
    
        data/lib/ffi_c.bundle
    DELETED
    
    | Binary file |