summaryrefslogtreecommitdiff
path: root/lib/ffi/variadic.rb
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2023-04-26 14:00:17 +0200
committerLars Kanis <lars@greiz-reinsdorf.de>2023-04-27 13:47:57 +0200
commit4fc6a8c5ec8a9a720330946af9d1103015c62942 (patch)
treee8aa241415e858a4e422e9a0a86abc1711403f22 /lib/ffi/variadic.rb
parente987ab50366a4b08617a20568eabdaa1fb761317 (diff)
downloadffi-4fc6a8c5ec8a9a720330946af9d1103015c62942.tar.gz
Store each FFI::Function in it's own instance variabe in the module to be attached
This allows to freeze the FFI::Function immediately, so that it is shareable by Ractor without the need to freeze the module explicit. To make it shareable the typedef hash used for variadic functions is duplicated and made frozen. This creates a small compatibility issue: Only typedefs defined above the variadic function can be used by that function. If a typedef is created after the definition of the variadic function, then this typedef can no longer be used as parameter to that variadic function. Also fix the retrieval of simple (non-struct) global variables per #attached_variables. Closes #975
Diffstat (limited to 'lib/ffi/variadic.rb')
-rw-r--r--lib/ffi/variadic.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/ffi/variadic.rb b/lib/ffi/variadic.rb
index 42c5549..800d121 100644
--- a/lib/ffi/variadic.rb
+++ b/lib/ffi/variadic.rb
@@ -55,11 +55,10 @@ module FFI
params = "*args"
call = "call"
mod.module_eval <<-code
- @ffi_functions = {} unless defined?(@ffi_functions)
- @ffi_functions[#{mname.inspect}] = invoker
+ @ffi_function_#{mname} = invoker
def self.#{mname}(#{params})
- @ffi_functions[#{mname.inspect}].#{call}(#{params})
+ @ffi_function_#{mname}.#{call}(#{params})
end
define_method(#{mname.inspect}, &method(:#{mname}))