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.
Files changed (78) hide show
  1. data/History.txt +14 -0
  2. data/TODO.rdoc +10 -5
  3. data/lib/ffi-glib.rb +7 -73
  4. data/lib/ffi-glib/array.rb +29 -4
  5. data/lib/ffi-glib/byte_array.rb +15 -1
  6. data/lib/ffi-glib/hash_table.rb +31 -24
  7. data/lib/ffi-glib/list.rb +28 -0
  8. data/lib/ffi-glib/list_methods.rb +10 -2
  9. data/lib/ffi-glib/ptr_array.rb +39 -0
  10. data/lib/ffi-glib/s_list.rb +29 -0
  11. data/lib/ffi-gobject.rb +49 -22
  12. data/lib/ffi-gobject/closure.rb +4 -3
  13. data/lib/ffi-gobject/helper.rb +20 -43
  14. data/lib/ffi-gobject/initially_unowned.rb +2 -0
  15. data/lib/ffi-gobject/object.rb +54 -0
  16. data/lib/ffi-gobject/ruby_closure.rb +22 -16
  17. data/lib/ffi-gobject/value.rb +54 -19
  18. data/lib/ffi-gobject_introspection/i_constant_info.rb +17 -1
  19. data/lib/ffi-gobject_introspection/i_field_info.rb +8 -0
  20. data/lib/ffi-gobject_introspection/i_property_info.rb +3 -1
  21. data/lib/ffi-gobject_introspection/lib.rb +19 -2
  22. data/lib/gir_ffi/arg_helper.rb +7 -45
  23. data/lib/gir_ffi/builder.rb +1 -1
  24. data/lib/gir_ffi/builder/argument.rb +148 -107
  25. data/lib/gir_ffi/builder/argument/base.rb +5 -5
  26. data/lib/gir_ffi/builder/argument/in_base.rb +2 -2
  27. data/lib/gir_ffi/builder/argument/in_out_base.rb +2 -3
  28. data/lib/gir_ffi/builder/argument/out_base.rb +2 -3
  29. data/lib/gir_ffi/builder/function.rb +11 -17
  30. data/lib/gir_ffi/builder/module.rb +26 -0
  31. data/lib/gir_ffi/builder/type.rb +5 -0
  32. data/lib/gir_ffi/builder/type/base.rb +2 -0
  33. data/lib/gir_ffi/builder/type/callback.rb +18 -3
  34. data/lib/gir_ffi/builder/type/constant.rb +4 -12
  35. data/lib/gir_ffi/builder/type/enum.rb +15 -6
  36. data/lib/gir_ffi/builder/type/interface.rb +4 -0
  37. data/lib/gir_ffi/builder/type/object.rb +11 -0
  38. data/lib/gir_ffi/builder/type/struct_based.rb +14 -4
  39. data/lib/gir_ffi/builder/type/union.rb +13 -7
  40. data/lib/gir_ffi/builder/type/with_layout.rb +59 -8
  41. data/lib/gir_ffi/class_base.rb +8 -1
  42. data/lib/gir_ffi/in_out_pointer.rb +17 -18
  43. data/lib/gir_ffi/in_pointer.rb +8 -1
  44. data/lib/gir_ffi/type_map.rb +12 -0
  45. data/lib/gir_ffi/variable_name_generator.rb +12 -0
  46. data/lib/gir_ffi/version.rb +1 -1
  47. data/test/ffi-glib/array_test.rb +54 -0
  48. data/test/ffi-glib/byte_array_test.rb +21 -0
  49. data/test/ffi-glib/glib_overrides_test.rb +1 -46
  50. data/test/ffi-glib/hash_table_test.rb +24 -0
  51. data/test/ffi-glib/list_test.rb +46 -0
  52. data/test/ffi-glib/ptr_array_test.rb +51 -0
  53. data/test/ffi-glib/s_list_test.rb +46 -0
  54. data/test/ffi-gobject/g_object_overrides_test.rb +8 -8
  55. data/test/ffi-gobject/gobject_test.rb +26 -0
  56. data/test/ffi-gobject/object_test.rb +12 -0
  57. data/test/ffi-gobject_introspection/i_constant_info_test.rb +5 -1
  58. data/test/ffi-gobject_introspection/lib_test.rb +56 -0
  59. data/test/integration/generated_gimarshallingtests_test.rb +118 -76
  60. data/test/integration/generated_regress_test.rb +220 -62
  61. data/test/integration/pretty_print_test.rb +11 -0
  62. data/test/type_builder_test.rb +0 -48
  63. data/test/unintrospectable_type_builder_test.rb +8 -2
  64. data/test/unit/builder_test.rb +1 -1
  65. data/test/unit/callback_builder_test.rb +19 -0
  66. data/test/unit/constant_builder_test.rb +11 -0
  67. data/test/unit/enum_builder_test.rb +25 -0
  68. data/test/unit/function_builder_test.rb +17 -0
  69. data/test/unit/in_out_pointer_test.rb +11 -0
  70. data/test/unit/in_pointer_test.rb +6 -2
  71. data/test/unit/interface_builder_test.rb +17 -0
  72. data/test/unit/module_builder_test.rb +95 -0
  73. data/test/unit/object_type_builder_test.rb +24 -0
  74. data/test/unit/struct_builder_test.rb +106 -0
  75. data/test/unit/union_builder_test.rb +17 -0
  76. data/test/unit/variable_name_generator_test.rb +16 -0
  77. metadata +102 -75
  78. data/test/module_builder_test.rb +0 -53
@@ -30,9 +30,9 @@ class GObjectOverridesTest < MiniTest::Spec
30
30
  should "pass in extra arguments" do
31
31
  o = Regress::TestSubObj.new
32
32
  sb = Regress::TestSimpleBoxedA.new
33
- sb[:some_int8] = 31
34
- sb[:some_double] = 2.42
35
- sb[:some_enum] = :value2
33
+ sb.some_int8 = 31
34
+ sb.some_double = 2.42
35
+ sb.some_enum = :value2
36
36
  b2 = nil
37
37
 
38
38
  argtypes = [:pointer, :pointer, :pointer]
@@ -101,7 +101,7 @@ class GObjectOverridesTest < MiniTest::Spec
101
101
 
102
102
  o = Regress::TestSubObj.new
103
103
  sb = Regress::TestSimpleBoxedA.new
104
- sb[:some_int] = 23
104
+ sb.some_int = 23
105
105
 
106
106
  GObject.signal_connect(o, "test-with-static-scope-arg", 2) { |i, object, d|
107
107
  @a = d
@@ -116,7 +116,7 @@ class GObjectOverridesTest < MiniTest::Spec
116
116
 
117
117
  should "pass on the extra arguments" do
118
118
  assert_instance_of Regress::TestSimpleBoxedA, @b
119
- assert_equal 23, @b[:some_int]
119
+ assert_equal 23, @b.some_int
120
120
  end
121
121
  end
122
122
 
@@ -139,15 +139,15 @@ class GObjectOverridesTest < MiniTest::Spec
139
139
  end
140
140
 
141
141
  should "contain two values" do
142
- assert_equal 2, @gva[:n_values]
142
+ assert_equal 2, @gva.n_values
143
143
  end
144
144
 
145
145
  should "have a first value with GType for TestSubObj" do
146
- assert_equal Regress::TestSubObj.get_gtype, (@gva.get_nth 0)[:g_type]
146
+ assert_equal Regress::TestSubObj.get_gtype, (@gva.get_nth 0).current_gtype
147
147
  end
148
148
 
149
149
  should "have a second value with GType for TestSimpleBoxedA" do
150
- assert_equal Regress::TestSimpleBoxedA.get_gtype, (@gva.get_nth 1)[:g_type]
150
+ assert_equal Regress::TestSimpleBoxedA.get_gtype, (@gva.get_nth 1).current_gtype
151
151
  end
152
152
  end
153
153
  end
@@ -18,5 +18,31 @@ describe GObject do
18
18
  end
19
19
  end
20
20
  end
21
+
22
+ it "has constants for the fundamental GTypes" do
23
+ assert_equal GObject.type_from_name("invalid"), GObject::TYPE_INVALID
24
+ assert_equal GObject.type_from_name("void"), GObject::TYPE_NONE
25
+ assert_equal GObject.type_from_name("GInterface"), GObject::TYPE_INTERFACE
26
+ assert_equal GObject.type_from_name("gchar"), GObject::TYPE_CHAR
27
+ assert_equal GObject.type_from_name("guchar"), GObject::TYPE_UCHAR
28
+ assert_equal GObject.type_from_name("gboolean"), GObject::TYPE_BOOLEAN
29
+ assert_equal GObject.type_from_name("gint"), GObject::TYPE_INT
30
+ assert_equal GObject.type_from_name("guint"), GObject::TYPE_UINT
31
+ assert_equal GObject.type_from_name("glong"), GObject::TYPE_LONG
32
+ assert_equal GObject.type_from_name("gulong"), GObject::TYPE_ULONG
33
+ assert_equal GObject.type_from_name("gint64"), GObject::TYPE_INT64
34
+ assert_equal GObject.type_from_name("guint64"), GObject::TYPE_UINT64
35
+ assert_equal GObject.type_from_name("GEnum"), GObject::TYPE_ENUM
36
+ assert_equal GObject.type_from_name("GFlags"), GObject::TYPE_FLAGS
37
+ assert_equal GObject.type_from_name("gfloat"), GObject::TYPE_FLOAT
38
+ assert_equal GObject.type_from_name("gdouble"), GObject::TYPE_DOUBLE
39
+ assert_equal GObject.type_from_name("gchararray"), GObject::TYPE_STRING
40
+ assert_equal GObject.type_from_name("gpointer"), GObject::TYPE_POINTER
41
+ assert_equal GObject.type_from_name("GBoxed"), GObject::TYPE_BOXED
42
+ assert_equal GObject.type_from_name("GParam"), GObject::TYPE_PARAM
43
+ assert_equal GObject.type_from_name("GObject"), GObject::TYPE_OBJECT
44
+ assert_equal GObject.type_from_name("GType"), GObject::TYPE_GTYPE
45
+ assert_equal GObject.type_from_name("GVariant"), GObject::TYPE_VARIANT
46
+ end
21
47
  end
22
48
 
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
2
+
3
+ require 'ffi-gobject'
4
+
5
+ describe GObject::Object do
6
+ describe "#get_property" do
7
+ it "is overridden to have arity 1" do
8
+ assert_equal 1,
9
+ GObject::Object.instance_method("get_property").arity
10
+ end
11
+ end
12
+ end
@@ -11,7 +11,11 @@ describe GObjectIntrospection::IConstantInfo do
11
11
  end
12
12
 
13
13
  it "returns a value union with member :v_int32 with value 1" do
14
- assert_equal 1, @info.value[:v_int32]
14
+ assert_equal 1, @info.value_union[:v_int32]
15
+ end
16
+
17
+ it "returns 1 as its value" do
18
+ assert_equal 1, @info.value
15
19
  end
16
20
  end
17
21
  end
@@ -0,0 +1,56 @@
1
+ require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
2
+
3
+ describe "loading the shared library" do
4
+ before do
5
+ # Avoid cluttering the error stream with method redefinition warnings.
6
+ stub(GObjectIntrospection::Lib).attach_function { }
7
+ end
8
+
9
+ describe "with ABI version 0 installed" do
10
+ before do
11
+ stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.1") { raise LoadError }
12
+ stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.0") { }
13
+ stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0") { raise "not expected" }
14
+ end
15
+
16
+ it "prints a warning message" do
17
+ _, err = capture_io do
18
+ load 'ffi-gobject_introspection/lib.rb'
19
+ end
20
+
21
+ assert_match(/not supported/, err)
22
+ end
23
+ end
24
+
25
+ describe "with ABI version 1 installed" do
26
+ before do
27
+ stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.0") { raise LoadError }
28
+ stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.1") { }
29
+ stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0") { raise "not expected" }
30
+ end
31
+
32
+ it "does not print a warning message" do
33
+ _, err = capture_io do
34
+ load 'ffi-gobject_introspection/lib.rb'
35
+ end
36
+
37
+ assert_equal "", err
38
+ end
39
+ end
40
+
41
+ describe "without being able to determine the ABI version" do
42
+ before do
43
+ stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.0") { raise LoadError }
44
+ stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0.so.1") { raise LoadError }
45
+ stub(GObjectIntrospection::Lib).ffi_lib("girepository-1.0") { }
46
+ end
47
+
48
+ it "prints a warning message" do
49
+ _, err = capture_io do
50
+ load 'ffi-gobject_introspection/lib.rb'
51
+ end
52
+
53
+ assert_match(/not supported/, err)
54
+ end
55
+ end
56
+ end
@@ -3,12 +3,10 @@ require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
3
3
 
4
4
  require 'gir_ffi'
5
5
 
6
+ GirFFI.setup :GIMarshallingTests
7
+
6
8
  # Tests generated methods and functions in the GIMarshallingTests namespace.
7
9
  describe "GIMarshallingTests" do
8
- before do
9
- GirFFI.setup :GIMarshallingTests
10
- end
11
-
12
10
  describe "BoxedStruct" do
13
11
  it "is created with #new" do
14
12
  bx = GIMarshallingTests::BoxedStruct.new
@@ -18,7 +16,7 @@ describe "GIMarshallingTests" do
18
16
  describe "an instance" do
19
17
  before do
20
18
  @bx = GIMarshallingTests::BoxedStruct.new
21
- @bx[:long_] = 42
19
+ @bx.long_ = 42
22
20
  end
23
21
 
24
22
  it "has a working method #inv" do
@@ -26,15 +24,38 @@ describe "GIMarshallingTests" do
26
24
  pass
27
25
  end
28
26
 
29
- it "has a field :long_" do
30
- assert_equal 42, @bx[:long_]
27
+ it "has a writable field long_" do
28
+ assert_equal 42, @bx.long_
29
+ @bx.long_ = 43
30
+ assert_equal 43, @bx.long_
31
31
  end
32
32
 
33
- # TODO: More friendly access to array fields.
34
- it "has a field :g_strv" do
35
- assert @bx[:g_strv].null?
33
+ it "has a writable field g_strv" do
34
+ assert_equal [], @bx.g_strv
35
+ @bx.g_strv = ["foo", "bar"]
36
+ assert_equal ["foo", "bar"], @bx.g_strv
36
37
  end
37
38
  end
39
+
40
+ it "has a working function #inout" do
41
+ bx = GIMarshallingTests::BoxedStruct.new
42
+ bx.long_ = 42
43
+
44
+ res = GIMarshallingTests::BoxedStruct.inout bx
45
+ assert_equal 42, bx.long_
46
+ assert_equal 0, res.long_
47
+ end
48
+
49
+ it "has a working function #out" do
50
+ res = GIMarshallingTests::BoxedStruct.out
51
+ assert_equal 42, res.long_
52
+ end
53
+
54
+ it "has a working function #returnv" do
55
+ res = GIMarshallingTests::BoxedStruct.returnv
56
+ assert_equal 42, res.long_
57
+ assert_equal ["0", "1", "2"], res.g_strv
58
+ end
38
59
  end
39
60
 
40
61
  it "has the constant CONSTANT_GERROR_CODE" do
@@ -90,9 +111,8 @@ describe "GIMarshallingTests" do
90
111
  describe "NestedStruct" do
91
112
  it "contains a SimpleStruct" do
92
113
  ns = GIMarshallingTests::NestedStruct.new
93
- # FIXME: Make it an instance of SimpleStruct
94
- assert_instance_of GIMarshallingTests::SimpleStruct::Struct,
95
- ns[:simple_struct]
114
+ assert_instance_of GIMarshallingTests::SimpleStruct,
115
+ ns.simple_struct
96
116
  end
97
117
  end
98
118
 
@@ -116,7 +136,7 @@ describe "GIMarshallingTests" do
116
136
  it "creates instances with #new" do
117
137
  ob = GIMarshallingTests::Object.new 42
118
138
  assert_instance_of GIMarshallingTests::Object, ob
119
- assert_equal 42, ob[:int_]
139
+ assert_equal 42, ob.int_
120
140
  end
121
141
 
122
142
  it "has a working function #full_inout" do
@@ -176,7 +196,7 @@ describe "GIMarshallingTests" do
176
196
 
177
197
  it "has a working virtual method #method_with_default_implementation" do
178
198
  @obj.method_with_default_implementation 104
179
- assert_equal 104, @obj[:int_]
199
+ assert_equal 104, @obj.int_
180
200
  end
181
201
 
182
202
  # This function is only found in the header
@@ -216,20 +236,26 @@ describe "GIMarshallingTests" do
216
236
  pass
217
237
  end
218
238
 
239
+ it "has a property 'int'" do
240
+ assert_equal 42, @obj.get_property("int")
241
+ @obj.set_property("int", 13)
242
+ assert_equal 13, @obj.get_property("int")
243
+ end
244
+
219
245
  it "has a working method #overridden_method" do
220
- @obj[:int_] = 0
246
+ @obj.set_property("int", 0)
221
247
  @obj.overridden_method
222
248
  pass
223
249
  end
224
250
 
225
- it "has a property 'int'"
226
-
227
- it "has a field parent_instance containing the parent struct" do
228
- assert_instance_of GObject::Object::Struct, @obj[:parent_instance]
251
+ it "has a read-only field parent_instance containing the parent struct" do
252
+ assert_instance_of GObject::Object, @obj.parent_instance
253
+ assert_raises(NoMethodError) { @obj.parent_instance = nil }
229
254
  end
230
255
 
231
- it "has a field int_ containing the argument to #new" do
232
- assert_equal 42, @obj[:int_]
256
+ it "has a read-only field int_ containing the argument to #new" do
257
+ assert_equal 42, @obj.int_
258
+ assert_raises(NoMethodError) { @obj.int_ = 1 }
233
259
  end
234
260
  end
235
261
  end
@@ -250,12 +276,14 @@ describe "GIMarshallingTests" do
250
276
  @obj = GIMarshallingTests::OverridesObject.new
251
277
  end
252
278
 
253
- it "has a field parent_instance containing the parent struct" do
254
- assert_instance_of GObject::Object::Struct, @obj[:parent_instance]
279
+ it "has a read-only field parent_instance containing the parent struct" do
280
+ assert_instance_of GObject::Object, @obj.parent_instance
281
+ assert_raises(NoMethodError) { @obj.parent_instance = nil }
255
282
  end
256
283
 
257
- it "has a field long_" do
258
- assert_equal 0.0, @obj[:long_]
284
+ it "has a read-only field long_" do
285
+ assert_equal 0.0, @obj.long_
286
+ assert_raises(NoMethodError) { @obj.long_ = 1 }
259
287
  end
260
288
  end
261
289
  end
@@ -271,12 +299,14 @@ describe "GIMarshallingTests" do
271
299
  @ps = GIMarshallingTests::PointerStruct.new
272
300
  end
273
301
 
274
- it "has a field long_" do
275
- assert_equal 0.0, @ps[:long_]
302
+ it "has a writable field long_" do
303
+ assert_equal 0, @ps.long_
304
+ @ps.long_ = 1056
305
+ assert_equal 1056, @ps.long_
276
306
  end
277
307
 
278
308
  it "has a working method #inv" do
279
- @ps[:long_] = 42.0
309
+ @ps.long_ = 42
280
310
  @ps.inv
281
311
  pass
282
312
  end
@@ -299,17 +329,21 @@ describe "GIMarshallingTests" do
299
329
  @ss = GIMarshallingTests::SimpleStruct.new
300
330
  end
301
331
 
302
- it "has a field long_" do
303
- assert_equal 0, @ss[:long_]
332
+ it "has a writable field long_" do
333
+ assert_equal 0, @ss.long_
334
+ @ss.long_ = 1056
335
+ assert_equal 1056, @ss.long_
304
336
  end
305
337
 
306
- it "has a field int8" do
307
- assert_equal 0, @ss[:int8]
338
+ it "has a writable field int8" do
339
+ assert_equal 0, @ss.int8
340
+ @ss.int8 = -43
341
+ assert_equal(-43, @ss.int8)
308
342
  end
309
343
 
310
344
  it "has a working method #inv" do
311
- @ss[:long_] = 6
312
- @ss[:int8] = 7
345
+ @ss.long_ = 6
346
+ @ss.int8 = 7
313
347
  @ss.inv
314
348
  pass
315
349
  end
@@ -337,8 +371,9 @@ describe "GIMarshallingTests" do
337
371
  pass
338
372
  end
339
373
 
340
- it "has a field parent_instance containing the parent struct" do
341
- assert_instance_of GIMarshallingTests::Object::Struct, @so[:parent_instance]
374
+ it "has a read-only field parent_instance containing the parent struct" do
375
+ assert_instance_of GIMarshallingTests::Object, @so.parent_instance
376
+ assert_raises(NoMethodError) { @so.parent_instance = nil }
342
377
  end
343
378
 
344
379
  it "has a working inherited virtual method #method_int8_in"
@@ -346,14 +381,14 @@ describe "GIMarshallingTests" do
346
381
 
347
382
  it "has a working inherited virtual method #method_with_default_implementation" do
348
383
  @so.method_with_default_implementation 104
349
- assert_equal 104, @so[:parent_instance][:int_]
384
+ assert_equal 104, @so.parent_instance.int_
350
385
  end
351
386
 
352
387
  it "has a working inherited method #int8_in"
353
388
  it "has a working inherited method #int8_out"
354
389
 
355
390
  it "has a working inherited method #method" do
356
- @so[:parent_instance][:int_] = 42
391
+ @so.parent_instance.set_property("int", 42)
357
392
  @so.method
358
393
  pass
359
394
  end
@@ -379,13 +414,13 @@ describe "GIMarshallingTests" do
379
414
  end
380
415
 
381
416
  it "has a working inherited method #none_in" do
382
- @so[:parent_instance][:int_] = 42
417
+ @so.parent_instance.set_property("int", 42)
383
418
  @so.none_in
384
419
  pass
385
420
  end
386
421
 
387
422
  it "has a working inherited method #overridden_method" do
388
- @so[:parent_instance][:int_] = 0
423
+ @so.parent_instance.set_property("int", 0)
389
424
  @so.overridden_method
390
425
  pass
391
426
  end
@@ -403,18 +438,20 @@ describe "GIMarshallingTests" do
403
438
  @it = GIMarshallingTests::Union.new
404
439
  end
405
440
 
406
- it "has a field long_" do
407
- assert_equal 0, @it[:long_]
441
+ it "has a writable field long_" do
442
+ assert_equal 0, @it.long_
443
+ @it.long_ = 1056
444
+ assert_equal 1056, @it.long_
408
445
  end
409
446
 
410
447
  it "has a working method #inv" do
411
- @it[:long_] = 42
448
+ @it.long_ = 42
412
449
  @it.inv
413
450
  pass
414
451
  end
415
452
 
416
453
  it "has a working method #method" do
417
- @it[:long_] = 42
454
+ @it.long_ = 42
418
455
  @it.method
419
456
  pass
420
457
  end
@@ -443,7 +480,7 @@ describe "GIMarshallingTests" do
443
480
 
444
481
  it "has a working function #array_fixed_out_struct" do
445
482
  res = GIMarshallingTests.array_fixed_out_struct
446
- assert_equal [[7, 6], [6, 7]], res.map {|s| [s[:long_], s[:int8]]}
483
+ assert_equal [[7, 6], [6, 7]], res.map {|s| [s.long_, s.int8]}
447
484
  end
448
485
 
449
486
  it "has a working function #array_fixed_short_in" do
@@ -456,10 +493,15 @@ describe "GIMarshallingTests" do
456
493
  assert_equal [-1, 0, 1, 2], res
457
494
  end
458
495
 
459
- it "has a working function #array_gvariant_in" do
496
+ it "has a working function #array_gvariant_(none)_in" do
460
497
  v1 = GLib::Variant.new_int32(27)
461
498
  v2 = GLib::Variant.new_string("Hello")
462
- GIMarshallingTests.array_gvariant_in [v1, v2]
499
+ if GIMarshallingTests._builder.setup_method :array_gvariant_in
500
+ GIMarshallingTests.array_gvariant_in [v1, v2]
501
+ else
502
+ GIMarshallingTests.array_gvariant_none_in [v1, v2]
503
+ end
504
+
463
505
  pass
464
506
  # TODO: Can we determine that result should be an array?
465
507
  # assert_equal 27, res[0].get_int32
@@ -549,20 +591,20 @@ describe "GIMarshallingTests" do
549
591
 
550
592
  it "has a working function #boxed_struct_inout" do
551
593
  bx = GIMarshallingTests::BoxedStruct.new
552
- bx[:long_] = 42
594
+ bx.long_ = 42
553
595
  res = GIMarshallingTests.boxed_struct_inout bx
554
- assert_equal 0, res[:long_]
596
+ assert_equal 0, res.long_
555
597
  end
556
598
 
557
599
  it "has a working function #boxed_struct_out" do
558
600
  res = GIMarshallingTests.boxed_struct_out
559
- assert_equal 42, res[:long_]
601
+ assert_equal 42, res.long_
560
602
  end
561
603
 
562
604
  it "has a working function #boxed_struct_returnv" do
563
605
  res = GIMarshallingTests.boxed_struct_returnv
564
- assert_equal 42, res[:long_]
565
- assert_equal ["0", "1", "2"], GirFFI::ArgHelper.strv_to_utf8_array(res[:g_strv])
606
+ assert_equal 42, res.long_
607
+ assert_equal ["0", "1", "2"], res.g_strv
566
608
  end
567
609
 
568
610
  it "has a working function #bytearray_full_return" do
@@ -575,8 +617,8 @@ describe "GIMarshallingTests" do
575
617
 
576
618
  it "has a working function #bytearray_none_in" do
577
619
  val = GIMarshallingTests.bytearray_full_return.to_string
578
- ba = GLib.byte_array_new
579
- GLib.byte_array_append ba, val
620
+ ba = GLib::ByteArray.new
621
+ ba = ba.append val
580
622
  GIMarshallingTests.bytearray_none_in ba
581
623
  pass
582
624
  end
@@ -676,8 +718,8 @@ describe "GIMarshallingTests" do
676
718
  end
677
719
 
678
720
  it "has a working function #garray_int_none_in" do
679
- arr = GLib.array_new :int
680
- GLib.array_append_vals arr, [-1, 0, 1, 2]
721
+ arr = GLib::Array.new :int
722
+ arr.append_vals [-1, 0, 1, 2]
681
723
  GIMarshallingTests.garray_int_none_in arr
682
724
  pass
683
725
  end
@@ -699,8 +741,8 @@ describe "GIMarshallingTests" do
699
741
 
700
742
  # TODO: Allow regular arrays as arguments directly.
701
743
  it "has a working function #garray_utf8_full_inout" do
702
- arr = GLib.array_new :utf8
703
- GLib.array_append_vals arr, ["0", "1", "2"]
744
+ arr = GLib::Array.new :utf8
745
+ arr.append_vals ["0", "1", "2"]
704
746
  res = GIMarshallingTests.garray_utf8_full_inout arr
705
747
  assert_equal ["-2", "-1", "0", "1"], res.to_a
706
748
  end
@@ -716,15 +758,15 @@ describe "GIMarshallingTests" do
716
758
  end
717
759
 
718
760
  it "has a working function #garray_utf8_none_in" do
719
- arr = GLib.array_new :utf8
720
- GLib.array_append_vals arr, ["0", "1", "2"]
761
+ arr = GLib::Array.new :utf8
762
+ arr.append_vals ["0", "1", "2"]
721
763
  GIMarshallingTests.garray_utf8_none_in arr
722
764
  pass
723
765
  end
724
766
 
725
767
  it "has a working function #garray_utf8_none_inout" do
726
- arr = GLib.array_new :utf8
727
- GLib.array_append_vals arr, ["0", "1", "2"]
768
+ arr = GLib::Array.new :utf8
769
+ arr.append_vals ["0", "1", "2"]
728
770
  res = GIMarshallingTests.garray_utf8_none_inout arr
729
771
  assert_equal ["-2", "-1", "0", "1"], res.to_a
730
772
  end
@@ -797,7 +839,7 @@ describe "GIMarshallingTests" do
797
839
  assert_equal({-1 => 1, 0 => 0, 1 => -1, 2 => -2}, gh.to_hash)
798
840
  end
799
841
 
800
- # XXX: Only defined in header
842
+ # This function is defined in the header but not implemented.
801
843
  # it "has a working function #ghashtable_utf8_container_in"
802
844
 
803
845
  it "has a working function #ghashtable_utf8_container_inout" do
@@ -818,7 +860,7 @@ describe "GIMarshallingTests" do
818
860
  res.to_hash)
819
861
  end
820
862
 
821
- # XXX: Only defined in header
863
+ # This function is defined in the header but not implemented.
822
864
  # it "has a working function #ghashtable_utf8_full_in"
823
865
 
824
866
  it "has a working function #ghashtable_utf8_full_inout" do
@@ -873,7 +915,7 @@ describe "GIMarshallingTests" do
873
915
  assert_equal [-1, 0, 1, 2], res.to_a
874
916
  end
875
917
 
876
- # XXX: Only defined in header
918
+ # This function is defined in the header but not implemented.
877
919
  # it "has a working function #glist_utf8_container_in"
878
920
 
879
921
  it "has a working function #glist_utf8_container_inout" do
@@ -891,7 +933,7 @@ describe "GIMarshallingTests" do
891
933
  assert_equal ["0", "1", "2"], res.to_a
892
934
  end
893
935
 
894
- # XXX: Only defined in header
936
+ # This function is defined in the header but not implemented.
895
937
  # it "has a working function #glist_utf8_full_in"
896
938
 
897
939
  it "has a working function #glist_utf8_full_inout" do
@@ -938,7 +980,7 @@ describe "GIMarshallingTests" do
938
980
  assert_equal [-1, 0, 1, 2], res.to_a
939
981
  end
940
982
 
941
- # XXX: Only defined in header
983
+ # This function is defined in the header but not implemented.
942
984
  # it "has a working function #gslist_utf8_container_in"
943
985
 
944
986
  it "has a working function #gslist_utf8_container_inout" do
@@ -956,7 +998,7 @@ describe "GIMarshallingTests" do
956
998
  assert_equal ["0", "1", "2"], res.to_a
957
999
  end
958
1000
 
959
- # XXX: Only defined in header
1001
+ # This function is defined in the header but not implemented.
960
1002
  # it "has a working function #gslist_utf8_full_in"
961
1003
 
962
1004
  it "has a working function #gslist_utf8_full_inout" do
@@ -1356,7 +1398,7 @@ describe "GIMarshallingTests" do
1356
1398
  it "has a working function #pointer_struct_returnv" do
1357
1399
  res = GIMarshallingTests.pointer_struct_returnv
1358
1400
  assert_instance_of GIMarshallingTests::PointerStruct, res
1359
- assert_equal 42, res[:long_]
1401
+ assert_equal 42, res.long_
1360
1402
  end
1361
1403
 
1362
1404
  it "has a working function #short_in_max" do
@@ -1402,8 +1444,8 @@ describe "GIMarshallingTests" do
1402
1444
  it "has a working function #simple_struct_returnv" do
1403
1445
  res = GIMarshallingTests.simple_struct_returnv
1404
1446
  assert_instance_of GIMarshallingTests::SimpleStruct, res
1405
- assert_equal 6, res[:long_]
1406
- assert_equal 7, res[:int8]
1447
+ assert_equal 6, res.long_
1448
+ assert_equal 7, res.int8
1407
1449
  end
1408
1450
 
1409
1451
  it "has a working function #size_in" do
@@ -1604,16 +1646,16 @@ describe "GIMarshallingTests" do
1604
1646
  assert_equal max_ulong, res
1605
1647
  end
1606
1648
 
1607
- # XXX: Only defined in header
1649
+ # This function is defined in the header but not implemented.
1608
1650
  # it "has a working function #union_inout"
1609
1651
 
1610
- # XXX: Only defined in header
1652
+ # This function is defined in the header but not implemented.
1611
1653
  # it "has a working function #union_out"
1612
1654
 
1613
1655
  it "has a working function #union_returnv" do
1614
1656
  res = GIMarshallingTests.union_returnv
1615
1657
  assert_instance_of GIMarshallingTests::Union, res
1616
- assert_equal 42, res[:long_]
1658
+ assert_equal 42, res.long_
1617
1659
  end
1618
1660
 
1619
1661
  it "has a working function #ushort_in" do
@@ -1641,7 +1683,7 @@ describe "GIMarshallingTests" do
1641
1683
  assert_nil res
1642
1684
  end
1643
1685
 
1644
- # XXX: Only defined in header
1686
+ # This function is defined in the header but not implemented.
1645
1687
  # it "has a working function #utf8_full_in"
1646
1688
 
1647
1689
  it "has a working function #utf8_full_inout" do