glib2 4.3.6 → 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/rbglib_regex.c +15 -31
- data/ext/glib2/rbgobj_param.c +1 -1
- 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-regex.rb +18 -2
- data/test/test-repository.rb +71 -0
- data/test/test-type-info.rb +65 -0
- metadata +21 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a0c2e2040f0df1627b2664fff3df265629b9b622d34d35f246246d6dde604c84
|
|
4
|
+
data.tar.gz: b373afa94a243519321eb03866691959d8c2bf6eb63dbce7d59d288cf0df9d4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad10988ccbb9f9792195752bb7f39b7aa0b7e7ec31fe41fb332a74879b1dc1a267f78e239e94fd6e25625a90ae88d2c5abb6b8c0c282cb9c8b54cb833ad22a72
|
|
7
|
+
data.tar.gz: 7098c0bdea81d6cc7c2cb430f9f67fa3166359f3a293f7fbefbb50f0f39a2eca4f3c9a6f6e06a3a32d978e1f2ade9bfe546fcb1a1f04d774714abd9ddb7206de
|
data/ext/glib2/extconf.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2002-
|
|
1
|
+
# Copyright (C) 2002-2026 Ruby-GNOME Project Team
|
|
2
2
|
#
|
|
3
3
|
# This library is free software; you can redistribute it and/or
|
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
|
@@ -39,6 +39,16 @@ unless required_pkg_config_package([package_id, 2, 56, 0],
|
|
|
39
39
|
exit(false)
|
|
40
40
|
end
|
|
41
41
|
PKGConfig.have_package('gthread-2.0')
|
|
42
|
+
if ENV["RUBY_GNOME_GLIB2_GIREPOSITORY_ENABLE"] == "yes"
|
|
43
|
+
have_girepository =
|
|
44
|
+
required_pkg_config_package(["girepository-2.0", 2, 80, 0],
|
|
45
|
+
debian: "libgirepository-2.0-dev")
|
|
46
|
+
else
|
|
47
|
+
have_girepository = false
|
|
48
|
+
end
|
|
49
|
+
if have_girepository
|
|
50
|
+
$defs << "-DHAVE_GIREPOSITORY"
|
|
51
|
+
end
|
|
42
52
|
|
|
43
53
|
have_header("unistd.h")
|
|
44
54
|
have_header("io.h")
|
|
@@ -50,17 +60,11 @@ have_func("rb_check_array_type", ruby_header)
|
|
|
50
60
|
have_func("rb_check_hash_type", ruby_header)
|
|
51
61
|
have_func("rb_exec_recursive", ruby_header)
|
|
52
62
|
have_func("rb_errinfo", ruby_header)
|
|
53
|
-
have_func("rb_thread_call_without_gvl", ruby_header)
|
|
54
|
-
have_func("ruby_native_thread_p", ruby_header)
|
|
55
|
-
have_func("rb_thread_call_with_gvl", ruby_header)
|
|
56
63
|
have_func("rb_gc_register_mark_object", ruby_header)
|
|
57
64
|
have_func("rb_exc_new_str", ruby_header)
|
|
58
65
|
# For Ruby 2.1. TODO: Remove this when we drop Ruby 2.1 support.
|
|
59
66
|
have_func("rb_enc_str_new_static", ruby_header)
|
|
60
67
|
|
|
61
|
-
have_var("curr_thread", [ruby_header, "node.h"])
|
|
62
|
-
have_var("rb_curr_thread", [ruby_header, "node.h"])
|
|
63
|
-
|
|
64
68
|
create_pkg_config_file("Ruby/GLib2", package_id)
|
|
65
69
|
|
|
66
70
|
enum_types_prefix = "glib-enum-types"
|
|
@@ -92,6 +96,18 @@ glib_mkenums(enum_types_prefix,
|
|
|
92
96
|
[],
|
|
93
97
|
preamble: "#include \"rbgprivate.h\"")
|
|
94
98
|
|
|
99
|
+
if have_girepository
|
|
100
|
+
girepository_headers = include_paths.split.inject([]) do |result, path|
|
|
101
|
+
result + Dir.glob(File.join(path.sub(/^-I/, ""), "girepository", "*.h"))
|
|
102
|
+
end
|
|
103
|
+
glib_mkenums("gi-enum-types",
|
|
104
|
+
girepository_headers,
|
|
105
|
+
"GI_TYPE_",
|
|
106
|
+
[],
|
|
107
|
+
id_prefix: "GI",
|
|
108
|
+
preamble: "#include <girepository/girepository.h>")
|
|
109
|
+
end
|
|
110
|
+
|
|
95
111
|
$defs << "-DRUBY_GLIB2_COMPILATION"
|
|
96
112
|
|
|
97
113
|
create_makefile(module_name)
|
data/ext/glib2/glib2.def
CHANGED
|
@@ -0,0 +1,226 @@
|
|
|
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_cGIArgInfo
|
|
25
|
+
#define SELF(self) (RVAL2GI_ARG_INFO(self))
|
|
26
|
+
|
|
27
|
+
gboolean
|
|
28
|
+
rbgi_arg_info_is_input_buffer(GIArgInfo *info)
|
|
29
|
+
{
|
|
30
|
+
if (gi_arg_info_get_direction(info) != GI_DIRECTION_IN) {
|
|
31
|
+
return FALSE;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Heuristic */
|
|
35
|
+
const gchar *name = gi_base_info_get_name(GI_BASE_INFO(info));
|
|
36
|
+
if (strcmp(name, "buffer") != 0) {
|
|
37
|
+
return FALSE;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
GITypeInfo type_info;
|
|
41
|
+
gi_arg_info_load_type_info(info, &type_info);
|
|
42
|
+
if (gi_type_info_get_tag(&type_info) != GI_TYPE_TAG_ARRAY) {
|
|
43
|
+
gi_base_info_clear(&type_info);
|
|
44
|
+
return FALSE;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
GIArrayType array_type = gi_type_info_get_array_type(&type_info);
|
|
48
|
+
if (array_type != GI_ARRAY_TYPE_C) {
|
|
49
|
+
gi_base_info_clear(&type_info);
|
|
50
|
+
return FALSE;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
unsigned int length_index;
|
|
54
|
+
if (!gi_type_info_get_array_length_index(&type_info, &length_index)) {
|
|
55
|
+
gi_base_info_clear(&type_info);
|
|
56
|
+
return FALSE;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
GITypeInfo *element_type_info = gi_type_info_get_param_type(&type_info, 0);
|
|
60
|
+
GITypeTag element_type_tag = gi_type_info_get_tag(element_type_info);
|
|
61
|
+
gi_base_info_unref(element_type_info);
|
|
62
|
+
gi_base_info_clear(&type_info);
|
|
63
|
+
return element_type_tag == GI_TYPE_TAG_UINT8;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
gboolean
|
|
67
|
+
rbgi_arg_info_is_output_buffer(GIArgInfo *info)
|
|
68
|
+
{
|
|
69
|
+
if (gi_arg_info_get_direction(info) != GI_DIRECTION_OUT) {
|
|
70
|
+
return FALSE;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!gi_arg_info_is_caller_allocates(info)) {
|
|
74
|
+
return FALSE;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
GITypeInfo type_info;
|
|
78
|
+
gi_arg_info_load_type_info(info, &type_info);
|
|
79
|
+
if (gi_type_info_get_tag(&type_info) != GI_TYPE_TAG_ARRAY) {
|
|
80
|
+
gi_base_info_clear(&type_info);
|
|
81
|
+
return FALSE;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
GITypeInfo *element_type_info = gi_type_info_get_param_type(&type_info, 0);
|
|
85
|
+
GITypeTag element_type_tag = gi_type_info_get_tag(element_type_info);
|
|
86
|
+
gi_base_info_unref(element_type_info);
|
|
87
|
+
gi_base_info_clear(&type_info);
|
|
88
|
+
return element_type_tag == GI_TYPE_TAG_UINT8;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static VALUE
|
|
92
|
+
rg_direction(VALUE self)
|
|
93
|
+
{
|
|
94
|
+
GIArgInfo *info;
|
|
95
|
+
|
|
96
|
+
info = SELF(self);
|
|
97
|
+
return GI_DIRECTION2RVAL(gi_arg_info_get_direction(info));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static VALUE
|
|
101
|
+
rg_caller_allocates_p(VALUE self)
|
|
102
|
+
{
|
|
103
|
+
GIArgInfo *info;
|
|
104
|
+
|
|
105
|
+
info = SELF(self);
|
|
106
|
+
return CBOOL2RVAL(gi_arg_info_is_caller_allocates(info));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static VALUE
|
|
110
|
+
rg_return_value_p(VALUE self)
|
|
111
|
+
{
|
|
112
|
+
GIArgInfo *info;
|
|
113
|
+
|
|
114
|
+
info = SELF(self);
|
|
115
|
+
return CBOOL2RVAL(gi_arg_info_is_return_value(info));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static VALUE
|
|
119
|
+
rg_optional_p(VALUE self)
|
|
120
|
+
{
|
|
121
|
+
GIArgInfo *info;
|
|
122
|
+
|
|
123
|
+
info = SELF(self);
|
|
124
|
+
return CBOOL2RVAL(gi_arg_info_is_optional(info));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static VALUE
|
|
128
|
+
rg_may_be_null_p(VALUE self)
|
|
129
|
+
{
|
|
130
|
+
GIArgInfo *info;
|
|
131
|
+
|
|
132
|
+
info = SELF(self);
|
|
133
|
+
return CBOOL2RVAL(gi_arg_info_may_be_null(info));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static VALUE
|
|
137
|
+
rg_ownership_transfer(VALUE self)
|
|
138
|
+
{
|
|
139
|
+
GIArgInfo *info;
|
|
140
|
+
|
|
141
|
+
info = SELF(self);
|
|
142
|
+
return GI_TRANSFER2RVAL(gi_arg_info_get_ownership_transfer(info));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static VALUE
|
|
146
|
+
rg_scope(VALUE self)
|
|
147
|
+
{
|
|
148
|
+
GIArgInfo *info;
|
|
149
|
+
|
|
150
|
+
info = SELF(self);
|
|
151
|
+
return GI_SCOPE_TYPE2RVAL(gi_arg_info_get_scope(info));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static VALUE
|
|
155
|
+
rg_closure_index(VALUE self)
|
|
156
|
+
{
|
|
157
|
+
GIArgInfo *info = SELF(self);
|
|
158
|
+
unsigned int closure_index;
|
|
159
|
+
if (gi_arg_info_get_closure_index(info, &closure_index)) {
|
|
160
|
+
return UINT2NUM(closure_index);
|
|
161
|
+
} else {
|
|
162
|
+
return Qnil;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static VALUE
|
|
167
|
+
rg_destroy_index(VALUE self)
|
|
168
|
+
{
|
|
169
|
+
GIArgInfo *info = SELF(self);
|
|
170
|
+
unsigned int destroy_index;
|
|
171
|
+
if (gi_arg_info_get_destroy_index(info, &destroy_index)) {
|
|
172
|
+
return UINT2NUM(destroy_index);
|
|
173
|
+
} else {
|
|
174
|
+
return Qnil;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static VALUE
|
|
179
|
+
rg_type(VALUE self)
|
|
180
|
+
{
|
|
181
|
+
GIArgInfo *info;
|
|
182
|
+
|
|
183
|
+
info = SELF(self);
|
|
184
|
+
return GOBJ2RVAL_UNREF(gi_arg_info_get_type_info(info));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
static VALUE
|
|
188
|
+
rg_input_buffer_p(VALUE self)
|
|
189
|
+
{
|
|
190
|
+
GIArgInfo *info = SELF(self);
|
|
191
|
+
return CBOOL2RVAL(rbgi_arg_info_is_input_buffer(info));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
static VALUE
|
|
195
|
+
rg_output_buffer_p(VALUE self)
|
|
196
|
+
{
|
|
197
|
+
GIArgInfo *info = SELF(self);
|
|
198
|
+
return CBOOL2RVAL(rbgi_arg_info_is_output_buffer(info));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
void
|
|
202
|
+
rbgi_arg_info_init(VALUE rb_mGLib)
|
|
203
|
+
{
|
|
204
|
+
VALUE RG_TARGET_NAMESPACE;
|
|
205
|
+
|
|
206
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(GI_TYPE_ARG_INFO, "ArgInfo", rb_mGLib);
|
|
207
|
+
|
|
208
|
+
RG_DEF_METHOD(direction, 0);
|
|
209
|
+
RG_DEF_METHOD_P(caller_allocates, 0);
|
|
210
|
+
RG_DEF_METHOD_P(return_value, 0);
|
|
211
|
+
RG_DEF_METHOD_P(optional, 0);
|
|
212
|
+
RG_DEF_METHOD_P(may_be_null, 0);
|
|
213
|
+
RG_DEF_METHOD(ownership_transfer, 0);
|
|
214
|
+
RG_DEF_METHOD(scope, 0);
|
|
215
|
+
RG_DEF_METHOD(closure_index, 0);
|
|
216
|
+
RG_DEF_METHOD(destroy_index, 0);
|
|
217
|
+
RG_DEF_METHOD(type, 0);
|
|
218
|
+
|
|
219
|
+
RG_DEF_METHOD_P(input_buffer, 0);
|
|
220
|
+
RG_DEF_METHOD_P(output_buffer, 0);
|
|
221
|
+
|
|
222
|
+
G_DEF_CLASS(GI_TYPE_DIRECTION, "Direction", rb_mGLib);
|
|
223
|
+
G_DEF_CLASS(GI_TYPE_SCOPE_TYPE, "ScopeType", rb_mGLib);
|
|
224
|
+
G_DEF_CLASS(GI_TYPE_TRANSFER, "Transfer", rb_mGLib);
|
|
225
|
+
}
|
|
226
|
+
#endif
|
|
@@ -0,0 +1,223 @@
|
|
|
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_cGLibBaseInfo
|
|
25
|
+
static VALUE RG_TARGET_NAMESPACE;
|
|
26
|
+
#define SELF(self) RVAL2GI_BASE_INFO(self)
|
|
27
|
+
|
|
28
|
+
static void
|
|
29
|
+
rbgi_base_info_free(void *data)
|
|
30
|
+
{
|
|
31
|
+
GIBaseInfo *info = data;
|
|
32
|
+
gi_base_info_unref(info);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static const rb_data_type_t rbgi_base_info_type = {
|
|
36
|
+
"GLib::BaseInfo",
|
|
37
|
+
{
|
|
38
|
+
NULL,
|
|
39
|
+
rbgi_base_info_free,
|
|
40
|
+
NULL,
|
|
41
|
+
NULL,
|
|
42
|
+
},
|
|
43
|
+
&rbg_glib_instantiatable_type,
|
|
44
|
+
NULL,
|
|
45
|
+
RUBY_TYPED_FREE_IMMEDIATELY |
|
|
46
|
+
RUBY_TYPED_WB_PROTECTED |
|
|
47
|
+
RUBY_TYPED_FROZEN_SHAREABLE,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
static VALUE
|
|
51
|
+
rbgi_base_info_alloc_func(VALUE klass)
|
|
52
|
+
{
|
|
53
|
+
return TypedData_Wrap_Struct(klass,
|
|
54
|
+
&rbgi_base_info_type,
|
|
55
|
+
NULL);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static gpointer
|
|
59
|
+
rbgi_base_info_robj2instance(VALUE rb_info, gpointer user_data)
|
|
60
|
+
{
|
|
61
|
+
GIBaseInfo *info;
|
|
62
|
+
TypedData_Get_Struct(rb_info,
|
|
63
|
+
GIBaseInfo,
|
|
64
|
+
&rbgi_base_info_type,
|
|
65
|
+
info);
|
|
66
|
+
return info;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static VALUE
|
|
70
|
+
rbgi_base_info_instance2robj(gpointer instance, gpointer user_data)
|
|
71
|
+
{
|
|
72
|
+
GIBaseInfo *info = instance;
|
|
73
|
+
if (!info) {
|
|
74
|
+
return Qnil;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
VALUE klass = RG_TARGET_NAMESPACE;
|
|
78
|
+
GType type = G_TYPE_FROM_INSTANCE(info);
|
|
79
|
+
if (type == GI_TYPE_ARG_INFO) {
|
|
80
|
+
ID id_ArgInfo;
|
|
81
|
+
RUBY_CONST_ID(id_ArgInfo, "ArgInfo");
|
|
82
|
+
klass = rb_const_get(rbg_mGLib(), id_ArgInfo);
|
|
83
|
+
} else if (type == GI_TYPE_CALLABLE_INFO) {
|
|
84
|
+
ID id_CallableInfo;
|
|
85
|
+
RUBY_CONST_ID(id_CallableInfo, "CallableInfo");
|
|
86
|
+
klass = rb_const_get(rbg_mGLib(), id_CallableInfo);
|
|
87
|
+
} else if (type == GI_TYPE_CONSTANT_INFO) {
|
|
88
|
+
ID id_ConstantInfo;
|
|
89
|
+
RUBY_CONST_ID(id_ConstantInfo, "ConstantInfo");
|
|
90
|
+
klass = rb_const_get(rbg_mGLib(), id_ConstantInfo);
|
|
91
|
+
} else if (type == GI_TYPE_FUNCTION_INFO) {
|
|
92
|
+
ID id_FunctionInfo;
|
|
93
|
+
RUBY_CONST_ID(id_FunctionInfo, "FunctionInfo");
|
|
94
|
+
klass = rb_const_get(rbg_mGLib(), id_FunctionInfo);
|
|
95
|
+
} else if (type == GI_TYPE_INTERFACE_INFO) {
|
|
96
|
+
ID id_InterfaceInfo;
|
|
97
|
+
RUBY_CONST_ID(id_InterfaceInfo, "InterfaceInfo");
|
|
98
|
+
klass = rb_const_get(rbg_mGLib(), id_InterfaceInfo);
|
|
99
|
+
} else if (type == GI_TYPE_OBJECT_INFO) {
|
|
100
|
+
ID id_ObjectInfo;
|
|
101
|
+
RUBY_CONST_ID(id_ObjectInfo, "ObjectInfo");
|
|
102
|
+
klass = rb_const_get(rbg_mGLib(), id_ObjectInfo);
|
|
103
|
+
} else if (type == GI_TYPE_PROPERTY_INFO) {
|
|
104
|
+
ID id_PropertyInfo;
|
|
105
|
+
RUBY_CONST_ID(id_PropertyInfo, "PropertyInfo");
|
|
106
|
+
klass = rb_const_get(rbg_mGLib(), id_PropertyInfo);
|
|
107
|
+
} else if (type == GI_TYPE_SIGNAL_INFO) {
|
|
108
|
+
ID id_SignalInfo;
|
|
109
|
+
RUBY_CONST_ID(id_SignalInfo, "SignalInfo");
|
|
110
|
+
klass = rb_const_get(rbg_mGLib(), id_SignalInfo);
|
|
111
|
+
} else if (type == GI_TYPE_STRUCT_INFO) {
|
|
112
|
+
ID id_StructInfo;
|
|
113
|
+
RUBY_CONST_ID(id_StructInfo, "StructInfo");
|
|
114
|
+
klass = rb_const_get(rbg_mGLib(), id_StructInfo);
|
|
115
|
+
} else if (type == GI_TYPE_TYPE_INFO) {
|
|
116
|
+
ID id_TypeInfo;
|
|
117
|
+
RUBY_CONST_ID(id_TypeInfo, "TypeInfo");
|
|
118
|
+
klass = rb_const_get(rbg_mGLib(), id_TypeInfo);
|
|
119
|
+
} else if (type == GI_TYPE_VFUNC_INFO) {
|
|
120
|
+
ID id_VFuncInfo;
|
|
121
|
+
RUBY_CONST_ID(id_VFuncInfo, "VFuncInfo");
|
|
122
|
+
klass = rb_const_get(rbg_mGLib(), id_VFuncInfo);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
gi_base_info_ref(info);
|
|
126
|
+
return TypedData_Wrap_Struct(klass, &rbgi_base_info_type, info);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static void
|
|
130
|
+
rbgi_base_info_unref(gpointer instance, gpointer user_data)
|
|
131
|
+
{
|
|
132
|
+
GIBaseInfo *info = instance;
|
|
133
|
+
if (!info) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
gi_base_info_unref(info);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static VALUE
|
|
140
|
+
rg_name(VALUE self)
|
|
141
|
+
{
|
|
142
|
+
GIBaseInfo *info;
|
|
143
|
+
|
|
144
|
+
info = SELF(self);
|
|
145
|
+
return CSTR2RVAL(gi_base_info_get_name(info));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
static VALUE
|
|
149
|
+
rg_namespace(VALUE self)
|
|
150
|
+
{
|
|
151
|
+
GIBaseInfo *info;
|
|
152
|
+
|
|
153
|
+
info = SELF(self);
|
|
154
|
+
return CSTR2RVAL(gi_base_info_get_namespace(info));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
static VALUE
|
|
158
|
+
rg_container(VALUE self)
|
|
159
|
+
{
|
|
160
|
+
GIBaseInfo *info = SELF(self);
|
|
161
|
+
return GOBJ2RVAL(gi_base_info_get_container(info));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
static VALUE
|
|
165
|
+
rg_operator_aref(VALUE self, VALUE name)
|
|
166
|
+
{
|
|
167
|
+
GIBaseInfo *info;
|
|
168
|
+
|
|
169
|
+
info = SELF(self);
|
|
170
|
+
return CSTR2RVAL(gi_base_info_get_attribute(info, RVAL2CSTR(name)));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
static VALUE
|
|
174
|
+
rg_each(VALUE self)
|
|
175
|
+
{
|
|
176
|
+
GIAttributeIter iter = {0, };
|
|
177
|
+
GIBaseInfo *info;
|
|
178
|
+
const gchar *name, *value;
|
|
179
|
+
|
|
180
|
+
RETURN_ENUMERATOR(self, 0, NULL);
|
|
181
|
+
|
|
182
|
+
info = SELF(self);
|
|
183
|
+
while (gi_base_info_iterate_attributes(info, &iter, &name, &value)) {
|
|
184
|
+
VALUE rb_name, rb_value;
|
|
185
|
+
rb_name = CSTR2RVAL(name);
|
|
186
|
+
rb_value = CSTR2RVAL(value);
|
|
187
|
+
rb_yield(rb_ary_new3(2, rb_name, rb_value));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return Qnil;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
void
|
|
194
|
+
rbgi_base_info_init(VALUE rb_mGLib)
|
|
195
|
+
{
|
|
196
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(GI_TYPE_BASE_INFO, "BaseInfo", rb_mGLib);
|
|
197
|
+
rb_define_alloc_func(RG_TARGET_NAMESPACE, rbgi_base_info_alloc_func);
|
|
198
|
+
|
|
199
|
+
RGConvertTable table = {
|
|
200
|
+
.type = GI_TYPE_BASE_INFO,
|
|
201
|
+
.klass = RG_TARGET_NAMESPACE,
|
|
202
|
+
.user_data = NULL,
|
|
203
|
+
.notify = NULL,
|
|
204
|
+
.get_superclass = NULL,
|
|
205
|
+
.type_init_hook = NULL,
|
|
206
|
+
.rvalue2gvalue = NULL,
|
|
207
|
+
.gvalue2rvalue = NULL,
|
|
208
|
+
.initialize = NULL,
|
|
209
|
+
.robj2instance = rbgi_base_info_robj2instance,
|
|
210
|
+
.instance2robj = rbgi_base_info_instance2robj,
|
|
211
|
+
.unref = rbgi_base_info_unref,
|
|
212
|
+
};
|
|
213
|
+
RG_DEF_CONVERSION(&table);
|
|
214
|
+
|
|
215
|
+
rb_include_module(RG_TARGET_NAMESPACE, rb_mEnumerable);
|
|
216
|
+
|
|
217
|
+
RG_DEF_METHOD(name, 0);
|
|
218
|
+
RG_DEF_METHOD(namespace, 0);
|
|
219
|
+
RG_DEF_METHOD(container, 0);
|
|
220
|
+
RG_DEF_METHOD_OPERATOR("[]", aref, 1);
|
|
221
|
+
RG_DEF_METHOD(each, 0);
|
|
222
|
+
}
|
|
223
|
+
#endif
|
|
@@ -0,0 +1,145 @@
|
|
|
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_cGICallableInfo
|
|
25
|
+
#define SELF(self) RVAL2GI_CALLABLE_INFO(self)
|
|
26
|
+
|
|
27
|
+
static VALUE
|
|
28
|
+
rg_set_lock_gvl_default(VALUE self, VALUE rb_boolean)
|
|
29
|
+
{
|
|
30
|
+
return rb_iv_set(self, "lock_gvl_default", rb_boolean);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static VALUE
|
|
34
|
+
rg_add_lock_gvl_predicate(VALUE self)
|
|
35
|
+
{
|
|
36
|
+
VALUE rb_predicates;
|
|
37
|
+
if (!RVAL2CBOOL(rb_ivar_defined(self, rb_intern("lock_gvl_predicates")))) {
|
|
38
|
+
rb_predicates = rb_ary_new();
|
|
39
|
+
rb_iv_set(self, "lock_gvl_predicates", rb_predicates);
|
|
40
|
+
} else {
|
|
41
|
+
rb_predicates = rb_iv_get(self, "lock_gvl_predicates");
|
|
42
|
+
}
|
|
43
|
+
rb_ary_push(rb_predicates, rb_block_lambda());
|
|
44
|
+
return Qnil;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static VALUE
|
|
48
|
+
rg_lock_gvl_p(int argc, VALUE *argv, VALUE self)
|
|
49
|
+
{
|
|
50
|
+
VALUE rb_receiver;
|
|
51
|
+
VALUE rb_lock_gvl_default = Qtrue;
|
|
52
|
+
rb_scan_args(argc, argv, "01", &rb_receiver);
|
|
53
|
+
if (RVAL2CBOOL(rb_ivar_defined(self, rb_intern("lock_gvl_default")))) {
|
|
54
|
+
rb_lock_gvl_default = rb_iv_get(self, "lock_gvl_default");
|
|
55
|
+
}
|
|
56
|
+
if (NIL_P(rb_receiver)) {
|
|
57
|
+
return rb_lock_gvl_default;
|
|
58
|
+
}
|
|
59
|
+
if (!RVAL2CBOOL(rb_ivar_defined(self, rb_intern("lock_gvl_predicates")))) {
|
|
60
|
+
return rb_lock_gvl_default;
|
|
61
|
+
}
|
|
62
|
+
VALUE rb_predicates = rb_iv_get(self, "lock_gvl_predicates");
|
|
63
|
+
long n = RARRAY_LEN(rb_predicates);
|
|
64
|
+
long i;
|
|
65
|
+
VALUE rb_args = rb_ary_new_from_args(2,
|
|
66
|
+
self,
|
|
67
|
+
rb_receiver);
|
|
68
|
+
VALUE rb_lock_gvl = rb_lock_gvl_default;
|
|
69
|
+
RARRAY_PTR_USE(rb_predicates, rb_predicates_raw, {
|
|
70
|
+
for (i = 0; i < n; i++) {
|
|
71
|
+
VALUE rb_predicate = rb_predicates_raw[n - i - 1];
|
|
72
|
+
VALUE rb_result = rb_proc_call(rb_predicate, rb_args);
|
|
73
|
+
if (NIL_P(rb_result)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
rb_lock_gvl = rb_result;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return rb_lock_gvl;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static VALUE
|
|
84
|
+
rg_can_throw_gerror_p(VALUE self)
|
|
85
|
+
{
|
|
86
|
+
GICallableInfo *info = SELF(self);
|
|
87
|
+
return CBOOL2RVAL(gi_callable_info_can_throw_gerror(info));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static VALUE
|
|
91
|
+
rg_return_type(VALUE self)
|
|
92
|
+
{
|
|
93
|
+
GICallableInfo *info = SELF(self);
|
|
94
|
+
return GOBJ2RVAL_UNREF(gi_callable_info_get_return_type(info));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static VALUE
|
|
98
|
+
rg_caller_owns(VALUE self)
|
|
99
|
+
{
|
|
100
|
+
GICallableInfo *info = SELF(self);
|
|
101
|
+
return GI_TRANSFER2RVAL(gi_callable_info_get_caller_owns(info));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static VALUE
|
|
105
|
+
rg_may_return_null_p(VALUE self)
|
|
106
|
+
{
|
|
107
|
+
GICallableInfo *info = SELF(self);
|
|
108
|
+
return CBOOL2RVAL(gi_callable_info_may_return_null(info));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
static VALUE
|
|
112
|
+
rg_n_args(VALUE self)
|
|
113
|
+
{
|
|
114
|
+
GICallableInfo *info = SELF(self);
|
|
115
|
+
return INT2NUM(gi_callable_info_get_n_args(info));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static VALUE
|
|
119
|
+
rg_get_arg(VALUE self, VALUE rb_n)
|
|
120
|
+
{
|
|
121
|
+
GICallableInfo *info = SELF(self);
|
|
122
|
+
gint n = NUM2INT(rb_n);
|
|
123
|
+
return GOBJ2RVAL_UNREF(gi_callable_info_get_arg(info, n));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
void
|
|
127
|
+
rbgi_callable_info_init(VALUE rb_mGLib)
|
|
128
|
+
{
|
|
129
|
+
VALUE RG_TARGET_NAMESPACE;
|
|
130
|
+
|
|
131
|
+
RG_TARGET_NAMESPACE =
|
|
132
|
+
G_DEF_CLASS(GI_TYPE_CALLABLE_INFO, "CallableInfo", rb_mGLib);
|
|
133
|
+
|
|
134
|
+
RG_DEF_METHOD(set_lock_gvl_default, 1);
|
|
135
|
+
RG_DEF_METHOD(add_lock_gvl_predicate, 0);
|
|
136
|
+
RG_DEF_METHOD_P(lock_gvl, -1);
|
|
137
|
+
|
|
138
|
+
RG_DEF_METHOD_P(can_throw_gerror, 0);
|
|
139
|
+
RG_DEF_METHOD(return_type, 0);
|
|
140
|
+
RG_DEF_METHOD(caller_owns, 0);
|
|
141
|
+
RG_DEF_METHOD_P(may_return_null, 0);
|
|
142
|
+
RG_DEF_METHOD(n_args, 0);
|
|
143
|
+
RG_DEF_METHOD(get_arg, 1);
|
|
144
|
+
}
|
|
145
|
+
#endif
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
#define RVAL2GI_REPOSITORY_LOAD_FLAGS(rb_flags) \
|
|
24
|
+
(RVAL2GFLAGS(rb_flags, GI_TYPE_REPOSITORY_LOAD_FLAGS))
|
|
25
|
+
|
|
26
|
+
#define RVAL2GI_ARG_INFO(rb_info) GI_ARG_INFO(RVAL2GOBJ(rb_info))
|
|
27
|
+
#define RVAL2GI_BASE_INFO(rb_info) GI_BASE_INFO(RVAL2GOBJ(rb_info))
|
|
28
|
+
#define RVAL2GI_CALLABLE_INFO(rb_info) GI_CALLABLE_INFO(RVAL2GOBJ(rb_info))
|
|
29
|
+
#define RVAL2GI_INTERFACE_INFO(rb_info) GI_INTERFACE_INFO(RVAL2GOBJ(rb_info))
|
|
30
|
+
#define RVAL2GI_TYPE_INFO(rb_info) GI_TYPE_INFO(RVAL2GOBJ(rb_info))
|
|
31
|
+
|
|
32
|
+
#define GI_ARRAY_TYPE2RVAL(type) (GENUM2RVAL(type, GI_TYPE_ARRAY_TYPE))
|
|
33
|
+
#define GI_DIRECTION2RVAL(direction) (GENUM2RVAL(direction, GI_TYPE_DIRECTION))
|
|
34
|
+
#define GI_SCOPE_TYPE2RVAL(scope) (GENUM2RVAL(scope, GI_TYPE_SCOPE_TYPE))
|
|
35
|
+
#define GI_TRANSFER2RVAL(transfer) (GENUM2RVAL(transfer, GI_TYPE_TRANSFER))
|
|
36
|
+
#define GI_TYPE_TAG2RVAL(tag) (GENUM2RVAL(tag, GI_TYPE_TYPE_TAG))
|