class FFI::StructByReference
This class includes the {FFI::DataConverter} module.
def from_native(value, ctx)
-
(Struct)-
Parameters:
-
ctx(nil) -- -
value(AbstractMemory) --
def from_native(value, ctx) @struct_class.new(value) end
def initialize(struct_class)
-
struct_class(Struct) --
def initialize(struct_class) unless Class === struct_class and struct_class < FFI::Struct raise TypeError, 'wrong type (expected subclass of FFI::Struct)' end @struct_class = struct_class end
def native_type
def native_type FFI::Type::POINTER end
def to_native(value, ctx)
-
(AbstractMemory)- Pointer on +value+.
Parameters:
-
ctx(nil) -- -
value(nil, Struct) --
def to_native(value, ctx) return Pointer::NULL if value.nil? unless @struct_class === value raise TypeError, "wrong argument type #{value.class} (expected #{@struct_class})" end value.pointer end