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,4 +1,4 @@
1
- # Copyright (C) 2018-2019 Ruby-GNOME Project Team
1
+ # Copyright (C) 2018-2021 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
@@ -26,4 +26,25 @@ module GLib
26
26
  define_deprecated_const(:PRIVATE, :STATIC_NAME)
27
27
  define_deprecated_method(:private?, :static_name?)
28
28
  end
29
+
30
+ class SpawnError
31
+ extend GLib::Deprecatable
32
+ define_deprecated_const(:E2BIG, :TOO_BIG)
33
+ end
34
+
35
+ module Unicode
36
+ extend GLib::Deprecatable
37
+ define_deprecated_singleton_method(
38
+ :canonical_decomposition,
39
+ warn: "Use 'GLib::UniChar.decompose(char)'.") do |_, char|
40
+ UniChar.decompose(char)
41
+ end
42
+ end
43
+
44
+ extend GLib::Deprecatable
45
+ define_deprecated_singleton_method(
46
+ :format_size_for_display,
47
+ warn: "Use 'GLib.format_size(size, flags: :iec_units)'.") do |_, size|
48
+ format_size(size, flags: :iec_units)
49
+ end
29
50
  end
data/lib/mkmf-gnome.rb CHANGED
@@ -37,11 +37,11 @@ end
37
37
  def enable_debug_build_flag(flags)
38
38
  if gcc?
39
39
  expanded_flags = RbConfig.expand(flags.dup)
40
- debug_option_pattern = /(^|\s)-g\d?(\s|$)/
40
+ debug_option_pattern = /(^|\s)-g(?:gdb)?\d?(\s|$)/
41
41
  if debug_option_pattern =~ expanded_flags
42
- expanded_flags.gsub(debug_option_pattern, '\\1-g3\\2')
42
+ expanded_flags.gsub(debug_option_pattern, '\\1-ggdb3\\2')
43
43
  else
44
- flags + " -g3"
44
+ flags + " -ggdb3"
45
45
  end
46
46
  else
47
47
  flags
@@ -198,7 +198,7 @@ def add_depend_package_path(target_name, target_source_dir, target_build_dir)
198
198
  $INCFLAGS = "-I#{target_build_dir} #{$INCFLAGS}"
199
199
  end
200
200
 
201
- library_base_name = target_name.gsub(/-/, "_")
201
+ library_base_name = File.basename(target_source_dir).gsub(/-/, "_")
202
202
  case RUBY_PLATFORM
203
203
  when /cygwin|mingw/
204
204
  $libs << " " << File.join(target_build_dir, "#{library_base_name}.so")
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2021 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
@@ -14,6 +14,12 @@
14
14
  # License along with this library; if not, write to the Free Software
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
+ require "pathname"
18
+
19
+ require "test-unit"
20
+
21
+ require "glib2"
22
+
17
23
  module GLibTestUtils
18
24
  private
19
25
  def only_glib_version(major, minor, micro)
@@ -22,7 +28,16 @@ module GLibTestUtils
22
28
  end
23
29
  end
24
30
 
25
- def only_win32
26
- omit("Only for Win32 platform") unless GLib.os_win32?
31
+ def only_windows
32
+ omit("Only for Windows platform") unless GLib.os_win32?
33
+ end
34
+
35
+ def only_not_windows
36
+ omit("Not for for Windows platform") if GLib.os_win32?
37
+ end
38
+
39
+ def normalize_path(path)
40
+ return path unless File::ALT_SEPARATOR
41
+ path.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
27
42
  end
28
43
  end
data/test/run-test.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright (C) 2015 Ruby-GNOME2 Project Team
2
+ #
3
+ # Copyright (C) 2015-2021 Ruby-GNOME Project Team
3
4
  #
4
5
  # This library is free software; you can redistribute it and/or
5
6
  # modify it under the terms of the GNU Lesser General Public
@@ -15,23 +16,57 @@
15
16
  # License along with this library; if not, write to the Free Software
16
17
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18
 
19
+ require "fileutils"
18
20
 
19
- base = File.expand_path(File.join(File.dirname(__FILE__)))
20
- top = File.expand_path(File.join(base, ".."))
21
+ def run_test(test_dir, dependencies)
22
+ $VERBOSE = true
21
23
 
22
- $LOAD_PATH.unshift(top)
23
- require 'test/glib-test-init'
24
+ ruby_gnome_build_dir = ENV["RUBY_GNOME_BUILD_DIR"]
25
+ ruby_gnome_build_dir ||= File.expand_path("..")
26
+ ruby_gnome_source_dir = File.expand_path("../..", test_dir)
24
27
 
25
- if File.exist?("#{top}/Makefile") and system("which make > /dev/null")
26
- system("cd #{top.dump} && make > /dev/null") or exit(1)
27
- end
28
+ dependencies.each do |dependency|
29
+ source_dir = File.join(ruby_gnome_source_dir, dependency)
30
+ build_dir = File.join(ruby_gnome_build_dir, dependency)
31
+ makefile = File.join(build_dir, "Makefile")
32
+ if File.exist?(makefile)
33
+ system("make", "-C", build_dir, "-j", out: IO::NULL) or exit(false)
34
+ $LOAD_PATH.unshift(File.join(build_dir, "ext", dependency))
35
+ end
36
+ $LOAD_PATH.unshift(File.join(source_dir, "lib"))
37
+ end
28
38
 
29
- $LOAD_PATH.unshift(File.join(top, "ext", "glib2"))
30
- $LOAD_PATH.unshift(File.join(top, "lib"))
39
+ source_fixture_dir = File.join(test_dir, "fixture")
40
+ if File.exist?(source_fixture_dir)
41
+ target_name = File.basename(File.expand_path("..", test_dir))
42
+ build_fixture_dir = File.join(ruby_gnome_build_dir,
43
+ target_name,
44
+ "test",
45
+ "fixture")
46
+ unless source_fixture_dir == build_fixture_dir
47
+ FileUtils.rm_rf(build_fixture_dir)
48
+ FileUtils.mkdir_p(File.dirname(build_fixture_dir))
49
+ FileUtils.cp_r(source_fixture_dir, build_fixture_dir)
50
+ end
51
+ Dir.chdir(build_fixture_dir) do
52
+ if File.exist?("Rakefile")
53
+ system("rake") or exit(false)
54
+ end
55
+ end
56
+ end
31
57
 
32
- $LOAD_PATH.unshift(base)
33
- require 'glib-test-utils'
58
+ require_relative "glib-test-utils"
34
59
 
35
- require 'glib2'
60
+ if block_given?
61
+ context = {
62
+ build_fixture_dir: build_fixture_dir,
63
+ }
64
+ yield(context)
65
+ end
36
66
 
37
- exit Test::Unit::AutoRunner.run(true, base)
67
+ exit(Test::Unit::AutoRunner.run(true, test_dir))
68
+ end
69
+
70
+ if $PROGRAM_NAME == __FILE__
71
+ run_test(__dir__, ["glib2"])
72
+ end
data/test/test-binding.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2021 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
@@ -55,10 +55,6 @@ class TestGLibBinding < Test::Unit::TestCase
55
55
  end
56
56
  end
57
57
 
58
- setup do
59
- only_glib_version(2, 26, 0)
60
- end
61
-
62
58
  setup do
63
59
  @source = DataObjectDefault.new
64
60
  @target = DataObjectDefault.new
@@ -86,7 +82,6 @@ class TestGLibBinding < Test::Unit::TestCase
86
82
  end
87
83
 
88
84
  test "#unbind" do
89
- only_glib_version(2, 38, 0)
90
85
  assert_equal(0, @target.target)
91
86
  @source.source = 10
92
87
  assert_equal(10, @target.target)
@@ -132,10 +127,6 @@ class TestGLibBinding < Test::Unit::TestCase
132
127
  end
133
128
  end
134
129
 
135
- setup do
136
- only_glib_version(2, 26, 0)
137
- end
138
-
139
130
  setup do
140
131
  @source = DataObjectBidir.new
141
132
  @target = DataObjectBidir.new
@@ -174,7 +165,6 @@ class TestGLibBinding < Test::Unit::TestCase
174
165
  end
175
166
 
176
167
  test "#unbind" do
177
- only_glib_version(2, 38, 0)
178
168
  assert_equal("nan", @target.target)
179
169
  @source.source = 10
180
170
  assert_equal("10", @target.target)
data/test/test-bytes.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2017-2019 Ruby-GNOME Project Team
1
+ # Copyright (C) 2017-2021 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,10 +17,6 @@
17
17
  class TestGLibBytes < Test::Unit::TestCase
18
18
  include GLibTestUtils
19
19
 
20
- setup do
21
- only_glib_version(2, 32, 0)
22
- end
23
-
24
20
  sub_test_case ".try_convert" do
25
21
  def test_nil
26
22
  assert_nil(GLib::Bytes.try_convert(nil))
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016-2017 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2016-2021 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
@@ -76,7 +76,6 @@ class TestDateTime < Test::Unit::TestCase
76
76
  end
77
77
 
78
78
  test "timezone: local time zone" do
79
- only_glib_version(2, 34, 0)
80
79
  time = Time.now
81
80
  tz = GLib::TimeZone.local
82
81
  datetime = GLib::DateTime.new(:timezone => tz,
@@ -95,7 +94,6 @@ class TestDateTime < Test::Unit::TestCase
95
94
  end
96
95
 
97
96
  test "timezone: UTC time zone" do
98
- only_glib_version(2, 34, 0)
99
97
  time = Time.now.utc
100
98
  tz = GLib::TimeZone.utc
101
99
  datetime = GLib::DateTime.new(:timezone => tz,
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2019 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2021 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
@@ -21,38 +21,7 @@ class TestGLibFileUtils < Test::Unit::TestCase
21
21
  string.gsub("\u{00A0}", " ")
22
22
  end
23
23
 
24
- sub_test_case "#format_size_for_display" do
25
- def setup
26
- only_glib_version(2, 16, 0)
27
- end
28
-
29
- def test_kb
30
- assert_equal("1.0 KB", GLib.format_size_for_display(1024))
31
- end
32
-
33
- def test_10kb
34
- assert_equal("10.0 KB", GLib.format_size_for_display(1024 * 10))
35
- end
36
-
37
- def test_mb
38
- assert_equal("1.0 MB", GLib.format_size_for_display(1024 * 1024))
39
- end
40
-
41
- def test_gb
42
- assert_equal("1.0 GB", GLib.format_size_for_display(1024 * 1024 * 1024))
43
- end
44
-
45
- def test_over_guint32_value
46
- guint32_max = 2 ** 32 - 1
47
- assert_equal("4.0 GB", GLib.format_size_for_display(guint32_max + 1))
48
- end
49
- end
50
-
51
24
  sub_test_case "#format_size" do
52
- def setup
53
- only_glib_version(2, 30, 0)
54
- end
55
-
56
25
  def test_kb
57
26
  assert_equal("1.0 kB",
58
27
  normalize_space(GLib.format_size(1000)))
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2017 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2021 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
@@ -26,11 +26,13 @@ class TestGIOChannel < Test::Unit::TestCase
26
26
 
27
27
  @file = Tempfile.new("glib2-content")
28
28
  @file.open
29
+ @file.binmode
29
30
  @file.print(@content)
30
31
  @file.close
31
32
 
32
33
  @sjis_file = Tempfile.new("glib2-sjis-content")
33
34
  @sjis_file.open
35
+ @sjis_file.binmode
34
36
  @sjis_file.print(@sjis_content)
35
37
  @sjis_file.close
36
38
  end
@@ -66,10 +68,6 @@ class TestGIOChannel < Test::Unit::TestCase
66
68
  end
67
69
  end
68
70
 
69
- assert_raises(GLib::IOChannelError) do
70
- io.close
71
- end
72
-
73
71
  assert_raises(GLib::FileError) do
74
72
  GLib::IOChannel.new("foo")
75
73
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2021 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
@@ -20,8 +20,6 @@ class TestGLibKeyFile < Test::Unit::TestCase
20
20
  include GLibTestUtils
21
21
 
22
22
  def test_load_from_dirs
23
- only_glib_version(2, 14, 0)
24
-
25
23
  key_file = GLib::KeyFile.new
26
24
  assert_raise(GLib::KeyFileError::NotFound) do
27
25
  key_file.load_from_dirs("non-existent")
@@ -34,7 +32,8 @@ class TestGLibKeyFile < Test::Unit::TestCase
34
32
  key_file.load_from_dirs("non-existent", search_dirs)
35
33
  end
36
34
  if GLib.check_version?(2, 31, 2)
37
- assert_equal(temp.path, key_file.load_from_dirs(base_name, search_dirs))
35
+ loaded_path = key_file.load_from_dirs(base_name, search_dirs)
36
+ assert_equal(temp.path, normalize_path(loaded_path))
38
37
  elsif GLib.check_version?(2, 30, 0)
39
38
  assert_raise(GLib::KeyFileError::NotFound) do
40
39
  key_file.load_from_dirs(base_name, search_dirs)
@@ -49,11 +48,11 @@ class TestGLibKeyFile < Test::Unit::TestCase
49
48
  key = value
50
49
  EOK
51
50
  temp.close
52
- assert_equal(temp.path, key_file.load_from_dirs(base_name, search_dirs))
51
+ loaded_path = key_file.load_from_dirs(base_name, search_dirs)
52
+ assert_equal(temp.path, normalize_path(loaded_path))
53
53
  end
54
54
 
55
55
  def test_desktop_constants
56
- only_glib_version(2, 14, 0)
57
56
  assert_equal("Desktop Entry", GLib::KeyFile::DESKTOP_GROUP)
58
57
  assert_equal("URL", GLib::KeyFile::DESKTOP_KEY_URL)
59
58
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2017 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2021 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,10 +17,6 @@
17
17
  class TestMatchInfo < Test::Unit::TestCase
18
18
  include GLibTestUtils
19
19
 
20
- setup do
21
- only_glib_version(2, 30, 0)
22
- end
23
-
24
20
  def test_string
25
21
  regex = GLib::Regex.new("[A-Z]+")
26
22
  match_info = regex.match("abc def")
data/test/test-regex.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2017 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2021 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,10 +17,6 @@
17
17
  class TestRegex < Test::Unit::TestCase
18
18
  include GLibTestUtils
19
19
 
20
- setup do
21
- only_glib_version(2, 30, 0)
22
- end
23
-
24
20
  def test_enum_match_flags
25
21
  assert_const_defined(GLib, :RegexMatchFlags)
26
22
  assert_kind_of(GLib::RegexMatchFlags, GLib::RegexMatchFlags::PARTIAL_HARD)
data/test/test-source.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013-2015 Ruby-GNOME2 Project Team
3
+ # Copyright (C) 2013-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
@@ -32,15 +32,6 @@ class TestGLibSource < Test::Unit::TestCase
32
32
  end
33
33
 
34
34
  def test_destroy
35
- # only_glib_version(2, 35, 4)
36
- # GMainContext may be freed before GSource by Ruby's GC.
37
- # If GMainContext is freed before GSource, GLib 2.35.3 or earlier is
38
- # crashed.
39
- #
40
- # See also:
41
- # * https://bugzilla.gnome.org/show_bug.cgi?id=661767
42
- # * https://git.gnome.org/browse/glib/commit/?id=26056558be4656ee6e891a4fae5d4198de7519cf
43
-
44
35
  context = GLib::MainContext.new
45
36
  source = GLib::Idle.source_new
46
37
  id = source.attach(context)
@@ -52,8 +43,6 @@ class TestGLibSource < Test::Unit::TestCase
52
43
  end
53
44
 
54
45
  def test_name
55
- only_glib_version(2, 26, 0)
56
-
57
46
  source = GLib::Idle.source_new
58
47
 
59
48
  source_name = "glib source"
@@ -62,8 +51,6 @@ class TestGLibSource < Test::Unit::TestCase
62
51
  end
63
52
 
64
53
  def test_ready_time
65
- only_glib_version(2, 36, 0)
66
-
67
54
  source = GLib::Idle.source_new
68
55
 
69
56
  ready_time = 5