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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5eb3b1aa3f99163ffd15dddc88852709b31677be988ebd0c2d3758866f19d43
4
- data.tar.gz: 138e20272596fe28a109d49634f3357e7c544fe3b266ccc158dfcfc44906efff
3
+ metadata.gz: '0966d9341e590e8623b6e5f8b46672e1258e64d76c4b5a623fed1153d982ca97'
4
+ data.tar.gz: 7c0d82c153c368cce300aa8e2e4cf45f1f2135707974d4a3da0c1f0ff6bb7aea
5
5
  SHA512:
6
- metadata.gz: bd1516bf65a1d8d19bd4a972f03e47ef078441f6c5927eb699a79428bb727b740e62193f810cce6c2ebc4d4e1e39d90abcf38a076da04c8d4e628af4e1a3ae50
7
- data.tar.gz: e194ca5bd89f3c75716e50b9f389803c73b0a5136e7eef766c43a1b31f0d193e2e097bd93373454d458fdd5057d20042b955b4e8c88b81053ce5aac8038d6dcc
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
- else
48
+ elsif File.directory?(argument)
47
49
  # Assume it's a search path:
48
- search_paths << value
50
+ search_paths << argument
49
51
  end
50
52
  end
51
53
 
@@ -150,9 +150,9 @@ module FFI
150
150
  end
151
151
 
152
152
  def ffi_define_type(name, value)
153
- case type
153
+ case value
154
154
  when FFI::Type
155
- @ffi_type_map[name] = type
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
- ffi_generic_enumeration(name, FFI::Enum, native_type, arguments)
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
- ffi_generic_enumeration(name, FFI::Bitmask, native_type, arguments)
172
+ ffi_define_generic_enumeration(name, FFI::Bitmask, native_type, *arguments)
173
173
  end
174
174
 
175
175
  private
@@ -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 ffi_load_library(name, **options)
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(library_name, search_paths)
48
- if library = ffi_load_library(path, **options)
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
@@ -31,6 +31,6 @@ end
31
31
 
32
32
  module FFI
33
33
  module Module
34
- VERSION = "0.1.0"
34
+ VERSION = "0.1.1"
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-module
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams