Module: FFI::RubyObject

Extended by:
DataConverter
Defined in:
lib/ffi/ruby_object.rb

Overview

FFI::DataConverter to pass ruby objects as void*

Objects are held in a global map of object id to WeakRef of the object.

ie caller that puts a RubyObject into a library is responsible for keeping that object from the GC.

Note this relies on the GVL to be threadsafe(ish)

Class Method Summary collapse

Class Method Details

.by_object_id(int_type = :long) ⇒ Object

Store a ruby object reference in an integer type

Parameters:

  • int_type (FFI::Type) (defaults to: :long)


47
48
49
# File 'lib/ffi/ruby_object.rb', line 47

def by_object_id(int_type = :long)
  CastAsInt.new(int_type)
end