gobject-introspection 3.4.9 → 3.5.0
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/gobject-introspection/rb-gi-arg-info.c +44 -1
- data/ext/gobject-introspection/rb-gi-arguments-in.c +22 -19
- data/ext/gobject-introspection/rb-gi-arguments-out.c +17 -17
- data/ext/gobject-introspection/rb-gi-arguments.c +1908 -53
- data/ext/gobject-introspection/rb-gi-callback.c +8 -2
- data/ext/gobject-introspection/rb-gi-constant-info.c +14 -10
- data/ext/gobject-introspection/rb-gi-conversions.h +1 -23
- data/ext/gobject-introspection/rb-gi-field-info.c +77 -76
- data/ext/gobject-introspection/rb-gi-function-info.c +57 -16
- data/ext/gobject-introspection/rb-gi-private-arg-info.h +3 -1
- data/ext/gobject-introspection/rb-gi-private-arguments.h +19 -3
- data/ext/gobject-introspection/rb-gi-private.h +6 -3
- data/ext/gobject-introspection/rb-gobject-introspection.c +5 -225
- data/lib/gobject-introspection/function-info.rb +2 -2
- data/lib/gobject-introspection/loader.rb +144 -73
- data/lib/gobject-introspection/type-tag.rb +115 -123
- data/test/test-loader.rb +14 -0
- metadata +5 -6
- data/ext/gobject-introspection/rb-gi-argument.c +0 -2051
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2019 Ruby-GNOME Project Team
|
1
|
+
# Copyright (C) 2019-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,171 +17,163 @@
|
|
17
17
|
module GObjectIntrospection
|
18
18
|
class TypeTag
|
19
19
|
def try_convert(type_info, value)
|
20
|
-
|
20
|
+
method = "try_convert_#{nick}"
|
21
|
+
if respond_to?(method, true)
|
22
|
+
__send__(method, type_info, value)
|
23
|
+
else
|
24
|
+
nil
|
25
|
+
end
|
21
26
|
end
|
22
27
|
|
23
28
|
def description(type_info)
|
24
|
-
nick
|
29
|
+
method = "description_#{nick}"
|
30
|
+
if respond_to?(method, true)
|
31
|
+
__send__(method, type_info)
|
32
|
+
else
|
33
|
+
nick
|
34
|
+
end
|
25
35
|
end
|
26
36
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
+
private
|
38
|
+
def try_convert_boolean(type_info, value)
|
39
|
+
case value
|
40
|
+
when true, false
|
41
|
+
value
|
42
|
+
when nil
|
43
|
+
false
|
44
|
+
else
|
45
|
+
nil
|
37
46
|
end
|
38
47
|
end
|
39
48
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
nil
|
48
|
-
end
|
49
|
+
def try_convert_integer(type_info, value)
|
50
|
+
if value.is_a?(Integer)
|
51
|
+
value
|
52
|
+
elsif value.respond_to?(:to_int)
|
53
|
+
value.to_int
|
54
|
+
else
|
55
|
+
nil
|
49
56
|
end
|
50
57
|
end
|
51
58
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
nil
|
69
|
-
end
|
59
|
+
alias_method :try_convert_int8, :try_convert_integer
|
60
|
+
alias_method :try_convert_uint8, :try_convert_integer
|
61
|
+
alias_method :try_convert_int16, :try_convert_integer
|
62
|
+
alias_method :try_convert_uint16, :try_convert_integer
|
63
|
+
alias_method :try_convert_int32, :try_convert_integer
|
64
|
+
alias_method :try_convert_uint32, :try_convert_integer
|
65
|
+
alias_method :try_convert_int64, :try_convert_integer
|
66
|
+
alias_method :try_convert_uint64, :try_convert_integer
|
67
|
+
|
68
|
+
def try_convert_float(type_info, value)
|
69
|
+
if value.is_a?(Float)
|
70
|
+
value
|
71
|
+
elsif value.respond_to?(:to_f) # TODO: Should we stop this?
|
72
|
+
value.to_f
|
73
|
+
else
|
74
|
+
nil
|
70
75
|
end
|
71
76
|
end
|
72
77
|
|
73
|
-
|
74
|
-
DOUBLE.extend(FloatTypeTag)
|
78
|
+
alias_method :try_convert_double, :try_convert_float
|
75
79
|
|
76
|
-
|
77
|
-
|
78
|
-
GLib::Type.try_convert(value)
|
79
|
-
end
|
80
|
+
def try_convert_gtype(type_info, value)
|
81
|
+
GLib::Type.try_convert(value)
|
80
82
|
end
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
84
|
+
def try_convert_utf8(type_info, value)
|
85
|
+
case value
|
86
|
+
when String
|
87
|
+
value.encode(Encoding::UTF_8)
|
88
|
+
when Symbol
|
89
|
+
value.to_s.encode(Encoding::UTF_8)
|
90
|
+
else
|
91
|
+
if value.respond_to?(:to_str)
|
92
|
+
value.to_str.encode(Encoding::UTF_8)
|
89
93
|
else
|
90
|
-
|
91
|
-
value.to_str.encode(Encoding::UTF_8)
|
92
|
-
else
|
93
|
-
nil
|
94
|
-
end
|
94
|
+
nil
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
99
|
+
def try_convert_filename(type_info, value)
|
100
|
+
case value
|
101
|
+
when String
|
102
|
+
value.encode(GLib::FILENAME_ENCODING)
|
103
|
+
else
|
104
|
+
if value.respond_to?(:to_path)
|
105
|
+
value.to_path.encode(GLib::FILENAME_ENCODING)
|
106
|
+
elsif value.respond_to?(:to_str)
|
107
|
+
value.to_str.encode(GLib::FILENAME_ENCODING)
|
104
108
|
else
|
105
|
-
|
106
|
-
value.to_path.encode(GLib::FILENAME_ENCODING)
|
107
|
-
elsif value.respond_to?(:to_str)
|
108
|
-
value.to_str.encode(GLib::FILENAME_ENCODING)
|
109
|
-
else
|
110
|
-
nil
|
111
|
-
end
|
109
|
+
nil
|
112
110
|
end
|
113
111
|
end
|
114
112
|
end
|
115
113
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
return nil if v.nil?
|
125
|
-
end
|
126
|
-
v
|
114
|
+
def try_convert_array_like(type_info, value)
|
115
|
+
value = Array.try_convert(value)
|
116
|
+
return nil if value.nil?
|
117
|
+
element_type_info = get_element_type_info(type_info)
|
118
|
+
value.collect do |v|
|
119
|
+
unless v.nil?
|
120
|
+
v = element_type_info.try_convert(v)
|
121
|
+
return nil if v.nil?
|
127
122
|
end
|
123
|
+
v
|
128
124
|
end
|
125
|
+
end
|
129
126
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
def get_element_type_info(type_info)
|
136
|
-
type_info.get_param_type(0)
|
137
|
-
end
|
127
|
+
def description_array_like(type_info)
|
128
|
+
element_type_info = type_info.get_param_type(0)
|
129
|
+
"#{nick}(#{element_type_info.description})"
|
138
130
|
end
|
139
131
|
|
140
|
-
|
141
|
-
|
132
|
+
def get_element_type_info(type_info)
|
133
|
+
type_info.get_param_type(0)
|
134
|
+
end
|
142
135
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
end
|
136
|
+
def try_convert_array(type_info, value)
|
137
|
+
case get_element_type_info(type_info).tag
|
138
|
+
when INT8, UINT8
|
139
|
+
case value
|
140
|
+
when String
|
141
|
+
return value
|
142
|
+
when GLib::Bytes
|
143
|
+
return value.to_s
|
152
144
|
end
|
153
|
-
super
|
154
145
|
end
|
146
|
+
try_convert_array_like(type_info, value)
|
155
147
|
end
|
156
148
|
|
157
|
-
|
158
|
-
GSLIST.extend(ArrayTypeTag)
|
149
|
+
alias_method :description_array, :description_array_like
|
159
150
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
value
|
165
|
-
else
|
166
|
-
nil
|
167
|
-
end
|
168
|
-
end
|
151
|
+
alias_method :try_convert_glist, :try_convert_array_like
|
152
|
+
alias_method :description_glist, :description_array_like
|
153
|
+
alias_method :try_convert_gslist, :try_convert_array_like
|
154
|
+
alias_method :description_gslist, :description_array_like
|
169
155
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
156
|
+
def try_convert_ghash(type_info, value)
|
157
|
+
case value
|
158
|
+
when Hash
|
159
|
+
value
|
160
|
+
else
|
161
|
+
nil
|
174
162
|
end
|
175
163
|
end
|
176
164
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
165
|
+
def description_ghash(type_info)
|
166
|
+
key_type = type_info.get_param_type(0)
|
167
|
+
value_type = type_info.get_param_type(1)
|
168
|
+
"#{nick}(#{key_type.description}->#{value_type.description})"
|
169
|
+
end
|
181
170
|
|
182
|
-
|
183
|
-
|
184
|
-
|
171
|
+
def try_convert_interface(type_info, value)
|
172
|
+
type_info.interface.try_convert(value)
|
173
|
+
end
|
174
|
+
|
175
|
+
def description_interface(type_info)
|
176
|
+
"#{nick}(#{type_info.interface.description})"
|
185
177
|
end
|
186
178
|
end
|
187
179
|
end
|
data/test/test-loader.rb
CHANGED
@@ -72,5 +72,19 @@ class TestLoaderInfo < Test::Unit::TestCase
|
|
72
72
|
resettable_converter.resetted
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
def test_ancestor
|
77
|
+
immutable_menu_class = Class.new(Gio::Menu) do
|
78
|
+
type_register("ImmutableMenu")
|
79
|
+
|
80
|
+
def virtual_do_is_mutable
|
81
|
+
false
|
82
|
+
end
|
83
|
+
end
|
84
|
+
immutable_menu = immutable_menu_class.new
|
85
|
+
assert do
|
86
|
+
not immutable_menu.mutable?
|
87
|
+
end
|
88
|
+
end
|
75
89
|
end
|
76
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gobject-introspection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
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:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glib2
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
19
|
+
version: 3.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.
|
26
|
+
version: 3.5.0
|
27
27
|
description: Ruby/GObjectIntrospection provides bindings of GObject Introspection
|
28
28
|
and a loader module that can generate dynamically Ruby bindings of any GObject C
|
29
29
|
libraries
|
@@ -42,7 +42,6 @@ files:
|
|
42
42
|
- ext/gobject-introspection/gobject-introspection-enum-types.h
|
43
43
|
- ext/gobject-introspection/gobject_introspection.def
|
44
44
|
- ext/gobject-introspection/rb-gi-arg-info.c
|
45
|
-
- ext/gobject-introspection/rb-gi-argument.c
|
46
45
|
- ext/gobject-introspection/rb-gi-arguments-in.c
|
47
46
|
- ext/gobject-introspection/rb-gi-arguments-out.c
|
48
47
|
- ext/gobject-introspection/rb-gi-arguments.c
|
@@ -154,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
153
|
- !ruby/object:Gem::Version
|
155
154
|
version: '0'
|
156
155
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
156
|
+
rubygems_version: 3.4.0.dev
|
158
157
|
signing_key:
|
159
158
|
specification_version: 4
|
160
159
|
summary: Ruby/GObjectIntrospection is a Ruby binding of GObject Introspection.
|