Class: FFI::Struct::ManagedStructConverter

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

Instance Method Summary (collapse)

Methods inherited from FFI::StructByReference

#native_type, #struct_class, #to_native

Constructor Details

- (ManagedStructConverter) initialize(struct_class)

Returns a new instance of ManagedStructConverter

Raises:

  • (NoMethodError)


210
211
212
213
214
215
# File 'lib/ffi/struct.rb', line 210

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

- (Struct) from_native(ptr, ctx)



220
221
222
# File 'lib/ffi/struct.rb', line 220

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