glib2 3.4.3 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/ext/glib2/extconf.rb +1 -5
- data/ext/glib2/glib-enum-types.c +1233 -0
- data/ext/glib2/glib-enum-types.h +154 -0
- data/ext/glib2/glib2.def +2 -0
- data/ext/glib2/rbglib-bytes.c +1 -5
- data/ext/glib2/rbglib-gc.c +98 -52
- data/ext/glib2/rbglib-variant-type.c +1 -5
- data/ext/glib2/rbglib-variant.c +6 -7
- data/ext/glib2/rbglib.c +68 -1
- data/ext/glib2/rbglib.h +13 -3
- data/ext/glib2/rbglib_bookmarkfile.c +1 -1
- data/ext/glib2/rbglib_datetime.c +1 -5
- data/ext/glib2/rbglib_error.c +39 -12
- data/ext/glib2/rbglib_fileutils.c +1 -17
- data/ext/glib2/rbglib_iochannel.c +4 -4
- data/ext/glib2/rbglib_keyfile.c +1 -35
- data/ext/glib2/rbglib_maincontext.c +6 -32
- data/ext/glib2/rbglib_mainloop.c +2 -17
- data/ext/glib2/rbglib_matchinfo.c +1 -5
- data/ext/glib2/rbglib_messages.c +4 -5
- data/ext/glib2/rbglib_pollfd.c +1 -25
- data/ext/glib2/rbglib_regex.c +1 -13
- data/ext/glib2/rbglib_source.c +1 -39
- data/ext/glib2/rbglib_spawn.c +5 -10
- data/ext/glib2/rbglib_spawnerror.c +2 -2
- data/ext/glib2/rbglib_threads.c +2 -15
- data/ext/glib2/rbglib_timezone.c +1 -5
- data/ext/glib2/rbglib_unichar.c +46 -5
- data/ext/glib2/rbglib_unicode.c +1 -18
- data/ext/glib2/rbglib_utils.c +1 -14
- data/ext/glib2/rbglib_win32.c +3 -7
- data/ext/glib2/rbgobj_binding.c +1 -7
- data/ext/glib2/rbgobj_boxed.c +1 -1
- data/ext/glib2/rbgobj_closure.c +22 -9
- data/ext/glib2/rbgobj_enums.c +3 -2
- data/ext/glib2/rbgobj_flags.c +1 -1
- data/ext/glib2/rbgobj_object.c +117 -106
- data/ext/glib2/rbgobj_param.c +3 -9
- data/ext/glib2/rbgobj_paramspecs.c +6 -24
- data/ext/glib2/rbgobj_signal.c +105 -93
- data/ext/glib2/rbgobj_strv.c +2 -2
- data/ext/glib2/rbgobj_type.c +58 -67
- data/ext/glib2/rbgobj_typeinterface.c +38 -2
- data/ext/glib2/rbgobj_value.c +23 -8
- data/ext/glib2/rbgobj_valuetypes.c +14 -62
- data/ext/glib2/rbgobject.c +4 -6
- data/ext/glib2/rbgobject.h +2 -27
- data/ext/glib2/rbgprivate.h +10 -6
- data/ext/glib2/rbgutil.h +3 -2
- data/ext/glib2/rbgutil_callback.c +30 -27
- data/lib/glib2/deprecated.rb +22 -1
- data/lib/glib2.rb +54 -3
- data/lib/mkmf-gnome.rb +7 -6
- data/test/glib-test-utils.rb +22 -3
- data/test/run-test.rb +49 -15
- data/test/test-binding.rb +1 -11
- data/test/test-bytes.rb +1 -5
- data/test/test-date-time.rb +1 -3
- data/test/{glib-test-init.rb → test-error.rb} +25 -3
- data/test/test-file-utils.rb +1 -32
- data/test/test-iochannel.rb +3 -5
- data/test/test-key-file.rb +5 -6
- data/test/test-match-info.rb +1 -5
- data/test/test-regex.rb +1 -5
- data/test/test-source.rb +1 -14
- data/test/test-spawn.rb +4 -1
- data/test/test-time-zone.rb +1 -5
- data/test/test-timeout.rb +2 -3
- data/test/test-unicode.rb +16 -12
- data/test/test-utils.rb +2 -8
- data/test/test-variant-type.rb +1 -3
- data/test/test-win32.rb +6 -6
- metadata +6 -5
- data/ext/glib2/rbgobj_valuearray.c +0 -100
data/ext/glib2/rbgobject.h
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C)
|
4
|
-
* Copyright (C) 2003,2006 Ruby-GNOME Project Team
|
3
|
+
* Copyright (C) 2003-2021 Ruby-GNOME Project Team
|
5
4
|
* Copyright (C) 2002,2003 Masahiro Sakai
|
6
5
|
*
|
7
6
|
* This library is free software; you can redistribute it and/or
|
@@ -206,6 +205,7 @@ extern void rbgobj_register_mark_func(GType gtype, RGMarkFunc mark);
|
|
206
205
|
extern void rbgobj_register_free_func(GType gtype, RGFreeFunc free);
|
207
206
|
extern VALUE rbgobj_cType;
|
208
207
|
extern VALUE rbgobj_gtype_new(GType gtype);
|
208
|
+
/* Deprecated. Use rbgobj_gtype_from_ruby() instead. */
|
209
209
|
extern GType rbgobj_gtype_get(VALUE obj);
|
210
210
|
|
211
211
|
/* rbgobj_signal.c */
|
@@ -292,31 +292,6 @@ extern VALUE rbgobj_enum_alloc_func(VALUE klass);
|
|
292
292
|
extern VALUE rbgobj_flags_alloc_func(VALUE klass);
|
293
293
|
|
294
294
|
|
295
|
-
/* rbglib_mainloop.c */
|
296
|
-
#if !GLIB_CHECK_VERSION(2,30,0)
|
297
|
-
#define G_TYPE_MAIN_LOOP (g_main_loop_get_type())
|
298
|
-
extern GType g_main_loop_get_type(void);
|
299
|
-
#endif
|
300
|
-
|
301
|
-
/* rbglib_maincontext.c */
|
302
|
-
#if !GLIB_CHECK_VERSION(2,30,0)
|
303
|
-
#define G_TYPE_MAIN_CONTEXT (g_main_context_get_type())
|
304
|
-
#define G_TYPE_SOURCE (g_source_get_type())
|
305
|
-
extern GType g_main_context_get_type(void);
|
306
|
-
extern GType g_source_get_type(void);
|
307
|
-
#endif
|
308
|
-
|
309
|
-
#if !GLIB_CHECK_VERSION(2, 36, 0)
|
310
|
-
#define G_TYPE_POLLFD (g_pollfd_get_type())
|
311
|
-
extern GType g_pollfd_get_type(void);
|
312
|
-
#endif
|
313
|
-
|
314
|
-
/* rbglib_keyfile.c */
|
315
|
-
#if !GLIB_CHECK_VERSION(2,31,2)
|
316
|
-
#define G_TYPE_KEY_FILE (g_key_file_get_type())
|
317
|
-
extern GType g_key_file_get_type(void);
|
318
|
-
#endif
|
319
|
-
|
320
295
|
/* rbgobj_convert.c */
|
321
296
|
typedef struct {
|
322
297
|
GType type;
|
data/ext/glib2/rbgprivate.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2007-
|
3
|
+
* Copyright (C) 2007-2021 Ruby-GNOME 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
|
@@ -21,12 +21,13 @@
|
|
21
21
|
#pragma once
|
22
22
|
|
23
23
|
/*
|
24
|
-
* CentOS 6: GLib 2.28
|
25
24
|
* CentOS 7: GLib 2.50
|
25
|
+
* CentOS 8: GLib 2.56
|
26
26
|
* Ubuntu 16.04: GLib 2.48
|
27
|
-
* Ubuntu 18.04: GLib 2.
|
27
|
+
* Ubuntu 18.04: GLib 2.56
|
28
|
+
* Ubuntu 20.04: GLib 2.64
|
28
29
|
*/
|
29
|
-
#define GLIB_VERSION_MIN_REQUIRED
|
30
|
+
#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_48
|
30
31
|
|
31
32
|
#include "rbgobject.h"
|
32
33
|
|
@@ -42,6 +43,10 @@
|
|
42
43
|
# define G_VALUE_INIT { 0, { { 0 } } }
|
43
44
|
#endif
|
44
45
|
|
46
|
+
#ifndef RUBY_TYPED_FROZEN_SHAREABLE
|
47
|
+
# define RUBY_TYPED_FROZEN_SHAREABLE 0
|
48
|
+
#endif
|
49
|
+
|
45
50
|
G_BEGIN_DECLS
|
46
51
|
|
47
52
|
typedef struct {
|
@@ -58,7 +63,7 @@ typedef struct {
|
|
58
63
|
GType type;
|
59
64
|
} boxed_holder;
|
60
65
|
|
61
|
-
G_GNUC_INTERNAL extern
|
66
|
+
G_GNUC_INTERNAL extern GPrivate rg_polling_key;
|
62
67
|
G_GNUC_INTERNAL extern rb_encoding *rbg_filename_encoding;
|
63
68
|
|
64
69
|
extern VALUE rbgobj_cEnum;
|
@@ -181,7 +186,6 @@ G_GNUC_INTERNAL void Init_gobject_gvalue(void);
|
|
181
186
|
G_GNUC_INTERNAL void Init_gobject_gvaluetypes(void);
|
182
187
|
G_GNUC_INTERNAL void Init_gobject_gboxed(void);
|
183
188
|
G_GNUC_INTERNAL void Init_gobject_gstrv(void);
|
184
|
-
G_GNUC_INTERNAL void Init_gobject_value_array(void);
|
185
189
|
G_GNUC_INTERNAL void Init_gobject_genumflags(void);
|
186
190
|
G_GNUC_INTERNAL void Init_gobject_genums(void);
|
187
191
|
G_GNUC_INTERNAL void Init_gobject_gflags(void);
|
data/ext/glib2/rbgutil.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011-
|
4
|
-
* Copyright (C) 2002,2003
|
3
|
+
* Copyright (C) 2011-2022 Ruby-GNOME Project Team
|
4
|
+
* Copyright (C) 2002,2003 Masao Mutoh
|
5
5
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
7
7
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -92,6 +92,7 @@ extern void rbg_define_singleton_method(VALUE obj, const char *name, VALUE (*fun
|
|
92
92
|
extern VALUE rbgutil_def_setters(VALUE klass);
|
93
93
|
extern void rbgutil_set_properties(VALUE self, VALUE hash);
|
94
94
|
extern VALUE rbgutil_protect(VALUE (*proc) (VALUE), VALUE data);
|
95
|
+
extern void rbgutil_on_callback_error(VALUE error);
|
95
96
|
extern VALUE rbgutil_invoke_callback(VALUE (*func)(VALUE), VALUE arg);
|
96
97
|
extern void rbgutil_start_callback_dispatch_thread(void);
|
97
98
|
extern void rbgutil_stop_callback_dispatch_thread(void);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2007-
|
3
|
+
* Copyright (C) 2007-2022 Ruby-GNOME 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
|
@@ -49,10 +49,16 @@ rbgutil_protect(VALUE (*func) (VALUE), VALUE data)
|
|
49
49
|
VALUE ret = rb_protect(func, data, &state);
|
50
50
|
VALUE e = rb_errinfo();
|
51
51
|
if (state && !NIL_P(e))
|
52
|
-
|
52
|
+
rbgutil_on_callback_error(e);
|
53
53
|
return ret;
|
54
54
|
}
|
55
55
|
|
56
|
+
void
|
57
|
+
rbgutil_on_callback_error(VALUE error)
|
58
|
+
{
|
59
|
+
rb_funcall(mGLib, id_exit_application, 2, error, INT2NUM(EXIT_FAILURE));
|
60
|
+
}
|
61
|
+
|
56
62
|
/**********************************************************************/
|
57
63
|
|
58
64
|
#ifdef HAVE_NATIVETHREAD
|
@@ -61,11 +67,11 @@ typedef struct _CallbackRequest {
|
|
61
67
|
VALUE (*function)(VALUE);
|
62
68
|
VALUE argument;
|
63
69
|
VALUE result;
|
64
|
-
GMutex
|
65
|
-
GCond
|
70
|
+
GMutex done_mutex;
|
71
|
+
GCond done_cond;
|
66
72
|
} CallbackRequest;
|
67
73
|
|
68
|
-
static GMutex
|
74
|
+
static GMutex callback_dispatch_thread_mutex;
|
69
75
|
static GAsyncQueue *callback_request_queue = NULL;
|
70
76
|
static ID id_callback_dispatch_thread;
|
71
77
|
static gint callback_pipe_fds[2] = {-1, -1};
|
@@ -84,10 +90,10 @@ static VALUE
|
|
84
90
|
process_request(void *user_data)
|
85
91
|
{
|
86
92
|
CallbackRequest *request = user_data;
|
87
|
-
g_mutex_lock(request->done_mutex);
|
93
|
+
g_mutex_lock(&(request->done_mutex));
|
88
94
|
request->result = rbgutil_protect(exec_callback, (VALUE)request);
|
89
|
-
g_cond_signal(request->done_cond);
|
90
|
-
g_mutex_unlock(request->done_mutex);
|
95
|
+
g_cond_signal(&(request->done_cond));
|
96
|
+
g_mutex_unlock(&(request->done_mutex));
|
91
97
|
|
92
98
|
return Qnil;
|
93
99
|
}
|
@@ -146,30 +152,30 @@ invoke_callback_in_ruby_thread(VALUE (*func)(VALUE), VALUE arg)
|
|
146
152
|
{
|
147
153
|
CallbackRequest request;
|
148
154
|
|
149
|
-
g_mutex_lock(callback_dispatch_thread_mutex);
|
155
|
+
g_mutex_lock(&callback_dispatch_thread_mutex);
|
150
156
|
if (callback_pipe_fds[0] == -1) {
|
151
157
|
g_error("Please call rbgutil_start_callback_dispatch_thread() "
|
152
158
|
"to dispatch a callback from non-ruby thread before "
|
153
159
|
"callbacks are requested from non-ruby thread.");
|
154
|
-
g_mutex_unlock(callback_dispatch_thread_mutex);
|
160
|
+
g_mutex_unlock(&callback_dispatch_thread_mutex);
|
155
161
|
return Qnil;
|
156
162
|
}
|
157
163
|
|
158
164
|
request.function = func;
|
159
165
|
request.argument = arg;
|
160
166
|
request.result = Qnil;
|
161
|
-
request.done_mutex
|
162
|
-
request.done_cond
|
167
|
+
g_mutex_init(&(request.done_mutex));
|
168
|
+
g_cond_init(&(request.done_cond));
|
163
169
|
|
164
|
-
g_mutex_lock(request.done_mutex);
|
170
|
+
g_mutex_lock(&(request.done_mutex));
|
165
171
|
queue_callback_request(&request);
|
166
|
-
g_mutex_unlock(callback_dispatch_thread_mutex);
|
172
|
+
g_mutex_unlock(&callback_dispatch_thread_mutex);
|
167
173
|
|
168
|
-
g_cond_wait(request.done_cond, request.done_mutex);
|
169
|
-
g_mutex_unlock(request.done_mutex);
|
174
|
+
g_cond_wait(&(request.done_cond), &(request.done_mutex));
|
175
|
+
g_mutex_unlock(&(request.done_mutex));
|
170
176
|
|
171
|
-
|
172
|
-
|
177
|
+
g_cond_clear(&(request.done_cond));
|
178
|
+
g_mutex_clear(&(request.done_mutex));
|
173
179
|
|
174
180
|
|
175
181
|
return request.result;
|
@@ -195,7 +201,7 @@ rbgutil_invoke_callback(VALUE (*func)(VALUE), VALUE arg)
|
|
195
201
|
{
|
196
202
|
#ifdef HAVE_NATIVETHREAD
|
197
203
|
if (ruby_native_thread_p()) {
|
198
|
-
if (!GPOINTER_TO_INT(
|
204
|
+
if (!GPOINTER_TO_INT(g_private_get(&rg_polling_key))) {
|
199
205
|
return rbgutil_protect(func, arg);
|
200
206
|
}
|
201
207
|
# ifdef HAVE_RB_THREAD_CALL_WITH_GVL
|
@@ -221,7 +227,7 @@ rbgutil_start_callback_dispatch_thread(void)
|
|
221
227
|
#ifdef HAVE_NATIVETHREAD
|
222
228
|
VALUE callback_dispatch_thread;
|
223
229
|
|
224
|
-
g_mutex_lock(callback_dispatch_thread_mutex);
|
230
|
+
g_mutex_lock(&callback_dispatch_thread_mutex);
|
225
231
|
callback_dispatch_thread = rb_ivar_get(mGLib, id_callback_dispatch_thread);
|
226
232
|
if (NIL_P(callback_dispatch_thread)) {
|
227
233
|
if (pipe(callback_pipe_fds) == -1)
|
@@ -231,7 +237,7 @@ rbgutil_start_callback_dispatch_thread(void)
|
|
231
237
|
rb_ivar_set(mGLib, id_callback_dispatch_thread,
|
232
238
|
callback_dispatch_thread);
|
233
239
|
}
|
234
|
-
g_mutex_unlock(callback_dispatch_thread_mutex);
|
240
|
+
g_mutex_unlock(&callback_dispatch_thread_mutex);
|
235
241
|
#endif
|
236
242
|
}
|
237
243
|
|
@@ -241,13 +247,13 @@ rbgutil_stop_callback_dispatch_thread(void)
|
|
241
247
|
#ifdef HAVE_NATIVETHREAD
|
242
248
|
VALUE callback_dispatch_thread;
|
243
249
|
|
244
|
-
g_mutex_lock(callback_dispatch_thread_mutex);
|
250
|
+
g_mutex_lock(&callback_dispatch_thread_mutex);
|
245
251
|
callback_dispatch_thread = rb_ivar_get(mGLib, id_callback_dispatch_thread);
|
246
252
|
if (!NIL_P(callback_dispatch_thread)) {
|
247
253
|
queue_callback_request(NULL);
|
248
254
|
rb_ivar_set(mGLib, id_callback_dispatch_thread, Qnil);
|
249
255
|
}
|
250
|
-
g_mutex_unlock(callback_dispatch_thread_mutex);
|
256
|
+
g_mutex_unlock(&callback_dispatch_thread_mutex);
|
251
257
|
#endif
|
252
258
|
}
|
253
259
|
|
@@ -260,13 +266,10 @@ Init_gutil_callback(void)
|
|
260
266
|
rb_eRuntimeError);
|
261
267
|
|
262
268
|
#ifdef HAVE_NATIVETHREAD
|
263
|
-
if (!g_thread_supported())
|
264
|
-
g_thread_init(NULL);
|
265
|
-
|
266
269
|
id_callback_dispatch_thread = rb_intern("callback_dispatch_thread");
|
267
270
|
rb_ivar_set(mGLib, id_callback_dispatch_thread, Qnil);
|
268
271
|
|
269
272
|
callback_request_queue = g_async_queue_new();
|
270
|
-
callback_dispatch_thread_mutex
|
273
|
+
g_mutex_init(&callback_dispatch_thread_mutex);
|
271
274
|
#endif
|
272
275
|
}
|
data/lib/glib2/deprecated.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2018-
|
1
|
+
# Copyright (C) 2018-2021 Ruby-GNOME 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
|
@@ -26,4 +26,25 @@ module GLib
|
|
26
26
|
define_deprecated_const(:PRIVATE, :STATIC_NAME)
|
27
27
|
define_deprecated_method(:private?, :static_name?)
|
28
28
|
end
|
29
|
+
|
30
|
+
class SpawnError
|
31
|
+
extend GLib::Deprecatable
|
32
|
+
define_deprecated_const(:E2BIG, :TOO_BIG)
|
33
|
+
end
|
34
|
+
|
35
|
+
module Unicode
|
36
|
+
extend GLib::Deprecatable
|
37
|
+
define_deprecated_singleton_method(
|
38
|
+
:canonical_decomposition,
|
39
|
+
warn: "Use 'GLib::UniChar.decompose(char)'.") do |_, char|
|
40
|
+
UniChar.decompose(char)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
extend GLib::Deprecatable
|
45
|
+
define_deprecated_singleton_method(
|
46
|
+
:format_size_for_display,
|
47
|
+
warn: "Use 'GLib.format_size(size, flags: :iec_units)'.") do |_, size|
|
48
|
+
format_size(size, flags: :iec_units)
|
49
|
+
end
|
29
50
|
end
|
data/lib/glib2.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2005-
|
1
|
+
# Copyright (C) 2005-2021 Ruby-GNOME 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
|
@@ -117,17 +117,68 @@ end
|
|
117
117
|
require "glib2.so"
|
118
118
|
|
119
119
|
module GLib
|
120
|
+
SIGNAL_HANDLER_PREFIX = "signal_do_"
|
121
|
+
VIRTUAL_FUNCTION_IMPLEMENTATION_PREFIX = "virtual_do_"
|
122
|
+
|
120
123
|
module MetaInterface
|
121
124
|
class << self
|
122
|
-
def signal_callback(klass,
|
125
|
+
def signal_callback(klass, name)
|
123
126
|
lambda do |instance, *args|
|
124
|
-
|
127
|
+
method_name = "#{SIGNAL_HANDLER_PREFIX}#{name}"
|
128
|
+
klass.instance_method(method_name).bind(instance).call(*args)
|
125
129
|
end
|
126
130
|
end
|
127
131
|
end
|
128
132
|
end
|
129
133
|
|
130
134
|
class Instantiatable
|
135
|
+
class << self
|
136
|
+
def method_added(name)
|
137
|
+
result = super
|
138
|
+
check_new_method(name)
|
139
|
+
result
|
140
|
+
end
|
141
|
+
|
142
|
+
def include(*modules, &block)
|
143
|
+
result = super
|
144
|
+
modules.each do |mod|
|
145
|
+
next if mod.is_a?(Interface)
|
146
|
+
mod.public_instance_methods(false).each do |name|
|
147
|
+
check_new_method(name)
|
148
|
+
end
|
149
|
+
mod.protected_instance_methods(false).each do |name|
|
150
|
+
check_new_method(name)
|
151
|
+
end
|
152
|
+
mod.private_instance_methods(false).each do |name|
|
153
|
+
check_new_method(name)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
result
|
157
|
+
end
|
158
|
+
|
159
|
+
private
|
160
|
+
def check_new_method(name)
|
161
|
+
case name.to_s
|
162
|
+
when /\A#{Regexp.escape(SIGNAL_HANDLER_PREFIX)}/o
|
163
|
+
signal_name = $POSTMATCH
|
164
|
+
begin
|
165
|
+
signal_ = signal(signal_name)
|
166
|
+
rescue NoSignalError
|
167
|
+
return
|
168
|
+
end
|
169
|
+
return unless signal_.class != self
|
170
|
+
signal_handler_attach(signal_, name.to_s) do |instance, *args|
|
171
|
+
instance.__send__(name, *args)
|
172
|
+
end
|
173
|
+
when /\A#{Regexp.escape(VIRTUAL_FUNCTION_IMPLEMENTATION_PREFIX)}/o
|
174
|
+
ancestors.each do |klass|
|
175
|
+
next unless klass.respond_to?(:implement_virtual_function)
|
176
|
+
return if klass.implement_virtual_function(self, name)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
131
182
|
private
|
132
183
|
def create_signal_handler(signal_name, callback)
|
133
184
|
callback
|
data/lib/mkmf-gnome.rb
CHANGED
@@ -37,11 +37,11 @@ end
|
|
37
37
|
def enable_debug_build_flag(flags)
|
38
38
|
if gcc?
|
39
39
|
expanded_flags = RbConfig.expand(flags.dup)
|
40
|
-
debug_option_pattern = /(^|\s)-g
|
40
|
+
debug_option_pattern = /(^|\s)-g(?:gdb)?\d?(\s|$)/
|
41
41
|
if debug_option_pattern =~ expanded_flags
|
42
|
-
expanded_flags.gsub(debug_option_pattern, '\\1-
|
42
|
+
expanded_flags.gsub(debug_option_pattern, '\\1-ggdb3\\2')
|
43
43
|
else
|
44
|
-
flags + " -
|
44
|
+
flags + " -ggdb3"
|
45
45
|
end
|
46
46
|
else
|
47
47
|
flags
|
@@ -72,9 +72,10 @@ def try_compiler_option(opt, &block)
|
|
72
72
|
end
|
73
73
|
|
74
74
|
try_compiler_option '-Wall'
|
75
|
-
|
75
|
+
# NOTE: This generates warnings for functions defined in ruby.h.
|
76
|
+
# try_compiler_option '-Waggregate-return'
|
76
77
|
try_compiler_option '-Wcast-align'
|
77
|
-
# NOTE:
|
78
|
+
# NOTE: This generates way too many false positives.
|
78
79
|
# try_compiler_option '-Wconversion'
|
79
80
|
try_compiler_option '-Wextra'
|
80
81
|
try_compiler_option '-Wformat=2'
|
@@ -198,7 +199,7 @@ def add_depend_package_path(target_name, target_source_dir, target_build_dir)
|
|
198
199
|
$INCFLAGS = "-I#{target_build_dir} #{$INCFLAGS}"
|
199
200
|
end
|
200
201
|
|
201
|
-
library_base_name =
|
202
|
+
library_base_name = File.basename(target_source_dir).gsub(/-/, "_")
|
202
203
|
case RUBY_PLATFORM
|
203
204
|
when /cygwin|mingw/
|
204
205
|
$libs << " " << File.join(target_build_dir, "#{library_base_name}.so")
|
data/test/glib-test-utils.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2015 Ruby-
|
1
|
+
# Copyright (C) 2015-2022 Ruby-GNOME 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,12 @@
|
|
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 "pathname"
|
18
|
+
|
19
|
+
require "test-unit"
|
20
|
+
|
21
|
+
require "glib2"
|
22
|
+
|
17
23
|
module GLibTestUtils
|
18
24
|
private
|
19
25
|
def only_glib_version(major, minor, micro)
|
@@ -22,7 +28,20 @@ module GLibTestUtils
|
|
22
28
|
end
|
23
29
|
end
|
24
30
|
|
25
|
-
def
|
26
|
-
omit("Only for
|
31
|
+
def only_windows
|
32
|
+
omit("Only for Windows platform") unless GLib.os_win32?
|
33
|
+
end
|
34
|
+
|
35
|
+
def only_not_windows
|
36
|
+
omit("Not for Windows platform") if GLib.os_win32?
|
37
|
+
end
|
38
|
+
|
39
|
+
def only_not_scl
|
40
|
+
omit("Not for SCL environment") if ENV["SCL"]
|
41
|
+
end
|
42
|
+
|
43
|
+
def normalize_path(path)
|
44
|
+
return path unless File::ALT_SEPARATOR
|
45
|
+
path.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
|
27
46
|
end
|
28
47
|
end
|
data/test/run-test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Copyright (C) 2015-
|
3
|
+
# Copyright (C) 2015-2021 Ruby-GNOME 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
|
@@ -16,23 +16,57 @@
|
|
16
16
|
# License along with this library; if not, write to the Free Software
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
|
-
|
20
|
-
source_dir = File.expand_path(File.join(test_dir, ".."))
|
21
|
-
build_dir = File.expand_path(".")
|
19
|
+
require "fileutils"
|
22
20
|
|
23
|
-
|
24
|
-
|
21
|
+
def run_test(test_dir, dependencies)
|
22
|
+
$VERBOSE = true
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
ruby_gnome_build_dir = ENV["RUBY_GNOME_BUILD_DIR"]
|
25
|
+
ruby_gnome_build_dir ||= File.expand_path("..")
|
26
|
+
ruby_gnome_source_dir = File.expand_path("../..", test_dir)
|
27
|
+
|
28
|
+
dependencies.each do |dependency|
|
29
|
+
source_dir = File.join(ruby_gnome_source_dir, dependency)
|
30
|
+
build_dir = File.join(ruby_gnome_build_dir, dependency)
|
31
|
+
makefile = File.join(build_dir, "Makefile")
|
32
|
+
if File.exist?(makefile)
|
33
|
+
system("make", "-C", build_dir, "-j", out: IO::NULL) or exit(false)
|
34
|
+
$LOAD_PATH.unshift(File.join(build_dir, "ext", dependency))
|
35
|
+
end
|
36
|
+
$LOAD_PATH.unshift(File.join(source_dir, "lib"))
|
37
|
+
end
|
29
38
|
|
30
|
-
|
31
|
-
|
39
|
+
source_fixture_dir = File.join(test_dir, "fixture")
|
40
|
+
if File.exist?(source_fixture_dir)
|
41
|
+
target_name = File.basename(File.expand_path("..", test_dir))
|
42
|
+
build_fixture_dir = File.join(ruby_gnome_build_dir,
|
43
|
+
target_name,
|
44
|
+
"test",
|
45
|
+
"fixture")
|
46
|
+
unless source_fixture_dir == build_fixture_dir
|
47
|
+
FileUtils.rm_rf(build_fixture_dir)
|
48
|
+
FileUtils.mkdir_p(File.dirname(build_fixture_dir))
|
49
|
+
FileUtils.cp_r(source_fixture_dir, build_fixture_dir)
|
50
|
+
end
|
51
|
+
Dir.chdir(build_fixture_dir) do
|
52
|
+
if File.exist?("Rakefile")
|
53
|
+
system("rake") or exit(false)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
32
57
|
|
33
|
-
|
34
|
-
require_relative "glib-test-utils"
|
58
|
+
require_relative "glib-test-utils"
|
35
59
|
|
36
|
-
|
60
|
+
if block_given?
|
61
|
+
context = {
|
62
|
+
build_fixture_dir: build_fixture_dir,
|
63
|
+
}
|
64
|
+
yield(context)
|
65
|
+
end
|
37
66
|
|
38
|
-
exit(Test::Unit::AutoRunner.run(true, test_dir))
|
67
|
+
exit(Test::Unit::AutoRunner.run(true, test_dir))
|
68
|
+
end
|
69
|
+
|
70
|
+
if $PROGRAM_NAME == __FILE__
|
71
|
+
run_test(__dir__, ["glib2"])
|
72
|
+
end
|
data/test/test-binding.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2015 Ruby-
|
1
|
+
# Copyright (C) 2015-2021 Ruby-GNOME 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
|
@@ -55,10 +55,6 @@ class TestGLibBinding < Test::Unit::TestCase
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
setup do
|
59
|
-
only_glib_version(2, 26, 0)
|
60
|
-
end
|
61
|
-
|
62
58
|
setup do
|
63
59
|
@source = DataObjectDefault.new
|
64
60
|
@target = DataObjectDefault.new
|
@@ -86,7 +82,6 @@ class TestGLibBinding < Test::Unit::TestCase
|
|
86
82
|
end
|
87
83
|
|
88
84
|
test "#unbind" do
|
89
|
-
only_glib_version(2, 38, 0)
|
90
85
|
assert_equal(0, @target.target)
|
91
86
|
@source.source = 10
|
92
87
|
assert_equal(10, @target.target)
|
@@ -132,10 +127,6 @@ class TestGLibBinding < Test::Unit::TestCase
|
|
132
127
|
end
|
133
128
|
end
|
134
129
|
|
135
|
-
setup do
|
136
|
-
only_glib_version(2, 26, 0)
|
137
|
-
end
|
138
|
-
|
139
130
|
setup do
|
140
131
|
@source = DataObjectBidir.new
|
141
132
|
@target = DataObjectBidir.new
|
@@ -174,7 +165,6 @@ class TestGLibBinding < Test::Unit::TestCase
|
|
174
165
|
end
|
175
166
|
|
176
167
|
test "#unbind" do
|
177
|
-
only_glib_version(2, 38, 0)
|
178
168
|
assert_equal("nan", @target.target)
|
179
169
|
@source.source = 10
|
180
170
|
assert_equal("10", @target.target)
|
data/test/test-bytes.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2017-
|
1
|
+
# Copyright (C) 2017-2021 Ruby-GNOME 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
|
@@ -17,10 +17,6 @@
|
|
17
17
|
class TestGLibBytes < Test::Unit::TestCase
|
18
18
|
include GLibTestUtils
|
19
19
|
|
20
|
-
setup do
|
21
|
-
only_glib_version(2, 32, 0)
|
22
|
-
end
|
23
|
-
|
24
20
|
sub_test_case ".try_convert" do
|
25
21
|
def test_nil
|
26
22
|
assert_nil(GLib::Bytes.try_convert(nil))
|
data/test/test-date-time.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2016-
|
1
|
+
# Copyright (C) 2016-2021 Ruby-GNOME 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
|
@@ -76,7 +76,6 @@ class TestDateTime < Test::Unit::TestCase
|
|
76
76
|
end
|
77
77
|
|
78
78
|
test "timezone: local time zone" do
|
79
|
-
only_glib_version(2, 34, 0)
|
80
79
|
time = Time.now
|
81
80
|
tz = GLib::TimeZone.local
|
82
81
|
datetime = GLib::DateTime.new(:timezone => tz,
|
@@ -95,7 +94,6 @@ class TestDateTime < Test::Unit::TestCase
|
|
95
94
|
end
|
96
95
|
|
97
96
|
test "timezone: UTC time zone" do
|
98
|
-
only_glib_version(2, 34, 0)
|
99
97
|
time = Time.now.utc
|
100
98
|
tz = GLib::TimeZone.utc
|
101
99
|
datetime = GLib::DateTime.new(:timezone => tz,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C)
|
1
|
+
# Copyright (C) 2021 Ruby-GNOME 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,28 @@
|
|
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
|
-
|
17
|
+
class TestError < Test::Unit::TestCase
|
18
|
+
sub_test_case("error class") do
|
19
|
+
def test_code
|
20
|
+
assert_equal(nil,
|
21
|
+
GLib::BookmarkFileError.new.code)
|
22
|
+
end
|
18
23
|
|
19
|
-
|
24
|
+
def test_domain
|
25
|
+
assert_equal("g-bookmark-file-error-quark",
|
26
|
+
GLib::BookmarkFileError.new.domain)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
sub_test_case("error code class") do
|
31
|
+
def test_code
|
32
|
+
assert_equal(GLib::BookmarkFileError::READ,
|
33
|
+
GLib::BookmarkFileError::Read.new.code)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_domain
|
37
|
+
assert_equal("g-bookmark-file-error-quark",
|
38
|
+
GLib::BookmarkFileError::Read.new.domain)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|