module GirFFI::Builders::WithMethods

Implements method creation for types such as, :union, :struct, :object, :interface.

Public Instance Methods

setup_instance_method(method) click to toggle source
# File lib/gir_ffi/builders/with_methods.rb, line 13
def setup_instance_method method
  go = info.find_instance_method method
  attach_and_define_method method, go, build_class
end
setup_method(method) click to toggle source
# File lib/gir_ffi/builders/with_methods.rb, line 8
def setup_method method
  go = info.find_method method
  attach_and_define_method method, go, meta_class
end

Private Instance Methods

attach_and_define_method(method, go, modul) click to toggle source
# File lib/gir_ffi/builders/with_methods.rb, line 29
def attach_and_define_method method, go, modul
  return false if go.nil?
  Builder.attach_ffi_function lib, go
  modul.class_eval { remove_method method }
  build_class.class_eval function_definition(go)
  true
end
function_definition(go) click to toggle source
# File lib/gir_ffi/builders/with_methods.rb, line 25
def function_definition go
  FunctionBuilder.new(go).generate
end
meta_class() click to toggle source
# File lib/gir_ffi/builders/with_methods.rb, line 20
def meta_class
  klass = build_class
  return (class << klass; self; end)
end
stub_methods() click to toggle source
# File lib/gir_ffi/builders/with_methods.rb, line 37
def stub_methods
  info.get_methods.each do |minfo|
    @klass.class_eval MethodStubber.new(minfo).method_stub
  end
end