Class: GirFFI::Builders::UserDefinedBuilder

Inherits:
ObjectBuilder show all
Defined in:
lib/gir_ffi/builders/user_defined_builder.rb

Overview

Implements the creation of GObject subclasses from Ruby.

Instance Attribute Summary

Attributes inherited from GirFFI::BaseTypeBuilder

#info

Instance Method Summary collapse

Methods inherited from ObjectBuilder

#find_property, #find_signal, #object_class_struct

Methods inherited from RegisteredTypeBuilder

#setup_instance_method, #setup_method

Methods inherited from GirFFI::BaseTypeBuilder

#build_class

Methods included from GirFFI::BuilderHelper

#get_or_define_class, #get_or_define_module, #optionally_define_constant

Constructor Details

#initialize(info) ⇒ UserDefinedBuilder



8
9
10
# File 'lib/gir_ffi/builders/user_defined_builder.rb', line 8

def initialize info
  @info = info
end

Instance Method Details

#instantiate_classObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gir_ffi/builders/user_defined_builder.rb', line 12

def instantiate_class
  if already_set_up
    @gtype = klass.get_gtype
  else
    @gtype = GObject.type_register_static(parent_gtype.to_i,
                                          info.g_name,
                                          gobject_type_info, 0)
    included_interfaces.each do |interface|
      ifinfo = gobject_interface_info interface
      GObject.type_add_interface_static @gtype, interface.get_gtype, ifinfo
    end
    setup_class
    TypeBuilder::CACHE[@gtype] = klass
  end
end

#setup_classObject



28
29
30
31
32
33
# File 'lib/gir_ffi/builders/user_defined_builder.rb', line 28

def setup_class
  setup_layout
  setup_constants
  setup_property_accessors
  setup_constructor
end

#target_gtypeObject



35
36
37
# File 'lib/gir_ffi/builders/user_defined_builder.rb', line 35

def target_gtype
  @gtype
end