gobject-introspection 2.2.5-x86-mingw32 → 3.0.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -3
- data/ext/gobject-introspection/extconf.rb +1 -1
- data/ext/gobject-introspection/rb-gi-argument.c +2275 -708
- data/ext/gobject-introspection/rb-gi-constant-info.c +1 -1
- data/ext/gobject-introspection/rb-gi-constructor-info.c +2 -2
- data/ext/gobject-introspection/rb-gi-conversions.h +40 -36
- data/ext/gobject-introspection/rb-gi-field-info.c +32 -6
- data/ext/gobject-introspection/rb-gi-function-info.c +98 -63
- data/ext/gobject-introspection/rb-gi-loader.c +33 -1
- data/ext/gobject-introspection/rb-gi-method-info.c +3 -6
- data/ext/gobject-introspection/rb-gi-private.h +2 -1
- data/ext/gobject-introspection/rb-gi-repository.c +29 -29
- data/lib/2.0/gobject_introspection.so +0 -0
- data/lib/2.1/gobject_introspection.so +0 -0
- data/lib/2.2/gobject_introspection.so +0 -0
- data/lib/gobject-introspection/arg-info.rb +27 -0
- data/lib/gobject-introspection/callable-info.rb +3 -1
- data/lib/gobject-introspection/loader.rb +160 -31
- data/lib/gobject-introspection.rb +1 -0
- data/vendor/local/bin/g-ir-compiler.exe +0 -0
- data/vendor/local/bin/g-ir-generate.exe +0 -0
- data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
- data/vendor/local/include/gobject-introspection-1.0/girepository.h +4 -0
- data/vendor/local/include/gobject-introspection-1.0/giversionmacros.h +15 -1
- data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +6 -1
- data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ast.py +3 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +19 -1
- data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +7 -3
- data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +1 -1
- data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +8 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
- data/vendor/local/lib/libgirepository-1.0.a +0 -0
- data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
- data/vendor/local/lib/libgirepository-1.0.la +3 -3
- data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +1 -1
- data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +1 -1
- data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +44 -7
- data/vendor/local/share/gir-1.0/GLib-2.0.gir +518 -131
- data/vendor/local/share/gir-1.0/GObject-2.0.gir +1248 -475
- data/vendor/local/share/gir-1.0/Gio-2.0.gir +1849 -80
- data/vendor/local/share/gobject-introspection-1.0/tests/annotation.c +1 -1
- data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +19 -16
- data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.h +1 -1
- data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +3 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +2 -2
- data/vendor/local/share/man/man1/g-ir-compiler.1 +1 -2
- data/vendor/local/share/man/man1/g-ir-generate.1 +2 -3
- metadata +5 -4
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2012-
|
3
|
+
* Copyright (C) 2012-2015 Ruby-GNOME2 Project Team
|
4
4
|
*
|
5
5
|
* This library is free software; you can redistribute it and/or
|
6
6
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -22,12 +22,235 @@
|
|
22
22
|
|
23
23
|
static VALUE rb_cGLibValue = Qnil;
|
24
24
|
|
25
|
+
static VALUE
|
26
|
+
interface_struct_to_ruby(gpointer object,
|
27
|
+
gboolean duplicate,
|
28
|
+
G_GNUC_UNUSED GITypeInfo *type_info,
|
29
|
+
GIBaseInfo *interface_info)
|
30
|
+
{
|
31
|
+
const char *namespace;
|
32
|
+
const char *name;
|
33
|
+
VALUE rb_module;
|
34
|
+
VALUE rb_class;
|
35
|
+
gpointer target_object = object;
|
36
|
+
RUBY_DATA_FUNC free_func = NULL;
|
37
|
+
|
38
|
+
namespace = g_base_info_get_namespace(interface_info);
|
39
|
+
name = g_base_info_get_name(interface_info);
|
40
|
+
rb_module = rb_const_get(rb_cObject, rb_intern(namespace));
|
41
|
+
rb_class = rb_const_get(rb_module, rb_intern(name));
|
42
|
+
if (duplicate) {
|
43
|
+
size_t object_size;
|
44
|
+
object_size = g_struct_info_get_size(interface_info);
|
45
|
+
target_object = xmalloc(object_size);
|
46
|
+
memcpy(target_object, object, object_size);
|
47
|
+
free_func = xfree;
|
48
|
+
}
|
49
|
+
return Data_Wrap_Struct(rb_class, NULL, free_func, target_object);
|
50
|
+
}
|
51
|
+
|
52
|
+
static gpointer
|
53
|
+
interface_struct_from_ruby(VALUE rb_object)
|
54
|
+
{
|
55
|
+
return DATA_PTR(rb_object);
|
56
|
+
}
|
57
|
+
|
58
|
+
static void
|
59
|
+
array_c_to_ruby_sized_interface(gconstpointer *elements,
|
60
|
+
gint64 n_elements,
|
61
|
+
GITypeInfo *element_type_info,
|
62
|
+
VALUE rb_array)
|
63
|
+
{
|
64
|
+
gint64 i;
|
65
|
+
GIBaseInfo *interface_info;
|
66
|
+
GIInfoType interface_type;
|
67
|
+
GType gtype;
|
68
|
+
const char *interface_name;
|
69
|
+
|
70
|
+
interface_info = g_type_info_get_interface(element_type_info);
|
71
|
+
interface_type = g_base_info_get_type(interface_info);
|
72
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
73
|
+
|
74
|
+
switch (interface_type) {
|
75
|
+
case GI_INFO_TYPE_INVALID:
|
76
|
+
case GI_INFO_TYPE_FUNCTION:
|
77
|
+
case GI_INFO_TYPE_CALLBACK:
|
78
|
+
interface_name = g_info_type_to_string(interface_type);
|
79
|
+
g_base_info_unref(interface_info);
|
80
|
+
g_base_info_unref(element_type_info);
|
81
|
+
rb_raise(rb_eNotImpError,
|
82
|
+
"TODO: GIArgument(array)[c][interface(%s)](%s) -> Ruby",
|
83
|
+
interface_name,
|
84
|
+
g_type_name(gtype));
|
85
|
+
break;
|
86
|
+
case GI_INFO_TYPE_STRUCT:
|
87
|
+
if (gtype == G_TYPE_NONE) {
|
88
|
+
for (i = 0; i < n_elements; i++) {
|
89
|
+
rb_ary_push(rb_array,
|
90
|
+
interface_struct_to_ruby((gpointer)elements[i],
|
91
|
+
FALSE,
|
92
|
+
element_type_info,
|
93
|
+
interface_info));
|
94
|
+
}
|
95
|
+
g_base_info_unref(interface_info);
|
96
|
+
g_base_info_unref(element_type_info);
|
97
|
+
} else {
|
98
|
+
interface_name = g_info_type_to_string(interface_type);
|
99
|
+
g_base_info_unref(interface_info);
|
100
|
+
g_base_info_unref(element_type_info);
|
101
|
+
rb_raise(rb_eNotImpError,
|
102
|
+
"TODO: GIArgument(array)[c][interface(%s)](%s) -> Ruby",
|
103
|
+
interface_name,
|
104
|
+
g_type_name(gtype));
|
105
|
+
}
|
106
|
+
break;
|
107
|
+
case GI_INFO_TYPE_BOXED:
|
108
|
+
case GI_INFO_TYPE_ENUM:
|
109
|
+
case GI_INFO_TYPE_FLAGS:
|
110
|
+
interface_name = g_info_type_to_string(interface_type);
|
111
|
+
g_base_info_unref(interface_info);
|
112
|
+
g_base_info_unref(element_type_info);
|
113
|
+
rb_raise(rb_eNotImpError,
|
114
|
+
"TODO: GIArgument(array)[c][interface(%s)](%s) -> Ruby",
|
115
|
+
interface_name,
|
116
|
+
g_type_name(gtype));
|
117
|
+
break;
|
118
|
+
case GI_INFO_TYPE_OBJECT:
|
119
|
+
for (i = 0; i < n_elements; i++) {
|
120
|
+
rb_ary_push(rb_array, GOBJ2RVAL((GObject *)(elements[i])));
|
121
|
+
}
|
122
|
+
g_base_info_unref(interface_info);
|
123
|
+
g_base_info_unref(element_type_info);
|
124
|
+
break;
|
125
|
+
case GI_INFO_TYPE_INTERFACE:
|
126
|
+
case GI_INFO_TYPE_CONSTANT:
|
127
|
+
case GI_INFO_TYPE_INVALID_0:
|
128
|
+
case GI_INFO_TYPE_UNION:
|
129
|
+
case GI_INFO_TYPE_VALUE:
|
130
|
+
case GI_INFO_TYPE_SIGNAL:
|
131
|
+
case GI_INFO_TYPE_VFUNC:
|
132
|
+
case GI_INFO_TYPE_PROPERTY:
|
133
|
+
case GI_INFO_TYPE_FIELD:
|
134
|
+
case GI_INFO_TYPE_ARG:
|
135
|
+
case GI_INFO_TYPE_TYPE:
|
136
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
137
|
+
interface_name = g_info_type_to_string(interface_type);
|
138
|
+
g_base_info_unref(interface_info);
|
139
|
+
g_base_info_unref(element_type_info);
|
140
|
+
rb_raise(rb_eNotImpError,
|
141
|
+
"TODO: GIArgument(array)[c][interface(%s)](%s) -> Ruby",
|
142
|
+
interface_name,
|
143
|
+
g_type_name(gtype));
|
144
|
+
break;
|
145
|
+
default:
|
146
|
+
g_base_info_unref(interface_info);
|
147
|
+
g_base_info_unref(element_type_info);
|
148
|
+
g_assert_not_reached();
|
149
|
+
break;
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
static void
|
154
|
+
array_c_to_ruby_sized(gconstpointer *elements,
|
155
|
+
gint64 n_elements,
|
156
|
+
GITypeInfo *type_info,
|
157
|
+
VALUE rb_array)
|
158
|
+
{
|
159
|
+
gint64 i;
|
160
|
+
GITypeInfo *element_type_info;
|
161
|
+
GITypeTag element_type_tag;
|
162
|
+
|
163
|
+
element_type_info = g_type_info_get_param_type(type_info, 0);
|
164
|
+
element_type_tag = g_type_info_get_tag(element_type_info);
|
165
|
+
|
166
|
+
switch (element_type_tag) {
|
167
|
+
case GI_TYPE_TAG_VOID:
|
168
|
+
case GI_TYPE_TAG_BOOLEAN:
|
169
|
+
case GI_TYPE_TAG_INT8:
|
170
|
+
g_base_info_unref(element_type_info);
|
171
|
+
rb_raise(rb_eNotImpError,
|
172
|
+
"TODO: GIArgument(array)[c][%s] -> Ruby",
|
173
|
+
g_type_tag_to_string(element_type_tag));
|
174
|
+
break;
|
175
|
+
case GI_TYPE_TAG_UINT8:
|
176
|
+
g_base_info_unref(element_type_info);
|
177
|
+
{
|
178
|
+
const guint8 *numbers = (const guint8 *)elements;
|
179
|
+
for (i = 0; i < n_elements; i++) {
|
180
|
+
rb_ary_push(rb_array, UINT2NUM(numbers[i]));
|
181
|
+
}
|
182
|
+
}
|
183
|
+
break;
|
184
|
+
case GI_TYPE_TAG_INT16:
|
185
|
+
case GI_TYPE_TAG_UINT16:
|
186
|
+
g_base_info_unref(element_type_info);
|
187
|
+
rb_raise(rb_eNotImpError,
|
188
|
+
"TODO: GIArgument(array)[c][%s] -> Ruby",
|
189
|
+
g_type_tag_to_string(element_type_tag));
|
190
|
+
break;
|
191
|
+
case GI_TYPE_TAG_INT32:
|
192
|
+
g_base_info_unref(element_type_info);
|
193
|
+
{
|
194
|
+
const gint8 *numbers = (const gint8 *)elements;
|
195
|
+
for (i = 0; i < n_elements; i++) {
|
196
|
+
rb_ary_push(rb_array, INT2NUM(numbers[i]));
|
197
|
+
}
|
198
|
+
}
|
199
|
+
break;
|
200
|
+
case GI_TYPE_TAG_UINT32:
|
201
|
+
case GI_TYPE_TAG_INT64:
|
202
|
+
case GI_TYPE_TAG_UINT64:
|
203
|
+
case GI_TYPE_TAG_FLOAT:
|
204
|
+
case GI_TYPE_TAG_DOUBLE:
|
205
|
+
case GI_TYPE_TAG_GTYPE:
|
206
|
+
g_base_info_unref(element_type_info);
|
207
|
+
rb_raise(rb_eNotImpError,
|
208
|
+
"TODO: GIArgument(array)[c][%s] -> Ruby",
|
209
|
+
g_type_tag_to_string(element_type_tag));
|
210
|
+
break;
|
211
|
+
case GI_TYPE_TAG_UTF8:
|
212
|
+
g_base_info_unref(element_type_info);
|
213
|
+
{
|
214
|
+
const gchar **strings = (const gchar **)elements;
|
215
|
+
for (i = 0; i < n_elements; i++) {
|
216
|
+
rb_ary_push(rb_array, CSTR2RVAL(strings[i]));
|
217
|
+
}
|
218
|
+
}
|
219
|
+
break;
|
220
|
+
case GI_TYPE_TAG_FILENAME:
|
221
|
+
case GI_TYPE_TAG_ARRAY:
|
222
|
+
g_base_info_unref(element_type_info);
|
223
|
+
rb_raise(rb_eNotImpError,
|
224
|
+
"TODO: GIArgument(array)[c][%s] -> Ruby",
|
225
|
+
g_type_tag_to_string(element_type_tag));
|
226
|
+
break;
|
227
|
+
case GI_TYPE_TAG_INTERFACE:
|
228
|
+
array_c_to_ruby_sized_interface(elements, n_elements, element_type_info,
|
229
|
+
rb_array);
|
230
|
+
break;
|
231
|
+
case GI_TYPE_TAG_GLIST:
|
232
|
+
case GI_TYPE_TAG_GSLIST:
|
233
|
+
case GI_TYPE_TAG_GHASH:
|
234
|
+
case GI_TYPE_TAG_ERROR:
|
235
|
+
case GI_TYPE_TAG_UNICHAR:
|
236
|
+
g_base_info_unref(element_type_info);
|
237
|
+
rb_raise(rb_eNotImpError,
|
238
|
+
"TODO: GIArgument(array)[c][%s] -> Ruby",
|
239
|
+
g_type_tag_to_string(element_type_tag));
|
240
|
+
break;
|
241
|
+
default:
|
242
|
+
g_base_info_unref(element_type_info);
|
243
|
+
g_assert_not_reached();
|
244
|
+
break;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
25
248
|
static void
|
26
249
|
array_c_to_ruby(GIArgument *array, GITypeInfo *type_info, gint64 n_elements,
|
27
250
|
VALUE rb_array)
|
28
251
|
{
|
29
|
-
|
30
|
-
|
252
|
+
gconstpointer *elements;
|
253
|
+
gint fixed_size;
|
31
254
|
gboolean zero_terminated_p;
|
32
255
|
|
33
256
|
elements = array->v_pointer;
|
@@ -35,29 +258,181 @@ array_c_to_ruby(GIArgument *array, GITypeInfo *type_info, gint64 n_elements,
|
|
35
258
|
return;
|
36
259
|
}
|
37
260
|
|
38
|
-
|
261
|
+
fixed_size = g_type_info_get_array_fixed_size(type_info);
|
39
262
|
zero_terminated_p = g_type_info_is_zero_terminated(type_info);
|
263
|
+
|
40
264
|
if (n_elements != -1) {
|
41
|
-
|
42
|
-
for (i = 0; i < n_elements; i++) {
|
43
|
-
rb_ary_push(rb_array, CSTR2RVAL(elements[i]));
|
44
|
-
}
|
265
|
+
array_c_to_ruby_sized(elements, n_elements, type_info, rb_array);
|
45
266
|
} else if (zero_terminated_p) {
|
46
|
-
|
47
|
-
|
267
|
+
const gchar **strings = (const gchar **)elements;
|
268
|
+
for (; *strings; strings++) {
|
269
|
+
rb_ary_push(rb_array, CSTR2RVAL(*strings));
|
48
270
|
}
|
49
271
|
} else {
|
50
272
|
rb_raise(rb_eNotImpError,
|
51
273
|
"TODO: GIArgument(array)[c] -> Ruby: "
|
52
274
|
"zero-terminated: %s "
|
53
|
-
"fixed-size: %
|
275
|
+
"fixed-size: %d "
|
54
276
|
"length: %" G_GINT64_FORMAT,
|
55
277
|
zero_terminated_p ? "true" : "false",
|
56
|
-
|
278
|
+
fixed_size,
|
57
279
|
n_elements);
|
58
280
|
}
|
59
281
|
}
|
60
282
|
|
283
|
+
static void
|
284
|
+
array_array_interface_to_ruby(GIArgument *array,
|
285
|
+
G_GNUC_UNUSED GITypeInfo *array_type_info,
|
286
|
+
GITypeInfo *element_type_info,
|
287
|
+
VALUE rb_array)
|
288
|
+
{
|
289
|
+
GArray *elements;
|
290
|
+
GIBaseInfo *interface_info;
|
291
|
+
GIInfoType interface_type;
|
292
|
+
GType gtype;
|
293
|
+
const char *interface_name;
|
294
|
+
|
295
|
+
elements = array->v_pointer;
|
296
|
+
|
297
|
+
interface_info = g_type_info_get_interface(element_type_info);
|
298
|
+
interface_type = g_base_info_get_type(interface_info);
|
299
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
300
|
+
|
301
|
+
switch (interface_type) {
|
302
|
+
case GI_INFO_TYPE_INVALID:
|
303
|
+
case GI_INFO_TYPE_FUNCTION:
|
304
|
+
case GI_INFO_TYPE_CALLBACK:
|
305
|
+
interface_name = g_info_type_to_string(interface_type);
|
306
|
+
g_base_info_unref(interface_info);
|
307
|
+
g_base_info_unref(element_type_info);
|
308
|
+
rb_raise(rb_eNotImpError,
|
309
|
+
"TODO: GIArgument(array)[array][interface(%s)](%s) -> Ruby",
|
310
|
+
interface_name,
|
311
|
+
g_type_name(gtype));
|
312
|
+
break;
|
313
|
+
case GI_INFO_TYPE_STRUCT:
|
314
|
+
if (gtype == G_TYPE_NONE) {
|
315
|
+
guint i;
|
316
|
+
guint element_size;
|
317
|
+
|
318
|
+
element_size = g_array_get_element_size(elements);
|
319
|
+
for (i = 0; i < elements->len; i++) {
|
320
|
+
gpointer element;
|
321
|
+
element = elements->data + (element_size * i);
|
322
|
+
rb_ary_push(rb_array,
|
323
|
+
interface_struct_to_ruby(element,
|
324
|
+
TRUE,
|
325
|
+
element_type_info,
|
326
|
+
interface_info));
|
327
|
+
}
|
328
|
+
} else {
|
329
|
+
interface_name = g_info_type_to_string(interface_type);
|
330
|
+
g_base_info_unref(interface_info);
|
331
|
+
g_base_info_unref(element_type_info);
|
332
|
+
rb_raise(rb_eNotImpError,
|
333
|
+
"TODO: GIArgument(array)[array][interface(%s)](%s) -> Ruby",
|
334
|
+
interface_name,
|
335
|
+
g_type_name(gtype));
|
336
|
+
}
|
337
|
+
break;
|
338
|
+
case GI_INFO_TYPE_BOXED:
|
339
|
+
case GI_INFO_TYPE_ENUM:
|
340
|
+
case GI_INFO_TYPE_FLAGS:
|
341
|
+
case GI_INFO_TYPE_OBJECT:
|
342
|
+
case GI_INFO_TYPE_INTERFACE:
|
343
|
+
case GI_INFO_TYPE_CONSTANT:
|
344
|
+
case GI_INFO_TYPE_INVALID_0:
|
345
|
+
case GI_INFO_TYPE_UNION:
|
346
|
+
case GI_INFO_TYPE_VALUE:
|
347
|
+
case GI_INFO_TYPE_SIGNAL:
|
348
|
+
case GI_INFO_TYPE_VFUNC:
|
349
|
+
case GI_INFO_TYPE_PROPERTY:
|
350
|
+
case GI_INFO_TYPE_FIELD:
|
351
|
+
case GI_INFO_TYPE_ARG:
|
352
|
+
case GI_INFO_TYPE_TYPE:
|
353
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
354
|
+
interface_name = g_info_type_to_string(interface_type);
|
355
|
+
g_base_info_unref(interface_info);
|
356
|
+
g_base_info_unref(element_type_info);
|
357
|
+
rb_raise(rb_eNotImpError,
|
358
|
+
"TODO: GIArgument(array)[array][interface(%s)](%s) -> Ruby",
|
359
|
+
interface_name,
|
360
|
+
g_type_name(gtype));
|
361
|
+
break;
|
362
|
+
default:
|
363
|
+
g_base_info_unref(interface_info);
|
364
|
+
g_base_info_unref(element_type_info);
|
365
|
+
g_assert_not_reached();
|
366
|
+
break;
|
367
|
+
}
|
368
|
+
|
369
|
+
g_base_info_unref(interface_info);
|
370
|
+
}
|
371
|
+
|
372
|
+
static void
|
373
|
+
array_array_to_ruby(GIArgument *array,
|
374
|
+
GITypeInfo *array_type_info,
|
375
|
+
VALUE rb_array)
|
376
|
+
{
|
377
|
+
GITypeInfo *element_type_info;
|
378
|
+
GITypeTag element_type_tag;
|
379
|
+
GArray *elements;
|
380
|
+
|
381
|
+
elements = array->v_pointer;
|
382
|
+
if (!elements) {
|
383
|
+
return;
|
384
|
+
}
|
385
|
+
|
386
|
+
element_type_info = g_type_info_get_param_type(array_type_info, 0);
|
387
|
+
element_type_tag = g_type_info_get_tag(element_type_info);
|
388
|
+
|
389
|
+
switch (element_type_tag) {
|
390
|
+
case GI_TYPE_TAG_VOID:
|
391
|
+
case GI_TYPE_TAG_BOOLEAN:
|
392
|
+
case GI_TYPE_TAG_INT8:
|
393
|
+
case GI_TYPE_TAG_UINT8:
|
394
|
+
case GI_TYPE_TAG_INT16:
|
395
|
+
case GI_TYPE_TAG_UINT16:
|
396
|
+
case GI_TYPE_TAG_INT32:
|
397
|
+
case GI_TYPE_TAG_UINT32:
|
398
|
+
case GI_TYPE_TAG_INT64:
|
399
|
+
case GI_TYPE_TAG_UINT64:
|
400
|
+
case GI_TYPE_TAG_FLOAT:
|
401
|
+
case GI_TYPE_TAG_DOUBLE:
|
402
|
+
case GI_TYPE_TAG_GTYPE:
|
403
|
+
case GI_TYPE_TAG_UTF8:
|
404
|
+
case GI_TYPE_TAG_FILENAME:
|
405
|
+
case GI_TYPE_TAG_ARRAY:
|
406
|
+
g_base_info_unref(element_type_info);
|
407
|
+
rb_raise(rb_eNotImpError,
|
408
|
+
"TODO: GIArgument(array)[array][%s] -> Ruby",
|
409
|
+
g_type_tag_to_string(element_type_tag));
|
410
|
+
break;
|
411
|
+
case GI_TYPE_TAG_INTERFACE:
|
412
|
+
array_array_interface_to_ruby(array,
|
413
|
+
array_type_info,
|
414
|
+
element_type_info,
|
415
|
+
rb_array);
|
416
|
+
break;
|
417
|
+
case GI_TYPE_TAG_GLIST:
|
418
|
+
case GI_TYPE_TAG_GSLIST:
|
419
|
+
case GI_TYPE_TAG_GHASH:
|
420
|
+
case GI_TYPE_TAG_ERROR:
|
421
|
+
case GI_TYPE_TAG_UNICHAR:
|
422
|
+
g_base_info_unref(element_type_info);
|
423
|
+
rb_raise(rb_eNotImpError,
|
424
|
+
"TODO: GIArgument(array)[array][%s] -> Ruby",
|
425
|
+
g_type_tag_to_string(element_type_tag));
|
426
|
+
break;
|
427
|
+
default:
|
428
|
+
g_base_info_unref(element_type_info);
|
429
|
+
g_assert_not_reached();
|
430
|
+
break;
|
431
|
+
}
|
432
|
+
|
433
|
+
g_base_info_unref(element_type_info);
|
434
|
+
}
|
435
|
+
|
61
436
|
static gint64
|
62
437
|
get_array_length(GIArgument *argument, GITypeInfo *type_info)
|
63
438
|
{
|
@@ -70,53 +445,53 @@ get_array_length(GIArgument *argument, GITypeInfo *type_info)
|
|
70
445
|
|
71
446
|
type_tag = g_type_info_get_tag(type_info);
|
72
447
|
switch (type_tag) {
|
73
|
-
|
74
|
-
|
448
|
+
case GI_TYPE_TAG_VOID:
|
449
|
+
case GI_TYPE_TAG_BOOLEAN:
|
75
450
|
rb_raise(rb_eNotImpError,
|
76
451
|
"TODO: invalid array length argument?: <%s>",
|
77
452
|
g_type_tag_to_string(type_tag));
|
78
453
|
break;
|
79
|
-
|
454
|
+
case GI_TYPE_TAG_INT8:
|
80
455
|
length = argument->v_int8;
|
81
456
|
break;
|
82
|
-
|
457
|
+
case GI_TYPE_TAG_UINT8:
|
83
458
|
length = argument->v_uint8;
|
84
459
|
break;
|
85
|
-
|
460
|
+
case GI_TYPE_TAG_INT16:
|
86
461
|
length = argument->v_int16;
|
87
462
|
break;
|
88
|
-
|
463
|
+
case GI_TYPE_TAG_UINT16:
|
89
464
|
length = argument->v_uint16;
|
90
465
|
break;
|
91
|
-
|
466
|
+
case GI_TYPE_TAG_INT32:
|
92
467
|
length = argument->v_int32;
|
93
468
|
break;
|
94
|
-
|
469
|
+
case GI_TYPE_TAG_UINT32:
|
95
470
|
length = argument->v_uint32;
|
96
471
|
break;
|
97
|
-
|
472
|
+
case GI_TYPE_TAG_INT64:
|
98
473
|
length = argument->v_int64;
|
99
474
|
break;
|
100
|
-
|
475
|
+
case GI_TYPE_TAG_UINT64:
|
101
476
|
length = argument->v_uint64;
|
102
477
|
break;
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
478
|
+
case GI_TYPE_TAG_FLOAT:
|
479
|
+
case GI_TYPE_TAG_DOUBLE:
|
480
|
+
case GI_TYPE_TAG_GTYPE:
|
481
|
+
case GI_TYPE_TAG_UTF8:
|
482
|
+
case GI_TYPE_TAG_FILENAME:
|
483
|
+
case GI_TYPE_TAG_ARRAY:
|
484
|
+
case GI_TYPE_TAG_INTERFACE:
|
485
|
+
case GI_TYPE_TAG_GLIST:
|
486
|
+
case GI_TYPE_TAG_GSLIST:
|
487
|
+
case GI_TYPE_TAG_GHASH:
|
488
|
+
case GI_TYPE_TAG_ERROR:
|
489
|
+
case GI_TYPE_TAG_UNICHAR:
|
115
490
|
rb_raise(rb_eNotImpError,
|
116
491
|
"TODO: invalid array length argument?: <%s>",
|
117
492
|
g_type_tag_to_string(type_tag));
|
118
493
|
break;
|
119
|
-
|
494
|
+
default:
|
120
495
|
g_assert_not_reached();
|
121
496
|
break;
|
122
497
|
}
|
@@ -124,7 +499,7 @@ get_array_length(GIArgument *argument, GITypeInfo *type_info)
|
|
124
499
|
return length;
|
125
500
|
}
|
126
501
|
|
127
|
-
VALUE
|
502
|
+
static VALUE
|
128
503
|
rb_gi_array_argument_to_ruby(GIArgument *array_argument,
|
129
504
|
GIArgument *length_argument,
|
130
505
|
GITypeInfo *array_type_info,
|
@@ -142,19 +517,19 @@ rb_gi_array_argument_to_ruby(GIArgument *array_argument,
|
|
142
517
|
rb_array = rb_ary_new2(n_elements);
|
143
518
|
}
|
144
519
|
switch (array_type) {
|
145
|
-
|
520
|
+
case GI_ARRAY_TYPE_C:
|
146
521
|
array_c_to_ruby(array_argument, array_type_info, n_elements, rb_array);
|
147
522
|
break;
|
148
|
-
|
149
|
-
|
523
|
+
case GI_ARRAY_TYPE_ARRAY:
|
524
|
+
array_array_to_ruby(array_argument, array_type_info, rb_array);
|
150
525
|
break;
|
151
|
-
|
526
|
+
case GI_ARRAY_TYPE_PTR_ARRAY:
|
152
527
|
rb_raise(rb_eNotImpError, "TODO: GIArgument(array)[ptr-array] -> Ruby");
|
153
528
|
break;
|
154
|
-
|
529
|
+
case GI_ARRAY_TYPE_BYTE_ARRAY:
|
155
530
|
rb_raise(rb_eNotImpError, "TODO: GIArgument(array)[byte-array] -> Ruby");
|
156
531
|
break;
|
157
|
-
|
532
|
+
default:
|
158
533
|
g_assert_not_reached();
|
159
534
|
break;
|
160
535
|
}
|
@@ -163,7 +538,30 @@ rb_gi_array_argument_to_ruby(GIArgument *array_argument,
|
|
163
538
|
}
|
164
539
|
|
165
540
|
static VALUE
|
166
|
-
|
541
|
+
interface_variant_to_ruby(GVariant *variant)
|
542
|
+
{
|
543
|
+
VALUE rb_value = Qnil;
|
544
|
+
const GVariantType *type;
|
545
|
+
|
546
|
+
type = g_variant_get_type(variant);
|
547
|
+
if (g_variant_type_equal(type, G_VARIANT_TYPE_STRING)) {
|
548
|
+
const char *value;
|
549
|
+
g_variant_get(variant, "s", &value);
|
550
|
+
rb_value = CSTR2RVAL(value);
|
551
|
+
} else {
|
552
|
+
rb_raise(rb_eNotImpError,
|
553
|
+
"TODO: GIArgument(interface)[GVariant][%.*s] -> Ruby",
|
554
|
+
(int)g_variant_type_get_string_length(type),
|
555
|
+
g_variant_type_peek_string(type));
|
556
|
+
}
|
557
|
+
|
558
|
+
return rb_value;
|
559
|
+
}
|
560
|
+
|
561
|
+
static VALUE
|
562
|
+
interface_to_ruby(GIArgument *argument,
|
563
|
+
gboolean duplicate,
|
564
|
+
GITypeInfo *type_info)
|
167
565
|
{
|
168
566
|
VALUE rb_interface;
|
169
567
|
GIBaseInfo *interface_info;
|
@@ -175,96 +573,104 @@ interface_to_ruby(GIArgument *argument, GITypeInfo *type_info)
|
|
175
573
|
|
176
574
|
gtype = g_registered_type_info_get_g_type(interface_info);
|
177
575
|
switch (interface_type) {
|
178
|
-
|
576
|
+
case GI_INFO_TYPE_INVALID:
|
179
577
|
rb_raise(rb_eNotImpError,
|
180
578
|
"TODO: GIArgument(interface)[invalid] -> Ruby");
|
181
579
|
break;
|
182
|
-
|
580
|
+
case GI_INFO_TYPE_FUNCTION:
|
183
581
|
rb_raise(rb_eNotImpError,
|
184
582
|
"TODO: GIArgument(interface)[function] -> Ruby");
|
185
583
|
break;
|
186
|
-
|
584
|
+
case GI_INFO_TYPE_CALLBACK:
|
187
585
|
rb_raise(rb_eNotImpError,
|
188
586
|
"TODO: GIArgument(interface)[callback] -> Ruby");
|
189
587
|
break;
|
190
|
-
|
191
|
-
if (gtype ==
|
588
|
+
case GI_INFO_TYPE_STRUCT:
|
589
|
+
if (gtype == G_TYPE_NONE) {
|
590
|
+
rb_interface = interface_struct_to_ruby(argument->v_pointer,
|
591
|
+
duplicate,
|
592
|
+
type_info,
|
593
|
+
interface_info);
|
594
|
+
} else if (gtype == G_TYPE_BYTES) {
|
192
595
|
GBytes *bytes = argument->v_pointer;
|
193
596
|
gconstpointer data;
|
194
597
|
gsize size;
|
195
598
|
data = g_bytes_get_data(bytes, &size);
|
196
599
|
rb_interface = rb_enc_str_new(data, size, rb_ascii8bit_encoding());
|
600
|
+
} else if (gtype == G_TYPE_VARIANT) {
|
601
|
+
GVariant *variant = argument->v_pointer;
|
602
|
+
rb_interface = interface_variant_to_ruby(variant);
|
197
603
|
} else {
|
198
604
|
rb_interface = BOXED2RVAL(argument->v_pointer, gtype);
|
199
605
|
}
|
200
606
|
break;
|
201
|
-
|
607
|
+
case GI_INFO_TYPE_BOXED:
|
202
608
|
rb_raise(rb_eNotImpError,
|
203
609
|
"TODO: GIArgument(interface)[boxed] -> Ruby");
|
204
610
|
break;
|
205
|
-
|
611
|
+
case GI_INFO_TYPE_ENUM:
|
206
612
|
if (gtype == G_TYPE_NONE) {
|
207
613
|
rb_interface = INT2NUM(argument->v_int32);
|
208
614
|
} else {
|
209
615
|
rb_interface = GENUM2RVAL(argument->v_int32, gtype);
|
210
616
|
}
|
211
617
|
break;
|
212
|
-
|
618
|
+
case GI_INFO_TYPE_FLAGS:
|
213
619
|
if (gtype == G_TYPE_NONE) {
|
214
620
|
rb_interface = INT2NUM(argument->v_int32);
|
215
621
|
} else {
|
216
622
|
rb_interface = GFLAGS2RVAL(argument->v_int32, gtype);
|
217
623
|
}
|
218
624
|
break;
|
219
|
-
|
625
|
+
case GI_INFO_TYPE_OBJECT:
|
220
626
|
rb_interface = GOBJ2RVAL(argument->v_pointer);
|
221
627
|
break;
|
222
|
-
|
628
|
+
case GI_INFO_TYPE_INTERFACE:
|
223
629
|
rb_interface = GOBJ2RVAL(argument->v_pointer);
|
224
630
|
break;
|
225
|
-
|
631
|
+
case GI_INFO_TYPE_CONSTANT:
|
226
632
|
rb_raise(rb_eNotImpError,
|
227
633
|
"TODO: GIArgument(interface)[constant] -> Ruby");
|
228
634
|
break;
|
229
|
-
|
635
|
+
case GI_INFO_TYPE_INVALID_0:
|
230
636
|
g_assert_not_reached();
|
231
637
|
break;
|
232
|
-
|
638
|
+
case GI_INFO_TYPE_UNION:
|
233
639
|
rb_interface = BOXED2RVAL(argument->v_pointer, gtype);
|
234
640
|
break;
|
235
|
-
|
641
|
+
case GI_INFO_TYPE_VALUE:
|
236
642
|
rb_raise(rb_eNotImpError,
|
237
643
|
"TODO: GIArgument(interface)[value] -> Ruby");
|
238
644
|
break;
|
239
|
-
|
645
|
+
case GI_INFO_TYPE_SIGNAL:
|
240
646
|
rb_raise(rb_eNotImpError,
|
241
647
|
"TODO: GIArgument(interface)[signal] -> Ruby");
|
242
648
|
break;
|
243
|
-
|
649
|
+
case GI_INFO_TYPE_VFUNC:
|
244
650
|
rb_raise(rb_eNotImpError,
|
245
651
|
"TODO: GIArgument(interface)[vfunc] -> Ruby");
|
246
652
|
break;
|
247
|
-
|
653
|
+
case GI_INFO_TYPE_PROPERTY:
|
248
654
|
rb_raise(rb_eNotImpError,
|
249
655
|
"TODO: GIArgument(interface)[property] -> Ruby");
|
250
656
|
break;
|
251
|
-
|
657
|
+
case GI_INFO_TYPE_FIELD:
|
252
658
|
rb_raise(rb_eNotImpError,
|
253
659
|
"TODO: GIArgument(interface)[field] -> Ruby");
|
254
660
|
break;
|
255
|
-
|
661
|
+
case GI_INFO_TYPE_ARG:
|
256
662
|
rb_raise(rb_eNotImpError,
|
257
663
|
"TODO: GIArgument(interface)[arg] -> Ruby");
|
258
664
|
break;
|
259
|
-
|
665
|
+
case GI_INFO_TYPE_TYPE:
|
260
666
|
rb_raise(rb_eNotImpError,
|
261
667
|
"TODO: GIArgument(interface)[type] -> Ruby");
|
262
668
|
break;
|
263
|
-
|
669
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
264
670
|
rb_raise(rb_eNotImpError,
|
265
671
|
"TODO: GIArgument(interface)[unresolved] -> Ruby");
|
266
672
|
break;
|
267
|
-
|
673
|
+
default:
|
268
674
|
g_assert_not_reached();
|
269
675
|
break;
|
270
676
|
}
|
@@ -274,57 +680,264 @@ interface_to_ruby(GIArgument *argument, GITypeInfo *type_info)
|
|
274
680
|
return rb_interface;
|
275
681
|
}
|
276
682
|
|
277
|
-
static
|
278
|
-
|
683
|
+
static void
|
684
|
+
normalize_out_array_length(GIArgument *normalized_argument,
|
685
|
+
GIArgument *argument,
|
686
|
+
GITypeInfo *type_info)
|
279
687
|
{
|
280
|
-
|
281
|
-
GITypeInfo *element_type_info;
|
282
|
-
GITypeTag element_type_tag;
|
283
|
-
|
284
|
-
element_type_info = g_type_info_get_param_type(type_info, 0);
|
285
|
-
element_type_tag = g_type_info_get_tag(element_type_info);
|
286
|
-
g_base_info_unref(element_type_info);
|
688
|
+
GITypeTag type_tag;
|
287
689
|
|
288
|
-
|
690
|
+
type_tag = g_type_info_get_tag(type_info);
|
691
|
+
switch (type_tag) {
|
289
692
|
case GI_TYPE_TAG_VOID:
|
290
693
|
case GI_TYPE_TAG_BOOLEAN:
|
694
|
+
rb_raise(rb_eNotImpError,
|
695
|
+
"TODO: invalid out array length argument?: <%s>",
|
696
|
+
g_type_tag_to_string(type_tag));
|
697
|
+
break;
|
291
698
|
case GI_TYPE_TAG_INT8:
|
699
|
+
normalized_argument->v_int8 = *((gint8 *)argument->v_pointer);
|
700
|
+
break;
|
292
701
|
case GI_TYPE_TAG_UINT8:
|
702
|
+
normalized_argument->v_uint8 = *((guint8 *)argument->v_pointer);
|
703
|
+
break;
|
293
704
|
case GI_TYPE_TAG_INT16:
|
705
|
+
normalized_argument->v_int16 = *((gint16 *)argument->v_pointer);
|
706
|
+
break;
|
294
707
|
case GI_TYPE_TAG_UINT16:
|
708
|
+
normalized_argument->v_uint16 = *((guint16 *)argument->v_pointer);
|
709
|
+
break;
|
295
710
|
case GI_TYPE_TAG_INT32:
|
711
|
+
normalized_argument->v_int32 = *((gint32 *)argument->v_pointer);
|
712
|
+
break;
|
296
713
|
case GI_TYPE_TAG_UINT32:
|
714
|
+
normalized_argument->v_uint32 = *((guint32 *)argument->v_pointer);
|
715
|
+
break;
|
297
716
|
case GI_TYPE_TAG_INT64:
|
717
|
+
normalized_argument->v_int64 = *((gint64 *)argument->v_pointer);
|
718
|
+
break;
|
298
719
|
case GI_TYPE_TAG_UINT64:
|
720
|
+
normalized_argument->v_uint64 = *((guint64 *)argument->v_pointer);
|
721
|
+
break;
|
299
722
|
case GI_TYPE_TAG_FLOAT:
|
300
723
|
case GI_TYPE_TAG_DOUBLE:
|
301
724
|
case GI_TYPE_TAG_GTYPE:
|
725
|
+
case GI_TYPE_TAG_UTF8:
|
726
|
+
case GI_TYPE_TAG_FILENAME:
|
727
|
+
case GI_TYPE_TAG_ARRAY:
|
728
|
+
case GI_TYPE_TAG_INTERFACE:
|
729
|
+
case GI_TYPE_TAG_GLIST:
|
730
|
+
case GI_TYPE_TAG_GSLIST:
|
731
|
+
case GI_TYPE_TAG_GHASH:
|
732
|
+
case GI_TYPE_TAG_ERROR:
|
733
|
+
case GI_TYPE_TAG_UNICHAR:
|
734
|
+
rb_raise(rb_eNotImpError,
|
735
|
+
"TODO: invalid out array length argument?: <%s>",
|
736
|
+
g_type_tag_to_string(type_tag));
|
737
|
+
break;
|
738
|
+
default:
|
739
|
+
g_assert_not_reached();
|
740
|
+
break;
|
741
|
+
}
|
742
|
+
}
|
743
|
+
|
744
|
+
static VALUE
|
745
|
+
rb_gi_argument_to_ruby_array(GIArgument *array_argument,
|
746
|
+
GITypeInfo *array_type_info,
|
747
|
+
GArray *in_args,
|
748
|
+
GArray *out_args,
|
749
|
+
GPtrArray *args_metadata)
|
750
|
+
{
|
751
|
+
VALUE rb_array;
|
752
|
+
gint length_index;
|
753
|
+
GIArgument *length_argument = NULL;
|
754
|
+
GIArgument normalized_length_argument;
|
755
|
+
GITypeInfo raw_length_type_info;
|
756
|
+
GITypeInfo *length_type_info = NULL;
|
757
|
+
|
758
|
+
length_index = g_type_info_get_array_length(array_type_info);
|
759
|
+
if (length_index != -1) {
|
760
|
+
RBGIArgMetadata *length_metadata;
|
761
|
+
GIArgInfo *length_arg_info = NULL;
|
762
|
+
GIArgument *raw_length_argument = NULL;
|
763
|
+
|
764
|
+
length_metadata = g_ptr_array_index(args_metadata, length_index);
|
765
|
+
length_arg_info = &(length_metadata->arg_info);
|
766
|
+
|
767
|
+
g_arg_info_load_type(length_arg_info, &raw_length_type_info);
|
768
|
+
length_type_info = &raw_length_type_info;
|
769
|
+
|
770
|
+
if (length_metadata->direction == GI_DIRECTION_OUT) {
|
771
|
+
raw_length_argument = &g_array_index(out_args, GIArgument,
|
772
|
+
length_metadata->out_arg_index);
|
773
|
+
} else if (length_metadata->direction == GI_DIRECTION_INOUT) {
|
774
|
+
raw_length_argument = &g_array_index(in_args, GIArgument,
|
775
|
+
length_metadata->in_arg_index);
|
776
|
+
}
|
777
|
+
|
778
|
+
if (raw_length_argument) {
|
779
|
+
normalize_out_array_length(&normalized_length_argument,
|
780
|
+
raw_length_argument,
|
781
|
+
length_type_info);
|
782
|
+
length_argument = &normalized_length_argument;
|
783
|
+
} else {
|
784
|
+
length_argument = &g_array_index(in_args, GIArgument,
|
785
|
+
length_metadata->in_arg_index);
|
786
|
+
}
|
787
|
+
}
|
788
|
+
|
789
|
+
rb_array = rb_gi_array_argument_to_ruby(array_argument,
|
790
|
+
length_argument,
|
791
|
+
array_type_info,
|
792
|
+
length_type_info);
|
793
|
+
|
794
|
+
return rb_array;
|
795
|
+
}
|
796
|
+
|
797
|
+
static VALUE
|
798
|
+
rb_gi_argument_to_ruby_glist_interface(GIArgument *argument,
|
799
|
+
G_GNUC_UNUSED GITypeInfo *type_info,
|
800
|
+
GITypeInfo *element_type_info)
|
801
|
+
{
|
802
|
+
VALUE rb_argument = Qnil;
|
803
|
+
GIBaseInfo *interface_info;
|
804
|
+
GIInfoType interface_type;
|
805
|
+
const gchar *interface_name;
|
806
|
+
GType gtype;
|
807
|
+
|
808
|
+
interface_info = g_type_info_get_interface(element_type_info);
|
809
|
+
interface_type = g_base_info_get_type(interface_info);
|
810
|
+
interface_name = g_info_type_to_string(interface_type);
|
811
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
812
|
+
|
813
|
+
switch (interface_type) {
|
814
|
+
case GI_INFO_TYPE_INVALID:
|
815
|
+
case GI_INFO_TYPE_FUNCTION:
|
816
|
+
case GI_INFO_TYPE_CALLBACK:
|
817
|
+
g_base_info_unref(interface_info);
|
818
|
+
g_base_info_unref(element_type_info);
|
819
|
+
rb_raise(rb_eNotImpError,
|
820
|
+
"TODO: GIArgument(GList)[interface(%s)](%s) -> Ruby",
|
821
|
+
interface_name,
|
822
|
+
g_type_name(gtype));
|
823
|
+
break;
|
824
|
+
case GI_INFO_TYPE_STRUCT:
|
825
|
+
if (gtype == G_TYPE_NONE) {
|
826
|
+
GList *node;
|
827
|
+
rb_argument = rb_ary_new();
|
828
|
+
for (node = argument->v_pointer; node; node = g_list_next(node)) {
|
829
|
+
rb_ary_push(rb_argument,
|
830
|
+
interface_struct_to_ruby(node->data,
|
831
|
+
FALSE,
|
832
|
+
element_type_info,
|
833
|
+
interface_info));
|
834
|
+
}
|
835
|
+
} else {
|
836
|
+
rb_argument = BOXEDGLIST2RVAL(argument->v_pointer, gtype);
|
837
|
+
}
|
838
|
+
break;
|
839
|
+
case GI_INFO_TYPE_BOXED:
|
840
|
+
rb_argument = BOXEDGLIST2RVAL(argument->v_pointer, gtype);
|
841
|
+
break;
|
842
|
+
case GI_INFO_TYPE_ENUM:
|
843
|
+
case GI_INFO_TYPE_FLAGS:
|
844
|
+
g_base_info_unref(interface_info);
|
845
|
+
g_base_info_unref(element_type_info);
|
846
|
+
rb_raise(rb_eNotImpError,
|
847
|
+
"TODO: GIArgument(GList)[interface(%s)](%s) -> Ruby",
|
848
|
+
interface_name,
|
849
|
+
g_type_name(gtype));
|
850
|
+
break;
|
851
|
+
case GI_INFO_TYPE_OBJECT:
|
852
|
+
case GI_INFO_TYPE_INTERFACE:
|
853
|
+
rb_argument = GOBJGLIST2RVAL(argument->v_pointer);
|
854
|
+
break;
|
855
|
+
case GI_INFO_TYPE_CONSTANT:
|
856
|
+
case GI_INFO_TYPE_INVALID_0:
|
857
|
+
case GI_INFO_TYPE_UNION:
|
858
|
+
case GI_INFO_TYPE_VALUE:
|
859
|
+
case GI_INFO_TYPE_SIGNAL:
|
860
|
+
case GI_INFO_TYPE_VFUNC:
|
861
|
+
case GI_INFO_TYPE_PROPERTY:
|
862
|
+
case GI_INFO_TYPE_FIELD:
|
863
|
+
case GI_INFO_TYPE_ARG:
|
864
|
+
case GI_INFO_TYPE_TYPE:
|
865
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
866
|
+
g_base_info_unref(interface_info);
|
867
|
+
g_base_info_unref(element_type_info);
|
868
|
+
rb_raise(rb_eNotImpError,
|
869
|
+
"TODO: GIArgument(GList)[interface(%s)](%s) -> Ruby",
|
870
|
+
interface_name,
|
871
|
+
g_type_name(gtype));
|
872
|
+
break;
|
873
|
+
default:
|
874
|
+
g_assert_not_reached();
|
875
|
+
break;
|
876
|
+
}
|
877
|
+
|
878
|
+
g_base_info_unref(interface_info);
|
879
|
+
g_base_info_unref(element_type_info);
|
880
|
+
|
881
|
+
return rb_argument;
|
882
|
+
}
|
883
|
+
|
884
|
+
static VALUE
|
885
|
+
rb_gi_argument_to_ruby_glist(GIArgument *argument, GITypeInfo *type_info)
|
886
|
+
{
|
887
|
+
VALUE rb_argument;
|
888
|
+
GITypeInfo *element_type_info;
|
889
|
+
GITypeTag element_type_tag;
|
890
|
+
|
891
|
+
element_type_info = g_type_info_get_param_type(type_info, 0);
|
892
|
+
element_type_tag = g_type_info_get_tag(element_type_info);
|
893
|
+
|
894
|
+
switch (element_type_tag) {
|
895
|
+
case GI_TYPE_TAG_VOID:
|
896
|
+
case GI_TYPE_TAG_BOOLEAN:
|
897
|
+
case GI_TYPE_TAG_INT8:
|
898
|
+
case GI_TYPE_TAG_UINT8:
|
899
|
+
case GI_TYPE_TAG_INT16:
|
900
|
+
case GI_TYPE_TAG_UINT16:
|
901
|
+
case GI_TYPE_TAG_INT32:
|
902
|
+
case GI_TYPE_TAG_UINT32:
|
903
|
+
case GI_TYPE_TAG_INT64:
|
904
|
+
case GI_TYPE_TAG_UINT64:
|
905
|
+
case GI_TYPE_TAG_FLOAT:
|
906
|
+
case GI_TYPE_TAG_DOUBLE:
|
907
|
+
case GI_TYPE_TAG_GTYPE:
|
908
|
+
g_base_info_unref(element_type_info);
|
302
909
|
rb_raise(rb_eNotImpError,
|
303
910
|
"TODO: GIArgument(GList)[%s] -> Ruby",
|
304
911
|
g_type_tag_to_string(element_type_tag));
|
305
912
|
break;
|
306
913
|
case GI_TYPE_TAG_UTF8:
|
914
|
+
g_base_info_unref(element_type_info);
|
307
915
|
rb_argument = CSTRGLIST2RVAL(argument->v_pointer);
|
308
916
|
break;
|
309
917
|
case GI_TYPE_TAG_FILENAME:
|
310
918
|
case GI_TYPE_TAG_ARRAY:
|
919
|
+
g_base_info_unref(element_type_info);
|
311
920
|
rb_raise(rb_eNotImpError,
|
312
921
|
"TODO: GIArgument(GList)[%s] -> Ruby",
|
313
922
|
g_type_tag_to_string(element_type_tag));
|
314
923
|
break;
|
315
924
|
case GI_TYPE_TAG_INTERFACE:
|
316
|
-
|
925
|
+
rb_argument = rb_gi_argument_to_ruby_glist_interface(argument,
|
926
|
+
type_info,
|
927
|
+
element_type_info);
|
317
928
|
break;
|
318
929
|
case GI_TYPE_TAG_GLIST:
|
319
930
|
case GI_TYPE_TAG_GSLIST:
|
320
931
|
case GI_TYPE_TAG_GHASH:
|
321
932
|
case GI_TYPE_TAG_ERROR:
|
322
933
|
case GI_TYPE_TAG_UNICHAR:
|
934
|
+
g_base_info_unref(element_type_info);
|
323
935
|
rb_raise(rb_eNotImpError,
|
324
936
|
"TODO: GIArgument(GList)[%s] -> Ruby",
|
325
937
|
g_type_tag_to_string(element_type_tag));
|
326
938
|
break;
|
327
939
|
default:
|
940
|
+
g_base_info_unref(element_type_info);
|
328
941
|
g_assert_not_reached();
|
329
942
|
break;
|
330
943
|
}
|
@@ -332,90 +945,177 @@ rb_gi_argument_to_ruby_glist(GIArgument *argument, GITypeInfo *type_info)
|
|
332
945
|
return rb_argument;
|
333
946
|
}
|
334
947
|
|
948
|
+
static VALUE
|
949
|
+
rb_gi_argument_to_ruby_gslist(GIArgument *argument, GITypeInfo *type_info)
|
950
|
+
{
|
951
|
+
VALUE rb_argument;
|
952
|
+
GITypeInfo *element_type_info;
|
953
|
+
GITypeTag element_type_tag;
|
954
|
+
|
955
|
+
element_type_info = g_type_info_get_param_type(type_info, 0);
|
956
|
+
element_type_tag = g_type_info_get_tag(element_type_info);
|
957
|
+
g_base_info_unref(element_type_info);
|
958
|
+
|
959
|
+
switch (element_type_tag) {
|
960
|
+
case GI_TYPE_TAG_VOID:
|
961
|
+
case GI_TYPE_TAG_BOOLEAN:
|
962
|
+
case GI_TYPE_TAG_INT8:
|
963
|
+
case GI_TYPE_TAG_UINT8:
|
964
|
+
case GI_TYPE_TAG_INT16:
|
965
|
+
case GI_TYPE_TAG_UINT16:
|
966
|
+
case GI_TYPE_TAG_INT32:
|
967
|
+
case GI_TYPE_TAG_UINT32:
|
968
|
+
case GI_TYPE_TAG_INT64:
|
969
|
+
case GI_TYPE_TAG_UINT64:
|
970
|
+
case GI_TYPE_TAG_FLOAT:
|
971
|
+
case GI_TYPE_TAG_DOUBLE:
|
972
|
+
case GI_TYPE_TAG_GTYPE:
|
973
|
+
rb_raise(rb_eNotImpError,
|
974
|
+
"TODO: GIArgument(GSList)[%s] -> Ruby",
|
975
|
+
g_type_tag_to_string(element_type_tag));
|
976
|
+
break;
|
977
|
+
case GI_TYPE_TAG_UTF8:
|
978
|
+
rb_argument = CSTRGSLIST2RVAL(argument->v_pointer);
|
979
|
+
break;
|
980
|
+
case GI_TYPE_TAG_FILENAME:
|
981
|
+
case GI_TYPE_TAG_ARRAY:
|
982
|
+
rb_raise(rb_eNotImpError,
|
983
|
+
"TODO: GIArgument(GSList)[%s] -> Ruby",
|
984
|
+
g_type_tag_to_string(element_type_tag));
|
985
|
+
break;
|
986
|
+
case GI_TYPE_TAG_INTERFACE:
|
987
|
+
rb_argument = GOBJGSLIST2RVAL(argument->v_pointer);
|
988
|
+
break;
|
989
|
+
case GI_TYPE_TAG_GLIST:
|
990
|
+
case GI_TYPE_TAG_GSLIST:
|
991
|
+
case GI_TYPE_TAG_GHASH:
|
992
|
+
case GI_TYPE_TAG_ERROR:
|
993
|
+
case GI_TYPE_TAG_UNICHAR:
|
994
|
+
rb_raise(rb_eNotImpError,
|
995
|
+
"TODO: GIArgument(GSList)[%s] -> Ruby",
|
996
|
+
g_type_tag_to_string(element_type_tag));
|
997
|
+
break;
|
998
|
+
default:
|
999
|
+
g_assert_not_reached();
|
1000
|
+
break;
|
1001
|
+
}
|
1002
|
+
|
1003
|
+
return rb_argument;
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
static VALUE
|
1007
|
+
rb_gi_argument_to_ruby_unichar(GIArgument *argument)
|
1008
|
+
{
|
1009
|
+
VALUE rb_argument;
|
1010
|
+
gunichar ucs4_character;
|
1011
|
+
gchar *utf8_string;
|
1012
|
+
GError *error = NULL;
|
1013
|
+
|
1014
|
+
ucs4_character = argument->v_uint32;
|
1015
|
+
utf8_string = g_ucs4_to_utf8(&ucs4_character, 1, NULL, NULL, &error);
|
1016
|
+
if (error) {
|
1017
|
+
RG_RAISE_ERROR(error);
|
1018
|
+
}
|
1019
|
+
rb_argument = CSTR2RVAL_FREE(utf8_string);
|
1020
|
+
|
1021
|
+
return rb_argument;
|
1022
|
+
}
|
335
1023
|
|
336
1024
|
VALUE
|
337
|
-
rb_gi_argument_to_ruby(GIArgument *argument,
|
1025
|
+
rb_gi_argument_to_ruby(GIArgument *argument,
|
1026
|
+
gboolean duplicate,
|
1027
|
+
GITypeInfo *type_info,
|
1028
|
+
GArray *in_args,
|
1029
|
+
GArray *out_args,
|
1030
|
+
GPtrArray *args_metadata)
|
338
1031
|
{
|
339
1032
|
VALUE rb_argument = Qnil;
|
340
1033
|
GITypeTag type_tag;
|
341
1034
|
|
342
1035
|
type_tag = g_type_info_get_tag(type_info);
|
343
1036
|
switch (type_tag) {
|
344
|
-
|
1037
|
+
case GI_TYPE_TAG_VOID:
|
345
1038
|
if (g_type_info_is_pointer(type_info)) {
|
346
1039
|
rb_argument = ULONG2NUM(GPOINTER_TO_UINT(argument->v_pointer));
|
347
1040
|
} else {
|
348
1041
|
rb_argument = Qnil;
|
349
1042
|
}
|
350
1043
|
break;
|
351
|
-
|
1044
|
+
case GI_TYPE_TAG_BOOLEAN:
|
352
1045
|
rb_argument = CBOOL2RVAL(argument->v_boolean);
|
353
1046
|
break;
|
354
|
-
|
1047
|
+
case GI_TYPE_TAG_INT8:
|
355
1048
|
rb_argument = INT2NUM(argument->v_int8);
|
356
1049
|
break;
|
357
|
-
|
1050
|
+
case GI_TYPE_TAG_UINT8:
|
358
1051
|
rb_argument = UINT2NUM(argument->v_uint8);
|
359
1052
|
break;
|
360
|
-
|
1053
|
+
case GI_TYPE_TAG_INT16:
|
361
1054
|
rb_argument = INT2NUM(argument->v_int16);
|
362
1055
|
break;
|
363
|
-
|
1056
|
+
case GI_TYPE_TAG_UINT16:
|
364
1057
|
rb_argument = UINT2NUM(argument->v_uint16);
|
365
1058
|
break;
|
366
|
-
|
1059
|
+
case GI_TYPE_TAG_INT32:
|
367
1060
|
rb_argument = INT2NUM(argument->v_int32);
|
368
1061
|
break;
|
369
|
-
|
1062
|
+
case GI_TYPE_TAG_UINT32:
|
370
1063
|
rb_argument = UINT2NUM(argument->v_uint32);
|
371
1064
|
break;
|
372
|
-
|
1065
|
+
case GI_TYPE_TAG_INT64:
|
373
1066
|
rb_argument = LONG2NUM(argument->v_int64);
|
374
1067
|
break;
|
375
|
-
|
1068
|
+
case GI_TYPE_TAG_UINT64:
|
376
1069
|
rb_argument = ULONG2NUM(argument->v_uint64);
|
377
1070
|
break;
|
378
|
-
|
1071
|
+
case GI_TYPE_TAG_FLOAT:
|
379
1072
|
rb_argument = DBL2NUM(argument->v_float);
|
380
1073
|
break;
|
381
|
-
|
1074
|
+
case GI_TYPE_TAG_DOUBLE:
|
382
1075
|
rb_argument = DBL2NUM(argument->v_double);
|
383
1076
|
break;
|
384
|
-
|
385
|
-
|
1077
|
+
case GI_TYPE_TAG_GTYPE:
|
1078
|
+
if (argument->v_size == G_TYPE_INVALID) {
|
1079
|
+
rb_argument = Qnil;
|
1080
|
+
} else {
|
1081
|
+
rb_argument = rbgobj_gtype_new(argument->v_size);
|
1082
|
+
}
|
386
1083
|
break;
|
387
|
-
|
1084
|
+
case GI_TYPE_TAG_UTF8:
|
388
1085
|
rb_argument = CSTR2RVAL(argument->v_string);
|
389
1086
|
break;
|
390
|
-
|
1087
|
+
case GI_TYPE_TAG_FILENAME:
|
391
1088
|
/* TODO: set encoding */
|
392
1089
|
rb_argument = CSTR2RVAL(argument->v_string);
|
393
1090
|
break;
|
394
|
-
|
395
|
-
rb_argument =
|
396
|
-
type_info,
|
1091
|
+
case GI_TYPE_TAG_ARRAY:
|
1092
|
+
rb_argument = rb_gi_argument_to_ruby_array(argument,
|
1093
|
+
type_info,
|
1094
|
+
in_args,
|
1095
|
+
out_args,
|
1096
|
+
args_metadata);
|
397
1097
|
break;
|
398
|
-
|
399
|
-
rb_argument = interface_to_ruby(argument, type_info);
|
1098
|
+
case GI_TYPE_TAG_INTERFACE:
|
1099
|
+
rb_argument = interface_to_ruby(argument, duplicate, type_info);
|
400
1100
|
break;
|
401
|
-
|
1101
|
+
case GI_TYPE_TAG_GLIST:
|
402
1102
|
rb_argument = rb_gi_argument_to_ruby_glist(argument, type_info);
|
403
1103
|
break;
|
404
|
-
|
405
|
-
|
1104
|
+
case GI_TYPE_TAG_GSLIST:
|
1105
|
+
rb_argument = rb_gi_argument_to_ruby_gslist(argument, type_info);
|
1106
|
+
break;
|
1107
|
+
case GI_TYPE_TAG_GHASH:
|
406
1108
|
rb_raise(rb_eNotImpError,
|
407
1109
|
"TODO: GIArgument(%s) -> Ruby",
|
408
1110
|
g_type_tag_to_string(type_tag));
|
409
1111
|
break;
|
410
|
-
|
1112
|
+
case GI_TYPE_TAG_ERROR:
|
411
1113
|
rb_argument = GERROR2RVAL(argument->v_pointer);
|
412
1114
|
break;
|
413
|
-
|
414
|
-
|
415
|
-
"TODO: GIArgument(%s) -> Ruby",
|
416
|
-
g_type_tag_to_string(type_tag));
|
1115
|
+
case GI_TYPE_TAG_UNICHAR:
|
1116
|
+
rb_argument = rb_gi_argument_to_ruby_unichar(argument);
|
417
1117
|
break;
|
418
|
-
|
1118
|
+
default:
|
419
1119
|
g_assert_not_reached();
|
420
1120
|
break;
|
421
1121
|
}
|
@@ -423,6 +1123,178 @@ rb_gi_argument_to_ruby(GIArgument *argument, GITypeInfo *type_info)
|
|
423
1123
|
return rb_argument;
|
424
1124
|
}
|
425
1125
|
|
1126
|
+
static void
|
1127
|
+
rb_gi_out_argument_init_array_array_interface(GIArgument *argument,
|
1128
|
+
G_GNUC_UNUSED GIArgInfo *arg_info,
|
1129
|
+
GITypeInfo *array_type_info,
|
1130
|
+
GITypeInfo *element_type_info)
|
1131
|
+
{
|
1132
|
+
gboolean zero_terminated_p;
|
1133
|
+
GIBaseInfo *interface_info;
|
1134
|
+
GIInfoType interface_type;
|
1135
|
+
GType gtype;
|
1136
|
+
const char *interface_name;
|
1137
|
+
|
1138
|
+
zero_terminated_p = g_type_info_is_zero_terminated(array_type_info);
|
1139
|
+
interface_info = g_type_info_get_interface(element_type_info);
|
1140
|
+
interface_type = g_base_info_get_type(interface_info);
|
1141
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
1142
|
+
|
1143
|
+
switch (interface_type) {
|
1144
|
+
case GI_INFO_TYPE_INVALID:
|
1145
|
+
case GI_INFO_TYPE_FUNCTION:
|
1146
|
+
case GI_INFO_TYPE_CALLBACK:
|
1147
|
+
interface_name = g_info_type_to_string(interface_type);
|
1148
|
+
g_base_info_unref(interface_info);
|
1149
|
+
g_base_info_unref(element_type_info);
|
1150
|
+
rb_raise(rb_eNotImpError,
|
1151
|
+
"TODO: GIArgument(array)[array][interface(%s)](%s) -> Ruby",
|
1152
|
+
interface_name,
|
1153
|
+
g_type_name(gtype));
|
1154
|
+
break;
|
1155
|
+
case GI_INFO_TYPE_STRUCT:
|
1156
|
+
{
|
1157
|
+
gsize struct_size;
|
1158
|
+
|
1159
|
+
struct_size = g_struct_info_get_size(interface_info);
|
1160
|
+
argument->v_pointer = g_array_new(zero_terminated_p,
|
1161
|
+
TRUE,
|
1162
|
+
struct_size);
|
1163
|
+
break;
|
1164
|
+
}
|
1165
|
+
case GI_INFO_TYPE_BOXED:
|
1166
|
+
case GI_INFO_TYPE_ENUM:
|
1167
|
+
case GI_INFO_TYPE_FLAGS:
|
1168
|
+
case GI_INFO_TYPE_OBJECT:
|
1169
|
+
case GI_INFO_TYPE_INTERFACE:
|
1170
|
+
case GI_INFO_TYPE_CONSTANT:
|
1171
|
+
case GI_INFO_TYPE_INVALID_0:
|
1172
|
+
case GI_INFO_TYPE_UNION:
|
1173
|
+
case GI_INFO_TYPE_VALUE:
|
1174
|
+
case GI_INFO_TYPE_SIGNAL:
|
1175
|
+
case GI_INFO_TYPE_VFUNC:
|
1176
|
+
case GI_INFO_TYPE_PROPERTY:
|
1177
|
+
case GI_INFO_TYPE_FIELD:
|
1178
|
+
case GI_INFO_TYPE_ARG:
|
1179
|
+
case GI_INFO_TYPE_TYPE:
|
1180
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
1181
|
+
interface_name = g_info_type_to_string(interface_type);
|
1182
|
+
g_base_info_unref(interface_info);
|
1183
|
+
g_base_info_unref(element_type_info);
|
1184
|
+
rb_raise(rb_eNotImpError,
|
1185
|
+
"TODO: GIArgument(array)[array][interface(%s)](%s) -> Ruby",
|
1186
|
+
interface_name,
|
1187
|
+
g_type_name(gtype));
|
1188
|
+
break;
|
1189
|
+
default:
|
1190
|
+
g_base_info_unref(interface_info);
|
1191
|
+
g_base_info_unref(element_type_info);
|
1192
|
+
g_assert_not_reached();
|
1193
|
+
break;
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
g_base_info_unref(interface_info);
|
1197
|
+
}
|
1198
|
+
|
1199
|
+
static void
|
1200
|
+
rb_gi_out_argument_init_array_array(GIArgument *argument,
|
1201
|
+
GIArgInfo *arg_info,
|
1202
|
+
GITypeInfo *array_type_info,
|
1203
|
+
GITypeInfo *element_type_info)
|
1204
|
+
{
|
1205
|
+
GITypeTag element_type_tag;
|
1206
|
+
|
1207
|
+
element_type_tag = g_type_info_get_tag(element_type_info);
|
1208
|
+
|
1209
|
+
switch (element_type_tag) {
|
1210
|
+
case GI_TYPE_TAG_VOID:
|
1211
|
+
case GI_TYPE_TAG_BOOLEAN:
|
1212
|
+
case GI_TYPE_TAG_INT8:
|
1213
|
+
case GI_TYPE_TAG_UINT8:
|
1214
|
+
case GI_TYPE_TAG_INT16:
|
1215
|
+
case GI_TYPE_TAG_UINT16:
|
1216
|
+
case GI_TYPE_TAG_INT32:
|
1217
|
+
case GI_TYPE_TAG_UINT32:
|
1218
|
+
case GI_TYPE_TAG_INT64:
|
1219
|
+
case GI_TYPE_TAG_UINT64:
|
1220
|
+
case GI_TYPE_TAG_FLOAT:
|
1221
|
+
case GI_TYPE_TAG_DOUBLE:
|
1222
|
+
case GI_TYPE_TAG_GTYPE:
|
1223
|
+
case GI_TYPE_TAG_UTF8:
|
1224
|
+
case GI_TYPE_TAG_FILENAME:
|
1225
|
+
case GI_TYPE_TAG_ARRAY:
|
1226
|
+
g_base_info_unref(element_type_info);
|
1227
|
+
rb_raise(rb_eNotImpError,
|
1228
|
+
"TODO: allocates GIArgument(array)[array][%s] for output",
|
1229
|
+
g_type_tag_to_string(element_type_tag));
|
1230
|
+
break;
|
1231
|
+
case GI_TYPE_TAG_INTERFACE:
|
1232
|
+
rb_gi_out_argument_init_array_array_interface(argument,
|
1233
|
+
arg_info,
|
1234
|
+
array_type_info,
|
1235
|
+
element_type_info);
|
1236
|
+
break;
|
1237
|
+
case GI_TYPE_TAG_GLIST:
|
1238
|
+
case GI_TYPE_TAG_GSLIST:
|
1239
|
+
case GI_TYPE_TAG_GHASH:
|
1240
|
+
case GI_TYPE_TAG_ERROR:
|
1241
|
+
case GI_TYPE_TAG_UNICHAR:
|
1242
|
+
g_base_info_unref(element_type_info);
|
1243
|
+
rb_raise(rb_eNotImpError,
|
1244
|
+
"TODO: allocates GIArgument(array)[array][%s] for output",
|
1245
|
+
g_type_tag_to_string(element_type_tag));
|
1246
|
+
break;
|
1247
|
+
default:
|
1248
|
+
g_base_info_unref(element_type_info);
|
1249
|
+
g_assert_not_reached();
|
1250
|
+
break;
|
1251
|
+
}
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
static void
|
1255
|
+
rb_gi_out_argument_init_array(GIArgument *argument, GIArgInfo *arg_info,
|
1256
|
+
GITypeInfo *array_type_info)
|
1257
|
+
{
|
1258
|
+
GIArrayType array_type;
|
1259
|
+
GITypeInfo *element_type_info;
|
1260
|
+
|
1261
|
+
array_type = g_type_info_get_array_type(array_type_info);
|
1262
|
+
element_type_info = g_type_info_get_param_type(array_type_info, 0);
|
1263
|
+
|
1264
|
+
switch (array_type) {
|
1265
|
+
case GI_ARRAY_TYPE_C:
|
1266
|
+
g_base_info_unref(element_type_info);
|
1267
|
+
rb_raise(rb_eNotImpError,
|
1268
|
+
"TODO: allocates GIArgument(array)[c][%s] for output",
|
1269
|
+
g_type_tag_to_string(g_type_info_get_tag(element_type_info)));
|
1270
|
+
break;
|
1271
|
+
case GI_ARRAY_TYPE_ARRAY:
|
1272
|
+
rb_gi_out_argument_init_array_array(argument,
|
1273
|
+
arg_info,
|
1274
|
+
array_type_info,
|
1275
|
+
element_type_info);
|
1276
|
+
break;
|
1277
|
+
case GI_ARRAY_TYPE_PTR_ARRAY:
|
1278
|
+
g_base_info_unref(element_type_info);
|
1279
|
+
rb_raise(rb_eNotImpError,
|
1280
|
+
"TODO: allocates GIArgument(array)[ptr-array][%s] for output",
|
1281
|
+
g_type_tag_to_string(g_type_info_get_tag(element_type_info)));
|
1282
|
+
break;
|
1283
|
+
case GI_ARRAY_TYPE_BYTE_ARRAY:
|
1284
|
+
g_base_info_unref(element_type_info);
|
1285
|
+
rb_raise(rb_eNotImpError,
|
1286
|
+
"TODO: allocates GIArgument(array)[byte-array][%s] for output",
|
1287
|
+
g_type_tag_to_string(g_type_info_get_tag(element_type_info)));
|
1288
|
+
break;
|
1289
|
+
default:
|
1290
|
+
g_base_info_unref(element_type_info);
|
1291
|
+
g_assert_not_reached();
|
1292
|
+
break;
|
1293
|
+
}
|
1294
|
+
|
1295
|
+
g_base_info_unref(element_type_info);
|
1296
|
+
}
|
1297
|
+
|
426
1298
|
static void
|
427
1299
|
rb_gi_out_argument_init_interface(GIArgument *argument, GIArgInfo *arg_info,
|
428
1300
|
GITypeInfo *type_info)
|
@@ -439,43 +1311,43 @@ rb_gi_out_argument_init_interface(GIArgument *argument, GIArgInfo *arg_info,
|
|
439
1311
|
interface_type = g_base_info_get_type(interface_info);
|
440
1312
|
|
441
1313
|
switch (interface_type) {
|
442
|
-
|
443
|
-
|
444
|
-
|
1314
|
+
case GI_INFO_TYPE_INVALID:
|
1315
|
+
case GI_INFO_TYPE_FUNCTION:
|
1316
|
+
case GI_INFO_TYPE_CALLBACK:
|
445
1317
|
rb_raise(rb_eNotImpError,
|
446
1318
|
"TODO: allocates GIArgument(interface)[%s] for output",
|
447
1319
|
g_info_type_to_string(interface_type));
|
448
1320
|
break;
|
449
|
-
|
450
|
-
|
451
|
-
|
1321
|
+
case GI_INFO_TYPE_STRUCT:
|
1322
|
+
{
|
1323
|
+
gsize struct_size;
|
452
1324
|
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
1325
|
+
struct_size = g_struct_info_get_size(interface_info);
|
1326
|
+
argument->v_pointer = xmalloc(struct_size);
|
1327
|
+
memset(argument->v_pointer, 0, struct_size);
|
1328
|
+
}
|
1329
|
+
break;
|
1330
|
+
case GI_INFO_TYPE_BOXED:
|
1331
|
+
case GI_INFO_TYPE_ENUM:
|
1332
|
+
case GI_INFO_TYPE_FLAGS:
|
1333
|
+
case GI_INFO_TYPE_OBJECT:
|
1334
|
+
case GI_INFO_TYPE_INTERFACE:
|
1335
|
+
case GI_INFO_TYPE_CONSTANT:
|
1336
|
+
case GI_INFO_TYPE_INVALID_0:
|
1337
|
+
case GI_INFO_TYPE_UNION:
|
1338
|
+
case GI_INFO_TYPE_VALUE:
|
1339
|
+
case GI_INFO_TYPE_SIGNAL:
|
1340
|
+
case GI_INFO_TYPE_VFUNC:
|
1341
|
+
case GI_INFO_TYPE_PROPERTY:
|
1342
|
+
case GI_INFO_TYPE_FIELD:
|
1343
|
+
case GI_INFO_TYPE_ARG:
|
1344
|
+
case GI_INFO_TYPE_TYPE:
|
1345
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
474
1346
|
rb_raise(rb_eNotImpError,
|
475
1347
|
"TODO: allocates GIArgument(interface)[%s] for output",
|
476
1348
|
g_info_type_to_string(interface_type));
|
477
1349
|
break;
|
478
|
-
|
1350
|
+
default:
|
479
1351
|
g_assert_not_reached();
|
480
1352
|
break;
|
481
1353
|
}
|
@@ -494,270 +1366,353 @@ rb_gi_out_argument_init(GIArgument *argument, GIArgInfo *arg_info)
|
|
494
1366
|
g_arg_info_load_type(arg_info, &type_info);
|
495
1367
|
type_tag = g_type_info_get_tag(&type_info);
|
496
1368
|
switch (type_tag) {
|
497
|
-
|
1369
|
+
case GI_TYPE_TAG_VOID:
|
498
1370
|
break;
|
499
|
-
|
1371
|
+
case GI_TYPE_TAG_BOOLEAN:
|
500
1372
|
argument->v_pointer = ALLOC(gboolean);
|
501
1373
|
break;
|
502
|
-
|
1374
|
+
case GI_TYPE_TAG_INT8:
|
503
1375
|
argument->v_pointer = ALLOC(gint8);
|
504
1376
|
break;
|
505
|
-
|
1377
|
+
case GI_TYPE_TAG_UINT8:
|
506
1378
|
argument->v_pointer = ALLOC(guint8);
|
507
1379
|
break;
|
508
|
-
|
1380
|
+
case GI_TYPE_TAG_INT16:
|
509
1381
|
argument->v_pointer = ALLOC(gint16);
|
510
1382
|
break;
|
511
|
-
|
1383
|
+
case GI_TYPE_TAG_UINT16:
|
512
1384
|
argument->v_pointer = ALLOC(guint16);
|
513
1385
|
break;
|
514
|
-
|
1386
|
+
case GI_TYPE_TAG_INT32:
|
515
1387
|
argument->v_pointer = ALLOC(gint32);
|
516
1388
|
break;
|
517
|
-
|
1389
|
+
case GI_TYPE_TAG_UINT32:
|
518
1390
|
argument->v_pointer = ALLOC(guint32);
|
519
1391
|
break;
|
520
|
-
|
1392
|
+
case GI_TYPE_TAG_INT64:
|
521
1393
|
argument->v_pointer = ALLOC(gint64);
|
522
1394
|
break;
|
523
|
-
|
1395
|
+
case GI_TYPE_TAG_UINT64:
|
524
1396
|
argument->v_pointer = ALLOC(guint64);
|
525
1397
|
break;
|
526
|
-
|
1398
|
+
case GI_TYPE_TAG_FLOAT:
|
527
1399
|
argument->v_pointer = ALLOC(gfloat);
|
528
1400
|
break;
|
529
|
-
|
1401
|
+
case GI_TYPE_TAG_DOUBLE:
|
530
1402
|
argument->v_pointer = ALLOC(gdouble);
|
531
1403
|
break;
|
532
|
-
|
1404
|
+
case GI_TYPE_TAG_GTYPE:
|
533
1405
|
argument->v_pointer = ALLOC(GType);
|
534
1406
|
break;
|
535
|
-
|
536
|
-
|
1407
|
+
case GI_TYPE_TAG_UTF8:
|
1408
|
+
case GI_TYPE_TAG_FILENAME:
|
537
1409
|
argument->v_pointer = ALLOC(gchar *);
|
538
1410
|
break;
|
539
|
-
|
540
|
-
argument
|
1411
|
+
case GI_TYPE_TAG_ARRAY:
|
1412
|
+
rb_gi_out_argument_init_array(argument, arg_info, &type_info);
|
541
1413
|
break;
|
542
|
-
|
1414
|
+
case GI_TYPE_TAG_INTERFACE:
|
543
1415
|
rb_gi_out_argument_init_interface(argument, arg_info, &type_info);
|
544
1416
|
break;
|
545
|
-
|
546
|
-
|
547
|
-
|
1417
|
+
case GI_TYPE_TAG_GLIST:
|
1418
|
+
case GI_TYPE_TAG_GSLIST:
|
1419
|
+
case GI_TYPE_TAG_GHASH:
|
548
1420
|
argument->v_pointer = ALLOC(gpointer);
|
549
1421
|
break;
|
550
|
-
|
1422
|
+
case GI_TYPE_TAG_ERROR:
|
551
1423
|
argument->v_pointer = ALLOC(GError *);
|
552
1424
|
memset(argument->v_pointer, 0, sizeof(GError *));
|
553
1425
|
break;
|
554
|
-
|
1426
|
+
case GI_TYPE_TAG_UNICHAR:
|
555
1427
|
argument->v_pointer = ALLOC(gunichar);
|
556
1428
|
break;
|
557
|
-
|
1429
|
+
default:
|
558
1430
|
g_assert_not_reached();
|
559
1431
|
break;
|
560
1432
|
}
|
561
1433
|
}
|
562
1434
|
|
563
1435
|
VALUE
|
564
|
-
rb_gi_out_argument_to_ruby(GIArgument *argument,
|
1436
|
+
rb_gi_out_argument_to_ruby(GIArgument *argument,
|
1437
|
+
GIArgInfo *arg_info,
|
1438
|
+
GArray *in_args,
|
1439
|
+
GArray *out_args,
|
1440
|
+
GPtrArray *args_metadata)
|
565
1441
|
{
|
566
1442
|
GIArgument normalized_argument;
|
567
1443
|
GITypeInfo type_info;
|
568
1444
|
GITypeTag type_tag;
|
1445
|
+
gboolean duplicate = FALSE;
|
569
1446
|
|
570
1447
|
memset(&normalized_argument, 0, sizeof(GIArgument));
|
571
1448
|
g_arg_info_load_type(arg_info, &type_info);
|
572
1449
|
type_tag = g_type_info_get_tag(&type_info);
|
573
1450
|
switch (type_tag) {
|
574
|
-
|
1451
|
+
case GI_TYPE_TAG_VOID:
|
575
1452
|
break;
|
576
|
-
|
1453
|
+
case GI_TYPE_TAG_BOOLEAN:
|
577
1454
|
normalized_argument.v_boolean = *((gboolean *)(argument->v_pointer));
|
578
1455
|
break;
|
579
|
-
|
1456
|
+
case GI_TYPE_TAG_INT8:
|
580
1457
|
normalized_argument.v_int8 = *((gint8 *)(argument->v_pointer));
|
581
1458
|
break;
|
582
|
-
|
1459
|
+
case GI_TYPE_TAG_UINT8:
|
583
1460
|
normalized_argument.v_uint8 = *((guint8 *)(argument->v_pointer));
|
584
1461
|
break;
|
585
|
-
|
1462
|
+
case GI_TYPE_TAG_INT16:
|
586
1463
|
normalized_argument.v_int16 = *((gint16 *)(argument->v_pointer));
|
587
1464
|
break;
|
588
|
-
|
1465
|
+
case GI_TYPE_TAG_UINT16:
|
589
1466
|
normalized_argument.v_uint16 = *((guint16 *)(argument->v_pointer));
|
590
1467
|
break;
|
591
|
-
|
1468
|
+
case GI_TYPE_TAG_INT32:
|
592
1469
|
normalized_argument.v_int32 = *((gint32 *)(argument->v_pointer));
|
593
1470
|
break;
|
594
|
-
|
1471
|
+
case GI_TYPE_TAG_UINT32:
|
595
1472
|
normalized_argument.v_uint32 = *((guint32 *)(argument->v_pointer));
|
596
1473
|
break;
|
597
|
-
|
1474
|
+
case GI_TYPE_TAG_INT64:
|
598
1475
|
normalized_argument.v_int64 = *((gint64 *)(argument->v_pointer));
|
599
1476
|
break;
|
600
|
-
|
1477
|
+
case GI_TYPE_TAG_UINT64:
|
601
1478
|
normalized_argument.v_uint64 = *((guint64 *)(argument->v_pointer));
|
602
1479
|
break;
|
603
|
-
|
1480
|
+
case GI_TYPE_TAG_FLOAT:
|
604
1481
|
normalized_argument.v_float = *((gfloat *)(argument->v_pointer));
|
605
1482
|
break;
|
606
|
-
|
1483
|
+
case GI_TYPE_TAG_DOUBLE:
|
607
1484
|
normalized_argument.v_double = *((gdouble *)(argument->v_pointer));
|
608
1485
|
break;
|
609
|
-
|
1486
|
+
case GI_TYPE_TAG_GTYPE:
|
610
1487
|
normalized_argument.v_size = *((GType *)(argument->v_pointer));
|
611
1488
|
break;
|
612
|
-
|
613
|
-
|
1489
|
+
case GI_TYPE_TAG_UTF8:
|
1490
|
+
case GI_TYPE_TAG_FILENAME:
|
614
1491
|
normalized_argument.v_string = *((gchar **)(argument->v_pointer));
|
615
1492
|
break;
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
1493
|
+
case GI_TYPE_TAG_ARRAY:
|
1494
|
+
case GI_TYPE_TAG_INTERFACE:
|
1495
|
+
case GI_TYPE_TAG_GLIST:
|
1496
|
+
case GI_TYPE_TAG_GSLIST:
|
1497
|
+
case GI_TYPE_TAG_GHASH:
|
621
1498
|
if (g_arg_info_is_caller_allocates(arg_info)) {
|
1499
|
+
duplicate = TRUE;
|
622
1500
|
normalized_argument.v_pointer = argument->v_pointer;
|
623
1501
|
} else {
|
624
1502
|
normalized_argument.v_pointer = *((gpointer *)(argument->v_pointer));
|
625
1503
|
}
|
626
1504
|
break;
|
627
|
-
|
1505
|
+
case GI_TYPE_TAG_ERROR:
|
628
1506
|
normalized_argument.v_pointer = *((GError **)(argument->v_pointer));
|
629
1507
|
break;
|
630
|
-
|
1508
|
+
case GI_TYPE_TAG_UNICHAR:
|
631
1509
|
normalized_argument.v_uint32 = *((guint32 *)(argument->v_pointer));
|
632
1510
|
break;
|
633
|
-
|
1511
|
+
default:
|
634
1512
|
g_assert_not_reached();
|
635
1513
|
break;
|
636
1514
|
}
|
637
1515
|
|
638
|
-
return rb_gi_argument_to_ruby(&normalized_argument,
|
1516
|
+
return rb_gi_argument_to_ruby(&normalized_argument,
|
1517
|
+
duplicate,
|
1518
|
+
&type_info,
|
1519
|
+
in_args,
|
1520
|
+
out_args,
|
1521
|
+
args_metadata);
|
639
1522
|
}
|
640
1523
|
|
641
1524
|
static void
|
642
|
-
|
643
|
-
|
644
|
-
|
1525
|
+
rb_gi_out_argument_fin_array(GIArgument *argument,
|
1526
|
+
G_GNUC_UNUSED GIArgInfo *arg_info,
|
1527
|
+
GITypeInfo *array_type_info)
|
645
1528
|
{
|
1529
|
+
GIArrayType array_type;
|
1530
|
+
|
1531
|
+
array_type = g_type_info_get_array_type(array_type_info);
|
1532
|
+
|
1533
|
+
switch (array_type) {
|
1534
|
+
case GI_ARRAY_TYPE_C:
|
1535
|
+
rb_raise(rb_eNotImpError,
|
1536
|
+
"TODO: free out GIArgument(array)[c]");
|
1537
|
+
break;
|
1538
|
+
case GI_ARRAY_TYPE_ARRAY:
|
1539
|
+
g_array_free(argument->v_pointer, TRUE);
|
1540
|
+
break;
|
1541
|
+
case GI_ARRAY_TYPE_PTR_ARRAY:
|
1542
|
+
rb_raise(rb_eNotImpError,
|
1543
|
+
"TODO: free out GIArgument(array)[ptr-array]");
|
1544
|
+
break;
|
1545
|
+
case GI_ARRAY_TYPE_BYTE_ARRAY:
|
1546
|
+
rb_raise(rb_eNotImpError,
|
1547
|
+
"TODO: free out GIArgument(array)[byte-array]");
|
1548
|
+
break;
|
1549
|
+
default:
|
1550
|
+
g_assert_not_reached();
|
1551
|
+
break;
|
1552
|
+
}
|
1553
|
+
}
|
1554
|
+
|
1555
|
+
void
|
1556
|
+
rb_gi_out_argument_fin(GIArgument *argument, GIArgInfo *arg_info)
|
1557
|
+
{
|
1558
|
+
GITypeInfo type_info;
|
646
1559
|
GITypeTag type_tag;
|
647
1560
|
|
648
|
-
|
1561
|
+
if (g_arg_info_get_direction(arg_info) != GI_DIRECTION_OUT) {
|
1562
|
+
return;
|
1563
|
+
}
|
1564
|
+
|
1565
|
+
g_arg_info_load_type(arg_info, &type_info);
|
1566
|
+
type_tag = g_type_info_get_tag(&type_info);
|
1567
|
+
|
649
1568
|
switch (type_tag) {
|
650
|
-
|
651
|
-
|
1569
|
+
case GI_TYPE_TAG_VOID:
|
1570
|
+
case GI_TYPE_TAG_BOOLEAN:
|
1571
|
+
case GI_TYPE_TAG_INT8:
|
1572
|
+
case GI_TYPE_TAG_UINT8:
|
1573
|
+
case GI_TYPE_TAG_INT16:
|
1574
|
+
case GI_TYPE_TAG_UINT16:
|
1575
|
+
case GI_TYPE_TAG_INT32:
|
1576
|
+
case GI_TYPE_TAG_UINT32:
|
1577
|
+
case GI_TYPE_TAG_INT64:
|
1578
|
+
case GI_TYPE_TAG_UINT64:
|
1579
|
+
case GI_TYPE_TAG_FLOAT:
|
1580
|
+
case GI_TYPE_TAG_DOUBLE:
|
1581
|
+
case GI_TYPE_TAG_GTYPE:
|
1582
|
+
case GI_TYPE_TAG_UTF8:
|
1583
|
+
xfree(argument->v_pointer);
|
1584
|
+
break;
|
1585
|
+
case GI_TYPE_TAG_FILENAME:
|
652
1586
|
rb_raise(rb_eNotImpError,
|
653
|
-
"TODO:
|
1587
|
+
"TODO: free out GIArgument(%s)",
|
654
1588
|
g_type_tag_to_string(type_tag));
|
655
1589
|
break;
|
656
|
-
|
657
|
-
|
1590
|
+
case GI_TYPE_TAG_ARRAY:
|
1591
|
+
rb_gi_out_argument_fin_array(argument, arg_info, &type_info);
|
658
1592
|
break;
|
659
|
-
|
660
|
-
|
1593
|
+
case GI_TYPE_TAG_INTERFACE:
|
1594
|
+
case GI_TYPE_TAG_GLIST:
|
1595
|
+
case GI_TYPE_TAG_GSLIST:
|
1596
|
+
case GI_TYPE_TAG_GHASH:
|
1597
|
+
case GI_TYPE_TAG_ERROR:
|
1598
|
+
case GI_TYPE_TAG_UNICHAR:
|
1599
|
+
xfree(argument->v_pointer);
|
661
1600
|
break;
|
662
|
-
|
663
|
-
|
1601
|
+
default:
|
1602
|
+
g_assert_not_reached();
|
664
1603
|
break;
|
665
|
-
|
666
|
-
|
1604
|
+
}
|
1605
|
+
}
|
1606
|
+
|
1607
|
+
static void
|
1608
|
+
rb_gi_return_argument_free_container(GIArgument *argument,
|
1609
|
+
GITypeInfo *type_info)
|
1610
|
+
{
|
1611
|
+
GITypeTag type_tag;
|
1612
|
+
|
1613
|
+
type_tag = g_type_info_get_tag(type_info);
|
1614
|
+
|
1615
|
+
switch (type_tag) {
|
1616
|
+
case GI_TYPE_TAG_VOID:
|
1617
|
+
case GI_TYPE_TAG_BOOLEAN:
|
1618
|
+
case GI_TYPE_TAG_INT8:
|
1619
|
+
case GI_TYPE_TAG_UINT8:
|
1620
|
+
case GI_TYPE_TAG_INT16:
|
1621
|
+
case GI_TYPE_TAG_UINT16:
|
1622
|
+
case GI_TYPE_TAG_INT32:
|
1623
|
+
case GI_TYPE_TAG_UINT32:
|
1624
|
+
case GI_TYPE_TAG_INT64:
|
1625
|
+
case GI_TYPE_TAG_UINT64:
|
1626
|
+
case GI_TYPE_TAG_FLOAT:
|
1627
|
+
case GI_TYPE_TAG_DOUBLE:
|
1628
|
+
case GI_TYPE_TAG_GTYPE:
|
1629
|
+
case GI_TYPE_TAG_UTF8:
|
1630
|
+
case GI_TYPE_TAG_FILENAME:
|
1631
|
+
rb_raise(rb_eNotImpError,
|
1632
|
+
"TODO: free GIArgument(%s) as container",
|
1633
|
+
g_type_tag_to_string(type_tag));
|
667
1634
|
break;
|
668
|
-
|
669
|
-
|
1635
|
+
case GI_TYPE_TAG_ARRAY:
|
1636
|
+
g_free(argument->v_pointer);
|
670
1637
|
break;
|
671
|
-
|
672
|
-
|
1638
|
+
case GI_TYPE_TAG_INTERFACE:
|
1639
|
+
rb_raise(rb_eNotImpError,
|
1640
|
+
"TODO: free GIArgument(%s) as container",
|
1641
|
+
g_type_tag_to_string(type_tag));
|
673
1642
|
break;
|
674
|
-
|
675
|
-
|
1643
|
+
case GI_TYPE_TAG_GLIST:
|
1644
|
+
g_list_free(argument->v_pointer);
|
676
1645
|
break;
|
677
|
-
|
678
|
-
|
1646
|
+
case GI_TYPE_TAG_GSLIST:
|
1647
|
+
g_slist_free(argument->v_pointer);
|
679
1648
|
break;
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
case GI_TYPE_TAG_UTF8:
|
684
|
-
case GI_TYPE_TAG_FILENAME:
|
685
|
-
case GI_TYPE_TAG_ARRAY:
|
686
|
-
case GI_TYPE_TAG_INTERFACE:
|
687
|
-
case GI_TYPE_TAG_GLIST:
|
688
|
-
case GI_TYPE_TAG_GSLIST:
|
689
|
-
case GI_TYPE_TAG_GHASH:
|
690
|
-
case GI_TYPE_TAG_ERROR:
|
691
|
-
case GI_TYPE_TAG_UNICHAR:
|
1649
|
+
case GI_TYPE_TAG_GHASH:
|
1650
|
+
case GI_TYPE_TAG_ERROR:
|
1651
|
+
case GI_TYPE_TAG_UNICHAR:
|
692
1652
|
rb_raise(rb_eNotImpError,
|
693
|
-
"TODO:
|
1653
|
+
"TODO: free GIArgument(%s) as container",
|
694
1654
|
g_type_tag_to_string(type_tag));
|
695
1655
|
break;
|
696
|
-
|
1656
|
+
default:
|
697
1657
|
g_assert_not_reached();
|
698
1658
|
break;
|
699
1659
|
}
|
700
1660
|
}
|
701
1661
|
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
GIArgInfo *array_arg_info,
|
706
|
-
GIArgInfo *length_arg_info)
|
1662
|
+
static void
|
1663
|
+
rb_gi_return_argument_free_everything_array_c(GIArgument *argument,
|
1664
|
+
GITypeInfo *type_info)
|
707
1665
|
{
|
708
|
-
|
709
|
-
|
710
|
-
GITypeInfo array_type_info;
|
711
|
-
|
712
|
-
normalized_array_argument.v_pointer =
|
713
|
-
*((gpointer *)(array_argument->v_pointer));
|
714
|
-
g_arg_info_load_type(array_arg_info, &array_type_info);
|
715
|
-
if (length_argument) {
|
716
|
-
GITypeInfo length_type_info;
|
717
|
-
GIArgument normalized_length_argument;
|
718
|
-
|
719
|
-
g_arg_info_load_type(length_arg_info, &length_type_info);
|
720
|
-
normalize_out_array_length(&normalized_length_argument,
|
721
|
-
length_argument,
|
722
|
-
&length_type_info);
|
723
|
-
rb_array = rb_gi_array_argument_to_ruby(&normalized_array_argument,
|
724
|
-
&normalized_length_argument,
|
725
|
-
&array_type_info,
|
726
|
-
&length_type_info);
|
727
|
-
} else {
|
728
|
-
rb_array = rb_gi_array_argument_to_ruby(&normalized_array_argument,
|
729
|
-
NULL,
|
730
|
-
&array_type_info,
|
731
|
-
NULL);
|
732
|
-
}
|
733
|
-
|
734
|
-
return rb_array;
|
735
|
-
}
|
1666
|
+
GITypeInfo *element_type_info;
|
1667
|
+
GITypeTag element_type_tag;
|
736
1668
|
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
GITypeInfo type_info;
|
1669
|
+
element_type_info = g_type_info_get_param_type(type_info, 0);
|
1670
|
+
element_type_tag = g_type_info_get_tag(element_type_info);
|
1671
|
+
g_base_info_unref(element_type_info);
|
741
1672
|
|
742
|
-
|
743
|
-
|
1673
|
+
switch (element_type_tag) {
|
1674
|
+
case GI_TYPE_TAG_VOID:
|
1675
|
+
case GI_TYPE_TAG_BOOLEAN:
|
1676
|
+
case GI_TYPE_TAG_INT8:
|
1677
|
+
rb_raise(rb_eNotImpError,
|
1678
|
+
"TODO: free GIArgument(array)[c][%s] everything",
|
1679
|
+
g_type_tag_to_string(element_type_tag));
|
1680
|
+
break;
|
1681
|
+
case GI_TYPE_TAG_UINT8:
|
1682
|
+
g_free(argument->v_pointer);
|
1683
|
+
break;
|
1684
|
+
case GI_TYPE_TAG_INT16:
|
1685
|
+
case GI_TYPE_TAG_UINT16:
|
1686
|
+
case GI_TYPE_TAG_INT32:
|
1687
|
+
case GI_TYPE_TAG_UINT32:
|
1688
|
+
case GI_TYPE_TAG_INT64:
|
1689
|
+
case GI_TYPE_TAG_UINT64:
|
1690
|
+
case GI_TYPE_TAG_FLOAT:
|
1691
|
+
case GI_TYPE_TAG_DOUBLE:
|
1692
|
+
case GI_TYPE_TAG_GTYPE:
|
1693
|
+
rb_raise(rb_eNotImpError,
|
1694
|
+
"TODO: free GIArgument(array)[c][%s] everything",
|
1695
|
+
g_type_tag_to_string(element_type_tag));
|
1696
|
+
break;
|
1697
|
+
case GI_TYPE_TAG_UTF8:
|
1698
|
+
g_strfreev(argument->v_pointer);
|
1699
|
+
break;
|
1700
|
+
case GI_TYPE_TAG_FILENAME:
|
1701
|
+
case GI_TYPE_TAG_ARRAY:
|
1702
|
+
case GI_TYPE_TAG_INTERFACE:
|
1703
|
+
case GI_TYPE_TAG_GLIST:
|
1704
|
+
case GI_TYPE_TAG_GSLIST:
|
1705
|
+
case GI_TYPE_TAG_GHASH:
|
1706
|
+
case GI_TYPE_TAG_ERROR:
|
1707
|
+
case GI_TYPE_TAG_UNICHAR:
|
1708
|
+
rb_raise(rb_eNotImpError,
|
1709
|
+
"TODO: free GIArgument(array)[c][%s] everything",
|
1710
|
+
g_type_tag_to_string(element_type_tag));
|
1711
|
+
break;
|
1712
|
+
default:
|
1713
|
+
g_assert_not_reached();
|
1714
|
+
break;
|
744
1715
|
}
|
745
|
-
|
746
|
-
g_arg_info_load_type(arg_info, &type_info);
|
747
|
-
xfree(argument->v_pointer);
|
748
|
-
}
|
749
|
-
|
750
|
-
static void
|
751
|
-
rb_gi_return_argument_free_container(G_GNUC_UNUSED GIArgument *argument,
|
752
|
-
GITypeInfo *type_info)
|
753
|
-
{
|
754
|
-
GITypeTag type_tag;
|
755
|
-
|
756
|
-
type_tag = g_type_info_get_tag(type_info);
|
757
|
-
|
758
|
-
rb_raise(rb_eNotImpError,
|
759
|
-
"TODO: free GIArgument(%s) as container",
|
760
|
-
g_type_tag_to_string(type_tag));
|
761
1716
|
}
|
762
1717
|
|
763
1718
|
static void
|
@@ -765,19 +1720,19 @@ rb_gi_return_argument_free_everything_array(GIArgument *argument,
|
|
765
1720
|
GITypeInfo *type_info)
|
766
1721
|
{
|
767
1722
|
switch (g_type_info_get_array_type(type_info)) {
|
768
|
-
|
769
|
-
|
1723
|
+
case GI_ARRAY_TYPE_C:
|
1724
|
+
rb_gi_return_argument_free_everything_array_c(argument, type_info);
|
770
1725
|
break;
|
771
|
-
|
1726
|
+
case GI_ARRAY_TYPE_ARRAY:
|
772
1727
|
g_array_free(argument->v_pointer, TRUE);
|
773
1728
|
break;
|
774
|
-
|
1729
|
+
case GI_ARRAY_TYPE_PTR_ARRAY:
|
775
1730
|
g_ptr_array_free(argument->v_pointer, TRUE);
|
776
1731
|
break;
|
777
|
-
|
1732
|
+
case GI_ARRAY_TYPE_BYTE_ARRAY:
|
778
1733
|
g_ptr_array_free(argument->v_pointer, TRUE);
|
779
1734
|
break;
|
780
|
-
|
1735
|
+
default:
|
781
1736
|
g_assert_not_reached();
|
782
1737
|
break;
|
783
1738
|
}
|
@@ -816,87 +1771,173 @@ rb_gi_return_argument_free_everything_interface(GIArgument *argument,
|
|
816
1771
|
g_base_info_unref(interface_info);
|
817
1772
|
|
818
1773
|
switch (interface_type) {
|
819
|
-
|
1774
|
+
case GI_INFO_TYPE_INVALID:
|
820
1775
|
rb_raise(rb_eNotImpError,
|
821
1776
|
"TODO: free GIArgument(interface)[invalid] everything");
|
822
1777
|
break;
|
823
|
-
|
1778
|
+
case GI_INFO_TYPE_FUNCTION:
|
824
1779
|
rb_raise(rb_eNotImpError,
|
825
1780
|
"TODO: free GIArgument(interface)[function] everything");
|
826
1781
|
break;
|
827
|
-
|
1782
|
+
case GI_INFO_TYPE_CALLBACK:
|
828
1783
|
rb_raise(rb_eNotImpError,
|
829
1784
|
"TODO: free GIArgument(interface)[callback] everything");
|
830
1785
|
break;
|
831
|
-
|
1786
|
+
case GI_INFO_TYPE_STRUCT:
|
832
1787
|
rb_gi_return_argument_free_everything_interface_struct(argument, gtype);
|
833
1788
|
break;
|
834
|
-
|
1789
|
+
case GI_INFO_TYPE_BOXED:
|
835
1790
|
rb_raise(rb_eNotImpError,
|
836
1791
|
"TODO: free GIArgument(interface)[boxed] everything");
|
837
1792
|
break;
|
838
|
-
|
1793
|
+
case GI_INFO_TYPE_ENUM:
|
839
1794
|
rb_raise(rb_eNotImpError,
|
840
1795
|
"TODO: free GIArgument(interface)[enum] everything");
|
841
1796
|
break;
|
842
|
-
|
1797
|
+
case GI_INFO_TYPE_FLAGS:
|
843
1798
|
rb_raise(rb_eNotImpError,
|
844
1799
|
"TODO: free GIArgument(interface)[flags] everything");
|
845
1800
|
break;
|
846
|
-
|
1801
|
+
case GI_INFO_TYPE_OBJECT:
|
847
1802
|
if (argument->v_pointer) {
|
848
1803
|
g_object_unref(argument->v_pointer);
|
849
1804
|
}
|
850
1805
|
break;
|
851
|
-
|
1806
|
+
case GI_INFO_TYPE_INTERFACE:
|
852
1807
|
if (argument->v_pointer) {
|
853
1808
|
g_object_unref(argument->v_pointer);
|
854
1809
|
}
|
855
1810
|
break;
|
856
|
-
|
1811
|
+
case GI_INFO_TYPE_CONSTANT:
|
857
1812
|
rb_raise(rb_eNotImpError,
|
858
1813
|
"TODO: free GIArgument(interface)[constant] everything");
|
859
1814
|
break;
|
860
|
-
|
1815
|
+
case GI_INFO_TYPE_INVALID_0:
|
861
1816
|
g_assert_not_reached();
|
862
1817
|
break;
|
863
|
-
|
1818
|
+
case GI_INFO_TYPE_UNION:
|
864
1819
|
rb_raise(rb_eNotImpError,
|
865
1820
|
"TODO: free GIArgument(interface)[union] everything");
|
866
1821
|
break;
|
867
|
-
|
1822
|
+
case GI_INFO_TYPE_VALUE:
|
868
1823
|
rb_raise(rb_eNotImpError,
|
869
1824
|
"TODO: free GIArgument(interface)[value] everything");
|
870
1825
|
break;
|
871
|
-
|
1826
|
+
case GI_INFO_TYPE_SIGNAL:
|
872
1827
|
rb_raise(rb_eNotImpError,
|
873
1828
|
"TODO: free GIArgument(interface)[signal] everything");
|
874
1829
|
break;
|
875
|
-
|
1830
|
+
case GI_INFO_TYPE_VFUNC:
|
876
1831
|
rb_raise(rb_eNotImpError,
|
877
1832
|
"TODO: free GIArgument(interface)[vfunc] everything");
|
878
1833
|
break;
|
879
|
-
|
1834
|
+
case GI_INFO_TYPE_PROPERTY:
|
880
1835
|
rb_raise(rb_eNotImpError,
|
881
1836
|
"TODO: free GIArgument(interface)[property] everything");
|
882
1837
|
break;
|
883
|
-
|
1838
|
+
case GI_INFO_TYPE_FIELD:
|
884
1839
|
rb_raise(rb_eNotImpError,
|
885
1840
|
"TODO: free GIArgument(interface)[field] everything");
|
886
1841
|
break;
|
887
|
-
|
1842
|
+
case GI_INFO_TYPE_ARG:
|
888
1843
|
rb_raise(rb_eNotImpError,
|
889
1844
|
"TODO: free GIArgument(interface)[arg] everything");
|
890
1845
|
break;
|
891
|
-
|
1846
|
+
case GI_INFO_TYPE_TYPE:
|
892
1847
|
rb_raise(rb_eNotImpError,
|
893
1848
|
"TODO: free GIArgument(interface)[type] everything");
|
894
1849
|
break;
|
895
|
-
|
1850
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
896
1851
|
rb_raise(rb_eNotImpError,
|
897
1852
|
"TODO: free GIArgument(interface)[unresolved] everything");
|
898
1853
|
break;
|
899
|
-
|
1854
|
+
default:
|
1855
|
+
g_assert_not_reached();
|
1856
|
+
break;
|
1857
|
+
}
|
1858
|
+
}
|
1859
|
+
|
1860
|
+
static void
|
1861
|
+
rb_gi_boxed_free_callback(gpointer boxed, gpointer user_data)
|
1862
|
+
{
|
1863
|
+
GType *gtype = user_data;
|
1864
|
+
|
1865
|
+
g_boxed_free(*gtype, boxed);
|
1866
|
+
}
|
1867
|
+
|
1868
|
+
|
1869
|
+
static void
|
1870
|
+
rb_gi_return_argument_free_everything_glist_interface(GIArgument *argument,
|
1871
|
+
G_GNUC_UNUSED GITypeInfo *type_info,
|
1872
|
+
GITypeInfo *element_type_info)
|
1873
|
+
{
|
1874
|
+
GIBaseInfo *interface_info;
|
1875
|
+
GIInfoType interface_type;
|
1876
|
+
const gchar *interface_name;
|
1877
|
+
GType gtype;
|
1878
|
+
|
1879
|
+
interface_info = g_type_info_get_interface(element_type_info);
|
1880
|
+
interface_type = g_base_info_get_type(interface_info);
|
1881
|
+
interface_name = g_info_type_to_string(interface_type);
|
1882
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
1883
|
+
g_base_info_unref(interface_info);
|
1884
|
+
g_base_info_unref(element_type_info);
|
1885
|
+
|
1886
|
+
switch (interface_type) {
|
1887
|
+
case GI_INFO_TYPE_INVALID:
|
1888
|
+
case GI_INFO_TYPE_FUNCTION:
|
1889
|
+
case GI_INFO_TYPE_CALLBACK:
|
1890
|
+
rb_raise(rb_eNotImpError,
|
1891
|
+
"TODO: free GIArgument(GList)[interface(%s)](%s) everything",
|
1892
|
+
interface_name,
|
1893
|
+
g_type_name(gtype));
|
1894
|
+
break;
|
1895
|
+
case GI_INFO_TYPE_STRUCT:
|
1896
|
+
if (gtype == G_TYPE_NONE) {
|
1897
|
+
rb_raise(rb_eNotImpError,
|
1898
|
+
"TODO: free GIArgument(GList)[interface(%s)](%s) everything",
|
1899
|
+
interface_name,
|
1900
|
+
g_type_name(gtype));
|
1901
|
+
} else {
|
1902
|
+
g_list_foreach(argument->v_pointer,
|
1903
|
+
rb_gi_boxed_free_callback,
|
1904
|
+
>ype);
|
1905
|
+
g_list_free(argument->v_pointer);
|
1906
|
+
}
|
1907
|
+
break;
|
1908
|
+
case GI_INFO_TYPE_BOXED:
|
1909
|
+
g_list_foreach(argument->v_pointer, rb_gi_boxed_free_callback, >ype);
|
1910
|
+
g_list_free(argument->v_pointer);
|
1911
|
+
break;
|
1912
|
+
case GI_INFO_TYPE_ENUM:
|
1913
|
+
case GI_INFO_TYPE_FLAGS:
|
1914
|
+
rb_raise(rb_eNotImpError,
|
1915
|
+
"TODO: free GIArgument(GList)[interface(%s)](%s) everything",
|
1916
|
+
interface_name,
|
1917
|
+
g_type_name(gtype));
|
1918
|
+
break;
|
1919
|
+
case GI_INFO_TYPE_OBJECT:
|
1920
|
+
case GI_INFO_TYPE_INTERFACE:
|
1921
|
+
g_list_foreach(argument->v_pointer, (GFunc)g_object_unref, NULL);
|
1922
|
+
g_list_free(argument->v_pointer);
|
1923
|
+
break;
|
1924
|
+
case GI_INFO_TYPE_CONSTANT:
|
1925
|
+
case GI_INFO_TYPE_INVALID_0:
|
1926
|
+
case GI_INFO_TYPE_UNION:
|
1927
|
+
case GI_INFO_TYPE_VALUE:
|
1928
|
+
case GI_INFO_TYPE_SIGNAL:
|
1929
|
+
case GI_INFO_TYPE_VFUNC:
|
1930
|
+
case GI_INFO_TYPE_PROPERTY:
|
1931
|
+
case GI_INFO_TYPE_FIELD:
|
1932
|
+
case GI_INFO_TYPE_ARG:
|
1933
|
+
case GI_INFO_TYPE_TYPE:
|
1934
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
1935
|
+
rb_raise(rb_eNotImpError,
|
1936
|
+
"TODO: free GIArgument(GList)[interface(%s)](%s) everything",
|
1937
|
+
interface_name,
|
1938
|
+
g_type_name(gtype));
|
1939
|
+
break;
|
1940
|
+
default:
|
900
1941
|
g_assert_not_reached();
|
901
1942
|
break;
|
902
1943
|
}
|
@@ -911,7 +1952,6 @@ rb_gi_return_argument_free_everything_glist(GIArgument *argument,
|
|
911
1952
|
|
912
1953
|
element_type_info = g_type_info_get_param_type(type_info, 0);
|
913
1954
|
element_type_tag = g_type_info_get_tag(element_type_info);
|
914
|
-
g_base_info_unref(element_type_info);
|
915
1955
|
|
916
1956
|
switch (element_type_tag) {
|
917
1957
|
case GI_TYPE_TAG_VOID:
|
@@ -927,33 +1967,97 @@ rb_gi_return_argument_free_everything_glist(GIArgument *argument,
|
|
927
1967
|
case GI_TYPE_TAG_FLOAT:
|
928
1968
|
case GI_TYPE_TAG_DOUBLE:
|
929
1969
|
case GI_TYPE_TAG_GTYPE:
|
1970
|
+
g_base_info_unref(element_type_info);
|
930
1971
|
rb_raise(rb_eNotImpError,
|
931
1972
|
"TODO: free GIArgument(GList)[%s] everything",
|
932
1973
|
g_type_tag_to_string(element_type_tag));
|
933
1974
|
break;
|
934
1975
|
case GI_TYPE_TAG_UTF8:
|
1976
|
+
g_base_info_unref(element_type_info);
|
935
1977
|
g_list_foreach(argument->v_pointer, (GFunc)g_free, NULL);
|
936
1978
|
g_list_free(argument->v_pointer);
|
937
1979
|
break;
|
938
1980
|
case GI_TYPE_TAG_FILENAME:
|
939
1981
|
case GI_TYPE_TAG_ARRAY:
|
1982
|
+
g_base_info_unref(element_type_info);
|
940
1983
|
rb_raise(rb_eNotImpError,
|
941
1984
|
"TODO: free GIArgument(GList)[%s] everything",
|
942
1985
|
g_type_tag_to_string(element_type_tag));
|
943
1986
|
break;
|
944
1987
|
case GI_TYPE_TAG_INTERFACE:
|
945
|
-
|
946
|
-
|
1988
|
+
rb_gi_return_argument_free_everything_glist_interface(argument,
|
1989
|
+
type_info,
|
1990
|
+
element_type_info);
|
947
1991
|
break;
|
948
1992
|
case GI_TYPE_TAG_GLIST:
|
949
1993
|
case GI_TYPE_TAG_GSLIST:
|
950
1994
|
case GI_TYPE_TAG_GHASH:
|
951
1995
|
case GI_TYPE_TAG_ERROR:
|
952
1996
|
case GI_TYPE_TAG_UNICHAR:
|
1997
|
+
g_base_info_unref(element_type_info);
|
953
1998
|
rb_raise(rb_eNotImpError,
|
954
1999
|
"TODO: free GIArgument(GList)[%s] everything",
|
955
2000
|
g_type_tag_to_string(element_type_tag));
|
956
2001
|
break;
|
2002
|
+
default:
|
2003
|
+
g_base_info_unref(element_type_info);
|
2004
|
+
g_assert_not_reached();
|
2005
|
+
break;
|
2006
|
+
}
|
2007
|
+
}
|
2008
|
+
|
2009
|
+
static void
|
2010
|
+
rb_gi_return_argument_free_everything_gslist(GIArgument *argument,
|
2011
|
+
GITypeInfo *type_info)
|
2012
|
+
{
|
2013
|
+
GITypeInfo *element_type_info;
|
2014
|
+
GITypeTag element_type_tag;
|
2015
|
+
|
2016
|
+
element_type_info = g_type_info_get_param_type(type_info, 0);
|
2017
|
+
element_type_tag = g_type_info_get_tag(element_type_info);
|
2018
|
+
g_base_info_unref(element_type_info);
|
2019
|
+
|
2020
|
+
switch (element_type_tag) {
|
2021
|
+
case GI_TYPE_TAG_VOID:
|
2022
|
+
case GI_TYPE_TAG_BOOLEAN:
|
2023
|
+
case GI_TYPE_TAG_INT8:
|
2024
|
+
case GI_TYPE_TAG_UINT8:
|
2025
|
+
case GI_TYPE_TAG_INT16:
|
2026
|
+
case GI_TYPE_TAG_UINT16:
|
2027
|
+
case GI_TYPE_TAG_INT32:
|
2028
|
+
case GI_TYPE_TAG_UINT32:
|
2029
|
+
case GI_TYPE_TAG_INT64:
|
2030
|
+
case GI_TYPE_TAG_UINT64:
|
2031
|
+
case GI_TYPE_TAG_FLOAT:
|
2032
|
+
case GI_TYPE_TAG_DOUBLE:
|
2033
|
+
case GI_TYPE_TAG_GTYPE:
|
2034
|
+
rb_raise(rb_eNotImpError,
|
2035
|
+
"TODO: free GIArgument(GSList)[%s] everything",
|
2036
|
+
g_type_tag_to_string(element_type_tag));
|
2037
|
+
break;
|
2038
|
+
case GI_TYPE_TAG_UTF8:
|
2039
|
+
g_slist_foreach(argument->v_pointer, (GFunc)g_free, NULL);
|
2040
|
+
g_slist_free(argument->v_pointer);
|
2041
|
+
break;
|
2042
|
+
case GI_TYPE_TAG_FILENAME:
|
2043
|
+
case GI_TYPE_TAG_ARRAY:
|
2044
|
+
rb_raise(rb_eNotImpError,
|
2045
|
+
"TODO: free GIArgument(GSList)[%s] everything",
|
2046
|
+
g_type_tag_to_string(element_type_tag));
|
2047
|
+
break;
|
2048
|
+
case GI_TYPE_TAG_INTERFACE:
|
2049
|
+
g_slist_foreach(argument->v_pointer, (GFunc)g_object_unref, NULL);
|
2050
|
+
g_slist_free(argument->v_pointer);
|
2051
|
+
break;
|
2052
|
+
case GI_TYPE_TAG_GLIST:
|
2053
|
+
case GI_TYPE_TAG_GSLIST:
|
2054
|
+
case GI_TYPE_TAG_GHASH:
|
2055
|
+
case GI_TYPE_TAG_ERROR:
|
2056
|
+
case GI_TYPE_TAG_UNICHAR:
|
2057
|
+
rb_raise(rb_eNotImpError,
|
2058
|
+
"TODO: free GIArgument(GSList)[%s] everything",
|
2059
|
+
g_type_tag_to_string(element_type_tag));
|
2060
|
+
break;
|
957
2061
|
default:
|
958
2062
|
g_assert_not_reached();
|
959
2063
|
break;
|
@@ -968,57 +2072,60 @@ rb_gi_return_argument_free_everything(GIArgument *argument,
|
|
968
2072
|
|
969
2073
|
type_tag = g_type_info_get_tag(type_info);
|
970
2074
|
switch (type_tag) {
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
2075
|
+
case GI_TYPE_TAG_VOID:
|
2076
|
+
case GI_TYPE_TAG_BOOLEAN:
|
2077
|
+
case GI_TYPE_TAG_INT8:
|
2078
|
+
case GI_TYPE_TAG_UINT8:
|
2079
|
+
case GI_TYPE_TAG_INT16:
|
2080
|
+
case GI_TYPE_TAG_UINT16:
|
2081
|
+
case GI_TYPE_TAG_INT32:
|
2082
|
+
case GI_TYPE_TAG_UINT32:
|
2083
|
+
case GI_TYPE_TAG_INT64:
|
2084
|
+
case GI_TYPE_TAG_UINT64:
|
2085
|
+
case GI_TYPE_TAG_FLOAT:
|
2086
|
+
case GI_TYPE_TAG_DOUBLE:
|
2087
|
+
case GI_TYPE_TAG_GTYPE:
|
984
2088
|
rb_raise(rb_eNotImpError,
|
985
2089
|
"TODO: free GIArgument(%s) everything",
|
986
2090
|
g_type_tag_to_string(type_tag));
|
987
2091
|
break;
|
988
|
-
|
2092
|
+
case GI_TYPE_TAG_UTF8:
|
989
2093
|
g_free(argument->v_string);
|
990
2094
|
break;
|
991
|
-
|
992
|
-
|
993
|
-
"TODO: free GIArgument(%s) everything",
|
994
|
-
g_type_tag_to_string(type_tag));
|
2095
|
+
case GI_TYPE_TAG_FILENAME:
|
2096
|
+
g_free(argument->v_string);
|
995
2097
|
break;
|
996
|
-
|
2098
|
+
case GI_TYPE_TAG_ARRAY:
|
997
2099
|
rb_gi_return_argument_free_everything_array(argument, type_info);
|
998
2100
|
break;
|
999
|
-
|
2101
|
+
case GI_TYPE_TAG_INTERFACE:
|
1000
2102
|
rb_gi_return_argument_free_everything_interface(argument, type_info);
|
1001
2103
|
break;
|
1002
|
-
|
2104
|
+
case GI_TYPE_TAG_GLIST:
|
1003
2105
|
rb_gi_return_argument_free_everything_glist(argument, type_info);
|
1004
2106
|
break;
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
2107
|
+
case GI_TYPE_TAG_GSLIST:
|
2108
|
+
rb_gi_return_argument_free_everything_gslist(argument, type_info);
|
2109
|
+
break;
|
2110
|
+
case GI_TYPE_TAG_GHASH:
|
2111
|
+
case GI_TYPE_TAG_ERROR:
|
2112
|
+
case GI_TYPE_TAG_UNICHAR:
|
1009
2113
|
rb_raise(rb_eNotImpError,
|
1010
2114
|
"TODO: free GIArgument(%s) everything",
|
1011
2115
|
g_type_tag_to_string(type_tag));
|
1012
2116
|
break;
|
1013
|
-
|
2117
|
+
default:
|
1014
2118
|
g_assert_not_reached();
|
1015
2119
|
break;
|
1016
2120
|
}
|
1017
2121
|
}
|
1018
2122
|
|
1019
2123
|
VALUE
|
1020
|
-
rb_gi_return_argument_to_ruby(
|
1021
|
-
|
2124
|
+
rb_gi_return_argument_to_ruby(GICallableInfo *callable_info,
|
2125
|
+
GIArgument *argument,
|
2126
|
+
GArray *in_args,
|
2127
|
+
GArray *out_args,
|
2128
|
+
GPtrArray *args_metadata)
|
1022
2129
|
{
|
1023
2130
|
VALUE rb_argument;
|
1024
2131
|
gboolean may_return_null;
|
@@ -1030,17 +2137,18 @@ rb_gi_return_argument_to_ruby(GIArgument *argument,
|
|
1030
2137
|
}
|
1031
2138
|
|
1032
2139
|
g_callable_info_load_return_type(callable_info, &return_value_info);
|
1033
|
-
rb_argument = rb_gi_argument_to_ruby(argument, &return_value_info
|
2140
|
+
rb_argument = rb_gi_argument_to_ruby(argument, FALSE, &return_value_info,
|
2141
|
+
in_args, out_args, args_metadata);
|
1034
2142
|
switch (g_callable_info_get_caller_owns(callable_info)) {
|
1035
|
-
|
2143
|
+
case GI_TRANSFER_NOTHING:
|
1036
2144
|
break;
|
1037
|
-
|
2145
|
+
case GI_TRANSFER_CONTAINER:
|
1038
2146
|
rb_gi_return_argument_free_container(argument, &return_value_info);
|
1039
2147
|
break;
|
1040
|
-
|
2148
|
+
case GI_TRANSFER_EVERYTHING:
|
1041
2149
|
rb_gi_return_argument_free_everything(argument, &return_value_info);
|
1042
2150
|
break;
|
1043
|
-
|
2151
|
+
default:
|
1044
2152
|
g_assert_not_reached();
|
1045
2153
|
break;
|
1046
2154
|
}
|
@@ -1048,8 +2156,10 @@ rb_gi_return_argument_to_ruby(GIArgument *argument,
|
|
1048
2156
|
}
|
1049
2157
|
|
1050
2158
|
static void
|
1051
|
-
|
1052
|
-
|
2159
|
+
rb_gi_value_argument_from_ruby_interface(GIArgument *argument,
|
2160
|
+
GITypeInfo *type_info,
|
2161
|
+
VALUE rb_argument,
|
2162
|
+
VALUE self)
|
1053
2163
|
{
|
1054
2164
|
GIBaseInfo *interface_info;
|
1055
2165
|
GIInfoType interface_type;
|
@@ -1058,87 +2168,217 @@ rb_gi_argument_from_ruby_interface(GIArgument *argument, GITypeInfo *type_info,
|
|
1058
2168
|
interface_info = g_type_info_get_interface(type_info);
|
1059
2169
|
interface_type = g_base_info_get_type(interface_info);
|
1060
2170
|
|
1061
|
-
gtype = g_registered_type_info_get_g_type(interface_info);
|
1062
2171
|
switch (interface_type) {
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
2172
|
+
case GI_INFO_TYPE_INVALID:
|
2173
|
+
case GI_INFO_TYPE_FUNCTION:
|
2174
|
+
case GI_INFO_TYPE_CALLBACK:
|
1066
2175
|
rb_raise(rb_eNotImpError,
|
1067
2176
|
"TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
|
1068
2177
|
g_info_type_to_string(interface_type),
|
1069
2178
|
g_base_info_get_name(interface_info));
|
1070
2179
|
break;
|
1071
|
-
|
2180
|
+
case GI_INFO_TYPE_STRUCT:
|
2181
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
1072
2182
|
if (gtype == G_TYPE_NONE) {
|
1073
2183
|
argument->v_pointer = DATA_PTR(rb_argument);
|
1074
2184
|
} else if (gtype == G_TYPE_VALUE) {
|
1075
2185
|
GValue *gvalue;
|
1076
|
-
|
1077
|
-
|
1078
|
-
if (rb_obj_is_kind_of(rb_argument, rb_cGLibValue)) {
|
1079
|
-
GValue *source_gvalue;
|
1080
|
-
source_gvalue = RVAL2BOXED(rb_argument, G_TYPE_VALUE);
|
1081
|
-
g_value_init(gvalue, source_gvalue->g_type);
|
1082
|
-
g_value_copy(source_gvalue, gvalue);
|
2186
|
+
if (RVAL2CBOOL(rb_obj_is_kind_of(rb_argument, rb_cGLibValue))) {
|
2187
|
+
gvalue = RVAL2BOXED(rb_argument, G_TYPE_VALUE);
|
1083
2188
|
} else {
|
2189
|
+
gvalue = ALLOC(GValue);
|
2190
|
+
memset(gvalue, 0, sizeof(GValue));
|
1084
2191
|
rbgobj_initialize_gvalue(gvalue, rb_argument);
|
1085
2192
|
}
|
1086
2193
|
argument->v_pointer = gvalue;
|
2194
|
+
} else if (gtype == G_TYPE_BYTES) {
|
2195
|
+
VALUE rb_string;
|
2196
|
+
GBytes *gbytes;
|
2197
|
+
|
2198
|
+
rb_string = StringValue(rb_argument);
|
2199
|
+
gbytes = g_bytes_new(RSTRING_PTR(rb_string),
|
2200
|
+
RSTRING_LEN(rb_string));
|
2201
|
+
argument->v_pointer = gbytes;
|
2202
|
+
} else if (gtype == G_TYPE_CLOSURE) {
|
2203
|
+
GClosure *rclosure = NULL;
|
2204
|
+
|
2205
|
+
rclosure = g_rclosure_new(rb_argument, Qnil, NULL);
|
2206
|
+
g_rclosure_attach(rclosure, self);
|
2207
|
+
argument->v_pointer = rclosure;
|
2208
|
+
} else if (gtype == G_TYPE_VARIANT) {
|
2209
|
+
argument->v_pointer = rbg_variant_from_ruby(rb_argument);
|
2210
|
+
} else {
|
2211
|
+
argument->v_pointer = RVAL2BOXED(rb_argument, gtype);
|
2212
|
+
}
|
2213
|
+
break;
|
2214
|
+
case GI_INFO_TYPE_BOXED:
|
2215
|
+
rb_raise(rb_eNotImpError,
|
2216
|
+
"TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
|
2217
|
+
g_info_type_to_string(interface_type),
|
2218
|
+
g_base_info_get_name(interface_info));
|
2219
|
+
break;
|
2220
|
+
case GI_INFO_TYPE_ENUM:
|
2221
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
2222
|
+
if (gtype == G_TYPE_NONE) {
|
2223
|
+
argument->v_int32 = NUM2INT(rb_argument);
|
2224
|
+
} else {
|
2225
|
+
argument->v_int32 = RVAL2GENUM(rb_argument, gtype);
|
2226
|
+
}
|
2227
|
+
break;
|
2228
|
+
case GI_INFO_TYPE_FLAGS:
|
2229
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
2230
|
+
if (gtype == G_TYPE_NONE) {
|
2231
|
+
argument->v_int32 = NUM2INT(rb_argument);
|
2232
|
+
} else {
|
2233
|
+
argument->v_int32 = RVAL2GFLAGS(rb_argument, gtype);
|
2234
|
+
}
|
2235
|
+
break;
|
2236
|
+
case GI_INFO_TYPE_OBJECT:
|
2237
|
+
case GI_INFO_TYPE_INTERFACE:
|
2238
|
+
argument->v_pointer = RVAL2GOBJ(rb_argument);
|
2239
|
+
break;
|
2240
|
+
case GI_INFO_TYPE_CONSTANT:
|
2241
|
+
rb_raise(rb_eNotImpError,
|
2242
|
+
"TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
|
2243
|
+
g_info_type_to_string(interface_type),
|
2244
|
+
g_base_info_get_name(interface_info));
|
2245
|
+
break;
|
2246
|
+
case GI_INFO_TYPE_INVALID_0:
|
2247
|
+
g_assert_not_reached();
|
2248
|
+
break;
|
2249
|
+
case GI_INFO_TYPE_UNION:
|
2250
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
2251
|
+
if (gtype == G_TYPE_NONE) {
|
2252
|
+
rb_raise(rb_eNotImpError,
|
2253
|
+
"TODO: Ruby -> GIArgument(interface)[%s]: <%s>"
|
2254
|
+
"(G_TYPE_NONE)",
|
2255
|
+
g_info_type_to_string(interface_type),
|
2256
|
+
g_base_info_get_name(interface_info));
|
1087
2257
|
} else {
|
1088
2258
|
argument->v_pointer = RVAL2BOXED(rb_argument, gtype);
|
1089
2259
|
}
|
1090
2260
|
break;
|
1091
|
-
|
2261
|
+
case GI_INFO_TYPE_VALUE:
|
2262
|
+
case GI_INFO_TYPE_SIGNAL:
|
2263
|
+
case GI_INFO_TYPE_VFUNC:
|
2264
|
+
case GI_INFO_TYPE_PROPERTY:
|
2265
|
+
case GI_INFO_TYPE_FIELD:
|
2266
|
+
case GI_INFO_TYPE_ARG:
|
2267
|
+
case GI_INFO_TYPE_TYPE:
|
2268
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
2269
|
+
default:
|
2270
|
+
rb_raise(rb_eNotImpError,
|
2271
|
+
"TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
|
2272
|
+
g_info_type_to_string(interface_type),
|
2273
|
+
g_base_info_get_name(interface_info));
|
2274
|
+
break;
|
2275
|
+
}
|
2276
|
+
|
2277
|
+
g_base_info_unref(interface_info);
|
2278
|
+
}
|
2279
|
+
|
2280
|
+
static void
|
2281
|
+
rb_gi_value_argument_from_ruby_glist(GIArgument *argument,
|
2282
|
+
GITypeInfo *type_info,
|
2283
|
+
VALUE rb_argument,
|
2284
|
+
G_GNUC_UNUSED VALUE self)
|
2285
|
+
{
|
2286
|
+
GITypeInfo *element_type_info;
|
2287
|
+
GITypeTag element_type_tag;
|
2288
|
+
|
2289
|
+
element_type_info = g_type_info_get_param_type(type_info, 0);
|
2290
|
+
element_type_tag = g_type_info_get_tag(element_type_info);
|
2291
|
+
g_base_info_unref(element_type_info);
|
2292
|
+
|
2293
|
+
switch (element_type_tag) {
|
2294
|
+
case GI_TYPE_TAG_VOID:
|
2295
|
+
case GI_TYPE_TAG_BOOLEAN:
|
2296
|
+
case GI_TYPE_TAG_INT8:
|
2297
|
+
case GI_TYPE_TAG_UINT8:
|
2298
|
+
case GI_TYPE_TAG_INT16:
|
2299
|
+
case GI_TYPE_TAG_UINT16:
|
2300
|
+
case GI_TYPE_TAG_INT32:
|
2301
|
+
case GI_TYPE_TAG_UINT32:
|
2302
|
+
case GI_TYPE_TAG_INT64:
|
2303
|
+
case GI_TYPE_TAG_UINT64:
|
2304
|
+
case GI_TYPE_TAG_FLOAT:
|
2305
|
+
case GI_TYPE_TAG_DOUBLE:
|
2306
|
+
case GI_TYPE_TAG_GTYPE:
|
2307
|
+
case GI_TYPE_TAG_UTF8:
|
2308
|
+
case GI_TYPE_TAG_FILENAME:
|
2309
|
+
case GI_TYPE_TAG_ARRAY:
|
2310
|
+
rb_raise(rb_eNotImpError,
|
2311
|
+
"TODO: Ruby -> GIArgument(GList)[%s]",
|
2312
|
+
g_type_tag_to_string(element_type_tag));
|
2313
|
+
break;
|
2314
|
+
case GI_TYPE_TAG_INTERFACE:
|
2315
|
+
argument->v_pointer = RVAL2GOBJGLIST(rb_argument);
|
2316
|
+
break;
|
2317
|
+
case GI_TYPE_TAG_GLIST:
|
2318
|
+
case GI_TYPE_TAG_GSLIST:
|
2319
|
+
case GI_TYPE_TAG_GHASH:
|
2320
|
+
case GI_TYPE_TAG_ERROR:
|
2321
|
+
case GI_TYPE_TAG_UNICHAR:
|
2322
|
+
rb_raise(rb_eNotImpError,
|
2323
|
+
"TODO: Ruby -> GIArgument(GList)[%s]",
|
2324
|
+
g_type_tag_to_string(element_type_tag));
|
2325
|
+
break;
|
2326
|
+
default:
|
2327
|
+
g_assert_not_reached();
|
2328
|
+
break;
|
2329
|
+
}
|
2330
|
+
}
|
2331
|
+
|
2332
|
+
static void
|
2333
|
+
rb_gi_value_argument_from_ruby_gslist(GIArgument *argument,
|
2334
|
+
GITypeInfo *type_info,
|
2335
|
+
VALUE rb_argument,
|
2336
|
+
G_GNUC_UNUSED VALUE self)
|
2337
|
+
{
|
2338
|
+
GITypeInfo *element_type_info;
|
2339
|
+
GITypeTag element_type_tag;
|
2340
|
+
|
2341
|
+
element_type_info = g_type_info_get_param_type(type_info, 0);
|
2342
|
+
element_type_tag = g_type_info_get_tag(element_type_info);
|
2343
|
+
g_base_info_unref(element_type_info);
|
2344
|
+
|
2345
|
+
switch (element_type_tag) {
|
2346
|
+
case GI_TYPE_TAG_VOID:
|
2347
|
+
case GI_TYPE_TAG_BOOLEAN:
|
2348
|
+
case GI_TYPE_TAG_INT8:
|
2349
|
+
case GI_TYPE_TAG_UINT8:
|
2350
|
+
case GI_TYPE_TAG_INT16:
|
2351
|
+
case GI_TYPE_TAG_UINT16:
|
2352
|
+
case GI_TYPE_TAG_INT32:
|
2353
|
+
case GI_TYPE_TAG_UINT32:
|
2354
|
+
case GI_TYPE_TAG_INT64:
|
2355
|
+
case GI_TYPE_TAG_UINT64:
|
2356
|
+
case GI_TYPE_TAG_FLOAT:
|
2357
|
+
case GI_TYPE_TAG_DOUBLE:
|
2358
|
+
case GI_TYPE_TAG_GTYPE:
|
2359
|
+
case GI_TYPE_TAG_UTF8:
|
2360
|
+
case GI_TYPE_TAG_FILENAME:
|
2361
|
+
case GI_TYPE_TAG_ARRAY:
|
1092
2362
|
rb_raise(rb_eNotImpError,
|
1093
|
-
"TODO: Ruby -> GIArgument(
|
1094
|
-
|
1095
|
-
g_base_info_get_name(interface_info));
|
1096
|
-
break;
|
1097
|
-
case GI_INFO_TYPE_ENUM:
|
1098
|
-
if (gtype == G_TYPE_NONE) {
|
1099
|
-
argument->v_int32 = NUM2INT(rb_argument);
|
1100
|
-
} else {
|
1101
|
-
argument->v_int32 = RVAL2GENUM(rb_argument, gtype);
|
1102
|
-
}
|
1103
|
-
break;
|
1104
|
-
case GI_INFO_TYPE_FLAGS:
|
1105
|
-
if (gtype == G_TYPE_NONE) {
|
1106
|
-
argument->v_int32 = NUM2INT(rb_argument);
|
1107
|
-
} else {
|
1108
|
-
argument->v_int32 = RVAL2GFLAGS(rb_argument, gtype);
|
1109
|
-
}
|
2363
|
+
"TODO: Ruby -> GIArgument(GSList)[%s]",
|
2364
|
+
g_type_tag_to_string(element_type_tag));
|
1110
2365
|
break;
|
1111
|
-
|
1112
|
-
|
1113
|
-
argument->v_pointer = RVAL2GOBJ(rb_argument);
|
2366
|
+
case GI_TYPE_TAG_INTERFACE:
|
2367
|
+
argument->v_pointer = RVAL2GOBJGSLIST(rb_argument);
|
1114
2368
|
break;
|
1115
|
-
|
2369
|
+
case GI_TYPE_TAG_GLIST:
|
2370
|
+
case GI_TYPE_TAG_GSLIST:
|
2371
|
+
case GI_TYPE_TAG_GHASH:
|
2372
|
+
case GI_TYPE_TAG_ERROR:
|
2373
|
+
case GI_TYPE_TAG_UNICHAR:
|
1116
2374
|
rb_raise(rb_eNotImpError,
|
1117
|
-
"TODO: Ruby -> GIArgument(
|
1118
|
-
|
1119
|
-
g_base_info_get_name(interface_info));
|
2375
|
+
"TODO: Ruby -> GIArgument(GSList)[%s]",
|
2376
|
+
g_type_tag_to_string(element_type_tag));
|
1120
2377
|
break;
|
1121
|
-
|
2378
|
+
default:
|
1122
2379
|
g_assert_not_reached();
|
1123
2380
|
break;
|
1124
|
-
case GI_INFO_TYPE_UNION:
|
1125
|
-
case GI_INFO_TYPE_VALUE:
|
1126
|
-
case GI_INFO_TYPE_SIGNAL:
|
1127
|
-
case GI_INFO_TYPE_VFUNC:
|
1128
|
-
case GI_INFO_TYPE_PROPERTY:
|
1129
|
-
case GI_INFO_TYPE_FIELD:
|
1130
|
-
case GI_INFO_TYPE_ARG:
|
1131
|
-
case GI_INFO_TYPE_TYPE:
|
1132
|
-
case GI_INFO_TYPE_UNRESOLVED:
|
1133
|
-
default:
|
1134
|
-
rb_raise(rb_eNotImpError,
|
1135
|
-
"TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
|
1136
|
-
g_info_type_to_string(interface_type),
|
1137
|
-
g_base_info_get_name(interface_info));
|
1138
|
-
break;
|
1139
2381
|
}
|
1140
|
-
|
1141
|
-
g_base_info_unref(interface_info);
|
1142
2382
|
}
|
1143
2383
|
|
1144
2384
|
static void
|
@@ -1158,7 +2398,7 @@ rb_gi_value_argument_from_ruby_void(GIArgument *argument, GITypeInfo *type_info,
|
|
1158
2398
|
|
1159
2399
|
GIArgument *
|
1160
2400
|
rb_gi_value_argument_from_ruby(GIArgument *argument, GITypeInfo *type_info,
|
1161
|
-
VALUE rb_argument)
|
2401
|
+
VALUE rb_argument, VALUE self)
|
1162
2402
|
{
|
1163
2403
|
GITypeTag type_tag;
|
1164
2404
|
|
@@ -1166,71 +2406,78 @@ rb_gi_value_argument_from_ruby(GIArgument *argument, GITypeInfo *type_info,
|
|
1166
2406
|
|
1167
2407
|
type_tag = g_type_info_get_tag(type_info);
|
1168
2408
|
switch (type_tag) {
|
1169
|
-
|
2409
|
+
case GI_TYPE_TAG_VOID:
|
1170
2410
|
rb_gi_value_argument_from_ruby_void(argument, type_info, rb_argument);
|
1171
2411
|
break;
|
1172
|
-
|
2412
|
+
case GI_TYPE_TAG_BOOLEAN:
|
1173
2413
|
argument->v_boolean = RVAL2CBOOL(rb_argument);
|
1174
2414
|
break;
|
1175
|
-
|
2415
|
+
case GI_TYPE_TAG_INT8:
|
1176
2416
|
argument->v_int8 = NUM2INT(rb_argument);
|
1177
2417
|
break;
|
1178
|
-
|
2418
|
+
case GI_TYPE_TAG_UINT8:
|
1179
2419
|
argument->v_uint8 = NUM2UINT(rb_argument);
|
1180
2420
|
break;
|
1181
|
-
|
2421
|
+
case GI_TYPE_TAG_INT16:
|
1182
2422
|
argument->v_int16 = NUM2INT(rb_argument);
|
1183
2423
|
break;
|
1184
|
-
|
2424
|
+
case GI_TYPE_TAG_UINT16:
|
1185
2425
|
argument->v_uint16 = NUM2UINT(rb_argument);
|
1186
2426
|
break;
|
1187
|
-
|
2427
|
+
case GI_TYPE_TAG_INT32:
|
1188
2428
|
argument->v_int32 = NUM2INT(rb_argument);
|
1189
2429
|
break;
|
1190
|
-
|
2430
|
+
case GI_TYPE_TAG_UINT32:
|
1191
2431
|
argument->v_uint32 = NUM2UINT(rb_argument);
|
1192
2432
|
break;
|
1193
|
-
|
2433
|
+
case GI_TYPE_TAG_INT64:
|
1194
2434
|
argument->v_int64 = NUM2LONG(rb_argument);
|
1195
2435
|
break;
|
1196
|
-
|
2436
|
+
case GI_TYPE_TAG_UINT64:
|
1197
2437
|
argument->v_uint64 = NUM2ULONG(rb_argument);
|
1198
2438
|
break;
|
1199
|
-
|
2439
|
+
case GI_TYPE_TAG_FLOAT:
|
1200
2440
|
argument->v_float = NUM2DBL(rb_argument);
|
1201
2441
|
break;
|
1202
|
-
|
2442
|
+
case GI_TYPE_TAG_DOUBLE:
|
1203
2443
|
argument->v_double = NUM2DBL(rb_argument);
|
1204
2444
|
break;
|
1205
|
-
|
2445
|
+
case GI_TYPE_TAG_GTYPE:
|
1206
2446
|
/* TODO: support GLib::Type and String as GType name. */
|
1207
2447
|
argument->v_size = NUM2ULONG(rb_argument);
|
1208
2448
|
break;
|
1209
|
-
|
2449
|
+
case GI_TYPE_TAG_UTF8:
|
1210
2450
|
/* TODO: support UTF-8 convert like rb_argument.encode("UTF-8"). */
|
1211
|
-
argument->v_string = (gchar *)
|
2451
|
+
argument->v_string = (gchar *)RVAL2CSTR_ACCEPT_SYMBOL(rb_argument);
|
1212
2452
|
break;
|
1213
|
-
|
2453
|
+
case GI_TYPE_TAG_FILENAME:
|
1214
2454
|
argument->v_string = (gchar *)RVAL2CSTR(rb_argument);
|
1215
2455
|
break;
|
1216
|
-
|
2456
|
+
case GI_TYPE_TAG_ARRAY:
|
1217
2457
|
rb_raise(rb_eNotImpError,
|
1218
2458
|
"should not be reached: Ruby -> GIArgument(%s)",
|
1219
2459
|
g_type_tag_to_string(type_tag));
|
1220
2460
|
break;
|
1221
|
-
|
1222
|
-
|
2461
|
+
case GI_TYPE_TAG_INTERFACE:
|
2462
|
+
rb_gi_value_argument_from_ruby_interface(argument, type_info,
|
2463
|
+
rb_argument, self);
|
2464
|
+
break;
|
2465
|
+
case GI_TYPE_TAG_GLIST:
|
2466
|
+
rb_gi_value_argument_from_ruby_glist(argument, type_info,
|
2467
|
+
rb_argument, self);
|
2468
|
+
break;
|
2469
|
+
case GI_TYPE_TAG_GSLIST:
|
2470
|
+
rb_gi_value_argument_from_ruby_gslist(argument, type_info,
|
2471
|
+
rb_argument, self);
|
1223
2472
|
break;
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
case GI_TYPE_TAG_ERROR:
|
1228
|
-
case GI_TYPE_TAG_UNICHAR:
|
2473
|
+
case GI_TYPE_TAG_GHASH:
|
2474
|
+
case GI_TYPE_TAG_ERROR:
|
2475
|
+
case GI_TYPE_TAG_UNICHAR:
|
1229
2476
|
rb_raise(rb_eNotImpError,
|
1230
2477
|
"TODO: Ruby -> GIArgument(%s)",
|
1231
2478
|
g_type_tag_to_string(type_tag));
|
1232
2479
|
break;
|
1233
|
-
|
2480
|
+
default:
|
1234
2481
|
g_assert_not_reached();
|
1235
2482
|
break;
|
1236
2483
|
}
|
@@ -1241,91 +2488,93 @@ rb_gi_value_argument_from_ruby(GIArgument *argument, GITypeInfo *type_info,
|
|
1241
2488
|
static void
|
1242
2489
|
rb_gi_inout_argument_from_ruby(GIArgument *argument,
|
1243
2490
|
G_GNUC_UNUSED GIArgInfo *arg_info,
|
1244
|
-
GITypeInfo *type_info,
|
2491
|
+
GITypeInfo *type_info,
|
2492
|
+
VALUE rb_argument,
|
2493
|
+
VALUE self)
|
1245
2494
|
{
|
1246
2495
|
GIArgument in_argument;
|
1247
2496
|
GITypeTag type_tag;
|
1248
2497
|
|
1249
|
-
rb_gi_value_argument_from_ruby(&in_argument, type_info, rb_argument);
|
2498
|
+
rb_gi_value_argument_from_ruby(&in_argument, type_info, rb_argument, self);
|
1250
2499
|
|
1251
2500
|
type_tag = g_type_info_get_tag(type_info);
|
1252
2501
|
switch (type_tag) {
|
1253
|
-
|
2502
|
+
case GI_TYPE_TAG_VOID:
|
1254
2503
|
break;
|
1255
|
-
|
2504
|
+
case GI_TYPE_TAG_BOOLEAN:
|
1256
2505
|
argument->v_pointer = ALLOC(gboolean);
|
1257
2506
|
*((gboolean *)argument->v_pointer) = in_argument.v_boolean;
|
1258
2507
|
break;
|
1259
|
-
|
2508
|
+
case GI_TYPE_TAG_INT8:
|
1260
2509
|
argument->v_pointer = ALLOC(gint8);
|
1261
2510
|
*((gint8 *)argument->v_pointer) = in_argument.v_int8;
|
1262
2511
|
break;
|
1263
|
-
|
2512
|
+
case GI_TYPE_TAG_UINT8:
|
1264
2513
|
argument->v_pointer = ALLOC(guint8);
|
1265
2514
|
*((guint8 *)argument->v_pointer) = in_argument.v_uint8;
|
1266
2515
|
break;
|
1267
|
-
|
2516
|
+
case GI_TYPE_TAG_INT16:
|
1268
2517
|
argument->v_pointer = ALLOC(gint16);
|
1269
2518
|
*((gint16 *)argument->v_pointer) = in_argument.v_int16;
|
1270
2519
|
break;
|
1271
|
-
|
2520
|
+
case GI_TYPE_TAG_UINT16:
|
1272
2521
|
argument->v_pointer = ALLOC(guint16);
|
1273
2522
|
*((guint16 *)argument->v_pointer) = in_argument.v_uint16;
|
1274
2523
|
break;
|
1275
|
-
|
2524
|
+
case GI_TYPE_TAG_INT32:
|
1276
2525
|
argument->v_pointer = ALLOC(gint32);
|
1277
2526
|
*((gint32 *)argument->v_pointer) = in_argument.v_int32;
|
1278
2527
|
break;
|
1279
|
-
|
2528
|
+
case GI_TYPE_TAG_UINT32:
|
1280
2529
|
argument->v_pointer = ALLOC(guint32);
|
1281
2530
|
*((guint32 *)argument->v_pointer) = in_argument.v_uint32;
|
1282
2531
|
break;
|
1283
|
-
|
2532
|
+
case GI_TYPE_TAG_INT64:
|
1284
2533
|
argument->v_pointer = ALLOC(gint64);
|
1285
2534
|
*((gint64 *)argument->v_pointer) = in_argument.v_int64;
|
1286
2535
|
break;
|
1287
|
-
|
2536
|
+
case GI_TYPE_TAG_UINT64:
|
1288
2537
|
argument->v_pointer = ALLOC(guint64);
|
1289
2538
|
*((guint64 *)argument->v_pointer) = in_argument.v_uint64;
|
1290
2539
|
break;
|
1291
|
-
|
2540
|
+
case GI_TYPE_TAG_FLOAT:
|
1292
2541
|
argument->v_pointer = ALLOC(gfloat);
|
1293
2542
|
*((gfloat *)argument->v_pointer) = in_argument.v_float;
|
1294
2543
|
break;
|
1295
|
-
|
2544
|
+
case GI_TYPE_TAG_DOUBLE:
|
1296
2545
|
argument->v_pointer = ALLOC(gdouble);
|
1297
2546
|
*((gdouble *)argument->v_pointer) = in_argument.v_double;
|
1298
2547
|
break;
|
1299
|
-
|
2548
|
+
case GI_TYPE_TAG_GTYPE:
|
1300
2549
|
argument->v_pointer = ALLOC(gsize);
|
1301
2550
|
*((gsize *)argument->v_pointer) = in_argument.v_size;
|
1302
2551
|
break;
|
1303
|
-
|
1304
|
-
|
2552
|
+
case GI_TYPE_TAG_UTF8:
|
2553
|
+
case GI_TYPE_TAG_FILENAME:
|
1305
2554
|
argument->v_pointer = ALLOC(gchar *);
|
1306
2555
|
*((gchar **)argument->v_pointer) = in_argument.v_string;
|
1307
2556
|
break;
|
1308
|
-
|
2557
|
+
case GI_TYPE_TAG_ARRAY:
|
1309
2558
|
rb_raise(rb_eNotImpError,
|
1310
2559
|
"should not be reached: Ruby -> GIArgument(%s)",
|
1311
2560
|
g_type_tag_to_string(type_tag));
|
1312
2561
|
break;
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
2562
|
+
case GI_TYPE_TAG_INTERFACE:
|
2563
|
+
case GI_TYPE_TAG_GLIST:
|
2564
|
+
case GI_TYPE_TAG_GSLIST:
|
2565
|
+
case GI_TYPE_TAG_GHASH:
|
1317
2566
|
argument->v_pointer = ALLOC(gpointer);
|
1318
2567
|
*((gpointer *)argument->v_pointer) = in_argument.v_pointer;
|
1319
2568
|
break;
|
1320
|
-
|
2569
|
+
case GI_TYPE_TAG_ERROR:
|
1321
2570
|
argument->v_pointer = ALLOC(GError *);
|
1322
2571
|
*((GError **)argument->v_pointer) = in_argument.v_pointer;
|
1323
2572
|
break;
|
1324
|
-
|
2573
|
+
case GI_TYPE_TAG_UNICHAR:
|
1325
2574
|
argument->v_pointer = ALLOC(gunichar);
|
1326
2575
|
*((gunichar *)argument->v_pointer) = in_argument.v_uint32;
|
1327
2576
|
break;
|
1328
|
-
|
2577
|
+
default:
|
1329
2578
|
g_assert_not_reached();
|
1330
2579
|
break;
|
1331
2580
|
}
|
@@ -1347,49 +2596,49 @@ rb_gi_in_argument_transfer_interface(GIArgument *argument,
|
|
1347
2596
|
g_base_info_unref(interface_info);
|
1348
2597
|
|
1349
2598
|
switch (interface_type) {
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
2599
|
+
case GI_INFO_TYPE_INVALID:
|
2600
|
+
case GI_INFO_TYPE_FUNCTION:
|
2601
|
+
case GI_INFO_TYPE_CALLBACK:
|
1353
2602
|
rb_raise(rb_eNotImpError,
|
1354
2603
|
"TODO: in transfer (interface) [%s]",
|
1355
2604
|
g_info_type_to_string(interface_type));
|
1356
2605
|
break;
|
1357
|
-
|
2606
|
+
case GI_INFO_TYPE_STRUCT:
|
1358
2607
|
rbgobj_boxed_unown(rb_argument);
|
1359
2608
|
break;
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
2609
|
+
case GI_INFO_TYPE_BOXED:
|
2610
|
+
case GI_INFO_TYPE_ENUM:
|
2611
|
+
case GI_INFO_TYPE_FLAGS:
|
1363
2612
|
rb_raise(rb_eNotImpError,
|
1364
2613
|
"TODO: in transfer (interface) [%s]",
|
1365
2614
|
g_info_type_to_string(interface_type));
|
1366
2615
|
break;
|
1367
|
-
|
2616
|
+
case GI_INFO_TYPE_OBJECT:
|
1368
2617
|
g_object_ref(argument->v_pointer);
|
1369
2618
|
break;
|
1370
|
-
|
1371
|
-
|
2619
|
+
case GI_INFO_TYPE_INTERFACE:
|
2620
|
+
case GI_INFO_TYPE_CONSTANT:
|
1372
2621
|
rb_raise(rb_eNotImpError,
|
1373
2622
|
"TODO: in transfer (interface) [%s]",
|
1374
2623
|
g_info_type_to_string(interface_type));
|
1375
2624
|
break;
|
1376
|
-
|
2625
|
+
case GI_INFO_TYPE_INVALID_0:
|
1377
2626
|
g_assert_not_reached();
|
1378
2627
|
break;
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
2628
|
+
case GI_INFO_TYPE_UNION:
|
2629
|
+
case GI_INFO_TYPE_VALUE:
|
2630
|
+
case GI_INFO_TYPE_SIGNAL:
|
2631
|
+
case GI_INFO_TYPE_VFUNC:
|
2632
|
+
case GI_INFO_TYPE_PROPERTY:
|
2633
|
+
case GI_INFO_TYPE_FIELD:
|
2634
|
+
case GI_INFO_TYPE_ARG:
|
2635
|
+
case GI_INFO_TYPE_TYPE:
|
2636
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
1388
2637
|
rb_raise(rb_eNotImpError,
|
1389
2638
|
"TODO: in transfer (interface) [%s]",
|
1390
2639
|
g_info_type_to_string(interface_type));
|
1391
2640
|
break;
|
1392
|
-
|
2641
|
+
default:
|
1393
2642
|
g_assert_not_reached();
|
1394
2643
|
break;
|
1395
2644
|
}
|
@@ -1407,40 +2656,40 @@ rb_gi_in_argument_transfer(GIArgument *argument, GITransfer transfer,
|
|
1407
2656
|
|
1408
2657
|
type_tag = g_type_info_get_tag(type_info);
|
1409
2658
|
switch (type_tag) {
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
break;
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
2659
|
+
case GI_TYPE_TAG_VOID:
|
2660
|
+
case GI_TYPE_TAG_BOOLEAN:
|
2661
|
+
case GI_TYPE_TAG_INT8:
|
2662
|
+
case GI_TYPE_TAG_UINT8:
|
2663
|
+
case GI_TYPE_TAG_INT16:
|
2664
|
+
case GI_TYPE_TAG_UINT16:
|
2665
|
+
case GI_TYPE_TAG_INT32:
|
2666
|
+
case GI_TYPE_TAG_UINT32:
|
2667
|
+
case GI_TYPE_TAG_INT64:
|
2668
|
+
case GI_TYPE_TAG_UINT64:
|
2669
|
+
case GI_TYPE_TAG_FLOAT:
|
2670
|
+
case GI_TYPE_TAG_DOUBLE:
|
2671
|
+
case GI_TYPE_TAG_GTYPE:
|
2672
|
+
break;
|
2673
|
+
case GI_TYPE_TAG_UTF8:
|
2674
|
+
case GI_TYPE_TAG_FILENAME:
|
2675
|
+
case GI_TYPE_TAG_ARRAY:
|
1427
2676
|
rb_raise(rb_eNotImpError,
|
1428
2677
|
"TODO: in transfer (%s)",
|
1429
2678
|
g_type_tag_to_string(type_tag));
|
1430
2679
|
break;
|
1431
|
-
|
2680
|
+
case GI_TYPE_TAG_INTERFACE:
|
1432
2681
|
rb_gi_in_argument_transfer_interface(argument, transfer,
|
1433
2682
|
type_info, rb_argument);
|
1434
2683
|
break;
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
2684
|
+
case GI_TYPE_TAG_GLIST:
|
2685
|
+
case GI_TYPE_TAG_GSLIST:
|
2686
|
+
case GI_TYPE_TAG_GHASH:
|
2687
|
+
case GI_TYPE_TAG_ERROR:
|
2688
|
+
case GI_TYPE_TAG_UNICHAR:
|
1440
2689
|
rb_raise(rb_eNotImpError,
|
1441
2690
|
"TODO: in transfer (%s)",
|
1442
2691
|
g_type_tag_to_string(type_tag));
|
1443
|
-
|
2692
|
+
default:
|
1444
2693
|
g_assert_not_reached();
|
1445
2694
|
break;
|
1446
2695
|
}
|
@@ -1448,93 +2697,221 @@ rb_gi_in_argument_transfer(GIArgument *argument, GITransfer transfer,
|
|
1448
2697
|
|
1449
2698
|
GIArgument *
|
1450
2699
|
rb_gi_in_argument_from_ruby(GIArgument *argument, GIArgInfo *arg_info,
|
1451
|
-
VALUE rb_argument)
|
2700
|
+
VALUE rb_argument, VALUE self)
|
1452
2701
|
{
|
1453
2702
|
GITypeInfo type_info;
|
1454
2703
|
|
1455
|
-
if (g_arg_info_may_be_null(arg_info) && NIL_P(rb_argument)) {
|
1456
|
-
memset(argument, 0, sizeof(GIArgument));
|
1457
|
-
return argument;
|
2704
|
+
if (g_arg_info_may_be_null(arg_info) && NIL_P(rb_argument)) {
|
2705
|
+
memset(argument, 0, sizeof(GIArgument));
|
2706
|
+
return argument;
|
2707
|
+
}
|
2708
|
+
|
2709
|
+
g_arg_info_load_type(arg_info, &type_info);
|
2710
|
+
if (g_arg_info_get_direction(arg_info) == GI_DIRECTION_INOUT) {
|
2711
|
+
rb_gi_inout_argument_from_ruby(argument, arg_info, &type_info,
|
2712
|
+
rb_argument, self);
|
2713
|
+
} else {
|
2714
|
+
rb_gi_value_argument_from_ruby(argument, &type_info, rb_argument, self);
|
2715
|
+
rb_gi_in_argument_transfer(argument,
|
2716
|
+
g_arg_info_get_ownership_transfer(arg_info),
|
2717
|
+
&type_info,
|
2718
|
+
rb_argument);
|
2719
|
+
}
|
2720
|
+
|
2721
|
+
return argument;
|
2722
|
+
}
|
2723
|
+
|
2724
|
+
static void
|
2725
|
+
set_in_array_length_argument(GIArgument *argument,
|
2726
|
+
GITypeInfo *type_info,
|
2727
|
+
gint64 length)
|
2728
|
+
{
|
2729
|
+
GITypeTag type_tag;
|
2730
|
+
|
2731
|
+
if (!argument) {
|
2732
|
+
return;
|
2733
|
+
}
|
2734
|
+
|
2735
|
+
type_tag = g_type_info_get_tag(type_info);
|
2736
|
+
switch (type_tag) {
|
2737
|
+
case GI_TYPE_TAG_VOID:
|
2738
|
+
case GI_TYPE_TAG_BOOLEAN:
|
2739
|
+
rb_raise(rb_eNotImpError,
|
2740
|
+
"TODO: invalid argument?: length[%s]",
|
2741
|
+
g_type_tag_to_string(type_tag));
|
2742
|
+
break;
|
2743
|
+
case GI_TYPE_TAG_INT8:
|
2744
|
+
argument->v_int8 = length;
|
2745
|
+
break;
|
2746
|
+
case GI_TYPE_TAG_UINT8:
|
2747
|
+
argument->v_uint8 = length;
|
2748
|
+
break;
|
2749
|
+
case GI_TYPE_TAG_INT16:
|
2750
|
+
argument->v_int16 = length;
|
2751
|
+
break;
|
2752
|
+
case GI_TYPE_TAG_UINT16:
|
2753
|
+
argument->v_uint16 = length;
|
2754
|
+
break;
|
2755
|
+
case GI_TYPE_TAG_INT32:
|
2756
|
+
argument->v_int32 = length;
|
2757
|
+
break;
|
2758
|
+
case GI_TYPE_TAG_UINT32:
|
2759
|
+
argument->v_uint32 = length;
|
2760
|
+
break;
|
2761
|
+
case GI_TYPE_TAG_INT64:
|
2762
|
+
argument->v_int64 = length;
|
2763
|
+
break;
|
2764
|
+
case GI_TYPE_TAG_UINT64:
|
2765
|
+
argument->v_uint64 = length;
|
2766
|
+
break;
|
2767
|
+
case GI_TYPE_TAG_FLOAT:
|
2768
|
+
case GI_TYPE_TAG_DOUBLE:
|
2769
|
+
case GI_TYPE_TAG_GTYPE:
|
2770
|
+
case GI_TYPE_TAG_UTF8:
|
2771
|
+
case GI_TYPE_TAG_FILENAME:
|
2772
|
+
case GI_TYPE_TAG_ARRAY:
|
2773
|
+
case GI_TYPE_TAG_INTERFACE:
|
2774
|
+
case GI_TYPE_TAG_GLIST:
|
2775
|
+
case GI_TYPE_TAG_GSLIST:
|
2776
|
+
case GI_TYPE_TAG_GHASH:
|
2777
|
+
case GI_TYPE_TAG_ERROR:
|
2778
|
+
case GI_TYPE_TAG_UNICHAR:
|
2779
|
+
rb_raise(rb_eNotImpError,
|
2780
|
+
"TODO: invalid argument?: length[%s]",
|
2781
|
+
g_type_tag_to_string(type_tag));
|
2782
|
+
break;
|
2783
|
+
default:
|
2784
|
+
g_assert_not_reached();
|
2785
|
+
break;
|
2786
|
+
}
|
2787
|
+
}
|
2788
|
+
|
2789
|
+
static void
|
2790
|
+
set_in_array_int16_arguments_from_ruby(GIArgument *array_argument,
|
2791
|
+
VALUE rb_number_array)
|
2792
|
+
{
|
2793
|
+
gint16 *numbers;
|
2794
|
+
gint i, n_args;
|
2795
|
+
|
2796
|
+
n_args = RARRAY_LEN(rb_number_array);
|
2797
|
+
numbers = ALLOC_N(gint16, n_args);
|
2798
|
+
for (i = 0; i < n_args; i++) {
|
2799
|
+
numbers[i] = NUM2INT(RARRAY_PTR(rb_number_array)[i]);
|
2800
|
+
}
|
2801
|
+
|
2802
|
+
array_argument->v_pointer = numbers;
|
2803
|
+
}
|
2804
|
+
|
2805
|
+
static void
|
2806
|
+
set_in_array_uint16_arguments_from_ruby(GIArgument *array_argument,
|
2807
|
+
VALUE rb_number_array)
|
2808
|
+
{
|
2809
|
+
guint16 *numbers;
|
2810
|
+
gint i, n_args;
|
2811
|
+
|
2812
|
+
n_args = RARRAY_LEN(rb_number_array);
|
2813
|
+
numbers = ALLOC_N(guint16, n_args);
|
2814
|
+
for (i = 0; i < n_args; i++) {
|
2815
|
+
numbers[i] = NUM2UINT(RARRAY_PTR(rb_number_array)[i]);
|
2816
|
+
}
|
2817
|
+
|
2818
|
+
array_argument->v_pointer = numbers;
|
2819
|
+
}
|
2820
|
+
|
2821
|
+
static void
|
2822
|
+
set_in_array_int32_arguments_from_ruby(GIArgument *array_argument,
|
2823
|
+
VALUE rb_number_array)
|
2824
|
+
{
|
2825
|
+
gint32 *numbers;
|
2826
|
+
gint i, n_args;
|
2827
|
+
|
2828
|
+
n_args = RARRAY_LEN(rb_number_array);
|
2829
|
+
numbers = ALLOC_N(gint32, n_args);
|
2830
|
+
for (i = 0; i < n_args; i++) {
|
2831
|
+
numbers[i] = NUM2INT(RARRAY_PTR(rb_number_array)[i]);
|
2832
|
+
}
|
2833
|
+
|
2834
|
+
array_argument->v_pointer = numbers;
|
2835
|
+
}
|
2836
|
+
|
2837
|
+
static void
|
2838
|
+
set_in_array_uint32_arguments_from_ruby(GIArgument *array_argument,
|
2839
|
+
VALUE rb_number_array)
|
2840
|
+
{
|
2841
|
+
guint32 *numbers;
|
2842
|
+
gint i, n_args;
|
2843
|
+
|
2844
|
+
n_args = RARRAY_LEN(rb_number_array);
|
2845
|
+
numbers = ALLOC_N(guint32, n_args);
|
2846
|
+
for (i = 0; i < n_args; i++) {
|
2847
|
+
numbers[i] = NUM2UINT(RARRAY_PTR(rb_number_array)[i]);
|
2848
|
+
}
|
2849
|
+
|
2850
|
+
array_argument->v_pointer = numbers;
|
2851
|
+
}
|
2852
|
+
|
2853
|
+
static void
|
2854
|
+
set_in_array_int64_arguments_from_ruby(GIArgument *array_argument,
|
2855
|
+
VALUE rb_number_array)
|
2856
|
+
{
|
2857
|
+
gint64 *numbers;
|
2858
|
+
gint i, n_args;
|
2859
|
+
|
2860
|
+
n_args = RARRAY_LEN(rb_number_array);
|
2861
|
+
numbers = ALLOC_N(gint64, n_args);
|
2862
|
+
for (i = 0; i < n_args; i++) {
|
2863
|
+
numbers[i] = NUM2LONG(RARRAY_PTR(rb_number_array)[i]);
|
2864
|
+
}
|
2865
|
+
|
2866
|
+
array_argument->v_pointer = numbers;
|
2867
|
+
}
|
2868
|
+
|
2869
|
+
static void
|
2870
|
+
set_in_array_uint64_arguments_from_ruby(GIArgument *array_argument,
|
2871
|
+
VALUE rb_number_array)
|
2872
|
+
{
|
2873
|
+
guint64 *numbers;
|
2874
|
+
gint i, n_args;
|
2875
|
+
|
2876
|
+
n_args = RARRAY_LEN(rb_number_array);
|
2877
|
+
numbers = ALLOC_N(guint64, n_args);
|
2878
|
+
for (i = 0; i < n_args; i++) {
|
2879
|
+
numbers[i] = NUM2ULONG(RARRAY_PTR(rb_number_array)[i]);
|
1458
2880
|
}
|
1459
2881
|
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
2882
|
+
array_argument->v_pointer = numbers;
|
2883
|
+
}
|
2884
|
+
|
2885
|
+
static void
|
2886
|
+
set_in_array_float_arguments_from_ruby(GIArgument *array_argument,
|
2887
|
+
VALUE rb_number_array)
|
2888
|
+
{
|
2889
|
+
gfloat *numbers;
|
2890
|
+
gint i, n_args;
|
2891
|
+
|
2892
|
+
n_args = RARRAY_LEN(rb_number_array);
|
2893
|
+
numbers = ALLOC_N(gfloat, n_args);
|
2894
|
+
for (i = 0; i < n_args; i++) {
|
2895
|
+
numbers[i] = NUM2DBL(RARRAY_PTR(rb_number_array)[i]);
|
1470
2896
|
}
|
1471
2897
|
|
1472
|
-
|
2898
|
+
array_argument->v_pointer = numbers;
|
1473
2899
|
}
|
1474
2900
|
|
1475
2901
|
static void
|
1476
|
-
|
1477
|
-
|
1478
|
-
gint64 length)
|
2902
|
+
set_in_array_double_arguments_from_ruby(GIArgument *array_argument,
|
2903
|
+
VALUE rb_number_array)
|
1479
2904
|
{
|
1480
|
-
|
2905
|
+
gdouble *numbers;
|
2906
|
+
gint i, n_args;
|
1481
2907
|
|
1482
|
-
|
1483
|
-
|
2908
|
+
n_args = RARRAY_LEN(rb_number_array);
|
2909
|
+
numbers = ALLOC_N(gdouble, n_args);
|
2910
|
+
for (i = 0; i < n_args; i++) {
|
2911
|
+
numbers[i] = NUM2DBL(RARRAY_PTR(rb_number_array)[i]);
|
1484
2912
|
}
|
1485
2913
|
|
1486
|
-
|
1487
|
-
switch (type_tag) {
|
1488
|
-
case GI_TYPE_TAG_VOID:
|
1489
|
-
case GI_TYPE_TAG_BOOLEAN:
|
1490
|
-
rb_raise(rb_eNotImpError,
|
1491
|
-
"TODO: invalid argument?: length[%s]",
|
1492
|
-
g_type_tag_to_string(type_tag));
|
1493
|
-
break;
|
1494
|
-
case GI_TYPE_TAG_INT8:
|
1495
|
-
argument->v_int8 = length;
|
1496
|
-
break;
|
1497
|
-
case GI_TYPE_TAG_UINT8:
|
1498
|
-
argument->v_uint8 = length;
|
1499
|
-
break;
|
1500
|
-
case GI_TYPE_TAG_INT16:
|
1501
|
-
argument->v_int16 = length;
|
1502
|
-
break;
|
1503
|
-
case GI_TYPE_TAG_UINT16:
|
1504
|
-
argument->v_uint16 = length;
|
1505
|
-
break;
|
1506
|
-
case GI_TYPE_TAG_INT32:
|
1507
|
-
argument->v_int32 = length;
|
1508
|
-
break;
|
1509
|
-
case GI_TYPE_TAG_UINT32:
|
1510
|
-
argument->v_uint32 = length;
|
1511
|
-
break;
|
1512
|
-
case GI_TYPE_TAG_INT64:
|
1513
|
-
argument->v_int64 = length;
|
1514
|
-
break;
|
1515
|
-
case GI_TYPE_TAG_UINT64:
|
1516
|
-
argument->v_uint64 = length;
|
1517
|
-
break;
|
1518
|
-
case GI_TYPE_TAG_FLOAT:
|
1519
|
-
case GI_TYPE_TAG_DOUBLE:
|
1520
|
-
case GI_TYPE_TAG_GTYPE:
|
1521
|
-
case GI_TYPE_TAG_UTF8:
|
1522
|
-
case GI_TYPE_TAG_FILENAME:
|
1523
|
-
case GI_TYPE_TAG_ARRAY:
|
1524
|
-
case GI_TYPE_TAG_INTERFACE:
|
1525
|
-
case GI_TYPE_TAG_GLIST:
|
1526
|
-
case GI_TYPE_TAG_GSLIST:
|
1527
|
-
case GI_TYPE_TAG_GHASH:
|
1528
|
-
case GI_TYPE_TAG_ERROR:
|
1529
|
-
case GI_TYPE_TAG_UNICHAR:
|
1530
|
-
rb_raise(rb_eNotImpError,
|
1531
|
-
"TODO: invalid argument?: length[%s]",
|
1532
|
-
g_type_tag_to_string(type_tag));
|
1533
|
-
break;
|
1534
|
-
default:
|
1535
|
-
g_assert_not_reached();
|
1536
|
-
break;
|
1537
|
-
}
|
2914
|
+
array_argument->v_pointer = numbers;
|
1538
2915
|
}
|
1539
2916
|
|
1540
2917
|
static void
|
@@ -1553,6 +2930,134 @@ set_in_array_gtype_arguments_from_ruby(GIArgument *array_argument,
|
|
1553
2930
|
array_argument->v_pointer = types;
|
1554
2931
|
}
|
1555
2932
|
|
2933
|
+
typedef struct {
|
2934
|
+
GType element_gtype;
|
2935
|
+
gsize element_size;
|
2936
|
+
VALUE rb_argument;
|
2937
|
+
gint n_args;
|
2938
|
+
gchar *values;
|
2939
|
+
} ArrayInterfaceStructFromRubyData;
|
2940
|
+
|
2941
|
+
static VALUE
|
2942
|
+
set_in_array_interface_struct_arguments_from_ruby_body(VALUE value)
|
2943
|
+
{
|
2944
|
+
ArrayInterfaceStructFromRubyData *data;
|
2945
|
+
gint i;
|
2946
|
+
|
2947
|
+
data = (ArrayInterfaceStructFromRubyData *)value;
|
2948
|
+
|
2949
|
+
for (i = 0; i < data->n_args; i++) {
|
2950
|
+
VALUE rb_element;
|
2951
|
+
gpointer element;
|
2952
|
+
|
2953
|
+
rb_element = RARRAY_PTR(data->rb_argument)[i];
|
2954
|
+
if (data->element_gtype == G_TYPE_NONE) {
|
2955
|
+
element = interface_struct_from_ruby(rb_element);
|
2956
|
+
} else {
|
2957
|
+
element = RVAL2BOXED(rb_element, data->element_gtype);
|
2958
|
+
}
|
2959
|
+
memcpy(data->values + (data->element_size * i),
|
2960
|
+
element,
|
2961
|
+
data->element_size);
|
2962
|
+
}
|
2963
|
+
|
2964
|
+
return Qnil;
|
2965
|
+
}
|
2966
|
+
|
2967
|
+
static G_GNUC_NORETURN VALUE
|
2968
|
+
set_in_array_interface_struct_arguments_from_ruby_rescue(VALUE value)
|
2969
|
+
{
|
2970
|
+
ArrayInterfaceStructFromRubyData *data;
|
2971
|
+
|
2972
|
+
data = (ArrayInterfaceStructFromRubyData *)value;
|
2973
|
+
xfree(data->values);
|
2974
|
+
|
2975
|
+
rb_exc_raise(rb_errinfo());
|
2976
|
+
}
|
2977
|
+
|
2978
|
+
static void
|
2979
|
+
set_in_array_interface_struct_arguments_from_ruby(GIArgument *array_argument,
|
2980
|
+
GType element_gtype,
|
2981
|
+
gsize element_size,
|
2982
|
+
VALUE rb_argument)
|
2983
|
+
{
|
2984
|
+
ArrayInterfaceStructFromRubyData data;
|
2985
|
+
|
2986
|
+
data.element_gtype = element_gtype;
|
2987
|
+
data.element_size = element_size;
|
2988
|
+
data.rb_argument = rb_argument;
|
2989
|
+
data.n_args = RARRAY_LEN(rb_argument);
|
2990
|
+
data.values = xmalloc(data.element_size * data.n_args);
|
2991
|
+
rb_rescue(set_in_array_interface_struct_arguments_from_ruby_body,
|
2992
|
+
(VALUE)&data,
|
2993
|
+
set_in_array_interface_struct_arguments_from_ruby_rescue,
|
2994
|
+
(VALUE)&data);
|
2995
|
+
array_argument->v_pointer = data.values;
|
2996
|
+
}
|
2997
|
+
|
2998
|
+
static void
|
2999
|
+
set_in_array_interface_arguments_from_ruby(GIArgument *array_argument,
|
3000
|
+
GITypeInfo *element_type_info,
|
3001
|
+
VALUE rb_argument)
|
3002
|
+
{
|
3003
|
+
GIBaseInfo *interface_info;
|
3004
|
+
GIInfoType interface_type;
|
3005
|
+
GType gtype;
|
3006
|
+
const char *interface_name;
|
3007
|
+
gsize size;
|
3008
|
+
|
3009
|
+
interface_info = g_type_info_get_interface(element_type_info);
|
3010
|
+
interface_type = g_base_info_get_type(interface_info);
|
3011
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
3012
|
+
|
3013
|
+
switch (interface_type) {
|
3014
|
+
case GI_INFO_TYPE_INVALID:
|
3015
|
+
case GI_INFO_TYPE_FUNCTION:
|
3016
|
+
case GI_INFO_TYPE_CALLBACK:
|
3017
|
+
interface_name = g_info_type_to_string(interface_type);
|
3018
|
+
g_base_info_unref(interface_info);
|
3019
|
+
rb_raise(rb_eNotImpError,
|
3020
|
+
"TODO: Ruby -> GIArgument(array)[interface(%s)](%s)",
|
3021
|
+
interface_name,
|
3022
|
+
g_type_name(gtype));
|
3023
|
+
break;
|
3024
|
+
case GI_INFO_TYPE_STRUCT:
|
3025
|
+
size = g_struct_info_get_size(interface_info);
|
3026
|
+
g_base_info_unref(interface_info);
|
3027
|
+
set_in_array_interface_struct_arguments_from_ruby(array_argument,
|
3028
|
+
gtype,
|
3029
|
+
size,
|
3030
|
+
rb_argument);
|
3031
|
+
break;
|
3032
|
+
case GI_INFO_TYPE_BOXED:
|
3033
|
+
case GI_INFO_TYPE_ENUM:
|
3034
|
+
case GI_INFO_TYPE_FLAGS:
|
3035
|
+
case GI_INFO_TYPE_OBJECT:
|
3036
|
+
case GI_INFO_TYPE_INTERFACE:
|
3037
|
+
case GI_INFO_TYPE_CONSTANT:
|
3038
|
+
case GI_INFO_TYPE_INVALID_0:
|
3039
|
+
case GI_INFO_TYPE_UNION:
|
3040
|
+
case GI_INFO_TYPE_VALUE:
|
3041
|
+
case GI_INFO_TYPE_SIGNAL:
|
3042
|
+
case GI_INFO_TYPE_VFUNC:
|
3043
|
+
case GI_INFO_TYPE_PROPERTY:
|
3044
|
+
case GI_INFO_TYPE_FIELD:
|
3045
|
+
case GI_INFO_TYPE_ARG:
|
3046
|
+
case GI_INFO_TYPE_TYPE:
|
3047
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
3048
|
+
interface_name = g_info_type_to_string(interface_type);
|
3049
|
+
g_base_info_unref(interface_info);
|
3050
|
+
rb_raise(rb_eNotImpError,
|
3051
|
+
"TODO: Ruby -> GIArgument(array)[interface(%s)](%s)",
|
3052
|
+
interface_name,
|
3053
|
+
g_type_name(gtype));
|
3054
|
+
break;
|
3055
|
+
default:
|
3056
|
+
g_assert_not_reached();
|
3057
|
+
break;
|
3058
|
+
}
|
3059
|
+
}
|
3060
|
+
|
1556
3061
|
static void
|
1557
3062
|
in_array_c_argument_from_ruby(GIArgument *array_argument,
|
1558
3063
|
GIArgument *length_argument,
|
@@ -1565,54 +3070,103 @@ in_array_c_argument_from_ruby(GIArgument *array_argument,
|
|
1565
3070
|
|
1566
3071
|
element_type_tag = g_type_info_get_tag(element_type_info);
|
1567
3072
|
switch (element_type_tag) {
|
1568
|
-
|
1569
|
-
|
3073
|
+
case GI_TYPE_TAG_VOID:
|
3074
|
+
case GI_TYPE_TAG_BOOLEAN:
|
1570
3075
|
rb_raise(rb_eNotImpError,
|
1571
3076
|
"TODO: Ruby -> GIArgument(array)[%s]",
|
1572
3077
|
g_type_tag_to_string(element_type_tag));
|
1573
3078
|
break;
|
1574
|
-
|
1575
|
-
|
3079
|
+
case GI_TYPE_TAG_INT8:
|
3080
|
+
case GI_TYPE_TAG_UINT8:
|
1576
3081
|
array_argument->v_pointer = RSTRING_PTR(rb_argument);
|
1577
3082
|
set_in_array_length_argument(length_argument, length_type_info,
|
1578
3083
|
RSTRING_LEN(rb_argument));
|
1579
3084
|
break;
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
3085
|
+
case GI_TYPE_TAG_INT16:
|
3086
|
+
rb_argument = rbg_to_array(rb_argument);
|
3087
|
+
set_in_array_int16_arguments_from_ruby(array_argument, rb_argument);
|
3088
|
+
set_in_array_length_argument(length_argument, length_type_info,
|
3089
|
+
RARRAY_LEN(rb_argument));
|
3090
|
+
break;
|
3091
|
+
case GI_TYPE_TAG_UINT16:
|
3092
|
+
rb_argument = rbg_to_array(rb_argument);
|
3093
|
+
set_in_array_uint16_arguments_from_ruby(array_argument, rb_argument);
|
3094
|
+
set_in_array_length_argument(length_argument, length_type_info,
|
3095
|
+
RARRAY_LEN(rb_argument));
|
3096
|
+
break;
|
3097
|
+
case GI_TYPE_TAG_INT32:
|
3098
|
+
rb_argument = rbg_to_array(rb_argument);
|
3099
|
+
set_in_array_int32_arguments_from_ruby(array_argument, rb_argument);
|
3100
|
+
set_in_array_length_argument(length_argument, length_type_info,
|
3101
|
+
RARRAY_LEN(rb_argument));
|
3102
|
+
break;
|
3103
|
+
case GI_TYPE_TAG_UINT32:
|
3104
|
+
rb_argument = rbg_to_array(rb_argument);
|
3105
|
+
set_in_array_uint32_arguments_from_ruby(array_argument, rb_argument);
|
3106
|
+
set_in_array_length_argument(length_argument, length_type_info,
|
3107
|
+
RARRAY_LEN(rb_argument));
|
3108
|
+
break;
|
3109
|
+
case GI_TYPE_TAG_INT64:
|
3110
|
+
rb_argument = rbg_to_array(rb_argument);
|
3111
|
+
set_in_array_int64_arguments_from_ruby(array_argument, rb_argument);
|
3112
|
+
set_in_array_length_argument(length_argument, length_type_info,
|
3113
|
+
RARRAY_LEN(rb_argument));
|
3114
|
+
break;
|
3115
|
+
case GI_TYPE_TAG_UINT64:
|
3116
|
+
rb_argument = rbg_to_array(rb_argument);
|
3117
|
+
set_in_array_uint64_arguments_from_ruby(array_argument, rb_argument);
|
3118
|
+
set_in_array_length_argument(length_argument, length_type_info,
|
3119
|
+
RARRAY_LEN(rb_argument));
|
3120
|
+
break;
|
3121
|
+
case GI_TYPE_TAG_FLOAT:
|
3122
|
+
rb_argument = rbg_to_array(rb_argument);
|
3123
|
+
set_in_array_float_arguments_from_ruby(array_argument, rb_argument);
|
3124
|
+
set_in_array_length_argument(length_argument, length_type_info,
|
3125
|
+
RARRAY_LEN(rb_argument));
|
3126
|
+
break;
|
3127
|
+
case GI_TYPE_TAG_DOUBLE:
|
3128
|
+
rb_argument = rbg_to_array(rb_argument);
|
3129
|
+
set_in_array_double_arguments_from_ruby(array_argument, rb_argument);
|
3130
|
+
set_in_array_length_argument(length_argument, length_type_info,
|
3131
|
+
RARRAY_LEN(rb_argument));
|
1591
3132
|
break;
|
1592
|
-
|
3133
|
+
case GI_TYPE_TAG_GTYPE:
|
3134
|
+
rb_argument = rbg_to_array(rb_argument);
|
1593
3135
|
set_in_array_gtype_arguments_from_ruby(array_argument,
|
1594
3136
|
rb_argument);
|
1595
3137
|
set_in_array_length_argument(length_argument, length_type_info,
|
1596
3138
|
RARRAY_LEN(rb_argument));
|
1597
3139
|
break;
|
1598
|
-
|
1599
|
-
|
3140
|
+
case GI_TYPE_TAG_UTF8:
|
3141
|
+
case GI_TYPE_TAG_FILENAME:
|
3142
|
+
rb_argument = rbg_to_array(rb_argument);
|
1600
3143
|
array_argument->v_pointer = RVAL2STRV(rb_argument);
|
1601
3144
|
set_in_array_length_argument(length_argument, length_type_info,
|
1602
3145
|
RARRAY_LEN(rb_argument));
|
1603
3146
|
break;
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
3147
|
+
case GI_TYPE_TAG_ARRAY:
|
3148
|
+
rb_raise(rb_eNotImpError,
|
3149
|
+
"TODO: Ruby -> GIArgument(array)[%s]",
|
3150
|
+
g_type_tag_to_string(element_type_tag));
|
3151
|
+
break;
|
3152
|
+
case GI_TYPE_TAG_INTERFACE:
|
3153
|
+
rb_argument = rbg_to_array(rb_argument);
|
3154
|
+
set_in_array_interface_arguments_from_ruby(array_argument,
|
3155
|
+
element_type_info,
|
3156
|
+
rb_argument);
|
3157
|
+
set_in_array_length_argument(length_argument, length_type_info,
|
3158
|
+
RARRAY_LEN(rb_argument));
|
3159
|
+
break;
|
3160
|
+
case GI_TYPE_TAG_GLIST:
|
3161
|
+
case GI_TYPE_TAG_GSLIST:
|
3162
|
+
case GI_TYPE_TAG_GHASH:
|
3163
|
+
case GI_TYPE_TAG_ERROR:
|
3164
|
+
case GI_TYPE_TAG_UNICHAR:
|
1611
3165
|
rb_raise(rb_eNotImpError,
|
1612
3166
|
"TODO: Ruby -> GIArgument(array)[%s]",
|
1613
3167
|
g_type_tag_to_string(element_type_tag));
|
1614
3168
|
break;
|
1615
|
-
|
3169
|
+
default:
|
1616
3170
|
g_assert_not_reached();
|
1617
3171
|
break;
|
1618
3172
|
}
|
@@ -1631,7 +3185,7 @@ in_array_argument_from_ruby(GIArgument *array_argument,
|
|
1631
3185
|
array_type = g_type_info_get_array_type(array_type_info);
|
1632
3186
|
element_type_info = g_type_info_get_param_type(array_type_info, 0);
|
1633
3187
|
switch (array_type) {
|
1634
|
-
|
3188
|
+
case GI_ARRAY_TYPE_C:
|
1635
3189
|
in_array_c_argument_from_ruby(array_argument,
|
1636
3190
|
length_argument,
|
1637
3191
|
array_type_info,
|
@@ -1639,14 +3193,14 @@ in_array_argument_from_ruby(GIArgument *array_argument,
|
|
1639
3193
|
element_type_info,
|
1640
3194
|
rb_argument);
|
1641
3195
|
break;
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
3196
|
+
case GI_ARRAY_TYPE_ARRAY:
|
3197
|
+
case GI_ARRAY_TYPE_PTR_ARRAY:
|
3198
|
+
case GI_ARRAY_TYPE_BYTE_ARRAY:
|
1645
3199
|
rb_raise(rb_eNotImpError,
|
1646
3200
|
"TODO: Ruby -> GIArgument(array)[%s]",
|
1647
3201
|
g_type_tag_to_string(g_type_info_get_tag(element_type_info)));
|
1648
3202
|
break;
|
1649
|
-
|
3203
|
+
default:
|
1650
3204
|
g_assert_not_reached();
|
1651
3205
|
break;
|
1652
3206
|
}
|
@@ -1666,61 +3220,61 @@ set_inout_array_length_argument(GIArgument *argument,
|
|
1666
3220
|
|
1667
3221
|
type_tag = g_type_info_get_tag(type_info);
|
1668
3222
|
switch (type_tag) {
|
1669
|
-
|
1670
|
-
|
3223
|
+
case GI_TYPE_TAG_VOID:
|
3224
|
+
case GI_TYPE_TAG_BOOLEAN:
|
1671
3225
|
rb_raise(rb_eNotImpError,
|
1672
3226
|
"TODO: invalid argument?: length[%s]",
|
1673
3227
|
g_type_tag_to_string(type_tag));
|
1674
3228
|
break;
|
1675
|
-
|
3229
|
+
case GI_TYPE_TAG_INT8:
|
1676
3230
|
argument->v_pointer = ALLOC(gint8);
|
1677
3231
|
*((gint8 *)argument->v_pointer) = length->v_int8;
|
1678
3232
|
break;
|
1679
|
-
|
3233
|
+
case GI_TYPE_TAG_UINT8:
|
1680
3234
|
argument->v_pointer = ALLOC(guint8);
|
1681
3235
|
*((guint8 *)argument->v_pointer) = length->v_uint8;
|
1682
3236
|
break;
|
1683
|
-
|
3237
|
+
case GI_TYPE_TAG_INT16:
|
1684
3238
|
argument->v_pointer = ALLOC(gint16);
|
1685
3239
|
*((gint16 *)argument->v_pointer) = length->v_int16;
|
1686
3240
|
break;
|
1687
|
-
|
3241
|
+
case GI_TYPE_TAG_UINT16:
|
1688
3242
|
argument->v_pointer = ALLOC(guint16);
|
1689
3243
|
*((guint16 *)argument->v_pointer) = length->v_uint16;
|
1690
3244
|
break;
|
1691
|
-
|
3245
|
+
case GI_TYPE_TAG_INT32:
|
1692
3246
|
argument->v_pointer = ALLOC(gint32);
|
1693
3247
|
*((gint32 *)argument->v_pointer) = length->v_int32;
|
1694
3248
|
break;
|
1695
|
-
|
3249
|
+
case GI_TYPE_TAG_UINT32:
|
1696
3250
|
argument->v_pointer = ALLOC(guint32);
|
1697
3251
|
*((guint32 *)argument->v_pointer) = length->v_uint32;
|
1698
3252
|
break;
|
1699
|
-
|
3253
|
+
case GI_TYPE_TAG_INT64:
|
1700
3254
|
argument->v_pointer = ALLOC(gint64);
|
1701
3255
|
*((gint64 *)argument->v_pointer) = length->v_int64;
|
1702
3256
|
break;
|
1703
|
-
|
3257
|
+
case GI_TYPE_TAG_UINT64:
|
1704
3258
|
argument->v_pointer = ALLOC(guint64);
|
1705
3259
|
*((guint64 *)argument->v_pointer) = length->v_uint64;
|
1706
3260
|
break;
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
3261
|
+
case GI_TYPE_TAG_FLOAT:
|
3262
|
+
case GI_TYPE_TAG_DOUBLE:
|
3263
|
+
case GI_TYPE_TAG_GTYPE:
|
3264
|
+
case GI_TYPE_TAG_UTF8:
|
3265
|
+
case GI_TYPE_TAG_FILENAME:
|
3266
|
+
case GI_TYPE_TAG_ARRAY:
|
3267
|
+
case GI_TYPE_TAG_INTERFACE:
|
3268
|
+
case GI_TYPE_TAG_GLIST:
|
3269
|
+
case GI_TYPE_TAG_GSLIST:
|
3270
|
+
case GI_TYPE_TAG_GHASH:
|
3271
|
+
case GI_TYPE_TAG_ERROR:
|
3272
|
+
case GI_TYPE_TAG_UNICHAR:
|
1719
3273
|
rb_raise(rb_eNotImpError,
|
1720
3274
|
"TODO: invalid argument?: length[%s]",
|
1721
3275
|
g_type_tag_to_string(type_tag));
|
1722
3276
|
break;
|
1723
|
-
|
3277
|
+
default:
|
1724
3278
|
g_assert_not_reached();
|
1725
3279
|
break;
|
1726
3280
|
}
|
@@ -1806,47 +3360,48 @@ rb_gi_value_argument_free_array_c(GIArgument *argument,
|
|
1806
3360
|
|
1807
3361
|
element_type_tag = g_type_info_get_tag(element_type_info);
|
1808
3362
|
switch (element_type_tag) {
|
1809
|
-
|
1810
|
-
|
3363
|
+
case GI_TYPE_TAG_VOID:
|
3364
|
+
case GI_TYPE_TAG_BOOLEAN:
|
1811
3365
|
rb_raise(rb_eNotImpError,
|
1812
3366
|
"TODO: free GIArgument(array)[%s]",
|
1813
3367
|
g_type_tag_to_string(element_type_tag));
|
1814
3368
|
break;
|
1815
|
-
|
1816
|
-
|
3369
|
+
case GI_TYPE_TAG_INT8:
|
3370
|
+
case GI_TYPE_TAG_UINT8:
|
1817
3371
|
/* Do nothing */
|
1818
3372
|
break;
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
3373
|
+
case GI_TYPE_TAG_INT16:
|
3374
|
+
case GI_TYPE_TAG_UINT16:
|
3375
|
+
case GI_TYPE_TAG_INT32:
|
3376
|
+
case GI_TYPE_TAG_UINT32:
|
3377
|
+
case GI_TYPE_TAG_INT64:
|
3378
|
+
case GI_TYPE_TAG_UINT64:
|
3379
|
+
case GI_TYPE_TAG_FLOAT:
|
3380
|
+
case GI_TYPE_TAG_DOUBLE:
|
3381
|
+
case GI_TYPE_TAG_GTYPE:
|
3382
|
+
xfree(argument->v_pointer);
|
3383
|
+
break;
|
3384
|
+
case GI_TYPE_TAG_UTF8:
|
3385
|
+
case GI_TYPE_TAG_FILENAME:
|
3386
|
+
g_free(argument->v_pointer);
|
3387
|
+
break;
|
3388
|
+
case GI_TYPE_TAG_ARRAY:
|
1827
3389
|
rb_raise(rb_eNotImpError,
|
1828
3390
|
"TODO: free GIArgument(array)[%s]",
|
1829
3391
|
g_type_tag_to_string(element_type_tag));
|
1830
|
-
|
1831
|
-
case GI_TYPE_TAG_GTYPE:
|
3392
|
+
case GI_TYPE_TAG_INTERFACE:
|
1832
3393
|
xfree(argument->v_pointer);
|
1833
3394
|
break;
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
case GI_TYPE_TAG_INTERFACE:
|
1840
|
-
case GI_TYPE_TAG_GLIST:
|
1841
|
-
case GI_TYPE_TAG_GSLIST:
|
1842
|
-
case GI_TYPE_TAG_GHASH:
|
1843
|
-
case GI_TYPE_TAG_ERROR:
|
1844
|
-
case GI_TYPE_TAG_UNICHAR:
|
3395
|
+
case GI_TYPE_TAG_GLIST:
|
3396
|
+
case GI_TYPE_TAG_GSLIST:
|
3397
|
+
case GI_TYPE_TAG_GHASH:
|
3398
|
+
case GI_TYPE_TAG_ERROR:
|
3399
|
+
case GI_TYPE_TAG_UNICHAR:
|
1845
3400
|
rb_raise(rb_eNotImpError,
|
1846
3401
|
"TODO: free GIArgument(array)[%s]",
|
1847
3402
|
g_type_tag_to_string(element_type_tag));
|
1848
3403
|
break;
|
1849
|
-
|
3404
|
+
default:
|
1850
3405
|
g_assert_not_reached();
|
1851
3406
|
break;
|
1852
3407
|
}
|
@@ -1861,16 +3416,16 @@ rb_gi_value_argument_free_array(GIArgument *argument, GITypeInfo *type_info)
|
|
1861
3416
|
array_type = g_type_info_get_array_type(type_info);
|
1862
3417
|
element_type_info = g_type_info_get_param_type(type_info, 0);
|
1863
3418
|
switch (array_type) {
|
1864
|
-
|
3419
|
+
case GI_ARRAY_TYPE_C:
|
1865
3420
|
rb_gi_value_argument_free_array_c(argument,
|
1866
3421
|
type_info,
|
1867
3422
|
element_type_info);
|
1868
3423
|
break;
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
3424
|
+
case GI_ARRAY_TYPE_ARRAY:
|
3425
|
+
case GI_ARRAY_TYPE_PTR_ARRAY:
|
3426
|
+
case GI_ARRAY_TYPE_BYTE_ARRAY:
|
1872
3427
|
break;
|
1873
|
-
|
3428
|
+
default:
|
1874
3429
|
g_assert_not_reached();
|
1875
3430
|
break;
|
1876
3431
|
}
|
@@ -1878,7 +3433,9 @@ rb_gi_value_argument_free_array(GIArgument *argument, GITypeInfo *type_info)
|
|
1878
3433
|
}
|
1879
3434
|
|
1880
3435
|
static void
|
1881
|
-
rb_gi_value_argument_free_interface(
|
3436
|
+
rb_gi_value_argument_free_interface(VALUE rb_argument,
|
3437
|
+
GIArgument *argument,
|
3438
|
+
GITypeInfo *type_info)
|
1882
3439
|
{
|
1883
3440
|
GIBaseInfo *interface_info;
|
1884
3441
|
GIInfoType interface_type;
|
@@ -1891,9 +3448,13 @@ rb_gi_value_argument_free_interface(GIArgument *argument, GITypeInfo *type_info)
|
|
1891
3448
|
gtype = g_registered_type_info_get_g_type(interface_info);
|
1892
3449
|
|
1893
3450
|
if (gtype == G_TYPE_VALUE) {
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
3451
|
+
if (!RVAL2CBOOL(rb_obj_is_kind_of(rb_argument, rb_cGLibValue))) {
|
3452
|
+
GValue *gvalue = argument->v_pointer;
|
3453
|
+
g_value_unset(gvalue);
|
3454
|
+
xfree(argument->v_pointer);
|
3455
|
+
}
|
3456
|
+
} else if (gtype == G_TYPE_BYTES) {
|
3457
|
+
g_bytes_unref(argument->v_pointer);
|
1897
3458
|
}
|
1898
3459
|
}
|
1899
3460
|
|
@@ -1901,48 +3462,52 @@ rb_gi_value_argument_free_interface(GIArgument *argument, GITypeInfo *type_info)
|
|
1901
3462
|
}
|
1902
3463
|
|
1903
3464
|
void
|
1904
|
-
rb_gi_value_argument_free(
|
3465
|
+
rb_gi_value_argument_free(VALUE rb_argument,
|
3466
|
+
GIArgument *argument,
|
3467
|
+
GITypeInfo *type_info)
|
1905
3468
|
{
|
1906
3469
|
GITypeTag type_tag;
|
1907
3470
|
|
1908
3471
|
type_tag = g_type_info_get_tag(type_info);
|
1909
3472
|
switch (type_tag) {
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
break;
|
1926
|
-
|
3473
|
+
case GI_TYPE_TAG_VOID:
|
3474
|
+
case GI_TYPE_TAG_BOOLEAN:
|
3475
|
+
case GI_TYPE_TAG_INT8:
|
3476
|
+
case GI_TYPE_TAG_UINT8:
|
3477
|
+
case GI_TYPE_TAG_INT16:
|
3478
|
+
case GI_TYPE_TAG_UINT16:
|
3479
|
+
case GI_TYPE_TAG_INT32:
|
3480
|
+
case GI_TYPE_TAG_UINT32:
|
3481
|
+
case GI_TYPE_TAG_INT64:
|
3482
|
+
case GI_TYPE_TAG_UINT64:
|
3483
|
+
case GI_TYPE_TAG_FLOAT:
|
3484
|
+
case GI_TYPE_TAG_DOUBLE:
|
3485
|
+
case GI_TYPE_TAG_GTYPE:
|
3486
|
+
case GI_TYPE_TAG_UTF8:
|
3487
|
+
case GI_TYPE_TAG_FILENAME:
|
3488
|
+
break;
|
3489
|
+
case GI_TYPE_TAG_ARRAY:
|
1927
3490
|
rb_gi_value_argument_free_array(argument, type_info);
|
1928
3491
|
break;
|
1929
|
-
|
1930
|
-
rb_gi_value_argument_free_interface(argument, type_info);
|
3492
|
+
case GI_TYPE_TAG_INTERFACE:
|
3493
|
+
rb_gi_value_argument_free_interface(rb_argument, argument, type_info);
|
1931
3494
|
break;
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
3495
|
+
case GI_TYPE_TAG_GLIST:
|
3496
|
+
case GI_TYPE_TAG_GSLIST:
|
3497
|
+
case GI_TYPE_TAG_GHASH:
|
3498
|
+
case GI_TYPE_TAG_ERROR:
|
3499
|
+
case GI_TYPE_TAG_UNICHAR:
|
1937
3500
|
break;
|
1938
|
-
|
3501
|
+
default:
|
1939
3502
|
g_assert_not_reached();
|
1940
3503
|
break;
|
1941
3504
|
}
|
1942
3505
|
}
|
1943
3506
|
|
1944
3507
|
static void
|
1945
|
-
rb_gi_inout_argument_free(
|
3508
|
+
rb_gi_inout_argument_free(VALUE rb_argument,
|
3509
|
+
GIArgument *argument,
|
3510
|
+
GITypeInfo *type_info)
|
1946
3511
|
{
|
1947
3512
|
GIArgument in_argument;
|
1948
3513
|
GITypeTag type_tag;
|
@@ -1950,99 +3515,101 @@ rb_gi_inout_argument_free(GIArgument *argument, GITypeInfo *type_info)
|
|
1950
3515
|
memset(&in_argument, 0, sizeof(GIArgument));
|
1951
3516
|
type_tag = g_type_info_get_tag(type_info);
|
1952
3517
|
switch (type_tag) {
|
1953
|
-
|
3518
|
+
case GI_TYPE_TAG_VOID:
|
1954
3519
|
break;
|
1955
|
-
|
3520
|
+
case GI_TYPE_TAG_BOOLEAN:
|
1956
3521
|
in_argument.v_boolean = *((gboolean *)(argument->v_pointer));
|
1957
3522
|
break;
|
1958
|
-
|
3523
|
+
case GI_TYPE_TAG_INT8:
|
1959
3524
|
in_argument.v_int8 = *((gint8 *)(argument->v_pointer));
|
1960
3525
|
break;
|
1961
|
-
|
3526
|
+
case GI_TYPE_TAG_UINT8:
|
1962
3527
|
/* TODO!!! */
|
1963
3528
|
in_argument.v_uint8 = *((guint8 *)(argument->v_pointer));
|
1964
3529
|
argument->v_pointer = ALLOC(guint8);
|
1965
3530
|
*((guint8 *)argument->v_pointer) = in_argument.v_uint8;
|
1966
3531
|
break;
|
1967
|
-
|
3532
|
+
case GI_TYPE_TAG_INT16:
|
1968
3533
|
in_argument.v_int16 = *((gint16 *)(argument->v_pointer));
|
1969
3534
|
argument->v_pointer = ALLOC(gint16);
|
1970
3535
|
*((gint16 *)argument->v_pointer) = in_argument.v_int16;
|
1971
3536
|
break;
|
1972
|
-
|
3537
|
+
case GI_TYPE_TAG_UINT16:
|
1973
3538
|
in_argument.v_uint16 = *((guint16 *)(argument->v_pointer));
|
1974
3539
|
argument->v_pointer = ALLOC(guint16);
|
1975
3540
|
*((guint16 *)argument->v_pointer) = in_argument.v_uint16;
|
1976
3541
|
break;
|
1977
|
-
|
3542
|
+
case GI_TYPE_TAG_INT32:
|
1978
3543
|
in_argument.v_int32 = *((gint32 *)(argument->v_pointer));
|
1979
3544
|
argument->v_pointer = ALLOC(gint32);
|
1980
3545
|
*((gint32 *)argument->v_pointer) = in_argument.v_int32;
|
1981
3546
|
break;
|
1982
|
-
|
3547
|
+
case GI_TYPE_TAG_UINT32:
|
1983
3548
|
in_argument.v_uint32 = *((guint32 *)(argument->v_pointer));
|
1984
3549
|
argument->v_pointer = ALLOC(guint32);
|
1985
3550
|
*((guint32 *)argument->v_pointer) = in_argument.v_uint32;
|
1986
3551
|
break;
|
1987
|
-
|
3552
|
+
case GI_TYPE_TAG_INT64:
|
1988
3553
|
in_argument.v_int64 = *((gint64 *)(argument->v_pointer));
|
1989
3554
|
argument->v_pointer = ALLOC(gint64);
|
1990
3555
|
*((gint64 *)argument->v_pointer) = in_argument.v_int64;
|
1991
3556
|
break;
|
1992
|
-
|
3557
|
+
case GI_TYPE_TAG_UINT64:
|
1993
3558
|
in_argument.v_uint64 = *((guint64 *)(argument->v_pointer));
|
1994
3559
|
argument->v_pointer = ALLOC(guint64);
|
1995
3560
|
*((guint64 *)argument->v_pointer) = in_argument.v_uint64;
|
1996
3561
|
break;
|
1997
|
-
|
3562
|
+
case GI_TYPE_TAG_FLOAT:
|
1998
3563
|
in_argument.v_float = *((gfloat *)(argument->v_pointer));
|
1999
3564
|
argument->v_pointer = ALLOC(gfloat);
|
2000
3565
|
*((gfloat *)argument->v_pointer) = in_argument.v_float;
|
2001
3566
|
break;
|
2002
|
-
|
3567
|
+
case GI_TYPE_TAG_DOUBLE:
|
2003
3568
|
in_argument.v_double = *((gdouble *)(argument->v_pointer));
|
2004
3569
|
argument->v_pointer = ALLOC(gdouble);
|
2005
3570
|
*((gdouble *)argument->v_pointer) = in_argument.v_double;
|
2006
3571
|
break;
|
2007
|
-
|
3572
|
+
case GI_TYPE_TAG_GTYPE:
|
2008
3573
|
in_argument.v_size = *((gsize *)(argument->v_pointer));
|
2009
3574
|
break;
|
2010
|
-
|
2011
|
-
|
3575
|
+
case GI_TYPE_TAG_UTF8:
|
3576
|
+
case GI_TYPE_TAG_FILENAME:
|
2012
3577
|
in_argument.v_string = *((gchar **)(argument->v_pointer));
|
2013
3578
|
break;
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
3579
|
+
case GI_TYPE_TAG_ARRAY:
|
3580
|
+
case GI_TYPE_TAG_INTERFACE:
|
3581
|
+
case GI_TYPE_TAG_GLIST:
|
3582
|
+
case GI_TYPE_TAG_GSLIST:
|
3583
|
+
case GI_TYPE_TAG_GHASH:
|
2019
3584
|
in_argument.v_pointer = *((gpointer *)(argument->v_pointer));
|
2020
3585
|
break;
|
2021
|
-
|
3586
|
+
case GI_TYPE_TAG_ERROR:
|
2022
3587
|
in_argument.v_pointer = *((GError **)(argument->v_pointer));
|
2023
3588
|
break;
|
2024
|
-
|
3589
|
+
case GI_TYPE_TAG_UNICHAR:
|
2025
3590
|
in_argument.v_uint32 = *((gunichar *)(argument->v_pointer));
|
2026
3591
|
break;
|
2027
|
-
|
3592
|
+
default:
|
2028
3593
|
g_assert_not_reached();
|
2029
3594
|
break;
|
2030
3595
|
}
|
2031
3596
|
|
2032
|
-
rb_gi_value_argument_free(&in_argument, type_info);
|
3597
|
+
rb_gi_value_argument_free(rb_argument, &in_argument, type_info);
|
2033
3598
|
xfree(argument->v_pointer);
|
2034
3599
|
}
|
2035
3600
|
|
2036
3601
|
void
|
2037
|
-
rb_gi_in_argument_free(
|
3602
|
+
rb_gi_in_argument_free(VALUE rb_argument,
|
3603
|
+
GIArgument *argument,
|
3604
|
+
GIArgInfo *arg_info)
|
2038
3605
|
{
|
2039
3606
|
GITypeInfo type_info;
|
2040
3607
|
|
2041
3608
|
g_arg_info_load_type(arg_info, &type_info);
|
2042
3609
|
if (g_arg_info_get_direction(arg_info) == GI_DIRECTION_INOUT) {
|
2043
|
-
rb_gi_inout_argument_free(argument, &type_info);
|
3610
|
+
rb_gi_inout_argument_free(rb_argument, argument, &type_info);
|
2044
3611
|
} else {
|
2045
|
-
rb_gi_value_argument_free(argument, &type_info);
|
3612
|
+
rb_gi_value_argument_free(rb_argument, argument, &type_info);
|
2046
3613
|
}
|
2047
3614
|
}
|
2048
3615
|
|