glib2 4.3.7 → 4.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/glib2/extconf.rb +23 -7
- data/ext/glib2/glib2.def +1 -0
- data/ext/glib2/rbgi-arg-info.c +226 -0
- data/ext/glib2/rbgi-base-info.c +223 -0
- data/ext/glib2/rbgi-callable-info.c +145 -0
- data/ext/glib2/rbgi-conversions.h +36 -0
- data/ext/glib2/rbgi-interface-info.c +167 -0
- data/ext/glib2/rbgi-private.h +42 -0
- data/ext/glib2/rbgi-repository.c +276 -0
- data/ext/glib2/rbgi-type-info.c +113 -0
- data/ext/glib2/rbglib.c +43 -1
- data/ext/glib2/rbglib.h +1 -1
- data/ext/glib2/rbglib_maincontext.c +1 -20
- data/ext/glib2/rbgobject.c +5 -1
- data/ext/glib2/rbgobject.h +2 -1
- data/ext/glib2/rbgutil.h +1 -0
- data/ext/glib2/rbgutil_callback.c +79 -30
- data/lib/glib-mkenums.rb +10 -4
- data/lib/glib2/callable-info.rb +140 -0
- data/lib/glib2/collection-reader.rb +41 -0
- data/lib/glib2/interface-info.rb +32 -0
- data/lib/glib2/repository.rb +47 -0
- data/lib/glib2/type-info.rb +33 -0
- data/lib/glib2.rb +8 -1
- data/test/glib-test-utils.rb +8 -1
- data/test/test-arg-info.rb +79 -0
- data/test/test-base-info.rb +42 -0
- data/test/test-bytes.rb +7 -4
- data/test/test-callable-info.rb +60 -0
- data/test/test-interface-info.rb +124 -0
- data/test/test-repository.rb +71 -0
- data/test/test-type-info.rb +65 -0
- metadata +21 -2
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2012-2026 Ruby-GNOME Project Team
|
|
4
|
+
*
|
|
5
|
+
* This library is free software; you can redistribute it and/or
|
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
7
|
+
* License as published by the Free Software Foundation; either
|
|
8
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
* Lesser General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
16
|
+
* License along with this library; if not, write to the Free Software
|
|
17
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
18
|
+
* MA 02110-1301 USA
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
#ifdef HAVE_GIREPOSITORY
|
|
22
|
+
#include "rbgi-private.h"
|
|
23
|
+
|
|
24
|
+
#define RG_TARGET_NAMESPACE rb_cGIInterfaceInfo
|
|
25
|
+
#define SELF(self) (RVAL2GI_INTERFACE_INFO(self))
|
|
26
|
+
|
|
27
|
+
static VALUE
|
|
28
|
+
rg_n_prerequisites(VALUE self)
|
|
29
|
+
{
|
|
30
|
+
GIInterfaceInfo *info = SELF(self);
|
|
31
|
+
return UINT2NUM(gi_interface_info_get_n_prerequisites(info));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static VALUE
|
|
35
|
+
rg_get_prerequisite(VALUE self, VALUE rb_n)
|
|
36
|
+
{
|
|
37
|
+
GIInterfaceInfo *info = SELF(self);
|
|
38
|
+
unsigned int n = NUM2UINT(rb_n);
|
|
39
|
+
return GOBJ2RVAL_UNREF(gi_interface_info_get_prerequisite(info, n));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static VALUE
|
|
43
|
+
rg_n_properties(VALUE self)
|
|
44
|
+
{
|
|
45
|
+
GIInterfaceInfo *info = SELF(self);
|
|
46
|
+
return UINT2NUM(gi_interface_info_get_n_properties(info));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE
|
|
50
|
+
rg_get_property(VALUE self, VALUE rb_n)
|
|
51
|
+
{
|
|
52
|
+
GIInterfaceInfo *info = SELF(self);
|
|
53
|
+
unsigned int n = NUM2UINT(rb_n);
|
|
54
|
+
return GOBJ2RVAL_UNREF(gi_interface_info_get_property(info, n));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static VALUE
|
|
58
|
+
rg_n_methods(VALUE self)
|
|
59
|
+
{
|
|
60
|
+
GIInterfaceInfo *info = SELF(self);
|
|
61
|
+
return UINT2NUM(gi_interface_info_get_n_methods(info));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static VALUE
|
|
65
|
+
rg_get_method(VALUE self, VALUE rb_n_or_name)
|
|
66
|
+
{
|
|
67
|
+
GIInterfaceInfo *info = SELF(self);
|
|
68
|
+
GIFunctionInfo *function_info;
|
|
69
|
+
if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) {
|
|
70
|
+
unsigned int n = NUM2UINT(rb_n_or_name);
|
|
71
|
+
function_info = gi_interface_info_get_method(info, n);
|
|
72
|
+
} else {
|
|
73
|
+
const char *name = RVAL2CSTR(rb_n_or_name);
|
|
74
|
+
function_info = gi_interface_info_find_method(info, name);
|
|
75
|
+
}
|
|
76
|
+
return GOBJ2RVAL_UNREF(function_info);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static VALUE
|
|
80
|
+
rg_n_signals(VALUE self)
|
|
81
|
+
{
|
|
82
|
+
GIInterfaceInfo *info = SELF(self);
|
|
83
|
+
return UINT2NUM(gi_interface_info_get_n_signals(info));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static VALUE
|
|
87
|
+
rg_get_signal(VALUE self, VALUE rb_n_or_name)
|
|
88
|
+
{
|
|
89
|
+
GIInterfaceInfo *info = SELF(self);
|
|
90
|
+
GISignalInfo *signal_info;
|
|
91
|
+
if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) {
|
|
92
|
+
unsigned int n = NUM2UINT(rb_n_or_name);
|
|
93
|
+
signal_info = gi_interface_info_get_signal(info, n);
|
|
94
|
+
} else {
|
|
95
|
+
const char *name = RVAL2CSTR(rb_n_or_name);
|
|
96
|
+
signal_info = gi_interface_info_find_signal(info, name);
|
|
97
|
+
}
|
|
98
|
+
return GOBJ2RVAL_UNREF(signal_info);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static VALUE
|
|
102
|
+
rg_n_vfuncs(VALUE self)
|
|
103
|
+
{
|
|
104
|
+
GIInterfaceInfo *info = SELF(self);
|
|
105
|
+
return UINT2NUM(gi_interface_info_get_n_vfuncs(info));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static VALUE
|
|
109
|
+
rg_get_vfunc(VALUE self, VALUE rb_n_or_name)
|
|
110
|
+
{
|
|
111
|
+
GIInterfaceInfo *info = SELF(self);
|
|
112
|
+
GIVFuncInfo *vfunc_info;
|
|
113
|
+
if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) {
|
|
114
|
+
unsigned int n = NUM2UINT(rb_n_or_name);
|
|
115
|
+
vfunc_info = gi_interface_info_get_vfunc(info, n);
|
|
116
|
+
} else {
|
|
117
|
+
const gchar *name = RVAL2CSTR(rb_n_or_name);
|
|
118
|
+
vfunc_info = gi_interface_info_find_vfunc(info, name);
|
|
119
|
+
}
|
|
120
|
+
return GOBJ2RVAL_UNREF(vfunc_info);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static VALUE
|
|
124
|
+
rg_n_constants(VALUE self)
|
|
125
|
+
{
|
|
126
|
+
GIInterfaceInfo *info = SELF(self);
|
|
127
|
+
return UINT2NUM(gi_interface_info_get_n_constants(info));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static VALUE
|
|
131
|
+
rg_get_constant(VALUE self, VALUE rb_n)
|
|
132
|
+
{
|
|
133
|
+
GIInterfaceInfo *info = SELF(self);
|
|
134
|
+
unsigned int n = NUM2UINT(rb_n);
|
|
135
|
+
return GOBJ2RVAL_UNREF(gi_interface_info_get_constant(info, n));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
static VALUE
|
|
139
|
+
rg_iface_struct(VALUE self)
|
|
140
|
+
{
|
|
141
|
+
GIInterfaceInfo *info = SELF(self);
|
|
142
|
+
return GOBJ2RVAL_UNREF(gi_interface_info_get_iface_struct(info));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
void
|
|
146
|
+
rbgi_interface_info_init(VALUE rb_mGLib)
|
|
147
|
+
{
|
|
148
|
+
VALUE RG_TARGET_NAMESPACE;
|
|
149
|
+
|
|
150
|
+
RG_TARGET_NAMESPACE =
|
|
151
|
+
G_DEF_CLASS(GI_TYPE_INTERFACE_INFO, "InterfaceInfo", rb_mGLib);
|
|
152
|
+
|
|
153
|
+
RG_DEF_METHOD(n_prerequisites, 0);
|
|
154
|
+
RG_DEF_METHOD(get_prerequisite, 1);
|
|
155
|
+
RG_DEF_METHOD(n_properties, 0);
|
|
156
|
+
RG_DEF_METHOD(get_property, 1);
|
|
157
|
+
RG_DEF_METHOD(n_methods, 0);
|
|
158
|
+
RG_DEF_METHOD(get_method, 1);
|
|
159
|
+
RG_DEF_METHOD(n_signals, 0);
|
|
160
|
+
RG_DEF_METHOD(get_signal, 1);
|
|
161
|
+
RG_DEF_METHOD(n_vfuncs, 0);
|
|
162
|
+
RG_DEF_METHOD(get_vfunc, 1);
|
|
163
|
+
RG_DEF_METHOD(n_constants, 0);
|
|
164
|
+
RG_DEF_METHOD(get_constant, 1);
|
|
165
|
+
RG_DEF_METHOD(iface_struct, 0);
|
|
166
|
+
}
|
|
167
|
+
#endif
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2012-2026 Ruby-GNOME Project Team
|
|
4
|
+
*
|
|
5
|
+
* This library is free software; you can redistribute it and/or
|
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
7
|
+
* License as published by the Free Software Foundation; either
|
|
8
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
* Lesser General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
16
|
+
* License along with this library; if not, write to the Free Software
|
|
17
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
18
|
+
* MA 02110-1301 USA
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
#pragma once
|
|
22
|
+
|
|
23
|
+
#include "rbgprivate.h"
|
|
24
|
+
#include "rbglib2conversions.h"
|
|
25
|
+
|
|
26
|
+
#include <girepository/girepository.h>
|
|
27
|
+
#include <girepository/girffi.h>
|
|
28
|
+
|
|
29
|
+
#include "gi-enum-types.h"
|
|
30
|
+
#include "rbgi-conversions.h"
|
|
31
|
+
|
|
32
|
+
G_GNUC_INTERNAL void rbgi_arg_info_init(VALUE mGLib);
|
|
33
|
+
G_GNUC_INTERNAL void rbgi_callable_info_init(VALUE mGLib);
|
|
34
|
+
G_GNUC_INTERNAL void rbgi_base_info_init(VALUE mGLib);
|
|
35
|
+
G_GNUC_INTERNAL void rbgi_interface_info_init(VALUE mGLib);
|
|
36
|
+
G_GNUC_INTERNAL void rbgi_repository_init(VALUE mGLib);
|
|
37
|
+
G_GNUC_INTERNAL void rbgi_type_info_init(VALUE mGLib);
|
|
38
|
+
|
|
39
|
+
G_GNUC_INTERNAL gboolean
|
|
40
|
+
rbgi_arg_info_is_input_buffer(GIArgInfo *info);
|
|
41
|
+
G_GNUC_INTERNAL gboolean
|
|
42
|
+
rbgi_arg_info_is_output_buffer(GIArgInfo *info);
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2012-2026 Ruby-GNOME Project Team
|
|
4
|
+
*
|
|
5
|
+
* This library is free software; you can redistribute it and/or
|
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
7
|
+
* License as published by the Free Software Foundation; either
|
|
8
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
* Lesser General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
16
|
+
* License along with this library; if not, write to the Free Software
|
|
17
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
18
|
+
* MA 02110-1301 USA
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
#ifdef HAVE_GIREPOSITORY
|
|
22
|
+
#include "rbgi-private.h"
|
|
23
|
+
|
|
24
|
+
#define RG_TARGET_NAMESPACE rb_cGLibRepository
|
|
25
|
+
static VALUE RG_TARGET_NAMESPACE;
|
|
26
|
+
#define SELF(self) RVAL2GOBJ(self)
|
|
27
|
+
|
|
28
|
+
#if GLIB_CHECK_VERSION(2, 86, 0)
|
|
29
|
+
/* Returns the singleton process-global default
|
|
30
|
+
* GLib::Repository. It is not currently supported to have
|
|
31
|
+
* multiple repositories in a particular process, but this function is provided
|
|
32
|
+
* in the unlikely eventuality that it would become possible, and as a
|
|
33
|
+
* convenience for higher level language bindings to conform to the GObject
|
|
34
|
+
* method call conventions.
|
|
35
|
+
*
|
|
36
|
+
* @return [GLib::Repository] The global singleton
|
|
37
|
+
* GLib::Repository.
|
|
38
|
+
*/
|
|
39
|
+
static VALUE
|
|
40
|
+
rg_s_default(G_GNUC_UNUSED VALUE klass)
|
|
41
|
+
{
|
|
42
|
+
return GOBJ2RVAL_UNREF(gi_repository_dup_default());
|
|
43
|
+
}
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
static VALUE
|
|
47
|
+
rg_prepend_search_path(VALUE self, VALUE rb_path)
|
|
48
|
+
{
|
|
49
|
+
gi_repository_prepend_search_path(SELF(self), RVAL2CSTR(rb_path));
|
|
50
|
+
return self;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static VALUE
|
|
54
|
+
rg_search_path(VALUE self)
|
|
55
|
+
{
|
|
56
|
+
GIRepository *repository = SELF(self);
|
|
57
|
+
size_t n_paths;
|
|
58
|
+
const gchar *const *paths =
|
|
59
|
+
gi_repository_get_search_path(repository, &n_paths);
|
|
60
|
+
VALUE rb_paths = rb_ary_new_capa(n_paths);
|
|
61
|
+
for (size_t i = 0; i < n_paths; i++) {
|
|
62
|
+
rb_ary_push(rb_paths, CSTR2RVAL(paths[i]));
|
|
63
|
+
}
|
|
64
|
+
return rb_paths;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Force the namespace to be loaded if it isn't already. If namespace is not
|
|
68
|
+
* loaded, this function will search for a ".typelib" file using the repository
|
|
69
|
+
* search path. In addition, a version of namespace may be specified. If version
|
|
70
|
+
* is not specified, the latest will be used.
|
|
71
|
+
*
|
|
72
|
+
* @param [String] namespace The namespace to load
|
|
73
|
+
* @param [String, nil] version An optional version
|
|
74
|
+
*/
|
|
75
|
+
static VALUE
|
|
76
|
+
rg_require(int argc, VALUE *argv, VALUE self)
|
|
77
|
+
{
|
|
78
|
+
VALUE rb_namespace, rb_version, rb_flags;
|
|
79
|
+
const gchar *namespace_, *version;
|
|
80
|
+
GIRepositoryLoadFlags flags = 0;
|
|
81
|
+
GError *error = NULL;
|
|
82
|
+
|
|
83
|
+
rb_scan_args(argc, argv, "12", &rb_namespace, &rb_version, &rb_flags);
|
|
84
|
+
|
|
85
|
+
namespace_ = RVAL2CSTR(rb_namespace);
|
|
86
|
+
version = RVAL2CSTR_ACCEPT_NIL(rb_version);
|
|
87
|
+
if (!NIL_P(rb_flags)) {
|
|
88
|
+
flags = RVAL2GI_REPOSITORY_LOAD_FLAGS(rb_flags);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
gi_repository_require(SELF(self), namespace_, version, flags, &error);
|
|
92
|
+
if (error) {
|
|
93
|
+
RG_RAISE_ERROR(error);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return Qnil;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/* Return an array of all (transitive) versioned dependencies for namespace.
|
|
101
|
+
* Returned strings are of the form "namespace-version".
|
|
102
|
+
* Note: namespace must have already been loaded using a function such as
|
|
103
|
+
* GLib::Repository.require() before calling this method.
|
|
104
|
+
*
|
|
105
|
+
* @param [String] namespace The namespace to get the dependencies for.
|
|
106
|
+
*
|
|
107
|
+
* @return [Array<String>] The dependencies.
|
|
108
|
+
*/
|
|
109
|
+
static VALUE
|
|
110
|
+
rg_get_dependencies(VALUE self, VALUE rb_namespace)
|
|
111
|
+
{
|
|
112
|
+
GIRepository *repository = SELF(self);
|
|
113
|
+
const gchar *namespace_ = RVAL2CSTR(rb_namespace);
|
|
114
|
+
size_t n_dependencies;
|
|
115
|
+
gchar **dependencies = gi_repository_get_dependencies(repository, namespace_, &n_dependencies);
|
|
116
|
+
if (!dependencies) {
|
|
117
|
+
return Qnil;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
VALUE rb_dependencies = rb_ary_new_capa(n_dependencies);
|
|
121
|
+
for (size_t i = 0; dependencies[i]; i++) {
|
|
122
|
+
rb_ary_push(rb_dependencies, CSTR2RVAL_FREE(dependencies[i]));
|
|
123
|
+
}
|
|
124
|
+
g_free(dependencies);
|
|
125
|
+
|
|
126
|
+
return rb_dependencies;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
/* Return the list of currently loaded namespaces.
|
|
131
|
+
*
|
|
132
|
+
* @return [Array<String>] The loaded namespaces.
|
|
133
|
+
*/
|
|
134
|
+
static VALUE
|
|
135
|
+
rg_loaded_namespaces(VALUE self)
|
|
136
|
+
{
|
|
137
|
+
GIRepository *repository = SELF(self);
|
|
138
|
+
size_t n_namespaces;
|
|
139
|
+
gchar **namespaces = gi_repository_get_loaded_namespaces(repository, &n_namespaces);
|
|
140
|
+
if (!namespaces) {
|
|
141
|
+
return Qnil;
|
|
142
|
+
}
|
|
143
|
+
VALUE rb_namespaces = rb_ary_new_capa(n_namespaces);
|
|
144
|
+
for (size_t i = 0; namespaces[i]; i++) {
|
|
145
|
+
rb_ary_push(rb_namespaces, CSTR2RVAL_FREE(namespaces[i]));
|
|
146
|
+
}
|
|
147
|
+
g_free(namespaces);
|
|
148
|
+
|
|
149
|
+
return rb_namespaces;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
/* This method returns the number of metadata entries in given namespace. The
|
|
154
|
+
* namespace must have already been loaded before calling this function.
|
|
155
|
+
*
|
|
156
|
+
* @param [String] namespace The namespace to fetch the entries from.
|
|
157
|
+
*
|
|
158
|
+
* @return [Integer] The number of metadata entries.
|
|
159
|
+
*/
|
|
160
|
+
static VALUE
|
|
161
|
+
rg_get_n_infos(VALUE self, VALUE rb_namespace)
|
|
162
|
+
{
|
|
163
|
+
const gchar *namespace_;
|
|
164
|
+
gint n_infos;
|
|
165
|
+
|
|
166
|
+
namespace_ = RVAL2CSTR(rb_namespace);
|
|
167
|
+
n_infos = gi_repository_get_n_infos(SELF(self), namespace_);
|
|
168
|
+
|
|
169
|
+
return INT2NUM(n_infos);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
/* This method returns a particular metadata entry in the given namespace. The
|
|
174
|
+
* namespace must have already been loaded before calling this function. See
|
|
175
|
+
* GLib::Repository#get_n_infos() to find the maximum number
|
|
176
|
+
* of entries.
|
|
177
|
+
*
|
|
178
|
+
* @param [String] namespace The namespace to fetch the metadata entry from.
|
|
179
|
+
* @param [Fixnum] index The index of the entry.
|
|
180
|
+
*
|
|
181
|
+
* @return [GLib::BaseInfo] The metadata entry.
|
|
182
|
+
*/
|
|
183
|
+
static VALUE
|
|
184
|
+
rg_get_info(VALUE self, VALUE rb_namespace, VALUE rb_n)
|
|
185
|
+
{
|
|
186
|
+
GIRepository *repository;
|
|
187
|
+
const gchar *namespace_;
|
|
188
|
+
gint n;
|
|
189
|
+
GIBaseInfo *info;
|
|
190
|
+
|
|
191
|
+
repository = SELF(self);
|
|
192
|
+
namespace_ = RVAL2CSTR(rb_namespace);
|
|
193
|
+
n = NUM2INT(rb_n);
|
|
194
|
+
info = gi_repository_get_info(repository, namespace_, n);
|
|
195
|
+
return GOBJ2RVAL_UNREF(info);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
/* This method searches for a particular type or name. If only one argument is
|
|
200
|
+
* given, it is interpreted as a gtype and all loaded namespaces are searched
|
|
201
|
+
* for it. If two arguments are given the first is a particular namespace and
|
|
202
|
+
* the second the name of an entry to search for.
|
|
203
|
+
*
|
|
204
|
+
* @overload find(type)
|
|
205
|
+
*
|
|
206
|
+
* @param [String] type The type to search for.
|
|
207
|
+
*
|
|
208
|
+
* @return [GLib::BaseInfo] The metadata entry.
|
|
209
|
+
*
|
|
210
|
+
*
|
|
211
|
+
* @overload find(namespace, type)
|
|
212
|
+
*
|
|
213
|
+
* @param [String] namespace The namespace to search in.
|
|
214
|
+
*
|
|
215
|
+
* @param [String] type The type to search for.
|
|
216
|
+
*
|
|
217
|
+
* @return [GLib::BaseInfo] The metadata entry.
|
|
218
|
+
*/
|
|
219
|
+
static VALUE
|
|
220
|
+
rg_find(int argc, VALUE *argv, VALUE self)
|
|
221
|
+
{
|
|
222
|
+
GIBaseInfo *info;
|
|
223
|
+
|
|
224
|
+
if (argc == 1) {
|
|
225
|
+
VALUE rb_gtype;
|
|
226
|
+
GType gtype;
|
|
227
|
+
rb_gtype = argv[0];
|
|
228
|
+
gtype = rbgobj_gtype_from_ruby(rb_gtype);
|
|
229
|
+
info = gi_repository_find_by_gtype(SELF(self), gtype);
|
|
230
|
+
} else {
|
|
231
|
+
VALUE rb_namespace, rb_name;
|
|
232
|
+
const gchar *namespace_, *name;
|
|
233
|
+
|
|
234
|
+
rb_scan_args(argc, argv, "2", &rb_namespace, &rb_name);
|
|
235
|
+
namespace_ = RVAL2CSTR(rb_namespace);
|
|
236
|
+
name = RVAL2CSTR(rb_name);
|
|
237
|
+
info = gi_repository_find_by_name(SELF(self), namespace_, name);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return GOBJ2RVAL_UNREF(info);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
static VALUE
|
|
244
|
+
rg_get_version(VALUE self, VALUE rb_namespace)
|
|
245
|
+
{
|
|
246
|
+
const gchar *version;
|
|
247
|
+
version = gi_repository_get_version(SELF(self), RVAL2CSTR(rb_namespace));
|
|
248
|
+
return CSTR2RVAL(version);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
void
|
|
252
|
+
rbgi_repository_init(VALUE rb_mGLib)
|
|
253
|
+
{
|
|
254
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(GI_TYPE_REPOSITORY, "Repository", rb_mGLib);
|
|
255
|
+
|
|
256
|
+
#if GLIB_CHECK_VERSION(2, 86, 0)
|
|
257
|
+
RG_DEF_SMETHOD(default, 0);
|
|
258
|
+
#endif
|
|
259
|
+
RG_DEF_METHOD(prepend_search_path, 1);
|
|
260
|
+
RG_DEF_METHOD(search_path, 0);
|
|
261
|
+
RG_DEF_METHOD(require, -1);
|
|
262
|
+
RG_DEF_METHOD(get_dependencies, 1);
|
|
263
|
+
RG_DEF_METHOD(loaded_namespaces, 0);
|
|
264
|
+
RG_DEF_METHOD(get_n_infos, 1);
|
|
265
|
+
RG_DEF_METHOD(get_info, 2);
|
|
266
|
+
RG_DEF_METHOD(find, -1);
|
|
267
|
+
RG_DEF_METHOD(get_version, 1);
|
|
268
|
+
|
|
269
|
+
G_DEF_CLASS(GI_TYPE_REPOSITORY_LOAD_FLAGS, "RepositoryLoadFlags", rb_mGLib);
|
|
270
|
+
G_DEF_ERROR(GI_REPOSITORY_ERROR,
|
|
271
|
+
"RepositoryError",
|
|
272
|
+
rb_mGLib,
|
|
273
|
+
rb_eLoadError,
|
|
274
|
+
GI_TYPE_REPOSITORY_ERROR);
|
|
275
|
+
}
|
|
276
|
+
#endif
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2012-2026 Ruby-GNOME Project Team
|
|
4
|
+
*
|
|
5
|
+
* This library is free software; you can redistribute it and/or
|
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
7
|
+
* License as published by the Free Software Foundation; either
|
|
8
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
* Lesser General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
16
|
+
* License along with this library; if not, write to the Free Software
|
|
17
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
18
|
+
* MA 02110-1301 USA
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
#ifdef HAVE_GIREPOSITORY
|
|
22
|
+
#include "rbgi-private.h"
|
|
23
|
+
|
|
24
|
+
#define RG_TARGET_NAMESPACE rb_cGITypeInfo
|
|
25
|
+
#define SELF(self) (RVAL2GI_TYPE_INFO(self))
|
|
26
|
+
|
|
27
|
+
static VALUE
|
|
28
|
+
rg_pointer_p(VALUE self)
|
|
29
|
+
{
|
|
30
|
+
GITypeInfo *info = SELF(self);
|
|
31
|
+
return CBOOL2RVAL(gi_type_info_is_pointer(info));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static VALUE
|
|
35
|
+
rg_tag(VALUE self)
|
|
36
|
+
{
|
|
37
|
+
GITypeInfo *info = SELF(self);
|
|
38
|
+
return GI_TYPE_TAG2RVAL(gi_type_info_get_tag(info));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static VALUE
|
|
42
|
+
rg_get_param_type(VALUE self, VALUE rb_n)
|
|
43
|
+
{
|
|
44
|
+
GITypeInfo *info = SELF(self);
|
|
45
|
+
gint n = NUM2INT(rb_n);
|
|
46
|
+
return GOBJ2RVAL_UNREF(gi_type_info_get_param_type(info, n));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE
|
|
50
|
+
rg_interface(VALUE self)
|
|
51
|
+
{
|
|
52
|
+
GITypeInfo *info = SELF(self);
|
|
53
|
+
return GOBJ2RVAL_UNREF(gi_type_info_get_interface(info));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static VALUE
|
|
57
|
+
rg_array_length_index(VALUE self)
|
|
58
|
+
{
|
|
59
|
+
GITypeInfo *info = SELF(self);
|
|
60
|
+
unsigned int length;
|
|
61
|
+
if (gi_type_info_get_array_length_index(info, &length)) {
|
|
62
|
+
return INT2NUM(length);
|
|
63
|
+
} else {
|
|
64
|
+
return Qnil;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static VALUE
|
|
69
|
+
rg_array_fixed_size(VALUE self)
|
|
70
|
+
{
|
|
71
|
+
GITypeInfo *info = SELF(self);
|
|
72
|
+
size_t size;
|
|
73
|
+
if (gi_type_info_get_array_fixed_size(info, &size)) {
|
|
74
|
+
return SIZET2NUM(size);
|
|
75
|
+
} else {
|
|
76
|
+
return Qnil;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static VALUE
|
|
81
|
+
rg_zero_terminated_p(VALUE self)
|
|
82
|
+
{
|
|
83
|
+
GITypeInfo *info = SELF(self);
|
|
84
|
+
return CBOOL2RVAL(gi_type_info_is_zero_terminated(info));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static VALUE
|
|
88
|
+
rg_array_type(VALUE self)
|
|
89
|
+
{
|
|
90
|
+
GITypeInfo *info = SELF(self);
|
|
91
|
+
return GI_ARRAY_TYPE2RVAL(gi_type_info_get_array_type(info));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
void
|
|
95
|
+
rbgi_type_info_init(VALUE rb_mGLib)
|
|
96
|
+
{
|
|
97
|
+
VALUE RG_TARGET_NAMESPACE;
|
|
98
|
+
|
|
99
|
+
RG_TARGET_NAMESPACE =
|
|
100
|
+
G_DEF_CLASS(GI_TYPE_TYPE_INFO, "TypeInfo", rb_mGLib);
|
|
101
|
+
|
|
102
|
+
RG_DEF_METHOD_P(pointer, 0);
|
|
103
|
+
RG_DEF_METHOD(tag, 0);
|
|
104
|
+
RG_DEF_METHOD(get_param_type, 1);
|
|
105
|
+
RG_DEF_METHOD(interface, 0);
|
|
106
|
+
RG_DEF_METHOD(array_length_index, 0);
|
|
107
|
+
RG_DEF_METHOD(array_fixed_size, 0);
|
|
108
|
+
RG_DEF_METHOD_P(zero_terminated, 0);
|
|
109
|
+
RG_DEF_METHOD(array_type, 0);
|
|
110
|
+
|
|
111
|
+
rb_undef_method(RG_TARGET_NAMESPACE, "name");
|
|
112
|
+
}
|
|
113
|
+
#endif
|
data/ext/glib2/rbglib.c
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (C) 2011-
|
|
3
|
+
* Copyright (C) 2011-2026 Ruby-GNOME Project Team
|
|
4
4
|
* Copyright (C) 2002,2003 Masahiro Sakai
|
|
5
5
|
*
|
|
6
6
|
* This library is free software; you can redistribute it and/or
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
#include <locale.h>
|
|
23
23
|
#include "rbgprivate.h"
|
|
24
24
|
#include "rbglib.h"
|
|
25
|
+
#ifdef HAVE_GIREPOSITORY
|
|
26
|
+
# include "rbgi-private.h"
|
|
27
|
+
#endif
|
|
25
28
|
|
|
26
29
|
#define RG_TARGET_NAMESPACE rbg_mGLib()
|
|
27
30
|
|
|
@@ -1294,4 +1297,43 @@ union GDoubleIEEE754;
|
|
|
1294
1297
|
Init_glib_time_zone();
|
|
1295
1298
|
Init_glib_bytes();
|
|
1296
1299
|
Init_glib_option();
|
|
1300
|
+
|
|
1301
|
+
#ifdef HAVE_GIREPOSITORY
|
|
1302
|
+
rbgi_base_info_init(rbg_mGLib());
|
|
1303
|
+
|
|
1304
|
+
rbgi_arg_info_init(rbg_mGLib());
|
|
1305
|
+
rbgi_callable_info_init(rbg_mGLib());
|
|
1306
|
+
/* TODO */
|
|
1307
|
+
/* rbgi_constant_info_init(rbg_mGLib()); */
|
|
1308
|
+
G_DEF_CLASS(GI_TYPE_CONSTANT_INFO, "ConstantInfo", rbg_mGLib());
|
|
1309
|
+
/* TODO */
|
|
1310
|
+
/* rbgi_function_info_init(rbg_mGLib()); */
|
|
1311
|
+
G_DEF_CLASS(GI_TYPE_FUNCTION_INFO, "FunctionInfo", rbg_mGLib());
|
|
1312
|
+
rbgi_interface_info_init(rbg_mGLib());
|
|
1313
|
+
/* TODO */
|
|
1314
|
+
/* rbgi_object_info_init(rbg_mGLib()); */
|
|
1315
|
+
G_DEF_CLASS(GI_TYPE_OBJECT_INFO, "ObjectInfo", rbg_mGLib());
|
|
1316
|
+
/* TODO */
|
|
1317
|
+
/* rbgi_property_info_init(rbg_mGLib()); */
|
|
1318
|
+
G_DEF_CLASS(GI_TYPE_PROPERTY_INFO, "PropertyInfo", rbg_mGLib());
|
|
1319
|
+
/* TODO */
|
|
1320
|
+
/* rbgi_signal_info_init(rbg_mGLib()); */
|
|
1321
|
+
G_DEF_CLASS(GI_TYPE_SIGNAL_INFO, "SignalInfo", rbg_mGLib());
|
|
1322
|
+
/* TODO */
|
|
1323
|
+
/* rbgi_struct_info_init(rbg_mGLib()); */
|
|
1324
|
+
G_DEF_CLASS(GI_TYPE_STRUCT_INFO, "StructInfo", rbg_mGLib());
|
|
1325
|
+
rbgi_type_info_init(rbg_mGLib());
|
|
1326
|
+
/* TODO */
|
|
1327
|
+
/* rbgi_vfunc_info_init(rbg_mGLib()); */
|
|
1328
|
+
G_DEF_CLASS(GI_TYPE_VFUNC_INFO, "VFuncInfo", rbg_mGLib());
|
|
1329
|
+
|
|
1330
|
+
/* TODO */
|
|
1331
|
+
/* rbgi_array_type_init(rbg_mGLib()); */
|
|
1332
|
+
G_DEF_CLASS(GI_TYPE_ARRAY_TYPE, "ArrayType", rbg_mGLib());
|
|
1333
|
+
/* TODO */
|
|
1334
|
+
/* rbgi_type_tag_init(rbg_mGLib()); */
|
|
1335
|
+
G_DEF_CLASS(GI_TYPE_TYPE_TAG, "TypeTag", rbg_mGLib());
|
|
1336
|
+
|
|
1337
|
+
rbgi_repository_init(rbg_mGLib());
|
|
1338
|
+
#endif
|
|
1297
1339
|
}
|