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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/Rakefile +6 -4
  4. data/ext/glib2/extconf.rb +1 -5
  5. data/ext/glib2/glib2.def +1 -0
  6. data/ext/glib2/rbglib-bytes.c +1 -5
  7. data/ext/glib2/rbglib-gc.c +98 -52
  8. data/ext/glib2/rbglib-variant-type.c +1 -5
  9. data/ext/glib2/rbglib-variant.c +3 -5
  10. data/ext/glib2/rbglib.c +4 -0
  11. data/ext/glib2/rbglib.h +13 -3
  12. data/ext/glib2/rbglib_bookmarkfile.c +4 -4
  13. data/ext/glib2/rbglib_datetime.c +1 -5
  14. data/ext/glib2/rbglib_error.c +3 -1
  15. data/ext/glib2/rbglib_fileutils.c +1 -17
  16. data/ext/glib2/rbglib_iochannel.c +4 -4
  17. data/ext/glib2/rbglib_keyfile.c +16 -41
  18. data/ext/glib2/rbglib_maincontext.c +6 -32
  19. data/ext/glib2/rbglib_mainloop.c +2 -17
  20. data/ext/glib2/rbglib_matchinfo.c +1 -5
  21. data/ext/glib2/rbglib_pollfd.c +1 -25
  22. data/ext/glib2/rbglib_regex.c +1 -13
  23. data/ext/glib2/rbglib_source.c +1 -39
  24. data/ext/glib2/rbglib_spawn.c +5 -10
  25. data/ext/glib2/rbglib_spawnerror.c +2 -2
  26. data/ext/glib2/rbglib_threads.c +2 -15
  27. data/ext/glib2/rbglib_timezone.c +1 -5
  28. data/ext/glib2/rbglib_unichar.c +46 -5
  29. data/ext/glib2/rbglib_unicode.c +1 -18
  30. data/ext/glib2/rbglib_utils.c +1 -14
  31. data/ext/glib2/rbglib_win32.c +3 -7
  32. data/ext/glib2/rbgobj_binding.c +1 -7
  33. data/ext/glib2/rbgobj_closure.c +22 -9
  34. data/ext/glib2/rbgobj_object.c +113 -104
  35. data/ext/glib2/rbgobj_param.c +2 -8
  36. data/ext/glib2/rbgobj_paramspecs.c +6 -24
  37. data/ext/glib2/rbgobj_signal.c +104 -92
  38. data/ext/glib2/rbgobj_strv.c +2 -2
  39. data/ext/glib2/rbgobj_type.c +58 -68
  40. data/ext/glib2/rbgobj_typeinterface.c +38 -2
  41. data/ext/glib2/rbgobj_value.c +3 -7
  42. data/ext/glib2/rbgobj_valuetypes.c +14 -62
  43. data/ext/glib2/rbgobject.c +4 -6
  44. data/ext/glib2/rbgobject.h +2 -27
  45. data/ext/glib2/rbgprivate.h +6 -6
  46. data/ext/glib2/rbgutil_callback.c +23 -26
  47. data/lib/glib2.rb +32 -3
  48. data/lib/glib2/deprecated.rb +22 -1
  49. data/lib/mkmf-gnome.rb +4 -4
  50. data/test/glib-test-utils.rb +18 -3
  51. data/test/run-test.rb +49 -14
  52. data/test/test-binding.rb +1 -11
  53. data/test/test-bytes.rb +1 -5
  54. data/test/test-date-time.rb +1 -3
  55. data/test/test-file-utils.rb +1 -32
  56. data/test/test-iochannel.rb +3 -5
  57. data/test/test-key-file.rb +5 -6
  58. data/test/test-match-info.rb +1 -5
  59. data/test/test-regex.rb +1 -5
  60. data/test/test-source.rb +1 -14
  61. data/test/test-spawn.rb +2 -1
  62. data/test/test-time-zone.rb +1 -5
  63. data/test/test-timeout.rb +2 -3
  64. data/test/test-unicode.rb +16 -12
  65. data/test/test-utils.rb +2 -8
  66. data/test/test-variant-type.rb +1 -3
  67. data/test/test-win32.rb +6 -6
  68. metadata +3 -7
  69. data/ext/glib2/glib-enum-types.c +0 -1233
  70. data/ext/glib2/glib-enum-types.h +0 -154
  71. data/ext/glib2/rbgobj_valuearray.c +0 -100
  72. data/test/glib-test-init.rb +0 -21
@@ -1,7 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2019 Ruby-GNOME2 Project Team
4
- * Copyright (C) 2004 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2004-2021 Ruby-GNOME Project Team
5
4
  * Copyright (C) 2004 Pascal Terjan
6
5
  *
7
6
  * This library is free software; you can redistribute it and/or
@@ -71,7 +70,6 @@ rg_s_unsetenv(VALUE self, VALUE variable)
71
70
  return self;
72
71
  }
73
72
 
74
- #ifdef HAVE_G_LISTENV
75
73
  static VALUE
76
74
  rg_s_listenv(G_GNUC_UNUSED VALUE self)
77
75
  {
@@ -86,7 +84,6 @@ rg_s_listenv(G_GNUC_UNUSED VALUE self)
86
84
  g_strfreev(c_list);
87
85
  return r_list;
88
86
  }
89
- #endif
90
87
 
91
88
  static VALUE
92
89
  rg_s_host_name(G_GNUC_UNUSED VALUE self)
@@ -136,14 +133,12 @@ rg_s_system_config_dirs(G_GNUC_UNUSED VALUE self)
136
133
  return STRV2RVAL((const gchar **)g_get_system_config_dirs());
137
134
  }
138
135
 
139
- #if GLIB_CHECK_VERSION(2, 14, 0)
140
136
  static VALUE
141
137
  rg_s_get_user_special_dir(G_GNUC_UNUSED VALUE self, VALUE directory)
142
138
  {
143
139
  return CSTR2RVAL(g_get_user_special_dir(RVAL2GENUM(directory,
144
140
  G_TYPE_USER_DIRECTORY)));
145
141
  }
146
- #endif
147
142
 
148
143
  static VALUE
149
144
  rg_s_home_dir(G_GNUC_UNUSED VALUE self)
@@ -288,15 +283,11 @@ void
288
283
  Init_glib_utils(void)
289
284
  {
290
285
  /* glib/gutils.h */
291
- #if GLIB_CHECK_VERSION(2, 14, 0)
292
286
  G_DEF_CLASS(G_TYPE_USER_DIRECTORY, "UserDirectory", RG_TARGET_NAMESPACE);
293
287
  G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_USER_DIRECTORY, "G_");
294
- #endif
295
288
 
296
- #if GLIB_CHECK_VERSION(2, 30, 0)
297
289
  G_DEF_CLASS(G_TYPE_FORMAT_SIZE_FLAGS,
298
290
  "FormatSizeFlags", RG_TARGET_NAMESPACE);
299
- #endif
300
291
 
301
292
  RG_DEF_SMETHOD(application_name, 0);
302
293
  RG_DEF_SMETHOD(set_application_name, 1);
@@ -305,9 +296,7 @@ Init_glib_utils(void)
305
296
  RG_DEF_SMETHOD(getenv, 1);
306
297
  RG_DEF_SMETHOD(setenv, 2);
307
298
  RG_DEF_SMETHOD(unsetenv, 1);
308
- #ifdef HAVE_G_LISTENV
309
299
  RG_DEF_SMETHOD(listenv, 0);
310
- #endif
311
300
  RG_DEF_SMETHOD(host_name, 0);
312
301
  RG_DEF_SMETHOD(user_name, 0);
313
302
  RG_DEF_SMETHOD(real_name, 0);
@@ -317,9 +306,7 @@ Init_glib_utils(void)
317
306
  RG_DEF_SMETHOD(user_config_dir, 0);
318
307
  RG_DEF_SMETHOD(system_data_dirs, 0);
319
308
  RG_DEF_SMETHOD(system_config_dirs, 0);
320
- #if GLIB_CHECK_VERSION(2, 14, 0)
321
309
  RG_DEF_SMETHOD(get_user_special_dir, 1);
322
- #endif
323
310
  RG_DEF_SMETHOD(home_dir, 0);
324
311
  RG_DEF_SMETHOD(tmp_dir, 0);
325
312
  RG_DEF_SMETHOD(current_dir, 0);
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
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
@@ -65,11 +65,10 @@ rbglib_m_win32_locale_filename_from_utf8_deprecated(VALUE self,
65
65
  return rg_s_locale_filename_from_utf8(self, utf8_filename);
66
66
  }
67
67
 
68
- # if GLIB_CHECK_VERSION(2, 16, 0)
69
68
  static VALUE
70
69
  rg_s_get_package_installation_directory_of_module(int argc,
71
- VALUE *argv,
72
- VALUE self)
70
+ VALUE *argv,
71
+ VALUE self)
73
72
  {
74
73
  VALUE rb_module;
75
74
  gchar *directory;
@@ -84,7 +83,6 @@ rg_s_get_package_installation_directory_of_module(int argc,
84
83
  directory = g_win32_get_package_installation_directory_of_module(hmodule);
85
84
  return CSTR2RVAL_FREE(directory);
86
85
  }
87
- # endif
88
86
  #endif
89
87
 
90
88
  void
@@ -105,8 +103,6 @@ Init_glib_win32(void)
105
103
  rbg_define_singleton_method(mGLib, "win32_locale_filename_from_utf8",
106
104
  rbglib_m_win32_locale_filename_from_utf8_deprecated, 1);
107
105
 
108
- # if GLIB_CHECK_VERSION(2, 16, 0)
109
106
  RG_DEF_SMETHOD(get_package_installation_directory_of_module, -1);
110
- # endif
111
107
  #endif
112
108
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2015 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2015-2021 Ruby-GNOME Project Team
4
4
  *
5
5
  * This library is free software; you can redistribute it and/or
6
6
  * modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,6 @@
24
24
 
25
25
  #define _SELF(object) G_BINDING(RVAL2GOBJ(self))
26
26
 
27
- #if GLIB_CHECK_VERSION(2, 38, 0)
28
27
  static VALUE
29
28
  rg_unbind(VALUE self)
30
29
  {
@@ -39,18 +38,13 @@ rg_unbind(VALUE self)
39
38
 
40
39
  return self;
41
40
  }
42
- #endif
43
41
 
44
42
  void
45
43
  Init_gobject_gbinding(void)
46
44
  {
47
- #if GLIB_CHECK_VERSION(2, 26, 0)
48
45
  VALUE RG_TARGET_NAMESPACE;
49
46
 
50
47
  RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BINDING, "Binding", mGLib);
51
- #endif
52
48
 
53
- #if GLIB_CHECK_VERSION(2, 38, 0)
54
49
  RG_DEF_METHOD(unbind, 0);
55
- #endif
56
50
  }
@@ -1,7 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2018 Ruby-GNOME2 Project Team
4
- * Copyright (C) 2002-2006 Ruby-GNOME2 Project
3
+ * Copyright (C) 2002-2021 Ruby-GNOME Project Team
5
4
  * Copyright (C) 2002,2003 Masahiro Sakai
6
5
  *
7
6
  * This library is free software; you can redistribute it and/or
@@ -173,7 +172,7 @@ rclosure_unref(GRClosure *rclosure)
173
172
  g_list_free(rclosure->objects);
174
173
  rclosure->objects = NULL;
175
174
  if (!NIL_P(rclosure->rb_holder)) {
176
- DATA_PTR(rclosure->rb_holder) = NULL;
175
+ RTYPEDDATA_DATA(rclosure->rb_holder) = NULL;
177
176
  rclosure->rb_holder = Qnil;
178
177
  }
179
178
  }
@@ -201,8 +200,10 @@ rclosure_invalidate(G_GNUC_UNUSED gpointer data, GClosure *closure)
201
200
  }
202
201
 
203
202
  static void
204
- gr_closure_holder_mark(GRClosure *rclosure)
203
+ gr_closure_holder_mark(void *data)
205
204
  {
205
+ GRClosure *rclosure = data;
206
+
206
207
  if (!rclosure)
207
208
  return;
208
209
 
@@ -211,8 +212,10 @@ gr_closure_holder_mark(GRClosure *rclosure)
211
212
  }
212
213
 
213
214
  static void
214
- gr_closure_holder_free(GRClosure *rclosure)
215
+ gr_closure_holder_free(void *data)
215
216
  {
217
+ GRClosure *rclosure = data;
218
+
216
219
  if (!rclosure)
217
220
  return;
218
221
 
@@ -225,6 +228,17 @@ gr_closure_holder_free(GRClosure *rclosure)
225
228
  }
226
229
  }
227
230
 
231
+ static const rb_data_type_t rbg_closure_holder_type = {
232
+ "GLib::ClosureHolder",
233
+ {
234
+ gr_closure_holder_mark,
235
+ gr_closure_holder_free,
236
+ },
237
+ NULL,
238
+ NULL,
239
+ RUBY_TYPED_FREE_IMMEDIATELY,
240
+ };
241
+
228
242
  static GClosure *
229
243
  g_rclosure_new_raw(VALUE callback_proc,
230
244
  VALUE extra_args,
@@ -241,10 +255,9 @@ g_rclosure_new_raw(VALUE callback_proc,
241
255
  closure->objects = NULL;
242
256
  closure->callback = callback_proc;
243
257
  closure->extra_args = extra_args;
244
- closure->rb_holder = Data_Wrap_Struct(rb_cData,
245
- gr_closure_holder_mark,
246
- gr_closure_holder_free,
247
- closure);
258
+ closure->rb_holder = TypedData_Wrap_Struct(rb_cObject,
259
+ &rbg_closure_holder_type,
260
+ closure);
248
261
  closure->tag[0] = '\0';
249
262
 
250
263
  g_closure_set_marshal((GClosure*)closure, &rclosure_marshal);
@@ -1,11 +1,10 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2019 Ruby-GNOME Project Team
4
- * Copyright (C) 2002-2004 Ruby-GNOME Project Team
3
+ * Copyright (C) 2002-2021 Ruby-GNOME Project Team
5
4
  * Copyright (C) 2002-2003 Masahiro Sakai
6
- * Copyright (C) 1998-2000 Yukihiro Matsumoto,
7
- * Daisuke Kanda,
8
- * Hiroshi Igarashi
5
+ * Copyright (C) 1998-2000 Yukihiro Matsumoto,
6
+ * Daisuke Kanda,
7
+ * Hiroshi Igarashi
9
8
  *
10
9
  * This library is free software; you can redistribute it and/or
11
10
  * modify it under the terms of the GNU Lesser General Public
@@ -496,140 +495,146 @@ gobj_s_properties(int argc, VALUE* argv, VALUE self)
496
495
  return ary;
497
496
  }
498
497
 
499
- static VALUE type_to_prop_setter_table;
500
- static VALUE type_to_prop_getter_table;
498
+ static GHashTable *rbg_type_to_prop_setter_tables;
499
+ static GMutex rbg_type_to_prop_setter_tables_mutex;
500
+ static GHashTable *rbg_type_to_prop_getter_tables;
501
+ static GMutex rbg_type_to_prop_getter_tables_mutex;
501
502
 
502
- void
503
- rbgobj_register_property_setter(GType gtype, const char *name, RValueToGValueFunc func)
503
+ static void
504
+ rbg_register_property_accessor(GHashTable *tables,
505
+ GMutex *mutex,
506
+ GType gtype,
507
+ const char *name,
508
+ gpointer accessor)
504
509
  {
505
- GObjectClass* oclass;
506
- GParamSpec* pspec;
510
+ g_mutex_lock(mutex);
507
511
 
508
- VALUE table = rb_hash_aref(type_to_prop_setter_table, INT2FIX(gtype));
509
- if (NIL_P(table)){
510
- table = rb_hash_new();
511
- rb_hash_aset(type_to_prop_setter_table, INT2FIX(gtype), table);
512
+ GHashTable *table = g_hash_table_lookup(tables, GUINT_TO_POINTER(gtype));
513
+ if (!table) {
514
+ table = g_hash_table_new(g_str_hash, g_str_equal);
515
+ g_hash_table_insert(tables, GUINT_TO_POINTER(gtype), table);
512
516
  }
513
517
 
514
- oclass = g_type_class_ref(gtype);
515
- pspec = g_object_class_find_property(oclass, name);
516
-
517
- rb_hash_aset(table, CSTR2RVAL(g_param_spec_get_name(pspec)),
518
- Data_Wrap_Struct(rb_cData, NULL, NULL, func));
518
+ GObjectClass *gclass = g_type_class_ref(gtype);
519
+ GParamSpec *pspec = g_object_class_find_property(gclass, name);
520
+ g_hash_table_insert(table,
521
+ (gchar *)g_param_spec_get_name(pspec),
522
+ accessor);
523
+ g_type_class_unref(gclass);
519
524
 
520
- g_type_class_unref(oclass);
525
+ g_mutex_unlock(mutex);
521
526
  }
522
527
 
523
- void
524
- rbgobj_register_property_getter(GType gtype, const char *name, GValueToRValueFunc func)
528
+ static gpointer
529
+ rbg_get_property_accessor(GHashTable *tables,
530
+ GMutex *mutex,
531
+ GType gtype,
532
+ const char *name)
525
533
  {
526
- GObjectClass* oclass;
527
- GParamSpec* pspec;
528
-
529
- VALUE table = rb_hash_aref(type_to_prop_getter_table, INT2FIX(gtype));
530
- if (NIL_P(table)){
531
- table = rb_hash_new();
532
- rb_hash_aset(type_to_prop_getter_table, INT2FIX(gtype), table);
534
+ g_mutex_lock(mutex);
535
+
536
+ gpointer accessor = NULL;
537
+ GHashTable *table = g_hash_table_lookup(tables, GUINT_TO_POINTER(gtype));
538
+ if (table) {
539
+ GObjectClass *gclass = g_type_class_ref(gtype);
540
+ GParamSpec *pspec = g_object_class_find_property(gclass, name);
541
+ accessor = g_hash_table_lookup(table, g_param_spec_get_name(pspec));
542
+ g_type_class_unref(gclass);
533
543
  }
534
544
 
535
- oclass = g_type_class_ref(gtype);
536
- pspec = g_object_class_find_property(oclass, name);
545
+ g_mutex_unlock(mutex);
537
546
 
538
- rb_hash_aset(table, CSTR2RVAL(g_param_spec_get_name(pspec)),
539
- Data_Wrap_Struct(rb_cData, NULL, NULL, func));
547
+ return accessor;
548
+ }
540
549
 
541
- g_type_class_unref(oclass);
550
+ void
551
+ rbgobj_register_property_setter(GType gtype,
552
+ const char *name,
553
+ RValueToGValueFunc func)
554
+ {
555
+ rbg_register_property_accessor(rbg_type_to_prop_setter_tables,
556
+ &rbg_type_to_prop_setter_tables_mutex,
557
+ gtype,
558
+ name,
559
+ func);
560
+ }
561
+
562
+ void
563
+ rbgobj_register_property_getter(GType gtype, const char *name, GValueToRValueFunc func)
564
+ {
565
+ rbg_register_property_accessor(rbg_type_to_prop_getter_tables,
566
+ &rbg_type_to_prop_getter_tables_mutex,
567
+ gtype,
568
+ name,
569
+ func);
542
570
  }
543
571
 
544
572
  static VALUE
545
573
  rg_set_property(VALUE self, VALUE prop_name, VALUE val)
546
574
  {
547
- GParamSpec* pspec;
548
575
  const char* name;
549
-
550
576
  if (SYMBOL_P(prop_name))
551
577
  name = rb_id2name(SYM2ID(prop_name));
552
578
  else
553
579
  name = StringValuePtr(prop_name);
554
580
 
555
- pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(RVAL2GOBJ(self)),
556
- name);
557
-
581
+ GParamSpec* pspec =
582
+ g_object_class_find_property(G_OBJECT_GET_CLASS(RVAL2GOBJ(self)),
583
+ name);
558
584
  if (!pspec)
559
585
  rb_raise(eNoPropertyError, "No such property: %s", name);
560
- else {
561
- // FIXME: use rb_ensure to call g_value_unset()
562
- RValueToGValueFunc setter = NULL;
563
- GValue gval = G_VALUE_INIT;
564
586
 
565
- g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec));
566
-
567
- {
568
- VALUE table = rb_hash_aref(type_to_prop_setter_table,
569
- INT2FIX(pspec->owner_type));
570
- if (!NIL_P(table)){
571
- VALUE obj = rb_hash_aref(table, CSTR2RVAL(g_param_spec_get_name(pspec)));
572
- if (!NIL_P(obj))
573
- Data_Get_Struct(obj, void, setter);
574
- }
575
- }
576
- if (setter) {
577
- setter(val, &gval);
578
- } else {
579
- rbgobj_rvalue_to_gvalue(val, &gval);
580
- }
581
-
582
- g_object_set_property(RVAL2GOBJ(self), name, &gval);
583
- g_value_unset(&gval);
587
+ RValueToGValueFunc setter =
588
+ rbg_get_property_accessor(rbg_type_to_prop_setter_tables,
589
+ &rbg_type_to_prop_setter_tables_mutex,
590
+ pspec->owner_type,
591
+ name);
592
+ // FIXME: use rb_ensure to call g_value_unset()
593
+ GValue gval = G_VALUE_INIT;
594
+ g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec));
595
+ if (setter) {
596
+ setter(val, &gval);
597
+ } else {
598
+ rbgobj_rvalue_to_gvalue(val, &gval);
599
+ }
600
+ g_object_set_property(RVAL2GOBJ(self), name, &gval);
601
+ g_value_unset(&gval);
584
602
 
585
- G_CHILD_SET(self, rb_intern(name), val);
603
+ G_CHILD_SET(self, rb_intern(name), val);
586
604
 
587
- return self;
588
- }
605
+ return self;
589
606
  }
590
607
 
591
608
  static VALUE
592
609
  rg_get_property(VALUE self, VALUE prop_name)
593
610
  {
594
- GParamSpec* pspec;
595
611
  const char* name;
596
-
597
612
  if (SYMBOL_P(prop_name))
598
613
  name = rb_id2name(SYM2ID(prop_name));
599
614
  else
600
615
  name = StringValuePtr(prop_name);
601
616
 
602
- pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(RVAL2GOBJ(self)),
603
- name);
604
-
617
+ GParamSpec *pspec =
618
+ g_object_class_find_property(G_OBJECT_GET_CLASS(RVAL2GOBJ(self)),
619
+ name);
605
620
  if (!pspec)
606
621
  rb_raise(eNoPropertyError, "No such property: %s", name);
607
- else {
608
- // FIXME: use rb_ensure to call g_value_unset()
609
- GValueToRValueFunc getter = NULL;
610
- GValue gval = G_VALUE_INIT;
611
- VALUE ret;
612
-
613
- {
614
- VALUE table = rb_hash_aref(type_to_prop_getter_table,
615
- INT2FIX(pspec->owner_type));
616
- if (!NIL_P(table)){
617
- VALUE obj = rb_hash_aref(table, CSTR2RVAL(g_param_spec_get_name(pspec)));
618
- if (!NIL_P(obj))
619
- Data_Get_Struct(obj, void, getter);
620
- }
621
- }
622
-
623
- g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec));
624
- g_object_get_property(RVAL2GOBJ(self), name, &gval);
625
622
 
626
- ret = getter ? getter(&gval) : GVAL2RVAL(&gval);
627
- g_value_unset(&gval);
628
-
629
- G_CHILD_SET(self, rb_intern(name), ret);
630
-
631
- return ret;
632
- }
623
+ GValueToRValueFunc getter =
624
+ rbg_get_property_accessor(rbg_type_to_prop_getter_tables,
625
+ &rbg_type_to_prop_getter_tables_mutex,
626
+ pspec->owner_type,
627
+ name);
628
+ // FIXME: use rb_ensure to call g_value_unset()
629
+ GValue gval = G_VALUE_INIT;
630
+ g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec));
631
+ g_object_get_property(RVAL2GOBJ(self), name, &gval);
632
+ VALUE ret = getter ? getter(&gval) : GVAL2RVAL(&gval);
633
+ g_value_unset(&gval);
634
+
635
+ G_CHILD_SET(self, rb_intern(name), ret);
636
+
637
+ return ret;
633
638
  }
634
639
 
635
640
  static VALUE rg_thaw_notify(VALUE self);
@@ -714,7 +719,6 @@ rg_type_name(VALUE self)
714
719
  return CSTR2RVAL(G_OBJECT_TYPE_NAME(RVAL2GOBJ(self)));
715
720
  }
716
721
 
717
- #if GLIB_CHECK_VERSION(2, 26, 0)
718
722
  typedef struct {
719
723
  VALUE transform_from_callback;
720
724
  VALUE transform_to_callback;
@@ -843,7 +847,6 @@ rg_bind_property(gint argc, VALUE *argv, VALUE self)
843
847
 
844
848
  return rb_binding;
845
849
  }
846
- #endif
847
850
 
848
851
  static VALUE
849
852
  rg_initialize(int argc, VALUE *argv, VALUE self)
@@ -1090,18 +1093,24 @@ Init_gobject_gobject(void)
1090
1093
  RG_DEF_METHOD(inspect, 0);
1091
1094
  RG_DEF_METHOD(type_name, 0);
1092
1095
 
1093
- #if GLIB_CHECK_VERSION(2, 26, 0)
1094
1096
  RG_DEF_METHOD(bind_property, -1);
1095
1097
  G_DEF_CLASS(G_TYPE_BINDING_FLAGS, "BindingFlags", mGLib);
1096
- #endif
1097
1098
 
1098
1099
  eNoPropertyError = rb_define_class_under(mGLib, "NoPropertyError",
1099
1100
  rb_eNameError);
1100
1101
 
1101
- rb_global_variable(&type_to_prop_setter_table);
1102
- rb_global_variable(&type_to_prop_getter_table);
1103
- type_to_prop_setter_table = rb_hash_new();
1104
- type_to_prop_getter_table = rb_hash_new();
1102
+ rbg_type_to_prop_setter_tables =
1103
+ g_hash_table_new_full(g_direct_hash,
1104
+ g_direct_equal,
1105
+ NULL,
1106
+ (GDestroyNotify)g_hash_table_unref);
1107
+ g_mutex_init(&rbg_type_to_prop_setter_tables_mutex);
1108
+ rbg_type_to_prop_getter_tables =
1109
+ g_hash_table_new_full(g_direct_hash,
1110
+ g_direct_equal,
1111
+ NULL,
1112
+ (GDestroyNotify)g_hash_table_unref);
1113
+ g_mutex_init(&rbg_type_to_prop_getter_tables_mutex);
1105
1114
 
1106
1115
  /* subclass */
1107
1116
  RG_DEF_SMETHOD(type_register, -1);