ffi-module 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ffi/module/config_tool.rb +4 -2
- data/lib/ffi/module/library.rb +4 -4
- data/lib/ffi/module/loader.rb +4 -8
- data/lib/ffi/module/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: '0966d9341e590e8623b6e5f8b46672e1258e64d76c4b5a623fed1153d982ca97'
         | 
| 4 | 
            +
              data.tar.gz: 7c0d82c153c368cce300aa8e2e4cf45f1f2135707974d4a3da0c1f0ff6bb7aea
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: cfc6f8d0f8d137fed89851a1b94a456b11641dc60289c80fe2122ae8b4dff21ac8144cdd1b92da35a4de9a5e8cd5990ab75c1856f70a0af34257b06f0eff322c
         | 
| 7 | 
            +
              data.tar.gz: d4306604e74a7f8211d4acfa6c2eef9e7e53ae45c9807d8a0b1e2313959a82546664708633bf108f1fc98a52eece56bf6a253d67de6e1fb46335f05066a86b4d
         | 
| @@ -33,6 +33,8 @@ module FFI | |
| 33 33 | 
             
            				return false unless output = ::IO.popen(command).read
         | 
| 34 34 |  | 
| 35 35 | 
             
            				arguments = ::Shellwords.split(output)
         | 
| 36 | 
            +
            				search_paths = search_paths.dup
         | 
| 37 | 
            +
            				names = names.dup
         | 
| 36 38 |  | 
| 37 39 | 
             
            				arguments.each do |argument|
         | 
| 38 40 | 
             
            					if match = argument.match(/\A(-[lL])(.*)\z/)
         | 
| @@ -43,9 +45,9 @@ module FFI | |
| 43 45 | 
             
            						when '-l'
         | 
| 44 46 | 
             
            							names << value
         | 
| 45 47 | 
             
            						end
         | 
| 46 | 
            -
            					 | 
| 48 | 
            +
            					elsif File.directory?(argument)
         | 
| 47 49 | 
             
            						# Assume it's a search path:
         | 
| 48 | 
            -
            						search_paths <<  | 
| 50 | 
            +
            						search_paths << argument
         | 
| 49 51 | 
             
            					end
         | 
| 50 52 | 
             
            				end
         | 
| 51 53 |  | 
    
        data/lib/ffi/module/library.rb
    CHANGED
    
    | @@ -150,9 +150,9 @@ module FFI | |
| 150 150 | 
             
            			end
         | 
| 151 151 |  | 
| 152 152 | 
             
            			def ffi_define_type(name, value)
         | 
| 153 | 
            -
            				case  | 
| 153 | 
            +
            				case value
         | 
| 154 154 | 
             
            				when FFI::Type
         | 
| 155 | 
            -
            					@ffi_type_map[name] =  | 
| 155 | 
            +
            					@ffi_type_map[name] = value
         | 
| 156 156 | 
             
            				when FFI::DataConverter
         | 
| 157 157 | 
             
            					@ffi_type_map[name] = FFI::Type::Mapped.new(value)
         | 
| 158 158 | 
             
            				else
         | 
| @@ -163,13 +163,13 @@ module FFI | |
| 163 163 | 
             
            			def ffi_define_enumeration(name, *arguments)
         | 
| 164 164 | 
             
            				native_type = arguments.first.kind_of?(FFI::Type) ? arguments.shift : nil
         | 
| 165 165 |  | 
| 166 | 
            -
            				 | 
| 166 | 
            +
            				ffi_define_generic_enumeration(name, FFI::Enum, native_type, *arguments)
         | 
| 167 167 | 
             
            			end
         | 
| 168 168 |  | 
| 169 169 | 
             
            			def ffi_define_bitmask(name, *arguments)
         | 
| 170 170 | 
             
            				native_type = arguments.first.kind_of?(FFI::Type) ? arguments.shift : nil
         | 
| 171 171 |  | 
| 172 | 
            -
            				 | 
| 172 | 
            +
            				ffi_define_generic_enumeration(name, FFI::Bitmask, native_type, *arguments)
         | 
| 173 173 | 
             
            			end
         | 
| 174 174 |  | 
| 175 175 | 
             
            		private
         | 
    
        data/lib/ffi/module/loader.rb
    CHANGED
    
    | @@ -35,22 +35,18 @@ module FFI | |
| 35 35 |  | 
| 36 36 | 
             
            				return nil
         | 
| 37 37 | 
             
            			end
         | 
| 38 | 
            -
             | 
| 38 | 
            +
            			
         | 
| 39 39 | 
             
            			def ffi_load(name, search_paths: nil, **options)
         | 
| 40 40 | 
             
            				# Try to load the library directly:
         | 
| 41 | 
            -
            				return true if  | 
| 41 | 
            +
            				return true if ffi_open_library(name, **options)
         | 
| 42 42 |  | 
| 43 43 | 
             
            				# If that fails, try to load it from the specified search paths:
         | 
| 44 44 | 
             
            				if search_paths&.any?
         | 
| 45 45 | 
             
            					name = FFI.map_library_name(name)
         | 
| 46 46 |  | 
| 47 | 
            -
            					if path = ffi_find_library_path( | 
| 48 | 
            -
            						 | 
| 49 | 
            -
            							libraries << library
         | 
| 50 | 
            -
            						end
         | 
| 47 | 
            +
            					if path = ffi_find_library_path(name, search_paths)
         | 
| 48 | 
            +
            						return true if ffi_open_library(path, **options)
         | 
| 51 49 | 
             
            					end
         | 
| 52 | 
            -
            					
         | 
| 53 | 
            -
            					return true if ffi_load_library(name, **options)
         | 
| 54 50 | 
             
            				end
         | 
| 55 51 |  | 
| 56 52 | 
             
            				return nil
         | 
    
        data/lib/ffi/module/version.rb
    CHANGED