fiddle 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0f57583928674b1ebb1313d3d079afd7f72b7103f1cdff830ef5aa77f868faa
4
- data.tar.gz: 0c2d7bbb4d6efd3da8f8023cb9b0d8de11b9baa3ab4e4f82d13e126e7eb301fd
3
+ metadata.gz: a45e277aca605b7e6ca64874fcb263a34c4ec365ee3c718c3df7e6d37e0786d7
4
+ data.tar.gz: a441f4a982a218093e53de55f101f1afb0307c8764a028ad60b703d0f81c906e
5
5
  SHA512:
6
- metadata.gz: 6c7a270b8a8d967fcff910335e93051d8aaddaa0617387598ce90031f1c92170f58ba255de84b742a16eb6a2b647df45b07c91ee712c5c34247a6adceaacadc6
7
- data.tar.gz: 121958d7cc7be584a1146c3a1ded233ab52facc1f4a31e4e02e49a91b5293897b3e6ae9f5280264ecc5adfbf72165a84837c05a75a82eae70764f16f48d567ef
6
+ metadata.gz: 4abc678600a35970e801719b4319908312e312db6ff987c020b52047c37ec123e2168346db6ad534462d0591645eaa40ea57851fd0e2e7bab92e297928c0d464
7
+ data.tar.gz: 9a8cbe9817d22c1d740caecf58252781c8268eea84a9957fe1704ac917482981fe4fe862d6d95d4a17ce8ac94a6b9cbc1272609ae77ab6d1f97901dcb2239a09
data/ext/fiddle/pointer.c CHANGED
@@ -827,7 +827,8 @@ rb_fiddle_ptr_read_mem(VALUE klass, VALUE address, VALUE len)
827
827
  static VALUE
828
828
  rb_fiddle_ptr_write_mem(VALUE klass, VALUE addr, VALUE str)
829
829
  {
830
- memcpy(NUM2PTR(addr), StringValuePtr(str), RSTRING_LEN(str));
830
+ const char *ptr = StringValuePtr(str);
831
+ memcpy(NUM2PTR(addr), ptr, RSTRING_LEN(str));
831
832
  return str;
832
833
  }
833
834
 
@@ -159,15 +159,16 @@ module Fiddle
159
159
  args[i] = Fiddle::FFIBackend.to_ffi_type(args[i])
160
160
  end
161
161
  else
162
- args.map! do |arg|
163
- if arg.respond_to?(:to_ptr)
164
- begin
165
- arg = arg.to_ptr
166
- end until arg.is_a?(FFI::Pointer) || !arg.respond_to?(:to_ptr)
167
- arg
168
- else
169
- arg
170
- end
162
+ @args.each_with_index do |arg_type, i|
163
+ next unless arg_type == Types::VOIDP
164
+
165
+ src = args[i]
166
+ next if src.nil?
167
+ next if src.is_a?(String)
168
+ next if src.is_a?(FFI::AbstractMemory)
169
+ next if src.is_a?(FFI::Struct)
170
+
171
+ args[i] = Pointer[src]
171
172
  end
172
173
  end
173
174
  result = @function.call(*args, &block)
@@ -261,6 +262,14 @@ module Fiddle
261
262
  end
262
263
  end
263
264
 
265
+ def self.write(addr, bytes)
266
+ FFI::Pointer.new(addr).write_bytes(bytes)
267
+ end
268
+
269
+ def self.read(addr, len)
270
+ FFI::Pointer.new(addr).read_bytes(len)
271
+ end
272
+
264
273
  class << self
265
274
  alias [] to_ptr
266
275
  end
@@ -308,6 +317,8 @@ module Fiddle
308
317
  end
309
318
  elsif addr.is_a?(IO)
310
319
  raise NotImplementedError, "IO ptr isn't supported"
320
+ else
321
+ FFI::Pointer.new(Integer(addr))
311
322
  end
312
323
 
313
324
  @size = size ? size : ptr.size
@@ -1,3 +1,3 @@
1
1
  module Fiddle
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.6"
3
3
  end
data/lib/fiddle.rb CHANGED
@@ -111,7 +111,11 @@ module Fiddle
111
111
  case line
112
112
  when /\A\s*(?:INPUT|GROUP)\s*\(\s*([^\s,\)]+)/
113
113
  # TODO: Should we support multiple files?
114
- return dlopen($1)
114
+ first_input = $1
115
+ if first_input.start_with?("-l")
116
+ first_input = "lib#{first_input[2..-1]}.so"
117
+ end
118
+ return dlopen(first_input)
115
119
  end
116
120
  end
117
121
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiddle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
- original_platform: ''
7
6
  authors:
8
7
  - Aaron Patterson
9
8
  - SHIBATA Hiroshi
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-11-09 00:00:00.000000000 Z
12
+ date: 2024-12-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A libffi wrapper for Ruby.
15
15
  email:
@@ -56,6 +56,7 @@ licenses:
56
56
  metadata:
57
57
  msys2_mingw_dependencies: libffi
58
58
  changelog_uri: https://github.com/ruby/fiddle/releases
59
+ post_install_message:
59
60
  rdoc_options: []
60
61
  require_paths:
61
62
  - lib
@@ -70,7 +71,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
71
  - !ruby/object:Gem::Version
71
72
  version: '0'
72
73
  requirements: []
73
- rubygems_version: 3.6.0.dev
74
+ rubygems_version: 3.5.22
75
+ signing_key:
74
76
  specification_version: 4
75
77
  summary: A libffi wrapper for Ruby.
76
78
  test_files: []