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,143 @@
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_cGITypeInfo
24
+ #define SELF(self) (RVAL2GI_TYPE_INFO(self))
25
+
26
+ GType
27
+ gi_type_info_get_type(void)
28
+ {
29
+ static GType type = 0;
30
+ if (type == 0) {
31
+ type = g_boxed_type_register_static("GITypeInfo",
32
+ (GBoxedCopyFunc)g_base_info_ref,
33
+ (GBoxedFreeFunc)g_base_info_unref);
34
+ }
35
+ return type;
36
+ }
37
+
38
+ VALUE
39
+ rb_gi_array_type_to_ruby(GIArrayType type)
40
+ {
41
+ if (type == (GIArrayType)-1) {
42
+ return Qnil;
43
+ } else {
44
+ return GENUM2RVAL(type, G_TYPE_I_ARRAY_TYPE);
45
+ }
46
+ }
47
+
48
+ static VALUE
49
+ rg_pointer_p(VALUE self)
50
+ {
51
+ GITypeInfo *info;
52
+
53
+ info = SELF(self);
54
+ return CBOOL2RVAL(g_type_info_is_pointer(info));
55
+ }
56
+
57
+ static VALUE
58
+ rg_tag(VALUE self)
59
+ {
60
+ GITypeInfo *info;
61
+
62
+ info = SELF(self);
63
+ return GI_TYPE_TAG2RVAL(g_type_info_get_tag(info));
64
+ }
65
+
66
+ static VALUE
67
+ rg_get_param_type(VALUE self, VALUE rb_n)
68
+ {
69
+ GITypeInfo *info;
70
+ gint n;
71
+
72
+ info = SELF(self);
73
+ n = NUM2INT(rb_n);
74
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_type_info_get_param_type(info, n));
75
+ }
76
+
77
+ static VALUE
78
+ rg_interface(VALUE self)
79
+ {
80
+ GITypeInfo *info;
81
+
82
+ info = SELF(self);
83
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_type_info_get_interface(info));
84
+ }
85
+
86
+ static VALUE
87
+ rg_array_length(VALUE self)
88
+ {
89
+ GITypeInfo *info;
90
+
91
+ info = SELF(self);
92
+ return INT2NUM(g_type_info_get_array_length(info));
93
+ }
94
+
95
+ static VALUE
96
+ rg_array_fixed_size(VALUE self)
97
+ {
98
+ GITypeInfo *info;
99
+
100
+ info = SELF(self);
101
+ return INT2NUM(g_type_info_get_array_fixed_size(info));
102
+ }
103
+
104
+ static VALUE
105
+ rg_zero_terminated_p(VALUE self)
106
+ {
107
+ GITypeInfo *info;
108
+
109
+ info = SELF(self);
110
+ return CBOOL2RVAL(g_type_info_is_zero_terminated(info));
111
+ }
112
+
113
+ static VALUE
114
+ rg_array_type(VALUE self)
115
+ {
116
+ GITypeInfo *info;
117
+
118
+ info = SELF(self);
119
+ return GI_ARRAY_TYPE2RVAL(g_type_info_get_array_type(info));
120
+ }
121
+
122
+ void
123
+ rb_gi_type_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo)
124
+ {
125
+ VALUE RG_TARGET_NAMESPACE;
126
+
127
+ RG_TARGET_NAMESPACE =
128
+ G_DEF_CLASS_WITH_PARENT(GI_TYPE_TYPE_INFO, "TypeInfo", rb_mGI,
129
+ rb_cGIBaseInfo);
130
+
131
+ RG_DEF_METHOD_P(pointer, 0);
132
+ RG_DEF_METHOD(tag, 0);
133
+ RG_DEF_METHOD(get_param_type, 1);
134
+ RG_DEF_METHOD(interface, 0);
135
+ RG_DEF_METHOD(array_length, 0);
136
+ RG_DEF_METHOD(array_fixed_size, 0);
137
+ RG_DEF_METHOD_P(zero_terminated, 0);
138
+ RG_DEF_METHOD(array_type, 0);
139
+
140
+ rb_undef_method(RG_TARGET_NAMESPACE, "name");
141
+
142
+ G_DEF_CLASS(G_TYPE_I_ARRAY_TYPE, "ArrayType", rb_mGI);
143
+ }
@@ -0,0 +1,43 @@
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_cGITypeTag
24
+ #define SELF(self) (RVAL2GI_TYPE_TAG(self))
25
+
26
+ static VALUE
27
+ rg_to_s(VALUE self)
28
+ {
29
+ GITypeTag tag;
30
+
31
+ tag = SELF(self);
32
+ return CSTR2RVAL(g_type_tag_to_string(tag));
33
+ }
34
+
35
+ void
36
+ rb_gi_type_tag_init(VALUE rb_mGI)
37
+ {
38
+ VALUE RG_TARGET_NAMESPACE;
39
+
40
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_I_TYPE_TAG, "TypeTag", rb_mGI);
41
+
42
+ RG_DEF_METHOD(to_s, 0);
43
+ }
@@ -0,0 +1,71 @@
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
+ #ifndef RB_GI_TYPES_H
22
+ #define RB_GI_TYPES_H
23
+
24
+ #define GI_TYPE_CALLABLE_INFO (gi_callable_info_get_type())
25
+ #define GI_TYPE_FUNCTION_INFO (gi_function_info_get_type())
26
+ #define GI_TYPE_METHOD_INFO (gi_method_info_get_type())
27
+ #define GI_TYPE_CONSTRUCTOR_INFO (gi_constructor_info_get_type())
28
+ #define GI_TYPE_CALLBACK_INFO (gi_callback_info_get_type())
29
+ #define GI_TYPE_REGISTERED_TYPE_INFO (gi_registered_type_info_get_type())
30
+ #define GI_TYPE_STRUCT_INFO (gi_struct_info_get_type())
31
+ #define GI_TYPE_BOXED_INFO (gi_boxed_info_get_type())
32
+ #define GI_TYPE_ENUM_INFO (gi_enum_info_get_type())
33
+ #define GI_TYPE_FLAGS_INFO (gi_flags_info_get_type())
34
+ #define GI_TYPE_OBJECT_INFO (gi_object_info_get_type())
35
+ #define GI_TYPE_INTERFACE_INFO (gi_interface_info_get_type())
36
+ #define GI_TYPE_CONSTANT_INFO (gi_constant_info_get_type())
37
+ #define GI_TYPE_UNION_INFO (gi_union_info_get_type())
38
+ #define GI_TYPE_VALUE_INFO (gi_value_info_get_type())
39
+ #define GI_TYPE_SIGNAL_INFO (gi_signal_info_get_type())
40
+ #define GI_TYPE_VFUNC_INFO (gi_vfunc_info_get_type())
41
+ #define GI_TYPE_PROPERTY_INFO (gi_property_info_get_type())
42
+ #define GI_TYPE_FIELD_INFO (gi_field_info_get_type())
43
+ #define GI_TYPE_ARG_INFO (gi_arg_info_get_type())
44
+ #define GI_TYPE_TYPE_INFO (gi_type_info_get_type())
45
+ #define GI_TYPE_UNRESOLVED_INFO (gi_unresolved_info_get_type())
46
+
47
+ GType gi_callable_info_get_type (void);
48
+ GType gi_function_info_get_type (void);
49
+ GType gi_method_info_get_type (void);
50
+ GType gi_constructor_info_get_type (void);
51
+ GType gi_callback_info_get_type (void);
52
+ GType gi_registered_type_info_get_type (void);
53
+ GType gi_struct_info_get_type (void);
54
+ GType gi_boxed_info_get_type (void);
55
+ GType gi_enum_info_get_type (void);
56
+ GType gi_flags_info_get_type (void);
57
+ GType gi_object_info_get_type (void);
58
+ GType gi_interface_info_get_type (void);
59
+ GType gi_constant_info_get_type (void);
60
+ GType gi_union_info_get_type (void);
61
+ GType gi_value_info_get_type (void);
62
+ GType gi_signal_info_get_type (void);
63
+ GType gi_vfunc_info_get_type (void);
64
+ GType gi_property_info_get_type (void);
65
+ GType gi_field_info_get_type (void);
66
+ GType gi_arg_info_get_type (void);
67
+ GType gi_type_info_get_type (void);
68
+ GType gi_unresolved_info_get_type (void);
69
+
70
+
71
+ #endif
@@ -0,0 +1,206 @@
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_cGIUnionInfo
24
+ #define SELF(self) (RVAL2GI_UNION_INFO(self))
25
+
26
+ GType
27
+ gi_union_info_get_type(void)
28
+ {
29
+ static GType type = 0;
30
+ if (type == 0) {
31
+ type = g_boxed_type_register_static("GIUnionInfo",
32
+ (GBoxedCopyFunc)g_base_info_ref,
33
+ (GBoxedFreeFunc)g_base_info_unref);
34
+ }
35
+ return type;
36
+ }
37
+
38
+ static VALUE
39
+ rg_n_fields(VALUE self)
40
+ {
41
+ GIUnionInfo *info;
42
+
43
+ info = SELF(self);
44
+ return INT2NUM(g_union_info_get_n_fields(info));
45
+ }
46
+
47
+ static VALUE
48
+ rg_get_field(VALUE self, VALUE rb_n)
49
+ {
50
+ GIUnionInfo *info;
51
+ gint n;
52
+
53
+ info = SELF(self);
54
+ n = NUM2INT(rb_n);
55
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_union_info_get_field(info, n));
56
+ }
57
+
58
+ static VALUE
59
+ rg_get_field_value(VALUE self, VALUE rb_union, VALUE rb_n)
60
+ {
61
+ GIUnionInfo *info;
62
+ gint n;
63
+ GIFieldInfo *field_info;
64
+ GType gtype;
65
+ VALUE rb_value;
66
+
67
+ info = SELF(self);
68
+ n = NUM2INT(rb_n);
69
+ field_info = g_union_info_get_field(info, n);
70
+ gtype = g_registered_type_info_get_g_type(info);
71
+ rb_value = rb_gi_field_info_get_field_raw(field_info,
72
+ RVAL2BOXED(rb_union, gtype));
73
+ g_base_info_unref(field_info);
74
+
75
+ return rb_value;
76
+ }
77
+
78
+ static VALUE
79
+ rg_set_field_value(VALUE self, VALUE rb_union, VALUE rb_n, VALUE rb_value)
80
+ {
81
+ GIUnionInfo *info;
82
+ gint n;
83
+ GIFieldInfo *field_info;
84
+ GType gtype;
85
+
86
+ info = SELF(self);
87
+ n = NUM2INT(rb_n);
88
+ field_info = g_union_info_get_field(info, n);
89
+ gtype = g_registered_type_info_get_g_type(info);
90
+ rb_gi_field_info_set_field_raw(field_info,
91
+ RVAL2BOXED(rb_union, gtype),
92
+ rb_value);
93
+ /* TODO: use rb_ensure() to unref field_info. */
94
+ g_base_info_unref(field_info);
95
+
96
+ return Qnil;
97
+ }
98
+
99
+ static VALUE
100
+ rg_n_methods(VALUE self)
101
+ {
102
+ GIUnionInfo *info;
103
+
104
+ info = SELF(self);
105
+ return INT2NUM(g_union_info_get_n_methods(info));
106
+ }
107
+
108
+ static VALUE
109
+ rg_get_method(VALUE self, VALUE rb_n_or_name)
110
+ {
111
+ GIUnionInfo *info;
112
+ GIFunctionInfo *function_info;
113
+
114
+ info = SELF(self);
115
+ if (RB_TYPE_P(self, T_FIXNUM)) {
116
+ gint n;
117
+ n = NUM2INT(rb_n_or_name);
118
+ function_info = g_union_info_get_method(info, n);
119
+ } else {
120
+ const gchar *name;
121
+ name = RVAL2CSTR(rb_n_or_name);
122
+ function_info = g_union_info_find_method(info, name);
123
+ }
124
+
125
+ return GI_BASE_INFO2RVAL_WITH_UNREF(function_info);
126
+ }
127
+
128
+ static VALUE
129
+ rg_discriminated_p(VALUE self)
130
+ {
131
+ GIUnionInfo *info;
132
+
133
+ info = SELF(self);
134
+ return CBOOL2RVAL(g_union_info_is_discriminated(info));
135
+ }
136
+
137
+ static VALUE
138
+ rg_discriminator_offset(VALUE self)
139
+ {
140
+ GIUnionInfo *info;
141
+
142
+ info = SELF(self);
143
+ return INT2NUM(g_union_info_get_discriminator_offset(info));
144
+ }
145
+
146
+ static VALUE
147
+ rg_discriminator_type(VALUE self)
148
+ {
149
+ GIUnionInfo *info;
150
+
151
+ info = SELF(self);
152
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_union_info_get_discriminator_type(info));
153
+ }
154
+
155
+ static VALUE
156
+ rg_get_discriminator(VALUE self, VALUE rb_n)
157
+ {
158
+ GIUnionInfo *info;
159
+ gint n;
160
+
161
+ info = SELF(self);
162
+ n = NUM2INT(rb_n);
163
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_union_info_get_discriminator(info, n));
164
+ }
165
+
166
+ static VALUE
167
+ rg_size(VALUE self)
168
+ {
169
+ GIUnionInfo *info;
170
+
171
+ info = SELF(self);
172
+ return ULONG2NUM(g_union_info_get_size(info));
173
+ }
174
+
175
+
176
+ static VALUE
177
+ rg_alignment(VALUE self)
178
+ {
179
+ GIUnionInfo *info;
180
+
181
+ info = SELF(self);
182
+ return ULONG2NUM(g_union_info_get_alignment(info));
183
+ }
184
+
185
+ void
186
+ rb_gi_union_info_init(VALUE rb_mGI, VALUE rb_cGIRegisteredTypeInfo)
187
+ {
188
+ VALUE RG_TARGET_NAMESPACE;
189
+
190
+ RG_TARGET_NAMESPACE =
191
+ G_DEF_CLASS_WITH_PARENT(GI_TYPE_UNION_INFO, "UnionInfo", rb_mGI,
192
+ rb_cGIRegisteredTypeInfo);
193
+
194
+ RG_DEF_METHOD(n_fields, 0);
195
+ RG_DEF_METHOD(get_field, 1);
196
+ RG_DEF_METHOD(get_field_value, 2);
197
+ RG_DEF_METHOD(set_field_value, 3);
198
+ RG_DEF_METHOD(n_methods, 0);
199
+ RG_DEF_METHOD(get_method, 1);
200
+ RG_DEF_METHOD_P(discriminated, 0);
201
+ RG_DEF_METHOD(discriminator_offset, 0);
202
+ RG_DEF_METHOD(discriminator_type, 0);
203
+ RG_DEF_METHOD(get_discriminator, 1);
204
+ RG_DEF_METHOD(size, 0);
205
+ RG_DEF_METHOD(alignment, 0);
206
+ }