Class: GObjectIntrospection::Loader::VirtualFunctionImplementor

Inherits:
Object
  • Object
show all
Defined in:
lib/gobject-introspection/loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(loader_class, gtype_prefix, infos) ⇒ VirtualFunctionImplementor

Returns a new instance of VirtualFunctionImplementor.



729
730
731
732
733
734
735
736
737
738
739
# File 'lib/gobject-introspection/loader.rb', line 729

def initialize(loader_class, gtype_prefix, infos)
  @loader_class = loader_class
  @gtype_prefix = gtype_prefix
  @infos = {}
  prefix = GLib::VIRTUAL_FUNCTION_IMPLEMENTATION_PREFIX
  infos.each do |info|
    name = info.name
    @infos[:"#{prefix}#{name}"] = info
    @infos[:"#{prefix}#{gtype_prefix}_#{name}"] = info
  end
end

Instance Method Details

#implement(implementor_gtype, name) ⇒ Object



741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
# File 'lib/gobject-introspection/loader.rb', line 741

def implement(implementor_gtype, name)
  info = @infos[name]
  return false if info.nil?
  container = info.container
  vtable_gtype = container.gtype
  if container.respond_to?(:class_struct)
    struct = container.class_struct
  else
    return false unless implementor_gtype.type_is_a?(vtable_gtype)
    struct = container.iface_struct
  end
  field = struct.find_field(info.name)
  @loader_class.implement_virtual_function(field,
                                           implementor_gtype,
                                           vtable_gtype,
                                           name.to_s)
  true
end