gir_ffi 0.7.7 → 0.7.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/Changelog.md +9 -0
- data/lib/ffi-glib/array.rb +1 -1
- data/lib/ffi-glib/error.rb +1 -2
- data/lib/ffi-glib/hash_table.rb +2 -2
- data/lib/ffi-glib/variant.rb +1 -1
- data/lib/ffi-gobject/base.rb +23 -23
- data/lib/ffi-gobject/object.rb +7 -3
- data/lib/ffi-gobject/value.rb +6 -1
- data/lib/ffi-gobject.rb +9 -6
- data/lib/ffi-gobject_introspection/i_base_info.rb +3 -3
- data/lib/ffi-gobject_introspection/i_constant_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_repository.rb +4 -1
- data/lib/ffi-gobject_introspection/i_type_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_unresolved_info.rb +7 -0
- data/lib/ffi-gobject_introspection/lib.rb +1 -1
- data/lib/gir_ffi/builders/argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +37 -29
- data/lib/gir_ffi/builders/callback_argument_builder.rb +57 -27
- data/lib/gir_ffi/builders/closure_convertor.rb +12 -8
- data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +12 -8
- data/lib/gir_ffi/builders/constructor_result_convertor.rb +11 -7
- data/lib/gir_ffi/builders/field_builder.rb +1 -1
- data/lib/gir_ffi/builders/function_builder.rb +1 -1
- data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +2 -2
- data/lib/gir_ffi/builders/method_template.rb +1 -1
- data/lib/gir_ffi/builders/null_convertor.rb +11 -7
- data/lib/gir_ffi/builders/property_builder.rb +1 -1
- data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +17 -13
- data/lib/gir_ffi/error_argument_info.rb +1 -1
- data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
- data/lib/gir_ffi/info_ext/i_unresolved_info.rb +12 -0
- data/lib/gir_ffi/info_ext/safe_constant_name.rb +2 -2
- data/lib/gir_ffi/info_ext/safe_function_name.rb +1 -1
- data/lib/gir_ffi/info_ext.rb +1 -0
- data/lib/gir_ffi/module_base.rb +1 -1
- data/lib/gir_ffi/receiver_argument_info.rb +15 -12
- data/lib/gir_ffi/user_data_argument_info.rb +17 -15
- data/lib/gir_ffi/user_data_type_info.rb +14 -12
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi-base/gobject/lib.rb +1 -1
- data/test/base_test_helper.rb +15 -15
- data/test/ffi-glib/array_test.rb +38 -38
- data/test/ffi-glib/byte_array_test.rb +6 -7
- data/test/ffi-glib/bytes_test.rb +9 -9
- data/test/ffi-glib/hash_table_test.rb +26 -23
- data/test/ffi-glib/iconv_test.rb +5 -5
- data/test/ffi-glib/list_test.rb +16 -16
- data/test/ffi-glib/main_loop_test.rb +6 -6
- data/test/ffi-glib/ptr_array_test.rb +45 -45
- data/test/ffi-glib/ruby_closure_test.rb +6 -6
- data/test/ffi-glib/s_list_test.rb +15 -15
- data/test/ffi-glib/strv_test.rb +21 -21
- data/test/ffi-glib/variant_test.rb +4 -4
- data/test/ffi-gobject/gobject_test.rb +35 -35
- data/test/ffi-gobject/object_class_test.rb +1 -1
- data/test/ffi-gobject/object_test.rb +29 -6
- data/test/ffi-gobject/value_test.rb +66 -52
- data/test/ffi-gobject_introspection/i_base_info_test.rb +10 -11
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +6 -6
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +4 -5
- data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -2
- data/test/ffi-gobject_introspection/i_object_info_test.rb +5 -5
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +9 -8
- data/test/ffi-gobject_introspection/i_repository_test.rb +16 -16
- data/test/ffi-gobject_introspection/i_type_info_test.rb +16 -2
- data/test/ffi-gobject_introspection/lib_test.rb +2 -2
- data/test/ffi-gobject_test.rb +50 -40
- data/test/gir_ffi/arg_helper_test.rb +5 -5
- data/test/gir_ffi/builder_test.rb +41 -41
- data/test/gir_ffi/builders/argument_builder_test.rb +240 -207
- data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -1
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +81 -15
- data/test/gir_ffi/builders/callback_builder_test.rb +39 -14
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +41 -33
- data/test/gir_ffi/builders/enum_builder_test.rb +3 -3
- data/test/gir_ffi/builders/field_builder_test.rb +17 -17
- data/test/gir_ffi/builders/function_builder_test.rb +16 -16
- data/test/gir_ffi/builders/interface_builder_test.rb +9 -7
- data/test/gir_ffi/builders/module_builder_test.rb +5 -6
- data/test/gir_ffi/builders/object_builder_test.rb +24 -19
- data/test/gir_ffi/builders/property_builder_test.rb +25 -23
- data/test/gir_ffi/builders/registered_type_builder_test.rb +11 -11
- data/test/gir_ffi/builders/return_value_builder_test.rb +237 -197
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +29 -22
- data/test/gir_ffi/builders/struct_builder_test.rb +10 -10
- data/test/gir_ffi/builders/unintrospectable_builder_test.rb +8 -8
- data/test/gir_ffi/builders/union_builder_test.rb +5 -6
- data/test/gir_ffi/builders/user_defined_builder_test.rb +42 -33
- data/test/gir_ffi/builders/vfunc_builder_test.rb +37 -30
- data/test/gir_ffi/callback_base_test.rb +4 -5
- data/test/gir_ffi/class_base_test.rb +35 -28
- data/test/gir_ffi/error_type_info_test.rb +14 -14
- data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -4
- data/test/gir_ffi/g_type_test.rb +6 -6
- data/test/gir_ffi/in_out_pointer_test.rb +27 -27
- data/test/gir_ffi/in_pointer_test.rb +54 -50
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +8 -7
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +7 -7
- data/test/gir_ffi/info_ext/i_field_info_test.rb +10 -8
- data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -15
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +10 -8
- data/test/gir_ffi/info_ext/i_type_info_test.rb +158 -155
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +17 -0
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +12 -10
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +12 -10
- data/test/gir_ffi/interface_base_test.rb +6 -6
- data/test/gir_ffi/method_stubber_test.rb +16 -13
- data/test/gir_ffi/object_base_test.rb +6 -6
- data/test/gir_ffi/sized_array_test.rb +23 -23
- data/test/gir_ffi/type_map_test.rb +3 -3
- data/test/gir_ffi/unintrospectable_type_info_test.rb +18 -18
- data/test/gir_ffi/user_defined_property_info_test.rb +4 -4
- data/test/gir_ffi/user_defined_type_info_test.rb +16 -16
- data/test/gir_ffi/variable_name_generator_test.rb +6 -6
- data/test/gir_ffi/version_test.rb +1 -1
- data/test/gir_ffi/zero_terminated_test.rb +16 -17
- data/test/gir_ffi-base/glib/boolean_test.rb +13 -13
- data/test/gir_ffi-base/glib/strv_test.rb +11 -11
- data/test/gir_ffi_test.rb +18 -18
- data/test/gir_ffi_test_helper.rb +13 -18
- data/test/integration/derived_classes_test.rb +8 -8
- data/test/integration/generated_gimarshallingtests_test.rb +794 -792
- data/test/integration/generated_gio_test.rb +25 -26
- data/test/integration/generated_glib_test.rb +8 -2
- data/test/integration/generated_gobject_test.rb +16 -9
- data/test/integration/generated_pango_ft2_test.rb +1 -2
- data/test/integration/generated_pango_test.rb +2 -2
- data/test/integration/generated_regress_test.rb +785 -705
- data/test/integration/generated_secret_test.rb +5 -5
- data/test/integration/method_lookup_test.rb +5 -5
- data/test/introspection_test_helper.rb +3 -1
- data/test/minitest/stats_plugin.rb +3 -3
- metadata +6 -3
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'gir_ffi_test_helper'
|
2
2
|
|
3
3
|
describe GirFFI::InfoExt::ITypeInfo do
|
4
|
-
let(:klass) {
|
5
|
-
|
6
|
-
|
4
|
+
let(:klass) {
|
5
|
+
Class.new do
|
6
|
+
include GirFFI::InfoExt::ITypeInfo
|
7
|
+
end
|
8
|
+
}
|
7
9
|
|
8
10
|
let(:type_info) { klass.new }
|
9
11
|
let(:elmtype_info) { klass.new }
|
@@ -12,13 +14,15 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
12
14
|
let(:iface_info) { Object.new }
|
13
15
|
|
14
16
|
let(:callback_type_info) {
|
15
|
-
get_introspection_data('Regress', 'test_callback').args[0].argument_type
|
17
|
+
get_introspection_data('Regress', 'test_callback').args[0].argument_type
|
18
|
+
}
|
16
19
|
let(:ghash_type_info) {
|
17
20
|
get_introspection_data('Regress',
|
18
|
-
'test_ghash_nested_everything_return').return_type
|
21
|
+
'test_ghash_nested_everything_return').return_type
|
22
|
+
}
|
19
23
|
|
20
|
-
describe
|
21
|
-
it
|
24
|
+
describe '#to_ffitype' do
|
25
|
+
it 'returns an array with elements subtype and size for type :array' do
|
22
26
|
mock(type_info).pointer? { false }
|
23
27
|
stub(type_info).tag { :array }
|
24
28
|
mock(type_info).array_fixed_size { 2 }
|
@@ -30,7 +34,7 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
30
34
|
assert_equal [:foo, 2], result
|
31
35
|
end
|
32
36
|
|
33
|
-
describe
|
37
|
+
describe 'for an :interface type' do
|
34
38
|
before do
|
35
39
|
stub(type_info).interface { iface_info }
|
36
40
|
stub(type_info).tag { :interface }
|
@@ -45,25 +49,25 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
48
|
-
describe
|
49
|
-
it
|
52
|
+
describe '#element_type' do
|
53
|
+
it 'returns the element type for lists' do
|
50
54
|
stub(elmtype_info).tag { :foo }
|
51
55
|
mock(elmtype_info).pointer? { false }
|
52
56
|
|
53
|
-
mock(type_info).tag {:glist}
|
57
|
+
mock(type_info).tag { :glist }
|
54
58
|
mock(type_info).param_type(0) { elmtype_info }
|
55
59
|
|
56
60
|
result = type_info.element_type
|
57
61
|
result.must_equal :foo
|
58
62
|
end
|
59
63
|
|
60
|
-
it
|
64
|
+
it 'returns the key and value types for ghashes' do
|
61
65
|
stub(keytype_info).tag { :foo }
|
62
66
|
mock(keytype_info).pointer? { false }
|
63
67
|
stub(valtype_info).tag { :bar }
|
64
68
|
mock(valtype_info).pointer? { false }
|
65
69
|
|
66
|
-
mock(type_info).tag {:ghash}
|
70
|
+
mock(type_info).tag { :ghash }
|
67
71
|
mock(type_info).param_type(0) { keytype_info }
|
68
72
|
mock(type_info).param_type(1) { valtype_info }
|
69
73
|
|
@@ -71,41 +75,41 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
71
75
|
result.must_equal [:foo, :bar]
|
72
76
|
end
|
73
77
|
|
74
|
-
it
|
75
|
-
mock(type_info).tag {:foo}
|
78
|
+
it 'returns nil for other types' do
|
79
|
+
mock(type_info).tag { :foo }
|
76
80
|
|
77
81
|
result = type_info.element_type
|
78
82
|
result.must_be_nil
|
79
83
|
end
|
80
84
|
|
81
|
-
it
|
85
|
+
it 'returns [:pointer, :void] if the element type is a pointer with tag :void' do
|
82
86
|
stub(elmtype_info).tag_or_class { [:pointer, :void] }
|
83
87
|
|
84
|
-
mock(type_info).tag {:glist}
|
88
|
+
mock(type_info).tag { :glist }
|
85
89
|
mock(type_info).param_type(0) { elmtype_info }
|
86
90
|
|
87
91
|
assert_equal [:pointer, :void], type_info.element_type
|
88
92
|
end
|
89
93
|
end
|
90
94
|
|
91
|
-
describe
|
92
|
-
describe
|
93
|
-
it
|
95
|
+
describe '#flattened_tag' do
|
96
|
+
describe 'for a simple type' do
|
97
|
+
it 'returns the type tag' do
|
94
98
|
stub(type_info).tag { :uint32 }
|
95
99
|
|
96
100
|
type_info.flattened_tag.must_equal :uint32
|
97
101
|
end
|
98
102
|
end
|
99
103
|
|
100
|
-
describe
|
104
|
+
describe 'for a zero-terminated array' do
|
101
105
|
before do
|
102
106
|
stub(type_info).tag { :array }
|
103
107
|
stub(type_info).param_type(0) { elmtype_info }
|
104
108
|
stub(type_info).zero_terminated? { true }
|
105
109
|
end
|
106
110
|
|
107
|
-
describe
|
108
|
-
it
|
111
|
+
describe 'of utf8' do
|
112
|
+
it 'returns :strv' do
|
109
113
|
stub(elmtype_info).tag { :utf8 }
|
110
114
|
stub(elmtype_info).pointer? { true }
|
111
115
|
|
@@ -113,8 +117,8 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
113
117
|
end
|
114
118
|
end
|
115
119
|
|
116
|
-
describe
|
117
|
-
it
|
120
|
+
describe 'of filename' do
|
121
|
+
it 'returns :strv' do
|
118
122
|
stub(elmtype_info).tag { :filename }
|
119
123
|
stub(elmtype_info).pointer? { true }
|
120
124
|
|
@@ -122,8 +126,8 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
122
126
|
end
|
123
127
|
end
|
124
128
|
|
125
|
-
describe
|
126
|
-
it
|
129
|
+
describe 'of another type' do
|
130
|
+
it 'returns :zero_terminated' do
|
127
131
|
stub(elmtype_info).tag { :foo }
|
128
132
|
stub(elmtype_info).pointer? { false }
|
129
133
|
|
@@ -132,8 +136,8 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
132
136
|
end
|
133
137
|
end
|
134
138
|
|
135
|
-
describe
|
136
|
-
it
|
139
|
+
describe 'for a fixed length c-like array' do
|
140
|
+
it 'returns :c' do
|
137
141
|
mock(type_info).tag { :array }
|
138
142
|
mock(type_info).zero_terminated? { false }
|
139
143
|
mock(type_info).array_type { :c }
|
@@ -142,8 +146,8 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
142
146
|
end
|
143
147
|
end
|
144
148
|
|
145
|
-
describe
|
146
|
-
it
|
149
|
+
describe 'for a GLib array' do
|
150
|
+
it 'returns :c' do
|
147
151
|
mock(type_info).tag { :array }
|
148
152
|
mock(type_info).zero_terminated? { false }
|
149
153
|
mock(type_info).array_type { :array }
|
@@ -153,8 +157,8 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
153
157
|
end
|
154
158
|
end
|
155
159
|
|
156
|
-
describe
|
157
|
-
describe
|
160
|
+
describe '#tag_or_class' do
|
161
|
+
describe 'for a simple type' do
|
158
162
|
it "returns the type's tag" do
|
159
163
|
stub(type_info).tag { :foo }
|
160
164
|
mock(type_info).pointer? { false }
|
@@ -163,8 +167,8 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
163
167
|
end
|
164
168
|
end
|
165
169
|
|
166
|
-
describe
|
167
|
-
it
|
170
|
+
describe 'for utf8 strings' do
|
171
|
+
it 'returns the tag :utf8' do
|
168
172
|
stub(type_info).tag { :utf8 }
|
169
173
|
mock(type_info).pointer? { true }
|
170
174
|
|
@@ -172,8 +176,8 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
172
176
|
end
|
173
177
|
end
|
174
178
|
|
175
|
-
describe
|
176
|
-
it
|
179
|
+
describe 'for filename strings' do
|
180
|
+
it 'returns the tag :filename' do
|
177
181
|
stub(type_info).tag { :filename }
|
178
182
|
mock(type_info).pointer? { true }
|
179
183
|
|
@@ -181,7 +185,7 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
181
185
|
end
|
182
186
|
end
|
183
187
|
|
184
|
-
describe
|
188
|
+
describe 'for an interface class' do
|
185
189
|
let(:interface) { Object.new }
|
186
190
|
|
187
191
|
before do
|
@@ -192,24 +196,24 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
192
196
|
mock(GirFFI::Builder).build_class(iface_info) { interface }
|
193
197
|
end
|
194
198
|
|
195
|
-
describe
|
196
|
-
it
|
199
|
+
describe 'when the interface type is :enum' do
|
200
|
+
it 'returns the built interface module' do
|
197
201
|
stub(iface_info).info_type { :enum }
|
198
202
|
|
199
203
|
type_info.tag_or_class.must_equal interface
|
200
204
|
end
|
201
205
|
end
|
202
206
|
|
203
|
-
describe
|
204
|
-
it
|
207
|
+
describe 'when the interface type is :object' do
|
208
|
+
it 'returns the built interface class' do
|
205
209
|
stub(iface_info).info_type { :object }
|
206
210
|
|
207
211
|
type_info.tag_or_class.must_equal interface
|
208
212
|
end
|
209
213
|
end
|
210
214
|
|
211
|
-
describe
|
212
|
-
it
|
215
|
+
describe 'when the interface type is :struct' do
|
216
|
+
it 'returns the built interface class' do
|
213
217
|
stub(iface_info).info_type { :struct }
|
214
218
|
|
215
219
|
type_info.tag_or_class.must_equal interface
|
@@ -218,14 +222,14 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
218
222
|
|
219
223
|
end
|
220
224
|
|
221
|
-
describe
|
225
|
+
describe 'for a callback' do
|
222
226
|
it "returns the callback's wrapper class" do
|
223
227
|
callback_type_info.tag_or_class.must_equal Regress::TestCallback
|
224
228
|
end
|
225
229
|
end
|
226
230
|
|
227
|
-
describe
|
228
|
-
it
|
231
|
+
describe 'for a pointer to simple type :foo' do
|
232
|
+
it 'returns [:pointer, :foo]' do
|
229
233
|
stub(type_info).tag { :foo }
|
230
234
|
mock(type_info).pointer? { true }
|
231
235
|
|
@@ -233,8 +237,8 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
233
237
|
end
|
234
238
|
end
|
235
239
|
|
236
|
-
describe
|
237
|
-
it
|
240
|
+
describe 'for a pointer to :void' do
|
241
|
+
it 'returns [:pointer, :void]' do
|
238
242
|
stub(type_info).tag { :void }
|
239
243
|
stub(type_info).pointer? { true }
|
240
244
|
|
@@ -242,33 +246,33 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
242
246
|
end
|
243
247
|
end
|
244
248
|
|
245
|
-
describe
|
246
|
-
it
|
249
|
+
describe 'for a complex nested hash type' do
|
250
|
+
it 'returns a representeation of the nested structure' do
|
247
251
|
ghash_type_info.tag_or_class.must_equal(
|
248
|
-
[
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
252
|
+
[:pointer,
|
253
|
+
[:ghash,
|
254
|
+
:utf8,
|
255
|
+
[:pointer,
|
256
|
+
[:ghash, :utf8, :utf8]]]])
|
253
257
|
end
|
254
258
|
end
|
255
259
|
end
|
256
260
|
|
257
|
-
describe
|
258
|
-
describe
|
261
|
+
describe '#to_callback_ffitype' do
|
262
|
+
describe 'for an :interface argument' do
|
259
263
|
before do
|
260
264
|
stub(type_info).interface { iface_info }
|
261
265
|
stub(type_info).tag { :interface }
|
262
266
|
stub(type_info).pointer? { false }
|
263
267
|
end
|
264
268
|
|
265
|
-
it
|
269
|
+
it 'correctly maps a :union argument to :pointer' do
|
266
270
|
stub(iface_info).info_type { :union }
|
267
271
|
|
268
272
|
type_info.to_callback_ffitype.must_equal :pointer
|
269
273
|
end
|
270
274
|
|
271
|
-
it
|
275
|
+
it 'correctly maps a :flags argument to :int32' do
|
272
276
|
stub(iface_info).info_type { :flags }
|
273
277
|
|
274
278
|
type_info.to_callback_ffitype.must_equal :int32
|
@@ -276,28 +280,28 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
276
280
|
end
|
277
281
|
end
|
278
282
|
|
279
|
-
describe
|
280
|
-
describe
|
283
|
+
describe '#extra_conversion_arguments' do
|
284
|
+
describe 'for normal types' do
|
281
285
|
before do
|
282
286
|
stub(type_info).tag { :foo }
|
283
287
|
end
|
284
288
|
|
285
|
-
it
|
289
|
+
it 'returns an empty array' do
|
286
290
|
type_info.extra_conversion_arguments.must_equal []
|
287
291
|
end
|
288
292
|
end
|
289
293
|
|
290
|
-
describe
|
294
|
+
describe 'for a string' do
|
291
295
|
before do
|
292
296
|
stub(type_info).tag { :utf8 }
|
293
297
|
end
|
294
298
|
|
295
|
-
it
|
299
|
+
it 'returns an array containing :utf8' do
|
296
300
|
type_info.extra_conversion_arguments.must_equal [:utf8]
|
297
301
|
end
|
298
302
|
end
|
299
303
|
|
300
|
-
describe
|
304
|
+
describe 'for a fixed-size array' do
|
301
305
|
before do
|
302
306
|
stub(type_info).tag { :array }
|
303
307
|
stub(type_info).zero_terminated? { false }
|
@@ -308,12 +312,12 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
308
312
|
stub(elmtype_info).tag_or_class { :foo }
|
309
313
|
end
|
310
314
|
|
311
|
-
it
|
315
|
+
it 'returns an array containing the element type' do
|
312
316
|
type_info.extra_conversion_arguments.must_equal [:foo, 3]
|
313
317
|
end
|
314
318
|
end
|
315
319
|
|
316
|
-
describe
|
320
|
+
describe 'for a zero-terminated array' do
|
317
321
|
before do
|
318
322
|
stub(type_info).tag { :array }
|
319
323
|
stub(type_info).zero_terminated? { true }
|
@@ -322,12 +326,12 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
322
326
|
stub(elmtype_info).tag_or_class { :foo }
|
323
327
|
end
|
324
328
|
|
325
|
-
it
|
329
|
+
it 'returns an array containing the element type' do
|
326
330
|
type_info.extra_conversion_arguments.must_equal [:foo]
|
327
331
|
end
|
328
332
|
end
|
329
333
|
|
330
|
-
describe
|
334
|
+
describe 'for a GArray' do
|
331
335
|
before do
|
332
336
|
stub(type_info).tag { :array }
|
333
337
|
stub(type_info).zero_terminated? { false }
|
@@ -337,14 +341,14 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
337
341
|
stub(elmtype_info).tag_or_class { :foo }
|
338
342
|
end
|
339
343
|
|
340
|
-
it
|
344
|
+
it 'returns an array containing the element type' do
|
341
345
|
type_info.extra_conversion_arguments.must_equal [:foo]
|
342
346
|
end
|
343
347
|
end
|
344
348
|
|
345
|
-
describe
|
349
|
+
describe 'for a GHashTable' do
|
346
350
|
before do
|
347
|
-
stub(type_info).tag {:ghash}
|
351
|
+
stub(type_info).tag { :ghash }
|
348
352
|
stub(type_info).param_type(0) { keytype_info }
|
349
353
|
stub(type_info).param_type(1) { valtype_info }
|
350
354
|
|
@@ -352,12 +356,12 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
352
356
|
stub(valtype_info).tag_or_class { :bar }
|
353
357
|
end
|
354
358
|
|
355
|
-
it
|
359
|
+
it 'returns an array containing the element type pair' do
|
356
360
|
type_info.extra_conversion_arguments.must_equal [[:foo, :bar]]
|
357
361
|
end
|
358
362
|
end
|
359
363
|
|
360
|
-
describe
|
364
|
+
describe 'for a GList' do
|
361
365
|
before do
|
362
366
|
stub(type_info).tag { :glist }
|
363
367
|
|
@@ -365,12 +369,12 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
365
369
|
stub(elmtype_info).tag_or_class { :foo }
|
366
370
|
end
|
367
371
|
|
368
|
-
it
|
372
|
+
it 'returns an array containing the element type' do
|
369
373
|
type_info.extra_conversion_arguments.must_equal [:foo]
|
370
374
|
end
|
371
375
|
end
|
372
376
|
|
373
|
-
describe
|
377
|
+
describe 'for a GSList' do
|
374
378
|
before do
|
375
379
|
stub(type_info).tag { :gslist }
|
376
380
|
|
@@ -378,56 +382,55 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
378
382
|
stub(elmtype_info).tag_or_class { :foo }
|
379
383
|
end
|
380
384
|
|
381
|
-
it
|
385
|
+
it 'returns an array containing the element type' do
|
382
386
|
type_info.extra_conversion_arguments.must_equal [:foo]
|
383
387
|
end
|
384
388
|
end
|
385
389
|
|
386
|
-
describe
|
390
|
+
describe 'for a GPtrArray' do
|
387
391
|
before do
|
388
392
|
stub(type_info).tag { :array }
|
389
393
|
stub(type_info).zero_terminated? { false }
|
390
394
|
stub(type_info).array_type { :ptr_array }
|
391
395
|
|
392
|
-
|
393
396
|
stub(type_info).param_type(0) { elmtype_info }
|
394
397
|
stub(elmtype_info).tag_or_class { :foo }
|
395
398
|
end
|
396
399
|
|
397
|
-
it
|
400
|
+
it 'returns an array containing the element type' do
|
398
401
|
type_info.extra_conversion_arguments.must_equal [:foo]
|
399
402
|
end
|
400
403
|
end
|
401
404
|
|
402
|
-
describe
|
405
|
+
describe 'for a :callback' do
|
403
406
|
before do
|
404
|
-
stub(interface_type_info = Object.new).namespace {
|
405
|
-
stub(interface_type_info).name {
|
407
|
+
stub(interface_type_info = Object.new).namespace { 'Bar' }
|
408
|
+
stub(interface_type_info).name { 'Foo' }
|
406
409
|
|
407
410
|
stub(type_info).tag { :callback }
|
408
411
|
stub(type_info).interface { interface_type_info }
|
409
412
|
end
|
410
413
|
|
411
|
-
it
|
414
|
+
it 'returns an empty array' do
|
412
415
|
type_info.extra_conversion_arguments.must_equal []
|
413
416
|
end
|
414
417
|
end
|
415
418
|
end
|
416
419
|
|
417
|
-
describe
|
420
|
+
describe '#argument_class_name' do
|
418
421
|
before do
|
419
422
|
stub(type_info).tag { tag }
|
420
423
|
end
|
421
424
|
|
422
|
-
describe
|
425
|
+
describe 'for :gint32' do
|
423
426
|
let(:tag) { :gint32 }
|
424
427
|
|
425
|
-
it
|
428
|
+
it 'is nil' do
|
426
429
|
type_info.argument_class_name.must_be_nil
|
427
430
|
end
|
428
431
|
end
|
429
432
|
|
430
|
-
describe
|
433
|
+
describe 'for interfaces' do
|
431
434
|
let(:tag) { :interface }
|
432
435
|
|
433
436
|
before do
|
@@ -436,253 +439,253 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
436
439
|
stub(iface_info).full_type_name { 'Bar::Foo' }
|
437
440
|
end
|
438
441
|
|
439
|
-
describe
|
442
|
+
describe 'for :struct' do
|
440
443
|
let(:interface_type) { :struct }
|
441
|
-
it
|
444
|
+
it 'equals the struct class name' do
|
442
445
|
type_info.argument_class_name.must_equal 'Bar::Foo'
|
443
446
|
end
|
444
447
|
end
|
445
448
|
|
446
|
-
describe
|
449
|
+
describe 'for :union' do
|
447
450
|
let(:interface_type) { :union }
|
448
|
-
it
|
451
|
+
it 'equals the union class name' do
|
449
452
|
type_info.argument_class_name.must_equal 'Bar::Foo'
|
450
453
|
end
|
451
454
|
end
|
452
455
|
|
453
|
-
describe
|
456
|
+
describe 'for :interface' do
|
454
457
|
let(:interface_type) { :interface }
|
455
458
|
|
456
|
-
it
|
459
|
+
it 'equals the interface module name' do
|
457
460
|
type_info.argument_class_name.must_equal 'Bar::Foo'
|
458
461
|
end
|
459
462
|
end
|
460
463
|
|
461
|
-
describe
|
464
|
+
describe 'for :object' do
|
462
465
|
let(:interface_type) { :object }
|
463
466
|
|
464
|
-
it
|
467
|
+
it 'equals the object class name' do
|
465
468
|
type_info.argument_class_name.must_equal 'Bar::Foo'
|
466
469
|
end
|
467
470
|
end
|
468
471
|
|
469
|
-
describe
|
472
|
+
describe 'for :callback' do
|
470
473
|
let(:interface_type) { :callback }
|
471
474
|
|
472
|
-
it
|
475
|
+
it 'equals the callback type name' do
|
473
476
|
type_info.argument_class_name.must_equal 'Bar::Foo'
|
474
477
|
end
|
475
478
|
end
|
476
479
|
end
|
477
480
|
|
478
|
-
describe
|
481
|
+
describe 'for :strv' do
|
479
482
|
let(:tag) { :strv }
|
480
483
|
|
481
|
-
it
|
484
|
+
it 'equals GLib::Strv' do
|
482
485
|
type_info.argument_class_name.must_equal 'GLib::Strv'
|
483
486
|
end
|
484
487
|
end
|
485
488
|
|
486
|
-
describe
|
489
|
+
describe 'for arrays' do
|
487
490
|
let(:tag) { :array }
|
488
491
|
before do
|
489
492
|
stub(type_info).param_type(0) { elmtype_info }
|
490
493
|
stub(elmtype_info).tag_or_class { :foo }
|
491
494
|
end
|
492
495
|
|
493
|
-
describe
|
496
|
+
describe 'for :zero_terminated' do
|
494
497
|
before do
|
495
498
|
stub(type_info).zero_terminated? { true }
|
496
499
|
end
|
497
500
|
|
498
|
-
it
|
499
|
-
type_info.argument_class_name.must_equal
|
501
|
+
it 'equals GirFFI::ZeroTerminated' do
|
502
|
+
type_info.argument_class_name.must_equal 'GirFFI::ZeroTerminated'
|
500
503
|
end
|
501
504
|
end
|
502
505
|
|
503
|
-
describe
|
506
|
+
describe 'for :byte_array' do
|
504
507
|
before do
|
505
508
|
stub(type_info).zero_terminated? { false }
|
506
509
|
stub(type_info).array_type { :byte_array }
|
507
510
|
end
|
508
511
|
|
509
|
-
it
|
512
|
+
it 'equals GLib::ByteArray' do
|
510
513
|
type_info.argument_class_name.must_equal 'GLib::ByteArray'
|
511
514
|
end
|
512
515
|
end
|
513
516
|
|
514
|
-
describe
|
517
|
+
describe 'for :ptr_array' do
|
515
518
|
before do
|
516
519
|
stub(type_info).zero_terminated? { false }
|
517
520
|
stub(type_info).array_type { :ptr_array }
|
518
521
|
end
|
519
522
|
|
520
|
-
it
|
523
|
+
it 'equals GLib::PtrArray' do
|
521
524
|
type_info.argument_class_name.must_equal 'GLib::PtrArray'
|
522
525
|
end
|
523
526
|
end
|
524
527
|
|
525
|
-
describe
|
528
|
+
describe 'for :array' do
|
526
529
|
before do
|
527
530
|
stub(type_info).zero_terminated? { false }
|
528
531
|
stub(type_info).array_type { :array }
|
529
532
|
end
|
530
533
|
|
531
|
-
it
|
534
|
+
it 'equals GLib::Array' do
|
532
535
|
type_info.argument_class_name.must_equal 'GLib::Array'
|
533
536
|
end
|
534
537
|
end
|
535
538
|
end
|
536
539
|
|
537
|
-
describe
|
540
|
+
describe 'for :glist' do
|
538
541
|
let(:tag) { :glist }
|
539
542
|
|
540
|
-
it
|
543
|
+
it 'equals GLib::List' do
|
541
544
|
type_info.argument_class_name.must_equal 'GLib::List'
|
542
545
|
end
|
543
546
|
end
|
544
547
|
|
545
|
-
describe
|
548
|
+
describe 'for :gslist' do
|
546
549
|
let(:tag) { :gslist }
|
547
550
|
|
548
|
-
it
|
551
|
+
it 'equals GLib::SList' do
|
549
552
|
type_info.argument_class_name.must_equal 'GLib::SList'
|
550
553
|
end
|
551
554
|
end
|
552
555
|
|
553
|
-
describe
|
556
|
+
describe 'for :ghash' do
|
554
557
|
let(:tag) { :ghash }
|
555
558
|
|
556
|
-
it
|
559
|
+
it 'equals GLib::HashTable' do
|
557
560
|
type_info.argument_class_name.must_equal 'GLib::HashTable'
|
558
561
|
end
|
559
562
|
end
|
560
563
|
|
561
|
-
describe
|
564
|
+
describe 'for :error' do
|
562
565
|
let(:tag) { :error }
|
563
566
|
|
564
|
-
it
|
567
|
+
it 'equals GLib::Error' do
|
565
568
|
type_info.argument_class_name.must_equal 'GLib::Error'
|
566
569
|
end
|
567
570
|
end
|
568
571
|
end
|
569
572
|
|
570
|
-
describe
|
573
|
+
describe '#g_type' do
|
571
574
|
before do
|
572
575
|
stub(type_info).tag { tag }
|
573
576
|
stub(type_info).pointer? { pointer? }
|
574
577
|
end
|
575
578
|
|
576
|
-
describe
|
579
|
+
describe 'for :void' do
|
577
580
|
let(:tag) { :void }
|
578
581
|
let(:pointer?) { false }
|
579
582
|
|
580
|
-
it
|
581
|
-
GObject.type_name(type_info.g_type).must_equal
|
583
|
+
it 'equals the none type' do
|
584
|
+
GObject.type_name(type_info.g_type).must_equal 'void'
|
582
585
|
end
|
583
586
|
end
|
584
587
|
|
585
|
-
describe
|
588
|
+
describe 'for :gboolean' do
|
586
589
|
let(:tag) { :gboolean }
|
587
590
|
let(:pointer?) { false }
|
588
591
|
|
589
|
-
it
|
590
|
-
GObject.type_name(type_info.g_type).must_equal
|
592
|
+
it 'equals the gboolean type' do
|
593
|
+
GObject.type_name(type_info.g_type).must_equal 'gboolean'
|
591
594
|
end
|
592
595
|
end
|
593
596
|
|
594
|
-
describe
|
597
|
+
describe 'for :gint32' do
|
595
598
|
let(:tag) { :gint32 }
|
596
599
|
let(:pointer?) { false }
|
597
600
|
|
598
|
-
it
|
599
|
-
GObject.type_name(type_info.g_type).must_equal
|
601
|
+
it 'equals the gint type' do
|
602
|
+
GObject.type_name(type_info.g_type).must_equal 'gint'
|
600
603
|
end
|
601
604
|
end
|
602
605
|
|
603
|
-
describe
|
606
|
+
describe 'for :gint64' do
|
604
607
|
let(:tag) { :gint64 }
|
605
608
|
let(:pointer?) { false }
|
606
609
|
|
607
|
-
it
|
608
|
-
GObject.type_name(type_info.g_type).must_equal
|
610
|
+
it 'equals the gint64 type' do
|
611
|
+
GObject.type_name(type_info.g_type).must_equal 'gint64'
|
609
612
|
end
|
610
613
|
end
|
611
614
|
|
612
|
-
describe
|
615
|
+
describe 'for :guint64' do
|
613
616
|
let(:tag) { :guint64 }
|
614
617
|
let(:pointer?) { false }
|
615
618
|
|
616
|
-
it
|
617
|
-
GObject.type_name(type_info.g_type).must_equal
|
619
|
+
it 'equals the guint64 type' do
|
620
|
+
GObject.type_name(type_info.g_type).must_equal 'guint64'
|
618
621
|
end
|
619
622
|
end
|
620
623
|
|
621
|
-
describe
|
624
|
+
describe 'for pointer to :utf8' do
|
622
625
|
let(:tag) { :utf8 }
|
623
626
|
let(:pointer?) { true }
|
624
627
|
|
625
|
-
it
|
626
|
-
GObject.type_name(type_info.g_type).must_equal
|
628
|
+
it 'equals the gchararray type' do
|
629
|
+
GObject.type_name(type_info.g_type).must_equal 'gchararray'
|
627
630
|
end
|
628
631
|
end
|
629
632
|
|
630
|
-
describe
|
633
|
+
describe 'for pointer to :ghash' do
|
631
634
|
let(:tag) { :ghash }
|
632
635
|
let(:pointer?) { true }
|
633
636
|
|
634
|
-
it
|
635
|
-
GObject.type_name(type_info.g_type).must_equal
|
637
|
+
it 'equals the GHashTable type' do
|
638
|
+
GObject.type_name(type_info.g_type).must_equal 'GHashTable'
|
636
639
|
end
|
637
640
|
end
|
638
641
|
|
639
|
-
describe
|
642
|
+
describe 'for arrays' do
|
640
643
|
let(:tag) { :array }
|
641
644
|
let(:pointer?) { true }
|
642
645
|
|
643
|
-
describe
|
646
|
+
describe 'for pointer to GArray' do
|
644
647
|
before do
|
645
648
|
stub(type_info).zero_terminated? { false }
|
646
649
|
stub(type_info).array_type { :array }
|
647
650
|
end
|
648
651
|
|
649
|
-
it
|
650
|
-
GObject.type_name(type_info.g_type).must_equal
|
652
|
+
it 'equals the GArray type' do
|
653
|
+
GObject.type_name(type_info.g_type).must_equal 'GArray'
|
651
654
|
end
|
652
655
|
end
|
653
656
|
|
654
|
-
describe
|
657
|
+
describe 'for a C array' do
|
655
658
|
before do
|
656
659
|
stub(type_info).zero_terminated? { false }
|
657
660
|
stub(type_info).array_type { :c }
|
658
661
|
end
|
659
662
|
|
660
|
-
it
|
661
|
-
GObject.type_name(type_info.g_type).must_equal
|
663
|
+
it 'equals the gpointer type' do
|
664
|
+
GObject.type_name(type_info.g_type).must_equal 'gpointer'
|
662
665
|
end
|
663
666
|
end
|
664
667
|
|
665
|
-
describe
|
668
|
+
describe 'for a zero-terminated array' do
|
666
669
|
before do
|
667
670
|
stub(type_info).param_type(0) { elmtype_info }
|
668
671
|
stub(type_info).zero_terminated? { true }
|
669
672
|
end
|
670
673
|
|
671
|
-
describe
|
672
|
-
it
|
674
|
+
describe 'of utf8' do
|
675
|
+
it 'equals the GStrv type' do
|
673
676
|
stub(elmtype_info).tag { :utf8 }
|
674
677
|
stub(elmtype_info).pointer? { true }
|
675
678
|
|
676
|
-
GObject.type_name(type_info.g_type).must_equal
|
679
|
+
GObject.type_name(type_info.g_type).must_equal 'GStrv'
|
677
680
|
end
|
678
681
|
end
|
679
682
|
|
680
|
-
describe
|
681
|
-
it
|
683
|
+
describe 'of filename' do
|
684
|
+
it 'equals the GStrv type' do
|
682
685
|
stub(elmtype_info).tag { :filename }
|
683
686
|
stub(elmtype_info).pointer? { true }
|
684
687
|
|
685
|
-
GObject.type_name(type_info.g_type).must_equal
|
688
|
+
GObject.type_name(type_info.g_type).must_equal 'GStrv'
|
686
689
|
end
|
687
690
|
end
|
688
691
|
end
|