Class: GObjectIntrospection::IRepository
- Inherits:
-
Object
- Object
- GObjectIntrospection::IRepository
- 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.
Constant Summary collapse
- TYPEMAP =
Map info type to class. Default is IBaseInfo.
{ invalid: IBaseInfo, function: IFunctionInfo, callback: ICallbackInfo, struct: IStructInfo, # TODO: There's no GIBoxedInfo, so what does :boxed mean? boxed: IBaseInfo, enum: IEnumInfo, flags: IFlagsInfo, object: IObjectInfo, interface: IInterfaceInfo, constant: IConstantInfo, invalid_was_error_domain: IBaseInfo, union: IUnionInfo, value: IValueInfo, signal: ISignalInfo, vfunc: IVFuncInfo, property: IPropertyInfo, field: IFieldInfo, arg: IArgInfo, type: ITypeInfo, unresolved: IBaseInfo }
Class Method Summary collapse
- .default ⇒ Object
- .prepend_search_path(path) ⇒ Object
- .type_tag_to_string(type) ⇒ Object
- .wrap_ibaseinfo_pointer(ptr) ⇒ Object
Instance Method Summary collapse
- #dependencies(namespace) ⇒ Object
- #find_by_gtype(gtype) ⇒ Object
- #find_by_name(namespace, name) ⇒ Object
- #info(namespace, index) ⇒ Object
-
#infos(namespace) ⇒ Object
Utility method.
-
#initialize ⇒ IRepository
constructor
A new instance of IRepository.
- #n_infos(namespace) ⇒ Object
- #require(namespace, version = nil, flags = 0) ⇒ Object
- #shared_library(namespace) ⇒ Object
Constructor Details
#initialize ⇒ IRepository
Returns a new instance of IRepository.
57 58 59 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 57 def initialize @gobj = Lib.g_irepository_get_default end |
Class Method Details
.default ⇒ Object
63 64 65 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 63 def self.default instance end |
.prepend_search_path(path) ⇒ Object
67 68 69 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 67 def self.prepend_search_path path Lib.g_irepository_prepend_search_path path end |
.type_tag_to_string(type) ⇒ Object
71 72 73 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 71 def self.type_tag_to_string type Lib.g_type_tag_to_string type end |
.wrap_ibaseinfo_pointer(ptr) ⇒ Object
118 119 120 121 122 123 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 118 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
108 109 110 111 112 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 108 def dependencies namespace strv_p = Lib.g_irepository_get_dependencies(@gobj, namespace) strv = GLib::Strv.new strv_p strv.to_a end |
#find_by_gtype(gtype) ⇒ Object
103 104 105 106 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 103 def find_by_gtype gtype raise ArgumentError, "Type #{gtype} is not a valid type" if gtype == 0 wrap_info Lib.g_irepository_find_by_gtype(@gobj, gtype) end |
#find_by_name(namespace, name) ⇒ Object
99 100 101 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 99 def find_by_name namespace, name wrap_info Lib.g_irepository_find_by_name(@gobj, namespace, name) end |
#info(namespace, index) ⇒ Object
88 89 90 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 88 def info namespace, index wrap_info Lib.g_irepository_get_info(@gobj, namespace, index) end |
#infos(namespace) ⇒ Object
Utility method
93 94 95 96 97 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 93 def infos namespace (0..(n_infos(namespace) - 1)).map do |idx| info namespace, idx end end |
#n_infos(namespace) ⇒ Object
84 85 86 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 84 def n_infos namespace Lib.g_irepository_get_n_infos @gobj, namespace end |
#require(namespace, version = nil, flags = 0) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 75 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). unless errp.null? end |
#shared_library(namespace) ⇒ Object
114 115 116 |
# File 'lib/ffi-gobject_introspection/i_repository.rb', line 114 def shared_library namespace Lib.g_irepository_get_shared_library @gobj, namespace end |