gobject-introspection 3.4.6 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- nil
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
- class << BOOLEAN
28
- def try_convert(type_info, value)
29
- case value
30
- when true, false
31
- value
32
- when nil
33
- false
34
- else
35
- nil
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
- module IntegerTypeTag
41
- def try_convert(type_info, value)
42
- if value.is_a?(Integer)
43
- value
44
- elsif value.respond_to?(:to_int)
45
- value.to_int
46
- else
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
- INT8.extend(IntegerTypeTag)
53
- UINT8.extend(IntegerTypeTag)
54
- INT16.extend(IntegerTypeTag)
55
- UINT16.extend(IntegerTypeTag)
56
- INT32.extend(IntegerTypeTag)
57
- UINT32.extend(IntegerTypeTag)
58
- INT64.extend(IntegerTypeTag)
59
- UINT64.extend(IntegerTypeTag)
60
-
61
- module FloatTypeTag
62
- def try_convert(type_info, value)
63
- if value.is_a?(Float)
64
- value
65
- elsif value.respond_to?(:to_f) # TODO: Should we stop this?
66
- value.to_f
67
- else
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
- FLOAT.extend(FloatTypeTag)
74
- DOUBLE.extend(FloatTypeTag)
78
+ alias_method :try_convert_double, :try_convert_float
75
79
 
76
- class << GTYPE
77
- def try_convert(type_info, value)
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
- class << UTF8
83
- def try_convert(type_info, value)
84
- case value
85
- when String
86
- value.encode(Encoding::UTF_8)
87
- when Symbol
88
- value.to_s.encode(Encoding::UTF_8)
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
- if value.respond_to?(:to_str)
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
- class << FILENAME
100
- def try_convert(type_info, value)
101
- case value
102
- when String
103
- value.encode(GLib::FILENAME_ENCODING)
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
- if value.respond_to?(:to_path)
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
- module ArrayTypeTag
117
- def try_convert(type_info, value)
118
- value = Array.try_convert(value)
119
- return nil if value.nil?
120
- element_type_info = get_element_type_info(type_info)
121
- value.collect do |v|
122
- unless v.nil?
123
- v = element_type_info.try_convert(v)
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
- def description(type_info)
131
- element_type_info = type_info.get_param_type(0)
132
- "#{super}(#{element_type_info.description})"
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
- class << ARRAY
141
- include ArrayTypeTag
132
+ def get_element_type_info(type_info)
133
+ type_info.get_param_type(0)
134
+ end
142
135
 
143
- def try_convert(type_info, value)
144
- case get_element_type_info(type_info).tag
145
- when INT8, UINT8
146
- case value
147
- when String
148
- return value
149
- when GLib::Bytes
150
- return value.to_s
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
- GLIST.extend(ArrayTypeTag)
158
- GSLIST.extend(ArrayTypeTag)
149
+ alias_method :description_array, :description_array_like
159
150
 
160
- class << GHASH
161
- def try_convert(type_info, value)
162
- case value
163
- when Hash
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
- def description(type_info)
171
- key_type = type_info.get_param_type(0)
172
- value_type = type_info.get_param_type(1)
173
- "#{super}(#{key_type.description}->#{value_type.description})"
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
- class << INTERFACE
178
- def try_convert(type_info, value)
179
- type_info.interface.try_convert(value)
180
- end
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
- def description(type_info)
183
- "#{super}(#{type_info.interface.description})"
184
- end
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.6
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-07-16 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: glib2
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.4.6
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.4.6
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.3.0.dev
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.