malloc

malloc(types, func=nil) Class Public methods Allocates a C union the types provided. When the instance is garbage collected, the C function func is called.

entity_class

entity_class() Class Public methods accessor to Fiddle::CUnionEntity

set_ctypes

set_ctypes(types) Instance Public methods Calculates the offsets and sizes for the given types in the struct.

assign_names

assign_names(members) Instance Public methods Set the names of the members in this C struct

[]=

[]=(name, val) Instance Public methods Set struct member name, to value val

[]

[](name) Instance Public methods Fetch struct member name

size

size(types) Class Public methods 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

new

new(addr, types, func = nil) Class Public methods 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

malloc

malloc(types, func = nil) Class Public methods Allocates a C struct with the types provided. When the instance is garbage collected, the C function func is called.

create

create(klass, types, members) Class Public methods Construct a new class given a C: class klass (CUnion, CStruct, or other that provide an entity_class) types (Fiddle::TYPE_INT, Fiddle::TYPE_SIZE_T, etc., see the C types constants) corresponding members Fiddle::Importer#struct and Fiddle::Importer#union wrap this functionality in an easy-to-use manner. Example: require 'fiddle/struct' require 'fiddle/cparser' include Fiddle::CParser types, members = parse_struct_signature