gobject-introspection 1.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/Rakefile +50 -0
  2. data/ext/gobject-introspection/extconf.rb +97 -0
  3. data/ext/gobject-introspection/rb-gi-arg-info.c +151 -0
  4. data/ext/gobject-introspection/rb-gi-argument.c +223 -0
  5. data/ext/gobject-introspection/rb-gi-base-info.c +218 -0
  6. data/ext/gobject-introspection/rb-gi-boxed-info.c +48 -0
  7. data/ext/gobject-introspection/rb-gi-callable-info.c +124 -0
  8. data/ext/gobject-introspection/rb-gi-callback-info.c +48 -0
  9. data/ext/gobject-introspection/rb-gi-constant-info.c +77 -0
  10. data/ext/gobject-introspection/rb-gi-constructor-info.c +82 -0
  11. data/ext/gobject-introspection/rb-gi-conversions.h +95 -0
  12. data/ext/gobject-introspection/rb-gi-enum-info.c +145 -0
  13. data/ext/gobject-introspection/rb-gi-field-info.c +149 -0
  14. data/ext/gobject-introspection/rb-gi-flags-info.c +48 -0
  15. data/ext/gobject-introspection/rb-gi-function-info.c +199 -0
  16. data/ext/gobject-introspection/rb-gi-interface-info.c +222 -0
  17. data/ext/gobject-introspection/rb-gi-loader.c +61 -0
  18. data/ext/gobject-introspection/rb-gi-method-info.c +66 -0
  19. data/ext/gobject-introspection/rb-gi-object-info.c +345 -0
  20. data/ext/gobject-introspection/rb-gi-property-info.c +77 -0
  21. data/ext/gobject-introspection/rb-gi-registered-type-info.c +86 -0
  22. data/ext/gobject-introspection/rb-gi-repository.c +164 -0
  23. data/ext/gobject-introspection/rb-gi-signal-info.c +77 -0
  24. data/ext/gobject-introspection/rb-gi-struct-info.c +183 -0
  25. data/ext/gobject-introspection/rb-gi-type-info.c +143 -0
  26. data/ext/gobject-introspection/rb-gi-type-tag.c +43 -0
  27. data/ext/gobject-introspection/rb-gi-types.h +71 -0
  28. data/ext/gobject-introspection/rb-gi-union-info.c +206 -0
  29. data/ext/gobject-introspection/rb-gi-unresolved-info.c +48 -0
  30. data/ext/gobject-introspection/rb-gi-value-info.c +57 -0
  31. data/ext/gobject-introspection/rb-gi-vfunc-info.c +91 -0
  32. data/ext/gobject-introspection/rb-gobject-introspection.c +42 -0
  33. data/ext/gobject-introspection/rb-gobject-introspection.h +105 -0
  34. data/extconf.rb +71 -0
  35. data/lib/gobject-introspection.rb +39 -0
  36. data/lib/gobject-introspection/collection-reader.rb +34 -0
  37. data/lib/gobject-introspection/loader.rb +148 -0
  38. data/lib/gobject-introspection/object-info.rb +33 -0
  39. data/lib/gobject-introspection/repository.rb +32 -0
  40. data/lib/gobject-introspection/struct-info.rb +28 -0
  41. data/sample/clutter-basic-actor.rb +132 -0
  42. data/sample/clutter.rb +29 -0
  43. data/test/gobject-introspection-test-utils.rb +26 -0
  44. data/test/run-test.rb +45 -0
  45. data/test/test-arg-info.rb +68 -0
  46. data/test/test-base-info.rb +31 -0
  47. data/test/test-boxed-info.rb +21 -0
  48. data/test/test-callable-info.rb +49 -0
  49. data/test/test-callback-info.rb +29 -0
  50. data/test/test-constant-info.rb +24 -0
  51. data/test/test-enum-info.rb +56 -0
  52. data/test/test-field-type.rb +42 -0
  53. data/test/test-flags-info.rb +27 -0
  54. data/test/test-function-info.rb +37 -0
  55. data/test/test-interface-info.rb +97 -0
  56. data/test/test-loader.rb +30 -0
  57. data/test/test-object-info.rb +131 -0
  58. data/test/test-property-info.rb +38 -0
  59. data/test/test-registered-type-info.rb +35 -0
  60. data/test/test-repository.rb +59 -0
  61. data/test/test-signal-info.rb +37 -0
  62. data/test/test-struct-info.rb +57 -0
  63. data/test/test-type-info.rb +62 -0
  64. data/test/test-type-tag.rb +29 -0
  65. data/test/test-union-info.rb +21 -0
  66. data/test/test-value-info.rb +28 -0
  67. data/test/test-vfunc-info.rb +42 -0
  68. metadata +162 -0
@@ -0,0 +1,61 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2012 Ruby-GNOME2 Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #include "rb-gobject-introspection.h"
22
+
23
+ #define RG_TARGET_NAMESPACE rb_cGILoader
24
+
25
+ static VALUE
26
+ rg_s_define_class(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
27
+ {
28
+ VALUE rb_gtype, rb_name, rb_module;
29
+ VALUE rb_options, rb_parent;
30
+ GType gtype;
31
+
32
+ rb_scan_args(argc, argv, "31", &rb_gtype, &rb_name, &rb_module, &rb_options);
33
+ rbg_scan_options(rb_options,
34
+ "parent", &rb_parent,
35
+ NULL);
36
+
37
+ gtype = NUM2ULONG(rb_to_int(rb_gtype));
38
+ return G_DEF_CLASS_WITH_PARENT(gtype, RVAL2CSTR(rb_name),
39
+ rb_module, rb_parent);
40
+ }
41
+
42
+ static VALUE
43
+ rg_s_define_interface(G_GNUC_UNUSED VALUE klass,
44
+ VALUE rb_gtype, VALUE rb_name, VALUE rb_module)
45
+ {
46
+ GType gtype;
47
+
48
+ gtype = NUM2ULONG(rb_to_int(rb_gtype));
49
+ return G_DEF_INTERFACE(gtype, RVAL2CSTR(rb_name), rb_module);
50
+ }
51
+
52
+ void
53
+ rb_gi_loader_init(VALUE rb_mGI)
54
+ {
55
+ VALUE RG_TARGET_NAMESPACE;
56
+
57
+ RG_TARGET_NAMESPACE = rb_define_class_under(rb_mGI, "Loader", rb_cObject);
58
+
59
+ RG_DEF_SMETHOD(define_class, -1);
60
+ RG_DEF_SMETHOD(define_interface, 3);
61
+ }
@@ -0,0 +1,66 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2012 Ruby-GNOME2 Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #include "rb-gobject-introspection.h"
22
+
23
+ #define RG_TARGET_NAMESPACE rb_cGIMethodInfo
24
+ #define SELF(self) RVAL2GI_FUNCTION_INFO(self)
25
+
26
+ GType
27
+ gi_method_info_get_type(void)
28
+ {
29
+ static GType type = 0;
30
+ if (type == 0) {
31
+ type = g_boxed_type_register_static("GIMethodInfo",
32
+ (GBoxedCopyFunc)g_base_info_ref,
33
+ (GBoxedFreeFunc)g_base_info_unref);
34
+ }
35
+ return type;
36
+ }
37
+
38
+ static VALUE
39
+ rg_invoke(int argc, VALUE *argv, VALUE self)
40
+ {
41
+ GIFunctionInfo *info;
42
+ GICallableInfo *callable_info;
43
+ GIArgument return_value;
44
+ GITypeInfo return_value_info;
45
+
46
+ info = SELF(self);
47
+ callable_info = (GICallableInfo *)info;
48
+
49
+ /* TODO: check argc >= 1 */
50
+ rb_gi_function_info_invoke_raw(info, argc, argv, &return_value);
51
+ g_callable_info_load_return_type(callable_info, &return_value_info);
52
+
53
+ return GI_ARGUMENT2RVAL(&return_value, &return_value_info);
54
+ }
55
+
56
+ void
57
+ rb_gi_method_info_init(VALUE rb_mGI, VALUE rb_cGIFunctionInfo)
58
+ {
59
+ VALUE RG_TARGET_NAMESPACE;
60
+
61
+ RG_TARGET_NAMESPACE =
62
+ G_DEF_CLASS_WITH_PARENT(GI_TYPE_METHOD_INFO, "MethodInfo", rb_mGI,
63
+ rb_cGIFunctionInfo);
64
+
65
+ RG_DEF_METHOD(invoke, -1);
66
+ }
@@ -0,0 +1,345 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2012 Ruby-GNOME2 Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #include "rb-gobject-introspection.h"
22
+
23
+ #define RG_TARGET_NAMESPACE rb_cGIObjectInfo
24
+ #define SELF(self) (RVAL2GI_OBJECT_INFO(self))
25
+
26
+ GType
27
+ gi_object_info_get_type(void)
28
+ {
29
+ static GType type = 0;
30
+ if (type == 0) {
31
+ type = g_boxed_type_register_static("GIObjectInfo",
32
+ (GBoxedCopyFunc)g_base_info_ref,
33
+ (GBoxedFreeFunc)g_base_info_unref);
34
+ }
35
+ return type;
36
+ }
37
+
38
+ static VALUE
39
+ rg_type_name(VALUE self)
40
+ {
41
+ GIObjectInfo *info;
42
+
43
+ info = SELF(self);
44
+ return CSTR2RVAL(g_object_info_get_type_name(info));
45
+ }
46
+
47
+ static VALUE
48
+ rg_type_init(VALUE self)
49
+ {
50
+ GIObjectInfo *info;
51
+
52
+ info = SELF(self);
53
+ return CSTR2RVAL(g_object_info_get_type_init(info));
54
+ }
55
+
56
+ static VALUE
57
+ rg_abstract_p(VALUE self)
58
+ {
59
+ GIObjectInfo *info;
60
+
61
+ info = SELF(self);
62
+ return CBOOL2RVAL(g_object_info_get_abstract(info));
63
+ }
64
+
65
+ static VALUE
66
+ rg_fundamental_p(VALUE self)
67
+ {
68
+ GIObjectInfo *info;
69
+
70
+ info = SELF(self);
71
+ return CBOOL2RVAL(g_object_info_get_fundamental(info));
72
+ }
73
+
74
+ static VALUE
75
+ rg_parent(VALUE self)
76
+ {
77
+ GIObjectInfo *info;
78
+
79
+ info = SELF(self);
80
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_parent(info));
81
+ }
82
+
83
+ static VALUE
84
+ rg_n_interfaces(VALUE self)
85
+ {
86
+ GIObjectInfo *info;
87
+
88
+ info = SELF(self);
89
+ return INT2NUM(g_object_info_get_n_interfaces(info));
90
+ }
91
+
92
+ static VALUE
93
+ rg_get_interface(VALUE self, VALUE rb_n)
94
+ {
95
+ GIObjectInfo *info;
96
+ gint n;
97
+
98
+ info = SELF(self);
99
+ n = NUM2INT(rb_n);
100
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_interface(info, n));
101
+ }
102
+
103
+ static VALUE
104
+ rg_n_fields(VALUE self)
105
+ {
106
+ GIObjectInfo *info;
107
+
108
+ info = SELF(self);
109
+ return INT2NUM(g_object_info_get_n_fields(info));
110
+ }
111
+
112
+ static VALUE
113
+ rg_get_field(VALUE self, VALUE rb_n)
114
+ {
115
+ GIObjectInfo *info;
116
+ gint n;
117
+
118
+ info = SELF(self);
119
+ n = NUM2INT(rb_n);
120
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_field(info, n));
121
+ }
122
+
123
+ static VALUE
124
+ rg_get_field_value(VALUE self, VALUE rb_object, VALUE rb_n)
125
+ {
126
+ GIObjectInfo *info;
127
+ gint n;
128
+ GIFieldInfo *field_info;
129
+ VALUE rb_value;
130
+
131
+ info = SELF(self);
132
+ n = NUM2INT(rb_n);
133
+ field_info = g_object_info_get_field(info, n);
134
+ rb_value = rb_gi_field_info_get_field_raw(field_info, RVAL2GOBJ(rb_object));
135
+ g_base_info_unref(field_info);
136
+
137
+ return rb_value;
138
+ }
139
+
140
+ static VALUE
141
+ rg_set_field_value(VALUE self, VALUE rb_object, VALUE rb_n, VALUE rb_value)
142
+ {
143
+ GIObjectInfo *info;
144
+ gint n;
145
+ GIFieldInfo *field_info;
146
+
147
+ info = SELF(self);
148
+ n = NUM2INT(rb_n);
149
+ field_info = g_object_info_get_field(info, n);
150
+ rb_gi_field_info_set_field_raw(field_info, RVAL2GOBJ(rb_object), rb_value);
151
+ /* TODO: use rb_ensure() to unref field_info. */
152
+ g_base_info_unref(field_info);
153
+
154
+ return Qnil;
155
+ }
156
+
157
+ static VALUE
158
+ rg_n_properties(VALUE self)
159
+ {
160
+ GIObjectInfo *info;
161
+
162
+ info = SELF(self);
163
+ return INT2NUM(g_object_info_get_n_properties(info));
164
+ }
165
+
166
+ static VALUE
167
+ rg_get_property(VALUE self, VALUE rb_n)
168
+ {
169
+ GIObjectInfo *info;
170
+ gint n;
171
+
172
+ info = SELF(self);
173
+ n = NUM2INT(rb_n);
174
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_property(info, n));
175
+ }
176
+
177
+ static VALUE
178
+ rg_n_methods(VALUE self)
179
+ {
180
+ GIObjectInfo *info;
181
+
182
+ info = SELF(self);
183
+ return INT2NUM(g_object_info_get_n_methods(info));
184
+ }
185
+
186
+ static VALUE
187
+ rg_get_method(VALUE self, VALUE rb_n_or_name)
188
+ {
189
+ GIObjectInfo *info;
190
+ GIFunctionInfo *function_info;
191
+
192
+ info = SELF(self);
193
+ if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) {
194
+ gint n;
195
+ n = NUM2INT(rb_n_or_name);
196
+ function_info = g_object_info_get_method(info, n);
197
+ } else {
198
+ const gchar *name;
199
+ name = RVAL2CSTR(rb_n_or_name);
200
+ function_info = g_object_info_find_method(info, name);
201
+ }
202
+
203
+ return GI_BASE_INFO2RVAL_WITH_UNREF(function_info);
204
+ }
205
+
206
+ static VALUE
207
+ rg_n_signals(VALUE self)
208
+ {
209
+ GIObjectInfo *info;
210
+
211
+ info = SELF(self);
212
+ return INT2NUM(g_object_info_get_n_signals(info));
213
+ }
214
+
215
+ static VALUE
216
+ rg_get_signal(VALUE self, VALUE rb_n)
217
+ {
218
+ GIObjectInfo *info;
219
+ gint n;
220
+
221
+ info = SELF(self);
222
+ n = NUM2INT(rb_n);
223
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_signal(info, n));
224
+ }
225
+
226
+ static VALUE
227
+ rg_n_vfuncs(VALUE self)
228
+ {
229
+ GIObjectInfo *info;
230
+
231
+ info = SELF(self);
232
+ return INT2NUM(g_object_info_get_n_vfuncs(info));
233
+ }
234
+
235
+ static VALUE
236
+ rg_get_vfunc(VALUE self, VALUE rb_n_or_name)
237
+ {
238
+ GIObjectInfo *info;
239
+ GIVFuncInfo *vfunc_info;
240
+
241
+ info = SELF(self);
242
+ if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) {
243
+ gint n;
244
+ n = NUM2INT(rb_n_or_name);
245
+ vfunc_info = g_object_info_get_vfunc(info, n);
246
+ } else {
247
+ const gchar *name;
248
+ name = RVAL2CSTR(rb_n_or_name);
249
+ vfunc_info = g_object_info_find_vfunc(info, name);
250
+ }
251
+
252
+ return GI_BASE_INFO2RVAL_WITH_UNREF(vfunc_info);
253
+ }
254
+
255
+ static VALUE
256
+ rg_n_constants(VALUE self)
257
+ {
258
+ GIObjectInfo *info;
259
+
260
+ info = SELF(self);
261
+ return INT2NUM(g_object_info_get_n_constants(info));
262
+ }
263
+
264
+ static VALUE
265
+ rg_get_constant(VALUE self, VALUE rb_n)
266
+ {
267
+ GIObjectInfo *info;
268
+ gint n;
269
+
270
+ info = SELF(self);
271
+ n = NUM2INT(rb_n);
272
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_object_info_get_constant(info, n));
273
+ }
274
+
275
+ static VALUE
276
+ rg_unref_function(VALUE self)
277
+ {
278
+ GIObjectInfo *info;
279
+
280
+ info = SELF(self);
281
+ return CSTR2RVAL(g_object_info_get_unref_function(info));
282
+ }
283
+
284
+ static VALUE
285
+ rg_ref_function(VALUE self)
286
+ {
287
+ GIObjectInfo *info;
288
+
289
+ info = SELF(self);
290
+ return CSTR2RVAL(g_object_info_get_ref_function(info));
291
+ }
292
+
293
+ static VALUE
294
+ rg_set_value_function(VALUE self)
295
+ {
296
+ GIObjectInfo *info;
297
+
298
+ info = SELF(self);
299
+ return CSTR2RVAL(g_object_info_get_set_value_function(info));
300
+ }
301
+
302
+ static VALUE
303
+ rg_get_value_function(VALUE self)
304
+ {
305
+ GIObjectInfo *info;
306
+
307
+ info = SELF(self);
308
+ return CSTR2RVAL(g_object_info_get_get_value_function(info));
309
+ }
310
+
311
+ void
312
+ rb_gi_object_info_init(VALUE rb_mGI, VALUE rb_cGIRegisteredTypeInfo)
313
+ {
314
+ VALUE RG_TARGET_NAMESPACE;
315
+
316
+ RG_TARGET_NAMESPACE =
317
+ G_DEF_CLASS_WITH_PARENT(GI_TYPE_OBJECT_INFO, "ObjectInfo", rb_mGI,
318
+ rb_cGIRegisteredTypeInfo);
319
+
320
+ RG_DEF_METHOD(type_name, 0);
321
+ RG_DEF_METHOD(type_init, 0);
322
+ RG_DEF_METHOD_P(abstract, 0);
323
+ RG_DEF_METHOD_P(fundamental, 0);
324
+ RG_DEF_METHOD(parent, 0);
325
+ RG_DEF_METHOD(n_interfaces, 0);
326
+ RG_DEF_METHOD(get_interface, 1);
327
+ RG_DEF_METHOD(n_fields, 0);
328
+ RG_DEF_METHOD(get_field, 1);
329
+ RG_DEF_METHOD(get_field_value, 2);
330
+ RG_DEF_METHOD(set_field_value, 3);
331
+ RG_DEF_METHOD(n_properties, 0);
332
+ RG_DEF_METHOD(get_property, 1);
333
+ RG_DEF_METHOD(n_methods, 0);
334
+ RG_DEF_METHOD(get_method, 1);
335
+ RG_DEF_METHOD(n_signals, 0);
336
+ RG_DEF_METHOD(get_signal, 1);
337
+ RG_DEF_METHOD(n_vfuncs, 0);
338
+ RG_DEF_METHOD(get_vfunc, 1);
339
+ RG_DEF_METHOD(n_constants, 0);
340
+ RG_DEF_METHOD(get_constant, 1);
341
+ RG_DEF_METHOD(unref_function, 0);
342
+ RG_DEF_METHOD(ref_function, 0);
343
+ RG_DEF_METHOD(set_value_function, 0);
344
+ RG_DEF_METHOD(get_value_function, 0);
345
+ }