fiddle 1.1.4 → 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: 8958948f3661cb522847c81b79d663a5748cd54df277ede3ec29d74b0fe6f223
4
- data.tar.gz: 273a20dc863a31915bc6d6b7653bdf5ce9e55061aea00a08b17996f26dd19ebd
3
+ metadata.gz: a45e277aca605b7e6ca64874fcb263a34c4ec365ee3c718c3df7e6d37e0786d7
4
+ data.tar.gz: a441f4a982a218093e53de55f101f1afb0307c8764a028ad60b703d0f81c906e
5
5
  SHA512:
6
- metadata.gz: a888a14cd08bd3f3fa860953752d35e4ddab070b5337db8f0468f3038b520c3bce7a0f82e84c35e62d49d123a4e1650e8d5c66da48fa76933404fa5d6bf91240
7
- data.tar.gz: d5206fda047f3fb5136f52025d683703b9c84de053d5f843347aad5144deaa8d81e2c02457ce7d325b1078ff2563470fd90576d4c876189c0830f24da9655dda
6
+ metadata.gz: 4abc678600a35970e801719b4319908312e312db6ff987c020b52047c37ec123e2168346db6ad534462d0591645eaa40ea57851fd0e2e7bab92e297928c0d464
7
+ data.tar.gz: 9a8cbe9817d22c1d740caecf58252781c8268eea84a9957fe1704ac917482981fe4fe862d6d95d4a17ce8ac94a6b9cbc1272609ae77ab6d1f97901dcb2239a09
@@ -154,7 +154,9 @@ initialize(int argc, VALUE argv[], VALUE self)
154
154
  if (args[kw_name] != Qundef) {
155
155
  name = args[kw_name];
156
156
  #ifdef HAVE_RB_STR_TO_INTERNED_STR
157
- name = rb_str_to_interned_str(name);
157
+ if (RB_TYPE_P(name, RUBY_T_STRING)) {
158
+ name = rb_str_to_interned_str(name);
159
+ }
158
160
  #endif
159
161
  }
160
162
  if (args[kw_need_gvl] != Qundef) {
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.4"
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,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiddle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  - SHIBATA Hiroshi
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2024-10-22 00:00:00.000000000 Z
12
+ date: 2024-12-12 00:00:00.000000000 Z
12
13
  dependencies: []
13
14
  description: A libffi wrapper for Ruby.
14
15
  email:
@@ -55,6 +56,7 @@ licenses:
55
56
  metadata:
56
57
  msys2_mingw_dependencies: libffi
57
58
  changelog_uri: https://github.com/ruby/fiddle/releases
59
+ post_install_message:
58
60
  rdoc_options: []
59
61
  require_paths:
60
62
  - lib
@@ -69,7 +71,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
71
  - !ruby/object:Gem::Version
70
72
  version: '0'
71
73
  requirements: []
72
- rubygems_version: 3.6.0.dev
74
+ rubygems_version: 3.5.22
75
+ signing_key:
73
76
  specification_version: 4
74
77
  summary: A libffi wrapper for Ruby.
75
78
  test_files: []