gir_ffi 0.15.2 → 0.15.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +11 -0
- data/Gemfile +1 -1
- data/lib/ffi-gobject/value.rb +3 -1
- data/lib/ffi-gobject_introspection/i_base_info.rb +1 -1
- data/lib/gir_ffi/builder_helper.rb +6 -1
- data/lib/gir_ffi/builders/callback_builder.rb +13 -1
- data/lib/gir_ffi/builders/enum_builder.rb +6 -2
- data/lib/gir_ffi/builders/field_builder.rb +2 -1
- data/lib/gir_ffi/builders/module_builder.rb +3 -1
- data/lib/gir_ffi/builders/struct_builder.rb +3 -1
- data/lib/gir_ffi/callback_base.rb +3 -5
- data/lib/gir_ffi/class_base.rb +1 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/test/ffi-gobject/object_test.rb +3 -2
- data/test/ffi-gobject/value_test.rb +1 -1
- data/test/ffi-gobject_introspection/i_base_info_test.rb +1 -1
- data/test/ffi-gobject_test.rb +4 -2
- data/test/gir_ffi/arg_helper_test.rb +13 -6
- data/test/gir_ffi/boxed_base_test.rb +1 -1
- data/test/gir_ffi/builder_test.rb +3 -157
- data/test/gir_ffi/builders/argument_builder_test.rb +73 -33
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +6 -2
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +5 -2
- data/test/gir_ffi/builders/constructor_builder_test.rb +3 -1
- data/test/gir_ffi/builders/field_builder_test.rb +9 -3
- data/test/gir_ffi/builders/function_builder_test.rb +30 -10
- data/test/gir_ffi/builders/initializer_builder_test.rb +3 -1
- data/test/gir_ffi/builders/object_builder_test.rb +6 -6
- data/test/gir_ffi/builders/property_builder_test.rb +5 -2
- data/test/gir_ffi/builders/return_value_builder_test.rb +20 -9
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +9 -7
- data/test/gir_ffi/builders/struct_builder_test.rb +6 -3
- data/test/gir_ffi/builders/user_defined_builder_test.rb +7 -3
- data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +11 -5
- data/test/gir_ffi/builders/vfunc_builder_test.rb +10 -6
- data/test/gir_ffi/class_base_test.rb +17 -12
- data/test/gir_ffi/core_test.rb +4 -3
- data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -2
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +2 -1
- data/test/gir_ffi/info_ext/i_type_info_test.rb +2 -1
- data/test/gir_ffi/method_stubber_test.rb +3 -1
- data/test/integration/derived_classes_test.rb +1 -0
- data/test/integration/generated_everything_test.rb +2 -1
- data/test/integration/generated_gimarshallingtests_test.rb +57 -44
- data/test/integration/generated_gtk_source_test.rb +6 -17
- data/test/integration/generated_regress_test.rb +16 -2
- data/test/integration/generated_warnlib_test.rb +4 -2
- data/test/introspection_test_helper.rb +2 -1
- metadata +22 -8
@@ -15,7 +15,10 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
15
15
|
|
16
16
|
it "has the correct value for #pre_conversion" do
|
17
17
|
_(builder.pre_conversion)
|
18
|
-
.must_equal [
|
18
|
+
.must_equal [
|
19
|
+
"_v1 = GirFFI::SizedArray.copy_from(" \
|
20
|
+
"[:pointer, GIMarshallingTests::BoxedStruct], -1, structs)"
|
21
|
+
]
|
19
22
|
end
|
20
23
|
|
21
24
|
it "has the correct value for #post_conversion" do
|
@@ -30,7 +33,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
30
33
|
end
|
31
34
|
|
32
35
|
it "has the correct value for #pre_conversion" do
|
33
|
-
_(builder.pre_conversion)
|
36
|
+
_(builder.pre_conversion)
|
37
|
+
.must_equal ["_v1 = Regress::TestCallbackUserData.from(callback)"]
|
34
38
|
end
|
35
39
|
|
36
40
|
it "has the correct value for #post_conversion" do
|
@@ -45,7 +49,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
45
49
|
end
|
46
50
|
|
47
51
|
it "has the correct value for #pre_conversion" do
|
48
|
-
_(builder.pre_conversion)
|
52
|
+
_(builder.pre_conversion)
|
53
|
+
.must_equal ["_v1 = GirFFI::ZeroTerminated.from(:gint32, ints)"]
|
49
54
|
end
|
50
55
|
|
51
56
|
it "has the correct value for #post_conversion" do
|
@@ -54,7 +59,9 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
54
59
|
end
|
55
60
|
|
56
61
|
describe "for :void" do
|
57
|
-
let(:arg_info)
|
62
|
+
let(:arg_info) do
|
63
|
+
get_introspection_data("Regress", "test_callback_user_data").args[1]
|
64
|
+
end
|
58
65
|
|
59
66
|
describe "when it is a regular argument" do
|
60
67
|
it "has the correct value for method_argument_name" do
|
@@ -97,11 +104,13 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
97
104
|
let(:arg_info) { get_introspection_data("GIMarshallingTests", "genum_out").args[0] }
|
98
105
|
|
99
106
|
it "has the correct value for #pre_conversion" do
|
100
|
-
_(builder.pre_conversion)
|
107
|
+
_(builder.pre_conversion)
|
108
|
+
.must_equal ["_v1 = FFI::MemoryPointer.new GIMarshallingTests::GEnum"]
|
101
109
|
end
|
102
110
|
|
103
111
|
it "has the correct value for #post_conversion" do
|
104
|
-
_(builder.post_conversion)
|
112
|
+
_(builder.post_conversion)
|
113
|
+
.must_equal ["_v2 = GIMarshallingTests::GEnum.get_value_from_pointer(_v1, 0)"]
|
105
114
|
end
|
106
115
|
end
|
107
116
|
|
@@ -111,11 +120,13 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
111
120
|
end
|
112
121
|
|
113
122
|
it "has the correct value for #pre_conversion" do
|
114
|
-
_(builder.pre_conversion)
|
123
|
+
_(builder.pre_conversion)
|
124
|
+
.must_equal ["_v1 = FFI::MemoryPointer.new GIMarshallingTests::Flags"]
|
115
125
|
end
|
116
126
|
|
117
127
|
it "has the correct value for #post_conversion" do
|
118
|
-
_(builder.post_conversion)
|
128
|
+
_(builder.post_conversion)
|
129
|
+
.must_equal ["_v2 = GIMarshallingTests::Flags.get_value_from_pointer(_v1, 0)"]
|
119
130
|
end
|
120
131
|
end
|
121
132
|
|
@@ -130,7 +141,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
130
141
|
end
|
131
142
|
|
132
143
|
it "has the correct value for #post_conversion" do
|
133
|
-
_(builder.post_conversion)
|
144
|
+
_(builder.post_conversion)
|
145
|
+
.must_equal ["_v2 = Regress::TestObj.wrap(_v1.get_pointer(0))"]
|
134
146
|
end
|
135
147
|
end
|
136
148
|
|
@@ -145,7 +157,10 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
145
157
|
|
146
158
|
it "has the correct value for #post_conversion" do
|
147
159
|
_(builder.post_conversion)
|
148
|
-
.must_equal [
|
160
|
+
.must_equal [
|
161
|
+
"_v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0)).tap" \
|
162
|
+
" { |it| it && it.ref }"
|
163
|
+
]
|
149
164
|
end
|
150
165
|
end
|
151
166
|
end
|
@@ -164,7 +179,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
164
179
|
|
165
180
|
it "has the correct value for #post_conversion" do
|
166
181
|
_(builder.post_conversion)
|
167
|
-
.must_equal ["_v2 = GIMarshallingTests::BoxedStruct.wrap_copy(
|
182
|
+
.must_equal ["_v2 = GIMarshallingTests::BoxedStruct.wrap_copy("\
|
183
|
+
"_v1.get_pointer(0))"]
|
168
184
|
end
|
169
185
|
end
|
170
186
|
|
@@ -208,13 +224,15 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
208
224
|
end
|
209
225
|
|
210
226
|
it "has the correct value for #post_conversion" do
|
211
|
-
_(builder.post_conversion)
|
227
|
+
_(builder.post_conversion)
|
228
|
+
.must_equal ["_v2 = GLib::Array.wrap(:utf8, _v1.get_pointer(0))"]
|
212
229
|
end
|
213
230
|
end
|
214
231
|
|
215
232
|
describe "when allocated by the caller" do
|
216
233
|
let(:function_info) do
|
217
|
-
get_introspection_data("GIMarshallingTests",
|
234
|
+
get_introspection_data("GIMarshallingTests",
|
235
|
+
"garray_utf8_full_out_caller_allocated")
|
218
236
|
end
|
219
237
|
|
220
238
|
let(:arg_info) { function_info.args[0] }
|
@@ -239,7 +257,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
239
257
|
end
|
240
258
|
|
241
259
|
it "has the correct value for #post_conversion" do
|
242
|
-
_(builder.post_conversion)
|
260
|
+
_(builder.post_conversion)
|
261
|
+
.must_equal ["_v2 = GLib::PtrArray.wrap(:utf8, _v1.get_pointer(0))"]
|
243
262
|
end
|
244
263
|
end
|
245
264
|
|
@@ -268,7 +287,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
268
287
|
end
|
269
288
|
|
270
289
|
it "has the correct value for #post_conversion" do
|
271
|
-
_(builder.post_conversion)
|
290
|
+
_(builder.post_conversion)
|
291
|
+
.must_equal ["_v2 = GirFFI::SizedArray.wrap(:gint32, 4, _v1.get_pointer(0))"]
|
272
292
|
end
|
273
293
|
end
|
274
294
|
|
@@ -288,7 +308,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
288
308
|
end
|
289
309
|
|
290
310
|
it "has the correct value for #post_conversion" do
|
291
|
-
_(builder.post_conversion)
|
311
|
+
_(builder.post_conversion)
|
312
|
+
.must_equal ["_v2 = GirFFI::SizedArray.wrap(:gint32, bar, _v1.get_pointer(0))"]
|
292
313
|
end
|
293
314
|
end
|
294
315
|
end
|
@@ -303,7 +324,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
303
324
|
end
|
304
325
|
|
305
326
|
it "has the correct value for #post_conversion" do
|
306
|
-
_(builder.post_conversion)
|
327
|
+
_(builder.post_conversion)
|
328
|
+
.must_equal ["_v2 = GLib::List.wrap(:utf8, _v1.get_pointer(0))"]
|
307
329
|
end
|
308
330
|
end
|
309
331
|
|
@@ -317,7 +339,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
317
339
|
end
|
318
340
|
|
319
341
|
it "has the correct value for #post_conversion" do
|
320
|
-
_(builder.post_conversion)
|
342
|
+
_(builder.post_conversion)
|
343
|
+
.must_equal ["_v2 = GLib::SList.wrap(:utf8, _v1.get_pointer(0))"]
|
321
344
|
end
|
322
345
|
end
|
323
346
|
|
@@ -331,7 +354,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
331
354
|
end
|
332
355
|
|
333
356
|
it "has the correct value for #post_conversion" do
|
334
|
-
_(builder.post_conversion)
|
357
|
+
_(builder.post_conversion)
|
358
|
+
.must_equal ["_v2 = GLib::HashTable.wrap([:utf8, :utf8], _v1.get_pointer(0))"]
|
335
359
|
end
|
336
360
|
end
|
337
361
|
|
@@ -397,12 +421,16 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
397
421
|
end
|
398
422
|
|
399
423
|
it "has the correct value for #pre_conversion" do
|
400
|
-
_(builder.pre_conversion)
|
401
|
-
|
424
|
+
_(builder.pre_conversion)
|
425
|
+
.must_equal [
|
426
|
+
"_v1 = FFI::MemoryPointer.new GIMarshallingTests::Enum",
|
427
|
+
"GIMarshallingTests::Enum.copy_value_to_pointer(#{arg_info.name}, _v1)"
|
428
|
+
]
|
402
429
|
end
|
403
430
|
|
404
431
|
it "has the correct value for #post_conversion" do
|
405
|
-
_(builder.post_conversion)
|
432
|
+
_(builder.post_conversion)
|
433
|
+
.must_equal ["_v2 = GIMarshallingTests::Enum.get_value_from_pointer(_v1, 0)"]
|
406
434
|
end
|
407
435
|
end
|
408
436
|
|
@@ -413,12 +441,17 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
413
441
|
|
414
442
|
it "has the correct value for #pre_conversion" do
|
415
443
|
_(builder.pre_conversion)
|
416
|
-
.must_equal [
|
417
|
-
|
444
|
+
.must_equal [
|
445
|
+
"_v1 = FFI::MemoryPointer.new GIMarshallingTests::NoTypeFlags",
|
446
|
+
"GIMarshallingTests::NoTypeFlags.copy_value_to_pointer(#{arg_info.name}, _v1)"
|
447
|
+
]
|
418
448
|
end
|
419
449
|
|
420
450
|
it "has the correct value for #post_conversion" do
|
421
|
-
_(builder.post_conversion)
|
451
|
+
_(builder.post_conversion)
|
452
|
+
.must_equal [
|
453
|
+
"_v2 = GIMarshallingTests::NoTypeFlags.get_value_from_pointer(_v1, 0)"
|
454
|
+
]
|
422
455
|
end
|
423
456
|
end
|
424
457
|
|
@@ -487,12 +520,14 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
487
520
|
end
|
488
521
|
|
489
522
|
it "has the correct value for #pre_conversion" do
|
490
|
-
_(builder.pre_conversion)
|
491
|
-
|
523
|
+
_(builder.pre_conversion)
|
524
|
+
.must_equal ["_v1 = FFI::MemoryPointer.new :pointer",
|
525
|
+
"_v1.put_pointer 0, GLib::PtrArray.from(:utf8, parray_)"]
|
492
526
|
end
|
493
527
|
|
494
528
|
it "has the correct value for #post_conversion" do
|
495
|
-
_(builder.post_conversion)
|
529
|
+
_(builder.post_conversion)
|
530
|
+
.must_equal ["_v2 = GLib::PtrArray.wrap(:utf8, _v1.get_pointer(0))"]
|
496
531
|
end
|
497
532
|
end
|
498
533
|
|
@@ -502,8 +537,9 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
502
537
|
end
|
503
538
|
|
504
539
|
it "has the correct value for #pre_conversion" do
|
505
|
-
_(builder.pre_conversion)
|
506
|
-
|
540
|
+
_(builder.pre_conversion)
|
541
|
+
.must_equal ["_v1 = FFI::MemoryPointer.new :pointer",
|
542
|
+
"_v1.put_pointer 0, GirFFI::InPointer.from_utf8(utf8)"]
|
507
543
|
end
|
508
544
|
|
509
545
|
it "has the correct value for #post_conversion" do
|
@@ -526,7 +562,9 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
526
562
|
|
527
563
|
it "has the correct value for #post_conversion" do
|
528
564
|
_(builder.post_conversion)
|
529
|
-
.must_equal [
|
565
|
+
.must_equal [
|
566
|
+
"_v2 = GIMarshallingTests::BoxedStruct.wrap_own(_v1.get_pointer(0))"
|
567
|
+
]
|
530
568
|
end
|
531
569
|
end
|
532
570
|
end
|
@@ -546,7 +584,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
546
584
|
end
|
547
585
|
|
548
586
|
it "has the correct value for #post_conversion" do
|
549
|
-
_(builder.post_conversion)
|
587
|
+
_(builder.post_conversion)
|
588
|
+
.must_equal ["_v2 = GirFFI::SizedArray.wrap(:gint32, 4, _v1.get_pointer(0))"]
|
550
589
|
end
|
551
590
|
end
|
552
591
|
|
@@ -572,7 +611,8 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
572
611
|
end
|
573
612
|
|
574
613
|
it "has the correct value for #post_conversion" do
|
575
|
-
_(builder.post_conversion)
|
614
|
+
_(builder.post_conversion)
|
615
|
+
.must_equal ["_v3 = GirFFI::SizedArray.wrap(:gint32, _v2, _v1.get_pointer(0))"]
|
576
616
|
end
|
577
617
|
end
|
578
618
|
end
|
@@ -19,7 +19,8 @@ describe GirFFI::Builders::CallbackArgumentBuilder do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "has the correct value for #post_conversion" do
|
22
|
-
_(builder.post_conversion)
|
22
|
+
_(builder.post_conversion)
|
23
|
+
.must_equal ["_v1.put_pointer 0, GirFFI::ZeroTerminated.from(:gfloat, _v2)"]
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -32,7 +33,10 @@ describe GirFFI::Builders::CallbackArgumentBuilder do
|
|
32
33
|
let(:arg_info) { vfunc_info.args[1] }
|
33
34
|
|
34
35
|
it "has the correct value for #pre_conversion" do
|
35
|
-
_(builder.pre_conversion)
|
36
|
+
_(builder.pre_conversion)
|
37
|
+
.must_equal [
|
38
|
+
"_v1 = FFI::MemoryPointer.new(:int8).tap { |ptr| out.put_pointer 0, ptr }"
|
39
|
+
]
|
36
40
|
end
|
37
41
|
|
38
42
|
it "has the correct value for #post_conversion" do
|
@@ -4,7 +4,9 @@ require "gir_ffi_test_helper"
|
|
4
4
|
|
5
5
|
describe GirFFI::Builders::CallbackReturnValueBuilder do
|
6
6
|
let(:var_gen) { GirFFI::VariableNameGenerator.new }
|
7
|
-
let(:return_value_info)
|
7
|
+
let(:return_value_info) do
|
8
|
+
GirFFI::ReturnValueInfo.new(type_info, ownership_transfer, false)
|
9
|
+
end
|
8
10
|
let(:type_info) { callback_info.return_type }
|
9
11
|
let(:ownership_transfer) { callback_info.caller_owns }
|
10
12
|
let(:builder) do
|
@@ -70,7 +72,8 @@ describe GirFFI::Builders::CallbackReturnValueBuilder do
|
|
70
72
|
it "increases the refcount of the result and converts it to a pointer" do
|
71
73
|
# Ensure variable names are generated in order
|
72
74
|
_(builder.capture_variable_name).must_equal "_v1"
|
73
|
-
_(builder.post_conversion)
|
75
|
+
_(builder.post_conversion)
|
76
|
+
.must_equal ["_v1.ref", "_v2 = GObject::Object.from(_v1).to_ptr"]
|
74
77
|
end
|
75
78
|
|
76
79
|
it "returns the result of the conversion" do
|
@@ -21,7 +21,9 @@ describe GirFFI::Builders::ConstructorBuilder do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "for constructors with a custom name" do
|
24
|
-
let(:function_info)
|
24
|
+
let(:function_info) do
|
25
|
+
get_method_introspection_data "Regress", "TestObj", "new_from_file"
|
26
|
+
end
|
25
27
|
it "builds a custom constructor" do
|
26
28
|
_(code).must_equal <<~CODE
|
27
29
|
def self.new_from_file(*args, &block)
|
@@ -7,7 +7,9 @@ describe GirFFI::Builders::FieldBuilder do
|
|
7
7
|
let(:instance) { GirFFI::Builders::FieldBuilder.new field_info, target_class }
|
8
8
|
|
9
9
|
describe "for a field of type :gint8 with an offset" do
|
10
|
-
let(:field_info)
|
10
|
+
let(:field_info) do
|
11
|
+
get_field_introspection_data "Regress", "TestSimpleBoxedA", "some_int8"
|
12
|
+
end
|
11
13
|
it "creates the right getter method" do
|
12
14
|
expected = <<~CODE
|
13
15
|
def some_int8
|
@@ -113,8 +115,12 @@ describe GirFFI::Builders::FieldBuilder do
|
|
113
115
|
end
|
114
116
|
|
115
117
|
describe "for a field with a related array length field" do
|
116
|
-
let(:field_info)
|
117
|
-
|
118
|
+
let(:field_info) do
|
119
|
+
get_field_introspection_data "GObject", "SignalQuery", "param_types"
|
120
|
+
end
|
121
|
+
let(:n_params_field_info) do
|
122
|
+
get_field_introspection_data "GObject", "SignalQuery", "n_params"
|
123
|
+
end
|
118
124
|
|
119
125
|
it "creates the right getter method" do
|
120
126
|
skip if field_info.field_type.array_length < 0
|
@@ -8,7 +8,9 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
8
8
|
let(:code) { builder.method_definition }
|
9
9
|
|
10
10
|
describe "generally" do
|
11
|
-
let(:function_info)
|
11
|
+
let(:function_info) do
|
12
|
+
get_method_introspection_data "GObject", "Object", "get_property"
|
13
|
+
end
|
12
14
|
|
13
15
|
it "returns the same result when called twice" do
|
14
16
|
original = builder.method_definition
|
@@ -18,7 +20,9 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
describe "for Regress:test_array_fixed_out_objects" do
|
21
|
-
let(:function_info)
|
23
|
+
let(:function_info) do
|
24
|
+
get_introspection_data "Regress", "test_array_fixed_out_objects"
|
25
|
+
end
|
22
26
|
it "builds a correct definition" do
|
23
27
|
_(code).must_equal <<~CODE
|
24
28
|
def self.test_array_fixed_out_objects
|
@@ -47,7 +51,9 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
47
51
|
end
|
48
52
|
|
49
53
|
describe "for methods taking a zero-terminated array with length argument" do
|
50
|
-
let(:function_info)
|
54
|
+
let(:function_info) do
|
55
|
+
get_method_introspection_data "Regress", "AnnotationObject", "parse_args"
|
56
|
+
end
|
51
57
|
it "builds a correct definition" do
|
52
58
|
_(code).must_equal <<~CODE
|
53
59
|
def parse_args(argv)
|
@@ -65,7 +71,9 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
65
71
|
end
|
66
72
|
|
67
73
|
describe "for functions with callbacks" do
|
68
|
-
let(:function_info)
|
74
|
+
let(:function_info) do
|
75
|
+
get_introspection_data "Regress", "test_callback_destroy_notify"
|
76
|
+
end
|
69
77
|
it "builds a correct definition" do
|
70
78
|
_(code).must_equal <<~CODE
|
71
79
|
def self.test_callback_destroy_notify(&callback)
|
@@ -119,7 +127,9 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
119
127
|
end
|
120
128
|
|
121
129
|
describe "for functions that have a caller-allocated GValue out argument" do
|
122
|
-
let(:function_info)
|
130
|
+
let(:function_info) do
|
131
|
+
get_introspection_data "GIMarshallingTests", "gvalue_out_caller_allocates"
|
132
|
+
end
|
123
133
|
|
124
134
|
it "creates a call to #get_value" do
|
125
135
|
_(code).must_equal <<~CODE
|
@@ -164,7 +174,9 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
164
174
|
end
|
165
175
|
|
166
176
|
describe "for a method with an inout array with size argument" do
|
167
|
-
let(:function_info)
|
177
|
+
let(:function_info) do
|
178
|
+
get_method_introspection_data "GIMarshallingTests", "Object", "method_array_inout"
|
179
|
+
end
|
168
180
|
it "builds the correct definition" do
|
169
181
|
_(code).must_equal <<~CODE
|
170
182
|
def method_array_inout(ints)
|
@@ -183,7 +195,9 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
183
195
|
end
|
184
196
|
|
185
197
|
describe "for a simple method" do
|
186
|
-
let(:function_info)
|
198
|
+
let(:function_info) do
|
199
|
+
get_method_introspection_data "Regress", "TestObj", "instance_method"
|
200
|
+
end
|
187
201
|
|
188
202
|
it "builds a correct definition" do
|
189
203
|
_(code).must_equal <<~CODE
|
@@ -501,7 +515,9 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
501
515
|
end
|
502
516
|
|
503
517
|
describe "for functions where some allow-none cannot be honored" do
|
504
|
-
let(:function_info)
|
518
|
+
let(:function_info) do
|
519
|
+
get_introspection_data "GIMarshallingTests", "array_in_utf8_two_in_out_of_order"
|
520
|
+
end
|
505
521
|
it "builds correct definition with default parameter value on the later arguments" do
|
506
522
|
_(code).must_equal <<~CODE
|
507
523
|
def self.array_in_utf8_two_in_out_of_order(a, ints, b = nil)
|
@@ -518,7 +534,9 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
518
534
|
|
519
535
|
describe "ownership transfer for an ingoing array of structs" do
|
520
536
|
describe "with no ownership transfer of the elements" do
|
521
|
-
let(:function_info)
|
537
|
+
let(:function_info) do
|
538
|
+
get_introspection_data "GIMarshallingTests", "array_struct_in"
|
539
|
+
end
|
522
540
|
|
523
541
|
it "builds a correct definition" do
|
524
542
|
_(code).must_equal <<~CODE
|
@@ -532,7 +550,9 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
532
550
|
end
|
533
551
|
end
|
534
552
|
describe "with ownership transfer of the elements" do
|
535
|
-
let(:function_info)
|
553
|
+
let(:function_info) do
|
554
|
+
get_introspection_data "GIMarshallingTests", "array_struct_take_in"
|
555
|
+
end
|
536
556
|
|
537
557
|
it "builds a correct definition" do
|
538
558
|
_(code).must_equal <<~CODE
|