glib2 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/ChangeLog +3023 -0
  2. data/README +28 -0
  3. data/Rakefile +87 -0
  4. data/extconf.rb +61 -0
  5. data/sample/bookmarkfile.rb +66 -0
  6. data/sample/completion.rb +45 -0
  7. data/sample/idle.rb +41 -0
  8. data/sample/iochannel.rb +44 -0
  9. data/sample/keyfile.rb +62 -0
  10. data/sample/shell.rb +36 -0
  11. data/sample/spawn.rb +25 -0
  12. data/sample/timeout.rb +28 -0
  13. data/sample/timeout2.rb +35 -0
  14. data/sample/timer.rb +40 -0
  15. data/sample/type-register.rb +103 -0
  16. data/sample/type-register2.rb +104 -0
  17. data/sample/utils.rb +54 -0
  18. data/src/glib-enum-types.c +1032 -0
  19. data/src/glib-enum-types.h +140 -0
  20. data/src/lib/glib-mkenums.rb +199 -0
  21. data/src/lib/glib2.rb +220 -0
  22. data/src/lib/mkmf-gnome2.rb +390 -0
  23. data/src/lib/pkg-config.rb +137 -0
  24. data/src/rbgcompat.h +30 -0
  25. data/src/rbglib.c +320 -0
  26. data/src/rbglib.h +96 -0
  27. data/src/rbglib_bookmarkfile.c +595 -0
  28. data/src/rbglib_completion.c +192 -0
  29. data/src/rbglib_convert.c +195 -0
  30. data/src/rbglib_error.c +95 -0
  31. data/src/rbglib_fileutils.c +83 -0
  32. data/src/rbglib_i18n.c +44 -0
  33. data/src/rbglib_int64.c +157 -0
  34. data/src/rbglib_iochannel.c +883 -0
  35. data/src/rbglib_keyfile.c +846 -0
  36. data/src/rbglib_maincontext.c +917 -0
  37. data/src/rbglib_mainloop.c +87 -0
  38. data/src/rbglib_messages.c +150 -0
  39. data/src/rbglib_pollfd.c +111 -0
  40. data/src/rbglib_shell.c +68 -0
  41. data/src/rbglib_source.c +190 -0
  42. data/src/rbglib_spawn.c +345 -0
  43. data/src/rbglib_threads.c +51 -0
  44. data/src/rbglib_timer.c +127 -0
  45. data/src/rbglib_unicode.c +611 -0
  46. data/src/rbglib_utils.c +386 -0
  47. data/src/rbglib_win32.c +136 -0
  48. data/src/rbgobj_boxed.c +251 -0
  49. data/src/rbgobj_closure.c +337 -0
  50. data/src/rbgobj_convert.c +167 -0
  51. data/src/rbgobj_enums.c +961 -0
  52. data/src/rbgobj_fundamental.c +30 -0
  53. data/src/rbgobj_object.c +892 -0
  54. data/src/rbgobj_param.c +390 -0
  55. data/src/rbgobj_paramspecs.c +305 -0
  56. data/src/rbgobj_signal.c +963 -0
  57. data/src/rbgobj_strv.c +61 -0
  58. data/src/rbgobj_type.c +851 -0
  59. data/src/rbgobj_typeinstance.c +121 -0
  60. data/src/rbgobj_typeinterface.c +148 -0
  61. data/src/rbgobj_typemodule.c +66 -0
  62. data/src/rbgobj_typeplugin.c +49 -0
  63. data/src/rbgobj_value.c +313 -0
  64. data/src/rbgobj_valuearray.c +59 -0
  65. data/src/rbgobj_valuetypes.c +298 -0
  66. data/src/rbgobject.c +406 -0
  67. data/src/rbgobject.h +265 -0
  68. data/src/rbgprivate.h +88 -0
  69. data/src/rbgutil.c +222 -0
  70. data/src/rbgutil.h +82 -0
  71. data/src/rbgutil_callback.c +231 -0
  72. data/test/glib-test-init.rb +6 -0
  73. data/test/glib-test-utils.rb +12 -0
  74. data/test/run-test.rb +25 -0
  75. data/test/test_enum.rb +99 -0
  76. data/test/test_file_utils.rb +15 -0
  77. data/test/test_glib2.rb +120 -0
  78. data/test/test_iochannel.rb +275 -0
  79. data/test/test_key_file.rb +38 -0
  80. data/test/test_mkenums.rb +25 -0
  81. data/test/test_signal.rb +20 -0
  82. data/test/test_timeout.rb +28 -0
  83. data/test/test_unicode.rb +369 -0
  84. data/test/test_utils.rb +37 -0
  85. data/test/test_win32.rb +13 -0
  86. metadata +165 -0
@@ -0,0 +1,611 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /**********************************************************************
3
+
4
+ rbglib_unicode.c -
5
+
6
+ $Author: ktou $
7
+ $Date: 2007/08/30 10:16:35 $
8
+
9
+ Copyright (C) 2006 Kouhei Sutou
10
+
11
+ **********************************************************************/
12
+ #include "rbgprivate.h"
13
+ #include "rbglib.h"
14
+
15
+ static VALUE
16
+ rbglib_m_charset(VALUE self)
17
+ {
18
+ const char *charset;
19
+ g_get_charset(&charset);
20
+ return rb_str_new2(charset);
21
+ }
22
+
23
+ #define DEF_IS_UNICHAR(name) \
24
+ static VALUE \
25
+ rbglib_m_unichar_is ## name(VALUE self, VALUE unichar) \
26
+ { \
27
+ return CBOOL2RVAL(g_unichar_is ## name(NUM2UINT(unichar))); \
28
+ }
29
+
30
+ DEF_IS_UNICHAR(alnum)
31
+ DEF_IS_UNICHAR(alpha)
32
+ DEF_IS_UNICHAR(cntrl)
33
+ DEF_IS_UNICHAR(digit)
34
+ DEF_IS_UNICHAR(graph)
35
+ DEF_IS_UNICHAR(lower)
36
+ DEF_IS_UNICHAR(print)
37
+ DEF_IS_UNICHAR(punct)
38
+ DEF_IS_UNICHAR(space)
39
+ DEF_IS_UNICHAR(upper)
40
+ DEF_IS_UNICHAR(xdigit)
41
+ DEF_IS_UNICHAR(title)
42
+ DEF_IS_UNICHAR(defined)
43
+ DEF_IS_UNICHAR(wide)
44
+ #if GLIB_CHECK_VERSION(2,12,0)
45
+ DEF_IS_UNICHAR(wide_cjk)
46
+ #endif
47
+
48
+ #undef DEF_IS_UNICHAR
49
+
50
+ static VALUE
51
+ rbglib_m_unichar_toupper(VALUE self, VALUE unichar)
52
+ {
53
+ return UINT2NUM(g_unichar_toupper(NUM2UINT(unichar)));
54
+ }
55
+
56
+ static VALUE
57
+ rbglib_m_unichar_tolower(VALUE self, VALUE unichar)
58
+ {
59
+ return UINT2NUM(g_unichar_tolower(NUM2UINT(unichar)));
60
+ }
61
+
62
+ static VALUE
63
+ rbglib_m_unichar_totitle(VALUE self, VALUE unichar)
64
+ {
65
+ return UINT2NUM(g_unichar_totitle(NUM2UINT(unichar)));
66
+ }
67
+
68
+ static VALUE
69
+ rbglib_m_unichar_digit_value(VALUE self, VALUE unichar)
70
+ {
71
+ return INT2NUM(g_unichar_digit_value(NUM2UINT(unichar)));
72
+ }
73
+
74
+ static VALUE
75
+ rbglib_m_unichar_xdigit_value(VALUE self, VALUE unichar)
76
+ {
77
+ return INT2NUM(g_unichar_xdigit_value(NUM2UINT(unichar)));
78
+ }
79
+
80
+ static VALUE
81
+ rbglib_m_unichar_type(VALUE self, VALUE unichar)
82
+ {
83
+ return GENUM2RVAL(g_unichar_type(NUM2UINT(unichar)),
84
+ G_TYPE_UNICODE_TYPE);
85
+ }
86
+
87
+ static VALUE
88
+ rbglib_m_unichar_break_type(VALUE self, VALUE unichar)
89
+ {
90
+ return GENUM2RVAL(g_unichar_break_type(NUM2UINT(unichar)),
91
+ G_TYPE_UNICODE_BREAK_TYPE);
92
+ }
93
+
94
+ static VALUE
95
+ rbglib_m_unicode_canonical_ordering(VALUE self, VALUE rb_ucs4)
96
+ {
97
+ VALUE normalized_ucs4;
98
+ gchar *original_str;
99
+ gunichar *ucs4;
100
+ gint len;
101
+
102
+ original_str = StringValuePtr(rb_ucs4);
103
+ len = RSTRING_LEN(rb_ucs4);
104
+ ucs4 = g_memdup(original_str, len);
105
+ g_unicode_canonical_ordering(ucs4, len);
106
+ normalized_ucs4 = rb_str_new((const char *)ucs4, len);
107
+ g_free(ucs4);
108
+ return normalized_ucs4;
109
+ }
110
+
111
+ static VALUE
112
+ rbglib_m_unicode_canonical_decomposition(VALUE self, VALUE unichar)
113
+ {
114
+ VALUE normalized_ucs4;
115
+ gunichar *ucs4;
116
+ gsize len;
117
+
118
+ ucs4 = g_unicode_canonical_decomposition(NUM2UINT(unichar), &len);
119
+ normalized_ucs4 = rb_str_new((const char *)ucs4, len * sizeof(gunichar));
120
+ g_free(ucs4);
121
+ return normalized_ucs4;
122
+ }
123
+
124
+ #if GLIB_CHECK_VERSION(2,4,0)
125
+ static VALUE
126
+ rbglib_m_unichar_get_mirror_char(VALUE self, VALUE unichar)
127
+ {
128
+ gunichar mirrored_char;
129
+
130
+ if (g_unichar_get_mirror_char(NUM2UINT(unichar), &mirrored_char)) {
131
+ return UINT2NUM(mirrored_char);
132
+ } else {
133
+ return unichar;
134
+ }
135
+ }
136
+ #endif
137
+
138
+ #if GLIB_CHECK_VERSION(2,14,0)
139
+ static VALUE
140
+ rbglib_m_unichar_combining_class(VALUE self, VALUE unichar)
141
+ {
142
+ return INT2NUM(g_unichar_combining_class(NUM2UINT(unichar)));
143
+ }
144
+
145
+ static VALUE
146
+ rbglib_m_unichar_get_script(VALUE self, VALUE unichar)
147
+ {
148
+ return GENUM2RVAL(g_unichar_get_script(NUM2UINT(unichar)),
149
+ G_TYPE_UNICODE_SCRIPT);
150
+ }
151
+
152
+ static VALUE
153
+ rbglib_m_unichar_ismark(VALUE self, VALUE unichar)
154
+ {
155
+ return CBOOL2RVAL(g_unichar_ismark(NUM2UINT(unichar)));
156
+ }
157
+
158
+ static VALUE
159
+ rbglib_m_unichar_iszerowidth(VALUE self, VALUE unichar)
160
+ {
161
+ return CBOOL2RVAL(g_unichar_iszerowidth(NUM2UINT(unichar)));
162
+ }
163
+ #endif
164
+
165
+ static VALUE
166
+ rbglib_m_utf8_get_char(int argc, VALUE *argv, VALUE self)
167
+ {
168
+ VALUE utf8, validate;
169
+ gunichar result;
170
+
171
+ rb_scan_args(argc, argv, "11", &utf8, &validate);
172
+
173
+ if (RVAL2CBOOL(validate)) {
174
+ StringValue(utf8);
175
+ result = g_utf8_get_char_validated(RSTRING_PTR(utf8),
176
+ RSTRING_LEN(utf8));
177
+ if (result == (gunichar)-1) {
178
+ return INT2NUM(-1);
179
+ } else if (result == (gunichar)-2) {
180
+ return INT2NUM(-2);
181
+ }
182
+ } else {
183
+ result = g_utf8_get_char(StringValueCStr(utf8));
184
+ }
185
+
186
+ return UINT2NUM(result);
187
+ }
188
+
189
+ static VALUE
190
+ rbglib_m_utf8_strlen(VALUE self, VALUE rb_utf8)
191
+ {
192
+ gchar *utf8;
193
+
194
+ utf8 = StringValueCStr(rb_utf8);
195
+ return INT2NUM(g_utf8_strlen(utf8, RSTRING_LEN(rb_utf8)));
196
+ }
197
+
198
+ static VALUE
199
+ rbglib_m_utf8_strreverse(VALUE self, VALUE rb_utf8)
200
+ {
201
+ VALUE result;
202
+ gchar *utf8, *reversed_utf8;
203
+
204
+ utf8 = StringValueCStr(rb_utf8);
205
+ reversed_utf8 = g_utf8_strreverse(utf8, RSTRING_LEN(rb_utf8));
206
+ result = rb_str_new2(reversed_utf8);
207
+ g_free(reversed_utf8);
208
+ return result;
209
+ }
210
+
211
+ static VALUE
212
+ rbglib_m_utf8_validate(VALUE self, VALUE str)
213
+ {
214
+ StringValue(str);
215
+ return CBOOL2RVAL(g_utf8_validate(RSTRING_PTR(str), RSTRING_LEN(str),
216
+ NULL));
217
+ }
218
+
219
+ static VALUE
220
+ rbglib_m_utf8_strup(VALUE self, VALUE rb_utf8)
221
+ {
222
+ VALUE result;
223
+ gchar *utf8, *upcased_utf8;
224
+
225
+ utf8 = StringValueCStr(rb_utf8);
226
+ upcased_utf8 = g_utf8_strup(utf8, RSTRING_LEN(rb_utf8));
227
+ result = rb_str_new2(upcased_utf8);
228
+ g_free(upcased_utf8);
229
+ return result;
230
+ }
231
+
232
+ static VALUE
233
+ rbglib_m_utf8_strdown(VALUE self, VALUE rb_utf8)
234
+ {
235
+ VALUE result;
236
+ gchar *utf8, *downcased_utf8;
237
+
238
+ utf8 = StringValueCStr(rb_utf8);
239
+ downcased_utf8 = g_utf8_strdown(utf8, RSTRING_LEN(rb_utf8));
240
+ result = rb_str_new2(downcased_utf8);
241
+ g_free(downcased_utf8);
242
+ return result;
243
+ }
244
+
245
+ static VALUE
246
+ rbglib_m_utf8_casefold(VALUE self, VALUE rb_utf8)
247
+ {
248
+ VALUE result;
249
+ gchar *utf8, *casefolded_utf8;
250
+
251
+ utf8 = StringValueCStr(rb_utf8);
252
+ casefolded_utf8 = g_utf8_casefold(utf8, RSTRING_LEN(rb_utf8));
253
+ result = rb_str_new2(casefolded_utf8);
254
+ g_free(casefolded_utf8);
255
+ return result;
256
+ }
257
+
258
+ static VALUE
259
+ rbglib_m_utf8_normalize(int argc, VALUE *argv, VALUE self)
260
+ {
261
+ VALUE rb_utf8, rb_mode, result;
262
+ gchar *utf8, *normalized_utf8;
263
+ GNormalizeMode mode = G_NORMALIZE_DEFAULT;
264
+
265
+ rb_scan_args(argc, argv, "11", &rb_utf8, &rb_mode);
266
+
267
+ if (!NIL_P(rb_mode))
268
+ mode = RVAL2GENUM(rb_mode, G_TYPE_NORMALIZE_MODE);
269
+
270
+ utf8 = StringValueCStr(rb_utf8);
271
+ normalized_utf8 = g_utf8_normalize(utf8, RSTRING_LEN(rb_utf8), mode);
272
+ result = rb_str_new2(normalized_utf8);
273
+ g_free(normalized_utf8);
274
+ return result;
275
+ }
276
+
277
+ static VALUE
278
+ rbglib_m_utf8_collate(VALUE self, VALUE utf8a, VALUE utf8b)
279
+ {
280
+ return INT2NUM(g_utf8_collate(StringValueCStr(utf8a),
281
+ StringValueCStr(utf8b)));
282
+ }
283
+
284
+ static VALUE
285
+ rbglib_m_utf8_collate_key(int argc, VALUE *argv, VALUE self)
286
+ {
287
+ VALUE result, rb_utf8, for_filename;
288
+ gchar *key, *utf8;
289
+ gssize len;
290
+
291
+ rb_scan_args(argc, argv, "11", &rb_utf8, &for_filename);
292
+
293
+ utf8 = StringValueCStr(rb_utf8);
294
+ len = RSTRING_LEN(rb_utf8);
295
+ #if GLIB_CHECK_VERSION(2,8,0)
296
+ if (RVAL2CBOOL(for_filename))
297
+ key = g_utf8_collate_key_for_filename(utf8, len);
298
+ else
299
+ #endif
300
+ key = g_utf8_collate_key(utf8, len);
301
+
302
+ result = rb_str_new2(key);
303
+ g_free(key);
304
+ return result;
305
+ }
306
+
307
+ static VALUE
308
+ rbglib_m_utf8_to_utf16(VALUE self, VALUE rb_utf8)
309
+ {
310
+ VALUE result;
311
+ gchar *utf8;
312
+ gunichar2 *utf16;
313
+ glong len, items_written;
314
+ GError *error = NULL;
315
+
316
+ utf8 = StringValueCStr(rb_utf8);
317
+ len = RSTRING_LEN(rb_utf8);
318
+
319
+ utf16 = g_utf8_to_utf16(utf8, len, NULL, &items_written, &error);
320
+
321
+ if (error)
322
+ RAISE_GERROR(error);
323
+
324
+ result = rb_str_new((char *)utf16, items_written * sizeof(*utf16));
325
+ g_free(utf16);
326
+ return result;
327
+ }
328
+
329
+ static VALUE
330
+ rbglib_m_utf8_to_ucs4(int argc, VALUE *argv, VALUE self)
331
+ {
332
+ VALUE result, rb_utf8, is_fast;
333
+ gchar *utf8;
334
+ gunichar *ucs4;
335
+ glong len, items_written;
336
+
337
+ rb_scan_args(argc, argv, "11", &rb_utf8, &is_fast);
338
+
339
+ utf8 = StringValueCStr(rb_utf8);
340
+ len = RSTRING_LEN(rb_utf8);
341
+
342
+ if (RVAL2CBOOL(is_fast)) {
343
+ ucs4 = g_utf8_to_ucs4_fast(utf8, len, &items_written);
344
+ } else {
345
+ GError *error = NULL;
346
+ ucs4 = g_utf8_to_ucs4(utf8, len, NULL, &items_written, &error);
347
+
348
+ if (error)
349
+ RAISE_GERROR(error);
350
+ }
351
+
352
+ result = rb_str_new((char *)ucs4, items_written * sizeof(*ucs4));
353
+ g_free(ucs4);
354
+ return result;
355
+ }
356
+
357
+ static VALUE
358
+ rbglib_m_utf16_to_ucs4(VALUE self, VALUE rb_utf16)
359
+ {
360
+ VALUE result;
361
+ gunichar *ucs4;
362
+ gunichar2 *utf16;
363
+ glong len, items_written;
364
+ GError *error = NULL;
365
+
366
+ utf16 = (gunichar2 *)StringValueCStr(rb_utf16);
367
+ len = RSTRING_LEN(rb_utf16) / sizeof(*utf16);
368
+
369
+ ucs4 = g_utf16_to_ucs4(utf16, len, NULL, &items_written, &error);
370
+
371
+ if (error)
372
+ RAISE_GERROR(error);
373
+
374
+ result = rb_str_new((char *)ucs4, items_written * sizeof(*ucs4));
375
+ g_free(ucs4);
376
+ return result;
377
+ }
378
+
379
+ static VALUE
380
+ rbglib_m_utf16_to_utf8(VALUE self, VALUE rb_utf16)
381
+ {
382
+ VALUE result;
383
+ gchar *utf8;
384
+ gunichar2 *utf16;
385
+ glong len, items_written;
386
+ GError *error = NULL;
387
+
388
+ utf16 = (gunichar2 *)StringValueCStr(rb_utf16);
389
+ len = RSTRING_LEN(rb_utf16) / sizeof(*utf16);
390
+
391
+ utf8 = g_utf16_to_utf8(utf16, len, NULL, &items_written, &error);
392
+
393
+ if (error)
394
+ RAISE_GERROR(error);
395
+
396
+ result = rb_str_new(utf8, items_written * sizeof(*utf8));
397
+ g_free(utf8);
398
+ return result;
399
+ }
400
+
401
+ static VALUE
402
+ rbglib_m_ucs4_to_utf16(VALUE self, VALUE rb_ucs4)
403
+ {
404
+ VALUE result;
405
+ gunichar *ucs4;
406
+ gunichar2 *utf16;
407
+ glong len, items_written;
408
+ GError *error = NULL;
409
+
410
+ ucs4 = (gunichar *)StringValuePtr(rb_ucs4);
411
+ len = RSTRING_LEN(rb_ucs4) / sizeof(*ucs4);
412
+
413
+ utf16 = g_ucs4_to_utf16(ucs4, len, NULL, &items_written, &error);
414
+
415
+ if (error)
416
+ RAISE_GERROR(error);
417
+
418
+ result = rb_str_new((char *)utf16, items_written * sizeof(*utf16));
419
+ g_free(utf16);
420
+ return result;
421
+ }
422
+
423
+ static VALUE
424
+ rbglib_m_ucs4_to_utf8(VALUE self, VALUE rb_ucs4)
425
+ {
426
+ VALUE result;
427
+ gunichar *ucs4;
428
+ gchar *utf8;
429
+ glong len, items_written;
430
+ GError *error = NULL;
431
+
432
+ ucs4 = (gunichar *)StringValuePtr(rb_ucs4);
433
+ len = RSTRING_LEN(rb_ucs4) / sizeof(*ucs4);
434
+
435
+ utf8 = g_ucs4_to_utf8(ucs4, len, NULL, &items_written, &error);
436
+
437
+ if (error)
438
+ RAISE_GERROR(error);
439
+
440
+ result = rb_str_new(utf8, items_written);
441
+ g_free(utf8);
442
+ return result;
443
+ }
444
+
445
+ static VALUE
446
+ rbglib_m_unichar_to_utf8(VALUE self, VALUE unichar)
447
+ {
448
+ gchar utf8[6];
449
+ gint len;
450
+
451
+ len = g_unichar_to_utf8(NUM2UINT(unichar), utf8);
452
+ return rb_str_new(utf8, len);
453
+ }
454
+
455
+ void
456
+ Init_glib_unicode(void)
457
+ {
458
+ VALUE mGLibUniChar, mGLibUnicode, mGLibUTF8, mGLibUTF16, mGLibUCS4;
459
+
460
+ mGLibUniChar = rb_define_module_under(mGLib, "UniChar");
461
+ mGLibUnicode = rb_define_module_under(mGLib, "Unicode");
462
+ mGLibUTF8 = rb_define_module_under(mGLib, "UTF8");
463
+ mGLibUTF16 = rb_define_module_under(mGLib, "UTF16");
464
+ mGLibUCS4 = rb_define_module_under(mGLib, "UCS4");
465
+
466
+ /* GUnicodeType */
467
+ G_DEF_CLASS(G_TYPE_UNICODE_TYPE, "Type", mGLibUnicode);
468
+ G_DEF_CONSTANTS(mGLibUnicode, G_TYPE_UNICODE_TYPE, "G_UNICODE_");
469
+ /* GUnicodeBreakType */
470
+ G_DEF_CLASS(G_TYPE_UNICODE_BREAK_TYPE, "BreakType", mGLibUnicode);
471
+ G_DEF_CONSTANTS(mGLibUnicode, G_TYPE_UNICODE_BREAK_TYPE, "G_UNICODE_");
472
+
473
+ #if GLIB_CHECK_VERSION(2,14,0)
474
+ /* GUnicodeScript */
475
+ G_DEF_CLASS(G_TYPE_UNICODE_SCRIPT, "Script", mGLibUnicode);
476
+ G_DEF_CONSTANTS(mGLibUnicode, G_TYPE_UNICODE_SCRIPT, "G_UNICODE_");
477
+ #endif
478
+
479
+ G_DEF_CLASS(G_TYPE_NORMALIZE_MODE, "NormalizeMode", mGLib);
480
+
481
+ rb_define_module_function(mGLib, "charset", rbglib_m_charset, 0);
482
+
483
+ rb_define_module_function(mGLibUniChar, "alnum?",
484
+ rbglib_m_unichar_isalnum, 1);
485
+ rb_define_module_function(mGLibUniChar, "alpha?",
486
+ rbglib_m_unichar_isalpha, 1);
487
+ rb_define_module_function(mGLibUniChar, "cntrl?",
488
+ rbglib_m_unichar_iscntrl, 1);
489
+ rb_define_module_function(mGLibUniChar, "digit?",
490
+ rbglib_m_unichar_isdigit, 1);
491
+ rb_define_module_function(mGLibUniChar, "graph?",
492
+ rbglib_m_unichar_isgraph, 1);
493
+ rb_define_module_function(mGLibUniChar, "lower?",
494
+ rbglib_m_unichar_islower, 1);
495
+ rb_define_module_function(mGLibUniChar, "print?",
496
+ rbglib_m_unichar_isprint, 1);
497
+ rb_define_module_function(mGLibUniChar, "punct?",
498
+ rbglib_m_unichar_ispunct, 1);
499
+ rb_define_module_function(mGLibUniChar, "space?",
500
+ rbglib_m_unichar_isspace, 1);
501
+ rb_define_module_function(mGLibUniChar, "upper?",
502
+ rbglib_m_unichar_isupper, 1);
503
+ rb_define_module_function(mGLibUniChar, "xdigit?",
504
+ rbglib_m_unichar_isxdigit, 1);
505
+ rb_define_module_function(mGLibUniChar, "title?",
506
+ rbglib_m_unichar_istitle, 1);
507
+ rb_define_module_function(mGLibUniChar, "defined?",
508
+ rbglib_m_unichar_isdefined, 1);
509
+ rb_define_module_function(mGLibUniChar, "wide?",
510
+ rbglib_m_unichar_iswide, 1);
511
+ #if GLIB_CHECK_VERSION(2,12,0)
512
+ rb_define_module_function(mGLibUniChar, "wide_cjk?",
513
+ rbglib_m_unichar_iswide_cjk, 1);
514
+ #endif
515
+
516
+ rb_define_module_function(mGLibUniChar, "to_upper",
517
+ rbglib_m_unichar_toupper, 1);
518
+ rb_define_module_function(mGLibUniChar, "to_lower",
519
+ rbglib_m_unichar_tolower, 1);
520
+ rb_define_module_function(mGLibUniChar, "to_title",
521
+ rbglib_m_unichar_totitle, 1);
522
+
523
+ rb_define_module_function(mGLibUniChar, "digit_value",
524
+ rbglib_m_unichar_digit_value, 1);
525
+ rb_define_module_function(mGLibUniChar, "xdigit_value",
526
+ rbglib_m_unichar_xdigit_value, 1);
527
+
528
+ rb_define_module_function(mGLibUniChar, "type", rbglib_m_unichar_type, 1);
529
+ rb_define_module_function(mGLibUniChar, "break_type",
530
+ rbglib_m_unichar_break_type, 1);
531
+
532
+ rb_define_singleton_method(mGLibUnicode, "canonical_ordering",
533
+ rbglib_m_unicode_canonical_ordering, 1);
534
+ rb_define_singleton_method(mGLibUnicode, "canonical_decomposition",
535
+ rbglib_m_unicode_canonical_decomposition, 1);
536
+
537
+ #if GLIB_CHECK_VERSION(2,4,0)
538
+ rb_define_module_function(mGLibUniChar, "get_mirror_char",
539
+ rbglib_m_unichar_get_mirror_char, 1);
540
+ #endif
541
+
542
+ #if GLIB_CHECK_VERSION(2,14,0)
543
+ rb_define_module_function(mGLibUniChar, "combining_class",
544
+ rbglib_m_unichar_combining_class, 1);
545
+ rb_define_module_function(mGLibUniChar, "get_script",
546
+ rbglib_m_unichar_get_script, 1);
547
+ rb_define_module_function(mGLibUniChar, "mark?",
548
+ rbglib_m_unichar_ismark, 1);
549
+ rb_define_module_function(mGLibUniChar, "zero_width?",
550
+ rbglib_m_unichar_iszerowidth, 1);
551
+ #endif
552
+
553
+ /*
554
+ Not implemented.
555
+ g_utf8_next_char
556
+ */
557
+ rb_define_module_function(mGLibUTF8, "get_char",
558
+ rbglib_m_utf8_get_char, -1);
559
+ /*
560
+ Not implemented.
561
+ g_utf8_offset_to_pointer
562
+ g_utf8_pointer_to_offset
563
+ g_utf8_prev_char
564
+ g_utf8_find_next_char
565
+ g_utf8_find_prev_char
566
+ g_utf8_prev_char
567
+ */
568
+ rb_define_module_function(mGLibUTF8, "size", rbglib_m_utf8_strlen, 1);
569
+ /*
570
+ Not implemented.
571
+ g_utf8_strncpy
572
+ g_utf8_strrchr
573
+ */
574
+ rb_define_module_function(mGLibUTF8, "reverse",
575
+ rbglib_m_utf8_strreverse, 1);
576
+ rb_define_module_function(mGLibUTF8, "validate",
577
+ rbglib_m_utf8_validate, 1);
578
+
579
+ rb_define_module_function(mGLibUTF8, "upcase",
580
+ rbglib_m_utf8_strup, 1);
581
+ rb_define_module_function(mGLibUTF8, "downcase",
582
+ rbglib_m_utf8_strdown, 1);
583
+ rb_define_module_function(mGLibUTF8, "casefold",
584
+ rbglib_m_utf8_casefold, 1);
585
+
586
+ rb_define_module_function(mGLibUTF8, "normalize",
587
+ rbglib_m_utf8_normalize, -1);
588
+
589
+ rb_define_module_function(mGLibUTF8, "collate",
590
+ rbglib_m_utf8_collate, 2);
591
+ rb_define_module_function(mGLibUTF8, "collate_key",
592
+ rbglib_m_utf8_collate_key, -1);
593
+
594
+ rb_define_module_function(mGLibUTF8, "to_utf16",
595
+ rbglib_m_utf8_to_utf16, 1);
596
+ rb_define_module_function(mGLibUTF8, "to_ucs4",
597
+ rbglib_m_utf8_to_ucs4, -1);
598
+
599
+ rb_define_module_function(mGLibUTF16, "to_ucs4",
600
+ rbglib_m_utf16_to_ucs4, 1);
601
+ rb_define_module_function(mGLibUTF16, "to_utf8",
602
+ rbglib_m_utf16_to_utf8, 1);
603
+
604
+ rb_define_module_function(mGLibUCS4, "to_utf16",
605
+ rbglib_m_ucs4_to_utf16, 1);
606
+ rb_define_module_function(mGLibUCS4, "to_utf8",
607
+ rbglib_m_ucs4_to_utf8, 1);
608
+
609
+ rb_define_module_function(mGLibUniChar, "to_utf8",
610
+ rbglib_m_unichar_to_utf8, 1);
611
+ }