Class NiceFFI::OpaqueStruct
In: lib/nice-ffi/opaquestruct.rb
Parent: Object

OpaqueStruct represents a Struct with an unknown layout. This is meant to be used when the C library designer has intentionally hidden the layout (e.g. to prevent user access).

Because the size of an OpaqueStruct is unknown, you should only use methods provided by the C library to allocate, modify, or free the struct‘s memory.

OpaqueStruct supports the same memory autorelease system as NiceStruct. Define MyClass.release( pointer ) to call the library function to free the struct, and pass an FFI::Pointer to new. You can disable autorelease for an individual instance by providing {:autorelease => false} as an option to new

Methods

inspect   new   to_ptr   to_s   typed_pointer  

Included Modules

NiceFFI::AutoRelease

Attributes

pointer  [R] 

Public Class methods

Create a new instance of the class, wrapping (not copying!) a FFI::Pointer. You can pass another instance of this class to create a new instance wrapping the same pointer.

If val is an instance of FFI::Pointer and you have defined MyClass.release, the pointer will be passed to MyClass.release when the memory is no longer being used. Use MyClass.release to free the memory for the struct, as appropriate for your class. To disable autorelease for this instance, set {:autorelease => false} in options.

(Note: FFI::MemoryPointer and FFI::Buffer have built-in memory management, so MyClass.release is never called for them.)

Returns a NiceFFI::TypedPointer instance for this class.

Public Instance methods

inspect()

Alias for to_s

[Validate]