glib2 3.4.9 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c89356959f6eaabab6237b23ed3e3820a0590869d2390ba5d6c6063aafe36fcb
4
- data.tar.gz: 07b367f72d3fe0cda25c855309a960f4d82367b98e2c92bdfe15cfea8dc2060f
3
+ metadata.gz: 135835c6036937932bed291b322562c6df79be9a0ef07610b9b01627fa9449d4
4
+ data.tar.gz: 0a07086fc4c87b2311fb608d2a27eedf3ceb1d9a24c0abc0caa061cfb7eacf1a
5
5
  SHA512:
6
- metadata.gz: 6ba67d05ed39fd2a1e8fa4f4ca4132b67670a1437469479a4904fce4783c73ab0353100bb9ddb416f250881070a68019058c4c1c7b429af959fa05e12e0a1fa1
7
- data.tar.gz: d87db1a676ee3c60e0855c29c567222524a9d14ee788a70af341866dff199ab46f8dfc58ca51c5b8612474df23ea2ad86bf6ec70950804898c88b2268bcde122
6
+ metadata.gz: 4498dc7d5f612602a79519285dc5e026f9f8abd0d74754317ad451399d780749066b38872317edd2ddb08f1b3ecca48ece9b9264ec61c52241d05c6f572c62d2
7
+ data.tar.gz: 3b240df85066aaea0ea91dd0f91b05bef11d74906c3c733549d4aa833fb56c88df88baffd9e20f08339e8371de4d7fbaf55a3b1e75a68a563c29dddf1a1035c5
data/ext/glib2/glib2.def CHANGED
@@ -153,6 +153,7 @@ EXPORTS
153
153
  rbgutil_glibid_r2g_func
154
154
  rbgutil_sym_g2r_func
155
155
  rbgutil_protect
156
+ rbgutil_on_callback_error
156
157
  rbgutil_invoke_callback
157
158
  rbgutil_start_callback_dispatch_thread
158
159
  rbgutil_stop_callback_dispatch_thread
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2015-2021 Ruby-GNOME Project Team
3
+ * Copyright (C) 2015-2022 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
@@ -69,9 +69,10 @@ rbg_variant_to_ruby(GVariant *variant)
69
69
  VALUE value = rbg_variant_to_ruby(val);
70
70
  g_variant_unref(val);
71
71
  return value;
72
- } else if (g_variant_type_is_array(type)) {
72
+ } else if (g_variant_type_is_array(type) ||
73
+ g_variant_type_is_tuple(type)) {
73
74
  gsize i, len = g_variant_n_children(variant);
74
- VALUE ary = rb_ary_new2(len);
75
+ VALUE ary = rb_ary_new_capa(len);
75
76
  for (i = 0; i < len; i++) {
76
77
  GVariant *val = g_variant_get_child_value(variant, i);
77
78
  rb_ary_store(ary, i, rbg_variant_to_ruby(val));
data/ext/glib2/rbglib.h CHANGED
@@ -32,8 +32,8 @@
32
32
  G_BEGIN_DECLS
33
33
 
34
34
  #define RBGLIB_MAJOR_VERSION 3
35
- #define RBGLIB_MINOR_VERSION 4
36
- #define RBGLIB_MICRO_VERSION 9
35
+ #define RBGLIB_MINOR_VERSION 5
36
+ #define RBGLIB_MICRO_VERSION 0
37
37
 
38
38
  #ifndef RB_ZALLOC
39
39
  # ifdef ZALLOC
@@ -23,8 +23,13 @@
23
23
  #include <ctype.h>
24
24
 
25
25
  static ID id_code;
26
+ static ID id_CODE;
27
+ static const char *name_CODE = "CODE";
26
28
  static ID id_domain;
27
- static ID id_code_classes;
29
+ static ID id_DOMAIN;
30
+ static const char *name_DOMAIN = "DOMAIN";
31
+ static ID id_CODE_CLASSES;
32
+ static const char *name_CODE_CLASSES = "CODE_CLASSES";
28
33
  static VALUE gerror_table;
29
34
  static VALUE generic_error;
30
35
  static VALUE error_info;
@@ -44,13 +49,9 @@ rbgerr_gerror2exception(GError *error)
44
49
  exception_klass = rb_hash_aref(gerror_table, UINT2NUM(error->domain));
45
50
  if (NIL_P(exception_klass)) {
46
51
  exception_klass = generic_error;
47
- } else {
48
- VALUE code_class = Qnil;
49
- VALUE code_classes;
50
- code_classes = rb_ivar_get(exception_klass, id_code_classes);
51
- if (!NIL_P(code_classes)) {
52
- code_class = rb_hash_aref(code_classes, INT2NUM(error->code));
53
- }
52
+ } else if (rb_const_defined_at(exception_klass, id_CODE_CLASSES)) {
53
+ VALUE code_classes = rb_const_get(exception_klass, id_CODE_CLASSES);
54
+ VALUE code_class = rb_hash_aref(code_classes, INT2NUM(error->code));
54
55
  if (!NIL_P(code_class)) {
55
56
  exception_klass = code_class;
56
57
  }
@@ -111,16 +112,17 @@ rbgerr_define_gerror(GQuark domain, const gchar *name, VALUE module, VALUE paren
111
112
  VALUE code_classes;
112
113
  VALUE rb_domain = rb_str_new_cstr(g_quark_to_string(domain));
113
114
  rbgutil_string_set_utf8_encoding(rb_domain);
115
+ rb_obj_freeze(rb_domain);
114
116
 
115
117
  error_class = rb_define_class_under(module, name, parent);
116
- rb_ivar_set(error_class, id_code, Qnil);
117
- rb_ivar_set(error_class, id_domain, rb_domain);
118
+ rb_define_const(error_class, name_CODE, Qnil);
119
+ rb_define_const(error_class, name_DOMAIN, rb_domain);
118
120
  rb_prepend_module(error_class, error_info);
119
121
 
120
122
  rb_hash_aset(gerror_table, UINT2NUM(domain), error_class);
121
123
 
122
124
  code_classes = rb_hash_new();
123
- rb_ivar_set(error_class, id_code_classes, code_classes);
125
+ rb_define_const(error_class, name_CODE_CLASSES, code_classes);
124
126
 
125
127
  if (gtype != G_TYPE_INVALID) {
126
128
  GEnumClass* gclass = g_type_class_ref(gtype);
@@ -146,14 +148,16 @@ rbgerr_define_gerror(GQuark domain, const gchar *name, VALUE module, VALUE paren
146
148
  code_class_name,
147
149
  error_class);
148
150
  g_free(code_class_name);
149
- rb_ivar_set(code_class, id_code, INT2NUM(entry->value));
150
- rb_ivar_set(code_class, id_domain, rb_domain);
151
+ rb_define_const(code_class, name_CODE, INT2NUM(entry->value));
152
+ rb_define_const(code_class, name_DOMAIN, rb_domain);
151
153
  rb_hash_aset(code_classes, INT2NUM(entry->value), code_class);
152
154
  }
153
155
 
154
156
  g_type_class_unref(gclass);
155
157
  }
156
158
 
159
+ rb_obj_freeze(code_classes);
160
+
157
161
  return error_class;
158
162
  }
159
163
 
@@ -161,8 +165,8 @@ static VALUE
161
165
  rg_initialize(int argc, VALUE *argv, VALUE self)
162
166
  {
163
167
  VALUE klass = rb_obj_class(self);
164
- rb_ivar_set(self, id_code, rb_ivar_get(klass, id_code));
165
- rb_ivar_set(self, id_domain, rb_ivar_get(klass, id_domain));
168
+ rb_ivar_set(self, id_code, rb_const_get(klass, id_CODE));
169
+ rb_ivar_set(self, id_domain, rb_const_get(klass, id_DOMAIN));
166
170
  return rb_call_super(argc, argv);
167
171
  }
168
172
 
@@ -178,8 +182,10 @@ void
178
182
  Init_glib_error(void)
179
183
  {
180
184
  id_code = rb_intern("@code");
185
+ id_CODE = rb_intern(name_CODE);
181
186
  id_domain = rb_intern("@domain");
182
- id_code_classes = rb_intern("@code_classes");
187
+ id_DOMAIN = rb_intern(name_DOMAIN);
188
+ id_CODE_CLASSES = rb_intern(name_CODE_CLASSES);
183
189
  gerror_table = rb_hash_new();
184
190
  rb_global_variable(&gerror_table);
185
191
 
@@ -190,6 +196,8 @@ Init_glib_error(void)
190
196
  RG_DEF_METHOD(initialize, -1);
191
197
 
192
198
  generic_error = rb_define_class_under(mGLib, "Error", rb_eRuntimeError);
199
+ rb_define_const(generic_error, name_CODE, Qnil);
200
+ rb_define_const(generic_error, name_DOMAIN, Qnil);
193
201
  rb_include_module(generic_error, error_info);
194
202
  }
195
203
 
@@ -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 *
@@ -236,7 +236,7 @@ static const rb_data_type_t rbg_closure_holder_type = {
236
236
  },
237
237
  NULL,
238
238
  NULL,
239
- RUBY_TYPED_FREE_IMMEDIATELY,
239
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
240
240
  };
241
241
 
242
242
  static GClosure *
@@ -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) {
@@ -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*
@@ -108,7 +108,7 @@ static const rb_data_type_t rg_glib_object_type = {
108
108
  },
109
109
  NULL,
110
110
  NULL,
111
- RUBY_TYPED_FREE_IMMEDIATELY,
111
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
112
112
  };
113
113
 
114
114
  void
@@ -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 *
@@ -36,7 +36,7 @@ static const rb_data_type_t rg_glib_signal_type = {
36
36
  },
37
37
  NULL,
38
38
  NULL,
39
- RUBY_TYPED_FREE_IMMEDIATELY,
39
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
40
40
  };
41
41
 
42
42
  VALUE
@@ -974,6 +974,7 @@ static inline void
974
974
  _def_fundamental_type(VALUE ary, GType gtype, const char* name)
975
975
  {
976
976
  VALUE c = rbgobj_gtype_new(gtype);
977
+ rb_obj_freeze(c);
977
978
  rb_define_const(RG_TARGET_NAMESPACE, name, c);
978
979
  rb_ary_push(ary, c);
979
980
  }
@@ -129,6 +129,7 @@ rbgobj_gvalue_to_rvalue(const GValue* value)
129
129
  continue;
130
130
  return func(value);
131
131
  }
132
+ return BOXED2RVAL(g_value_get_boxed(value), type);
132
133
  }
133
134
  case G_TYPE_VARIANT:
134
135
  {
@@ -293,7 +294,24 @@ rbgobj_rvalue_to_gvalue(VALUE val, GValue* result)
293
294
  }
294
295
  case G_TYPE_OBJECT:
295
296
  case G_TYPE_INTERFACE:
296
- g_value_set_object(result, NIL_P(val) ? NULL : RVAL2GOBJ(val));
297
+ if (NIL_P(val)) {
298
+ g_value_set_object(result, NULL);
299
+ } else {
300
+ VALUE value_class = GTYPE2CLASS(type);
301
+ ID id_try_convert;
302
+ CONST_ID(id_try_convert, "try_convert");
303
+ if (!NIL_P(value_class) &&
304
+ rb_respond_to(value_class, id_try_convert)) {
305
+ VALUE converted_value = rb_funcall(value_class,
306
+ id_try_convert,
307
+ 1,
308
+ val);
309
+ if (!NIL_P(converted_value)) {
310
+ val = converted_value;
311
+ }
312
+ }
313
+ g_value_set_object(result, RVAL2GOBJ(val));
314
+ }
297
315
  return;
298
316
  case G_TYPE_PARAM:
299
317
  g_value_set_param(result, NIL_P(val) ? NULL : RVAL2GOBJ(val));
@@ -330,6 +348,7 @@ rbgobj_rvalue_to_gvalue(VALUE val, GValue* result)
330
348
  func(val, result);
331
349
  }
332
350
  }
351
+ break;
333
352
  }
334
353
  }
335
354
 
@@ -43,6 +43,10 @@
43
43
  # define G_VALUE_INIT { 0, { { 0 } } }
44
44
  #endif
45
45
 
46
+ #ifndef RUBY_TYPED_FROZEN_SHAREABLE
47
+ # define RUBY_TYPED_FROZEN_SHAREABLE 0
48
+ #endif
49
+
46
50
  G_BEGIN_DECLS
47
51
 
48
52
  typedef struct {
data/ext/glib2/rbgutil.h CHANGED
@@ -1,7 +1,7 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2015 Ruby-GNOME2 Project Team
4
- * Copyright (C) 2002,2003 Masao Mutoh
3
+ * Copyright (C) 2011-2022 Ruby-GNOME Project Team
4
+ * Copyright (C) 2002,2003 Masao Mutoh
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
7
7
  * modify it under the terms of the GNU Lesser General Public
@@ -92,6 +92,7 @@ extern void rbg_define_singleton_method(VALUE obj, const char *name, VALUE (*fun
92
92
  extern VALUE rbgutil_def_setters(VALUE klass);
93
93
  extern void rbgutil_set_properties(VALUE self, VALUE hash);
94
94
  extern VALUE rbgutil_protect(VALUE (*proc) (VALUE), VALUE data);
95
+ extern void rbgutil_on_callback_error(VALUE error);
95
96
  extern VALUE rbgutil_invoke_callback(VALUE (*func)(VALUE), VALUE arg);
96
97
  extern void rbgutil_start_callback_dispatch_thread(void);
97
98
  extern void rbgutil_stop_callback_dispatch_thread(void);
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2007-2021 Ruby-GNOME Project Team
3
+ * Copyright (C) 2007-2022 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
@@ -49,10 +49,16 @@ rbgutil_protect(VALUE (*func) (VALUE), VALUE data)
49
49
  VALUE ret = rb_protect(func, data, &state);
50
50
  VALUE e = rb_errinfo();
51
51
  if (state && !NIL_P(e))
52
- rb_funcall(mGLib, id_exit_application, 2, e, INT2NUM(EXIT_FAILURE));
52
+ rbgutil_on_callback_error(e);
53
53
  return ret;
54
54
  }
55
55
 
56
+ void
57
+ rbgutil_on_callback_error(VALUE error)
58
+ {
59
+ rb_funcall(mGLib, id_exit_application, 2, error, INT2NUM(EXIT_FAILURE));
60
+ }
61
+
56
62
  /**********************************************************************/
57
63
 
58
64
  #ifdef HAVE_NATIVETHREAD
data/lib/glib2.rb CHANGED
@@ -134,8 +134,30 @@ module GLib
134
134
  class Instantiatable
135
135
  class << self
136
136
  def method_added(name)
137
- super
137
+ result = super
138
+ check_new_method(name)
139
+ result
140
+ end
141
+
142
+ def include(*modules, &block)
143
+ result = super
144
+ modules.each do |mod|
145
+ next if mod.is_a?(Interface)
146
+ mod.public_instance_methods(false).each do |name|
147
+ check_new_method(name)
148
+ end
149
+ mod.protected_instance_methods(false).each do |name|
150
+ check_new_method(name)
151
+ end
152
+ mod.private_instance_methods(false).each do |name|
153
+ check_new_method(name)
154
+ end
155
+ end
156
+ result
157
+ end
138
158
 
159
+ private
160
+ def check_new_method(name)
139
161
  case name.to_s
140
162
  when /\A#{Regexp.escape(SIGNAL_HANDLER_PREFIX)}/o
141
163
  signal_name = $POSTMATCH
data/lib/mkmf-gnome.rb CHANGED
@@ -72,9 +72,10 @@ def try_compiler_option(opt, &block)
72
72
  end
73
73
 
74
74
  try_compiler_option '-Wall'
75
- try_compiler_option '-Waggregate-return'
75
+ # NOTE: This generates warnings for functions defined in ruby.h.
76
+ # try_compiler_option '-Waggregate-return'
76
77
  try_compiler_option '-Wcast-align'
77
- # NOTE: Generates way too many false positives.
78
+ # NOTE: This generates way too many false positives.
78
79
  # try_compiler_option '-Wconversion'
79
80
  try_compiler_option '-Wextra'
80
81
  try_compiler_option '-Wformat=2'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2021 Ruby-GNOME Project Team
1
+ # Copyright (C) 2015-2022 Ruby-GNOME Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -33,7 +33,11 @@ module GLibTestUtils
33
33
  end
34
34
 
35
35
  def only_not_windows
36
- omit("Not for for Windows platform") if GLib.os_win32?
36
+ omit("Not for Windows platform") if GLib.os_win32?
37
+ end
38
+
39
+ def only_not_scl
40
+ omit("Not for SCL environment") if ENV["SCL"]
37
41
  end
38
42
 
39
43
  def normalize_path(path)
data/test/test-spawn.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2021 Ruby-GNOME Project Team
1
+ # Copyright (C) 2015-2022 Ruby-GNOME Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -35,6 +35,8 @@ class TestGLibSpawn < Test::Unit::TestCase
35
35
 
36
36
  def test_async_clear_environment
37
37
  only_not_windows
38
+ only_not_scl
39
+
38
40
  if RbConfig.respond_to?(:ruby)
39
41
  ruby = RbConfig.ruby
40
42
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib2
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.9
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME Project Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-10 00:00:00.000000000 Z
11
+ date: 2022-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pkg-config
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  - !ruby/object:Gem::Version
223
223
  version: '0'
224
224
  requirements: []
225
- rubygems_version: 3.3.0.dev
225
+ rubygems_version: 3.4.0.dev
226
226
  signing_key:
227
227
  specification_version: 4
228
228
  summary: Ruby/GLib2 is a Ruby binding of GLib-2.x.