Module: GirFFI::Builder

Extended by:
BuilderHelper
Defined in:
lib/gir_ffi/builder.rb

Overview

Builds modules and classes based on information found in the introspection repository. Call its build_module and build_class methods to create the modules and classes used in your program.

Class Method Summary collapse

Methods included from BuilderHelper

const_defined_for, get_or_define_class, get_or_define_module, optionally_define_constant

Class Method Details

.attach_ffi_function(lib, info) ⇒ Object

TODO: Move elsewhere, perhaps to FunctionBuilder.



29
30
31
32
33
34
# File 'lib/gir_ffi/builder.rb', line 29

def self.attach_ffi_function lib, info
  sym = info.symbol
  return if lib.method_defined? sym

  lib.attach_function sym, info.argument_ffi_types, info.return_ffi_type
end

.build_by_gtype(gtype) ⇒ Object



17
18
19
20
21
22
# File 'lib/gir_ffi/builder.rb', line 17

def self.build_by_gtype gtype
  info = GObjectIntrospection::IRepository.default.find_by_gtype gtype
  info ||= UnintrospectableTypeInfo.new gtype

  build_class info
end

.build_class(info) ⇒ Object



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

def self.build_class info
  Builders::TypeBuilder.build(info)
end

.build_module(namespace, version = nil) ⇒ Object



24
25
26
# File 'lib/gir_ffi/builder.rb', line 24

def self.build_module namespace, version=nil
  Builders::ModuleBuilder.new(namespace, version).generate
end