size

size(types) Class Public methods Given types, returns the offset for the packed sizes of those types DL::CStructEntity.size([DL::TYPE_DOUBLE, DL::TYPE_INT, DL::TYPE_CHAR, DL::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. The C function func is called when the instance is garbage collected. See also DL::CPtr.new

malloc

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

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 (DL:TYPE_INT, DL::TYPE_SIZE_T, etc., see the C types constants) corresponding members DL::Importer#struct and DL::Importer#union wrap this functionality in an easy-to-use manner. Example: require 'dl/struct' require 'dl/cparser' include DL::CParser types, members = parse_struct_signature(['int i','char c']) MyStruc

entity_class

entity_class() Class Public methods accessor to DL::CStructEntity

parse_struct_signature

parse_struct_signature(signature, tymap=nil) Instance Public methods Parses a C struct's members Example: parse_struct_signature(['int i', 'char c']) => [[DL::TYPE_INT, DL::TYPE_CHAR], ["i", "c"]]

parse_signature

parse_signature(signature, tymap=nil) Instance Public methods Parses a C prototype signature Example: include DL::CParser => Object parse_signature('double sum(double, double)') => ["sum", DL::TYPE_DOUBLE, [DL::TYPE_DOUBLE, DL::TYPE_DOUBLE]]

parse_ctype

parse_ctype(ty, tymap=nil) Instance Public methods Given a String of C type ty, return the corresponding DL constant. ty can also accept an Array of C type Strings, and will returned in a corresponding Array. If Hash tymap is provided, ty is expected to be the key, and the value will be the C type to be looked up. Example: parse_ctype('int') => DL::TYPE_INT parse_ctype('double') => DL::TYPE_DOUBLE parse_ctype('unsigned char') => -DL::TYPE_CHAR

sym

sym(symbol) Instance Public methods

handlers

handlers() Instance Public methods