gir_ffi 0.1.0 → 0.2.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.
- data/History.txt +14 -0
- data/TODO.rdoc +10 -5
- data/lib/ffi-glib.rb +7 -73
- data/lib/ffi-glib/array.rb +29 -4
- data/lib/ffi-glib/byte_array.rb +15 -1
- data/lib/ffi-glib/hash_table.rb +31 -24
- data/lib/ffi-glib/list.rb +28 -0
- data/lib/ffi-glib/list_methods.rb +10 -2
- data/lib/ffi-glib/ptr_array.rb +39 -0
- data/lib/ffi-glib/s_list.rb +29 -0
- data/lib/ffi-gobject.rb +49 -22
- data/lib/ffi-gobject/closure.rb +4 -3
- data/lib/ffi-gobject/helper.rb +20 -43
- data/lib/ffi-gobject/initially_unowned.rb +2 -0
- data/lib/ffi-gobject/object.rb +54 -0
- data/lib/ffi-gobject/ruby_closure.rb +22 -16
- data/lib/ffi-gobject/value.rb +54 -19
- data/lib/ffi-gobject_introspection/i_constant_info.rb +17 -1
- data/lib/ffi-gobject_introspection/i_field_info.rb +8 -0
- data/lib/ffi-gobject_introspection/i_property_info.rb +3 -1
- data/lib/ffi-gobject_introspection/lib.rb +19 -2
- data/lib/gir_ffi/arg_helper.rb +7 -45
- data/lib/gir_ffi/builder.rb +1 -1
- data/lib/gir_ffi/builder/argument.rb +148 -107
- data/lib/gir_ffi/builder/argument/base.rb +5 -5
- data/lib/gir_ffi/builder/argument/in_base.rb +2 -2
- data/lib/gir_ffi/builder/argument/in_out_base.rb +2 -3
- data/lib/gir_ffi/builder/argument/out_base.rb +2 -3
- data/lib/gir_ffi/builder/function.rb +11 -17
- data/lib/gir_ffi/builder/module.rb +26 -0
- data/lib/gir_ffi/builder/type.rb +5 -0
- data/lib/gir_ffi/builder/type/base.rb +2 -0
- data/lib/gir_ffi/builder/type/callback.rb +18 -3
- data/lib/gir_ffi/builder/type/constant.rb +4 -12
- data/lib/gir_ffi/builder/type/enum.rb +15 -6
- data/lib/gir_ffi/builder/type/interface.rb +4 -0
- data/lib/gir_ffi/builder/type/object.rb +11 -0
- data/lib/gir_ffi/builder/type/struct_based.rb +14 -4
- data/lib/gir_ffi/builder/type/union.rb +13 -7
- data/lib/gir_ffi/builder/type/with_layout.rb +59 -8
- data/lib/gir_ffi/class_base.rb +8 -1
- data/lib/gir_ffi/in_out_pointer.rb +17 -18
- data/lib/gir_ffi/in_pointer.rb +8 -1
- data/lib/gir_ffi/type_map.rb +12 -0
- data/lib/gir_ffi/variable_name_generator.rb +12 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/test/ffi-glib/array_test.rb +54 -0
- data/test/ffi-glib/byte_array_test.rb +21 -0
- data/test/ffi-glib/glib_overrides_test.rb +1 -46
- data/test/ffi-glib/hash_table_test.rb +24 -0
- data/test/ffi-glib/list_test.rb +46 -0
- data/test/ffi-glib/ptr_array_test.rb +51 -0
- data/test/ffi-glib/s_list_test.rb +46 -0
- data/test/ffi-gobject/g_object_overrides_test.rb +8 -8
- data/test/ffi-gobject/gobject_test.rb +26 -0
- data/test/ffi-gobject/object_test.rb +12 -0
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +5 -1
- data/test/ffi-gobject_introspection/lib_test.rb +56 -0
- data/test/integration/generated_gimarshallingtests_test.rb +118 -76
- data/test/integration/generated_regress_test.rb +220 -62
- data/test/integration/pretty_print_test.rb +11 -0
- data/test/type_builder_test.rb +0 -48
- data/test/unintrospectable_type_builder_test.rb +8 -2
- data/test/unit/builder_test.rb +1 -1
- data/test/unit/callback_builder_test.rb +19 -0
- data/test/unit/constant_builder_test.rb +11 -0
- data/test/unit/enum_builder_test.rb +25 -0
- data/test/unit/function_builder_test.rb +17 -0
- data/test/unit/in_out_pointer_test.rb +11 -0
- data/test/unit/in_pointer_test.rb +6 -2
- data/test/unit/interface_builder_test.rb +17 -0
- data/test/unit/module_builder_test.rb +95 -0
- data/test/unit/object_type_builder_test.rb +24 -0
- data/test/unit/struct_builder_test.rb +106 -0
- data/test/unit/union_builder_test.rb +17 -0
- data/test/unit/variable_name_generator_test.rb +16 -0
- metadata +102 -75
- data/test/module_builder_test.rb +0 -53
@@ -33,19 +33,19 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
33
33
|
should "create an instance using #new_alternative_constructor1" do
|
34
34
|
tb = Regress::TestBoxed.new_alternative_constructor1 1
|
35
35
|
assert_instance_of Regress::TestBoxed, tb
|
36
|
-
assert_equal 1, tb
|
36
|
+
assert_equal 1, tb.some_int8
|
37
37
|
end
|
38
38
|
|
39
39
|
should "create an instance using #new_alternative_constructor2" do
|
40
40
|
tb = Regress::TestBoxed.new_alternative_constructor2 1, 2
|
41
41
|
assert_instance_of Regress::TestBoxed, tb
|
42
|
-
assert_equal 1 + 2, tb
|
42
|
+
assert_equal 1 + 2, tb.some_int8
|
43
43
|
end
|
44
44
|
|
45
45
|
should "create an instance using #new_alternative_constructor3" do
|
46
46
|
tb = Regress::TestBoxed.new_alternative_constructor3 "54"
|
47
47
|
assert_instance_of Regress::TestBoxed, tb
|
48
|
-
assert_equal 54, tb
|
48
|
+
assert_equal 54, tb.some_int8
|
49
49
|
end
|
50
50
|
|
51
51
|
should "have non-zero positive result for #get_gtype" do
|
@@ -72,12 +72,12 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
72
72
|
end
|
73
73
|
|
74
74
|
should "copy fields" do
|
75
|
-
assert_equal 123, @tb2
|
75
|
+
assert_equal 123, @tb2.some_int8
|
76
76
|
end
|
77
77
|
|
78
78
|
should "create a true copy" do
|
79
|
-
@tb
|
80
|
-
assert_equal 123, @tb2
|
79
|
+
@tb.some_int8 = 89
|
80
|
+
assert_equal 123, @tb2.some_int8
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -112,15 +112,48 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
112
112
|
end
|
113
113
|
|
114
114
|
describe "TestFundamentalObject" do
|
115
|
-
it "must
|
115
|
+
it "must exist" do
|
116
|
+
Regress::TestFundamentalObject
|
117
|
+
end
|
118
|
+
|
119
|
+
it "does not have GObject::Object as an ancestor" do
|
120
|
+
refute_includes Regress::TestFundamentalObject.ancestors,
|
121
|
+
GObject::Object
|
122
|
+
end
|
123
|
+
# TODO: Test more, if possible (e.g., cannot be instantiated).
|
116
124
|
end
|
117
125
|
|
118
126
|
describe "TestFundamentalSubObject" do
|
119
|
-
|
127
|
+
before do
|
128
|
+
@so = Regress::TestFundamentalSubObject.new "foo"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "can be instantiated" do
|
132
|
+
pass
|
133
|
+
end
|
134
|
+
|
135
|
+
it "is a subclass of TestFundamentalObject" do
|
136
|
+
assert_kind_of Regress::TestFundamentalObject, @so
|
137
|
+
end
|
138
|
+
|
139
|
+
it "stores the constructor parameter in the :data field" do
|
140
|
+
assert_equal "foo", @so.data
|
141
|
+
end
|
142
|
+
|
143
|
+
it "has a refcount of 1" do
|
144
|
+
assert_equal 1, @so.fundamental_object.refcount
|
145
|
+
end
|
120
146
|
end
|
121
147
|
|
122
148
|
describe "TestInterface" do
|
123
|
-
it "
|
149
|
+
it "is a module" do
|
150
|
+
assert_instance_of Module, Regress::TestInterface
|
151
|
+
end
|
152
|
+
|
153
|
+
it "extends InterfaceBase" do
|
154
|
+
metaclass = class << Regress::TestInterface; self; end
|
155
|
+
assert_includes metaclass.ancestors, GirFFI::InterfaceBase
|
156
|
+
end
|
124
157
|
end
|
125
158
|
|
126
159
|
context "the Regress::TestObj class" do
|
@@ -167,6 +200,115 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
167
200
|
end
|
168
201
|
end
|
169
202
|
|
203
|
+
describe "#get_property" do
|
204
|
+
it "gets the 'bare' property" do
|
205
|
+
obj = Regress::TestObj.new_from_file("bar")
|
206
|
+
@o.set_bare obj
|
207
|
+
|
208
|
+
obj2 = @o.get_property("bare")
|
209
|
+
|
210
|
+
assert_equal obj.to_ptr, obj2.to_ptr
|
211
|
+
assert_instance_of Regress::TestObj, obj2
|
212
|
+
end
|
213
|
+
|
214
|
+
it "gets the 'boxed' property" do
|
215
|
+
tb = Regress::TestBoxed.new_alternative_constructor1 75
|
216
|
+
@o.set_property "boxed", tb
|
217
|
+
|
218
|
+
tb2 = @o.get_property("boxed")
|
219
|
+
|
220
|
+
assert_instance_of Regress::TestBoxed, tb2
|
221
|
+
assert_equal 75, tb2.some_int8
|
222
|
+
end
|
223
|
+
|
224
|
+
it "gets the 'hash-table' property" do
|
225
|
+
ht = GLib::HashTable.new :utf8, :gint8
|
226
|
+
ht.insert "foo", 34
|
227
|
+
ht.insert "bar", 83
|
228
|
+
|
229
|
+
@o.set_property "hash-table", ht
|
230
|
+
|
231
|
+
ht2 = @o.get_property "hash-table"
|
232
|
+
assert_equal({"foo" => 34, "bar" => 83}, ht2.to_hash)
|
233
|
+
end
|
234
|
+
|
235
|
+
it "gets the 'float' property" do
|
236
|
+
@o.set_property "float", 3.14
|
237
|
+
assert_in_epsilon 3.14, @o.get_property("float")
|
238
|
+
end
|
239
|
+
|
240
|
+
it "gets the 'double' property" do
|
241
|
+
@o.set_property "double", 3.14
|
242
|
+
assert_in_epsilon 3.14, @o.get_property("double")
|
243
|
+
end
|
244
|
+
|
245
|
+
it "gets the 'int' property" do
|
246
|
+
@o.set_property "int", 42
|
247
|
+
assert_equal 42, @o.get_property("int")
|
248
|
+
end
|
249
|
+
|
250
|
+
it "gets the 'list' property" do
|
251
|
+
lst = GLib::List.new(:utf8).append("foo").append("bar")
|
252
|
+
|
253
|
+
@o.set_property "list", lst
|
254
|
+
|
255
|
+
lst2 = @o.get_property "list"
|
256
|
+
assert_equal ["foo", "bar"], lst2.to_a
|
257
|
+
end
|
258
|
+
|
259
|
+
it "gets the 'string' property" do
|
260
|
+
@o.set_property "string", "foobar"
|
261
|
+
assert_equal "foobar", @o.get_property("string")
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
describe "#set_property" do
|
266
|
+
it "sets the 'bare' property" do
|
267
|
+
obj = Regress::TestObj.new_from_file("bar")
|
268
|
+
@o.set_property "bare", obj
|
269
|
+
assert_equal obj.to_ptr, @o.bare.to_ptr
|
270
|
+
end
|
271
|
+
|
272
|
+
it "sets the 'boxed' property" do
|
273
|
+
tb = Regress::TestBoxed.new_alternative_constructor1 75
|
274
|
+
@o.set_property "boxed", tb
|
275
|
+
tb2 = @o.boxed
|
276
|
+
assert_equal 75, tb2.some_int8
|
277
|
+
end
|
278
|
+
|
279
|
+
it "sets the 'hash-table' property" do
|
280
|
+
@o.set_property("hash-table", {"foo" => 34, "bar" => 83})
|
281
|
+
assert_equal({"foo" => 34, "bar" => 83},
|
282
|
+
GLib::HashTable.wrap(:utf8, :gint32, @o.hash_table.to_ptr).to_hash)
|
283
|
+
end
|
284
|
+
|
285
|
+
it "sets the 'float' property" do
|
286
|
+
@o.set_property "float", 3.14
|
287
|
+
assert_in_epsilon 3.14, @o.some_float
|
288
|
+
end
|
289
|
+
|
290
|
+
it "sets the 'double' property" do
|
291
|
+
@o.set_property "double", 3.14
|
292
|
+
assert_in_epsilon 3.14, @o.some_double
|
293
|
+
end
|
294
|
+
|
295
|
+
it "sets the 'int' property" do
|
296
|
+
@o.set_property "int", 42
|
297
|
+
assert_equal 42, @o.some_int8
|
298
|
+
end
|
299
|
+
|
300
|
+
it "sets the 'list' property" do
|
301
|
+
@o.set_property "list", ["foo", "bar"]
|
302
|
+
assert_equal ["foo", "bar"],
|
303
|
+
GLib::List.wrap(:utf8, @o.list.to_ptr).to_a
|
304
|
+
end
|
305
|
+
|
306
|
+
it "sets the 'string' property" do
|
307
|
+
@o.set_property "string", "foobar"
|
308
|
+
assert_equal "foobar", @o.string
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
170
312
|
should "have a reference count of 1" do
|
171
313
|
assert_equal 1, ref_count(@o)
|
172
314
|
end
|
@@ -184,7 +326,7 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
184
326
|
obj = Regress::TestObj.new_from_file("bar")
|
185
327
|
@o.set_bare obj
|
186
328
|
# TODO: What is the correct value to retrieve from the fields?
|
187
|
-
assert_equal obj.to_ptr, @o
|
329
|
+
assert_equal obj.to_ptr, @o.bare.to_ptr
|
188
330
|
end
|
189
331
|
|
190
332
|
should "have a working #instance_method method" do
|
@@ -247,19 +389,19 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
247
389
|
context "an instance" do
|
248
390
|
setup do
|
249
391
|
@obj = Regress::TestSimpleBoxedA.new
|
250
|
-
@obj
|
251
|
-
@obj
|
252
|
-
@obj
|
253
|
-
@obj
|
392
|
+
@obj.some_int = 4236
|
393
|
+
@obj.some_int8 = 36
|
394
|
+
@obj.some_double = 23.53
|
395
|
+
@obj.some_enum = :value2
|
254
396
|
end
|
255
397
|
|
256
398
|
context "its equals method" do
|
257
399
|
setup do
|
258
400
|
@ob2 = Regress::TestSimpleBoxedA.new
|
259
|
-
@ob2
|
260
|
-
@ob2
|
261
|
-
@ob2
|
262
|
-
@ob2
|
401
|
+
@ob2.some_int = 4236
|
402
|
+
@ob2.some_int8 = 36
|
403
|
+
@ob2.some_double = 23.53
|
404
|
+
@ob2.some_enum = :value2
|
263
405
|
end
|
264
406
|
|
265
407
|
should "return true if values are the same" do
|
@@ -267,12 +409,12 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
267
409
|
end
|
268
410
|
|
269
411
|
should "return true if enum values differ" do
|
270
|
-
@ob2
|
412
|
+
@ob2.some_enum = :value3
|
271
413
|
assert_equal true, @obj.equals(@ob2)
|
272
414
|
end
|
273
415
|
|
274
416
|
should "return false if other values differ" do
|
275
|
-
@ob2
|
417
|
+
@ob2.some_int = 1
|
276
418
|
assert_equal false, @obj.equals(@ob2)
|
277
419
|
end
|
278
420
|
end
|
@@ -287,15 +429,15 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
287
429
|
end
|
288
430
|
|
289
431
|
should "copy fields" do
|
290
|
-
assert_equal 4236, @ob2
|
291
|
-
assert_equal 36, @ob2
|
292
|
-
assert_equal 23.53, @ob2
|
293
|
-
assert_equal :value2, @ob2
|
432
|
+
assert_equal 4236, @ob2.some_int
|
433
|
+
assert_equal 36, @ob2.some_int8
|
434
|
+
assert_equal 23.53, @ob2.some_double
|
435
|
+
assert_equal :value2, @ob2.some_enum
|
294
436
|
end
|
295
437
|
|
296
438
|
should "create a true copy" do
|
297
|
-
@obj
|
298
|
-
assert_equal 36, @ob2
|
439
|
+
@obj.some_int8 = 89
|
440
|
+
assert_equal 36, @ob2.some_int8
|
299
441
|
end
|
300
442
|
end
|
301
443
|
end
|
@@ -305,17 +447,17 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
305
447
|
context "an instance" do
|
306
448
|
should "have a working clone method" do
|
307
449
|
a = Regress::TestStructA.new
|
308
|
-
a
|
309
|
-
a
|
310
|
-
a
|
311
|
-
a
|
450
|
+
a.some_int = 2556
|
451
|
+
a.some_int8 = -10
|
452
|
+
a.some_double = 1.03455e20
|
453
|
+
a.some_enum = :value2
|
312
454
|
|
313
455
|
b = a.clone
|
314
456
|
|
315
|
-
assert_equal 2556, b
|
316
|
-
assert_equal(-10, b
|
317
|
-
assert_equal 1.03455e20, b
|
318
|
-
assert_equal :value2, b
|
457
|
+
assert_equal 2556, b.some_int
|
458
|
+
assert_equal(-10, b.some_int8)
|
459
|
+
assert_equal 1.03455e20, b.some_double
|
460
|
+
assert_equal :value2, b.some_enum
|
319
461
|
end
|
320
462
|
end
|
321
463
|
end
|
@@ -324,25 +466,26 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
324
466
|
describe "an instance" do
|
325
467
|
it "has a working method #clone" do
|
326
468
|
a = Regress::TestStructB.new
|
327
|
-
a
|
328
|
-
a
|
329
|
-
a
|
330
|
-
a
|
331
|
-
a
|
469
|
+
a.some_int8 = 42
|
470
|
+
a.nested_a.some_int = 2556
|
471
|
+
a.nested_a.some_int8 = -10
|
472
|
+
a.nested_a.some_double = 1.03455e20
|
473
|
+
a.nested_a.some_enum = :value2
|
332
474
|
|
333
475
|
b = a.clone
|
334
476
|
|
335
|
-
assert_equal 42, b
|
336
|
-
assert_equal 2556, b
|
337
|
-
assert_equal(-10, b
|
338
|
-
assert_equal 1.03455e20, b
|
339
|
-
assert_equal :value2, b
|
477
|
+
assert_equal 42, b.some_int8
|
478
|
+
assert_equal 2556, b.nested_a.some_int
|
479
|
+
assert_equal(-10, b.nested_a.some_int8)
|
480
|
+
assert_equal 1.03455e20, b.nested_a.some_double
|
481
|
+
assert_equal :value2, b.nested_a.some_enum
|
340
482
|
end
|
341
483
|
end
|
342
484
|
end
|
343
485
|
|
344
|
-
|
345
|
-
|
486
|
+
describe "TestStructC" do
|
487
|
+
it "needs to be tested"
|
488
|
+
end
|
346
489
|
|
347
490
|
describe "TestSubObj" do
|
348
491
|
it "is created with #new" do
|
@@ -366,7 +509,7 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
366
509
|
end
|
367
510
|
|
368
511
|
it "has a field parent_instance" do
|
369
|
-
assert_instance_of Regress::TestObj
|
512
|
+
assert_instance_of Regress::TestObj, @tso.parent_instance
|
370
513
|
end
|
371
514
|
end
|
372
515
|
end
|
@@ -386,26 +529,24 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
386
529
|
@obj = Regress::TestWi8021x.new
|
387
530
|
end
|
388
531
|
|
389
|
-
|
532
|
+
it "sets its boolean field with #set_testbool" do
|
390
533
|
@obj.set_testbool true
|
391
|
-
assert_equal 1, @obj
|
534
|
+
assert_equal 1, @obj.testbool
|
392
535
|
@obj.set_testbool false
|
393
|
-
assert_equal 0, @obj
|
536
|
+
assert_equal 0, @obj.testbool
|
394
537
|
end
|
395
538
|
|
396
|
-
|
397
|
-
@obj
|
539
|
+
it "gets its boolean field with #get_testbool" do
|
540
|
+
@obj.set_testbool false
|
398
541
|
assert_equal false, @obj.get_testbool
|
399
|
-
@obj
|
542
|
+
@obj.set_testbool true
|
400
543
|
assert_equal true, @obj.get_testbool
|
401
544
|
end
|
402
545
|
|
403
|
-
|
404
|
-
@obj
|
405
|
-
|
406
|
-
|
407
|
-
@obj.get_property "testbool", gv
|
408
|
-
assert_equal true, gv.get_boolean
|
546
|
+
it "gets its boolean field with #get_property" do
|
547
|
+
@obj.set_testbool true
|
548
|
+
val = @obj.get_property "testbool"
|
549
|
+
assert_equal true, val
|
409
550
|
end
|
410
551
|
end
|
411
552
|
end
|
@@ -491,7 +632,7 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
491
632
|
|
492
633
|
should "have correct test_async_ready_callback" do
|
493
634
|
a = 1
|
494
|
-
main_loop = GLib.
|
635
|
+
main_loop = GLib::MainLoop.new nil, false
|
495
636
|
|
496
637
|
Regress.test_async_ready_callback Proc.new {
|
497
638
|
main_loop.quit
|
@@ -631,12 +772,29 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
631
772
|
assert_in_delta 5435.32, r, 0.001
|
632
773
|
end
|
633
774
|
|
775
|
+
describe "#test_garray_container_return" do
|
776
|
+
before do
|
777
|
+
@arr = Regress.test_garray_container_return
|
778
|
+
end
|
779
|
+
|
780
|
+
it "returns an instance of GLib::PtrArray" do
|
781
|
+
@arr.must_be_instance_of GLib::PtrArray
|
782
|
+
end
|
783
|
+
|
784
|
+
it "returns the correct values" do
|
785
|
+
@arr.len.must_be :==, 1
|
786
|
+
ptr = @arr.pdata
|
787
|
+
ptr2 = ptr.read_pointer
|
788
|
+
ptr2.read_string.must_be :==, "regress"
|
789
|
+
end
|
790
|
+
end
|
791
|
+
|
634
792
|
describe "#test_ghash_container_return" do
|
635
793
|
before do
|
636
794
|
@hash = Regress.test_ghash_container_return
|
637
795
|
end
|
638
796
|
|
639
|
-
it "returns an instance of GLib::
|
797
|
+
it "returns an instance of GLib::HashTable" do
|
640
798
|
@hash.must_be_instance_of GLib::HashTable
|
641
799
|
end
|
642
800
|
|
@@ -868,7 +1026,7 @@ class GeneratedRegressTest < MiniTest::Spec
|
|
868
1026
|
|
869
1027
|
should "have correct test_simple_boxed_a_const_return" do
|
870
1028
|
result = Regress.test_simple_boxed_a_const_return
|
871
|
-
assert_equal [5, 6, 7.0], [result
|
1029
|
+
assert_equal [5, 6, 7.0], [result.some_int, result.some_int8, result.some_double]
|
872
1030
|
end
|
873
1031
|
|
874
1032
|
describe "the #test_simple_callback function" do
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe "Pretty-printing the Regress module" do
|
4
|
+
before do
|
5
|
+
GirFFI.setup :Regress
|
6
|
+
end
|
7
|
+
|
8
|
+
it "runs without throwing an exception" do
|
9
|
+
Regress._builder.pretty_print
|
10
|
+
end
|
11
|
+
end
|
data/test/type_builder_test.rb
CHANGED
@@ -2,54 +2,6 @@ require File.expand_path('gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
|
2
2
|
|
3
3
|
class TypeBuilderTest < MiniTest::Spec
|
4
4
|
context "The Builder::Type class" do
|
5
|
-
should "use parent struct as default layout" do
|
6
|
-
@gir = GObjectIntrospection::IRepository.default
|
7
|
-
@gir.require 'GObject', nil
|
8
|
-
|
9
|
-
stub(info = Object.new).parent { @gir.find_by_name 'GObject', 'Object' }
|
10
|
-
stub(info).fields { [] }
|
11
|
-
stub(info).info_type { :object }
|
12
|
-
stub(info).safe_name { 'Bar' }
|
13
|
-
stub(info).namespace { 'Foo' }
|
14
|
-
|
15
|
-
@classbuilder = GirFFI::Builder::Type::Object.new info
|
16
|
-
|
17
|
-
spec = @classbuilder.send :layout_specification
|
18
|
-
assert_equal [:parent, GObject::Object::Struct, 0], spec
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "for a layout with a fixed-length array" do
|
22
|
-
before do
|
23
|
-
stub(subtype = Object.new).pointer? { false }
|
24
|
-
stub(subtype).tag { :foo }
|
25
|
-
|
26
|
-
stub(@type = Object.new).pointer? { false }
|
27
|
-
stub(@type).tag { :array }
|
28
|
-
stub(@type).array_fixed_size { 2 }
|
29
|
-
stub(@type).param_type { subtype }
|
30
|
-
|
31
|
-
stub(field = Object.new).field_type { @type }
|
32
|
-
stub(field).name { "bar" }
|
33
|
-
stub(field).offset { 0 }
|
34
|
-
|
35
|
-
stub(@struct = Object.new).safe_name { 'Bar' }
|
36
|
-
stub(@struct).namespace { 'Foo' }
|
37
|
-
stub(@struct).fields { [ field ] }
|
38
|
-
end
|
39
|
-
|
40
|
-
it "creates the correct ffi type for the array" do
|
41
|
-
builder = GirFFI::Builder::Type::RegisteredType.new @struct
|
42
|
-
spec = builder.send :itypeinfo_to_ffitype_for_struct, @type
|
43
|
-
assert_equal [:foo, 2], spec
|
44
|
-
end
|
45
|
-
|
46
|
-
it "creates the correct layout specification" do
|
47
|
-
builder = GirFFI::Builder::Type::Struct.new @struct
|
48
|
-
spec = builder.send :layout_specification
|
49
|
-
assert_equal [:bar, [:foo, 2], 0], spec
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
5
|
context "for Gtk::Widget" do
|
54
6
|
setup do
|
55
7
|
@cbuilder = GirFFI::Builder::Type::Object.new get_introspection_data('Gtk', 'Widget')
|