gobject-introspection 2.2.5-x64-mingw32 → 3.0.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -3
- data/ext/gobject-introspection/extconf.rb +1 -1
- data/ext/gobject-introspection/rb-gi-argument.c +2275 -708
- data/ext/gobject-introspection/rb-gi-constant-info.c +1 -1
- data/ext/gobject-introspection/rb-gi-constructor-info.c +2 -2
- data/ext/gobject-introspection/rb-gi-conversions.h +40 -36
- data/ext/gobject-introspection/rb-gi-field-info.c +32 -6
- data/ext/gobject-introspection/rb-gi-function-info.c +98 -63
- data/ext/gobject-introspection/rb-gi-loader.c +33 -1
- data/ext/gobject-introspection/rb-gi-method-info.c +3 -6
- data/ext/gobject-introspection/rb-gi-private.h +2 -1
- data/ext/gobject-introspection/rb-gi-repository.c +29 -29
- data/lib/2.0/gobject_introspection.so +0 -0
- data/lib/2.1/gobject_introspection.so +0 -0
- data/lib/2.2/gobject_introspection.so +0 -0
- data/lib/gobject-introspection.rb +1 -0
- data/lib/gobject-introspection/arg-info.rb +27 -0
- data/lib/gobject-introspection/callable-info.rb +3 -1
- data/lib/gobject-introspection/loader.rb +160 -31
- data/vendor/local/bin/g-ir-compiler.exe +0 -0
- data/vendor/local/bin/g-ir-generate.exe +0 -0
- data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
- data/vendor/local/include/gobject-introspection-1.0/girepository.h +4 -0
- data/vendor/local/include/gobject-introspection-1.0/giversionmacros.h +15 -1
- data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +6 -1
- data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ast.py +3 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +19 -1
- data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +7 -3
- data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +1 -1
- data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +8 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
- data/vendor/local/lib/libgirepository-1.0.a +0 -0
- data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
- data/vendor/local/lib/libgirepository-1.0.la +3 -3
- data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +1 -1
- data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +1 -1
- data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +44 -7
- data/vendor/local/share/gir-1.0/GLib-2.0.gir +518 -131
- data/vendor/local/share/gir-1.0/GObject-2.0.gir +1248 -475
- data/vendor/local/share/gir-1.0/Gio-2.0.gir +1849 -80
- data/vendor/local/share/gobject-introspection-1.0/tests/annotation.c +1 -1
- data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +19 -16
- data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.h +1 -1
- data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +3 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +2 -2
- data/vendor/local/share/man/man1/g-ir-compiler.1 +1 -2
- data/vendor/local/share/man/man1/g-ir-generate.1 +2 -3
- metadata +5 -4
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2012-
|
3
|
+
* Copyright (C) 2012-2015 Ruby-GNOME2 Project Team
|
4
4
|
*
|
5
5
|
* This library is free software; you can redistribute it and/or
|
6
6
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -205,6 +205,37 @@ rg_s_start_callback_dispatch_thread(G_GNUC_UNUSED VALUE klass)
|
|
205
205
|
return Qnil;
|
206
206
|
}
|
207
207
|
|
208
|
+
static VALUE
|
209
|
+
rg_s_reference_gobject(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
|
210
|
+
{
|
211
|
+
VALUE rb_gobject;
|
212
|
+
VALUE rb_options, rb_sink;
|
213
|
+
gpointer gobject;
|
214
|
+
gboolean sink;
|
215
|
+
|
216
|
+
rb_scan_args(argc, argv, "11",
|
217
|
+
&rb_gobject, &rb_options);
|
218
|
+
rbg_scan_options(rb_options,
|
219
|
+
"sink", &rb_sink,
|
220
|
+
NULL);
|
221
|
+
|
222
|
+
gobject = RVAL2GOBJ(rb_gobject);
|
223
|
+
|
224
|
+
if (NIL_P(rb_sink)) {
|
225
|
+
sink = FALSE;
|
226
|
+
} else {
|
227
|
+
sink = RVAL2CBOOL(rb_sink);
|
228
|
+
}
|
229
|
+
|
230
|
+
if (sink) {
|
231
|
+
g_object_ref_sink(gobject);
|
232
|
+
} else {
|
233
|
+
g_object_ref(gobject);
|
234
|
+
}
|
235
|
+
|
236
|
+
return Qnil;
|
237
|
+
}
|
238
|
+
|
208
239
|
void
|
209
240
|
rb_gi_loader_init(VALUE rb_mGI)
|
210
241
|
{
|
@@ -221,4 +252,5 @@ rb_gi_loader_init(VALUE rb_mGI)
|
|
221
252
|
RG_DEF_SMETHOD(register_boxed_class_converter, 1);
|
222
253
|
RG_DEF_SMETHOD(register_constant_rename_map, 2);
|
223
254
|
RG_DEF_SMETHOD(start_callback_dispatch_thread, 0);
|
255
|
+
RG_DEF_SMETHOD(reference_gobject, -1);
|
224
256
|
}
|
@@ -39,8 +39,6 @@ static VALUE
|
|
39
39
|
rg_invoke(VALUE self, VALUE rb_options)
|
40
40
|
{
|
41
41
|
GIFunctionInfo *info;
|
42
|
-
GICallableInfo *callable_info;
|
43
|
-
GIArgument return_value;
|
44
42
|
VALUE rb_out_args;
|
45
43
|
VALUE rb_return_value;
|
46
44
|
|
@@ -49,14 +47,13 @@ rg_invoke(VALUE self, VALUE rb_options)
|
|
49
47
|
/* TODO: use rb_protect */
|
50
48
|
rb_out_args = rb_gi_function_info_invoke_raw(info,
|
51
49
|
rb_options,
|
52
|
-
|
53
|
-
|
54
|
-
callable_info = (GICallableInfo *)info;
|
55
|
-
rb_return_value = GI_RETURN_ARGUMENT2RVAL(&return_value, callable_info);
|
50
|
+
NULL,
|
51
|
+
&rb_return_value);
|
56
52
|
|
57
53
|
if (NIL_P(rb_out_args)) {
|
58
54
|
return rb_return_value;
|
59
55
|
} else {
|
56
|
+
GICallableInfo *callable_info = (GICallableInfo *)info;
|
60
57
|
GITypeInfo return_value_info;
|
61
58
|
g_callable_info_load_return_type(callable_info, &return_value_info);
|
62
59
|
if (g_type_info_get_tag(&return_value_info) != GI_TYPE_TAG_VOID) {
|
@@ -94,7 +94,8 @@ void rb_gi_loader_init (VALUE rb_mGI);
|
|
94
94
|
|
95
95
|
VALUE rb_gi_function_info_invoke_raw (GIFunctionInfo *info,
|
96
96
|
VALUE rb_options,
|
97
|
-
GIArgument *return_value
|
97
|
+
GIArgument *return_value,
|
98
|
+
VALUE *rb_return_value);
|
98
99
|
|
99
100
|
VALUE rb_gi_field_info_get_field_raw (GIFieldInfo *info,
|
100
101
|
gpointer memory);
|
@@ -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-2015 Ruby-GNOME2 Project Team
|
4
4
|
*
|
5
5
|
* This library is free software; you can redistribute it and/or
|
6
6
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -51,7 +51,7 @@ rg_s_default(G_GNUC_UNUSED VALUE klass)
|
|
51
51
|
* loaded, this function will search for a ".typelib" file using the repository
|
52
52
|
* search path. In addition, a version of namespace may be specified. If version
|
53
53
|
* is not specified, the latest will be used.
|
54
|
-
*
|
54
|
+
*
|
55
55
|
* @param [String] namespace The namespace to load
|
56
56
|
* @param [String, nil] version An optional version
|
57
57
|
*/
|
@@ -68,12 +68,12 @@ rg_require(int argc, VALUE *argv, VALUE self)
|
|
68
68
|
namespace_ = RVAL2CSTR(rb_namespace);
|
69
69
|
version = RVAL2CSTR_ACCEPT_NIL(rb_version);
|
70
70
|
if (!NIL_P(rb_flags)) {
|
71
|
-
|
71
|
+
flags = RVAL2GI_REPOSITORY_LOAD_FLAGS(rb_flags);
|
72
72
|
}
|
73
73
|
|
74
74
|
g_irepository_require(SELF(self), namespace_, version, flags, &error);
|
75
75
|
if (error) {
|
76
|
-
|
76
|
+
RG_RAISE_ERROR(error);
|
77
77
|
}
|
78
78
|
|
79
79
|
return Qnil;
|
@@ -84,9 +84,9 @@ rg_require(int argc, VALUE *argv, VALUE self)
|
|
84
84
|
* Returned strings are of the form "namespace-version".
|
85
85
|
* Note: namespace must have already been loaded using a function such as
|
86
86
|
* GObjectIntrospection::Repository.require() before calling this method.
|
87
|
-
*
|
87
|
+
*
|
88
88
|
* @param [String] namespace The namespace to get the dependencies for.
|
89
|
-
*
|
89
|
+
*
|
90
90
|
* @return [Array<String>] The dependencies.
|
91
91
|
*/
|
92
92
|
static VALUE
|
@@ -112,7 +112,7 @@ rg_get_dependencies(VALUE self, VALUE rb_namespace)
|
|
112
112
|
|
113
113
|
|
114
114
|
/* Return the list of currently loaded namespaces.
|
115
|
-
*
|
115
|
+
*
|
116
116
|
* @return [Array<String>] The loaded namespaces.
|
117
117
|
*/
|
118
118
|
static VALUE
|
@@ -137,9 +137,9 @@ rg_loaded_namespaces(VALUE self)
|
|
137
137
|
|
138
138
|
/* This method returns the number of metadata entries in given namespace. The
|
139
139
|
* namespace must have already been loaded before calling this function.
|
140
|
-
*
|
140
|
+
*
|
141
141
|
* @param [String] namespace The namespace to fetch the entries from.
|
142
|
-
*
|
142
|
+
*
|
143
143
|
* @return [Integer] The number of metadata entries.
|
144
144
|
*/
|
145
145
|
static VALUE
|
@@ -159,10 +159,10 @@ rg_get_n_infos(VALUE self, VALUE rb_namespace)
|
|
159
159
|
* namespace must have already been loaded before calling this function. See
|
160
160
|
* GObjectIntrospection::Repository#get_n_infos() to find the maximum number
|
161
161
|
* of entries.
|
162
|
-
*
|
162
|
+
*
|
163
163
|
* @param [String] namespace The namespace to fetch the metadata entry from.
|
164
164
|
* @param [Fixnum] index The index of the entry.
|
165
|
-
*
|
165
|
+
*
|
166
166
|
* @return [GObjectIntrospection::BaseInfo] The metadata entry.
|
167
167
|
*/
|
168
168
|
static VALUE
|
@@ -185,20 +185,20 @@ rg_get_info(VALUE self, VALUE rb_namespace, VALUE rb_n)
|
|
185
185
|
* given, it is interpreted as a gtype and all loaded namespaces are searched
|
186
186
|
* for it. If two arguments are given the first is a particular namespace and
|
187
187
|
* the second the name of an entry to search for.
|
188
|
-
*
|
188
|
+
*
|
189
189
|
* @overload find(type)
|
190
190
|
*
|
191
191
|
* @param [String] type The type to search for.
|
192
|
-
*
|
192
|
+
*
|
193
193
|
* @return [GObjectIntrospection::BaseInfo] The metadata entry.
|
194
|
-
*
|
195
|
-
*
|
194
|
+
*
|
195
|
+
*
|
196
196
|
* @overload find(namespace, type)
|
197
|
-
*
|
197
|
+
*
|
198
198
|
* @param [String] namespace The namespace to search in.
|
199
|
-
*
|
199
|
+
*
|
200
200
|
* @param [String] type The type to search for.
|
201
|
-
*
|
201
|
+
*
|
202
202
|
* @return [GObjectIntrospection::BaseInfo] The metadata entry.
|
203
203
|
*/
|
204
204
|
|
@@ -208,19 +208,19 @@ rg_find(int argc, VALUE *argv, VALUE self)
|
|
208
208
|
GIBaseInfo *info;
|
209
209
|
|
210
210
|
if (argc == 1) {
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
211
|
+
VALUE rb_gtype;
|
212
|
+
GType gtype;
|
213
|
+
rb_gtype = argv[0];
|
214
|
+
gtype = NUM2UINT(rb_gtype);
|
215
|
+
info = g_irepository_find_by_gtype(SELF(self), gtype);
|
216
216
|
} else {
|
217
|
-
|
218
|
-
|
217
|
+
VALUE rb_namespace, rb_name;
|
218
|
+
const gchar *namespace_, *name;
|
219
219
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
220
|
+
rb_scan_args(argc, argv, "2", &rb_namespace, &rb_name);
|
221
|
+
namespace_ = RVAL2CSTR(rb_namespace);
|
222
|
+
name = RVAL2CSTR(rb_name);
|
223
|
+
info = g_irepository_find_by_name(SELF(self), namespace_, name);
|
224
224
|
}
|
225
225
|
|
226
226
|
return GI_BASE_INFO2RVAL(info);
|
Binary file
|
Binary file
|
Binary file
|
@@ -44,6 +44,7 @@ end
|
|
44
44
|
GLib::Log.set_log_domain(GObjectIntrospection::LOG_DOMAIN)
|
45
45
|
|
46
46
|
require "gobject-introspection/repository"
|
47
|
+
require "gobject-introspection/arg-info"
|
47
48
|
require "gobject-introspection/callable-info"
|
48
49
|
require "gobject-introspection/object-info"
|
49
50
|
require "gobject-introspection/interface-info"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Copyright (C) 2015 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module GObjectIntrospection
|
18
|
+
class ArgInfo
|
19
|
+
def gclosure?
|
20
|
+
type_info = type
|
21
|
+
return false if type_info.tag != TypeTag::INTERFACE
|
22
|
+
|
23
|
+
struct_info = type_info.interface
|
24
|
+
struct_info.gtype.name == "GClosure"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -78,7 +78,9 @@ module GObjectIntrospection
|
|
78
78
|
|
79
79
|
def require_callback?
|
80
80
|
args.any? do |arg|
|
81
|
-
arg.direction == Direction::IN and
|
81
|
+
arg.direction == Direction::IN and
|
82
|
+
arg.scope != ScopeType::INVALID and
|
83
|
+
!arg.may_be_null?
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-
|
1
|
+
# Copyright (C) 2012-2015 Ruby-GNOME2 Project Team
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -14,6 +14,8 @@
|
|
14
14
|
# License along with this library; if not, write to the Free Software
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
16
|
|
17
|
+
require "English"
|
18
|
+
|
17
19
|
module GObjectIntrospection
|
18
20
|
class Loader
|
19
21
|
class << self
|
@@ -72,18 +74,20 @@ module GObjectIntrospection
|
|
72
74
|
|
73
75
|
def load_function_info(info)
|
74
76
|
name = rubyish_method_name(info)
|
75
|
-
|
77
|
+
define_singleton_method(@base_module, name, info)
|
76
78
|
end
|
77
79
|
|
78
80
|
def define_module_function(target_module, name, function_info)
|
79
81
|
unlock_gvl = should_unlock_gvl?(function_info, target_module)
|
80
|
-
|
82
|
+
prepare = lambda do |arguments, &block|
|
83
|
+
arguments, block = build_arguments(function_info, arguments, &block)
|
81
84
|
method_name = "#{target_module}\#.#{name}"
|
82
85
|
validate_arguments(function_info, method_name, arguments)
|
86
|
+
[arguments, block]
|
83
87
|
end
|
84
88
|
target_module.module_eval do
|
85
89
|
define_method(name) do |*arguments, &block|
|
86
|
-
|
90
|
+
arguments, block = prepare.call(arguments, &block)
|
87
91
|
function_info.invoke({
|
88
92
|
:arguments => arguments,
|
89
93
|
:unlock_gvl => unlock_gvl,
|
@@ -96,14 +100,16 @@ module GObjectIntrospection
|
|
96
100
|
|
97
101
|
def define_singleton_method(klass, name, info)
|
98
102
|
unlock_gvl = should_unlock_gvl?(info, klass)
|
99
|
-
|
103
|
+
prepare = lambda do |arguments|
|
104
|
+
arguments, block = build_arguments(info, arguments, &block)
|
100
105
|
validate_arguments(info, "#{klass}.#{name}", arguments)
|
106
|
+
[arguments, block]
|
101
107
|
end
|
102
108
|
singleton_class = (class << klass; self; end)
|
103
109
|
singleton_class.__send__(:define_method, name) do |*arguments, &block|
|
104
|
-
|
110
|
+
arguments, block = prepare.call(arguments, &block)
|
105
111
|
if block.nil? and info.require_callback?
|
106
|
-
|
112
|
+
to_enum(name, *arguments)
|
107
113
|
else
|
108
114
|
info.invoke({
|
109
115
|
:arguments => arguments,
|
@@ -128,9 +134,21 @@ module GObjectIntrospection
|
|
128
134
|
end
|
129
135
|
|
130
136
|
def load_struct_info(info)
|
131
|
-
|
137
|
+
case info.name
|
138
|
+
when /Class\z/
|
139
|
+
base_class_name = $PREMATCH
|
140
|
+
method_infos = info.methods.find_all do |method_info|
|
141
|
+
method_info.is_a?(MethodInfo)
|
142
|
+
end
|
143
|
+
unless methods.empty?
|
144
|
+
base_class = @base_module.const_get(base_class_name)
|
145
|
+
load_method_infos(method_infos, base_class.singleton_class)
|
146
|
+
end
|
147
|
+
else
|
148
|
+
return if info.gtype_struct?
|
132
149
|
|
133
|
-
|
150
|
+
define_struct(info)
|
151
|
+
end
|
134
152
|
end
|
135
153
|
|
136
154
|
def define_boxed(info)
|
@@ -203,10 +221,14 @@ module GObjectIntrospection
|
|
203
221
|
end
|
204
222
|
@base_module.const_set(info.name, flags_module)
|
205
223
|
else
|
206
|
-
self.class.define_class(info.gtype, info
|
224
|
+
self.class.define_class(info.gtype, flags_class_name(info), @base_module)
|
207
225
|
end
|
208
226
|
end
|
209
227
|
|
228
|
+
def flags_class_name(info)
|
229
|
+
info.name
|
230
|
+
end
|
231
|
+
|
210
232
|
def load_object_info(info)
|
211
233
|
klass = self.class.define_class(info.gtype, info.name, @base_module)
|
212
234
|
load_fields(info, klass)
|
@@ -220,8 +242,12 @@ module GObjectIntrospection
|
|
220
242
|
end
|
221
243
|
end
|
222
244
|
|
245
|
+
def field_name(field_info, klass)
|
246
|
+
field_info.name
|
247
|
+
end
|
248
|
+
|
223
249
|
def load_field(info, i, field_info, klass)
|
224
|
-
name = field_info
|
250
|
+
name = field_name(field_info, klass)
|
225
251
|
flags = field_info.flags
|
226
252
|
|
227
253
|
if flags.readable?
|
@@ -230,6 +256,7 @@ module GObjectIntrospection
|
|
230
256
|
else
|
231
257
|
reader_method_name = name
|
232
258
|
end
|
259
|
+
remove_existing_method(klass, reader_method_name)
|
233
260
|
klass.__send__(:define_method, reader_method_name) do ||
|
234
261
|
info.get_field_value(self, i)
|
235
262
|
end
|
@@ -264,20 +291,26 @@ module GObjectIntrospection
|
|
264
291
|
def load_constructor_infos(infos, klass)
|
265
292
|
return if infos.empty?
|
266
293
|
|
267
|
-
|
294
|
+
prepare = lambda do |info, method_name, arguments, &block|
|
295
|
+
arguments, block = build_arguments(info, arguments, &block)
|
268
296
|
validate_arguments(info, "#{klass}\##{method_name}", arguments)
|
297
|
+
[arguments, block]
|
298
|
+
end
|
299
|
+
call_initialize_post = lambda do |object|
|
300
|
+
initialize_post(object)
|
269
301
|
end
|
270
302
|
infos.each do |info|
|
271
303
|
name = "initialize_#{info.name}"
|
272
304
|
unlock_gvl = should_unlock_gvl?(info, klass)
|
273
305
|
klass.__send__(:define_method, name) do |*arguments, &block|
|
274
|
-
|
306
|
+
arguments, block = prepare.call(info, name, arguments, &block)
|
275
307
|
info.invoke({
|
276
308
|
:receiver => self,
|
277
309
|
:arguments => arguments,
|
278
310
|
:unlock_gvl => unlock_gvl,
|
279
311
|
},
|
280
312
|
&block)
|
313
|
+
call_initialize_post.call(self)
|
281
314
|
end
|
282
315
|
klass.__send__(:private, name)
|
283
316
|
end
|
@@ -291,6 +324,18 @@ module GObjectIntrospection
|
|
291
324
|
end
|
292
325
|
end
|
293
326
|
|
327
|
+
def initialize_post(object)
|
328
|
+
end
|
329
|
+
|
330
|
+
def build_arguments(info, arguments, &block)
|
331
|
+
last_in_arg = info.in_args.last
|
332
|
+
if block and last_in_arg and last_in_arg.gclosure?
|
333
|
+
[arguments + [block], nil]
|
334
|
+
else
|
335
|
+
[arguments, block]
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
294
339
|
def validate_arguments(info, method_name, arguments)
|
295
340
|
n_in_args = info.n_in_args
|
296
341
|
n_required_in_args = info.n_required_in_args
|
@@ -340,40 +385,115 @@ module GObjectIntrospection
|
|
340
385
|
end
|
341
386
|
|
342
387
|
def match_argument?(arg_info, argument)
|
343
|
-
|
388
|
+
type = arg_info.type
|
389
|
+
case type.tag
|
390
|
+
when TypeTag::BOOLEAN
|
391
|
+
argument == true or argument == false
|
392
|
+
when TypeTag::INT8,
|
393
|
+
TypeTag::UINT8,
|
394
|
+
TypeTag::INT16,
|
395
|
+
TypeTag::UINT16,
|
396
|
+
TypeTag::INT32,
|
397
|
+
TypeTag::UINT32,
|
398
|
+
TypeTag::INT64,
|
399
|
+
TypeTag::UINT64,
|
400
|
+
TypeTag::FLOAT,
|
401
|
+
TypeTag::DOUBLE
|
402
|
+
argument.is_a?(Numeric)
|
403
|
+
when TypeTag::GTYPE
|
404
|
+
argument.is_a?(GLib::Type)
|
344
405
|
when TypeTag::UTF8
|
345
406
|
argument.is_a?(String)
|
407
|
+
when TypeTag::FILENAME
|
408
|
+
argument.is_a?(String)
|
409
|
+
when TypeTag::ARRAY
|
410
|
+
argument.is_a?(Array)
|
411
|
+
when TypeTag::INTERFACE
|
412
|
+
interface = type.interface
|
413
|
+
case interface.type
|
414
|
+
when InfoType::STRUCT
|
415
|
+
match_argument_interface_struct?(arg_info, interface, argument)
|
416
|
+
when InfoType::OBJECT,
|
417
|
+
InfoType::INTERFACE
|
418
|
+
argument.is_a?(interface.gtype.to_class)
|
419
|
+
else
|
420
|
+
# TODO
|
421
|
+
false
|
422
|
+
end
|
423
|
+
when TypeTag::GLIST,
|
424
|
+
TypeTag::GSLIST
|
425
|
+
argument.is_a?(Array)
|
346
426
|
else
|
347
427
|
# TODO
|
348
428
|
false
|
349
429
|
end
|
350
430
|
end
|
351
431
|
|
432
|
+
def match_argument_interface_struct?(arg_info, interface, argument)
|
433
|
+
gtype = interface.gtype
|
434
|
+
case gtype.name
|
435
|
+
when "void"
|
436
|
+
# TODO
|
437
|
+
false
|
438
|
+
when "CairoSurface"
|
439
|
+
if Object.const_defined?(:Cairo)
|
440
|
+
argument.is_a?(Cairo::Surface)
|
441
|
+
else
|
442
|
+
false
|
443
|
+
end
|
444
|
+
else
|
445
|
+
argument.is_a?(gtype.to_class)
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
352
449
|
def rubyish_method_name(function_info, options={})
|
353
450
|
name = function_info.name
|
354
451
|
if options[:prefix]
|
355
452
|
name = name.gsub(/\A#{Regexp.escape(options[:prefix])}/, "")
|
356
453
|
end
|
357
454
|
return_type = function_info.return_type
|
358
|
-
|
455
|
+
return_type_tag = return_type.tag
|
456
|
+
case return_type_tag
|
457
|
+
when TypeTag::BOOLEAN
|
359
458
|
case name
|
360
459
|
when /\A(?:is|get_is)_/
|
361
460
|
"#{$POSTMATCH}?"
|
362
461
|
when /\Aget_/
|
363
462
|
if function_info.n_in_args.zero?
|
364
|
-
|
463
|
+
if function_info.n_out_args.zero?
|
464
|
+
"#{$POSTMATCH}?"
|
465
|
+
else
|
466
|
+
$POSTMATCH
|
467
|
+
end
|
365
468
|
else
|
366
469
|
name
|
367
470
|
end
|
368
|
-
when /\A(?:has|use)_/
|
471
|
+
when /\A(?:has|use|can|in|.*_is)_/
|
369
472
|
"#{name}?"
|
473
|
+
when "exists"
|
474
|
+
"exist?"
|
475
|
+
else
|
476
|
+
name
|
477
|
+
end
|
478
|
+
when TypeTag::GLIST, TypeTag::GSLIST
|
479
|
+
case name
|
480
|
+
when /\A(?:list|get)_/
|
481
|
+
if function_info.n_in_args.zero?
|
482
|
+
$POSTMATCH
|
483
|
+
else
|
484
|
+
name
|
485
|
+
end
|
370
486
|
else
|
371
487
|
name
|
372
488
|
end
|
373
|
-
elsif /\Aget_/ =~ name and function_info.n_in_args.zero?
|
374
|
-
$POSTMATCH
|
375
489
|
else
|
376
490
|
case name
|
491
|
+
when /\Aget_/
|
492
|
+
if function_info.n_in_args.zero?
|
493
|
+
$POSTMATCH
|
494
|
+
else
|
495
|
+
name
|
496
|
+
end
|
377
497
|
when "to_string"
|
378
498
|
"to_s"
|
379
499
|
when "foreach"
|
@@ -400,19 +520,26 @@ module GObjectIntrospection
|
|
400
520
|
define_equal_style_setter(info, klass, method_name)
|
401
521
|
end
|
402
522
|
|
523
|
+
def remove_existing_method(klass, method_name)
|
524
|
+
return unless klass.method_defined?(method_name)
|
525
|
+
return unless klass.instance_method(method_name).owner == klass
|
526
|
+
klass.__send__(:remove_method, method_name)
|
527
|
+
end
|
528
|
+
|
403
529
|
def define_method(info, klass, method_name)
|
404
530
|
unlock_gvl = should_unlock_gvl?(info, klass)
|
405
|
-
|
531
|
+
remove_existing_method(klass, method_name)
|
532
|
+
function_info_p = (info.class == FunctionInfo)
|
533
|
+
no_return_value_p =
|
534
|
+
(info.return_type.tag == TypeTag::VOID and info.n_out_args.zero?)
|
535
|
+
prepare = lambda do |arguments, &block|
|
536
|
+
arguments, block = build_arguments(info, arguments, &block)
|
406
537
|
validate_arguments(info, "#{klass}\##{method_name}", arguments)
|
538
|
+
[arguments, block]
|
407
539
|
end
|
408
|
-
if klass.method_defined?(method_name) and
|
409
|
-
klass.instance_method(method_name).owner == klass
|
410
|
-
klass.__send__(:remove_method, method_name)
|
411
|
-
end
|
412
|
-
function_info_p = (info.class == FunctionInfo)
|
413
540
|
klass.__send__(:define_method, method_name) do |*arguments, &block|
|
414
541
|
arguments = [self] + arguments if function_info_p
|
415
|
-
|
542
|
+
arguments, block = prepare.call(arguments, &block)
|
416
543
|
if block.nil? and info.require_callback?
|
417
544
|
to_enum(method_name, *arguments)
|
418
545
|
else
|
@@ -421,7 +548,12 @@ module GObjectIntrospection
|
|
421
548
|
:unlock_gvl => unlock_gvl,
|
422
549
|
}
|
423
550
|
options[:receiver] = self unless function_info_p
|
424
|
-
info.invoke(options, &block)
|
551
|
+
return_value = info.invoke(options, &block)
|
552
|
+
if no_return_value_p
|
553
|
+
self
|
554
|
+
else
|
555
|
+
return_value
|
556
|
+
end
|
425
557
|
end
|
426
558
|
end
|
427
559
|
end
|
@@ -429,10 +561,7 @@ module GObjectIntrospection
|
|
429
561
|
def define_equal_style_setter(info, klass, method_name)
|
430
562
|
if /\Aset_/ =~ method_name and info.n_args == 1
|
431
563
|
setter_method_name = "#{$POSTMATCH}="
|
432
|
-
|
433
|
-
klass.instance_method(setter_method_name).owner == klass
|
434
|
-
klass.__send__(:remove_method, setter_method_name)
|
435
|
-
end
|
564
|
+
remove_existing_method(klass, setter_method_name)
|
436
565
|
klass.__send__(:alias_method, setter_method_name, method_name)
|
437
566
|
end
|
438
567
|
end
|