Class: FFI::Struct::ManagedStructConverter

Inherits:
FFI::StructByReference show all
Defined in:
lib/ffi/struct.rb

Instance Attribute Summary

Attributes inherited from FFI::StructByReference

#struct_class

Instance Method Summary collapse

Methods inherited from FFI::StructByReference

#native_type, #to_native

Methods included from DataConverter

#native_type, #to_native

Constructor Details

#initialize(struct_class) ⇒ ManagedStructConverter

Returns a new instance of ManagedStructConverter

Parameters:

Raises:

  • (NoMethodError)

150
151
152
153
154
155
# File 'lib/ffi/struct.rb', line 150

def initialize(struct_class)
  super(struct_class)

  raise NoMethodError, "release() not implemented for class #{struct_class}" unless struct_class.respond_to? :release
  @method = struct_class.method(:release)
end

Instance Method Details

#from_native(ptr, ctx) ⇒ Struct

Parameters:

Returns:


160
161
162
# File 'lib/ffi/struct.rb', line 160

def from_native(ptr, ctx)
  struct_class.new(AutoPointer.new(ptr, @method))
end