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 +4 -4
- data/ext/fiddle/function.c +3 -1
- data/ext/fiddle/pointer.c +2 -1
- data/lib/fiddle/ffi_backend.rb +20 -9
- data/lib/fiddle/version.rb +1 -1
- data/lib/fiddle.rb +5 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a45e277aca605b7e6ca64874fcb263a34c4ec365ee3c718c3df7e6d37e0786d7
|
4
|
+
data.tar.gz: a441f4a982a218093e53de55f101f1afb0307c8764a028ad60b703d0f81c906e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4abc678600a35970e801719b4319908312e312db6ff987c020b52047c37ec123e2168346db6ad534462d0591645eaa40ea57851fd0e2e7bab92e297928c0d464
|
7
|
+
data.tar.gz: 9a8cbe9817d22c1d740caecf58252781c8268eea84a9957fe1704ac917482981fe4fe862d6d95d4a17ce8ac94a6b9cbc1272609ae77ab6d1f97901dcb2239a09
|
data/ext/fiddle/function.c
CHANGED
@@ -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
|
-
|
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
|
-
|
830
|
+
const char *ptr = StringValuePtr(str);
|
831
|
+
memcpy(NUM2PTR(addr), ptr, RSTRING_LEN(str));
|
831
832
|
return str;
|
832
833
|
}
|
833
834
|
|
data/lib/fiddle/ffi_backend.rb
CHANGED
@@ -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.
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
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
|
data/lib/fiddle/version.rb
CHANGED
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
|
-
|
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
|
+
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-
|
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.
|
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: []
|