gir_ffi 0.6.7 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{History.txt → Changelog.md} +93 -61
- data/{DESIGN.rdoc → DESIGN.md} +7 -7
- data/README.md +5 -7
- data/TODO.md +90 -0
- data/lib/ffi-glib.rb +0 -1
- data/lib/ffi-glib/array.rb +13 -29
- data/lib/ffi-glib/array_methods.rb +13 -0
- data/lib/ffi-glib/container_class_methods.rb +6 -1
- data/lib/ffi-glib/hash_table.rb +3 -2
- data/lib/ffi-glib/list.rb +3 -17
- data/lib/ffi-glib/list_methods.rb +22 -3
- data/lib/ffi-glib/ptr_array.rb +19 -19
- data/lib/ffi-glib/s_list.rb +3 -17
- data/lib/ffi-gobject.rb +10 -17
- data/lib/ffi-gobject/object.rb +19 -9
- data/lib/ffi-gobject/object_class.rb +14 -0
- data/lib/ffi-gobject/ruby_closure.rb +4 -5
- data/lib/ffi-gobject/value.rb +7 -5
- data/lib/ffi-gobject_introspection/i_vfunc_info.rb +1 -1
- data/lib/gir_ffi-base.rb +0 -2
- data/lib/gir_ffi-base/gobject.rb +1 -0
- data/lib/gir_ffi-base/gobject/lib.rb +1 -1
- data/lib/gir_ffi.rb +2 -0
- data/lib/gir_ffi/arg_helper.rb +18 -8
- data/lib/gir_ffi/builders/argument_builder.rb +62 -55
- data/lib/gir_ffi/builders/base_argument_builder.rb +52 -106
- data/lib/gir_ffi/builders/base_type_builder.rb +3 -3
- data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +34 -0
- data/lib/gir_ffi/builders/callback_argument_builder.rb +73 -0
- data/lib/gir_ffi/builders/callback_builder.rb +19 -9
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +54 -0
- data/lib/gir_ffi/builders/closure_convertor.rb +9 -0
- data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +9 -0
- data/lib/gir_ffi/builders/constructor_result_convertor.rb +9 -0
- data/lib/gir_ffi/builders/enum_builder.rb +16 -16
- data/lib/gir_ffi/builders/field_builder.rb +36 -15
- data/lib/gir_ffi/builders/function_builder.rb +32 -27
- data/lib/gir_ffi/builders/interface_builder.rb +14 -4
- data/lib/gir_ffi/builders/mapping_method_builder.rb +95 -43
- data/lib/gir_ffi/builders/module_builder.rb +22 -35
- data/lib/gir_ffi/builders/null_convertor.rb +9 -0
- data/lib/gir_ffi/builders/object_builder.rb +11 -14
- data/lib/gir_ffi/builders/property_builder.rb +107 -9
- data/lib/gir_ffi/builders/registered_type_builder.rb +2 -2
- data/lib/gir_ffi/builders/return_value_builder.rb +42 -33
- data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +15 -0
- data/lib/gir_ffi/builders/signal_builder.rb +18 -58
- data/lib/gir_ffi/builders/struct_builder.rb +1 -2
- data/lib/gir_ffi/builders/type_builder.rb +1 -0
- data/lib/gir_ffi/builders/unintrospectable_builder.rb +4 -4
- data/lib/gir_ffi/builders/user_defined_builder.rb +151 -26
- data/lib/gir_ffi/builders/vfunc_builder.rb +57 -0
- data/lib/gir_ffi/builders/with_layout.rb +10 -8
- data/lib/gir_ffi/builders/with_methods.rb +1 -1
- data/lib/gir_ffi/callback_base.rb +42 -8
- data/lib/gir_ffi/class_base.rb +1 -2
- data/lib/gir_ffi/enum_base.rb +26 -4
- data/lib/gir_ffi/error_argument_info.rb +21 -0
- data/lib/gir_ffi/{setter_argument_info.rb → field_argument_info.rb} +2 -1
- data/lib/gir_ffi/g_type.rb +25 -0
- data/lib/gir_ffi/in_out_pointer.rb +3 -14
- data/lib/gir_ffi/in_pointer.rb +20 -21
- data/lib/gir_ffi/info_ext.rb +2 -0
- data/lib/gir_ffi/info_ext/i_callable_info.rb +0 -9
- data/lib/gir_ffi/info_ext/i_callback_info.rb +17 -0
- data/lib/gir_ffi/info_ext/i_function_info.rb +4 -0
- data/lib/gir_ffi/info_ext/i_property_info.rb +4 -0
- data/lib/gir_ffi/info_ext/i_registered_type_info.rb +1 -0
- data/lib/gir_ffi/info_ext/i_signal_info.rb +14 -16
- data/lib/gir_ffi/info_ext/i_type_info.rb +72 -34
- data/lib/gir_ffi/info_ext/i_vfunc_info.rb +12 -0
- data/lib/gir_ffi/info_ext/safe_constant_name.rb +3 -2
- data/lib/gir_ffi/interface_base.rb +8 -3
- data/lib/gir_ffi/module_base.rb +3 -5
- data/lib/gir_ffi/object_base.rb +8 -0
- data/lib/gir_ffi/receiver_argument_info.rb +21 -0
- data/lib/gir_ffi/receiver_type_info.rb +27 -0
- data/lib/gir_ffi/return_value_info.rb +23 -0
- data/lib/gir_ffi/signal_base.rb +1 -1
- data/lib/{ffi-glib → gir_ffi}/sized_array.rb +10 -6
- data/lib/gir_ffi/struct_base.rb +10 -9
- data/lib/gir_ffi/type_base.rb +1 -0
- data/lib/gir_ffi/type_map.rb +3 -0
- data/lib/gir_ffi/unintrospectable_type_info.rb +4 -1
- data/lib/gir_ffi/union_base.rb +4 -21
- data/lib/gir_ffi/user_data_argument_info.rb +21 -0
- data/lib/gir_ffi/user_data_type_info.rb +17 -0
- data/lib/gir_ffi/user_defined_type_info.rb +18 -4
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi/vfunc_base.rb +8 -0
- data/lib/gir_ffi/vfunc_implementation.rb +11 -0
- data/lib/gir_ffi/zero_terminated.rb +18 -24
- data/test/base_test_helper.rb +2 -3
- data/test/ffi-glib/array_test.rb +3 -3
- data/test/ffi-glib/ruby_closure_test.rb +3 -3
- data/test/ffi-gobject/value_test.rb +15 -1
- data/test/ffi-gobject_test.rb +2 -1
- data/test/gir_ffi/arg_helper_test.rb +21 -2
- data/test/gir_ffi/builders/argument_builder_test.rb +213 -287
- data/test/gir_ffi/builders/base_argument_builder_test.rb +1 -1
- data/test/gir_ffi/builders/callback_builder_test.rb +26 -8
- data/test/gir_ffi/builders/field_builder_test.rb +18 -3
- data/test/gir_ffi/builders/function_builder_test.rb +30 -12
- data/test/gir_ffi/builders/interface_builder_test.rb +9 -0
- data/test/gir_ffi/builders/module_builder_test.rb +0 -39
- data/test/gir_ffi/builders/object_builder_test.rb +27 -27
- data/test/gir_ffi/builders/property_builder_test.rb +110 -0
- data/test/gir_ffi/builders/return_value_builder_test.rb +168 -200
- data/test/gir_ffi/builders/signal_builder_test.rb +58 -14
- data/test/gir_ffi/builders/struct_builder_test.rb +2 -41
- data/test/gir_ffi/builders/user_defined_builder_test.rb +88 -20
- data/test/gir_ffi/builders/vfunc_builder_test.rb +44 -0
- data/test/gir_ffi/g_type_test.rb +29 -0
- data/test/gir_ffi/in_pointer_test.rb +28 -9
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +0 -9
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +19 -0
- data/test/gir_ffi/info_ext/i_function_info_test.rb +9 -0
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +8 -11
- data/test/gir_ffi/info_ext/i_type_info_test.rb +140 -16
- data/test/gir_ffi/interface_base_test.rb +9 -3
- data/test/gir_ffi/object_base_test.rb +1 -2
- data/test/{ffi-glib → gir_ffi}/sized_array_test.rb +28 -28
- data/test/gir_ffi/type_map_test.rb +1 -1
- data/test/gir_ffi/user_defined_type_info_test.rb +36 -4
- data/test/gir_ffi_test.rb +5 -5
- data/test/gir_ffi_test_helper.rb +4 -0
- data/test/integration/generated_gimarshallingtests_test.rb +163 -59
- data/test/integration/generated_gobject_test.rb +21 -8
- data/test/integration/generated_pango_test.rb +2 -2
- data/test/integration/generated_regress_test.rb +361 -101
- data/test/lib/autogen.sh +5 -1
- metadata +51 -35
- data/TODO.rdoc +0 -63
- data/lib/gir_ffi-base/gir_ffi/library.rb +0 -17
- data/lib/gir_ffi-base/gir_ffi/struct.rb +0 -27
@@ -1,359 +1,331 @@
|
|
1
1
|
require 'gir_ffi_test_helper'
|
2
2
|
|
3
3
|
describe GirFFI::Builders::ReturnValueBuilder do
|
4
|
-
let(:type_info) { Object.new }
|
5
4
|
let(:var_gen) { GirFFI::VariableNameGenerator.new }
|
5
|
+
let(:return_type_info) { GirFFI::ReturnValueInfo.new(type_info) }
|
6
6
|
let(:for_constructor) { false }
|
7
|
-
let(:skip) { false }
|
8
7
|
let(:builder) { GirFFI::Builders::ReturnValueBuilder.new(var_gen,
|
9
|
-
|
10
|
-
|
11
|
-
skip) }
|
12
|
-
let(:conversion_arguments) { [] }
|
13
|
-
let(:argument_class_name) { flattened_tag }
|
14
|
-
let(:flattened_tag) { nil }
|
15
|
-
|
16
|
-
before do
|
17
|
-
stub(type_info).argument_class_name { argument_class_name }
|
18
|
-
stub(type_info).extra_conversion_arguments { conversion_arguments }
|
19
|
-
stub(type_info).flattened_tag { flattened_tag }
|
20
|
-
end
|
8
|
+
return_type_info,
|
9
|
+
for_constructor) }
|
21
10
|
|
22
11
|
describe "for :gint32" do
|
23
|
-
let(:
|
12
|
+
let(:type_info) { get_introspection_data("GIMarshallingTests",
|
13
|
+
"int_return_min").return_type }
|
24
14
|
|
25
|
-
it "has no statements in #
|
26
|
-
builder.
|
15
|
+
it "has no statements in #post_conversion" do
|
16
|
+
builder.post_conversion.must_equal []
|
27
17
|
end
|
28
18
|
|
29
19
|
it "returns the result of the c function directly" do
|
30
|
-
builder.
|
31
|
-
builder.
|
20
|
+
builder.capture_variable_name.must_equal "_v1"
|
21
|
+
builder.return_value_name.must_equal "_v1"
|
32
22
|
end
|
33
23
|
end
|
34
24
|
|
35
25
|
describe "for :struct" do
|
36
|
-
let(:
|
37
|
-
|
26
|
+
let(:type_info) { get_method_introspection_data("GIMarshallingTests",
|
27
|
+
"BoxedStruct",
|
28
|
+
"returnv").return_type }
|
38
29
|
|
39
|
-
it "wraps the result in #
|
40
|
-
builder.
|
41
|
-
builder.
|
30
|
+
it "wraps the result in #post_conversion" do
|
31
|
+
builder.capture_variable_name.must_equal "_v1"
|
32
|
+
builder.post_conversion.must_equal [ "_v2 = GIMarshallingTests::BoxedStruct.wrap(_v1)" ]
|
42
33
|
end
|
43
34
|
|
44
35
|
it "returns the wrapped result" do
|
45
|
-
builder.
|
46
|
-
builder.
|
36
|
+
builder.capture_variable_name.must_equal "_v1"
|
37
|
+
builder.return_value_name.must_equal "_v2"
|
47
38
|
end
|
48
39
|
end
|
49
40
|
|
50
41
|
describe "for :union" do
|
51
|
-
let(:
|
52
|
-
|
42
|
+
let(:type_info) { get_method_introspection_data("GIMarshallingTests",
|
43
|
+
"Union",
|
44
|
+
"returnv").return_type }
|
53
45
|
|
54
|
-
it "wraps the result in #
|
55
|
-
builder.
|
56
|
-
builder.
|
46
|
+
it "wraps the result in #post_conversion" do
|
47
|
+
builder.capture_variable_name.must_equal "_v1"
|
48
|
+
builder.post_conversion.must_equal [ "_v2 = GIMarshallingTests::Union.wrap(_v1)" ]
|
57
49
|
end
|
58
50
|
|
59
51
|
it "returns the wrapped result" do
|
60
|
-
builder.
|
61
|
-
builder.
|
52
|
+
builder.capture_variable_name.must_equal "_v1"
|
53
|
+
builder.return_value_name.must_equal "_v2"
|
62
54
|
end
|
63
55
|
end
|
64
56
|
|
65
57
|
describe "for :interface" do
|
66
|
-
let(:
|
67
|
-
|
68
|
-
|
69
|
-
describe "when the method is not a constructor" do
|
70
|
-
let(:for_constructor) { false }
|
58
|
+
let(:type_info) { get_method_introspection_data("Gio",
|
59
|
+
"File",
|
60
|
+
"new_for_commandline_arg").return_type }
|
71
61
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
it "returns the wrapped result" do
|
78
|
-
builder.callarg.must_equal "_v1"
|
79
|
-
builder.retval.must_equal "_v2"
|
80
|
-
end
|
62
|
+
it "wraps the result in #post_conversion" do
|
63
|
+
builder.capture_variable_name.must_equal "_v1"
|
64
|
+
builder.post_conversion.must_equal [ "_v2 = Gio::File.wrap(_v1)" ]
|
81
65
|
end
|
82
66
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
it "wraps the result in #post" do
|
87
|
-
builder.callarg.must_equal "_v1"
|
88
|
-
builder.post.must_equal [ "_v2 = self.constructor_wrap(_v1)" ]
|
89
|
-
end
|
90
|
-
|
91
|
-
it "returns the wrapped result" do
|
92
|
-
builder.callarg.must_equal "_v1"
|
93
|
-
builder.retval.must_equal "_v2"
|
94
|
-
end
|
67
|
+
it "returns the wrapped result" do
|
68
|
+
builder.capture_variable_name.must_equal "_v1"
|
69
|
+
builder.return_value_name.must_equal "_v2"
|
95
70
|
end
|
96
71
|
end
|
97
72
|
|
98
73
|
describe "for :object" do
|
99
|
-
let(:argument_class_name) { 'Bar::Foo' }
|
100
|
-
let(:flattened_tag) { :object }
|
101
|
-
|
102
74
|
describe "when the method is not a constructor" do
|
75
|
+
let(:type_info) { get_method_introspection_data("GIMarshallingTests",
|
76
|
+
"Object",
|
77
|
+
"full_return").return_type }
|
103
78
|
let(:for_constructor) { false }
|
104
79
|
|
105
|
-
it "wraps the result in #
|
106
|
-
builder.
|
107
|
-
builder.
|
80
|
+
it "wraps the result in #post_conversion" do
|
81
|
+
builder.capture_variable_name.must_equal "_v1"
|
82
|
+
builder.post_conversion.must_equal [ "_v2 = GIMarshallingTests::Object.wrap(_v1)" ]
|
108
83
|
end
|
109
84
|
|
110
85
|
it "returns the wrapped result" do
|
111
|
-
builder.
|
112
|
-
builder.
|
86
|
+
builder.capture_variable_name.must_equal "_v1"
|
87
|
+
builder.return_value_name.must_equal "_v2"
|
113
88
|
end
|
114
89
|
end
|
115
90
|
|
116
91
|
describe "when the method is a constructor" do
|
92
|
+
let(:type_info) { get_method_introspection_data("GIMarshallingTests",
|
93
|
+
"Object",
|
94
|
+
"new").return_type }
|
117
95
|
let(:for_constructor) { true }
|
118
96
|
|
119
|
-
it "wraps the result in #
|
120
|
-
builder.
|
121
|
-
builder.
|
97
|
+
it "wraps the result in #post_conversion" do
|
98
|
+
builder.capture_variable_name.must_equal "_v1"
|
99
|
+
builder.post_conversion.must_equal [ "_v2 = self.constructor_wrap(_v1)" ]
|
122
100
|
end
|
123
101
|
|
124
102
|
it "returns the wrapped result" do
|
125
|
-
builder.
|
126
|
-
builder.
|
103
|
+
builder.capture_variable_name.must_equal "_v1"
|
104
|
+
builder.return_value_name.must_equal "_v2"
|
127
105
|
end
|
128
106
|
end
|
129
107
|
end
|
130
108
|
|
131
109
|
describe "for :strv" do
|
132
|
-
let(:
|
133
|
-
|
110
|
+
let(:type_info) { get_method_introspection_data("GLib",
|
111
|
+
"KeyFile",
|
112
|
+
"get_locale_string_list").return_type }
|
134
113
|
|
135
|
-
it "wraps the result in #
|
136
|
-
builder.
|
137
|
-
builder.
|
114
|
+
it "wraps the result in #post_conversion" do
|
115
|
+
builder.capture_variable_name.must_equal "_v1"
|
116
|
+
builder.post_conversion.must_equal [ "_v2 = GLib::Strv.wrap(_v1)" ]
|
138
117
|
end
|
139
118
|
|
140
119
|
it "returns the wrapped result" do
|
141
|
-
builder.
|
142
|
-
builder.
|
120
|
+
builder.capture_variable_name.must_equal "_v1"
|
121
|
+
builder.return_value_name.must_equal "_v2"
|
143
122
|
end
|
144
123
|
end
|
145
124
|
|
146
125
|
describe "for :zero_terminated" do
|
147
|
-
let(:
|
148
|
-
|
149
|
-
|
126
|
+
let(:type_info) { get_method_introspection_data("GLib",
|
127
|
+
"Variant",
|
128
|
+
"dup_bytestring").return_type }
|
129
|
+
before do
|
130
|
+
skip unless type_info.zero_terminated?
|
131
|
+
end
|
150
132
|
|
151
|
-
it "wraps the result in #
|
152
|
-
builder.
|
153
|
-
builder.
|
133
|
+
it "wraps the result in #post_conversion" do
|
134
|
+
builder.capture_variable_name.must_equal "_v1"
|
135
|
+
builder.post_conversion.must_equal [ "_v2 = GirFFI::ZeroTerminated.wrap(:guint8, _v1)" ]
|
154
136
|
end
|
155
137
|
|
156
138
|
it "returns the wrapped result" do
|
157
|
-
builder.
|
158
|
-
builder.
|
139
|
+
builder.capture_variable_name.must_equal "_v1"
|
140
|
+
builder.return_value_name.must_equal "_v2"
|
159
141
|
end
|
160
142
|
end
|
161
143
|
|
162
144
|
describe "for :byte_array" do
|
163
|
-
let(:
|
164
|
-
|
145
|
+
let(:type_info) { get_introspection_data("GIMarshallingTests",
|
146
|
+
"bytearray_full_return").return_type }
|
165
147
|
|
166
|
-
it "wraps the result in #
|
167
|
-
builder.
|
168
|
-
builder.
|
148
|
+
it "wraps the result in #post_conversion" do
|
149
|
+
builder.capture_variable_name.must_equal "_v1"
|
150
|
+
builder.post_conversion.must_equal [ "_v2 = GLib::ByteArray.wrap(_v1)" ]
|
169
151
|
end
|
170
152
|
|
171
153
|
it "returns the wrapped result" do
|
172
|
-
builder.
|
173
|
-
builder.
|
154
|
+
builder.capture_variable_name.must_equal "_v1"
|
155
|
+
builder.return_value_name.must_equal "_v2"
|
174
156
|
end
|
175
157
|
end
|
176
158
|
|
177
159
|
describe "for :ptr_array" do
|
178
|
-
let(:
|
179
|
-
|
180
|
-
let(:flattened_tag) { :ptr_array }
|
160
|
+
let(:type_info) { get_introspection_data("GIMarshallingTests",
|
161
|
+
"gptrarray_utf8_none_return").return_type }
|
181
162
|
|
182
|
-
it "wraps the result in #
|
183
|
-
builder.
|
184
|
-
builder.
|
163
|
+
it "wraps the result in #post_conversion" do
|
164
|
+
builder.capture_variable_name.must_equal "_v1"
|
165
|
+
builder.post_conversion.must_equal [ "_v2 = GLib::PtrArray.wrap(:utf8, _v1)" ]
|
185
166
|
end
|
186
167
|
|
187
168
|
it "returns the wrapped result" do
|
188
|
-
builder.
|
189
|
-
builder.
|
169
|
+
builder.capture_variable_name.must_equal "_v1"
|
170
|
+
builder.return_value_name.must_equal "_v2"
|
190
171
|
end
|
191
172
|
end
|
192
173
|
|
193
174
|
describe "for :glist" do
|
194
|
-
let(:
|
195
|
-
|
196
|
-
let(:flattened_tag) { :glist }
|
175
|
+
let(:type_info) { get_introspection_data("GIMarshallingTests",
|
176
|
+
"glist_int_none_return").return_type }
|
197
177
|
|
198
|
-
it "wraps the result in #
|
199
|
-
builder.
|
200
|
-
builder.
|
178
|
+
it "wraps the result in #post_conversion" do
|
179
|
+
builder.capture_variable_name.must_equal "_v1"
|
180
|
+
builder.post_conversion.must_equal [ "_v2 = GLib::List.wrap(:gint32, _v1)" ]
|
201
181
|
end
|
202
182
|
|
203
183
|
it "returns the wrapped result" do
|
204
|
-
builder.
|
205
|
-
builder.
|
184
|
+
builder.capture_variable_name.must_equal "_v1"
|
185
|
+
builder.return_value_name.must_equal "_v2"
|
206
186
|
end
|
207
187
|
end
|
208
188
|
|
209
189
|
describe "for :gslist" do
|
210
|
-
let(:
|
211
|
-
|
212
|
-
let(:flattened_tag) { :gslist }
|
190
|
+
let(:type_info) { get_introspection_data("GIMarshallingTests",
|
191
|
+
"gslist_int_none_return").return_type }
|
213
192
|
|
214
|
-
it "wraps the result in #
|
215
|
-
builder.
|
216
|
-
builder.
|
193
|
+
it "wraps the result in #post_conversion" do
|
194
|
+
builder.capture_variable_name.must_equal "_v1"
|
195
|
+
builder.post_conversion.must_equal [ "_v2 = GLib::SList.wrap(:gint32, _v1)" ]
|
217
196
|
end
|
218
197
|
|
219
198
|
it "returns the wrapped result" do
|
220
|
-
builder.
|
221
|
-
builder.
|
199
|
+
builder.capture_variable_name.must_equal "_v1"
|
200
|
+
builder.return_value_name.must_equal "_v2"
|
222
201
|
end
|
223
202
|
end
|
224
203
|
|
225
204
|
describe "for :ghash" do
|
226
|
-
let(:
|
227
|
-
|
228
|
-
let(:flattened_tag) { :ghash }
|
205
|
+
let(:type_info) { get_introspection_data("GIMarshallingTests",
|
206
|
+
"ghashtable_int_none_return").return_type }
|
229
207
|
|
230
|
-
it "wraps the result in #
|
231
|
-
builder.
|
232
|
-
builder.
|
208
|
+
it "wraps the result in #post_conversion" do
|
209
|
+
builder.capture_variable_name.must_equal "_v1"
|
210
|
+
builder.post_conversion.must_equal [ "_v2 = GLib::HashTable.wrap([:gint32, :gint32], _v1)" ]
|
233
211
|
end
|
234
212
|
|
235
213
|
it "returns the wrapped result" do
|
236
|
-
builder.
|
237
|
-
builder.
|
214
|
+
builder.capture_variable_name.must_equal "_v1"
|
215
|
+
builder.return_value_name.must_equal "_v2"
|
238
216
|
end
|
239
217
|
end
|
240
218
|
|
241
219
|
describe "for :array" do
|
242
|
-
let(:
|
243
|
-
|
244
|
-
|
220
|
+
let(:type_info) { get_introspection_data("GIMarshallingTests",
|
221
|
+
"garray_int_none_return").return_type }
|
222
|
+
|
245
223
|
|
246
|
-
it "wraps the result in #
|
247
|
-
builder.
|
248
|
-
builder.
|
224
|
+
it "wraps the result in #post_conversion" do
|
225
|
+
builder.capture_variable_name.must_equal "_v1"
|
226
|
+
builder.post_conversion.must_equal [ "_v2 = GLib::Array.wrap(:gint32, _v1)" ]
|
249
227
|
end
|
250
228
|
|
251
229
|
it "returns the wrapped result" do
|
252
|
-
builder.
|
253
|
-
builder.
|
230
|
+
builder.capture_variable_name.must_equal "_v1"
|
231
|
+
builder.return_value_name.must_equal "_v2"
|
254
232
|
end
|
255
233
|
end
|
256
234
|
|
257
235
|
describe "for :error" do
|
258
|
-
let(:
|
259
|
-
|
236
|
+
let(:type_info) { get_introspection_data("GIMarshallingTests",
|
237
|
+
"gerror_return").return_type }
|
260
238
|
|
261
|
-
it "wraps the result in #
|
262
|
-
builder.
|
263
|
-
builder.
|
239
|
+
it "wraps the result in #post_conversion" do
|
240
|
+
builder.capture_variable_name.must_equal "_v1"
|
241
|
+
builder.post_conversion.must_equal [ "_v2 = GLib::Error.wrap(_v1)" ]
|
264
242
|
end
|
265
243
|
|
266
244
|
it "returns the wrapped result" do
|
267
|
-
builder.
|
268
|
-
builder.
|
245
|
+
builder.capture_variable_name.must_equal "_v1"
|
246
|
+
builder.return_value_name.must_equal "_v2"
|
269
247
|
end
|
270
248
|
end
|
271
249
|
|
272
250
|
describe "for :c" do
|
273
|
-
let(:argument_class_name) { 'GLib::SizedArray' }
|
274
|
-
|
275
251
|
describe "with fixed size" do
|
276
|
-
|
277
|
-
|
278
|
-
stub(type_info).subtype_tag_or_class { :foo }
|
279
|
-
stub(type_info).array_fixed_size { 3 }
|
280
|
-
end
|
252
|
+
let(:type_info) { get_introspection_data("GIMarshallingTests",
|
253
|
+
"array_fixed_int_return").return_type }
|
281
254
|
|
282
|
-
it "converts the result in #
|
283
|
-
builder.
|
284
|
-
builder.
|
255
|
+
it "converts the result in #post_conversion" do
|
256
|
+
builder.capture_variable_name.must_equal "_v1"
|
257
|
+
builder.post_conversion.must_equal [ "_v2 = GirFFI::SizedArray.wrap(:gint32, 4, _v1)" ]
|
285
258
|
end
|
286
259
|
|
287
260
|
it "returns the wrapped result" do
|
288
|
-
builder.
|
289
|
-
builder.
|
261
|
+
builder.capture_variable_name.must_equal "_v1"
|
262
|
+
builder.return_value_name.must_equal "_v2"
|
290
263
|
end
|
291
264
|
end
|
292
265
|
|
293
266
|
describe "with separate size parameter" do
|
294
267
|
let(:length_argument) { Object.new }
|
268
|
+
let(:type_info) { get_method_introspection_data("GIMarshallingTests",
|
269
|
+
"Object",
|
270
|
+
"method_array_return").return_type }
|
295
271
|
|
296
272
|
before do
|
297
|
-
stub(
|
298
|
-
stub(type_info).subtype_tag_or_class { :foo }
|
299
|
-
stub(type_info).array_fixed_size { -1 }
|
300
|
-
|
301
|
-
stub(length_argument).retname { "bar" }
|
273
|
+
stub(length_argument).post_converted_name { "bar" }
|
302
274
|
builder.length_arg = length_argument
|
303
275
|
end
|
304
276
|
|
305
|
-
it "converts the result in #
|
306
|
-
builder.
|
307
|
-
builder.
|
277
|
+
it "converts the result in #post_conversion" do
|
278
|
+
builder.capture_variable_name.must_equal "_v1"
|
279
|
+
builder.post_conversion.must_equal [ "_v2 = GirFFI::SizedArray.wrap(:gint32, bar, _v1)" ]
|
308
280
|
end
|
309
281
|
|
310
282
|
it "returns the wrapped result" do
|
311
|
-
builder.
|
312
|
-
builder.
|
283
|
+
builder.capture_variable_name.must_equal "_v1"
|
284
|
+
builder.return_value_name.must_equal "_v2"
|
313
285
|
end
|
314
286
|
end
|
315
287
|
end
|
316
288
|
|
317
289
|
describe "for :utf8" do
|
318
|
-
|
319
|
-
|
320
|
-
end
|
290
|
+
let(:type_info) {
|
291
|
+
get_introspection_data("GIMarshallingTests", "utf8_full_return").return_type }
|
321
292
|
|
322
|
-
it "converts the result in #
|
323
|
-
builder.
|
324
|
-
builder.
|
293
|
+
it "converts the result in #post_conversion" do
|
294
|
+
builder.capture_variable_name.must_equal "_v1"
|
295
|
+
builder.post_conversion.must_equal [ "_v2 = _v1.to_utf8" ]
|
325
296
|
end
|
326
297
|
|
327
298
|
it "returns the converted result" do
|
328
|
-
builder.
|
329
|
-
builder.
|
299
|
+
builder.capture_variable_name.must_equal "_v1"
|
300
|
+
builder.return_value_name.must_equal "_v2"
|
330
301
|
end
|
331
302
|
end
|
332
303
|
|
333
304
|
describe "for :void pointer" do
|
305
|
+
let(:callback_info) {
|
306
|
+
get_introspection_data("GIMarshallingTests", "CallbackIntInt") }
|
307
|
+
let(:type_info) { callback_info.args[1].argument_type }
|
308
|
+
|
334
309
|
before do
|
335
|
-
|
336
|
-
stub(type_info).pointer? { true }
|
310
|
+
skip unless callback_info
|
337
311
|
end
|
338
312
|
|
339
|
-
it "has no statements in #
|
340
|
-
builder.
|
313
|
+
it "has no statements in #post_conversion" do
|
314
|
+
builder.post_conversion.must_equal []
|
341
315
|
end
|
342
316
|
|
343
317
|
it "returns the result of the c function directly" do
|
344
|
-
builder.
|
345
|
-
builder.
|
318
|
+
builder.capture_variable_name.must_equal "_v1"
|
319
|
+
builder.return_value_name.must_equal "_v1"
|
346
320
|
end
|
347
321
|
end
|
348
322
|
|
349
323
|
describe "for :void" do
|
350
|
-
|
351
|
-
|
352
|
-
stub(type_info).pointer? { false }
|
353
|
-
end
|
324
|
+
let(:type_info) {
|
325
|
+
get_method_introspection_data("Regress", "TestObj", "null_out").return_type }
|
354
326
|
|
355
|
-
it "has no statements in #
|
356
|
-
builder.
|
327
|
+
it "has no statements in #post_conversion" do
|
328
|
+
builder.post_conversion.must_equal []
|
357
329
|
end
|
358
330
|
|
359
331
|
it "marks itself as irrelevant" do
|
@@ -361,40 +333,36 @@ describe GirFFI::Builders::ReturnValueBuilder do
|
|
361
333
|
end
|
362
334
|
|
363
335
|
it "returns nothing" do
|
364
|
-
builder.
|
336
|
+
builder.return_value_name.must_be_nil
|
365
337
|
end
|
366
338
|
end
|
367
339
|
|
368
340
|
describe "for a closure argument" do
|
369
|
-
let(:
|
341
|
+
let(:type_info) {
|
370
342
|
get_introspection_data("Regress", "TestCallbackUserData").args[0].argument_type }
|
371
|
-
let(:builder) { GirFFI::Builders::ReturnValueBuilder.new(var_gen, tp_info) }
|
372
343
|
|
373
344
|
before do
|
374
345
|
builder.is_closure = true
|
375
346
|
end
|
376
347
|
|
377
|
-
it "fetches the stored object in #
|
378
|
-
builder.
|
379
|
-
builder.
|
348
|
+
it "fetches the stored object in #post_conversion" do
|
349
|
+
builder.capture_variable_name.must_equal "_v1"
|
350
|
+
builder.post_conversion.must_equal [ "_v2 = GirFFI::ArgHelper::OBJECT_STORE[_v1.address]" ]
|
380
351
|
end
|
381
352
|
|
382
353
|
it "returns the stored object" do
|
383
|
-
builder.
|
384
|
-
builder.
|
354
|
+
builder.capture_variable_name.must_equal "_v1"
|
355
|
+
builder.return_value_name.must_equal "_v2"
|
385
356
|
end
|
386
357
|
end
|
387
358
|
|
388
359
|
describe "for a skipped return value" do
|
389
|
-
let(:
|
390
|
-
|
391
|
-
|
392
|
-
stub(type_info).flattened_tag { :uint32 }
|
393
|
-
stub(type_info).pointer? { false }
|
394
|
-
end
|
360
|
+
let(:type_info) {
|
361
|
+
get_method_introspection_data("Regress", "TestObj", "skip_return_val").return_type }
|
362
|
+
let(:return_type_info) { GirFFI::ReturnValueInfo.new(type_info, true) }
|
395
363
|
|
396
|
-
it "has no statements in #
|
397
|
-
builder.
|
364
|
+
it "has no statements in #post_conversion" do
|
365
|
+
builder.post_conversion.must_equal []
|
398
366
|
end
|
399
367
|
|
400
368
|
it "marks itself as irrelevant" do
|
@@ -402,7 +370,7 @@ describe GirFFI::Builders::ReturnValueBuilder do
|
|
402
370
|
end
|
403
371
|
|
404
372
|
it "returns nothing" do
|
405
|
-
builder.
|
373
|
+
builder.return_value_name.must_be_nil
|
406
374
|
end
|
407
375
|
end
|
408
376
|
end
|