A pointer to a C structure

Class Methods
No documentation available

Allocates a C struct with the types provided.

See Fiddle::Pointer.malloc for memory management issues.

Wraps the C pointer addr as a C struct with the given types.

When the instance is garbage collected, the C function func is called.

See also Fiddle::Pointer.new

Returns the offset for the packed sizes for the given types.

Fiddle::CStructEntity.size(
  [ Fiddle::TYPE_DOUBLE,
    Fiddle::TYPE_INT,
    Fiddle::TYPE_CHAR,
    Fiddle::TYPE_VOIDP ]) #=> 24
Instance Methods

Fetch struct member name if only one argument is specified. If two arguments are specified, the first is an offset and the second is a length and this method returns the string of length bytes beginning at offset.

Examples:

my_struct = struct(['int id']).malloc
my_struct.id = 1
my_struct['id'] # => 1
my_struct[0, 4] # => "\x01\x00\x00\x00".b

Set struct member name, to value val. If more arguments are specified, writes the string of bytes to the memory at the given offset and length.

Examples:

my_struct = struct(['int id']).malloc
my_struct['id'] = 1
my_struct[0, 4] = "\x01\x00\x00\x00".b
my_struct.id # => 1

Set the names of the members in this C struct

Calculates the offsets and sizes for the given types in the struct.