glib2 3.4.0 → 3.4.5
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/Rakefile +6 -4
- data/ext/glib2/extconf.rb +1 -5
- data/ext/glib2/glib2.def +1 -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 +3 -5
- data/ext/glib2/rbglib.c +4 -0
- data/ext/glib2/rbglib.h +13 -3
- data/ext/glib2/rbglib_bookmarkfile.c +4 -4
- data/ext/glib2/rbglib_datetime.c +1 -5
- data/ext/glib2/rbglib_error.c +3 -1
- data/ext/glib2/rbglib_fileutils.c +1 -17
- data/ext/glib2/rbglib_iochannel.c +4 -4
- data/ext/glib2/rbglib_keyfile.c +16 -41
- 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_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_closure.c +22 -9
- data/ext/glib2/rbgobj_object.c +113 -104
- data/ext/glib2/rbgobj_param.c +2 -8
- data/ext/glib2/rbgobj_paramspecs.c +6 -24
- data/ext/glib2/rbgobj_signal.c +104 -92
- data/ext/glib2/rbgobj_strv.c +2 -2
- data/ext/glib2/rbgobj_type.c +58 -68
- data/ext/glib2/rbgobj_typeinterface.c +38 -2
- data/ext/glib2/rbgobj_value.c +3 -7
- 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 +6 -6
- data/ext/glib2/rbgutil_callback.c +23 -26
- data/lib/glib2.rb +32 -3
- data/lib/glib2/deprecated.rb +22 -1
- data/lib/mkmf-gnome.rb +4 -4
- data/test/glib-test-utils.rb +18 -3
- data/test/run-test.rb +49 -14
- data/test/test-binding.rb +1 -11
- data/test/test-bytes.rb +1 -5
- data/test/test-date-time.rb +1 -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 +2 -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 +3 -7
- data/ext/glib2/glib-enum-types.c +0 -1233
- data/ext/glib2/glib-enum-types.h +0 -154
- data/ext/glib2/rbgobj_valuearray.c +0 -100
- data/test/glib-test-init.rb +0 -21
data/ext/glib2/rbglib_pollfd.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011-
|
3
|
+
* Copyright (C) 2011-2021 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2005 Masao Mutoh
|
5
5
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
@@ -21,30 +21,6 @@
|
|
21
21
|
|
22
22
|
#include "rbgprivate.h"
|
23
23
|
|
24
|
-
#if !GLIB_CHECK_VERSION(2, 36, 0)
|
25
|
-
static GPollFD*
|
26
|
-
pollfd_copy(const GPollFD* pollfd)
|
27
|
-
{
|
28
|
-
GPollFD* new_pollfd;
|
29
|
-
g_return_val_if_fail (pollfd != NULL, NULL);
|
30
|
-
|
31
|
-
new_pollfd = g_new(GPollFD, 1);
|
32
|
-
*new_pollfd = *pollfd;
|
33
|
-
return new_pollfd;
|
34
|
-
}
|
35
|
-
|
36
|
-
GType
|
37
|
-
g_pollfd_get_type(void)
|
38
|
-
{
|
39
|
-
static GType our_type = 0;
|
40
|
-
if (our_type == 0)
|
41
|
-
our_type = g_boxed_type_register_static ("GPollFD",
|
42
|
-
(GBoxedCopyFunc)pollfd_copy,
|
43
|
-
(GBoxedFreeFunc)g_free);
|
44
|
-
return our_type;
|
45
|
-
}
|
46
|
-
#endif
|
47
|
-
|
48
24
|
#define RG_TARGET_NAMESPACE cPollFD
|
49
25
|
#define _SELF(s) ((GPollFD*)RVAL2BOXED(s, G_TYPE_POLLFD))
|
50
26
|
|
data/ext/glib2/rbglib_regex.c
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (C) 2015-
|
2
|
+
* Copyright (C) 2015-2021 Ruby-GNOME Project Team
|
3
3
|
*
|
4
4
|
* This library is free software; you can redistribute it and/or
|
5
5
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -136,7 +136,6 @@ rg_split(gint argc, VALUE *argv, VALUE self)
|
|
136
136
|
return STRV2RVAL_FREE(strings);
|
137
137
|
}
|
138
138
|
|
139
|
-
#if GLIB_CHECK_VERSION(2, 30, 0)
|
140
139
|
static VALUE
|
141
140
|
rg_match(gint argc, VALUE *argv, VALUE self)
|
142
141
|
{
|
@@ -191,7 +190,6 @@ rg_match(gint argc, VALUE *argv, VALUE self)
|
|
191
190
|
rb_iv_set(rb_match_info, "@string", rb_frozen_string);
|
192
191
|
return rb_match_info;
|
193
192
|
}
|
194
|
-
#endif
|
195
193
|
|
196
194
|
static VALUE
|
197
195
|
rg_max_backref(VALUE self)
|
@@ -205,7 +203,6 @@ rg_capture_count(VALUE self)
|
|
205
203
|
return INT2NUM(g_regex_get_capture_count(_SELF(self)));
|
206
204
|
}
|
207
205
|
|
208
|
-
#if GLIB_CHECK_VERSION(2, 34, 0)
|
209
206
|
static VALUE
|
210
207
|
rg_has_cr_or_lf_p(VALUE self)
|
211
208
|
{
|
@@ -217,7 +214,6 @@ rg_max_lookbehind(VALUE self)
|
|
217
214
|
{
|
218
215
|
return INT2NUM(g_regex_get_max_lookbehind(_SELF(self)));
|
219
216
|
}
|
220
|
-
#endif
|
221
217
|
|
222
218
|
static VALUE
|
223
219
|
rg_string_number(VALUE self, VALUE string)
|
@@ -225,7 +221,6 @@ rg_string_number(VALUE self, VALUE string)
|
|
225
221
|
return INT2NUM(g_regex_get_string_number(_SELF(self), RVAL2CSTR(string)));
|
226
222
|
}
|
227
223
|
|
228
|
-
#if GLIB_CHECK_VERSION(2, 30, 0)
|
229
224
|
static VALUE
|
230
225
|
rg_match_all(gint argc, VALUE *argv, VALUE self)
|
231
226
|
{
|
@@ -423,7 +418,6 @@ rg_replace(gint argc, VALUE *argv, VALUE self)
|
|
423
418
|
|
424
419
|
return CSTR2RVAL_FREE(modified_string);
|
425
420
|
}
|
426
|
-
#endif
|
427
421
|
|
428
422
|
static VALUE
|
429
423
|
rg_s_escape_string(G_GNUC_UNUSED VALUE self, VALUE string)
|
@@ -472,20 +466,14 @@ Init_glib_regex(void)
|
|
472
466
|
RG_DEF_METHOD(compile_flags, 0);
|
473
467
|
RG_DEF_METHOD(match_flags, 0);
|
474
468
|
RG_DEF_METHOD(split, -1);
|
475
|
-
#if GLIB_CHECK_VERSION(2, 30, 0)
|
476
469
|
RG_DEF_METHOD(match, -1);
|
477
|
-
#endif
|
478
470
|
RG_DEF_METHOD(max_backref, 0);
|
479
471
|
RG_DEF_METHOD(capture_count, 0);
|
480
|
-
#if GLIB_CHECK_VERSION(2, 34, 0)
|
481
472
|
RG_DEF_METHOD_P(has_cr_or_lf, 0);
|
482
473
|
RG_DEF_METHOD(max_lookbehind, 0);
|
483
|
-
#endif
|
484
474
|
RG_DEF_METHOD(string_number, 1);
|
485
|
-
#if GLIB_CHECK_VERSION(2, 30, 0)
|
486
475
|
RG_DEF_METHOD(match_all, -1);
|
487
476
|
RG_DEF_METHOD(replace, -1);
|
488
|
-
#endif
|
489
477
|
|
490
478
|
RG_DEF_SMETHOD(escape_string, 1);
|
491
479
|
RG_DEF_SMETHOD(check_replacement, 1);
|
data/ext/glib2/rbglib_source.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011-
|
3
|
+
* Copyright (C) 2011-2021 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2005 Masao Mutoh
|
5
5
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
@@ -23,32 +23,6 @@
|
|
23
23
|
|
24
24
|
static ID id_call;
|
25
25
|
|
26
|
-
/*****************************************/
|
27
|
-
#if !GLIB_CHECK_VERSION(2,30,0)
|
28
|
-
static void
|
29
|
-
source_free(GSource *source)
|
30
|
-
{
|
31
|
-
if (g_source_is_destroyed(source)) {
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
|
35
|
-
g_source_unref(source);
|
36
|
-
g_source_destroy(source);
|
37
|
-
}
|
38
|
-
|
39
|
-
GType
|
40
|
-
g_source_get_type(void)
|
41
|
-
{
|
42
|
-
static GType our_type = 0;
|
43
|
-
if (our_type == 0)
|
44
|
-
our_type = g_boxed_type_register_static ("GSource",
|
45
|
-
(GBoxedCopyFunc)g_source_ref,
|
46
|
-
(GBoxedFreeFunc)source_free);
|
47
|
-
return our_type;
|
48
|
-
}
|
49
|
-
#endif
|
50
|
-
/*****************************************/
|
51
|
-
|
52
26
|
#define RG_TARGET_NAMESPACE cSource
|
53
27
|
#define _SELF(s) ((GSource*)RVAL2BOXED(s, G_TYPE_SOURCE))
|
54
28
|
|
@@ -112,7 +86,6 @@ rg_id(VALUE self)
|
|
112
86
|
return UINT2NUM(g_source_get_id(_SELF(self)));
|
113
87
|
}
|
114
88
|
|
115
|
-
#if GLIB_CHECK_VERSION(2, 26, 0)
|
116
89
|
static VALUE
|
117
90
|
rg_name(VALUE self)
|
118
91
|
{
|
@@ -125,7 +98,6 @@ rg_set_name(VALUE self, VALUE name)
|
|
125
98
|
g_source_set_name(_SELF(self), RVAL2CSTR(name));
|
126
99
|
return self;
|
127
100
|
}
|
128
|
-
#endif
|
129
101
|
|
130
102
|
static VALUE
|
131
103
|
rg_context(VALUE self)
|
@@ -158,7 +130,6 @@ void g_source_set_callback_indirect (GSource *source,
|
|
158
130
|
GSourceCallbackFuncs *callback_funcs);
|
159
131
|
*/
|
160
132
|
|
161
|
-
#if GLIB_CHECK_VERSION(2, 36, 0)
|
162
133
|
static VALUE
|
163
134
|
rg_ready_time(VALUE self)
|
164
135
|
{
|
@@ -173,7 +144,6 @@ rg_set_ready_time(VALUE self, VALUE ready_time)
|
|
173
144
|
g_source_set_ready_time(_SELF(self), NUM2LL(ready_time));
|
174
145
|
return self;
|
175
146
|
}
|
176
|
-
#endif
|
177
147
|
|
178
148
|
static VALUE
|
179
149
|
rg_add_poll(VALUE self, VALUE fd)
|
@@ -189,7 +159,6 @@ rg_remove_poll(VALUE self, VALUE fd)
|
|
189
159
|
return self;
|
190
160
|
}
|
191
161
|
|
192
|
-
#if GLIB_CHECK_VERSION(2, 28, 0)
|
193
162
|
static VALUE
|
194
163
|
rg_time(VALUE self)
|
195
164
|
{
|
@@ -197,7 +166,6 @@ rg_time(VALUE self)
|
|
197
166
|
time = g_source_get_time(_SELF(self));
|
198
167
|
return LL2NUM(time);
|
199
168
|
}
|
200
|
-
#endif
|
201
169
|
|
202
170
|
/* How can I implement them ?
|
203
171
|
gboolean g_source_remove_by_funcs_user_data
|
@@ -226,21 +194,15 @@ Init_glib_source(void)
|
|
226
194
|
RG_DEF_METHOD(set_can_recurse, 1);
|
227
195
|
RG_DEF_METHOD_P(can_recurse, 0);
|
228
196
|
RG_DEF_METHOD(id, 0);
|
229
|
-
#if GLIB_CHECK_VERSION(2, 26, 0)
|
230
197
|
RG_DEF_METHOD(name, 0);
|
231
198
|
RG_REPLACE_SET_PROPERTY(name, 1);
|
232
|
-
#endif
|
233
199
|
RG_DEF_METHOD(context, 0);
|
234
200
|
RG_DEF_METHOD(set_callback, 0);
|
235
|
-
#if GLIB_CHECK_VERSION(2, 36, 0)
|
236
201
|
RG_DEF_METHOD(ready_time, 0);
|
237
202
|
RG_REPLACE_SET_PROPERTY(ready_time, 1);
|
238
|
-
#endif
|
239
203
|
RG_DEF_METHOD(add_poll, 1);
|
240
204
|
RG_DEF_METHOD(remove_poll, 1);
|
241
|
-
#if GLIB_CHECK_VERSION(2, 28, 0)
|
242
205
|
RG_DEF_METHOD(time, 0);
|
243
|
-
#endif
|
244
206
|
|
245
207
|
/* GLib::Source.remove is moved to rbglib_maincontext.c */
|
246
208
|
}
|
data/ext/glib2/rbglib_spawn.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011 Ruby-
|
3
|
+
* Copyright (C) 2011-2021 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2004 Masao Mutoh
|
5
5
|
* Copyright (C) 2004 Kazuhiro NISHIYAMA
|
6
6
|
*
|
@@ -29,10 +29,11 @@ static ID id_call;
|
|
29
29
|
static ID id_new;
|
30
30
|
|
31
31
|
static void
|
32
|
-
child_setup(gpointer
|
32
|
+
child_setup(gpointer data)
|
33
33
|
{
|
34
|
-
|
35
|
-
|
34
|
+
VALUE func = POINTER2RVAL(data);
|
35
|
+
if (!NIL_P(func)) {
|
36
|
+
rb_funcall(func, id_call, 0);
|
36
37
|
}
|
37
38
|
}
|
38
39
|
|
@@ -204,8 +205,6 @@ rg_s_command_line_async(G_GNUC_UNUSED VALUE self, VALUE str)
|
|
204
205
|
return ret;
|
205
206
|
}
|
206
207
|
|
207
|
-
#ifdef HAVE_G_SPAWN_CLOSE_PID
|
208
|
-
|
209
208
|
#define RVAL2GPID(value) ((GPid)NUM2INT(pid))
|
210
209
|
|
211
210
|
static VALUE
|
@@ -215,8 +214,6 @@ rg_s_close_pid(G_GNUC_UNUSED VALUE self, VALUE pid)
|
|
215
214
|
return Qnil;
|
216
215
|
}
|
217
216
|
|
218
|
-
#endif
|
219
|
-
|
220
217
|
void
|
221
218
|
Init_glib_spawn(void)
|
222
219
|
{
|
@@ -231,9 +228,7 @@ Init_glib_spawn(void)
|
|
231
228
|
RG_DEF_SMETHOD(sync, 4);
|
232
229
|
RG_DEF_SMETHOD(command_line_sync, 1);
|
233
230
|
RG_DEF_SMETHOD(command_line_async, 1);
|
234
|
-
#ifdef HAVE_G_SPAWN_CLOSE_PID
|
235
231
|
RG_DEF_SMETHOD(close_pid, 1);
|
236
|
-
#endif
|
237
232
|
|
238
233
|
rb_define_const(RG_TARGET_NAMESPACE, "LEAVE_DESCRIPTORS_OPEN", INT2NUM(G_SPAWN_LEAVE_DESCRIPTORS_OPEN));
|
239
234
|
rb_define_const(RG_TARGET_NAMESPACE, "DO_NOT_REAP_CHILD", INT2NUM(G_SPAWN_DO_NOT_REAP_CHILD));
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011 Ruby-
|
3
|
+
* Copyright (C) 2011-2021 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2004 Masao Mutoh
|
5
5
|
* Copyright (C) 2004 Kazuhiro NISHIYAMA
|
6
6
|
*
|
@@ -35,7 +35,7 @@ Init_glib_spawnerror(void)
|
|
35
35
|
rb_define_const(RG_TARGET_NAMESPACE, "CHDIR", INT2NUM(G_SPAWN_ERROR_CHDIR));
|
36
36
|
rb_define_const(RG_TARGET_NAMESPACE, "EACCES", INT2NUM(G_SPAWN_ERROR_ACCES));
|
37
37
|
rb_define_const(RG_TARGET_NAMESPACE, "EPERM", INT2NUM(G_SPAWN_ERROR_PERM));
|
38
|
-
rb_define_const(RG_TARGET_NAMESPACE, "
|
38
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TOO_BIG", INT2NUM(G_SPAWN_ERROR_TOO_BIG));
|
39
39
|
rb_define_const(RG_TARGET_NAMESPACE, "ENOEXEC", INT2NUM(G_SPAWN_ERROR_NOEXEC));
|
40
40
|
rb_define_const(RG_TARGET_NAMESPACE, "ENAMETOOLONG", INT2NUM(G_SPAWN_ERROR_NAMETOOLONG));
|
41
41
|
rb_define_const(RG_TARGET_NAMESPACE, "ENOENT", INT2NUM(G_SPAWN_ERROR_NOENT));
|
data/ext/glib2/rbglib_threads.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011 Ruby-
|
3
|
+
* Copyright (C) 2011-2021 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2005 Masao Mutoh
|
5
5
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
@@ -28,26 +28,13 @@ static VALUE RG_TARGET_NAMESPACE;
|
|
28
28
|
static VALUE
|
29
29
|
rg_s_init(VALUE self)
|
30
30
|
{
|
31
|
-
#ifdef HAVE_G_THREAD_INIT
|
32
|
-
#if defined(G_THREADS_ENABLED) && !GLIB_CHECK_VERSION(2, 32, 0)
|
33
|
-
g_thread_init(NULL);
|
34
|
-
#endif
|
35
|
-
#endif
|
36
31
|
return self;
|
37
32
|
}
|
38
33
|
|
39
34
|
static VALUE
|
40
35
|
rg_s_supported_p(G_GNUC_UNUSED VALUE self)
|
41
36
|
{
|
42
|
-
|
43
|
-
#ifdef G_THREADS_ENABLED
|
44
|
-
return CBOOL2RVAL(g_thread_supported());
|
45
|
-
#else
|
46
|
-
return Qfalse;
|
47
|
-
#endif
|
48
|
-
#else
|
49
|
-
return Qfalse;
|
50
|
-
#endif
|
37
|
+
return Qtrue;
|
51
38
|
|
52
39
|
}
|
53
40
|
|
data/ext/glib2/rbglib_timezone.c
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (C) 2016 Ruby-
|
2
|
+
* Copyright (C) 2016-2021 Ruby-GNOME Project Team
|
3
3
|
*
|
4
4
|
* This library is free software; you can redistribute it and/or
|
5
5
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -22,7 +22,6 @@
|
|
22
22
|
#define RG_TARGET_NAMESPACE cTimeZone
|
23
23
|
#define _SELF(s) ((GTimeZone*)RVAL2BOXED(s, G_TYPE_TIME_ZONE))
|
24
24
|
|
25
|
-
#if GLIB_CHECK_VERSION(2, 34, 0)
|
26
25
|
static VALUE
|
27
26
|
rg_initialize(gint argc, VALUE *argv, VALUE self)
|
28
27
|
{
|
@@ -69,12 +68,10 @@ rg_offset(VALUE self, VALUE rb_interval)
|
|
69
68
|
gint interval = NUM2INT(rb_interval);
|
70
69
|
return INT2NUM(g_time_zone_get_offset(_SELF(self), interval));
|
71
70
|
}
|
72
|
-
#endif
|
73
71
|
|
74
72
|
void
|
75
73
|
Init_glib_time_zone(void)
|
76
74
|
{
|
77
|
-
#if GLIB_CHECK_VERSION(2, 34, 0)
|
78
75
|
VALUE RG_TARGET_NAMESPACE;
|
79
76
|
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TIME_ZONE, "TimeZone", mGLib);
|
80
77
|
RG_DEF_METHOD(initialize, -1);
|
@@ -82,5 +79,4 @@ Init_glib_time_zone(void)
|
|
82
79
|
RG_DEF_SMETHOD(utc, 0);
|
83
80
|
RG_DEF_METHOD(abbreviation, 1);
|
84
81
|
RG_DEF_METHOD(offset, 1);
|
85
|
-
#endif
|
86
82
|
}
|
data/ext/glib2/rbglib_unichar.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011 Ruby-
|
3
|
+
* Copyright (C) 2011-2021 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2006 Kouhei Sutou
|
5
5
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
@@ -105,7 +105,6 @@ rg_s_get_mirror_char(G_GNUC_UNUSED VALUE self, VALUE unichar)
|
|
105
105
|
}
|
106
106
|
}
|
107
107
|
|
108
|
-
#if GLIB_CHECK_VERSION(2,14,0)
|
109
108
|
static VALUE
|
110
109
|
rg_s_combining_class(G_GNUC_UNUSED VALUE self, VALUE unichar)
|
111
110
|
{
|
@@ -130,7 +129,6 @@ rg_s_zero_width_p(G_GNUC_UNUSED VALUE self, VALUE unichar)
|
|
130
129
|
{
|
131
130
|
return CBOOL2RVAL(g_unichar_iszerowidth(NUM2UINT(unichar)));
|
132
131
|
}
|
133
|
-
#endif
|
134
132
|
|
135
133
|
static VALUE
|
136
134
|
rg_s_to_utf8(G_GNUC_UNUSED VALUE self, VALUE unichar)
|
@@ -142,6 +140,48 @@ rg_s_to_utf8(G_GNUC_UNUSED VALUE self, VALUE unichar)
|
|
142
140
|
return CSTR2RVAL_LEN(utf8, len);
|
143
141
|
}
|
144
142
|
|
143
|
+
static VALUE
|
144
|
+
rg_s_compose(G_GNUC_UNUSED VALUE self, VALUE unichar1, VALUE unichar2)
|
145
|
+
{
|
146
|
+
gunichar composed_char;
|
147
|
+
if (g_unichar_compose(NUM2UINT(unichar1),
|
148
|
+
NUM2UINT(unichar2),
|
149
|
+
&composed_char)) {
|
150
|
+
return UINT2NUM(composed_char);
|
151
|
+
} else {
|
152
|
+
return Qnil;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
static VALUE
|
157
|
+
rg_s_decompose(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
158
|
+
{
|
159
|
+
VALUE unichar;
|
160
|
+
VALUE options = Qnil;
|
161
|
+
gboolean compat = FALSE;
|
162
|
+
|
163
|
+
rb_scan_args(argc, argv, "1:", &unichar, &options);
|
164
|
+
if (!NIL_P(options)) {
|
165
|
+
ID keywords[1];
|
166
|
+
VALUE values[1];
|
167
|
+
keywords[0] = rb_intern("compat");
|
168
|
+
rb_get_kwargs(options, keywords, 0, 1, values);
|
169
|
+
if (values[0] != Qundef) {
|
170
|
+
compat = CBOOL2RVAL(values[0]);
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
/* 18 is enough. See g_unichar_fully_decompose() document. */
|
175
|
+
gunichar result[G_UNICHAR_MAX_DECOMPOSITION_LENGTH];
|
176
|
+
gsize result_len =
|
177
|
+
g_unichar_fully_decompose(NUM2UINT(unichar),
|
178
|
+
compat,
|
179
|
+
result,
|
180
|
+
G_UNICHAR_MAX_DECOMPOSITION_LENGTH);
|
181
|
+
return CSTR2RVAL_LEN_UCS4((const char *)result,
|
182
|
+
result_len * sizeof(gunichar));
|
183
|
+
}
|
184
|
+
|
145
185
|
void
|
146
186
|
Init_glib_unichar(void)
|
147
187
|
{
|
@@ -190,12 +230,13 @@ Init_glib_unichar(void)
|
|
190
230
|
|
191
231
|
RG_DEF_SMETHOD(get_mirror_char, 1);
|
192
232
|
|
193
|
-
#if GLIB_CHECK_VERSION(2,14,0)
|
194
233
|
RG_DEF_SMETHOD(combining_class, 1);
|
195
234
|
RG_DEF_SMETHOD(get_script, 1);
|
196
235
|
RG_DEF_SMETHOD_P(mark, 1);
|
197
236
|
RG_DEF_SMETHOD_P(zero_width, 1);
|
198
|
-
#endif
|
199
237
|
|
200
238
|
RG_DEF_SMETHOD(to_utf8, 1);
|
239
|
+
|
240
|
+
RG_DEF_SMETHOD(compose, 2);
|
241
|
+
RG_DEF_SMETHOD(decompose, -1);
|
201
242
|
}
|
data/ext/glib2/rbglib_unicode.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011-
|
3
|
+
* Copyright (C) 2011-2021 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2006 Kouhei Sutou
|
5
5
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
@@ -49,20 +49,6 @@ rg_s_canonical_ordering(G_GNUC_UNUSED VALUE self, VALUE rb_ucs4)
|
|
49
49
|
return normalized_ucs4;
|
50
50
|
}
|
51
51
|
|
52
|
-
static VALUE
|
53
|
-
rg_s_canonical_decomposition(G_GNUC_UNUSED VALUE self, VALUE unichar)
|
54
|
-
{
|
55
|
-
VALUE normalized_ucs4;
|
56
|
-
gunichar *ucs4;
|
57
|
-
gsize len;
|
58
|
-
|
59
|
-
ucs4 = g_unicode_canonical_decomposition(NUM2UINT(unichar), &len);
|
60
|
-
normalized_ucs4 = CSTR2RVAL_LEN_UCS4((const char *)ucs4,
|
61
|
-
len * sizeof(gunichar));
|
62
|
-
g_free(ucs4);
|
63
|
-
return normalized_ucs4;
|
64
|
-
}
|
65
|
-
|
66
52
|
void
|
67
53
|
Init_glib_unicode(void)
|
68
54
|
{
|
@@ -75,16 +61,13 @@ Init_glib_unicode(void)
|
|
75
61
|
G_DEF_CLASS(G_TYPE_UNICODE_BREAK_TYPE, "BreakType", RG_TARGET_NAMESPACE);
|
76
62
|
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_UNICODE_BREAK_TYPE, "G_UNICODE_");
|
77
63
|
|
78
|
-
#if GLIB_CHECK_VERSION(2,14,0)
|
79
64
|
/* GUnicodeScript */
|
80
65
|
G_DEF_CLASS(G_TYPE_UNICODE_SCRIPT, "Script", RG_TARGET_NAMESPACE);
|
81
66
|
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_UNICODE_SCRIPT, "G_UNICODE_");
|
82
|
-
#endif
|
83
67
|
|
84
68
|
G_DEF_CLASS(G_TYPE_NORMALIZE_MODE, "NormalizeMode", mGLib);
|
85
69
|
|
86
70
|
rbg_define_singleton_method(mGLib, "charset", rbglib_m_charset, 0);
|
87
71
|
|
88
72
|
RG_DEF_SMETHOD(canonical_ordering, 1);
|
89
|
-
RG_DEF_SMETHOD(canonical_decomposition, 1);
|
90
73
|
}
|