class GirFFI::Builders::RegisteredTypeBuilder

Base class for type builders building types specified by subtypes of IRegisteredTypeInfo. These are types whose C representation is complex, i.e., a struct or a union.

Public Instance Methods

setup_instance_method(method) click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 23
def setup_instance_method(method)
  method_info = info.find_instance_method method
  return unless method_info

  remove_old_method method_info, build_class
  attach_and_define_method method_info
end
setup_method(method) click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 15
def setup_method(method)
  method_info = info.find_method method
  return unless method_info

  remove_old_method method_info, meta_class
  attach_and_define_method method_info
end
target_gtype() click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 31
def target_gtype
  info.g_type
end

Private Instance Methods

alias_accessors(minfo) click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 97
def alias_accessors(minfo)
  if minfo.name =~ /^get_(.*)/
    klass.send :alias_method, Regexp.last_match(1), minfo.name
  elsif minfo.n_args == 1 && minfo.name =~ /^set_(.*)/
    klass.send :alias_method, "#{Regexp.last_match(1)}=", minfo.name
  end
end
attach_and_define_method(method_info) click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 41
def attach_and_define_method(method_info)
  attach_method method_info
  if method_info.constructor?
    define_construction_methods method_info
  else
    define_method method_info
  end
  method_info.safe_name
end
attach_method(method_info) click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 73
def attach_method(method_info)
  Builder.attach_ffi_function lib, method_info
end
define_construction_methods(method_info) click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 56
def define_construction_methods(method_info)
  initializer_builder = InitializerBuilder.new(method_info)
  initializer_name = initializer_builder.method_name.to_sym
  unless build_class.private_instance_methods(false).include? initializer_name
    build_class.class_eval initializer_builder.method_definition, __FILE__, __LINE__
  end
  constructor_definition = ConstructorBuilder.new(method_info).method_definition
  build_class.class_eval(constructor_definition, __FILE__, __LINE__)
end
define_method(method_info) click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 51
def define_method(method_info)
  method_definition = FunctionBuilder.new(method_info).method_definition
  build_class.class_eval(method_definition, __FILE__, __LINE__)
end
fields() click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 93
def fields
  info.fields
end
meta_class() click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 37
def meta_class
  (class << build_class; self; end)
end
parent_info() click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 89
def parent_info
  nil
end
remove_old_method(method_info, modul) click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 66
def remove_old_method(method_info, modul)
  method = method_info.safe_name
  modul.class_eval do
    remove_method method if method_defined? method
  end
end
setup_constants() click to toggle source
Calls superclass method GirFFI::BaseTypeBuilder#setup_constants
# File lib/gir_ffi/builders/registered_type_builder.rb, line 84
def setup_constants
  klass.const_set :G_TYPE, target_gtype
  super
end
stub_methods() click to toggle source
# File lib/gir_ffi/builders/registered_type_builder.rb, line 77
def stub_methods
  info.get_methods.each do |minfo|
    klass.class_eval MethodStubber.new(minfo).method_stub, __FILE__, __LINE__
    alias_accessors(minfo) if minfo.method?
  end
end