Module: FFI::Function::RegisterAttach
- Included in:
- FFI::Function
- Defined in:
- lib/ffi/function.rb
Overview
Stash the Function in a module variable so it can be inspected by attached_functions. On CRuby it also ensures that it does not get garbage collected.
Instance Method Summary collapse
Instance Method Details
#attach(mod, name) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ffi/function.rb', line 57 def attach(mod, name) funcs = mod.instance_variable_defined?("@ffi_functions") && mod.instance_variable_get("@ffi_functions") unless funcs funcs = {} mod.instance_variable_set("@ffi_functions", funcs) end funcs[name.to_sym] = self # Jump to the native attach method of CRuby, JRuby or Tuffleruby super end |