glib2 3.5.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/ext/glib2/extconf.rb +4 -3
  3. data/ext/glib2/glib2.def +6 -0
  4. data/ext/glib2/rbglib-bytes.c +1 -1
  5. data/ext/glib2/rbglib-gc.c +1 -1
  6. data/ext/glib2/rbglib-variant-type.c +1 -1
  7. data/ext/glib2/rbglib-variant.c +75 -2
  8. data/ext/glib2/rbglib.c +25 -59
  9. data/ext/glib2/rbglib.h +16 -3
  10. data/ext/glib2/rbglib_bookmarkfile.c +3 -2
  11. data/ext/glib2/rbglib_convert.c +2 -2
  12. data/ext/glib2/rbglib_datetime.c +14 -3
  13. data/ext/glib2/rbglib_error.c +2 -2
  14. data/ext/glib2/rbglib_fileutils.c +2 -2
  15. data/ext/glib2/rbglib_gettext.c +1 -1
  16. data/ext/glib2/rbglib_i18n.c +2 -2
  17. data/ext/glib2/rbglib_io_constants.c +1 -1
  18. data/ext/glib2/rbglib_iochannel.c +2 -2
  19. data/ext/glib2/rbglib_iochannel_win32_socket.c +2 -2
  20. data/ext/glib2/rbglib_iochannelerror.c +1 -1
  21. data/ext/glib2/rbglib_keyfile.c +2 -2
  22. data/ext/glib2/rbglib_maincontext.c +6 -6
  23. data/ext/glib2/rbglib_mainloop.c +1 -1
  24. data/ext/glib2/rbglib_matchinfo.c +1 -1
  25. data/ext/glib2/rbglib_messages.c +1 -1
  26. data/ext/glib2/rbglib_pollfd.c +1 -1
  27. data/ext/glib2/rbglib_regex.c +3 -3
  28. data/ext/glib2/rbglib_shell.c +1 -1
  29. data/ext/glib2/rbglib_shellerror.c +1 -1
  30. data/ext/glib2/rbglib_source.c +1 -1
  31. data/ext/glib2/rbglib_spawn.c +1 -1
  32. data/ext/glib2/rbglib_spawnerror.c +1 -1
  33. data/ext/glib2/rbglib_threads.c +1 -1
  34. data/ext/glib2/rbglib_timer.c +1 -1
  35. data/ext/glib2/rbglib_timezone.c +1 -1
  36. data/ext/glib2/rbglib_ucs4.c +1 -1
  37. data/ext/glib2/rbglib_unichar.c +1 -1
  38. data/ext/glib2/rbglib_unicode.c +3 -3
  39. data/ext/glib2/rbglib_utf16.c +1 -1
  40. data/ext/glib2/rbglib_utf8.c +1 -1
  41. data/ext/glib2/rbglib_utils.c +1 -1
  42. data/ext/glib2/rbglib_win32.c +3 -3
  43. data/ext/glib2/rbgobj_binding.c +1 -1
  44. data/ext/glib2/rbgobj_boxed.c +1 -1
  45. data/ext/glib2/rbgobj_closure.c +76 -85
  46. data/ext/glib2/rbgobj_enums.c +1 -1
  47. data/ext/glib2/rbgobj_flags.c +1 -1
  48. data/ext/glib2/rbgobj_object.c +32 -5
  49. data/ext/glib2/rbgobj_param.c +1 -1
  50. data/ext/glib2/rbgobj_signal.c +63 -19
  51. data/ext/glib2/rbgobj_type.c +2 -2
  52. data/ext/glib2/rbgobj_typeinstance.c +1 -1
  53. data/ext/glib2/rbgobj_typeinterface.c +4 -4
  54. data/ext/glib2/rbgobj_typemodule.c +1 -1
  55. data/ext/glib2/rbgobj_typeplugin.c +1 -1
  56. data/ext/glib2/rbgobj_value.c +1 -1
  57. data/ext/glib2/rbgobj_valuetypes.c +14 -4
  58. data/ext/glib2/rbgobject.c +7 -21
  59. data/ext/glib2/rbgobject.h +4 -1
  60. data/ext/glib2/rbgprivate.h +7 -4
  61. data/ext/glib2/rbgutil.c +20 -1
  62. data/ext/glib2/rbgutil.h +3 -0
  63. data/ext/glib2/rbgutil_callback.c +7 -7
  64. data/lib/glib2/date-time.rb +35 -0
  65. data/lib/glib2/variant.rb +25 -0
  66. data/lib/glib2.rb +6 -1
  67. data/lib/mkmf-gnome.rb +2 -2
  68. data/test/test-date-time.rb +14 -2
  69. data/test/test-glib2.rb +21 -9
  70. data/test/test-variant.rb +44 -1
  71. metadata +7 -7
  72. data/ext/glib2/glib-enum-types.c +0 -1233
  73. data/ext/glib2/glib-enum-types.h +0 -154
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08fb0595254789a347a4b16d4ca8cdda38ffec0a50533173ce4c6ddefb1f42e2'
4
- data.tar.gz: 2101aee918510ef73cd33955a150f3e42f22d575fbf34b26197a436372b1a262
3
+ metadata.gz: e7d1eb0a21b97c5152d4f792de24a5fc4c12074f1f38e1c0eb220d63e68c1adf
4
+ data.tar.gz: 792084386504df0ca97a1a8dcd0f5c5fae4cc0909ae93daf0699225d1a9bb52a
5
5
  SHA512:
6
- metadata.gz: 753e8d436bb66c430f1d6a6d7787838099eac3f166988761e1cdbfe37f1bf319d6ecaab813ffc3302670be1421763036ebad78e9e70160920cd6872070bd80b7
7
- data.tar.gz: 8d86223f738fc358c40d61491da10946df888cafad626174b2cbae3fb294090099dcd742c6c01b84490dbdbebcc282ba4380f2a49c5e8706d1f5fbb26168ea89
6
+ metadata.gz: 68b6c0da8fac487e6267dfcf77b5695b838a8244702c241032f6a21a180cb7b9e403c642353efbec236d0fd5a2a9ffd6b6d241d85123fcc50038432b95599456
7
+ data.tar.gz: 7f369ff1a891dc192546b6c690ac819ad36610f13c3a69d68897607c41af214fb84d77312229c9c74c7777e9419c0ec06297d1c63939874c7d3e1deef015cf2c
data/ext/glib2/extconf.rb CHANGED
@@ -28,12 +28,13 @@ require "mkmf-gnome"
28
28
 
29
29
  unless required_pkg_config_package([package_id, 2, 12, 0],
30
30
  :alt_linux => "glib2-devel",
31
- :debian => "libglib2.0-dev",
32
- :redhat => "pkgconfig(#{package_id})",
33
31
  :arch_linux => "glib2",
32
+ :debian => "libglib2.0-dev",
33
+ :gentoo_linux => "dev-libs/glib",
34
34
  :homebrew => "glib",
35
35
  :macports => "glib2",
36
- :msys2 => "glib2")
36
+ :msys2 => "glib2",
37
+ :redhat => "pkgconfig(#{package_id})")
37
38
  exit(false)
38
39
  end
39
40
  PKGConfig.have_package('gthread-2.0')
data/ext/glib2/glib2.def CHANGED
@@ -76,11 +76,16 @@ EXPORTS
76
76
  g_rclosure_new
77
77
  g_rclosure_new_call
78
78
  g_rclosure_attach
79
+ g_rclosure_attach_gobject
80
+ g_rclosure_detach
81
+ g_rclosure_detach_gobject
79
82
  g_rclosure_set_tag
80
83
  rbgobj_ruby_value_get_type
81
84
  g_value_get_ruby_value
82
85
  g_value_set_ruby_value
83
86
  g_key_file_get_type
87
+ rbg_mGLib
88
+ rbg_cGLibObject
84
89
  rbg_rval_inspect
85
90
  rbg_string_value_ptr
86
91
  rbg_rval2cstr
@@ -127,6 +132,7 @@ EXPORTS
127
132
  rbg_rval2glist
128
133
  rbg_rval2gslist
129
134
  rbg_define_method
135
+ rbg_define_private_method
130
136
  rbg_define_singleton_method
131
137
  rbg_to_array
132
138
  rbg_to_hash
@@ -122,7 +122,7 @@ rg_pointer(VALUE self)
122
122
  void
123
123
  Init_glib_bytes(void)
124
124
  {
125
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BYTES, "Bytes", mGLib);
125
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BYTES, "Bytes", rbg_mGLib());
126
126
 
127
127
  RG_DEF_SMETHOD(try_convert, 1);
128
128
 
@@ -191,7 +191,7 @@ void
191
191
  Init_glib_gc(void)
192
192
  {
193
193
  VALUE gc_marker = rbg_gc_marker_new_raw();
194
- rb_ivar_set(mGLib, rb_intern("gc_marker"), gc_marker);
194
+ rb_ivar_set(rbg_mGLib(), rb_intern("gc_marker"), gc_marker);
195
195
  TypedData_Get_Struct(gc_marker,
196
196
  RBGGCMarker,
197
197
  &rbg_gc_marker_type,
@@ -234,7 +234,7 @@ rg_element(VALUE self)
234
234
  void
235
235
  Init_glib_variant_type(void)
236
236
  {
237
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_VARIANT_TYPE, "VariantType", mGLib);
237
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_VARIANT_TYPE, "VariantType", rbg_mGLib());
238
238
 
239
239
  RG_DEF_SMETHOD_P(valid, 1);
240
240
  RG_DEF_SMETHOD(scan, 1);
@@ -107,10 +107,53 @@ rg_variant_free(gpointer object)
107
107
  g_variant_unref(variant);
108
108
  }
109
109
 
110
+ static const rb_data_type_t rbg_variant_type = {
111
+ "GLib::Variant",
112
+ {
113
+ NULL,
114
+ rg_variant_free,
115
+ },
116
+ NULL,
117
+ NULL,
118
+ RUBY_TYPED_FREE_IMMEDIATELY,
119
+ };
120
+
110
121
  static VALUE
111
122
  rg_variant_allocate(VALUE klass)
112
123
  {
113
- return Data_Wrap_Struct(klass, NULL, rg_variant_free, NULL);
124
+ return TypedData_Wrap_Struct(klass, &rbg_variant_type, NULL);
125
+ }
126
+
127
+ static VALUE
128
+ rg_s_parse(int argc, VALUE *argv, VALUE klass)
129
+ {
130
+ VALUE rb_text;
131
+ VALUE rb_variant_type;
132
+ rb_scan_args(argc, argv, "11", &rb_text, &rb_variant_type);
133
+ const gchar *text = RVAL2CSTR(rb_text);
134
+ const gchar *limit = text + RSTRING_LEN(rb_text);
135
+ const GVariantType *variant_type = NULL;
136
+ if (!NIL_P(rb_variant_type)) {
137
+ variant_type = RVAL2GVARIANTTYPE(rb_variant_type);
138
+ }
139
+ GError *error = NULL;
140
+ GVariant *variant = g_variant_parse(variant_type,
141
+ text,
142
+ limit,
143
+ NULL,
144
+ &error);
145
+ if (error) {
146
+ GError *detailed_error = NULL;
147
+ gchar *context = g_variant_parse_error_print_context(error, text);
148
+ g_set_error_literal(&detailed_error,
149
+ error->domain,
150
+ error->code,
151
+ context);
152
+ g_free(context);
153
+ g_error_free(error);
154
+ RG_RAISE_ERROR(detailed_error);
155
+ }
156
+ return TypedData_Wrap_Struct(klass, &rbg_variant_type, variant);
114
157
  }
115
158
 
116
159
  static GVariant *
@@ -283,14 +326,44 @@ rg_type(VALUE self)
283
326
  return GVARIANTTYPE2RVAL((GVariantType *)g_variant_get_type(variant));
284
327
  }
285
328
 
329
+ static VALUE
330
+ rg_to_s(int argc, VALUE *argv, VALUE self)
331
+ {
332
+ VALUE options = Qnil;
333
+ gboolean type_annotate = FALSE;
334
+ rb_scan_args(argc, argv, ":", &options);
335
+ if (!NIL_P(options)) {
336
+ ID keywords[1];
337
+ VALUE values[1];
338
+ keywords[0] = rb_intern("type_annotate");
339
+ rb_get_kwargs(options, keywords, 0, 1, values);
340
+ if (values[0] != Qundef) {
341
+ type_annotate = CBOOL2RVAL(values[0]);
342
+ }
343
+ }
344
+
345
+ GVariant *variant = _SELF(self);
346
+ gchar *string = g_variant_print(variant, type_annotate);
347
+ return CSTR2RVAL_FREE(string);
348
+ }
349
+
286
350
  void
287
351
  Init_glib_variant(void)
288
352
  {
289
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_VARIANT, "Variant", mGLib);
353
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_VARIANT, "Variant", rbg_mGLib());
290
354
 
291
355
  rb_define_alloc_func(RG_TARGET_NAMESPACE, rg_variant_allocate);
292
356
 
357
+ RG_DEF_SMETHOD(parse, -1);
358
+
293
359
  RG_DEF_METHOD(initialize, -1);
294
360
  RG_DEF_METHOD(value, 0);
295
361
  RG_DEF_METHOD(type, 0);
362
+ RG_DEF_METHOD(to_s, -1);
363
+
364
+ G_DEF_ERROR(G_VARIANT_PARSE_ERROR,
365
+ "VariantParseError",
366
+ rbg_mGLib(),
367
+ rb_eRuntimeError,
368
+ G_TYPE_VARIANT_PARSE_ERROR);
296
369
  }
data/ext/glib2/rbglib.c CHANGED
@@ -29,6 +29,12 @@ static ID id_inspect;
29
29
 
30
30
  VALUE RG_TARGET_NAMESPACE;
31
31
 
32
+ VALUE
33
+ rbg_mGLib(void)
34
+ {
35
+ return RG_TARGET_NAMESPACE;
36
+ }
37
+
32
38
  const gchar *
33
39
  rbg_rval2cstr(VALUE *str)
34
40
  {
@@ -1067,68 +1073,24 @@ rg_s_os_unix_p(G_GNUC_UNUSED VALUE self)
1067
1073
  #endif
1068
1074
  }
1069
1075
 
1070
- #ifdef _WIN32
1071
- /* Workaround: I don't know why but DllMain() is required with
1072
- * mingw-w64-x86_64-gettext-0.21-1 or later. We don't need DllMain()
1073
- * with mingw-w64-x86_64-gettext-0.19.8.1-10 or earlier.
1074
- *
1075
- * If we don't define DllMain() with mingw-w64-x86_64-gettext-0.21-1
1076
- * or later, we got "The specified procedure could not be found" error
1077
- * when "require 'glib2'" is evaluated.
1078
- *
1079
- * Notes:
1080
- *
1081
- * * This isn't happen when we build glib2 gem (gem install glib2)
1082
- * with mingw-w64-x86_64-gettext-0.19.8.1-10 or earlier and update
1083
- * mingw-w64-x86_64-gettext to 0.21-1 or later. (DllMain() isn't
1084
- * required.) It seems that this is a link time
1085
- * problem. msys64\mingw64\lib\libintl.dll.a may be related. It
1086
- * may require DllMain() with mingw-w64-x86_64-gettext-0.21-1 or
1087
- * later.
1088
- *
1089
- * * libintl.dll is linked with empty source and
1090
- * mingw-w64-x86_64-gettext-0.21-1 or later:
1091
- *
1092
- * void hello(void) {}
1093
- *
1094
- * cc -shared empty.c -o empty.dll -lintl
1095
- *
1096
- * libintl.dll is NOT linked with empty source and
1097
- * mingw-w64-x86_64-gettext-0.19.8-1-10 or earlier.
1098
- *
1099
- * * This isn't happen without Ruby. (At least I couldn't reproduce
1100
- * this without Ruby.)
1101
- *
1102
- * The following program isn't failed:
1103
- *
1104
- * #include <stdio.h>
1105
- * #include <windows.h>
1106
- *
1107
- * int
1108
- * main(void) {
1109
- * HMODULE b = LoadLibrary("empty.dll");
1110
- * if (b) {
1111
- * printf("loaded\n");
1112
- * FreeLibrary(b);
1113
- * } else {
1114
- * printf("failed to load: %d\n", GetLastError());
1115
- * }
1116
- * return 0;
1117
- * }
1118
- */
1119
- BOOL WINAPI
1120
- DllMain(G_GNUC_UNUSED HINSTANCE hinstDLL,
1121
- G_GNUC_UNUSED DWORD fdwReason,
1122
- G_GNUC_UNUSED LPVOID lpvReserved);
1076
+ static VALUE
1077
+ rg_s_malloc(G_GNUC_UNUSED VALUE self, VALUE size)
1078
+ {
1079
+ return POINTER2NUM(g_malloc(NUM2SIZET(size)));
1080
+ }
1123
1081
 
1124
- BOOL WINAPI
1125
- DllMain(G_GNUC_UNUSED HINSTANCE hinstDLL,
1126
- G_GNUC_UNUSED DWORD fdwReason,
1127
- G_GNUC_UNUSED LPVOID lpvReserved)
1082
+ static VALUE
1083
+ rg_s_malloc0(G_GNUC_UNUSED VALUE self, VALUE size)
1128
1084
  {
1129
- return TRUE;
1085
+ return POINTER2NUM(g_malloc0(NUM2SIZET(size)));
1086
+ }
1087
+
1088
+ static VALUE
1089
+ rg_s_free(G_GNUC_UNUSED VALUE self, VALUE address)
1090
+ {
1091
+ g_free(NUM2POINTER(address));
1092
+ return RUBY_Qnil;
1130
1093
  }
1131
- #endif
1132
1094
 
1133
1095
  extern void Init_glib2(void);
1134
1096
 
@@ -1216,6 +1178,10 @@ Init_glib2(void)
1216
1178
  RG_DEF_SMETHOD_P(os_beos, 0);
1217
1179
  RG_DEF_SMETHOD_P(os_unix, 0);
1218
1180
 
1181
+ RG_DEF_SMETHOD(malloc, 1);
1182
+ RG_DEF_SMETHOD(malloc0, 1);
1183
+ RG_DEF_SMETHOD(free, 1);
1184
+
1219
1185
  rb_define_const(RG_TARGET_NAMESPACE, "DIR_SEPARATOR", CSTR2RVAL(G_DIR_SEPARATOR_S));
1220
1186
  rb_define_const(RG_TARGET_NAMESPACE, "SEARCHPATH_SEPARATOR", CSTR2RVAL(G_SEARCHPATH_SEPARATOR_S));
1221
1187
 
data/ext/glib2/rbglib.h CHANGED
@@ -31,9 +31,9 @@
31
31
 
32
32
  G_BEGIN_DECLS
33
33
 
34
- #define RBGLIB_MAJOR_VERSION 3
35
- #define RBGLIB_MINOR_VERSION 5
36
- #define RBGLIB_MICRO_VERSION 1
34
+ #define RBGLIB_MAJOR_VERSION 4
35
+ #define RBGLIB_MINOR_VERSION 0
36
+ #define RBGLIB_MICRO_VERSION 2
37
37
 
38
38
  #ifndef RB_ZALLOC
39
39
  # ifdef ZALLOC
@@ -142,6 +142,14 @@ G_BEGIN_DECLS
142
142
  #define RVAL2POINTER(value) ((gpointer)(value))
143
143
  #define POINTER2RVAL(pointer) ((VALUE)(pointer))
144
144
 
145
+ #if SIZEOF_VOIDP == SIZEOF_LONG
146
+ # define NUM2POINTER(number) ((gpointer)NUM2ULONG(number))
147
+ # define POINTER2NUM(pointer) ULONG2NUM((unsigned long)pointer)
148
+ #else
149
+ # define NUM2POINTER(number) ((gpointer)NUM2ULL(number))
150
+ # define POINTER2NUM(pointer) ULL2NUM((unsigned LONG_LONG)pointer)
151
+ #endif
152
+
145
153
  #define GINTS2RVAL(ary, n) rbg_gints2rval(ary, n)
146
154
  #define GINTS2RVAL_FREE(ary, n) rbg_gints2rval(ary, n)
147
155
 
@@ -165,8 +173,13 @@ G_BEGIN_DECLS
165
173
  # define RUBY_GLIB2_VAR extern
166
174
  #endif
167
175
 
176
+ /* Deprecated. Use rbg_mGLib() instead. */
177
+ G_GNUC_DEPRECATED_FOR(rbg_mGLib())
168
178
  RUBY_GLIB2_VAR VALUE mGLib;
169
179
 
180
+ extern VALUE rbg_mGLib(void);
181
+ extern VALUE rbg_cGLibObject(void);
182
+
170
183
  extern const gchar *rbg_rval_inspect(VALUE object);
171
184
 
172
185
  extern gchar* rbg_string_value_ptr(volatile VALUE* ptr); /* no longer used */
@@ -500,9 +500,10 @@ rg_move_item(VALUE self, VALUE old_uri, VALUE new_uri)
500
500
  void
501
501
  Init_glib_bookmark_file(void)
502
502
  {
503
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BOOKMARK_FILE, "BookmarkFile", mGLib);
503
+ VALUE RG_TARGET_NAMESPACE =
504
+ G_DEF_CLASS(G_TYPE_BOOKMARK_FILE, "BookmarkFile", rbg_mGLib());
504
505
 
505
- G_DEF_ERROR(G_BOOKMARK_FILE_ERROR, "BookmarkFileError", mGLib,
506
+ G_DEF_ERROR(G_BOOKMARK_FILE_ERROR, "BookmarkFileError", rbg_mGLib(),
506
507
  rb_eRuntimeError, G_TYPE_BOOKMARK_FILE_ERROR);
507
508
 
508
509
  RG_DEF_METHOD(initialize, 0);
@@ -23,8 +23,6 @@
23
23
  #include "rbgprivate.h"
24
24
  #include "rbglib.h"
25
25
 
26
- #define RG_TARGET_NAMESPACE mGLib
27
-
28
26
  static VALUE
29
27
  rg_s_convert(G_GNUC_UNUSED VALUE self, VALUE str, VALUE to, VALUE from)
30
28
  {
@@ -171,6 +169,8 @@ rg_s_utf8_validate(G_GNUC_UNUSED VALUE self, VALUE str)
171
169
  void
172
170
  Init_glib_convert(void)
173
171
  {
172
+ VALUE RG_TARGET_NAMESPACE = rbg_mGLib();
173
+
174
174
  VALUE cCharError = G_DEF_ERROR2(G_CONVERT_ERROR, "ConvertError", RG_TARGET_NAMESPACE, rb_eIOError);
175
175
 
176
176
  rb_define_const(cCharError, "NO_CONVERSION", INT2NUM(G_CONVERT_ERROR_NO_CONVERSION));
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2016-2021 Ruby-GNOME Project Team
2
+ * Copyright (C) 2016-2022 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
@@ -53,7 +53,7 @@ is_timezone(VALUE rb_timezone)
53
53
  {
54
54
  VALUE rb_cTimeZone;
55
55
 
56
- rb_cTimeZone = rb_const_get(mGLib, rb_intern("TimeZone"));
56
+ rb_cTimeZone = rb_const_get(rbg_mGLib(), rb_intern("TimeZone"));
57
57
  return RVAL2CBOOL(rb_obj_is_kind_of(rb_timezone, rb_cTimeZone));
58
58
  }
59
59
 
@@ -230,12 +230,20 @@ rg_format(VALUE self, VALUE rb_format)
230
230
  return CSTR2RVAL(g_date_time_format(_SELF(self), format));
231
231
  }
232
232
 
233
+ #if GLIB_CHECK_VERSION(2, 62, 0)
234
+ static VALUE
235
+ rg_format_iso8601(VALUE self)
236
+ {
237
+ return CSTR2RVAL(g_date_time_format_iso8601(_SELF(self)));
238
+ }
239
+ #endif
240
+
233
241
  void
234
242
  Init_glib_date_time(void)
235
243
  {
236
244
  VALUE RG_TARGET_NAMESPACE;
237
245
 
238
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_DATE_TIME, "DateTime", mGLib);
246
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_DATE_TIME, "DateTime", rbg_mGLib());
239
247
 
240
248
  RG_DEF_SMETHOD(now, -1);
241
249
 
@@ -247,4 +255,7 @@ Init_glib_date_time(void)
247
255
  RG_DEF_METHOD(minute, 0);
248
256
  RG_DEF_METHOD(second, 0);
249
257
  RG_DEF_METHOD(format, 1);
258
+ #if GLIB_CHECK_VERSION(2, 62, 0)
259
+ RG_DEF_METHOD(format_iso8601, 0);
260
+ #endif
250
261
  }
@@ -190,12 +190,12 @@ Init_glib_error(void)
190
190
  rb_global_variable(&gerror_table);
191
191
 
192
192
  #define RG_TARGET_NAMESPACE error_info
193
- error_info = rb_define_module_under(mGLib, "ErrorInfo");
193
+ error_info = rb_define_module_under(rbg_mGLib(), "ErrorInfo");
194
194
  rb_define_attr(error_info, "code", TRUE, FALSE);
195
195
  rb_define_attr(error_info, "domain", TRUE, FALSE);
196
196
  RG_DEF_METHOD(initialize, -1);
197
197
 
198
- generic_error = rb_define_class_under(mGLib, "Error", rb_eRuntimeError);
198
+ generic_error = rb_define_class_under(rbg_mGLib(), "Error", rb_eRuntimeError);
199
199
  rb_define_const(generic_error, name_CODE, Qnil);
200
200
  rb_define_const(generic_error, name_DOMAIN, Qnil);
201
201
  rb_include_module(generic_error, error_info);
@@ -71,7 +71,7 @@ rbglib_m_format_size(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
71
71
  void
72
72
  Init_glib_fileutils(void)
73
73
  {
74
- VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_FILE_ERROR, "FileError", mGLib, rb_eIOError);
74
+ VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_FILE_ERROR, "FileError", rbg_mGLib(), rb_eIOError);
75
75
 
76
76
  rb_define_const(RG_TARGET_NAMESPACE, "EXIST", INT2NUM(G_FILE_ERROR_EXIST));
77
77
  rb_define_const(RG_TARGET_NAMESPACE, "ISDIR", INT2NUM(G_FILE_ERROR_ISDIR));
@@ -98,6 +98,6 @@ Init_glib_fileutils(void)
98
98
  rb_define_const(RG_TARGET_NAMESPACE, "PERM", INT2NUM(G_FILE_ERROR_PERM));
99
99
  rb_define_const(RG_TARGET_NAMESPACE, "FAILED", INT2NUM(G_FILE_ERROR_FAILED));
100
100
 
101
- rbg_define_singleton_method(mGLib, "format_size",
101
+ rbg_define_singleton_method(rbg_mGLib(), "format_size",
102
102
  rbglib_m_format_size, -1);
103
103
  }
@@ -43,6 +43,6 @@ Init_glib_gettext(void)
43
43
  {
44
44
  VALUE RG_TARGET_NAMESPACE;
45
45
 
46
- RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "GetText");
46
+ RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "GetText");
47
47
  RG_DEF_SMETHOD(bindtextdomain, -1);
48
48
  }
@@ -24,8 +24,6 @@
24
24
  #undef _
25
25
  #include <glib/gi18n.h>
26
26
 
27
- #define RG_TARGET_NAMESPACE mGLib
28
-
29
27
  static VALUE
30
28
  rg_s_language_names(G_GNUC_UNUSED VALUE self)
31
29
  {
@@ -35,6 +33,8 @@ rg_s_language_names(G_GNUC_UNUSED VALUE self)
35
33
  void
36
34
  Init_glib_i18n(void)
37
35
  {
36
+ VALUE RG_TARGET_NAMESPACE = rbg_mGLib();
37
+
38
38
  /* glib/gi18n.h */
39
39
  RG_DEF_SMETHOD(language_names, 0);
40
40
  }
@@ -23,7 +23,7 @@
23
23
  void
24
24
  Init_glib_io_constants(void)
25
25
  {
26
- VALUE RG_TARGET_NAMESPACE = mGLib;
26
+ VALUE RG_TARGET_NAMESPACE = rbg_mGLib();
27
27
 
28
28
  /* GIOCondition */
29
29
  G_DEF_CLASS(G_TYPE_IO_CONDITION, "IOCondition", RG_TARGET_NAMESPACE);
@@ -777,7 +777,7 @@ rg_print(int argc, VALUE *argv, VALUE out)
777
777
  void
778
778
  Init_glib_io_channel(void)
779
779
  {
780
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_IO_CHANNEL, "IOChannel", mGLib);
780
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_IO_CHANNEL, "IOChannel", rbg_mGLib());
781
781
 
782
782
  rb_include_module(RG_TARGET_NAMESPACE, rb_mEnumerable);
783
783
 
@@ -851,7 +851,7 @@ Init_glib_io_channel(void)
851
851
  rb_define_const(RG_TARGET_NAMESPACE, "FLAG_GET_MASK", INT2NUM(G_IO_FLAG_GET_MASK));
852
852
  rb_define_const(RG_TARGET_NAMESPACE, "FLAG_SET_MASK", INT2NUM(G_IO_FLAG_SET_MASK));
853
853
 
854
- rb_mIOChannelSource = rb_define_module_under(mGLib, "IOChannelSource");
854
+ rb_mIOChannelSource = rb_define_module_under(rbg_mGLib(), "IOChannelSource");
855
855
  rb_define_method(rb_mIOChannelSource,
856
856
  "set_callback",
857
857
  rg_io_channel_source_set_callback,
@@ -47,9 +47,9 @@ Init_glib_io_channel_win32_socket(void)
47
47
  /* GIOWin32Channel */
48
48
  VALUE RG_TARGET_NAMESPACE;
49
49
  RG_TARGET_NAMESPACE =
50
- rb_define_class_under(mGLib,
50
+ rb_define_class_under(rbg_mGLib(),
51
51
  "IOChannelWin32Socket",
52
- rb_const_get(mGLib, rb_intern("IOChannel")));
52
+ rb_const_get(rbg_mGLib(), rb_intern("IOChannel")));
53
53
  RG_DEF_METHOD(initialize, 1);
54
54
  #endif
55
55
  }
@@ -32,7 +32,7 @@ rg_s_from_errno(G_GNUC_UNUSED VALUE self, VALUE errno_)
32
32
  void
33
33
  Init_glib_io_channelerror(void)
34
34
  {
35
- VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_IO_CHANNEL_ERROR, "IOChannelError", mGLib, rb_eIOError);
35
+ VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_IO_CHANNEL_ERROR, "IOChannelError", rbg_mGLib(), rb_eIOError);
36
36
 
37
37
  /* GIOChannelError */
38
38
  RG_DEF_SMETHOD(from_errno, 1);
@@ -631,8 +631,8 @@ rg_remove_comment(VALUE self, VALUE group_name, VALUE key)
631
631
  void
632
632
  Init_glib_keyfile(void)
633
633
  {
634
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_KEY_FILE, "KeyFile", mGLib);
635
- G_DEF_ERROR(G_KEY_FILE_ERROR, "KeyFileError", mGLib,
634
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_KEY_FILE, "KeyFile", rbg_mGLib());
635
+ G_DEF_ERROR(G_KEY_FILE_ERROR, "KeyFileError", rbg_mGLib(),
636
636
  rb_eRuntimeError, G_TYPE_KEY_FILE_ERROR);
637
637
 
638
638
  RG_DEF_METHOD(initialize, 0);
@@ -498,11 +498,11 @@ child_watch_add(VALUE self, VALUE pid)
498
498
  void
499
499
  Init_glib_main_context(void)
500
500
  {
501
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MAIN_CONTEXT, "MainContext", mGLib);
501
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MAIN_CONTEXT, "MainContext", rbg_mGLib());
502
502
 
503
- VALUE timeout = rb_define_module_under(mGLib, "Timeout");
504
- VALUE idle = rb_define_module_under(mGLib, "Idle");
505
- VALUE child_watch = rb_define_module_under(mGLib, "ChildWatch");
503
+ VALUE timeout = rb_define_module_under(rbg_mGLib(), "Timeout");
504
+ VALUE idle = rb_define_module_under(rbg_mGLib(), "Idle");
505
+ VALUE child_watch = rb_define_module_under(rbg_mGLib(), "ChildWatch");
506
506
 
507
507
  id_call = rb_intern("call");
508
508
 
@@ -510,10 +510,10 @@ Init_glib_main_context(void)
510
510
 
511
511
  main_thread = g_thread_self();
512
512
 
513
- rbg_define_singleton_method(mGLib, "set_ruby_thread_priority",
513
+ rbg_define_singleton_method(rbg_mGLib(), "set_ruby_thread_priority",
514
514
  ruby_source_set_priority, 1);
515
515
 
516
- mGLibSource = rb_const_get(mGLib, rb_intern("Source"));
516
+ mGLibSource = rb_const_get(rbg_mGLib(), rb_intern("Source"));
517
517
  rbg_define_singleton_method(mGLibSource, "remove", source_remove, 1);
518
518
  rbg_define_singleton_method(mGLibSource, "current", source_current_source, 0);
519
519
  /*
@@ -119,7 +119,7 @@ rg_context(VALUE self)
119
119
  void
120
120
  Init_glib_main_loop(void)
121
121
  {
122
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MAIN_LOOP, "MainLoop", mGLib);
122
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MAIN_LOOP, "MainLoop", rbg_mGLib());
123
123
 
124
124
  RG_DEF_METHOD(initialize, -1);
125
125
  RG_DEF_METHOD(run, 0);
@@ -163,7 +163,7 @@ Init_glib_matchinfo(void)
163
163
  {
164
164
  VALUE RG_TARGET_NAMESPACE;
165
165
 
166
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MATCH_INFO, "MatchInfo", mGLib);
166
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MATCH_INFO, "MatchInfo", rbg_mGLib());
167
167
  RG_DEF_METHOD(regex, 0);
168
168
  RG_DEF_METHOD(string, 0);
169
169
  RG_DEF_METHOD_P(matches, 0);
@@ -129,7 +129,7 @@ rg_s_log(G_GNUC_UNUSED VALUE self, VALUE domain, VALUE level, VALUE str)
129
129
  void
130
130
  Init_glib_messages(void)
131
131
  {
132
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Log");
132
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "Log");
133
133
 
134
134
  log_canceled = FALSE;
135
135
 
@@ -75,7 +75,7 @@ rg_revents(VALUE self)
75
75
  void
76
76
  Init_glib_poll_fd(void)
77
77
  {
78
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_POLLFD, "PollFD", mGLib);
78
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_POLLFD, "PollFD", rbg_mGLib());
79
79
 
80
80
  RG_DEF_METHOD(initialize, 3);
81
81
 
@@ -459,7 +459,7 @@ rg_s_have_reference_p(G_GNUC_UNUSED VALUE self, VALUE rb_replacement)
459
459
  void
460
460
  Init_glib_regex(void)
461
461
  {
462
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_REGEX, "Regex", mGLib);
462
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_REGEX, "Regex", rbg_mGLib());
463
463
 
464
464
  RG_DEF_METHOD(initialize, -1);
465
465
  RG_DEF_METHOD(pattern, 0);
@@ -479,6 +479,6 @@ Init_glib_regex(void)
479
479
  RG_DEF_SMETHOD(check_replacement, 1);
480
480
  RG_DEF_SMETHOD_P(have_reference, 1);
481
481
 
482
- G_DEF_CLASS(G_TYPE_REGEX_MATCH_FLAGS, "RegexMatchFlags", mGLib);
483
- G_DEF_CLASS(G_TYPE_REGEX_COMPILE_FLAGS, "RegexCompileFlags", mGLib);
482
+ G_DEF_CLASS(G_TYPE_REGEX_MATCH_FLAGS, "RegexMatchFlags", rbg_mGLib());
483
+ G_DEF_CLASS(G_TYPE_REGEX_COMPILE_FLAGS, "RegexCompileFlags", rbg_mGLib());
484
484
  }
@@ -56,7 +56,7 @@ rg_s_unquote(G_GNUC_UNUSED VALUE self, VALUE quoted_string)
56
56
  void
57
57
  Init_glib_shell(void)
58
58
  {
59
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Shell");
59
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "Shell");
60
60
 
61
61
  RG_DEF_SMETHOD(parse, 1);
62
62
  RG_DEF_SMETHOD(quote, 1);
@@ -26,7 +26,7 @@
26
26
  void
27
27
  Init_glib_shellerror(void)
28
28
  {
29
- VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_SHELL_ERROR, "ShellError", mGLib, rb_eRuntimeError);
29
+ VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_SHELL_ERROR, "ShellError", rbg_mGLib(), rb_eRuntimeError);
30
30
 
31
31
  rb_define_const(RG_TARGET_NAMESPACE, "BAD_QUOTING", INT2FIX(G_SHELL_ERROR_BAD_QUOTING));
32
32
  rb_define_const(RG_TARGET_NAMESPACE, "EMPTY_STRING", INT2FIX(G_SHELL_ERROR_EMPTY_STRING));
@@ -177,7 +177,7 @@ gboolean g_source_remove_by_user_data (gpointer user_data);
177
177
  void
178
178
  Init_glib_source(void)
179
179
  {
180
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOURCE, "Source", mGLib);
180
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_SOURCE, "Source", rbg_mGLib());
181
181
 
182
182
  id_call = rb_intern("call");
183
183