Class: GObjectIntrospection::IRepository

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/ffi-gobject_introspection/i_repository.rb

Overview

The Gobject Introspection Repository. This class is the point of access to the introspection typelibs. This class wraps the GIRepository struct.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIRepository

Returns a new instance of IRepository.



13
14
15
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 13

def initialize
  @gobj = Lib.g_irepository_get_default
end

Class Method Details

.defaultObject



19
20
21
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 19

def self.default
  instance
end

.prepend_search_path(path) ⇒ Object



23
24
25
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 23

def self.prepend_search_path(path)
  Lib.g_irepository_prepend_search_path path
end

.type_tag_to_string(type) ⇒ Object



27
28
29
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 27

def self.type_tag_to_string(type)
  Lib.g_type_tag_to_string type
end

.wrap_ibaseinfo_pointer(ptr) ⇒ Object



78
79
80
81
82
83
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 78

def self.wrap_ibaseinfo_pointer(ptr)
  return nil if ptr.null?
  type = Lib.g_base_info_get_type ptr
  klass = TYPEMAP[type]
  klass.wrap ptr
end

Instance Method Details

#dependencies(namespace) ⇒ Object



64
65
66
67
68
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 64

def dependencies(namespace)
  strv_p = Lib.g_irepository_get_dependencies(@gobj, namespace)
  strv = Strv.new strv_p
  strv.to_a
end

#find_by_gtype(gtype) ⇒ Object

Raises:

  • (ArgumentError)


59
60
61
62
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 59

def find_by_gtype(gtype)
  raise ArgumentError, "Type #{gtype} is not a valid type" if gtype.zero?
  wrap_info Lib.g_irepository_find_by_gtype(@gobj, gtype)
end

#find_by_name(namespace, name) ⇒ Object



55
56
57
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 55

def find_by_name(namespace, name)
  wrap_info Lib.g_irepository_find_by_name(@gobj, namespace, name)
end

#info(namespace, index) ⇒ Object



44
45
46
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 44

def info(namespace, index)
  wrap_info Lib.g_irepository_get_info(@gobj, namespace, index)
end

#infos(namespace) ⇒ Object

Utility method



49
50
51
52
53
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 49

def infos(namespace)
  (0..(n_infos(namespace) - 1)).map do |idx|
    info namespace, idx
  end
end

#n_infos(namespace) ⇒ Object



40
41
42
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 40

def n_infos(namespace)
  Lib.g_irepository_get_n_infos @gobj, namespace
end

#require(namespace, version = nil, flags = 0) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 31

def require(namespace, version = nil, flags = 0)
  errpp = FFI::MemoryPointer.new(:pointer).write_pointer nil

  Lib.g_irepository_require @gobj, namespace, version, flags, errpp

  errp = errpp.read_pointer
  raise GError.new(errp).message unless errp.null?
end

#shared_library(namespace) ⇒ Object



70
71
72
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 70

def shared_library(namespace)
  Lib.g_irepository_get_shared_library @gobj, namespace
end

#version(namespace) ⇒ Object



74
75
76
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 74

def version(namespace)
  Lib.g_irepository_get_version @gobj, namespace
end