glib2 3.4.9 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/ext/glib2/extconf.rb +4 -3
  3. data/ext/glib2/glib2.def +5 -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 +79 -5
  8. data/ext/glib2/rbglib.c +30 -1
  9. data/ext/glib2/rbglib.h +17 -4
  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 +26 -18
  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 +2 -2
  45. data/ext/glib2/rbgobj_closure.c +55 -85
  46. data/ext/glib2/rbgobj_enums.c +4 -3
  47. data/ext/glib2/rbgobj_flags.c +2 -2
  48. data/ext/glib2/rbgobj_object.c +33 -6
  49. data/ext/glib2/rbgobj_param.c +2 -2
  50. data/ext/glib2/rbgobj_signal.c +37 -19
  51. data/ext/glib2/rbgobj_type.c +3 -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 +21 -2
  57. data/ext/glib2/rbgobj_valuetypes.c +14 -4
  58. data/ext/glib2/rbgobject.c +7 -21
  59. data/ext/glib2/rbgobject.h +1 -0
  60. data/ext/glib2/rbgprivate.h +11 -4
  61. data/ext/glib2/rbgutil.c +20 -1
  62. data/ext/glib2/rbgutil.h +6 -2
  63. data/ext/glib2/rbgutil_callback.c +14 -8
  64. data/lib/glib2/date-time.rb +35 -0
  65. data/lib/glib2/variant.rb +25 -0
  66. data/lib/glib2.rb +29 -2
  67. data/lib/mkmf-gnome.rb +5 -4
  68. data/test/glib-test-utils.rb +6 -2
  69. data/test/test-date-time.rb +14 -2
  70. data/test/test-glib2.rb +21 -9
  71. data/test/test-spawn.rb +3 -1
  72. data/test/test-variant.rb +44 -1
  73. metadata +8 -8
  74. data/ext/glib2/glib-enum-types.c +0 -1233
  75. data/ext/glib2/glib-enum-types.h +0 -154
@@ -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
 
@@ -217,7 +217,7 @@ rg_s_close_pid(G_GNUC_UNUSED VALUE self, VALUE pid)
217
217
  void
218
218
  Init_glib_spawn(void)
219
219
  {
220
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Spawn");
220
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "Spawn");
221
221
 
222
222
  id_call = rb_intern("call");
223
223
  id_new = rb_intern("new");
@@ -28,7 +28,7 @@
28
28
  void
29
29
  Init_glib_spawnerror(void)
30
30
  {
31
- VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_SPAWN_ERROR, "SpawnError", mGLib, rb_eIOError);
31
+ VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_SPAWN_ERROR, "SpawnError", rbg_mGLib(), rb_eIOError);
32
32
 
33
33
  rb_define_const(RG_TARGET_NAMESPACE, "FORK", INT2NUM(G_SPAWN_ERROR_FORK));
34
34
  rb_define_const(RG_TARGET_NAMESPACE, "READ", INT2NUM(G_SPAWN_ERROR_READ));
@@ -41,7 +41,7 @@ rg_s_supported_p(G_GNUC_UNUSED VALUE self)
41
41
  void
42
42
  Init_glib_threads(void)
43
43
  {
44
- RG_TARGET_NAMESPACE = rb_define_class_under(mGLib, "Thread", rb_cObject);
44
+ RG_TARGET_NAMESPACE = rb_define_class_under(rbg_mGLib(), "Thread", rb_cObject);
45
45
 
46
46
  RG_DEF_SMETHOD(init, 0);
47
47
  RG_DEF_SMETHOD_P(supported, 0);
@@ -116,7 +116,7 @@ rg_reset(VALUE self)
116
116
  void
117
117
  Init_glib_timer(void)
118
118
  {
119
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TIMER, "Timer", mGLib);
119
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TIMER, "Timer", rbg_mGLib());
120
120
 
121
121
  RG_DEF_METHOD(initialize, 0);
122
122
  RG_DEF_METHOD(start, 0);
@@ -73,7 +73,7 @@ void
73
73
  Init_glib_time_zone(void)
74
74
  {
75
75
  VALUE RG_TARGET_NAMESPACE;
76
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TIME_ZONE, "TimeZone", mGLib);
76
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TIME_ZONE, "TimeZone", rbg_mGLib());
77
77
  RG_DEF_METHOD(initialize, -1);
78
78
  RG_DEF_SMETHOD(local, 0);
79
79
  RG_DEF_SMETHOD(utc, 0);
@@ -72,7 +72,7 @@ rg_s_to_utf8(G_GNUC_UNUSED VALUE self, VALUE rb_ucs4)
72
72
  void
73
73
  Init_glib_ucs4(void)
74
74
  {
75
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "UCS4");
75
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "UCS4");
76
76
 
77
77
  RG_DEF_SMETHOD(to_utf16, 1);
78
78
  RG_DEF_SMETHOD(to_utf8, 1);
@@ -185,7 +185,7 @@ rg_s_decompose(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
185
185
  void
186
186
  Init_glib_unichar(void)
187
187
  {
188
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "UniChar");
188
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "UniChar");
189
189
 
190
190
  rbg_define_singleton_method(RG_TARGET_NAMESPACE, "alnum?",
191
191
  rbglib_m_unichar_isalnum, 1);
@@ -52,7 +52,7 @@ rg_s_canonical_ordering(G_GNUC_UNUSED VALUE self, VALUE rb_ucs4)
52
52
  void
53
53
  Init_glib_unicode(void)
54
54
  {
55
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Unicode");
55
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "Unicode");
56
56
 
57
57
  /* GUnicodeType */
58
58
  G_DEF_CLASS(G_TYPE_UNICODE_TYPE, "Type", RG_TARGET_NAMESPACE);
@@ -65,9 +65,9 @@ Init_glib_unicode(void)
65
65
  G_DEF_CLASS(G_TYPE_UNICODE_SCRIPT, "Script", RG_TARGET_NAMESPACE);
66
66
  G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_UNICODE_SCRIPT, "G_UNICODE_");
67
67
 
68
- G_DEF_CLASS(G_TYPE_NORMALIZE_MODE, "NormalizeMode", mGLib);
68
+ G_DEF_CLASS(G_TYPE_NORMALIZE_MODE, "NormalizeMode", rbg_mGLib());
69
69
 
70
- rbg_define_singleton_method(mGLib, "charset", rbglib_m_charset, 0);
70
+ rbg_define_singleton_method(rbg_mGLib(), "charset", rbglib_m_charset, 0);
71
71
 
72
72
  RG_DEF_SMETHOD(canonical_ordering, 1);
73
73
  }
@@ -71,7 +71,7 @@ rg_s_to_utf8(G_GNUC_UNUSED VALUE self, VALUE rb_utf16)
71
71
  void
72
72
  Init_glib_utf16(void)
73
73
  {
74
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "UTF16");
74
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "UTF16");
75
75
 
76
76
  RG_DEF_SMETHOD(to_ucs4, 1);
77
77
  RG_DEF_SMETHOD(to_utf8, 1);
@@ -218,7 +218,7 @@ rg_s_to_ucs4(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
218
218
  void
219
219
  Init_glib_utf8(void)
220
220
  {
221
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "UTF8");
221
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "UTF8");
222
222
 
223
223
  /*
224
224
  Not implemented.
@@ -21,7 +21,7 @@
21
21
 
22
22
  #include "rbgprivate.h"
23
23
 
24
- #define RG_TARGET_NAMESPACE mGLib
24
+ #define RG_TARGET_NAMESPACE rbg_mGLib()
25
25
 
26
26
  static VALUE
27
27
  rg_s_application_name(G_GNUC_UNUSED VALUE self)
@@ -90,17 +90,17 @@ Init_glib_win32(void)
90
90
  {
91
91
  #ifdef G_OS_WIN32
92
92
  /* glib/gwin32.h */
93
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Win32");
93
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "Win32");
94
94
 
95
95
  RG_DEF_SMETHOD(error_message, 1);
96
96
  RG_DEF_SMETHOD(locale, 0);
97
97
  RG_DEF_SMETHOD(version, 0);
98
98
  /* Deprecated */
99
- rbg_define_singleton_method(mGLib, "win32_locale", rbglib_m_win32_locale_deprecated, 0);
99
+ rbg_define_singleton_method(rbg_mGLib(), "win32_locale", rbglib_m_win32_locale_deprecated, 0);
100
100
 
101
101
  RG_DEF_SMETHOD(locale_filename_from_utf8, 1);
102
102
  /* Deprecated */
103
- rbg_define_singleton_method(mGLib, "win32_locale_filename_from_utf8",
103
+ rbg_define_singleton_method(rbg_mGLib(), "win32_locale_filename_from_utf8",
104
104
  rbglib_m_win32_locale_filename_from_utf8_deprecated, 1);
105
105
 
106
106
  RG_DEF_SMETHOD(get_package_installation_directory_of_module, -1);
@@ -44,7 +44,7 @@ Init_gobject_gbinding(void)
44
44
  {
45
45
  VALUE RG_TARGET_NAMESPACE;
46
46
 
47
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BINDING, "Binding", mGLib);
47
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BINDING, "Binding", rbg_mGLib());
48
48
 
49
49
  RG_DEF_METHOD(unbind, 0);
50
50
  }
@@ -60,7 +60,7 @@ static const rb_data_type_t rg_glib_boxed_type = {
60
60
  },
61
61
  NULL,
62
62
  NULL,
63
- RUBY_TYPED_FREE_IMMEDIATELY,
63
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
64
64
  };
65
65
 
66
66
  static boxed_holder *
@@ -302,7 +302,7 @@ boxed_from_ruby(VALUE from, GValue *to)
302
302
  void
303
303
  Init_gobject_gboxed(void)
304
304
  {
305
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BOXED, "Boxed", mGLib);
305
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BOXED, "Boxed", rbg_mGLib());
306
306
 
307
307
  rbgobj_register_g2r_func(G_TYPE_BOXED, boxed_to_ruby);
308
308
  rbgobj_register_r2g_func(G_TYPE_BOXED, boxed_from_ruby);
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2002-2021 Ruby-GNOME Project Team
3
+ * Copyright (C) 2002-2022 Ruby-GNOME Project Team
4
4
  * Copyright (C) 2002,2003 Masahiro Sakai
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
@@ -34,7 +34,6 @@ struct _GRClosure
34
34
  VALUE callback;
35
35
  VALUE extra_args;
36
36
  VALUE rb_holder;
37
- gint count;
38
37
  GList *objects;
39
38
  GValToRValSignalFunc g2r_func;
40
39
  RGClosureCallFunc call_func;
@@ -64,7 +63,7 @@ struct marshal_arg
64
63
  static int
65
64
  rclosure_alive_p(GRClosure *rclosure)
66
65
  {
67
- return (rclosure->count > 0 && !NIL_P(rclosure->rb_holder));
66
+ return !NIL_P(rclosure->rb_holder);
68
67
  }
69
68
 
70
69
  static VALUE
@@ -121,8 +120,8 @@ rclosure_marshal_do(VALUE arg_)
121
120
 
122
121
  ret = rb_apply(callback, id_call, args);
123
122
  } else {
124
- rb_warn("GRClosure invoking callback: already destroyed: %s",
125
- rclosure->tag[0] ? rclosure->tag : "(anonymous)");
123
+ g_warning("GRClosure invoking callback: already destroyed: %s",
124
+ rclosure->tag[0] ? rclosure->tag : "(anonymous)");
126
125
  }
127
126
 
128
127
  if (return_value && G_VALUE_TYPE(return_value))
@@ -159,43 +158,25 @@ rclosure_marshal(GClosure* closure,
159
158
  static void rclosure_weak_notify(gpointer data, GObject* where_the_object_was);
160
159
 
161
160
  static void
162
- rclosure_unref(GRClosure *rclosure)
161
+ rclosure_finalize(G_GNUC_UNUSED gpointer data, GClosure *closure)
163
162
  {
164
- rclosure->count--;
163
+ GRClosure *rclosure = (GRClosure *)closure;
165
164
 
166
- if (!rclosure_alive_p(rclosure)) {
167
- GList *next;
168
- for (next = rclosure->objects; next; next = next->next) {
169
- GObject *object = G_OBJECT(next->data);
170
- g_object_weak_unref(object, rclosure_weak_notify, rclosure);
171
- }
172
- g_list_free(rclosure->objects);
173
- rclosure->objects = NULL;
174
- if (!NIL_P(rclosure->rb_holder)) {
175
- RTYPEDDATA_DATA(rclosure->rb_holder) = NULL;
176
- rclosure->rb_holder = Qnil;
165
+ GList *next;
166
+ for (next = rclosure->objects; next; next = next->next) {
167
+ GObject *object = G_OBJECT(next->data);
168
+ g_object_weak_unref(object, rclosure_weak_notify, rclosure);
169
+ VALUE obj = rbgobj_ruby_object_from_instance2(object, FALSE);
170
+ if (!NIL_P(rclosure->rb_holder) && !NIL_P(obj)) {
171
+ rbgobj_object_remove_relative(obj, rclosure->rb_holder);
177
172
  }
178
173
  }
179
- }
180
-
181
- static void
182
- rclosure_invalidate(G_GNUC_UNUSED gpointer data, GClosure *closure)
183
- {
184
- GRClosure *rclosure = (GRClosure*)closure;
185
-
186
- if (rclosure->count > 0) {
187
- GList *next;
188
-
189
- rclosure->count = 1;
190
- for (next = rclosure->objects; next; next = next->next) {
191
- GObject *object = G_OBJECT(next->data);
192
- VALUE obj = rbgobj_ruby_object_from_instance2(object, FALSE);
193
- if (!NIL_P(rclosure->rb_holder) && !NIL_P(obj)) {
194
- rbgobj_object_remove_relative(obj, rclosure->rb_holder);
195
- }
196
- }
174
+ g_list_free(rclosure->objects);
175
+ rclosure->objects = NULL;
197
176
 
198
- rclosure_unref(rclosure);
177
+ if (!NIL_P(rclosure->rb_holder)) {
178
+ RTYPEDDATA_DATA(rclosure->rb_holder) = NULL;
179
+ rclosure->rb_holder = Qnil;
199
180
  }
200
181
  }
201
182
 
@@ -219,13 +200,7 @@ gr_closure_holder_free(void *data)
219
200
  if (!rclosure)
220
201
  return;
221
202
 
222
- if (rclosure->count > 0) {
223
- rclosure->count = 1;
224
-
225
- /* No need to remove us from the relatives hash of our objects, as
226
- * those aren't alive anymore anyway */
227
- rclosure_unref(rclosure);
228
- }
203
+ g_closure_unref((GClosure *)rclosure);
229
204
  }
230
205
 
231
206
  static const rb_data_type_t rbg_closure_holder_type = {
@@ -236,7 +211,7 @@ static const rb_data_type_t rbg_closure_holder_type = {
236
211
  },
237
212
  NULL,
238
213
  NULL,
239
- RUBY_TYPED_FREE_IMMEDIATELY,
214
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
240
215
  };
241
216
 
242
217
  static GClosure *
@@ -245,26 +220,24 @@ g_rclosure_new_raw(VALUE callback_proc,
245
220
  GValToRValSignalFunc g2r_func,
246
221
  RGClosureCallFunc call_func)
247
222
  {
248
- GRClosure* closure;
249
-
250
- closure = (GRClosure*)g_closure_new_simple(sizeof(GRClosure), NULL);
251
-
252
- closure->count = 1;
253
- closure->g2r_func = g2r_func;
254
- closure->call_func = call_func;
255
- closure->objects = NULL;
256
- closure->callback = callback_proc;
257
- closure->extra_args = extra_args;
258
- closure->rb_holder = TypedData_Wrap_Struct(rb_cObject,
259
- &rbg_closure_holder_type,
260
- closure);
261
- closure->tag[0] = '\0';
262
-
263
- g_closure_set_marshal((GClosure*)closure, &rclosure_marshal);
264
- g_closure_add_invalidate_notifier((GClosure*)closure, NULL,
265
- &rclosure_invalidate);
266
-
267
- return (GClosure*)closure;
223
+ GClosure *closure = g_closure_new_simple(sizeof(GRClosure), NULL);
224
+
225
+ GRClosure *rclosure = (GRClosure *)closure;
226
+
227
+ rclosure->g2r_func = g2r_func;
228
+ rclosure->call_func = call_func;
229
+ rclosure->objects = NULL;
230
+ rclosure->callback = callback_proc;
231
+ rclosure->extra_args = extra_args;
232
+ rclosure->rb_holder = TypedData_Wrap_Struct(rb_cObject,
233
+ &rbg_closure_holder_type,
234
+ rclosure);
235
+ rclosure->tag[0] = '\0';
236
+
237
+ g_closure_set_marshal(closure, &rclosure_marshal);
238
+ g_closure_add_finalize_notifier(closure, NULL, rclosure_finalize);
239
+
240
+ return closure;
268
241
  }
269
242
 
270
243
  GClosure *
@@ -287,34 +260,30 @@ g_rclosure_new_call(VALUE callback_proc,
287
260
  }
288
261
 
289
262
  static void
290
- rclosure_weak_notify(gpointer data, GObject* where_the_object_was)
263
+ rclosure_weak_notify(gpointer data, GObject *where_the_object_was)
291
264
  {
292
265
  GRClosure *rclosure = data;
293
- if (rclosure_alive_p(rclosure)) {
294
- rclosure->objects =
295
- g_list_remove(rclosure->objects, where_the_object_was);
296
- rclosure_unref(rclosure);
297
- }
266
+ rclosure->objects = g_list_remove(rclosure->objects, where_the_object_was);
267
+ g_closure_unref((GClosure *)rclosure);
298
268
  }
299
269
 
300
270
  void
301
271
  g_rclosure_attach(GClosure *closure, VALUE object)
302
272
  {
303
- static VALUE cGLibObject = Qnil;
304
273
  GRClosure *rclosure = (GRClosure *)closure;
305
-
306
274
  rbgobj_add_relative(object, rclosure->rb_holder);
275
+ }
307
276
 
308
- if (NIL_P(cGLibObject)) {
309
- cGLibObject = rb_const_get(mGLib, rb_intern("Object"));
310
- }
311
- if (rb_obj_is_kind_of(object, cGLibObject)) {
312
- GObject *gobject;
313
- gobject = RVAL2GOBJ(object);
314
- rclosure->count++;
315
- g_object_weak_ref(gobject, rclosure_weak_notify, rclosure);
316
- rclosure->objects = g_list_prepend(rclosure->objects, gobject);
317
- }
277
+ void
278
+ g_rclosure_attach_gobject(GClosure *closure, VALUE object)
279
+ {
280
+ GRClosure *rclosure = (GRClosure *)closure;
281
+ g_rclosure_attach(closure, object);
282
+
283
+ GObject *gobject = RVAL2GOBJ(object);
284
+ g_closure_ref(closure);
285
+ g_object_weak_ref(gobject, rclosure_weak_notify, rclosure);
286
+ rclosure->objects = g_list_prepend(rclosure->objects, gobject);
318
287
  }
319
288
 
320
289
  void
@@ -350,8 +319,9 @@ init_rclosure(void)
350
319
  static VALUE
351
320
  rg_initialize(VALUE self)
352
321
  {
353
- GClosure* closure = g_rclosure_new(rb_block_proc(), Qnil, NULL);
322
+ GClosure *closure = g_rclosure_new(rb_block_proc(), Qnil, NULL);
354
323
  G_INITIALIZE(self, closure);
324
+ g_closure_ref(closure);
355
325
  g_closure_sink(closure);
356
326
  return self;
357
327
  }
@@ -387,7 +357,7 @@ Init_gobject_gclosure(void)
387
357
 
388
358
  init_rclosure();
389
359
 
390
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CLOSURE, "Closure", mGLib);
360
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CLOSURE, "Closure", rbg_mGLib());
391
361
 
392
362
  RG_DEF_METHOD(initialize, 0);
393
363
  RG_DEF_METHOD_P(in_marshal, 0);
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2019 Ruby-GNOME Project Team
3
+ * Copyright (C) 2011-2021 Ruby-GNOME Project Team
4
4
  * Copyright (C) 2004-2006 Ruby-GNOME Project Team
5
5
  * Copyright (C) 2002,2003 Masahiro Sakai
6
6
  *
@@ -114,7 +114,7 @@ static const rb_data_type_t rg_glib_enum_type = {
114
114
  },
115
115
  NULL,
116
116
  NULL,
117
- RUBY_TYPED_FREE_IMMEDIATELY,
117
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
118
118
  };
119
119
 
120
120
  static enum_holder *
@@ -191,6 +191,7 @@ rbgobj_init_enum_class(VALUE klass)
191
191
 
192
192
  rb_raw_enum_value = INT2NUM(entry->value);
193
193
  value = rb_funcall(klass, id_new, 1, rb_raw_enum_value);
194
+ rb_obj_freeze(value);
194
195
  rb_hash_aset(values, rb_raw_enum_value, value);
195
196
  const_nick_name = nick_to_const_name(entry->value_nick);
196
197
  if (const_nick_name) {
@@ -412,7 +413,7 @@ Init_gobject_genums(void)
412
413
  id_to_s = rb_intern("to_s");
413
414
  id_values = rb_intern("values");
414
415
 
415
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_ENUM, "Enum", mGLib);
416
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_ENUM, "Enum", rbg_mGLib());
416
417
 
417
418
  rbg_define_singleton_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0);
418
419
  rbg_define_method(RG_TARGET_NAMESPACE, "gtype", generic_gtype, 0);
@@ -83,7 +83,7 @@ static const rb_data_type_t rg_glib_flags_type = {
83
83
  },
84
84
  NULL,
85
85
  NULL,
86
- RUBY_TYPED_FREE_IMMEDIATELY,
86
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
87
87
  };
88
88
 
89
89
  static flags_holder*
@@ -542,7 +542,7 @@ Init_gobject_gflags(void)
542
542
  id_or = rb_intern("|");
543
543
  id_to_i = rb_intern("to_i");
544
544
 
545
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FLAGS, "Flags", mGLib);
545
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FLAGS, "Flags", rbg_mGLib());
546
546
 
547
547
  rbg_define_singleton_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0);
548
548
  rbg_define_method(RG_TARGET_NAMESPACE, "gtype", generic_gtype, 0);
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2002-2021 Ruby-GNOME Project Team
3
+ * Copyright (C) 2002-2022 Ruby-GNOME Project Team
4
4
  * Copyright (C) 2002-2003 Masahiro Sakai
5
5
  * Copyright (C) 1998-2000 Yukihiro Matsumoto,
6
6
  * Daisuke Kanda,
@@ -30,6 +30,12 @@ VALUE RG_TARGET_NAMESPACE;
30
30
  static VALUE eNoPropertyError;
31
31
  static GQuark RUBY_GOBJECT_OBJ_KEY;
32
32
 
33
+ VALUE
34
+ rbg_cGLibObject(void)
35
+ {
36
+ return RG_TARGET_NAMESPACE;
37
+ }
38
+
33
39
  gboolean
34
40
  rbg_is_object(VALUE object)
35
41
  {
@@ -108,7 +114,7 @@ static const rb_data_type_t rg_glib_object_type = {
108
114
  },
109
115
  NULL,
110
116
  NULL,
111
- RUBY_TYPED_FREE_IMMEDIATELY,
117
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
112
118
  };
113
119
 
114
120
  void
@@ -311,6 +317,12 @@ rg_s_new_bang(int argc, VALUE *argv, VALUE self)
311
317
  return result;
312
318
  }
313
319
 
320
+ static VALUE
321
+ rg_s_init(int argc, VALUE *argv, VALUE self)
322
+ {
323
+ return RUBY_Qnil;
324
+ }
325
+
314
326
  struct param_setup_arg {
315
327
  GObjectClass* gclass;
316
328
  GParameter* params;
@@ -872,6 +884,15 @@ rg_initialize(int argc, VALUE *argv, VALUE self)
872
884
  gobj = rbgobj_gobject_new(RVAL2GTYPE(self), params_hash);
873
885
 
874
886
  G_INITIALIZE(self, gobj);
887
+
888
+ rb_funcall(self, rb_intern("initialize_post"), 0);
889
+
890
+ return Qnil;
891
+ }
892
+
893
+ static VALUE
894
+ rg_initialize_post(VALUE self)
895
+ {
875
896
  return Qnil;
876
897
  }
877
898
 
@@ -956,6 +977,9 @@ rbgobj_class_init_func(gpointer g_class, G_GNUC_UNUSED gpointer class_data)
956
977
 
957
978
  g_object_class->set_property = set_prop_func;
958
979
  g_object_class->get_property = get_prop_func;
980
+
981
+ VALUE rb_class = GTYPE2CLASS(G_TYPE_FROM_CLASS(g_class));
982
+ rb_funcall(rb_class, rb_intern("init"), 0);
959
983
  }
960
984
 
961
985
  void
@@ -1062,11 +1086,11 @@ rg_s_type_register(int argc, VALUE *argv, VALUE self)
1062
1086
  void
1063
1087
  Init_gobject_gobject(void)
1064
1088
  {
1065
- RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(G_TYPE_OBJECT, "Object", mGLib,
1089
+ RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(G_TYPE_OBJECT, "Object", rbg_mGLib(),
1066
1090
  gobj_mark, NULL);
1067
1091
 
1068
1092
  #ifdef G_TYPE_INITIALLY_UNOWNED
1069
- G_DEF_CLASS(G_TYPE_INITIALLY_UNOWNED, "InitiallyUnowned", mGLib);
1093
+ G_DEF_CLASS(G_TYPE_INITIALLY_UNOWNED, "InitiallyUnowned", rbg_mGLib());
1070
1094
  #endif
1071
1095
 
1072
1096
  RUBY_GOBJECT_OBJ_KEY = g_quark_from_static_string("__ruby_gobject_object__");
@@ -1074,6 +1098,8 @@ Init_gobject_gobject(void)
1074
1098
  rb_define_alloc_func(RG_TARGET_NAMESPACE, rbgobj_object_alloc_func);
1075
1099
  RG_DEF_SMETHOD_BANG(new, -1);
1076
1100
 
1101
+ RG_DEF_SMETHOD(init, 0);
1102
+
1077
1103
  rbg_define_singleton_method(RG_TARGET_NAMESPACE, "property", &gobj_s_property, 1);
1078
1104
  rbg_define_singleton_method(RG_TARGET_NAMESPACE, "properties", &gobj_s_properties, -1);
1079
1105
  RG_DEF_SMETHOD(install_property, -1);
@@ -1089,6 +1115,7 @@ Init_gobject_gobject(void)
1089
1115
  RG_DEF_METHOD_P(destroyed, 0);
1090
1116
 
1091
1117
  RG_DEF_METHOD(initialize, -1);
1118
+ RG_DEF_PRIVATE_METHOD(initialize_post, 0);
1092
1119
  rbg_define_method(RG_TARGET_NAMESPACE, "ref_count", gobj_ref_count, 0); /* for debugging */
1093
1120
  RG_DEF_METHOD_P(floating, 0); /* for debugging */
1094
1121
  RG_DEF_METHOD(unref, 0);
@@ -1096,9 +1123,9 @@ Init_gobject_gobject(void)
1096
1123
  RG_DEF_METHOD(type_name, 0);
1097
1124
 
1098
1125
  RG_DEF_METHOD(bind_property, -1);
1099
- G_DEF_CLASS(G_TYPE_BINDING_FLAGS, "BindingFlags", mGLib);
1126
+ G_DEF_CLASS(G_TYPE_BINDING_FLAGS, "BindingFlags", rbg_mGLib());
1100
1127
 
1101
- eNoPropertyError = rb_define_class_under(mGLib, "NoPropertyError",
1128
+ eNoPropertyError = rb_define_class_under(rbg_mGLib(), "NoPropertyError",
1102
1129
  rb_eNameError);
1103
1130
 
1104
1131
  rbg_type_to_prop_setter_tables =
@@ -61,7 +61,7 @@ static const rb_data_type_t rg_glib_param_type = {
61
61
  },
62
62
  NULL,
63
63
  NULL,
64
- RUBY_TYPED_FREE_IMMEDIATELY,
64
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
65
65
  };
66
66
 
67
67
  static pspec_holder *
@@ -353,7 +353,7 @@ void
353
353
  Init_gobject_gparam(void)
354
354
  {
355
355
  qparamspec = g_quark_from_static_string("__ruby_gobject_param_spec__");
356
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_PARAM, "Param", mGLib);
356
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_PARAM, "Param", rbg_mGLib());
357
357
 
358
358
  /* GParamFlags */
359
359
  rb_define_const(RG_TARGET_NAMESPACE, "READABLE",