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
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
@@ -313,8 +335,13 @@ GLib::Log.set_log_domain(GLib::Thread::LOG_DOMAIN)
313
335
  GLib::Log.set_log_domain(GLib::Module::LOG_DOMAIN)
314
336
 
315
337
  require "glib2/version"
316
- require "glib2/regex"
338
+
317
339
  require "glib2/deprecated"
340
+
341
+ require "glib2/date-time"
342
+ require "glib2/regex"
343
+ require "glib2/variant"
344
+
318
345
  =begin
319
346
  Don't we need this?
320
347
  ObjectSpace.define_finalizer(GLib) {
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'
@@ -190,12 +191,12 @@ end
190
191
 
191
192
  def add_depend_package_path(target_name, target_source_dir, target_build_dir)
192
193
  if File.exist?(target_source_dir)
193
- $INCFLAGS = "-I#{target_source_dir} #{$INCFLAGS}"
194
+ $INCFLAGS = "-I#{target_source_dir}".quote + " #{$INCFLAGS}"
194
195
  end
195
196
 
196
197
  return unless File.exist?(target_build_dir)
197
198
  if target_source_dir != target_build_dir
198
- $INCFLAGS = "-I#{target_build_dir} #{$INCFLAGS}"
199
+ $INCFLAGS = "-I#{target_build_dir}".quote + " #{$INCFLAGS}"
199
200
  end
200
201
 
201
202
  library_base_name = File.basename(target_source_dir).gsub(/-/, "_")
@@ -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)
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016-2021 Ruby-GNOME Project Team
1
+ # Copyright (C) 2016-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
@@ -24,7 +24,6 @@ class TestDateTime < Test::Unit::TestCase
24
24
  end
25
25
 
26
26
  sub_test_case "new" do
27
-
28
27
  test "unix: :local" do
29
28
  time = Time.now
30
29
  format = "%Y-%m-%d-%H-%M"
@@ -111,4 +110,17 @@ class TestDateTime < Test::Unit::TestCase
111
110
  assert_equal(time.sec, datetime.second)
112
111
  end
113
112
  end
113
+
114
+ def test_format_iso8601
115
+ only_glib_version(2, 66, 0)
116
+ datetime = GLib::DateTime.new(year: 2022,
117
+ month: 7,
118
+ day: 18,
119
+ hour: 23,
120
+ minute: 24,
121
+ second: 4.9,
122
+ timezone: GLib::TimeZone.utc)
123
+ assert_equal("2022-07-18T23:24:04.900000Z",
124
+ datetime.format_iso8601)
125
+ end
114
126
  end
data/test/test-glib2.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # coding: ascii-8bit
2
2
  #
3
- # Copyright (C) 2015-2019 Ruby-GNOME2 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
@@ -130,17 +130,19 @@ class TestGLib < Test::Unit::TestCase
130
130
  end
131
131
 
132
132
  def test_signal_handler_disconnect_and_gc
133
- obj = GLib::Object.new
133
+ object = GLib::Object.new
134
134
  klass = Class.new
135
- 1000.times {
136
- a = klass.new
137
- id = obj.signal_connect("notify") { p a }
138
- obj.signal_handler_disconnect(id)
135
+ n_tries = 100
136
+ n_tries.times {
137
+ garbage_collected_object = klass.new
138
+ id = object.signal_connect("notify") { p garbage_collected_object }
139
+ object.signal_handler_disconnect(id)
139
140
  }
140
141
  GC.start
141
- ary = []
142
- ObjectSpace.each_object(klass) { |a| ary.push(a) }
143
- assert_operator(ary.size, :<, 1000)
142
+ n_alive_objects = ObjectSpace.each_object(klass) {}
143
+ assert do
144
+ n_alive_objects < n_tries
145
+ end
144
146
  end
145
147
 
146
148
  def test_gtype
@@ -150,4 +152,14 @@ class TestGLib < Test::Unit::TestCase
150
152
  obj = GLib::Object.new
151
153
  assert_equal(obj.gtype, GLib::Object.gtype)
152
154
  end
155
+
156
+ def test_malloc
157
+ address = GLib.malloc(29)
158
+ GLib.free(address)
159
+ end
160
+
161
+ def test_malloc0
162
+ address = GLib.malloc0(29)
163
+ GLib.free(address)
164
+ end
153
165
  end
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
data/test/test-variant.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2018 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2018-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
@@ -17,6 +17,31 @@
17
17
  class TestGLibVariant < Test::Unit::TestCase
18
18
  include GLibTestUtils
19
19
 
20
+ sub_test_case ".parse" do
21
+ test "no type" do
22
+ variant = GLib::Variant.parse("'hello'")
23
+ assert_equal([GLib::VariantType::STRING, "hello"],
24
+ [variant.type, variant.value])
25
+ end
26
+
27
+ test "type" do
28
+ variant = GLib::Variant.parse("29", "y")
29
+ assert_equal([GLib::VariantType::BYTE, 29],
30
+ [variant.type, variant.value])
31
+ end
32
+
33
+ test "garbage" do
34
+ message = <<-MESSAGE
35
+ expected end of input:
36
+ 29 hello
37
+ ^
38
+ MESSAGE
39
+ assert_raise(GLib::VariantParseError::InputNotAtEnd.new(message)) do
40
+ GLib::Variant.parse("29 hello", "y")
41
+ end
42
+ end
43
+ end
44
+
20
45
  sub_test_case "#initialize" do
21
46
  test "type: string" do
22
47
  variant = GLib::Variant.new("hello", "s")
@@ -24,4 +49,22 @@ class TestGLibVariant < Test::Unit::TestCase
24
49
  [variant.type, variant.value])
25
50
  end
26
51
  end
52
+
53
+ sub_test_case "#to_s" do
54
+ test "default" do
55
+ variant = GLib::Variant.new(29, "y")
56
+ assert_equal("0x1d", variant.to_s)
57
+ end
58
+
59
+ test "type_annotate:" do
60
+ variant = GLib::Variant.new(29, "y")
61
+ assert_equal("byte 0x1d", variant.to_s(type_annotate: true))
62
+ end
63
+ end
64
+
65
+ test "#inspect" do
66
+ variant = GLib::Variant.new(29, "y")
67
+ assert_equal("#<GLib::Variant:0x00 type=y value=29>",
68
+ variant.inspect.gsub(/0x\h+/, "0x00"))
69
+ end
27
70
  end
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: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME Project Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-10 00:00:00.000000000 Z
11
+ date: 2022-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pkg-config
@@ -65,8 +65,6 @@ files:
65
65
  - Rakefile
66
66
  - ext/glib2/depend
67
67
  - ext/glib2/extconf.rb
68
- - ext/glib2/glib-enum-types.c
69
- - ext/glib2/glib-enum-types.h
70
68
  - ext/glib2/glib2.def
71
69
  - ext/glib2/rbgcompat.h
72
70
  - ext/glib2/rbglib-bytes.c
@@ -145,9 +143,11 @@ files:
145
143
  - glib2.gemspec
146
144
  - lib/glib-mkenums.rb
147
145
  - lib/glib2.rb
146
+ - lib/glib2/date-time.rb
148
147
  - lib/glib2/deprecatable.rb
149
148
  - lib/glib2/deprecated.rb
150
149
  - lib/glib2/regex.rb
150
+ - lib/glib2/variant.rb
151
151
  - lib/glib2/version.rb
152
152
  - lib/gnome2-raketask.rb
153
153
  - lib/gnome2/rake/external-package.rb
@@ -207,7 +207,7 @@ licenses:
207
207
  - LGPL-2.1+
208
208
  metadata:
209
209
  msys2_mingw_dependencies: glib2
210
- post_install_message:
210
+ post_install_message:
211
211
  rdoc_options: []
212
212
  require_paths:
213
213
  - lib
@@ -222,8 +222,8 @@ 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
226
- signing_key:
225
+ rubygems_version: 3.4.0.dev
226
+ signing_key:
227
227
  specification_version: 4
228
228
  summary: Ruby/GLib2 is a Ruby binding of GLib-2.x.
229
229
  test_files: []