Class: GirFFI::Builders::StructBuilder

Inherits:
RegisteredTypeBuilder show all
Includes:
StructLike
Defined in:
lib/gir_ffi/builders/struct_builder.rb

Overview

Implements the creation of a class representing a Struct.

Instance Attribute Summary

Attributes inherited from GirFFI::BaseTypeBuilder

#info

Instance Method Summary collapse

Methods included from StructLike

#setup_class, #setup_field_accessors

Methods included from WithLayout

#layout_specification

Methods inherited from RegisteredTypeBuilder

#setup_instance_method, #setup_method, #target_gtype

Methods inherited from GirFFI::BaseTypeBuilder

#build_class, #initialize, #instantiate_class

Methods included from GirFFI::BuilderHelper

#get_or_define_class, #get_or_define_module, #optionally_define_constant

Constructor Details

This class inherits a constructor from GirFFI::BaseTypeBuilder

Instance Method Details

#layout_superclassObject



13
14
15
# File 'lib/gir_ffi/builders/struct_builder.rb', line 13

def layout_superclass
  GirFFI::Struct
end

#superclassObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gir_ffi/builders/struct_builder.rb', line 17

def superclass
  if info.gtype_struct?
    # HACK: Inheritance chain is not expressed in GObject's code correctly.
    type_name = info.full_type_name
    return GObject::ObjectClass if type_name == 'GObject::InitiallyUnownedClass'
    type = fields.first.field_type
    return type.tag_or_class if type.tag == :interface
  end

  return BoxedBase if GObject.type_fundamental(info.gtype) == GObject::TYPE_BOXED

  StructBase
end