gobject-introspection 1.1.9 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -11
- data/ext/gobject-introspection/extconf.rb +3 -3
- data/ext/gobject-introspection/rb-gi-argument.c +836 -62
- data/ext/gobject-introspection/rb-gi-callable-info.c +2 -22
- data/ext/gobject-introspection/rb-gi-constructor-info.c +52 -14
- data/ext/gobject-introspection/rb-gi-conversions.h +29 -8
- data/ext/gobject-introspection/rb-gi-field-info.c +7 -3
- data/ext/gobject-introspection/rb-gi-function-info.c +475 -57
- data/ext/gobject-introspection/rb-gi-loader.c +94 -1
- data/ext/gobject-introspection/rb-gi-method-info.c +45 -6
- data/ext/gobject-introspection/rb-gi-struct-info.c +12 -5
- data/ext/gobject-introspection/rb-gi-union-info.c +1 -1
- data/ext/gobject-introspection/rb-gobject-introspection.c +3 -1
- data/ext/gobject-introspection/rb-gobject-introspection.h +4 -1
- data/lib/gobject-introspection.rb +4 -1
- data/lib/gobject-introspection/callable-info.rb +55 -0
- data/lib/gobject-introspection/interface-info.rb +32 -0
- data/lib/gobject-introspection/loader.rb +143 -34
- data/{sample/clutter.rb → lib/gobject-introspection/union-info.rb} +9 -10
- data/test/test-arg-info.rb +1 -1
- data/test/test-callable-info.rb +2 -2
- metadata +12 -11
- data/sample/clutter-basic-actor.rb +0 -132
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2012 Ruby-GNOME2 Project Team
|
3
|
+
# Copyright (C) 2012-2013 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
|
@@ -27,21 +27,12 @@ package = GNOME2Package.new do |_package|
|
|
27
27
|
_package.win32.packages = []
|
28
28
|
_package.win32.dependencies = []
|
29
29
|
_package.win32.build_dependencies = ["glib2"]
|
30
|
-
libffi_lib_dir = File.join(_package.win32.package.root_dir, "..",
|
31
|
-
"glib2", "vendor", "local", "lib")
|
32
|
-
libffi_include_dir = File.join(libffi_lib_dir, "libffi-3.0.6", "include")
|
33
30
|
_package.win32.build_packages = [
|
34
31
|
{
|
35
32
|
:name => "gobject-introspection",
|
36
33
|
:download_site => :gnome,
|
37
34
|
:label => "gobject-introspection",
|
38
|
-
:version => "1.35.
|
39
|
-
:include_paths => [
|
40
|
-
libffi_include_dir,
|
41
|
-
],
|
42
|
-
:library_paths => [
|
43
|
-
libffi_lib_dir,
|
44
|
-
],
|
35
|
+
:version => "1.35.4",
|
45
36
|
:configure_args => [],
|
46
37
|
:compression_method => "xz",
|
47
38
|
},
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Copyright (C) 2012 Ruby-GNOME2 Project Team
|
3
|
+
# Copyright (C) 2012-2013 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
|
@@ -23,12 +23,12 @@ base_dir = source_dir.parent.parent.expand_path
|
|
23
23
|
top_dir = base_dir.parent.expand_path
|
24
24
|
top_build_dir = Pathname(".").parent.parent.parent.expand_path
|
25
25
|
|
26
|
-
mkmf_gnome2_dir = top_dir + "glib2" +
|
26
|
+
mkmf_gnome2_dir = top_dir + "glib2" + "lib"
|
27
27
|
version_suffix = ""
|
28
28
|
unless mkmf_gnome2_dir.exist?
|
29
29
|
if /(-\d+\.\d+\.\d+)(?:\.\d+)?\z/ =~ base_dir.basename.to_s
|
30
30
|
version_suffix = $1
|
31
|
-
mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" +
|
31
|
+
mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + "lib"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2012 Ruby-GNOME2 Project Team
|
3
|
+
* Copyright (C) 2012-2013 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
|
@@ -20,12 +20,178 @@
|
|
20
20
|
|
21
21
|
#include "rb-gobject-introspection.h"
|
22
22
|
|
23
|
+
static VALUE rb_cGLibValue = Qnil;
|
24
|
+
|
25
|
+
static void
|
26
|
+
array_c_to_ruby(const gchar **elements, GITypeInfo *type_info, VALUE rb_array)
|
27
|
+
{
|
28
|
+
gint n_elements;
|
29
|
+
gboolean fixed_size_p;
|
30
|
+
gboolean zero_terminated_p;
|
31
|
+
|
32
|
+
n_elements = g_type_info_get_array_length(type_info);
|
33
|
+
fixed_size_p = g_type_info_get_array_fixed_size(type_info);
|
34
|
+
zero_terminated_p = g_type_info_is_zero_terminated(type_info);
|
35
|
+
if (n_elements != -1) {
|
36
|
+
gint i;
|
37
|
+
for (i = 0; i < n_elements; i++) {
|
38
|
+
rb_ary_push(rb_array, CSTR2RVAL(elements[i]));
|
39
|
+
}
|
40
|
+
} else if (zero_terminated_p) {
|
41
|
+
for (; *elements; elements++) {
|
42
|
+
rb_ary_push(rb_array, CSTR2RVAL(*elements));
|
43
|
+
}
|
44
|
+
} else {
|
45
|
+
rb_raise(rb_eNotImpError,
|
46
|
+
"TODO: GIArgument(array)[c] -> Ruby: "
|
47
|
+
"zero-terminated: %s "
|
48
|
+
"fixed-size: %s "
|
49
|
+
"length: %d",
|
50
|
+
zero_terminated_p ? "true" : "false",
|
51
|
+
fixed_size_p ? "true" : "false",
|
52
|
+
n_elements);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
static VALUE
|
57
|
+
array_to_ruby(gpointer array, GITypeInfo *type_info)
|
58
|
+
{
|
59
|
+
VALUE rb_array;
|
60
|
+
GIArrayType array_type;
|
61
|
+
gint n_elements;
|
62
|
+
|
63
|
+
array_type = g_type_info_get_array_type(type_info);
|
64
|
+
n_elements = g_type_info_get_array_length(type_info);
|
65
|
+
if (n_elements == -1) {
|
66
|
+
rb_array = rb_ary_new();
|
67
|
+
} else {
|
68
|
+
rb_array = rb_ary_new2(n_elements);
|
69
|
+
}
|
70
|
+
switch (array_type) {
|
71
|
+
case GI_ARRAY_TYPE_C:
|
72
|
+
array_c_to_ruby(array, type_info, rb_array);
|
73
|
+
break;
|
74
|
+
case GI_ARRAY_TYPE_ARRAY:
|
75
|
+
rb_raise(rb_eNotImpError, "TODO: GIArgument(array)[array] -> Ruby");
|
76
|
+
break;
|
77
|
+
case GI_ARRAY_TYPE_PTR_ARRAY:
|
78
|
+
rb_raise(rb_eNotImpError, "TODO: GIArgument(array)[ptr-array] -> Ruby");
|
79
|
+
break;
|
80
|
+
case GI_ARRAY_TYPE_BYTE_ARRAY:
|
81
|
+
rb_raise(rb_eNotImpError, "TODO: GIArgument(array)[byte-array] -> Ruby");
|
82
|
+
break;
|
83
|
+
default:
|
84
|
+
g_assert_not_reached();
|
85
|
+
break;
|
86
|
+
}
|
87
|
+
|
88
|
+
return rb_array;
|
89
|
+
}
|
90
|
+
|
91
|
+
static VALUE
|
92
|
+
interface_to_ruby(GIArgument *argument, GITypeInfo *type_info)
|
93
|
+
{
|
94
|
+
VALUE rb_interface;
|
95
|
+
GIBaseInfo *interface_info;
|
96
|
+
GIInfoType interface_type;
|
97
|
+
GType gtype;
|
98
|
+
|
99
|
+
interface_info = g_type_info_get_interface(type_info);
|
100
|
+
interface_type = g_base_info_get_type(interface_info);
|
101
|
+
|
102
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
103
|
+
switch (interface_type) {
|
104
|
+
case GI_INFO_TYPE_INVALID:
|
105
|
+
rb_raise(rb_eNotImpError,
|
106
|
+
"TODO: GIArgument(interface)[invalid] -> Ruby");
|
107
|
+
break;
|
108
|
+
case GI_INFO_TYPE_FUNCTION:
|
109
|
+
rb_raise(rb_eNotImpError,
|
110
|
+
"TODO: GIArgument(interface)[function] -> Ruby");
|
111
|
+
break;
|
112
|
+
case GI_INFO_TYPE_CALLBACK:
|
113
|
+
rb_raise(rb_eNotImpError,
|
114
|
+
"TODO: GIArgument(interface)[callback] -> Ruby");
|
115
|
+
break;
|
116
|
+
case GI_INFO_TYPE_STRUCT:
|
117
|
+
rb_interface = BOXED2RVAL(argument->v_pointer, gtype);
|
118
|
+
break;
|
119
|
+
case GI_INFO_TYPE_BOXED:
|
120
|
+
rb_raise(rb_eNotImpError,
|
121
|
+
"TODO: GIArgument(interface)[boxed] -> Ruby");
|
122
|
+
break;
|
123
|
+
case GI_INFO_TYPE_ENUM:
|
124
|
+
rb_interface = GENUM2RVAL(argument->v_int32, gtype);
|
125
|
+
break;
|
126
|
+
case GI_INFO_TYPE_FLAGS:
|
127
|
+
rb_interface = GFLAGS2RVAL(argument->v_int32, gtype);
|
128
|
+
break;
|
129
|
+
case GI_INFO_TYPE_OBJECT:
|
130
|
+
rb_interface = GOBJ2RVAL(argument->v_pointer);
|
131
|
+
break;
|
132
|
+
case GI_INFO_TYPE_INTERFACE:
|
133
|
+
rb_interface = GOBJ2RVAL(argument->v_pointer);
|
134
|
+
break;
|
135
|
+
case GI_INFO_TYPE_CONSTANT:
|
136
|
+
rb_raise(rb_eNotImpError,
|
137
|
+
"TODO: GIArgument(interface)[constant] -> Ruby");
|
138
|
+
break;
|
139
|
+
case GI_INFO_TYPE_INVALID_0:
|
140
|
+
g_assert_not_reached();
|
141
|
+
break;
|
142
|
+
case GI_INFO_TYPE_UNION:
|
143
|
+
rb_interface = BOXED2RVAL(argument->v_pointer, gtype);
|
144
|
+
break;
|
145
|
+
case GI_INFO_TYPE_VALUE:
|
146
|
+
rb_raise(rb_eNotImpError,
|
147
|
+
"TODO: GIArgument(interface)[value] -> Ruby");
|
148
|
+
break;
|
149
|
+
case GI_INFO_TYPE_SIGNAL:
|
150
|
+
rb_raise(rb_eNotImpError,
|
151
|
+
"TODO: GIArgument(interface)[signal] -> Ruby");
|
152
|
+
break;
|
153
|
+
case GI_INFO_TYPE_VFUNC:
|
154
|
+
rb_raise(rb_eNotImpError,
|
155
|
+
"TODO: GIArgument(interface)[vfunc] -> Ruby");
|
156
|
+
break;
|
157
|
+
case GI_INFO_TYPE_PROPERTY:
|
158
|
+
rb_raise(rb_eNotImpError,
|
159
|
+
"TODO: GIArgument(interface)[property] -> Ruby");
|
160
|
+
break;
|
161
|
+
case GI_INFO_TYPE_FIELD:
|
162
|
+
rb_raise(rb_eNotImpError,
|
163
|
+
"TODO: GIArgument(interface)[field] -> Ruby");
|
164
|
+
break;
|
165
|
+
case GI_INFO_TYPE_ARG:
|
166
|
+
rb_raise(rb_eNotImpError,
|
167
|
+
"TODO: GIArgument(interface)[arg] -> Ruby");
|
168
|
+
break;
|
169
|
+
case GI_INFO_TYPE_TYPE:
|
170
|
+
rb_raise(rb_eNotImpError,
|
171
|
+
"TODO: GIArgument(interface)[type] -> Ruby");
|
172
|
+
break;
|
173
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
174
|
+
rb_raise(rb_eNotImpError,
|
175
|
+
"TODO: GIArgument(interface)[unresolved] -> Ruby");
|
176
|
+
break;
|
177
|
+
default:
|
178
|
+
g_assert_not_reached();
|
179
|
+
break;
|
180
|
+
}
|
181
|
+
|
182
|
+
g_base_info_unref(interface_info);
|
183
|
+
|
184
|
+
return rb_interface;
|
185
|
+
}
|
186
|
+
|
23
187
|
VALUE
|
24
188
|
rb_gi_argument_to_ruby(GIArgument *argument, GITypeInfo *type_info)
|
25
189
|
{
|
26
190
|
VALUE rb_argument = Qnil;
|
191
|
+
GITypeTag type_tag;
|
27
192
|
|
28
|
-
|
193
|
+
type_tag = g_type_info_get_tag(type_info);
|
194
|
+
switch (type_tag) {
|
29
195
|
case GI_TYPE_TAG_VOID:
|
30
196
|
rb_argument = Qnil;
|
31
197
|
break;
|
@@ -73,46 +239,23 @@ rb_gi_argument_to_ruby(GIArgument *argument, GITypeInfo *type_info)
|
|
73
239
|
rb_argument = CSTR2RVAL(argument->v_string);
|
74
240
|
break;
|
75
241
|
case GI_TYPE_TAG_ARRAY:
|
76
|
-
|
242
|
+
rb_argument = array_to_ruby(argument->v_pointer, type_info);
|
77
243
|
break;
|
78
244
|
case GI_TYPE_TAG_INTERFACE:
|
79
|
-
|
80
|
-
GIBaseInfo *interface_info;
|
81
|
-
GIInfoType interface_type;
|
82
|
-
GType gtype;
|
83
|
-
|
84
|
-
interface_info = g_type_info_get_interface(type_info);
|
85
|
-
interface_type = g_base_info_get_type(interface_info);
|
86
|
-
|
87
|
-
gtype = g_registered_type_info_get_g_type(interface_info);
|
88
|
-
switch (interface_type) {
|
89
|
-
case GI_INFO_TYPE_ENUM:
|
90
|
-
rb_argument = GENUM2RVAL(argument->v_int32, gtype);
|
91
|
-
break;
|
92
|
-
case GI_INFO_TYPE_FLAGS:
|
93
|
-
rb_argument = GFLAGS2RVAL(argument->v_int32, gtype);
|
94
|
-
break;
|
95
|
-
case GI_INFO_TYPE_OBJECT:
|
96
|
-
rb_argument = GOBJ2RVAL(argument->v_pointer);
|
97
|
-
break;
|
98
|
-
case GI_INFO_TYPE_STRUCT:
|
99
|
-
rb_argument = BOXED2RVAL(argument->v_pointer, gtype);
|
100
|
-
break;
|
101
|
-
}
|
102
|
-
|
103
|
-
g_base_info_unref(interface_info);
|
104
|
-
}
|
245
|
+
rb_argument = interface_to_ruby(argument, type_info);
|
105
246
|
break;
|
106
247
|
case GI_TYPE_TAG_GLIST:
|
107
248
|
case GI_TYPE_TAG_GSLIST:
|
108
249
|
case GI_TYPE_TAG_GHASH:
|
109
|
-
|
250
|
+
rb_raise(rb_eNotImpError, "TODO: GIArgument(unichar) -> Ruby");
|
110
251
|
break;
|
111
252
|
case GI_TYPE_TAG_ERROR:
|
112
253
|
RG_RAISE_ERROR(argument->v_pointer);
|
113
254
|
break;
|
114
255
|
case GI_TYPE_TAG_UNICHAR:
|
115
|
-
|
256
|
+
rb_raise(rb_eNotImpError,
|
257
|
+
"TODO: GIArgument(%s) -> Ruby",
|
258
|
+
g_type_tag_to_string(type_tag));
|
116
259
|
break;
|
117
260
|
default:
|
118
261
|
g_assert_not_reached();
|
@@ -122,13 +265,364 @@ rb_gi_argument_to_ruby(GIArgument *argument, GITypeInfo *type_info)
|
|
122
265
|
return rb_argument;
|
123
266
|
}
|
124
267
|
|
268
|
+
void
|
269
|
+
rb_gi_out_argument_init(GIArgument *argument, GIArgInfo *arg_info)
|
270
|
+
{
|
271
|
+
GITypeInfo type_info;
|
272
|
+
GITypeTag type_tag;
|
273
|
+
|
274
|
+
memset(argument, 0, sizeof(GIArgument));
|
275
|
+
|
276
|
+
g_arg_info_load_type(arg_info, &type_info);
|
277
|
+
type_tag = g_type_info_get_tag(&type_info);
|
278
|
+
switch (type_tag) {
|
279
|
+
case GI_TYPE_TAG_VOID:
|
280
|
+
break;
|
281
|
+
case GI_TYPE_TAG_BOOLEAN:
|
282
|
+
argument->v_pointer = ALLOC(gboolean);
|
283
|
+
break;
|
284
|
+
case GI_TYPE_TAG_INT8:
|
285
|
+
argument->v_pointer = ALLOC(gint8);
|
286
|
+
break;
|
287
|
+
case GI_TYPE_TAG_UINT8:
|
288
|
+
argument->v_pointer = ALLOC(guint8);
|
289
|
+
break;
|
290
|
+
case GI_TYPE_TAG_INT16:
|
291
|
+
argument->v_pointer = ALLOC(gint16);
|
292
|
+
break;
|
293
|
+
case GI_TYPE_TAG_UINT16:
|
294
|
+
argument->v_pointer = ALLOC(guint16);
|
295
|
+
break;
|
296
|
+
case GI_TYPE_TAG_INT32:
|
297
|
+
argument->v_pointer = ALLOC(gint32);
|
298
|
+
break;
|
299
|
+
case GI_TYPE_TAG_UINT32:
|
300
|
+
argument->v_pointer = ALLOC(guint32);
|
301
|
+
break;
|
302
|
+
case GI_TYPE_TAG_INT64:
|
303
|
+
argument->v_pointer = ALLOC(gint64);
|
304
|
+
break;
|
305
|
+
case GI_TYPE_TAG_UINT64:
|
306
|
+
argument->v_pointer = ALLOC(guint64);
|
307
|
+
break;
|
308
|
+
case GI_TYPE_TAG_FLOAT:
|
309
|
+
argument->v_pointer = ALLOC(gfloat);
|
310
|
+
break;
|
311
|
+
case GI_TYPE_TAG_DOUBLE:
|
312
|
+
argument->v_pointer = ALLOC(gdouble);
|
313
|
+
break;
|
314
|
+
case GI_TYPE_TAG_GTYPE:
|
315
|
+
argument->v_pointer = ALLOC(GType);
|
316
|
+
break;
|
317
|
+
case GI_TYPE_TAG_UTF8:
|
318
|
+
case GI_TYPE_TAG_FILENAME:
|
319
|
+
argument->v_pointer = ALLOC(gchar *);
|
320
|
+
break;
|
321
|
+
case GI_TYPE_TAG_ARRAY:
|
322
|
+
argument->v_pointer = ALLOC(gpointer);
|
323
|
+
break;
|
324
|
+
case GI_TYPE_TAG_INTERFACE:
|
325
|
+
argument->v_pointer = ALLOC(gpointer);
|
326
|
+
break;
|
327
|
+
case GI_TYPE_TAG_GLIST:
|
328
|
+
case GI_TYPE_TAG_GSLIST:
|
329
|
+
case GI_TYPE_TAG_GHASH:
|
330
|
+
argument->v_pointer = ALLOC(gpointer);
|
331
|
+
break;
|
332
|
+
case GI_TYPE_TAG_ERROR:
|
333
|
+
argument->v_pointer = ALLOC(GError *);
|
334
|
+
memset(argument->v_pointer, 0, sizeof(GError *));
|
335
|
+
break;
|
336
|
+
case GI_TYPE_TAG_UNICHAR:
|
337
|
+
argument->v_pointer = ALLOC(gunichar);
|
338
|
+
break;
|
339
|
+
default:
|
340
|
+
g_assert_not_reached();
|
341
|
+
break;
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
345
|
+
VALUE
|
346
|
+
rb_gi_out_argument_to_ruby(GIArgument *argument, GIArgInfo *arg_info)
|
347
|
+
{
|
348
|
+
GIArgument normalized_argument;
|
349
|
+
GITypeInfo type_info;
|
350
|
+
GITypeTag type_tag;
|
351
|
+
|
352
|
+
memset(&normalized_argument, 0, sizeof(GIArgument));
|
353
|
+
g_arg_info_load_type(arg_info, &type_info);
|
354
|
+
type_tag = g_type_info_get_tag(&type_info);
|
355
|
+
switch (type_tag) {
|
356
|
+
case GI_TYPE_TAG_VOID:
|
357
|
+
break;
|
358
|
+
case GI_TYPE_TAG_BOOLEAN:
|
359
|
+
normalized_argument.v_boolean = *((gboolean *)(argument->v_pointer));
|
360
|
+
break;
|
361
|
+
case GI_TYPE_TAG_INT8:
|
362
|
+
normalized_argument.v_int8 = *((gint8 *)(argument->v_pointer));
|
363
|
+
break;
|
364
|
+
case GI_TYPE_TAG_UINT8:
|
365
|
+
normalized_argument.v_uint8 = *((guint8 *)(argument->v_pointer));
|
366
|
+
break;
|
367
|
+
case GI_TYPE_TAG_INT16:
|
368
|
+
normalized_argument.v_int16 = *((gint16 *)(argument->v_pointer));
|
369
|
+
break;
|
370
|
+
case GI_TYPE_TAG_UINT16:
|
371
|
+
normalized_argument.v_uint16 = *((guint16 *)(argument->v_pointer));
|
372
|
+
break;
|
373
|
+
case GI_TYPE_TAG_INT32:
|
374
|
+
normalized_argument.v_int32 = *((gint32 *)(argument->v_pointer));
|
375
|
+
break;
|
376
|
+
case GI_TYPE_TAG_UINT32:
|
377
|
+
normalized_argument.v_uint32 = *((guint32 *)(argument->v_pointer));
|
378
|
+
break;
|
379
|
+
case GI_TYPE_TAG_INT64:
|
380
|
+
normalized_argument.v_int64 = *((gint64 *)(argument->v_pointer));
|
381
|
+
break;
|
382
|
+
case GI_TYPE_TAG_UINT64:
|
383
|
+
normalized_argument.v_uint64 = *((guint64 *)(argument->v_pointer));
|
384
|
+
break;
|
385
|
+
case GI_TYPE_TAG_FLOAT:
|
386
|
+
normalized_argument.v_float = *((gfloat *)(argument->v_pointer));
|
387
|
+
break;
|
388
|
+
case GI_TYPE_TAG_DOUBLE:
|
389
|
+
normalized_argument.v_double = *((gdouble *)(argument->v_pointer));
|
390
|
+
break;
|
391
|
+
case GI_TYPE_TAG_GTYPE:
|
392
|
+
normalized_argument.v_size = *((GType *)(argument->v_pointer));
|
393
|
+
break;
|
394
|
+
case GI_TYPE_TAG_UTF8:
|
395
|
+
case GI_TYPE_TAG_FILENAME:
|
396
|
+
normalized_argument.v_string = *((gchar **)(argument->v_pointer));
|
397
|
+
break;
|
398
|
+
case GI_TYPE_TAG_ARRAY:
|
399
|
+
case GI_TYPE_TAG_INTERFACE:
|
400
|
+
case GI_TYPE_TAG_GLIST:
|
401
|
+
case GI_TYPE_TAG_GSLIST:
|
402
|
+
case GI_TYPE_TAG_GHASH:
|
403
|
+
normalized_argument.v_pointer = *((gpointer *)(argument->v_pointer));
|
404
|
+
break;
|
405
|
+
case GI_TYPE_TAG_ERROR:
|
406
|
+
normalized_argument.v_pointer = *((GError **)(argument->v_pointer));
|
407
|
+
break;
|
408
|
+
case GI_TYPE_TAG_UNICHAR:
|
409
|
+
normalized_argument.v_uint32 = *((guint32 *)(argument->v_pointer));
|
410
|
+
break;
|
411
|
+
default:
|
412
|
+
g_assert_not_reached();
|
413
|
+
break;
|
414
|
+
}
|
415
|
+
|
416
|
+
return rb_gi_argument_to_ruby(&normalized_argument, &type_info);
|
417
|
+
}
|
418
|
+
|
419
|
+
void
|
420
|
+
rb_gi_out_argument_fin(GIArgument *argument, GIArgInfo *arg_info)
|
421
|
+
{
|
422
|
+
GITypeInfo type_info;
|
423
|
+
|
424
|
+
if (g_arg_info_get_direction(arg_info) != GI_DIRECTION_OUT) {
|
425
|
+
return;
|
426
|
+
}
|
427
|
+
|
428
|
+
g_arg_info_load_type(arg_info, &type_info);
|
429
|
+
xfree(argument->v_pointer);
|
430
|
+
}
|
431
|
+
|
432
|
+
VALUE
|
433
|
+
rb_gi_return_argument_to_ruby(GIArgument *argument,
|
434
|
+
GICallableInfo *callable_info)
|
435
|
+
{
|
436
|
+
gboolean may_return_null;
|
437
|
+
GITypeInfo return_value_info;
|
438
|
+
|
439
|
+
may_return_null = g_callable_info_may_return_null(callable_info);
|
440
|
+
if (may_return_null && !argument->v_pointer) {
|
441
|
+
return Qnil;
|
442
|
+
}
|
443
|
+
|
444
|
+
g_callable_info_load_return_type(callable_info, &return_value_info);
|
445
|
+
return rb_gi_argument_to_ruby(argument, &return_value_info);
|
446
|
+
}
|
447
|
+
|
448
|
+
static void
|
449
|
+
rb_gi_argument_from_ruby_array_c(GIArgument *argument,
|
450
|
+
G_GNUC_UNUSED GITypeInfo *type_info,
|
451
|
+
GITypeInfo *element_type_info,
|
452
|
+
VALUE rb_argument)
|
453
|
+
{
|
454
|
+
GITypeTag element_type_tag;
|
455
|
+
|
456
|
+
element_type_tag = g_type_info_get_tag(element_type_info);
|
457
|
+
switch (element_type_tag) {
|
458
|
+
case GI_TYPE_TAG_VOID:
|
459
|
+
case GI_TYPE_TAG_BOOLEAN:
|
460
|
+
rb_raise(rb_eNotImpError,
|
461
|
+
"TODO: Ruby -> GIArgument(array)[%s]",
|
462
|
+
g_type_tag_to_string(element_type_tag));
|
463
|
+
break;
|
464
|
+
case GI_TYPE_TAG_INT8:
|
465
|
+
argument->v_pointer = StringValueCStr(rb_argument);
|
466
|
+
break;
|
467
|
+
case GI_TYPE_TAG_UINT8:
|
468
|
+
argument->v_pointer = RSTRING_PTR(rb_argument);
|
469
|
+
break;
|
470
|
+
case GI_TYPE_TAG_INT16:
|
471
|
+
case GI_TYPE_TAG_UINT16:
|
472
|
+
case GI_TYPE_TAG_INT32:
|
473
|
+
case GI_TYPE_TAG_UINT32:
|
474
|
+
case GI_TYPE_TAG_INT64:
|
475
|
+
case GI_TYPE_TAG_UINT64:
|
476
|
+
case GI_TYPE_TAG_FLOAT:
|
477
|
+
case GI_TYPE_TAG_DOUBLE:
|
478
|
+
case GI_TYPE_TAG_GTYPE:
|
479
|
+
rb_raise(rb_eNotImpError,
|
480
|
+
"TODO: Ruby -> GIArgument(array)[%s]",
|
481
|
+
g_type_tag_to_string(element_type_tag));
|
482
|
+
break;
|
483
|
+
case GI_TYPE_TAG_UTF8:
|
484
|
+
case GI_TYPE_TAG_FILENAME:
|
485
|
+
argument->v_pointer = RVAL2STRV(rb_argument);
|
486
|
+
break;
|
487
|
+
case GI_TYPE_TAG_ARRAY:
|
488
|
+
case GI_TYPE_TAG_INTERFACE:
|
489
|
+
case GI_TYPE_TAG_GLIST:
|
490
|
+
case GI_TYPE_TAG_GSLIST:
|
491
|
+
case GI_TYPE_TAG_GHASH:
|
492
|
+
case GI_TYPE_TAG_ERROR:
|
493
|
+
case GI_TYPE_TAG_UNICHAR:
|
494
|
+
rb_raise(rb_eNotImpError,
|
495
|
+
"TODO: Ruby -> GIArgument(array)[%s]",
|
496
|
+
g_type_tag_to_string(element_type_tag));
|
497
|
+
break;
|
498
|
+
default:
|
499
|
+
g_assert_not_reached();
|
500
|
+
break;
|
501
|
+
}
|
502
|
+
}
|
503
|
+
|
504
|
+
static void
|
505
|
+
rb_gi_argument_from_ruby_array(GIArgument *argument, GITypeInfo *type_info,
|
506
|
+
VALUE rb_argument)
|
507
|
+
{
|
508
|
+
GIArrayType array_type;
|
509
|
+
GITypeInfo *element_type_info;
|
510
|
+
|
511
|
+
array_type = g_type_info_get_array_type(type_info);
|
512
|
+
element_type_info = g_type_info_get_param_type(type_info, 0);
|
513
|
+
switch (array_type) {
|
514
|
+
case GI_ARRAY_TYPE_C:
|
515
|
+
rb_gi_argument_from_ruby_array_c(argument,
|
516
|
+
type_info, element_type_info,
|
517
|
+
rb_argument);
|
518
|
+
break;
|
519
|
+
case GI_ARRAY_TYPE_ARRAY:
|
520
|
+
case GI_ARRAY_TYPE_PTR_ARRAY:
|
521
|
+
case GI_ARRAY_TYPE_BYTE_ARRAY:
|
522
|
+
/* TODO */
|
523
|
+
break;
|
524
|
+
default:
|
525
|
+
g_assert_not_reached();
|
526
|
+
break;
|
527
|
+
}
|
528
|
+
g_base_info_unref(element_type_info);
|
529
|
+
}
|
530
|
+
|
531
|
+
static void
|
532
|
+
rb_gi_argument_from_ruby_interface(GIArgument *argument, GITypeInfo *type_info,
|
533
|
+
VALUE rb_argument)
|
534
|
+
{
|
535
|
+
GIBaseInfo *interface_info;
|
536
|
+
GIInfoType interface_type;
|
537
|
+
GType gtype;
|
538
|
+
|
539
|
+
interface_info = g_type_info_get_interface(type_info);
|
540
|
+
interface_type = g_base_info_get_type(interface_info);
|
541
|
+
|
542
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
543
|
+
switch (interface_type) {
|
544
|
+
case GI_INFO_TYPE_INVALID:
|
545
|
+
case GI_INFO_TYPE_FUNCTION:
|
546
|
+
case GI_INFO_TYPE_CALLBACK:
|
547
|
+
rb_raise(rb_eNotImpError,
|
548
|
+
"TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
|
549
|
+
g_info_type_to_string(interface_type),
|
550
|
+
g_base_info_get_name(interface_info));
|
551
|
+
break;
|
552
|
+
case GI_INFO_TYPE_STRUCT:
|
553
|
+
if (gtype == G_TYPE_VALUE) {
|
554
|
+
GValue *gvalue;
|
555
|
+
gvalue = ALLOC(GValue);
|
556
|
+
memset(gvalue, 0, sizeof(GValue));
|
557
|
+
if (rb_obj_is_kind_of(rb_argument, rb_cGLibValue)) {
|
558
|
+
GValue *source_gvalue;
|
559
|
+
source_gvalue = RVAL2BOXED(rb_argument, G_TYPE_VALUE);
|
560
|
+
g_value_init(gvalue, source_gvalue->g_type);
|
561
|
+
g_value_copy(source_gvalue, gvalue);
|
562
|
+
} else {
|
563
|
+
rbgobj_initialize_gvalue(gvalue, rb_argument);
|
564
|
+
}
|
565
|
+
argument->v_pointer = gvalue;
|
566
|
+
} else {
|
567
|
+
argument->v_pointer = RVAL2BOXED(rb_argument, gtype);
|
568
|
+
}
|
569
|
+
break;
|
570
|
+
case GI_INFO_TYPE_BOXED:
|
571
|
+
rb_raise(rb_eNotImpError,
|
572
|
+
"TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
|
573
|
+
g_info_type_to_string(interface_type),
|
574
|
+
g_base_info_get_name(interface_info));
|
575
|
+
break;
|
576
|
+
case GI_INFO_TYPE_ENUM:
|
577
|
+
argument->v_int32 = RVAL2GENUM(rb_argument, gtype);
|
578
|
+
break;
|
579
|
+
case GI_INFO_TYPE_FLAGS:
|
580
|
+
argument->v_int32 = RVAL2GFLAGS(rb_argument, gtype);
|
581
|
+
break;
|
582
|
+
case GI_INFO_TYPE_OBJECT:
|
583
|
+
case GI_INFO_TYPE_INTERFACE:
|
584
|
+
argument->v_pointer = RVAL2GOBJ(rb_argument);
|
585
|
+
break;
|
586
|
+
case GI_INFO_TYPE_CONSTANT:
|
587
|
+
rb_raise(rb_eNotImpError,
|
588
|
+
"TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
|
589
|
+
g_info_type_to_string(interface_type),
|
590
|
+
g_base_info_get_name(interface_info));
|
591
|
+
break;
|
592
|
+
case GI_INFO_TYPE_INVALID_0:
|
593
|
+
g_assert_not_reached();
|
594
|
+
break;
|
595
|
+
case GI_INFO_TYPE_UNION:
|
596
|
+
case GI_INFO_TYPE_VALUE:
|
597
|
+
case GI_INFO_TYPE_SIGNAL:
|
598
|
+
case GI_INFO_TYPE_VFUNC:
|
599
|
+
case GI_INFO_TYPE_PROPERTY:
|
600
|
+
case GI_INFO_TYPE_FIELD:
|
601
|
+
case GI_INFO_TYPE_ARG:
|
602
|
+
case GI_INFO_TYPE_TYPE:
|
603
|
+
case GI_INFO_TYPE_UNRESOLVED:
|
604
|
+
default:
|
605
|
+
rb_raise(rb_eNotImpError,
|
606
|
+
"TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
|
607
|
+
g_info_type_to_string(interface_type),
|
608
|
+
g_base_info_get_name(interface_info));
|
609
|
+
break;
|
610
|
+
}
|
611
|
+
|
612
|
+
g_base_info_unref(interface_info);
|
613
|
+
}
|
614
|
+
|
615
|
+
|
125
616
|
GIArgument *
|
126
|
-
|
127
|
-
|
617
|
+
rb_gi_in_argument_from_ruby(GIArgument *argument, GITypeInfo *type_info,
|
618
|
+
VALUE rb_argument)
|
128
619
|
{
|
620
|
+
GITypeTag type_tag;
|
621
|
+
|
129
622
|
memset(argument, 0, sizeof(GIArgument));
|
130
623
|
|
131
|
-
|
624
|
+
type_tag = g_type_info_get_tag(type_info);
|
625
|
+
switch (type_tag) {
|
132
626
|
case GI_TYPE_TAG_VOID:
|
133
627
|
break;
|
134
628
|
case GI_TYPE_TAG_BOOLEAN:
|
@@ -176,48 +670,328 @@ rb_gi_argument_from_ruby(GIArgument *argument, GITypeInfo *type_info,
|
|
176
670
|
argument->v_string = (gchar *)RVAL2CSTR(rb_argument);
|
177
671
|
break;
|
178
672
|
case GI_TYPE_TAG_ARRAY:
|
179
|
-
|
673
|
+
rb_gi_argument_from_ruby_array(argument, type_info, rb_argument);
|
180
674
|
break;
|
181
675
|
case GI_TYPE_TAG_INTERFACE:
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
break;
|
198
|
-
case GI_INFO_TYPE_OBJECT:
|
199
|
-
argument->v_pointer = RVAL2GOBJ(rb_argument);
|
200
|
-
break;
|
201
|
-
case GI_INFO_TYPE_STRUCT:
|
202
|
-
argument->v_pointer = RVAL2BOXED(rb_argument, gtype);
|
203
|
-
default:
|
204
|
-
break;
|
205
|
-
}
|
676
|
+
rb_gi_argument_from_ruby_interface(argument, type_info, rb_argument);
|
677
|
+
break;
|
678
|
+
case GI_TYPE_TAG_GLIST:
|
679
|
+
case GI_TYPE_TAG_GSLIST:
|
680
|
+
case GI_TYPE_TAG_GHASH:
|
681
|
+
case GI_TYPE_TAG_ERROR:
|
682
|
+
case GI_TYPE_TAG_UNICHAR:
|
683
|
+
rb_raise(rb_eNotImpError,
|
684
|
+
"TODO: Ruby -> GIArgument(%s)",
|
685
|
+
g_type_tag_to_string(type_tag));
|
686
|
+
break;
|
687
|
+
default:
|
688
|
+
g_assert_not_reached();
|
689
|
+
break;
|
690
|
+
}
|
206
691
|
|
207
|
-
|
208
|
-
|
692
|
+
return argument;
|
693
|
+
}
|
694
|
+
|
695
|
+
static void
|
696
|
+
rb_gi_inout_argument_from_ruby(GIArgument *argument,
|
697
|
+
G_GNUC_UNUSED GIArgInfo *arg_info,
|
698
|
+
GITypeInfo *type_info, VALUE rb_argument)
|
699
|
+
{
|
700
|
+
GIArgument in_argument;
|
701
|
+
GITypeTag type_tag;
|
702
|
+
|
703
|
+
rb_gi_in_argument_from_ruby(&in_argument, type_info, rb_argument);
|
704
|
+
|
705
|
+
type_tag = g_type_info_get_tag(type_info);
|
706
|
+
switch (type_tag) {
|
707
|
+
case GI_TYPE_TAG_VOID:
|
708
|
+
break;
|
709
|
+
case GI_TYPE_TAG_BOOLEAN:
|
710
|
+
argument->v_pointer = ALLOC(gboolean);
|
711
|
+
*((gboolean *)argument->v_pointer) = in_argument.v_boolean;
|
712
|
+
break;
|
713
|
+
case GI_TYPE_TAG_INT8:
|
714
|
+
argument->v_pointer = ALLOC(gint8);
|
715
|
+
*((gint8 *)argument->v_pointer) = in_argument.v_int8;
|
716
|
+
break;
|
717
|
+
case GI_TYPE_TAG_UINT8:
|
718
|
+
argument->v_pointer = ALLOC(guint8);
|
719
|
+
*((guint8 *)argument->v_pointer) = in_argument.v_uint8;
|
720
|
+
break;
|
721
|
+
case GI_TYPE_TAG_INT16:
|
722
|
+
argument->v_pointer = ALLOC(gint16);
|
723
|
+
*((gint16 *)argument->v_pointer) = in_argument.v_int16;
|
209
724
|
break;
|
725
|
+
case GI_TYPE_TAG_UINT16:
|
726
|
+
argument->v_pointer = ALLOC(guint16);
|
727
|
+
*((guint16 *)argument->v_pointer) = in_argument.v_uint16;
|
728
|
+
break;
|
729
|
+
case GI_TYPE_TAG_INT32:
|
730
|
+
argument->v_pointer = ALLOC(gint32);
|
731
|
+
*((gint32 *)argument->v_pointer) = in_argument.v_int32;
|
732
|
+
break;
|
733
|
+
case GI_TYPE_TAG_UINT32:
|
734
|
+
argument->v_pointer = ALLOC(guint32);
|
735
|
+
*((guint32 *)argument->v_pointer) = in_argument.v_uint32;
|
736
|
+
break;
|
737
|
+
case GI_TYPE_TAG_INT64:
|
738
|
+
argument->v_pointer = ALLOC(gint64);
|
739
|
+
*((gint64 *)argument->v_pointer) = in_argument.v_int64;
|
740
|
+
break;
|
741
|
+
case GI_TYPE_TAG_UINT64:
|
742
|
+
argument->v_pointer = ALLOC(guint64);
|
743
|
+
*((guint64 *)argument->v_pointer) = in_argument.v_uint64;
|
744
|
+
break;
|
745
|
+
case GI_TYPE_TAG_FLOAT:
|
746
|
+
argument->v_pointer = ALLOC(gfloat);
|
747
|
+
*((gfloat *)argument->v_pointer) = in_argument.v_float;
|
748
|
+
break;
|
749
|
+
case GI_TYPE_TAG_DOUBLE:
|
750
|
+
argument->v_pointer = ALLOC(gdouble);
|
751
|
+
*((gdouble *)argument->v_pointer) = in_argument.v_double;
|
752
|
+
break;
|
753
|
+
case GI_TYPE_TAG_GTYPE:
|
754
|
+
argument->v_pointer = ALLOC(gsize);
|
755
|
+
*((gsize *)argument->v_pointer) = in_argument.v_size;
|
756
|
+
break;
|
757
|
+
case GI_TYPE_TAG_UTF8:
|
758
|
+
case GI_TYPE_TAG_FILENAME:
|
759
|
+
argument->v_pointer = ALLOC(gchar *);
|
760
|
+
*((gchar **)argument->v_pointer) = in_argument.v_string;
|
761
|
+
break;
|
762
|
+
case GI_TYPE_TAG_ARRAY:
|
763
|
+
case GI_TYPE_TAG_INTERFACE:
|
210
764
|
case GI_TYPE_TAG_GLIST:
|
211
765
|
case GI_TYPE_TAG_GSLIST:
|
212
766
|
case GI_TYPE_TAG_GHASH:
|
767
|
+
argument->v_pointer = ALLOC(gpointer);
|
768
|
+
*((gpointer *)argument->v_pointer) = in_argument.v_pointer;
|
769
|
+
break;
|
213
770
|
case GI_TYPE_TAG_ERROR:
|
771
|
+
argument->v_pointer = ALLOC(GError *);
|
772
|
+
*((GError **)argument->v_pointer) = in_argument.v_pointer;
|
773
|
+
break;
|
214
774
|
case GI_TYPE_TAG_UNICHAR:
|
215
|
-
|
775
|
+
argument->v_pointer = ALLOC(gunichar);
|
776
|
+
*((gunichar *)argument->v_pointer) = in_argument.v_uint32;
|
216
777
|
break;
|
217
778
|
default:
|
218
779
|
g_assert_not_reached();
|
219
780
|
break;
|
220
781
|
}
|
782
|
+
}
|
783
|
+
|
784
|
+
GIArgument *
|
785
|
+
rb_gi_call_argument_from_ruby(GIArgument *argument, GIArgInfo *arg_info,
|
786
|
+
VALUE rb_argument)
|
787
|
+
{
|
788
|
+
GITypeInfo type_info;
|
789
|
+
|
790
|
+
if (g_arg_info_may_be_null(arg_info) && NIL_P(rb_argument)) {
|
791
|
+
memset(argument, 0, sizeof(GIArgument));
|
792
|
+
return argument;
|
793
|
+
}
|
794
|
+
|
795
|
+
g_arg_info_load_type(arg_info, &type_info);
|
796
|
+
if (g_arg_info_get_direction(arg_info) == GI_DIRECTION_INOUT) {
|
797
|
+
rb_gi_inout_argument_from_ruby(argument, arg_info, &type_info,
|
798
|
+
rb_argument);
|
799
|
+
} else {
|
800
|
+
rb_gi_in_argument_from_ruby(argument, &type_info, rb_argument);
|
801
|
+
}
|
221
802
|
|
222
803
|
return argument;
|
223
804
|
}
|
805
|
+
|
806
|
+
static void
|
807
|
+
rb_gi_in_argument_free_array(GIArgument *argument, GITypeInfo *type_info)
|
808
|
+
{
|
809
|
+
GIArrayType array_type;
|
810
|
+
|
811
|
+
array_type = g_type_info_get_array_type(type_info);
|
812
|
+
switch (array_type) {
|
813
|
+
case GI_ARRAY_TYPE_C:
|
814
|
+
g_free(argument->v_pointer);
|
815
|
+
break;
|
816
|
+
case GI_ARRAY_TYPE_ARRAY:
|
817
|
+
case GI_ARRAY_TYPE_PTR_ARRAY:
|
818
|
+
case GI_ARRAY_TYPE_BYTE_ARRAY:
|
819
|
+
break;
|
820
|
+
default:
|
821
|
+
g_assert_not_reached();
|
822
|
+
break;
|
823
|
+
}
|
824
|
+
}
|
825
|
+
|
826
|
+
static void
|
827
|
+
rb_gi_in_argument_free_interface(GIArgument *argument, GITypeInfo *type_info)
|
828
|
+
{
|
829
|
+
GIBaseInfo *interface_info;
|
830
|
+
GIInfoType interface_type;
|
831
|
+
GType gtype;
|
832
|
+
|
833
|
+
interface_info = g_type_info_get_interface(type_info);
|
834
|
+
interface_type = g_base_info_get_type(interface_info);
|
835
|
+
|
836
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
837
|
+
|
838
|
+
if (interface_type == GI_INFO_TYPE_STRUCT && gtype == G_TYPE_VALUE) {
|
839
|
+
GValue *gvalue = argument->v_pointer;
|
840
|
+
g_value_unset(gvalue);
|
841
|
+
xfree(argument->v_pointer);
|
842
|
+
}
|
843
|
+
|
844
|
+
g_base_info_unref(interface_info);
|
845
|
+
}
|
846
|
+
|
847
|
+
void
|
848
|
+
rb_gi_in_argument_free(GIArgument *argument, GITypeInfo *type_info)
|
849
|
+
{
|
850
|
+
GITypeTag type_tag;
|
851
|
+
|
852
|
+
type_tag = g_type_info_get_tag(type_info);
|
853
|
+
switch (type_tag) {
|
854
|
+
case GI_TYPE_TAG_VOID:
|
855
|
+
case GI_TYPE_TAG_BOOLEAN:
|
856
|
+
case GI_TYPE_TAG_INT8:
|
857
|
+
case GI_TYPE_TAG_UINT8:
|
858
|
+
case GI_TYPE_TAG_INT16:
|
859
|
+
case GI_TYPE_TAG_UINT16:
|
860
|
+
case GI_TYPE_TAG_INT32:
|
861
|
+
case GI_TYPE_TAG_UINT32:
|
862
|
+
case GI_TYPE_TAG_INT64:
|
863
|
+
case GI_TYPE_TAG_UINT64:
|
864
|
+
case GI_TYPE_TAG_FLOAT:
|
865
|
+
case GI_TYPE_TAG_DOUBLE:
|
866
|
+
case GI_TYPE_TAG_GTYPE:
|
867
|
+
case GI_TYPE_TAG_UTF8:
|
868
|
+
case GI_TYPE_TAG_FILENAME:
|
869
|
+
break;
|
870
|
+
case GI_TYPE_TAG_ARRAY:
|
871
|
+
rb_gi_in_argument_free_array(argument, type_info);
|
872
|
+
break;
|
873
|
+
case GI_TYPE_TAG_INTERFACE:
|
874
|
+
rb_gi_in_argument_free_interface(argument, type_info);
|
875
|
+
break;
|
876
|
+
case GI_TYPE_TAG_GLIST:
|
877
|
+
case GI_TYPE_TAG_GSLIST:
|
878
|
+
case GI_TYPE_TAG_GHASH:
|
879
|
+
case GI_TYPE_TAG_ERROR:
|
880
|
+
case GI_TYPE_TAG_UNICHAR:
|
881
|
+
break;
|
882
|
+
default:
|
883
|
+
g_assert_not_reached();
|
884
|
+
break;
|
885
|
+
}
|
886
|
+
}
|
887
|
+
|
888
|
+
static void
|
889
|
+
rb_gi_inout_argument_free(GIArgument *argument, GITypeInfo *type_info)
|
890
|
+
{
|
891
|
+
GIArgument in_argument;
|
892
|
+
GITypeTag type_tag;
|
893
|
+
|
894
|
+
memset(&in_argument, 0, sizeof(GIArgument));
|
895
|
+
type_tag = g_type_info_get_tag(type_info);
|
896
|
+
switch (type_tag) {
|
897
|
+
case GI_TYPE_TAG_VOID:
|
898
|
+
break;
|
899
|
+
case GI_TYPE_TAG_BOOLEAN:
|
900
|
+
in_argument.v_boolean = *((gboolean *)(argument->v_pointer));
|
901
|
+
break;
|
902
|
+
case GI_TYPE_TAG_INT8:
|
903
|
+
in_argument.v_int8 = *((gint8 *)(argument->v_pointer));
|
904
|
+
break;
|
905
|
+
case GI_TYPE_TAG_UINT8:
|
906
|
+
/* TODO!!! */
|
907
|
+
in_argument.v_uint8 = *((guint8 *)(argument->v_pointer));
|
908
|
+
argument->v_pointer = ALLOC(guint8);
|
909
|
+
*((guint8 *)argument->v_pointer) = in_argument.v_uint8;
|
910
|
+
break;
|
911
|
+
case GI_TYPE_TAG_INT16:
|
912
|
+
in_argument.v_int16 = *((gint16 *)(argument->v_pointer));
|
913
|
+
argument->v_pointer = ALLOC(gint16);
|
914
|
+
*((gint16 *)argument->v_pointer) = in_argument.v_int16;
|
915
|
+
break;
|
916
|
+
case GI_TYPE_TAG_UINT16:
|
917
|
+
in_argument.v_uint16 = *((guint16 *)(argument->v_pointer));
|
918
|
+
argument->v_pointer = ALLOC(guint16);
|
919
|
+
*((guint16 *)argument->v_pointer) = in_argument.v_uint16;
|
920
|
+
break;
|
921
|
+
case GI_TYPE_TAG_INT32:
|
922
|
+
in_argument.v_int32 = *((gint32 *)(argument->v_pointer));
|
923
|
+
argument->v_pointer = ALLOC(gint32);
|
924
|
+
*((gint32 *)argument->v_pointer) = in_argument.v_int32;
|
925
|
+
break;
|
926
|
+
case GI_TYPE_TAG_UINT32:
|
927
|
+
in_argument.v_uint32 = *((guint32 *)(argument->v_pointer));
|
928
|
+
argument->v_pointer = ALLOC(guint32);
|
929
|
+
*((guint32 *)argument->v_pointer) = in_argument.v_uint32;
|
930
|
+
break;
|
931
|
+
case GI_TYPE_TAG_INT64:
|
932
|
+
in_argument.v_int64 = *((gint64 *)(argument->v_pointer));
|
933
|
+
argument->v_pointer = ALLOC(gint64);
|
934
|
+
*((gint64 *)argument->v_pointer) = in_argument.v_int64;
|
935
|
+
break;
|
936
|
+
case GI_TYPE_TAG_UINT64:
|
937
|
+
in_argument.v_uint64 = *((guint64 *)(argument->v_pointer));
|
938
|
+
argument->v_pointer = ALLOC(guint64);
|
939
|
+
*((guint64 *)argument->v_pointer) = in_argument.v_uint64;
|
940
|
+
break;
|
941
|
+
case GI_TYPE_TAG_FLOAT:
|
942
|
+
in_argument.v_float = *((gfloat *)(argument->v_pointer));
|
943
|
+
argument->v_pointer = ALLOC(gfloat);
|
944
|
+
*((gfloat *)argument->v_pointer) = in_argument.v_float;
|
945
|
+
break;
|
946
|
+
case GI_TYPE_TAG_DOUBLE:
|
947
|
+
in_argument.v_double = *((gdouble *)(argument->v_pointer));
|
948
|
+
argument->v_pointer = ALLOC(gdouble);
|
949
|
+
*((gdouble *)argument->v_pointer) = in_argument.v_double;
|
950
|
+
break;
|
951
|
+
case GI_TYPE_TAG_GTYPE:
|
952
|
+
in_argument.v_size = *((gsize *)(argument->v_pointer));
|
953
|
+
break;
|
954
|
+
case GI_TYPE_TAG_UTF8:
|
955
|
+
case GI_TYPE_TAG_FILENAME:
|
956
|
+
in_argument.v_string = *((gchar **)(argument->v_pointer));
|
957
|
+
break;
|
958
|
+
case GI_TYPE_TAG_ARRAY:
|
959
|
+
case GI_TYPE_TAG_INTERFACE:
|
960
|
+
case GI_TYPE_TAG_GLIST:
|
961
|
+
case GI_TYPE_TAG_GSLIST:
|
962
|
+
case GI_TYPE_TAG_GHASH:
|
963
|
+
in_argument.v_pointer = *((gpointer *)(argument->v_pointer));
|
964
|
+
break;
|
965
|
+
case GI_TYPE_TAG_ERROR:
|
966
|
+
in_argument.v_pointer = *((GError **)(argument->v_pointer));
|
967
|
+
break;
|
968
|
+
case GI_TYPE_TAG_UNICHAR:
|
969
|
+
in_argument.v_uint32 = *((gunichar *)(argument->v_pointer));
|
970
|
+
break;
|
971
|
+
default:
|
972
|
+
g_assert_not_reached();
|
973
|
+
break;
|
974
|
+
}
|
975
|
+
|
976
|
+
rb_gi_in_argument_free(&in_argument, type_info);
|
977
|
+
xfree(argument->v_pointer);
|
978
|
+
}
|
979
|
+
|
980
|
+
void
|
981
|
+
rb_gi_call_argument_free(GIArgument *argument, GIArgInfo *arg_info)
|
982
|
+
{
|
983
|
+
GITypeInfo type_info;
|
984
|
+
|
985
|
+
g_arg_info_load_type(arg_info, &type_info);
|
986
|
+
if (g_arg_info_get_direction(arg_info) == GI_DIRECTION_INOUT) {
|
987
|
+
rb_gi_inout_argument_free(argument, &type_info);
|
988
|
+
} else {
|
989
|
+
rb_gi_in_argument_free(argument, &type_info);
|
990
|
+
}
|
991
|
+
}
|
992
|
+
|
993
|
+
void
|
994
|
+
rb_gi_argument_init(void)
|
995
|
+
{
|
996
|
+
rb_cGLibValue = rb_const_get(mGLib, rb_intern("Value"));
|
997
|
+
}
|