glib2 4.3.6 → 4.3.8
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.
- checksums.yaml +4 -4
- data/ext/glib2/extconf.rb +23 -7
- data/ext/glib2/glib2.def +1 -0
- data/ext/glib2/rbgi-arg-info.c +226 -0
- data/ext/glib2/rbgi-base-info.c +223 -0
- data/ext/glib2/rbgi-callable-info.c +145 -0
- data/ext/glib2/rbgi-conversions.h +36 -0
- data/ext/glib2/rbgi-interface-info.c +167 -0
- data/ext/glib2/rbgi-private.h +42 -0
- data/ext/glib2/rbgi-repository.c +276 -0
- data/ext/glib2/rbgi-type-info.c +113 -0
- data/ext/glib2/rbglib.c +43 -1
- data/ext/glib2/rbglib.h +1 -1
- data/ext/glib2/rbglib_maincontext.c +1 -20
- data/ext/glib2/rbglib_regex.c +15 -31
- data/ext/glib2/rbgobj_param.c +1 -1
- data/ext/glib2/rbgobject.c +5 -1
- data/ext/glib2/rbgobject.h +2 -1
- data/ext/glib2/rbgutil.h +1 -0
- data/ext/glib2/rbgutil_callback.c +79 -30
- data/lib/glib-mkenums.rb +10 -4
- data/lib/glib2/callable-info.rb +140 -0
- data/lib/glib2/collection-reader.rb +41 -0
- data/lib/glib2/interface-info.rb +32 -0
- data/lib/glib2/repository.rb +47 -0
- data/lib/glib2/type-info.rb +33 -0
- data/lib/glib2.rb +8 -1
- data/test/glib-test-utils.rb +8 -1
- data/test/test-arg-info.rb +79 -0
- data/test/test-base-info.rb +42 -0
- data/test/test-bytes.rb +7 -4
- data/test/test-callable-info.rb +60 -0
- data/test/test-interface-info.rb +124 -0
- data/test/test-regex.rb +18 -2
- data/test/test-repository.rb +71 -0
- data/test/test-type-info.rb +65 -0
- metadata +21 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Copyright (C) 2012-2026 Ruby-GNOME Project Team
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16
|
+
|
|
17
|
+
module GLib
|
|
18
|
+
class Repository
|
|
19
|
+
class << self
|
|
20
|
+
if Repository.respond_to?(:default)
|
|
21
|
+
alias_method :default_raw, :default
|
|
22
|
+
def default
|
|
23
|
+
@@default ||= default_raw
|
|
24
|
+
end
|
|
25
|
+
else
|
|
26
|
+
def default
|
|
27
|
+
@@default ||= new
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
include Enumerable
|
|
33
|
+
|
|
34
|
+
def each(*namespaces)
|
|
35
|
+
return to_enum(__method__, *namespaces) unless block_given?
|
|
36
|
+
|
|
37
|
+
if namespaces.empty?
|
|
38
|
+
namespaces = loaded_namespaces
|
|
39
|
+
end
|
|
40
|
+
namespaces.each do |namespace|
|
|
41
|
+
get_n_infos(namespace).times do |i|
|
|
42
|
+
yield(get_info(namespace, i))
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Copyright (C) 2019-2026 Ruby-GNOME Project Team
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16
|
+
|
|
17
|
+
module GLib
|
|
18
|
+
class TypeInfo
|
|
19
|
+
def try_convert(value)
|
|
20
|
+
tag.try_convert(self, value)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def description
|
|
24
|
+
tag.description(self)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def inspect
|
|
28
|
+
super.gsub(/>\z/) do
|
|
29
|
+
" tag=#{tag.inspect}>"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/glib2.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2005-
|
|
1
|
+
# Copyright (C) 2005-2026 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
|
|
@@ -345,6 +345,13 @@ require "glib2/value"
|
|
|
345
345
|
require "glib2/variant"
|
|
346
346
|
require "glib2/variant-type"
|
|
347
347
|
|
|
348
|
+
if GLib.const_defined?(:Repository)
|
|
349
|
+
require_relative "glib2/callable-info"
|
|
350
|
+
require_relative "glib2/interface-info"
|
|
351
|
+
require_relative "glib2/repository"
|
|
352
|
+
require_relative "glib2/type-info"
|
|
353
|
+
end
|
|
354
|
+
|
|
348
355
|
=begin
|
|
349
356
|
Don't we need this?
|
|
350
357
|
ObjectSpace.define_finalizer(GLib) {
|
data/test/glib-test-utils.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2015-
|
|
1
|
+
# Copyright (C) 2015-2026 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
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16
16
|
|
|
17
17
|
require "pathname"
|
|
18
|
+
require "weakref"
|
|
18
19
|
|
|
19
20
|
require "test-unit"
|
|
20
21
|
|
|
@@ -40,6 +41,12 @@ module GLibTestUtils
|
|
|
40
41
|
omit("Not for SCL environment") if ENV["SCL"]
|
|
41
42
|
end
|
|
42
43
|
|
|
44
|
+
def only_girepository
|
|
45
|
+
unless GLib.const_defined?(:Repository)
|
|
46
|
+
omit("Need RUBY_GNOME_GLIB2_GIREPOSITORY_ENABLE=yes on build")
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
43
50
|
def normalize_path(path)
|
|
44
51
|
return path unless File::ALT_SEPARATOR
|
|
45
52
|
path.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Copyright (C) 2012-2026 Ruby-GNOME Project Team
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16
|
+
|
|
17
|
+
class TestArgInfo < Test::Unit::TestCase
|
|
18
|
+
include GLibTestUtils
|
|
19
|
+
|
|
20
|
+
def setup
|
|
21
|
+
only_girepository
|
|
22
|
+
@repository = GLib::Repository.default
|
|
23
|
+
@repository.require("GObject")
|
|
24
|
+
@callable_info = @repository.find("GObject", "signal_name")
|
|
25
|
+
@info = @callable_info.get_arg(0)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_direction
|
|
29
|
+
assert_equal(GLib::Direction::IN,
|
|
30
|
+
@info.direction)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_caller_allocate?
|
|
34
|
+
assert do
|
|
35
|
+
not @info.caller_allocates?
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_return_value?
|
|
40
|
+
assert do
|
|
41
|
+
not @info.return_value?
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_optional?
|
|
46
|
+
assert do
|
|
47
|
+
not @info.optional?
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_may_be_null?
|
|
52
|
+
assert do
|
|
53
|
+
not @info.may_be_null?
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_ownership_transfer
|
|
58
|
+
assert_equal(GLib::Transfer::NOTHING,
|
|
59
|
+
@info.ownership_transfer)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_scope
|
|
63
|
+
assert_equal(GLib::ScopeType::INVALID,
|
|
64
|
+
@info.scope)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_closure_index
|
|
68
|
+
assert_nil(@info.closure_index)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_destroy_index
|
|
72
|
+
assert_nil(@info.destroy_index)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_type
|
|
76
|
+
assert_kind_of(GLib::TypeInfo,
|
|
77
|
+
@info.type)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Copyright (C) 2012-2026 Ruby-GNOME Project Team
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16
|
+
|
|
17
|
+
class TestBaseInfo < Test::Unit::TestCase
|
|
18
|
+
include GLibTestUtils
|
|
19
|
+
|
|
20
|
+
def setup
|
|
21
|
+
only_girepository
|
|
22
|
+
@repository = GLib::Repository.default
|
|
23
|
+
@repository.require("GObject")
|
|
24
|
+
@info = @repository.find("GObject", "Object")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_name
|
|
28
|
+
assert_equal("Object", @info.name)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_namespace
|
|
32
|
+
assert_equal("GObject", @info.namespace)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_container
|
|
36
|
+
assert_nil(@info.container)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_enumerable
|
|
40
|
+
assert_equal([], @info.to_a)
|
|
41
|
+
end
|
|
42
|
+
end
|
data/test/test-bytes.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2017-
|
|
1
|
+
# Copyright (C) 2017-2026 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
|
|
@@ -42,14 +42,17 @@ class TestGLibBytes < Test::Unit::TestCase
|
|
|
42
42
|
def create_bytes(options={})
|
|
43
43
|
data = "Hello"
|
|
44
44
|
data.freeze if options[:freeze]
|
|
45
|
-
[data
|
|
45
|
+
[WeakRef.new(data), GLib::Bytes.new(data)]
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
test "frozen" do
|
|
49
|
-
|
|
49
|
+
ref, bytes = create_bytes(:freeze => true)
|
|
50
50
|
GC.start
|
|
51
|
+
assert do
|
|
52
|
+
ref.weakref_alive?
|
|
53
|
+
end
|
|
51
54
|
assert_equal(bytes.to_s,
|
|
52
|
-
|
|
55
|
+
ref.to_s)
|
|
53
56
|
end
|
|
54
57
|
end
|
|
55
58
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Copyright (C) 2012-2026 Ruby-GNOME Project Team
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16
|
+
|
|
17
|
+
class TestCallableInfo < Test::Unit::TestCase
|
|
18
|
+
include GLibTestUtils
|
|
19
|
+
|
|
20
|
+
def setup
|
|
21
|
+
only_girepository
|
|
22
|
+
@repository = GLib::Repository.default
|
|
23
|
+
@repository.require("GObject")
|
|
24
|
+
@info = @repository.find("GObject", "signal_name")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_can_throw_gerror
|
|
28
|
+
assert do
|
|
29
|
+
not @info.can_throw_gerror?
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_return_type
|
|
34
|
+
assert_kind_of(GLib::TypeInfo,
|
|
35
|
+
@info.return_type)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_caller_owns
|
|
39
|
+
assert_equal(GLib::Transfer::NOTHING,
|
|
40
|
+
@info.caller_owns)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_may_return_null?
|
|
44
|
+
assert do
|
|
45
|
+
@info.may_return_null?
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_n_args
|
|
50
|
+
assert_equal(1, @info.n_args)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_get_arg
|
|
54
|
+
assert_equal("signal_id", @info.get_arg(0).name)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_args
|
|
58
|
+
assert_equal(["signal_id"], @info.args.collect(&:name))
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Copyright (C) 2012-2026 Ruby-GNOME Project Team
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16
|
+
|
|
17
|
+
class TestInterfaceInfo < Test::Unit::TestCase
|
|
18
|
+
include GLibTestUtils
|
|
19
|
+
|
|
20
|
+
def setup
|
|
21
|
+
only_girepository
|
|
22
|
+
@repository = GLib::Repository.default
|
|
23
|
+
@repository.require("Gio")
|
|
24
|
+
@info = @repository.find("Gio", "TlsServerConnection")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_n_prerequisites
|
|
28
|
+
assert_equal(1, @info.n_prerequisites)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_prerequisite
|
|
32
|
+
assert_kind_of(GLib::ObjectInfo,
|
|
33
|
+
@info.get_prerequisite(0))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_n_properties
|
|
37
|
+
assert_equal(1, @info.n_properties)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_property
|
|
41
|
+
assert_kind_of(GLib::PropertyInfo,
|
|
42
|
+
@info.get_property(0))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_n_methods
|
|
46
|
+
assert_equal(1, @info.n_methods)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_get_method_n
|
|
50
|
+
assert_kind_of(GLib::FunctionInfo,
|
|
51
|
+
@info.get_method(0))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_get_method_name
|
|
55
|
+
assert_kind_of(GLib::FunctionInfo,
|
|
56
|
+
@info.get_method("new"))
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_n_signals
|
|
60
|
+
info = @repository.find("Gio", "Volume")
|
|
61
|
+
assert_equal(2, info.n_signals)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_get_signal_n
|
|
65
|
+
info = @repository.find("Gio", "Volume")
|
|
66
|
+
assert_kind_of(GLib::SignalInfo,
|
|
67
|
+
info.get_signal(0))
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_get_signal_name
|
|
71
|
+
info = @repository.find("Gio", "Volume")
|
|
72
|
+
assert_kind_of(GLib::SignalInfo,
|
|
73
|
+
info.get_signal("changed"))
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_n_vfuncs
|
|
77
|
+
info = @repository.find("Gio", "Volume")
|
|
78
|
+
assert do
|
|
79
|
+
info.n_vfuncs > 0
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_get_vfunc_n
|
|
84
|
+
info = @repository.find("Gio", "Volume")
|
|
85
|
+
assert_kind_of(GLib::VFuncInfo,
|
|
86
|
+
info.get_vfunc(0))
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_get_vfunc_name
|
|
90
|
+
info = @repository.find("Gio", "Volume")
|
|
91
|
+
assert_kind_of(GLib::VFuncInfo,
|
|
92
|
+
info.get_vfunc("can_eject"))
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_n_constants
|
|
96
|
+
repository = GLib::Repository.new
|
|
97
|
+
begin
|
|
98
|
+
repository.require("GXml")
|
|
99
|
+
rescue GLib::RepositoryError
|
|
100
|
+
omit("GXml is needed")
|
|
101
|
+
end
|
|
102
|
+
info = repository.find("GXml", "IXsdSchema")
|
|
103
|
+
assert do
|
|
104
|
+
info.n_constants > 0
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_get_constant
|
|
109
|
+
repository = GLib::Repository.new
|
|
110
|
+
begin
|
|
111
|
+
repository.require("GXml")
|
|
112
|
+
rescue GLib::RepositoryError
|
|
113
|
+
omit("GXml is needed")
|
|
114
|
+
end
|
|
115
|
+
info = repository.find("GXml", "IXsdSchema")
|
|
116
|
+
assert_kind_of(GLib::ConstantInfo,
|
|
117
|
+
info.get_constant(0))
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def test_iface_struct
|
|
121
|
+
assert_kind_of(GLib::StructInfo,
|
|
122
|
+
@info.iface_struct)
|
|
123
|
+
end
|
|
124
|
+
end
|
data/test/test-regex.rb
CHANGED
|
@@ -280,10 +280,26 @@ class TestRegex < Test::Unit::TestCase
|
|
|
280
280
|
assert_equal(" to to to to", modified_string)
|
|
281
281
|
end
|
|
282
282
|
|
|
283
|
-
test "
|
|
283
|
+
test "nil" do
|
|
284
284
|
regex = GLib::Regex.new("1|2|3|4")
|
|
285
285
|
modified_string = regex.replace(" 4 3 2 1") do |match_info|
|
|
286
|
-
|
|
286
|
+
if match_info.fetch(0) == "4"
|
|
287
|
+
"to"
|
|
288
|
+
else
|
|
289
|
+
nil
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
assert_equal(" to 3 2 1", modified_string)
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
test "false" do
|
|
296
|
+
regex = GLib::Regex.new("1|2|3|4")
|
|
297
|
+
modified_string = regex.replace(" 4 3 2 1") do |match_info|
|
|
298
|
+
if match_info.fetch(0) == "4"
|
|
299
|
+
"to"
|
|
300
|
+
else
|
|
301
|
+
false
|
|
302
|
+
end
|
|
287
303
|
end
|
|
288
304
|
assert_equal(" to 3 2 1", modified_string)
|
|
289
305
|
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Copyright (C) 2012-2026 Ruby-GNOME Project Team
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16
|
+
|
|
17
|
+
class TestRepository < Test::Unit::TestCase
|
|
18
|
+
include GLibTestUtils
|
|
19
|
+
|
|
20
|
+
def setup
|
|
21
|
+
only_girepository
|
|
22
|
+
@repository = GLib::Repository.default
|
|
23
|
+
@repository.require("GObject")
|
|
24
|
+
@repository.require("Gio")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_search_path
|
|
28
|
+
repository = GLib::Repository.new
|
|
29
|
+
path = repository.search_path
|
|
30
|
+
repository.prepend_search_path(__dir__)
|
|
31
|
+
assert_equal([__dir__] + path,
|
|
32
|
+
repository.search_path)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_get_n_infos
|
|
36
|
+
assert_kind_of(Integer, @repository.get_n_infos("GObject"))
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_get_info
|
|
40
|
+
assert_kind_of(GLib::BaseInfo,
|
|
41
|
+
@repository.get_info("GObject", 0))
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_get_dependencies
|
|
45
|
+
assert_equal(["GLib-2.0"].sort,
|
|
46
|
+
@repository.get_dependencies("GObject").sort)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_loaded_namespaces
|
|
50
|
+
assert_equal(["GLib", "GObject", "Gio", "GModule"].sort,
|
|
51
|
+
@repository.loaded_namespaces.sort - ["GioUnix"])
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_enumerable
|
|
55
|
+
namespaces = @repository.collect do |info|
|
|
56
|
+
info.namespace
|
|
57
|
+
end
|
|
58
|
+
assert_equal(["GLib", "GObject", "Gio", "GModule"].sort,
|
|
59
|
+
namespaces.uniq.sort - ["GioUnix"])
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_find_by_gtype
|
|
63
|
+
info = @repository.find(GLib::Object.gtype)
|
|
64
|
+
assert_equal("Object", info.name)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_find_by_name
|
|
68
|
+
info = @repository.find("GObject", "Object")
|
|
69
|
+
assert_equal("Object", info.name)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Copyright (C) 2012-2026 Ruby-GNOME Project Team
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License as published by the Free Software Foundation; either
|
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11
|
+
# Lesser General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
14
|
+
# License along with this library; if not, write to the Free Software
|
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16
|
+
|
|
17
|
+
class TestTypeInfo < Test::Unit::TestCase
|
|
18
|
+
include GLibTestUtils
|
|
19
|
+
|
|
20
|
+
def setup
|
|
21
|
+
only_girepository
|
|
22
|
+
@repository = GLib::Repository.default
|
|
23
|
+
@repository.require("GObject")
|
|
24
|
+
@function_info = @repository.find("GObject", "signal_list_ids")
|
|
25
|
+
@info = @function_info.return_type
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_pointer?
|
|
29
|
+
assert_true(@info.pointer?)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_tag
|
|
33
|
+
assert_kind_of(GLib::TypeTag,
|
|
34
|
+
@info.tag)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_param_type
|
|
38
|
+
assert_kind_of(GLib::TypeInfo,
|
|
39
|
+
@info.get_param_type(0))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_interface
|
|
43
|
+
function_info = @repository.find("Gio", "app_info_create_from_commandline")
|
|
44
|
+
info = function_info.return_type
|
|
45
|
+
assert_kind_of(GLib::InterfaceInfo,
|
|
46
|
+
info.interface)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_array_length_index
|
|
50
|
+
assert_equal(1, @info.array_length_index)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_array_fixed_size
|
|
54
|
+
assert_nil(@info.array_fixed_size)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_zero_terminated?
|
|
58
|
+
assert_false(@info.zero_terminated?)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_array_type
|
|
62
|
+
assert_equal(GLib::ArrayType::C,
|
|
63
|
+
@info.array_type)
|
|
64
|
+
end
|
|
65
|
+
end
|