glib2 3.4.0 → 3.4.5

Sign up to get free protection for your applications and to get access to all the features.
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,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) 2002,2003 Masahiro Sakai
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
@@ -276,7 +276,7 @@ rg_value_convert(int argc, VALUE* argv, VALUE self)
276
276
  rb_scan_args(argc, argv, "21", &src, &src_type, &strict_validation);
277
277
 
278
278
  /* FIXME: use rb_ensure to ensure following g_value_unset() call*/
279
- g_value_init(&src_value, rbgobj_gtype_get(src_type));
279
+ g_value_init(&src_value, rbgobj_gtype_from_ruby(src_type));
280
280
  g_value_init(&dest_value, G_PARAM_SPEC_VALUE_TYPE(pspec));
281
281
 
282
282
  rbgobj_rvalue_to_gvalue(src, &src_value);
@@ -344,9 +344,7 @@ param_is_flag(G_PARAM_LAX_VALIDATION)
344
344
  param_is_flag(G_PARAM_STATIC_NAME)
345
345
  param_is_flag(G_PARAM_STATIC_NICK)
346
346
  param_is_flag(G_PARAM_STATIC_BLURB)
347
- #if GLIB_CHECK_VERSION(2, 42, 0)
348
347
  param_is_flag(G_PARAM_EXPLICIT_NOTIFY)
349
- #endif
350
348
  param_is_flag(G_PARAM_DEPRECATED)
351
349
 
352
350
  /**********************************************************************/
@@ -376,10 +374,8 @@ Init_gobject_gparam(void)
376
374
  INT2FIX(G_PARAM_STATIC_NICK));
377
375
  rb_define_const(RG_TARGET_NAMESPACE, "STATIC_BLURB",
378
376
  INT2FIX(G_PARAM_STATIC_BLURB));
379
- #if GLIB_CHECK_VERSION(2, 42, 0)
380
377
  rb_define_const(RG_TARGET_NAMESPACE, "EXPLICIT_NOTIFY",
381
378
  INT2FIX(G_PARAM_EXPLICIT_NOTIFY));
382
- #endif
383
379
  rb_define_const(RG_TARGET_NAMESPACE, "DEPRECATED",
384
380
  INT2FIX(G_PARAM_DEPRECATED));
385
381
  rb_define_const(RG_TARGET_NAMESPACE, "MASK",
@@ -432,10 +428,8 @@ Init_gobject_gparam(void)
432
428
  param_is_G_PARAM_STATIC_NICK, 0);
433
429
  rbg_define_method(RG_TARGET_NAMESPACE, "static_blurb?",
434
430
  param_is_G_PARAM_STATIC_BLURB, 0);
435
- #if GLIB_CHECK_VERSION(2, 42, 0)
436
431
  rbg_define_method(RG_TARGET_NAMESPACE, "explicit_notify?",
437
432
  param_is_G_PARAM_EXPLICIT_NOTIFY, 0);
438
- #endif
439
433
  rbg_define_method(RG_TARGET_NAMESPACE, "deprecated?",
440
434
  param_is_G_PARAM_DEPRECATED, 0);
441
435
  }
@@ -1,7 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011 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) 2002,2003 Masahiro Sakai
6
5
  *
7
6
  * This library is free software; you can redistribute it and/or
@@ -116,7 +115,7 @@ enum_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
116
115
  VALUE enum_type, VALUE default_value, VALUE flags)
117
116
  {
118
117
  GParamSpec* pspec;
119
- GType gtype = rbgobj_gtype_get(enum_type);
118
+ GType gtype = rbgobj_gtype_from_ruby(enum_type);
120
119
 
121
120
  pspec = g_param_spec_enum(StringValuePtr(name),
122
121
  StringValuePtr(nick),
@@ -133,7 +132,7 @@ flags_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
133
132
  VALUE flags_type, VALUE default_value, VALUE flags)
134
133
  {
135
134
  GParamSpec* pspec;
136
- GType gtype = rbgobj_gtype_get(flags_type);
135
+ GType gtype = rbgobj_gtype_from_ruby(flags_type);
137
136
 
138
137
  pspec = g_param_spec_flags(StringValuePtr(name),
139
138
  StringValuePtr(nick),
@@ -167,7 +166,7 @@ param_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
167
166
  pspec = g_param_spec_param(StringValuePtr(name),
168
167
  StringValuePtr(nick),
169
168
  StringValuePtr(blurb),
170
- rbgobj_gtype_get(param_type),
169
+ rbgobj_gtype_from_ruby(param_type),
171
170
  NUM2UINT(flags));
172
171
  rbgobj_param_spec_initialize(self, pspec);
173
172
  return Qnil;
@@ -181,7 +180,7 @@ boxed_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
181
180
  pspec = g_param_spec_boxed(StringValuePtr(name),
182
181
  StringValuePtr(nick),
183
182
  StringValuePtr(blurb),
184
- rbgobj_gtype_get(boxed_type),
183
+ rbgobj_gtype_from_ruby(boxed_type),
185
184
  NUM2UINT(flags));
186
185
  rbgobj_param_spec_initialize(self, pspec);
187
186
  return Qnil;
@@ -199,20 +198,6 @@ pointer_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, VALUE flags)
199
198
  return Qnil;
200
199
  }
201
200
 
202
- static VALUE
203
- value_array_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
204
- VALUE element_spec, VALUE flags)
205
- {
206
- GParamSpec* pspec;
207
- pspec = g_param_spec_value_array(StringValuePtr(name),
208
- StringValuePtr(nick),
209
- StringValuePtr(blurb),
210
- RVAL2GOBJ(element_spec),
211
- NUM2UINT(flags));
212
- rbgobj_param_spec_initialize(self, pspec);
213
- return Qnil;
214
- }
215
-
216
201
  static VALUE
217
202
  object_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
218
203
  VALUE object_type, VALUE flags)
@@ -221,7 +206,7 @@ object_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
221
206
  pspec = g_param_spec_object(StringValuePtr(name),
222
207
  StringValuePtr(nick),
223
208
  StringValuePtr(blurb),
224
- rbgobj_gtype_get(object_type),
209
+ rbgobj_gtype_from_ruby(object_type),
225
210
  NUM2UINT(flags));
226
211
  rbgobj_param_spec_initialize(self, pspec);
227
212
  return Qnil;
@@ -303,9 +288,6 @@ Init_gobject_gparamspecs(void)
303
288
  c = G_DEF_CLASS(G_TYPE_PARAM_POINTER, "Pointer", cParamSpec);
304
289
  rbg_define_method(c, "initialize", pointer_initialize, 4);
305
290
 
306
- c = G_DEF_CLASS(G_TYPE_PARAM_VALUE_ARRAY, "ValueArray", cParamSpec);
307
- rbg_define_method(c, "initialize", value_array_initialize, 5);
308
-
309
291
  c = G_DEF_CLASS(G_TYPE_PARAM_OBJECT, "Object", cParamSpec);
310
292
  rbg_define_method(c, "initialize", object_initialize, 5);
311
293
  }
@@ -1,7 +1,6 @@
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
5
  *
7
6
  * This library is free software; you can redistribute it and/or
@@ -27,8 +26,6 @@
27
26
  static VALUE RG_TARGET_NAMESPACE;
28
27
  VALUE rbgobj_signal_wrap(guint sig_id);
29
28
 
30
- #define default_handler_method_prefix "signal_do_"
31
-
32
29
  /**********************************************************************/
33
30
 
34
31
  static const rb_data_type_t rg_glib_signal_type = {
@@ -64,45 +61,57 @@ rbgobj_signal_get_raw(VALUE rb_signal)
64
61
  return query;
65
62
  }
66
63
 
67
- static VALUE signal_func_table;
64
+ static GHashTable *rbg_signal_func_table;
65
+ static GMutex rbg_signal_func_table_mutex;
68
66
 
69
67
  void
70
- rbgobj_set_signal_func(VALUE klass, const gchar *sig_name, GValToRValSignalFunc func)
68
+ rbgobj_set_signal_func(VALUE klass,
69
+ const gchar *signal_name,
70
+ GValToRValSignalFunc func)
71
71
  {
72
- VALUE obj = Data_Wrap_Struct(rb_cData, NULL, NULL, func);
73
- guint signal_id = g_signal_lookup(sig_name, CLASS2GTYPE(klass));
74
- rb_hash_aset(signal_func_table, UINT2NUM(signal_id), obj);
72
+ guint signal_id = g_signal_lookup(signal_name, CLASS2GTYPE(klass));
73
+ g_mutex_lock(&rbg_signal_func_table_mutex);
74
+ g_hash_table_insert(rbg_signal_func_table,
75
+ GUINT_TO_POINTER(signal_id),
76
+ func);
77
+ g_mutex_unlock(&rbg_signal_func_table_mutex);
75
78
  }
76
79
 
77
80
  GValToRValSignalFunc
78
81
  rbgobj_get_signal_func(guint signal_id)
79
82
  {
80
- GValToRValSignalFunc func = NULL;
81
- VALUE func_obj = rb_hash_aref(signal_func_table, UINT2NUM(signal_id));
82
- if (!NIL_P(func_obj))
83
- Data_Get_Struct(func_obj, void, func);
83
+ g_mutex_lock(&rbg_signal_func_table_mutex);
84
+ GValToRValSignalFunc func =
85
+ g_hash_table_lookup(rbg_signal_func_table,
86
+ GUINT_TO_POINTER(signal_id));
87
+ g_mutex_unlock(&rbg_signal_func_table_mutex);
84
88
  return func;
85
89
  }
86
90
 
87
- static VALUE signal_call_func_table;
91
+ static GHashTable *rbg_signal_call_func_table;
92
+ static GMutex rbg_signal_call_func_table_mutex;
88
93
 
89
94
  void
90
95
  rbgobj_set_signal_call_func(VALUE klass,
91
96
  const gchar *signal_name,
92
97
  RGClosureCallFunc func)
93
98
  {
94
- VALUE obj = Data_Wrap_Struct(rb_cData, NULL, NULL, func);
95
99
  guint signal_id = g_signal_lookup(signal_name, CLASS2GTYPE(klass));
96
- rb_hash_aset(signal_call_func_table, UINT2NUM(signal_id), obj);
100
+ g_mutex_lock(&rbg_signal_call_func_table_mutex);
101
+ g_hash_table_insert(rbg_signal_call_func_table,
102
+ GUINT_TO_POINTER(signal_id),
103
+ func);
104
+ g_mutex_unlock(&rbg_signal_call_func_table_mutex);
97
105
  }
98
106
 
99
107
  RGClosureCallFunc
100
108
  rbgobj_get_signal_call_func(guint signal_id)
101
109
  {
102
- RGClosureCallFunc func = NULL;
103
- VALUE func_obj = rb_hash_aref(signal_call_func_table, UINT2NUM(signal_id));
104
- if (!NIL_P(func_obj))
105
- Data_Get_Struct(func_obj, void, func);
110
+ g_mutex_lock(&rbg_signal_call_func_table_mutex);
111
+ RGClosureCallFunc func =
112
+ g_hash_table_lookup(rbg_signal_call_func_table,
113
+ GUINT_TO_POINTER(signal_id));
114
+ g_mutex_unlock(&rbg_signal_call_func_table_mutex);
106
115
  return func;
107
116
  }
108
117
 
@@ -150,7 +159,7 @@ rbg_rval2gtypes_body(VALUE value)
150
159
  struct rval2gtypes_args *args = (struct rval2gtypes_args *)value;
151
160
 
152
161
  for (i = 0; i < args->n; i++)
153
- args->result[i] = rbgobj_gtype_get(RARRAY_PTR(args->ary)[i]);
162
+ args->result[i] = rbgobj_gtype_from_ruby(RARRAY_PTR(args->ary)[i]);
154
163
 
155
164
  return Qnil;
156
165
  }
@@ -224,23 +233,16 @@ gobj_s_define_signal(int argc, VALUE* argv, VALUE self)
224
233
  signal_flags = RVAL2GFLAGS(rbsignal_flags, G_TYPE_SIGNAL_FLAGS);
225
234
 
226
235
  {
227
- VALUE rb_method_name;
228
- VALUE proc;
229
- ID method_id;
230
-
231
- rb_method_name =
232
- rb_str_concat(rb_str_new_cstr(default_handler_method_prefix),
233
- rbsignal_name);
234
- method_id = rb_to_id(rb_method_name);
235
-
236
- proc = rb_funcall(mMetaInterface, rb_intern("signal_callback"), 2,
237
- self, ID2SYM(method_id));
238
-
236
+ VALUE proc = rb_funcall(mMetaInterface,
237
+ rb_intern("signal_callback"),
238
+ 2,
239
+ self,
240
+ rbsignal_name);
239
241
  class_closure = g_rclosure_new(proc, Qnil, NULL);
240
- g_rclosure_set_tag(class_closure, RVAL2CSTR(rb_method_name));
242
+ g_rclosure_set_tag(class_closure, RVAL2CSTR(rbsignal_name));
241
243
  }
242
244
 
243
- return_type = rbgobj_gtype_get(rbreturn_type);
245
+ return_type = rbgobj_gtype_from_ruby(rbreturn_type);
244
246
  param_types = RVAL2GTYPES_ACCEPT_NIL(params, n_params);
245
247
 
246
248
  signal = g_signal_newv(signal_name,
@@ -440,30 +442,33 @@ struct emit_arg {
440
442
 
441
443
  GSignalQuery query;
442
444
  GQuark detail;
443
- GValueArray* instance_and_params;
445
+ GArray *instance_and_params;
444
446
  };
445
447
 
446
448
  static VALUE
447
449
  emit_body(VALUE rb_arg)
448
450
  {
449
451
  struct emit_arg *arg = (struct emit_arg *)rb_arg;
450
- GValue param = G_VALUE_INIT;
451
452
 
452
- g_value_init(&param, G_TYPE_FROM_INSTANCE(RVAL2GOBJ(arg->self)));
453
- rbgobj_rvalue_to_gvalue(arg->self, &param);
454
- g_value_array_append(arg->instance_and_params, &param);
455
- g_value_unset(&param);
453
+ gsize value_index = 0;
454
+ GValue *gself = &g_array_index(arg->instance_and_params,
455
+ GValue,
456
+ value_index);
457
+ g_value_init(gself, G_TYPE_FROM_INSTANCE(RVAL2GOBJ(arg->self)));
458
+ rbgobj_rvalue_to_gvalue(arg->self, gself);
459
+ value_index++;
456
460
 
457
461
  {
458
462
  guint i;
459
463
  for (i = 0; i < arg->query.n_params; i++){
460
464
  GType gtype = arg->query.param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE;
461
465
 
462
- g_value_init(&param, gtype);
463
-
464
- rbgobj_rvalue_to_gvalue(rb_ary_entry(arg->args, i), &param);
465
- g_value_array_append(arg->instance_and_params, &param);
466
- g_value_unset(&param);
466
+ GValue *gparam = &g_array_index(arg->instance_and_params,
467
+ GValue,
468
+ value_index);
469
+ g_value_init(gparam, gtype);
470
+ rbgobj_rvalue_to_gvalue(rb_ary_entry(arg->args, i), gparam);
471
+ value_index++;
467
472
  }
468
473
  }
469
474
 
@@ -475,7 +480,7 @@ emit_body(VALUE rb_arg)
475
480
  g_value_init(&return_value,
476
481
  arg->query.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE);
477
482
 
478
- g_signal_emitv(arg->instance_and_params->values,
483
+ g_signal_emitv((GValue *)(arg->instance_and_params->data),
479
484
  arg->query.signal_id, arg->detail,
480
485
  (use_ret) ? &return_value : NULL);
481
486
 
@@ -493,7 +498,7 @@ static VALUE
493
498
  emit_ensure(VALUE rb_arg)
494
499
  {
495
500
  struct emit_arg *arg = (struct emit_arg *)rb_arg;
496
- g_value_array_free(arg->instance_and_params);
501
+ g_array_unref(arg->instance_and_params);
497
502
  return Qnil;
498
503
  }
499
504
 
@@ -525,7 +530,13 @@ gobj_sig_emit(int argc, VALUE *argv, VALUE self)
525
530
  arg.query.n_params + 1);
526
531
 
527
532
  arg.self = self;
528
- arg.instance_and_params = g_value_array_new(1 + arg.query.n_params);
533
+ arg.instance_and_params = g_array_sized_new(FALSE,
534
+ TRUE,
535
+ sizeof(GValue),
536
+ 1 + arg.query.n_params);
537
+ g_array_set_clear_func(arg.instance_and_params,
538
+ (GDestroyNotify)g_value_unset);
539
+ g_array_set_size(arg.instance_and_params, 1 + arg.query.n_params);
529
540
 
530
541
  return rb_ensure(emit_body, (VALUE)&arg, emit_ensure, (VALUE)&arg);
531
542
  }
@@ -628,17 +639,24 @@ static VALUE
628
639
  chain_from_overridden_body(VALUE rb_arg)
629
640
  {
630
641
  struct emit_arg *arg = (struct emit_arg *)rb_arg;
631
- g_value_init(arg->instance_and_params->values,
632
- G_TYPE_FROM_INSTANCE(RVAL2GOBJ(arg->self)));
633
- rbgobj_rvalue_to_gvalue(arg->self, arg->instance_and_params->values);
642
+ gsize value_index = 0;
643
+ GValue *gself = &g_array_index(arg->instance_and_params,
644
+ GValue,
645
+ value_index);
646
+ g_value_init(gself, G_TYPE_FROM_INSTANCE(RVAL2GOBJ(arg->self)));
647
+ rbgobj_rvalue_to_gvalue(arg->self, gself);
648
+ value_index++;
634
649
 
635
650
  {
636
- GValue* params = arg->instance_and_params->values + 1;
637
651
  guint i;
638
652
  for (i = 0; i < arg->query.n_params; i++) {
639
653
  GType gtype = arg->query.param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE;
640
- g_value_init(params + i, gtype);
641
- rbgobj_rvalue_to_gvalue(rb_ary_entry(arg->args, i), params + i);
654
+ GValue *gparam = &g_array_index(arg->instance_and_params,
655
+ GValue,
656
+ value_index);
657
+ g_value_init(gparam, gtype);
658
+ rbgobj_rvalue_to_gvalue(rb_ary_entry(arg->args, i), gparam);
659
+ value_index++;
642
660
  }
643
661
  }
644
662
 
@@ -650,7 +668,7 @@ chain_from_overridden_body(VALUE rb_arg)
650
668
  g_value_init(&return_value,
651
669
  arg->query.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE);
652
670
 
653
- g_signal_chain_from_overridden(arg->instance_and_params->values,
671
+ g_signal_chain_from_overridden((GValue *)(arg->instance_and_params->data),
654
672
  (use_ret) ? &return_value : NULL);
655
673
 
656
674
  if (use_ret) {
@@ -682,46 +700,38 @@ gobj_sig_chain_from_overridden(int argc, VALUE *argv, VALUE self)
682
700
 
683
701
  arg.self = self;
684
702
  arg.args = rb_ary_new4(argc, argv);
685
- arg.instance_and_params = g_value_array_new(1 + argc);
703
+ arg.instance_and_params = g_array_sized_new(FALSE,
704
+ TRUE,
705
+ sizeof(GValue),
706
+ 1 + argc);
707
+ g_array_set_clear_func(arg.instance_and_params,
708
+ (GDestroyNotify)g_value_unset);
709
+ g_array_set_size(arg.instance_and_params, 1 + argc);
686
710
 
687
711
  return rb_ensure(chain_from_overridden_body, (VALUE)&arg,
688
712
  emit_ensure, (VALUE)&arg);
689
713
  }
690
714
 
691
715
  static VALUE
692
- gobj_s_method_added(VALUE klass, VALUE id)
716
+ gobj_s_signal_handler_attach(VALUE klass,
717
+ VALUE rb_signal,
718
+ VALUE rb_handler_name)
693
719
  {
694
- const RGObjClassInfo* cinfo = rbgobj_lookup_class(klass);
695
- const char* name = rb_id2name(SYM2ID(id));
696
- const int prefix_len = strlen(default_handler_method_prefix);
697
- guint signal_id;
698
-
699
- if (cinfo->klass != klass) return Qnil;
700
- if (strncmp(default_handler_method_prefix, name, prefix_len)) return Qnil;
701
-
702
- signal_id = g_signal_lookup(name + prefix_len, cinfo->gtype);
703
- if (!signal_id) return Qnil;
704
-
705
- {
706
- GSignalQuery query;
707
- g_signal_query(signal_id, &query);
708
- if (query.itype == cinfo->gtype)
709
- return Qnil;
710
- }
711
-
712
- {
713
- VALUE proc = rb_funcall(mMetaInterface, rb_intern("signal_callback"), 2,
714
- klass, id);
715
- GClosure* rclosure = g_rclosure_new(proc, Qnil,
716
- rbgobj_get_signal_func(signal_id));
717
- g_rclosure_attach((GClosure *)rclosure, klass);
718
- g_signal_override_class_closure(signal_id, cinfo->gtype, rclosure);
719
- }
720
+ const RGObjClassInfo *cinfo = rbgobj_lookup_class(klass);
721
+ guint signal_id = rbgobj_signal_get_raw(rb_signal)->signal_id;
722
+ VALUE handler_name = RVAL2CSTR(rb_handler_name);
723
+ VALUE proc = rb_block_proc();
724
+ GClosure* rclosure = g_rclosure_new(proc,
725
+ Qnil,
726
+ rbgobj_get_signal_func(signal_id));
727
+ g_rclosure_set_tag(rclosure, handler_name);
728
+ g_rclosure_attach((GClosure *)rclosure, klass);
729
+ g_signal_override_class_closure(signal_id, cinfo->gtype, rclosure);
720
730
 
721
731
  {
722
732
  VALUE mod = rb_define_module_under(klass, RubyGObjectHookModule);
723
733
  rb_include_module(klass, mod);
724
- rbg_define_method(mod, name, gobj_sig_chain_from_overridden, -1);
734
+ rbg_define_method(mod, handler_name, gobj_sig_chain_from_overridden, -1);
725
735
  }
726
736
 
727
737
  return Qnil;
@@ -947,7 +957,7 @@ Init_gobject_gsignal(void)
947
957
  {
948
958
  VALUE cSignalFlags, cSignalMatchType;
949
959
 
950
- RG_TARGET_NAMESPACE = rb_define_class_under(mGLib, "Signal", rb_cData);
960
+ RG_TARGET_NAMESPACE = rb_define_class_under(mGLib, "Signal", rb_cObject);
951
961
 
952
962
  RG_DEF_METHOD(id, 0);
953
963
  RG_DEF_METHOD(name, 0);
@@ -990,11 +1000,11 @@ Init_gobject_gsignal(void)
990
1000
 
991
1001
  eNoSignalError = rb_define_class_under(mGLib, "NoSignalError", rb_eNameError);
992
1002
 
993
- signal_func_table = rb_hash_new();
994
- rb_global_variable(&signal_func_table);
1003
+ rbg_signal_func_table = g_hash_table_new(g_direct_hash, g_direct_equal);
1004
+ g_mutex_init(&rbg_signal_func_table_mutex);
995
1005
 
996
- signal_call_func_table = rb_hash_new();
997
- rb_global_variable(&signal_call_func_table);
1006
+ rbg_signal_call_func_table = g_hash_table_new(g_direct_hash, g_direct_equal);
1007
+ g_mutex_init(&rbg_signal_call_func_table_mutex);
998
1008
 
999
1009
  rbg_define_method(mMetaInterface, "define_signal", gobj_s_define_signal, -1);
1000
1010
  rb_define_alias(mMetaInterface, "signal_new", "define_signal");
@@ -1026,6 +1036,8 @@ Init_gobject_gsignal(void)
1026
1036
  rbg_define_method(cInstantiatable, "signal_handler_is_connected?",
1027
1037
  gobj_sig_handler_is_connected, 1);
1028
1038
 
1029
- rbg_define_singleton_method(cInstantiatable, "method_added",
1030
- gobj_s_method_added, 1);
1039
+ rbg_define_singleton_method(cInstantiatable,
1040
+ "signal_handler_attach",
1041
+ gobj_s_signal_handler_attach,
1042
+ 2);
1031
1043
  }