module FFI::Function::RegisterAttach

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.

Public Instance Methods

attach(mod, name) click to toggle source
Calls superclass method
# 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