method

create

ruby latest stable - Class: DL::CStructBuilder

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2_1_10) is shown here.

create(klass, types, members)
public

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'])

MyStruct = DL::CStructBuilder.create(CUnion, types, members)

obj = MyStruct.allocate