gobject-introspection 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +5 -5
- data/ext/gobject-introspection/rb-gi-argument.c +28 -3
- data/ext/gobject-introspection/rb-gi-constructor-info.c +6 -1
- data/ext/gobject-introspection/rb-gi-function-info.c +29 -4
- data/ext/gobject-introspection/rb-gi-loader.c +19 -3
- data/ext/gobject-introspection/rb-gi-struct-info.c +28 -16
- data/lib/gobject-introspection/callable-info.rb +16 -7
- data/lib/gobject-introspection/loader.rb +47 -19
- data/test/test-object-info.rb +1 -1
- data/test/test-signal-info.rb +2 -2
- data/test/test-struct-info.rb +1 -1
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4875c4a9ddb218ef740a2135550956b781c32ba
|
4
|
+
data.tar.gz: 9e29ebc166a0e80ced774aa1e05a990d51f39f7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3cf5eff3a6cca27bfafc05a27093dedafd1f604f5d78841edc8423c7c2d99249b721afd67531ee25d3f137fb32bd1f7cfb3e3d9370d50373fbb74107dc451f5
|
7
|
+
data.tar.gz: 1c5b04919021c4054870606ecf0b5cb7cf36ec2eaa29b9044acec7672574d814ea69c22ef0f7635681bb6ea1ee67972650d1cc13ca01b7734e65243d95383d7e
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2012-
|
3
|
+
# Copyright (C) 2012-2014 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
|
@@ -32,7 +32,7 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
|
|
32
32
|
:name => "glib",
|
33
33
|
:download_site => :gnome,
|
34
34
|
:label => "GLib",
|
35
|
-
:version => "2.
|
35
|
+
:version => "2.42.0",
|
36
36
|
:compression_method => "xz",
|
37
37
|
:windows => {
|
38
38
|
:build => false,
|
@@ -47,7 +47,7 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
|
|
47
47
|
:name => "gobject-introspection",
|
48
48
|
:download_site => :gnome,
|
49
49
|
:label => "gobject-introspection",
|
50
|
-
:version => "1.
|
50
|
+
:version => "1.42.0",
|
51
51
|
:compression_method => "xz",
|
52
52
|
:windows => {
|
53
53
|
:configure_args => [
|
@@ -55,7 +55,7 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
|
|
55
55
|
"--disable-tests",
|
56
56
|
],
|
57
57
|
:patches => [
|
58
|
-
"
|
58
|
+
"support-external-g-ir-scanner.diff",
|
59
59
|
],
|
60
60
|
:need_autoreconf => true,
|
61
61
|
:built_file => "bin/libgirepository-1.0-1.dll",
|
@@ -104,7 +104,7 @@ namespace :win32 do
|
|
104
104
|
original_pc.each_line do |line|
|
105
105
|
case line
|
106
106
|
when /\Ag_ir_(scanner|compiler)=/
|
107
|
-
new_pc << line.gsub(/\${bindir}/, "${native_bindir}")
|
107
|
+
new_pc << line.gsub(/\${bindir}/, "${native_bindir}").gsub(/\.exe/, "")
|
108
108
|
else
|
109
109
|
new_pc << line
|
110
110
|
end
|
@@ -953,7 +953,9 @@ rb_gi_argument_from_ruby_interface(GIArgument *argument, GITypeInfo *type_info,
|
|
953
953
|
g_base_info_get_name(interface_info));
|
954
954
|
break;
|
955
955
|
case GI_INFO_TYPE_STRUCT:
|
956
|
-
if (gtype ==
|
956
|
+
if (gtype == G_TYPE_NONE) {
|
957
|
+
argument->v_pointer = DATA_PTR(rb_argument);
|
958
|
+
} else if (gtype == G_TYPE_VALUE) {
|
957
959
|
GValue *gvalue;
|
958
960
|
gvalue = ALLOC(GValue);
|
959
961
|
memset(gvalue, 0, sizeof(GValue));
|
@@ -1419,6 +1421,22 @@ set_in_array_length_argument(GIArgument *argument,
|
|
1419
1421
|
}
|
1420
1422
|
}
|
1421
1423
|
|
1424
|
+
static void
|
1425
|
+
set_in_array_gtype_arguments_from_ruby(GIArgument *array_argument,
|
1426
|
+
VALUE rb_class_array)
|
1427
|
+
{
|
1428
|
+
GType *types;
|
1429
|
+
gint i, n_args;
|
1430
|
+
|
1431
|
+
n_args = RARRAY_LEN(rb_class_array);
|
1432
|
+
types = ALLOC_N(GType, n_args);
|
1433
|
+
for (i = 0; i < n_args; i++) {
|
1434
|
+
types[i] = CLASS2GTYPE(RARRAY_PTR(rb_class_array)[i]);
|
1435
|
+
}
|
1436
|
+
|
1437
|
+
array_argument->v_pointer = types;
|
1438
|
+
}
|
1439
|
+
|
1422
1440
|
static void
|
1423
1441
|
in_array_c_argument_from_ruby(GIArgument *array_argument,
|
1424
1442
|
GIArgument *length_argument,
|
@@ -1451,11 +1469,16 @@ in_array_c_argument_from_ruby(GIArgument *array_argument,
|
|
1451
1469
|
case GI_TYPE_TAG_UINT64:
|
1452
1470
|
case GI_TYPE_TAG_FLOAT:
|
1453
1471
|
case GI_TYPE_TAG_DOUBLE:
|
1454
|
-
case GI_TYPE_TAG_GTYPE:
|
1455
1472
|
rb_raise(rb_eNotImpError,
|
1456
1473
|
"TODO: Ruby -> GIArgument(array)[%s]",
|
1457
1474
|
g_type_tag_to_string(element_type_tag));
|
1458
1475
|
break;
|
1476
|
+
case GI_TYPE_TAG_GTYPE:
|
1477
|
+
set_in_array_gtype_arguments_from_ruby(array_argument,
|
1478
|
+
rb_argument);
|
1479
|
+
set_in_array_length_argument(length_argument, length_type_info,
|
1480
|
+
RARRAY_LEN(rb_argument));
|
1481
|
+
break;
|
1459
1482
|
case GI_TYPE_TAG_UTF8:
|
1460
1483
|
case GI_TYPE_TAG_FILENAME:
|
1461
1484
|
array_argument->v_pointer = RVAL2STRV(rb_argument);
|
@@ -1685,11 +1708,13 @@ rb_gi_value_argument_free_array_c(GIArgument *argument,
|
|
1685
1708
|
case GI_TYPE_TAG_UINT64:
|
1686
1709
|
case GI_TYPE_TAG_FLOAT:
|
1687
1710
|
case GI_TYPE_TAG_DOUBLE:
|
1688
|
-
case GI_TYPE_TAG_GTYPE:
|
1689
1711
|
rb_raise(rb_eNotImpError,
|
1690
1712
|
"TODO: free GIArgument(array)[%s]",
|
1691
1713
|
g_type_tag_to_string(element_type_tag));
|
1692
1714
|
break;
|
1715
|
+
case GI_TYPE_TAG_GTYPE:
|
1716
|
+
xfree(argument->v_pointer);
|
1717
|
+
break;
|
1693
1718
|
case GI_TYPE_TAG_UTF8:
|
1694
1719
|
case GI_TYPE_TAG_FILENAME:
|
1695
1720
|
g_free(argument->v_pointer);
|
@@ -65,7 +65,12 @@ initialize_receiver(VALUE receiver, GITypeInfo *info, GIArgument *value)
|
|
65
65
|
case GI_INFO_TYPE_INTERFACE:
|
66
66
|
case GI_INFO_TYPE_CONSTANT:
|
67
67
|
case GI_INFO_TYPE_INVALID_0:
|
68
|
+
rb_raise(rb_eRuntimeError,
|
69
|
+
"TODO: returned value isn't object, struct or union");
|
70
|
+
break;
|
68
71
|
case GI_INFO_TYPE_UNION:
|
72
|
+
G_INITIALIZE(receiver, value->v_pointer);
|
73
|
+
break;
|
69
74
|
case GI_INFO_TYPE_VALUE:
|
70
75
|
case GI_INFO_TYPE_SIGNAL:
|
71
76
|
case GI_INFO_TYPE_VFUNC:
|
@@ -76,7 +81,7 @@ initialize_receiver(VALUE receiver, GITypeInfo *info, GIArgument *value)
|
|
76
81
|
case GI_INFO_TYPE_UNRESOLVED:
|
77
82
|
default:
|
78
83
|
rb_raise(rb_eRuntimeError,
|
79
|
-
"TODO: returned value isn't object or
|
84
|
+
"TODO: returned value isn't object, struct or union");
|
80
85
|
break;
|
81
86
|
}
|
82
87
|
}
|
@@ -93,7 +93,6 @@ allocate_arguments(GICallableInfo *info,
|
|
93
93
|
GPtrArray *args_metadata)
|
94
94
|
{
|
95
95
|
gint i, n_args;
|
96
|
-
gint rb_arg_index = 0;
|
97
96
|
|
98
97
|
n_args = g_callable_info_get_n_args(info);
|
99
98
|
for (i = 0; i < n_args; i++) {
|
@@ -127,7 +126,6 @@ allocate_arguments(GICallableInfo *info,
|
|
127
126
|
if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) {
|
128
127
|
metadata->in_arg_index = in_args->len;
|
129
128
|
g_array_append_val(in_args, argument);
|
130
|
-
metadata->rb_arg_index = rb_arg_index++;
|
131
129
|
}
|
132
130
|
if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) {
|
133
131
|
metadata->out_arg_index = out_args->len;
|
@@ -161,7 +159,6 @@ fill_metadata_callback(GPtrArray *args_metadata)
|
|
161
159
|
closure_metadata = g_ptr_array_index(args_metadata, closure_index);
|
162
160
|
closure_metadata->closure_p = TRUE;
|
163
161
|
metadata->closure_in_arg_index = closure_metadata->in_arg_index;
|
164
|
-
closure_metadata->rb_arg_index = -1;
|
165
162
|
}
|
166
163
|
|
167
164
|
destroy_index = g_arg_info_get_destroy(arg_info);
|
@@ -170,7 +167,6 @@ fill_metadata_callback(GPtrArray *args_metadata)
|
|
170
167
|
destroy_metadata = g_ptr_array_index(args_metadata, destroy_index);
|
171
168
|
destroy_metadata->destroy_p = TRUE;
|
172
169
|
metadata->destroy_in_arg_index = destroy_metadata->in_arg_index;
|
173
|
-
destroy_metadata->rb_arg_index = -1;
|
174
170
|
}
|
175
171
|
}
|
176
172
|
}
|
@@ -213,11 +209,40 @@ fill_metadata_array(GPtrArray *args_metadata)
|
|
213
209
|
}
|
214
210
|
}
|
215
211
|
|
212
|
+
static void
|
213
|
+
fill_metadata_rb_arg_index(GPtrArray *args_metadata)
|
214
|
+
{
|
215
|
+
guint i;
|
216
|
+
gint rb_arg_index = 0;
|
217
|
+
|
218
|
+
for (i = 0; i < args_metadata->len; i++) {
|
219
|
+
RBGIArgMetadata *metadata;
|
220
|
+
|
221
|
+
metadata = g_ptr_array_index(args_metadata, i);
|
222
|
+
|
223
|
+
if (metadata->closure_p) {
|
224
|
+
continue;
|
225
|
+
}
|
226
|
+
|
227
|
+
if (metadata->destroy_p) {
|
228
|
+
continue;
|
229
|
+
}
|
230
|
+
|
231
|
+
if (metadata->array_length_p) {
|
232
|
+
continue;
|
233
|
+
}
|
234
|
+
|
235
|
+
metadata->rb_arg_index = rb_arg_index;
|
236
|
+
rb_arg_index++;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
216
240
|
static void
|
217
241
|
fill_metadata(GPtrArray *args_metadata)
|
218
242
|
{
|
219
243
|
fill_metadata_callback(args_metadata);
|
220
244
|
fill_metadata_array(args_metadata);
|
245
|
+
fill_metadata_rb_arg_index(args_metadata);
|
221
246
|
}
|
222
247
|
|
223
248
|
static void
|
@@ -27,18 +27,24 @@ static const gchar *boxed_class_converters_name = "@@boxed_class_converters";
|
|
27
27
|
static VALUE
|
28
28
|
rg_s_define_class(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
|
29
29
|
{
|
30
|
+
VALUE rb_class;
|
30
31
|
VALUE rb_gtype, rb_name, rb_module;
|
31
|
-
VALUE rb_options, rb_parent;
|
32
|
+
VALUE rb_options, rb_parent, rb_size;
|
32
33
|
GType gtype;
|
33
34
|
|
34
35
|
rb_scan_args(argc, argv, "31", &rb_gtype, &rb_name, &rb_module, &rb_options);
|
35
36
|
rbg_scan_options(rb_options,
|
36
37
|
"parent", &rb_parent,
|
38
|
+
"size", &rb_size,
|
37
39
|
NULL);
|
38
40
|
|
39
41
|
gtype = NUM2ULONG(rb_to_int(rb_gtype));
|
40
|
-
|
41
|
-
|
42
|
+
rb_class = G_DEF_CLASS_WITH_PARENT(gtype, RVAL2CSTR(rb_name),
|
43
|
+
rb_module, rb_parent);
|
44
|
+
if (!NIL_P(rb_size)) {
|
45
|
+
rb_iv_set(rb_class, "@size", rb_size);
|
46
|
+
}
|
47
|
+
return rb_class;
|
42
48
|
}
|
43
49
|
|
44
50
|
static VALUE
|
@@ -183,6 +189,15 @@ rg_s_register_boxed_class_converter(VALUE klass, VALUE rb_gtype)
|
|
183
189
|
return Qnil;
|
184
190
|
}
|
185
191
|
|
192
|
+
static VALUE
|
193
|
+
rg_s_register_constant_rename_map(G_GNUC_UNUSED VALUE klass,
|
194
|
+
VALUE rb_original,
|
195
|
+
VALUE rb_renamed)
|
196
|
+
{
|
197
|
+
G_RENAME_CONSTANT(RVAL2CSTR(rb_original), RVAL2CSTR(rb_renamed));
|
198
|
+
return Qnil;
|
199
|
+
}
|
200
|
+
|
186
201
|
static VALUE
|
187
202
|
rg_s_start_callback_dispatch_thread(G_GNUC_UNUSED VALUE klass)
|
188
203
|
{
|
@@ -204,5 +219,6 @@ rb_gi_loader_init(VALUE rb_mGI)
|
|
204
219
|
RG_DEF_SMETHOD(define_struct, -1);
|
205
220
|
RG_DEF_SMETHOD(define_error, -1);
|
206
221
|
RG_DEF_SMETHOD(register_boxed_class_converter, 1);
|
222
|
+
RG_DEF_SMETHOD(register_constant_rename_map, 2);
|
207
223
|
RG_DEF_SMETHOD(start_callback_dispatch_thread, 0);
|
208
224
|
}
|
@@ -55,28 +55,42 @@ rg_get_field(VALUE self, VALUE rb_n)
|
|
55
55
|
return GI_BASE_INFO2RVAL_WITH_UNREF(g_struct_info_get_field(info, n));
|
56
56
|
}
|
57
57
|
|
58
|
+
static gpointer
|
59
|
+
extract_raw_struct(VALUE rb_struct,
|
60
|
+
GIStructInfo *struct_info)
|
61
|
+
{
|
62
|
+
GType gtype;
|
63
|
+
gpointer raw_struct;
|
64
|
+
|
65
|
+
gtype = g_registered_type_info_get_g_type(struct_info);
|
66
|
+
if (gtype == G_TYPE_NONE && rb_respond_to(rb_struct, rb_intern("gtype"))) {
|
67
|
+
VALUE rb_gtype;
|
68
|
+
rb_gtype = rb_funcall(rb_struct, rb_intern("gtype"), 0);
|
69
|
+
gtype = NUM2ULONG(rb_funcall(rb_gtype, rb_intern("to_i"), 0));
|
70
|
+
}
|
71
|
+
if (gtype == G_TYPE_NONE) {
|
72
|
+
raw_struct = DATA_PTR(rb_struct);
|
73
|
+
} else {
|
74
|
+
raw_struct = RVAL2BOXED(rb_struct, gtype);
|
75
|
+
}
|
76
|
+
|
77
|
+
return raw_struct;
|
78
|
+
}
|
79
|
+
|
58
80
|
static VALUE
|
59
81
|
rg_get_field_value(VALUE self, VALUE rb_struct, VALUE rb_n)
|
60
82
|
{
|
61
83
|
GIStructInfo *info;
|
84
|
+
gpointer raw_struct;
|
62
85
|
gint n;
|
63
86
|
GIFieldInfo *field_info;
|
64
87
|
VALUE rb_value;
|
65
|
-
gpointer instance;
|
66
88
|
|
67
89
|
info = SELF(self);
|
90
|
+
raw_struct = extract_raw_struct(rb_struct, info);
|
68
91
|
n = NUM2INT(rb_n);
|
69
92
|
field_info = g_struct_info_get_field(info, n);
|
70
|
-
|
71
|
-
VALUE rb_gtype;
|
72
|
-
GType gtype;
|
73
|
-
rb_gtype = rb_funcall(rb_struct, rb_intern("gtype"), 0);
|
74
|
-
gtype = NUM2ULONG(rb_funcall(rb_gtype, rb_intern("to_i"), 0));
|
75
|
-
instance = RVAL2BOXED(rb_struct, gtype);
|
76
|
-
} else {
|
77
|
-
Data_Get_Struct(rb_struct, void, instance);
|
78
|
-
}
|
79
|
-
rb_value = rb_gi_field_info_get_field_raw(field_info, instance);
|
93
|
+
rb_value = rb_gi_field_info_get_field_raw(field_info, raw_struct);
|
80
94
|
g_base_info_unref(field_info);
|
81
95
|
|
82
96
|
return rb_value;
|
@@ -86,17 +100,15 @@ static VALUE
|
|
86
100
|
rg_set_field_value(VALUE self, VALUE rb_struct, VALUE rb_n, VALUE rb_value)
|
87
101
|
{
|
88
102
|
GIStructInfo *info;
|
103
|
+
gpointer raw_struct;
|
89
104
|
gint n;
|
90
105
|
GIFieldInfo *field_info;
|
91
|
-
GType gtype;
|
92
106
|
|
93
107
|
info = SELF(self);
|
108
|
+
raw_struct = extract_raw_struct(rb_struct, info);
|
94
109
|
n = NUM2INT(rb_n);
|
95
110
|
field_info = g_struct_info_get_field(info, n);
|
96
|
-
|
97
|
-
rb_gi_field_info_set_field_raw(field_info,
|
98
|
-
RVAL2BOXED(rb_struct, gtype),
|
99
|
-
rb_value);
|
111
|
+
rb_gi_field_info_set_field_raw(field_info, raw_struct, rb_value);
|
100
112
|
/* TODO: use rb_ensure() to unref field_info. */
|
101
113
|
g_base_info_unref(field_info);
|
102
114
|
|
@@ -23,22 +23,31 @@ module GObjectIntrospection
|
|
23
23
|
collection_reader("args")
|
24
24
|
|
25
25
|
def in_args
|
26
|
+
array_length_indexes = []
|
26
27
|
callback_indexes = []
|
27
28
|
closure_indexes = []
|
28
29
|
destroy_indexes = []
|
29
30
|
args.each_with_index do |arg, i|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
if arg.type.tag == TypeTag::ARRAY
|
32
|
+
array_length = arg.type.array_length
|
33
|
+
array_length_indexes << array_length if array_length != -1
|
34
|
+
end
|
35
|
+
|
36
|
+
unless arg.scope == ScopeType::INVALID
|
37
|
+
callback_indexes << i
|
38
|
+
closure_index = arg.closure
|
39
|
+
closure_indexes << closure_index if closure_index != -1
|
40
|
+
destroy_index = arg.destroy
|
41
|
+
destroy_indexes << destroy_index if destroy_index != -1
|
42
|
+
end
|
36
43
|
end
|
37
44
|
|
38
45
|
args.find_all.with_index do |arg, i|
|
39
46
|
case arg.direction
|
40
47
|
when Direction::IN, Direction::INOUT
|
41
|
-
if
|
48
|
+
if array_length_indexes.include?(i)
|
49
|
+
false
|
50
|
+
elsif callback_indexes.include?(i)
|
42
51
|
false
|
43
52
|
elsif closure_indexes.include?(i)
|
44
53
|
false
|
@@ -120,7 +120,8 @@ module GObjectIntrospection
|
|
120
120
|
:parent => options[:parent])
|
121
121
|
else
|
122
122
|
klass = self.class.define_class(info.gtype, info.name, @base_module,
|
123
|
-
:parent => options[:parent]
|
123
|
+
:parent => options[:parent],
|
124
|
+
:size => info.size)
|
124
125
|
end
|
125
126
|
load_fields(info, klass)
|
126
127
|
load_methods(info, klass)
|
@@ -134,6 +135,7 @@ module GObjectIntrospection
|
|
134
135
|
|
135
136
|
def define_boxed(info)
|
136
137
|
klass = self.class.define_class(info.gtype, info.name, @base_module)
|
138
|
+
_ = klass # TODO: Remove me. It is just for suppressing a warning.
|
137
139
|
# TODO
|
138
140
|
# load_fields(info, klass)
|
139
141
|
# load_methods(info, klass)
|
@@ -223,7 +225,12 @@ module GObjectIntrospection
|
|
223
225
|
flags = field_info.flags
|
224
226
|
|
225
227
|
if flags.readable?
|
226
|
-
|
228
|
+
if field_info.type.tag == TypeTag::BOOLEAN
|
229
|
+
reader_method_name = "#{name}?"
|
230
|
+
else
|
231
|
+
reader_method_name = name
|
232
|
+
end
|
233
|
+
klass.__send__(:define_method, reader_method_name) do ||
|
227
234
|
info.get_field_value(self, i)
|
228
235
|
end
|
229
236
|
end
|
@@ -291,9 +298,9 @@ module GObjectIntrospection
|
|
291
298
|
|
292
299
|
detail = "#{arguments.size} for "
|
293
300
|
if n_in_args == n_required_in_args
|
294
|
-
detail << "#{
|
301
|
+
detail << "#{n_in_args}"
|
295
302
|
else
|
296
|
-
detail << "#{
|
303
|
+
detail << "#{n_required_in_args}..#{n_in_args}"
|
297
304
|
end
|
298
305
|
message = "#{method_name}: wrong number of arguments (#{detail})"
|
299
306
|
raise ArgumentError, message
|
@@ -304,11 +311,12 @@ module GObjectIntrospection
|
|
304
311
|
max_n_args = nil
|
305
312
|
candidate_infos = []
|
306
313
|
infos.each do |info|
|
307
|
-
|
314
|
+
n_in_args = info.n_in_args
|
315
|
+
n_required_in_args = info.n_required_in_args
|
316
|
+
if (n_required_in_args..n_in_args).cover?(arguments.size)
|
308
317
|
candidate_infos << info
|
309
318
|
end
|
310
|
-
|
311
|
-
min_n_args = [min_n_args || n_in_args, n_in_args].min
|
319
|
+
min_n_args = [min_n_args || n_required_in_args, n_required_in_args].min
|
312
320
|
max_n_args = [max_n_args || n_in_args, n_in_args].max
|
313
321
|
end
|
314
322
|
|
@@ -316,8 +324,9 @@ module GObjectIntrospection
|
|
316
324
|
return candidate_infos.first
|
317
325
|
elsif candidate_infos.size > 1
|
318
326
|
candidate_info = candidate_infos.find do |info|
|
319
|
-
info.in_args
|
320
|
-
|
327
|
+
in_arg_infos = info.in_args
|
328
|
+
arguments.each.with_index.all? do |argument, i|
|
329
|
+
match_argument?(in_arg_infos[i], argument)
|
321
330
|
end
|
322
331
|
end
|
323
332
|
return candidate_info || candidate_infos.first
|
@@ -374,29 +383,48 @@ module GObjectIntrospection
|
|
374
383
|
infos.each do |info|
|
375
384
|
method_name = rubyish_method_name(info)
|
376
385
|
load_method_info(info, klass, method_name)
|
377
|
-
if /\Aset_/ =~ method_name and info.n_args == 1
|
378
|
-
klass.__send__(:alias_method, "#{$POSTMATCH}=", method_name)
|
379
|
-
end
|
380
386
|
end
|
381
387
|
end
|
382
388
|
|
383
389
|
def load_method_info(info, klass, method_name)
|
390
|
+
define_method(info, klass, method_name)
|
391
|
+
define_equal_style_setter(info, klass, method_name)
|
392
|
+
end
|
393
|
+
|
394
|
+
def define_method(info, klass, method_name)
|
384
395
|
unlock_gvl = should_unlock_gvl?(info, klass)
|
385
396
|
validate = lambda do |arguments|
|
386
397
|
validate_arguments(info, "#{klass}\##{method_name}", arguments)
|
387
398
|
end
|
399
|
+
if klass.method_defined?(method_name) and
|
400
|
+
klass.instance_method(method_name).owner == klass
|
401
|
+
klass.__send__(:remove_method, method_name)
|
402
|
+
end
|
403
|
+
function_info_p = (info.class == FunctionInfo)
|
388
404
|
klass.__send__(:define_method, method_name) do |*arguments, &block|
|
405
|
+
arguments = [self] + arguments if function_info_p
|
389
406
|
validate.call(arguments, &block)
|
390
407
|
if block.nil? and info.require_callback?
|
391
|
-
|
408
|
+
to_enum(method_name, *arguments)
|
392
409
|
else
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
410
|
+
options = {
|
411
|
+
:arguments => arguments,
|
412
|
+
:unlock_gvl => unlock_gvl,
|
413
|
+
}
|
414
|
+
options[:receiver] = self unless function_info_p
|
415
|
+
info.invoke(options, &block)
|
416
|
+
end
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
def define_equal_style_setter(info, klass, method_name)
|
421
|
+
if /\Aset_/ =~ method_name and info.n_args == 1
|
422
|
+
setter_method_name = "#{$POSTMATCH}="
|
423
|
+
if klass.method_defined?(setter_method_name) and
|
424
|
+
klass.instance_method(setter_method_name).owner == klass
|
425
|
+
klass.__send__(:remove_method, setter_method_name)
|
399
426
|
end
|
427
|
+
klass.__send__(:alias_method, setter_method_name, method_name)
|
400
428
|
end
|
401
429
|
end
|
402
430
|
|
data/test/test-object-info.rb
CHANGED
data/test/test-signal-info.rb
CHANGED
data/test/test-struct-info.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gobject-introspection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Ruby-GNOME2 Project Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glib2
|
@@ -16,26 +16,26 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.2.
|
19
|
+
version: 2.2.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.2.
|
26
|
+
version: 2.2.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: test-unit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2'
|
41
41
|
description: Ruby/GObjectIntrospection is a Ruby binding of GObjectIntrospection.
|
@@ -46,17 +46,6 @@ extensions:
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- Rakefile
|
49
|
-
- extconf.rb
|
50
|
-
- lib/gobject-introspection.rb
|
51
|
-
- lib/gobject-introspection/boxed-info.rb
|
52
|
-
- lib/gobject-introspection/callable-info.rb
|
53
|
-
- lib/gobject-introspection/collection-reader.rb
|
54
|
-
- lib/gobject-introspection/interface-info.rb
|
55
|
-
- lib/gobject-introspection/loader.rb
|
56
|
-
- lib/gobject-introspection/object-info.rb
|
57
|
-
- lib/gobject-introspection/repository.rb
|
58
|
-
- lib/gobject-introspection/struct-info.rb
|
59
|
-
- lib/gobject-introspection/union-info.rb
|
60
49
|
- ext/gobject-introspection/depend
|
61
50
|
- ext/gobject-introspection/extconf.rb
|
62
51
|
- ext/gobject-introspection/gobject_introspection.def
|
@@ -92,6 +81,17 @@ files:
|
|
92
81
|
- ext/gobject-introspection/rb-gi-vfunc-info.c
|
93
82
|
- ext/gobject-introspection/rb-gobject-introspection.c
|
94
83
|
- ext/gobject-introspection/rb-gobject-introspection.h
|
84
|
+
- extconf.rb
|
85
|
+
- lib/gobject-introspection.rb
|
86
|
+
- lib/gobject-introspection/boxed-info.rb
|
87
|
+
- lib/gobject-introspection/callable-info.rb
|
88
|
+
- lib/gobject-introspection/collection-reader.rb
|
89
|
+
- lib/gobject-introspection/interface-info.rb
|
90
|
+
- lib/gobject-introspection/loader.rb
|
91
|
+
- lib/gobject-introspection/object-info.rb
|
92
|
+
- lib/gobject-introspection/repository.rb
|
93
|
+
- lib/gobject-introspection/struct-info.rb
|
94
|
+
- lib/gobject-introspection/union-info.rb
|
95
95
|
- test/gobject-introspection-test-utils.rb
|
96
96
|
- test/run-test.rb
|
97
97
|
- test/test-arg-info.rb
|
@@ -127,17 +127,17 @@ require_paths:
|
|
127
127
|
- lib
|
128
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- -
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: 1.9.3
|
133
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
|
-
- -
|
135
|
+
- - ">="
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.2.2
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Ruby/GObjectIntrospection is a Ruby binding of GObjectIntrospection.
|