gir_ffi 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +7 -0
  3. data/TODO.md +8 -0
  4. data/lib/ffi-glib/array.rb +7 -7
  5. data/lib/ffi-glib/byte_array.rb +3 -4
  6. data/lib/ffi-glib/bytes.rb +3 -3
  7. data/lib/ffi-glib/error.rb +2 -2
  8. data/lib/ffi-glib/hash_table.rb +7 -7
  9. data/lib/ffi-glib/iconv.rb +3 -4
  10. data/lib/ffi-glib/list.rb +3 -3
  11. data/lib/ffi-glib/list_methods.rb +3 -3
  12. data/lib/ffi-glib/ptr_array.rb +6 -6
  13. data/lib/ffi-glib/s_list.rb +3 -3
  14. data/lib/ffi-glib/strv.rb +3 -3
  15. data/lib/ffi-glib/variant.rb +6 -2
  16. data/lib/ffi-glib.rb +3 -0
  17. data/lib/ffi-gobject/base.rb +1 -0
  18. data/lib/ffi-gobject/closure.rb +2 -2
  19. data/lib/ffi-gobject/initially_unowned.rb +4 -3
  20. data/lib/ffi-gobject/object.rb +5 -5
  21. data/lib/ffi-gobject/object_class.rb +2 -2
  22. data/lib/ffi-gobject/ruby_closure.rb +2 -3
  23. data/lib/ffi-gobject/value.rb +5 -5
  24. data/lib/ffi-gobject.rb +17 -22
  25. data/lib/ffi-gobject_introspection/i_arg_info.rb +0 -1
  26. data/lib/ffi-gobject_introspection/i_base_info.rb +3 -4
  27. data/lib/ffi-gobject_introspection/i_callable_info.rb +1 -2
  28. data/lib/ffi-gobject_introspection/i_constant_info.rb +19 -11
  29. data/lib/ffi-gobject_introspection/i_enum_info.rb +4 -3
  30. data/lib/ffi-gobject_introspection/i_function_info.rb +7 -1
  31. data/lib/ffi-gobject_introspection/i_interface_info.rb +12 -0
  32. data/lib/ffi-gobject_introspection/i_object_info.rb +19 -8
  33. data/lib/ffi-gobject_introspection/i_registered_type_info.rb +0 -1
  34. data/lib/ffi-gobject_introspection/i_repository.rb +10 -15
  35. data/lib/ffi-gobject_introspection/i_struct_info.rb +4 -2
  36. data/lib/ffi-gobject_introspection/i_type_info.rb +4 -2
  37. data/lib/ffi-gobject_introspection/i_union_info.rb +7 -3
  38. data/lib/ffi-gobject_introspection/i_value_info.rb +0 -1
  39. data/lib/ffi-gobject_introspection/lib.rb +1 -2
  40. data/lib/ffi-gobject_introspection.rb +0 -1
  41. data/lib/gir_ffi/allocation_helper.rb +2 -1
  42. data/lib/gir_ffi/arg_helper.rb +6 -2
  43. data/lib/gir_ffi/builder_helper.rb +1 -0
  44. data/lib/gir_ffi/builders/argument_builder_collection.rb +67 -0
  45. data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +2 -0
  46. data/lib/gir_ffi/builders/callback_argument_builder.rb +7 -5
  47. data/lib/gir_ffi/builders/callback_builder.rb +3 -1
  48. data/lib/gir_ffi/builders/callback_return_value_builder.rb +2 -0
  49. data/lib/gir_ffi/builders/closure_argument_builder.rb +13 -0
  50. data/lib/gir_ffi/builders/closure_convertor.rb +2 -0
  51. data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +2 -0
  52. data/lib/gir_ffi/builders/constructor_result_convertor.rb +1 -0
  53. data/lib/gir_ffi/builders/enum_builder.rb +1 -4
  54. data/lib/gir_ffi/builders/field_builder.rb +2 -2
  55. data/lib/gir_ffi/builders/function_builder.rb +2 -1
  56. data/lib/gir_ffi/builders/interface_builder.rb +0 -3
  57. data/lib/gir_ffi/builders/mapping_method_builder.rb +24 -92
  58. data/lib/gir_ffi/builders/marshalling_method_builder.rb +73 -0
  59. data/lib/gir_ffi/builders/null_argument_builder.rb +3 -0
  60. data/lib/gir_ffi/builders/null_builder.rb +1 -0
  61. data/lib/gir_ffi/builders/object_builder.rb +0 -2
  62. data/lib/gir_ffi/builders/property_builder.rb +4 -4
  63. data/lib/gir_ffi/builders/registered_type_builder.rb +35 -1
  64. data/lib/gir_ffi/builders/return_value_builder.rb +4 -6
  65. data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +2 -0
  66. data/lib/gir_ffi/builders/signal_closure_builder.rb +46 -0
  67. data/lib/gir_ffi/builders/struct_builder.rb +0 -2
  68. data/lib/gir_ffi/builders/type_builder.rb +1 -1
  69. data/lib/gir_ffi/builders/unintrospectable_builder.rb +1 -1
  70. data/lib/gir_ffi/builders/union_builder.rb +0 -2
  71. data/lib/gir_ffi/builders/user_defined_builder.rb +6 -18
  72. data/lib/gir_ffi/builders/vfunc_builder.rb +6 -4
  73. data/lib/gir_ffi/builders/with_layout.rb +1 -2
  74. data/lib/gir_ffi/callback_base.rb +4 -4
  75. data/lib/gir_ffi/class_base.rb +28 -18
  76. data/lib/gir_ffi/enum_base.rb +2 -2
  77. data/lib/gir_ffi/ffi_ext/pointer.rb +1 -0
  78. data/lib/gir_ffi/in_out_pointer.rb +4 -4
  79. data/lib/gir_ffi/in_pointer.rb +2 -2
  80. data/lib/gir_ffi/info_ext/full_type_name.rb +16 -0
  81. data/lib/gir_ffi/info_ext/i_arg_info.rb +2 -3
  82. data/lib/gir_ffi/info_ext/i_callback_info.rb +1 -8
  83. data/lib/gir_ffi/info_ext/i_property_info.rb +0 -1
  84. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +0 -1
  85. data/lib/gir_ffi/info_ext/i_signal_info.rb +8 -40
  86. data/lib/gir_ffi/info_ext/i_type_info.rb +12 -2
  87. data/lib/gir_ffi/info_ext/i_vfunc_info.rb +1 -6
  88. data/lib/gir_ffi/info_ext/safe_constant_name.rb +0 -5
  89. data/lib/gir_ffi/info_ext.rb +1 -0
  90. data/lib/gir_ffi/lib_c.rb +1 -0
  91. data/lib/gir_ffi/module_base.rb +2 -2
  92. data/lib/gir_ffi/object_base.rb +0 -16
  93. data/lib/gir_ffi/receiver_argument_info.rb +0 -4
  94. data/lib/gir_ffi/registered_type_base.rb +0 -1
  95. data/lib/gir_ffi/sized_array.rb +5 -5
  96. data/lib/gir_ffi/struct_base.rb +4 -0
  97. data/lib/gir_ffi/type_base.rb +2 -2
  98. data/lib/gir_ffi/type_map.rb +1 -0
  99. data/lib/gir_ffi/unintrospectable_type_info.rb +1 -3
  100. data/lib/gir_ffi/user_data_type_info.rb +2 -0
  101. data/lib/gir_ffi/version.rb +2 -1
  102. data/lib/gir_ffi/zero_terminated.rb +6 -6
  103. data/lib/gir_ffi-base/glib/boolean.rb +2 -2
  104. data/lib/gir_ffi-base/glib/strv.rb +1 -1
  105. data/lib/gir_ffi-base/gobject/lib.rb +1 -0
  106. data/lib/gir_ffi-base/gobject.rb +1 -1
  107. data/lib/gir_ffi.rb +2 -0
  108. data/test/ffi-glib/hash_table_test.rb +1 -1
  109. data/test/ffi-glib/strv_test.rb +27 -0
  110. data/test/ffi-gobject_introspection/i_constant_info_test.rb +1 -5
  111. data/test/ffi-gobject_test.rb +3 -3
  112. data/test/gir_ffi/builders/{with_methods_test.rb → registered_type_builder_test.rb} +1 -1
  113. data/test/gir_ffi/builders/signal_closure_builder_test.rb +136 -0
  114. data/test/gir_ffi/builders/user_defined_builder_test.rb +2 -1
  115. data/test/gir_ffi/info_ext/i_signal_info_test.rb +0 -11
  116. data/test/integration/generated_gimarshallingtests_test.rb +47 -2
  117. data/test/integration/generated_regress_test.rb +19 -11
  118. metadata +82 -25
  119. data/lib/gir_ffi/builders/signal_builder.rb +0 -51
  120. data/lib/gir_ffi/builders/with_methods.rb +0 -45
  121. data/lib/gir_ffi/signal_base.rb +0 -21
  122. data/lib/gir_ffi/vfunc_base.rb +0 -9
  123. data/test/gir_ffi/builders/signal_builder_test.rb +0 -106
@@ -1,6 +1,33 @@
1
1
  require 'base_test_helper'
2
2
 
3
3
  describe GLib::Strv do
4
+ describe "::from" do
5
+ it "creates a Strv from a Ruby array" do
6
+ strv = GLib::Strv.from ["1", "2", "3"]
7
+ strv.must_be_instance_of GLib::Strv
8
+ strv.to_a.must_equal ["1", "2", "3"]
9
+ end
10
+
11
+ it "return its argument if given a Strv" do
12
+ strv = GLib::Strv.from ["1", "2", "3"]
13
+ strv2 = GLib::Strv.from strv
14
+ assert strv2.equal? strv
15
+ end
16
+
17
+ it "wraps its argument if given a pointer" do
18
+ strv = GLib::Strv.from ["1", "2", "3"]
19
+
20
+ pointer = strv.to_ptr
21
+ pointer.must_be_kind_of FFI::Pointer
22
+
23
+ strv2 = GLib::Strv.from pointer
24
+
25
+ strv2.must_be_kind_of GLib::Strv
26
+ refute strv2.equal? strv
27
+ strv2.to_a.must_equal strv.to_a
28
+ end
29
+ end
30
+
4
31
  describe "#==" do
5
32
  it "returns true when comparing to an array with the same elements" do
6
33
  strv = GLib::Strv.from ["1", "2", "3"]
@@ -10,11 +10,7 @@ describe GObjectIntrospection::IConstantInfo do
10
10
  assert_equal :gint32, @info.constant_type.tag
11
11
  end
12
12
 
13
- it "returns a value union with member :v_int32 with value 1_000_000" do
14
- assert_equal 1_000_000, @info.value_union[:v_int32]
15
- end
16
-
17
- it "returns 1 as its value" do
13
+ it "returns 1_000_000 as its value" do
18
14
  assert_equal 1_000_000, @info.value
19
15
  end
20
16
  end
@@ -122,14 +122,14 @@ describe GObject do
122
122
  sb = Regress::TestSimpleBoxedA.new
123
123
  sb.some_int = 23
124
124
 
125
- GObject.signal_connect(o, "test-with-static-scope-arg", 2) { |i, object, d|
126
- @a = d
125
+ GObject.signal_connect(o, "test-with-static-scope-arg", 2) { |instance, object, user_data|
126
+ @a = user_data
127
127
  @b = object
128
128
  }
129
129
  GObject.signal_emit o, "test-with-static-scope-arg", sb
130
130
  end
131
131
 
132
- it "moves the user data argument" do
132
+ it "passes on the user data argument" do
133
133
  assert_equal 2, @a
134
134
  end
135
135
 
@@ -2,7 +2,7 @@ require 'gir_ffi_test_helper'
2
2
 
3
3
  GirFFI.setup :Regress
4
4
 
5
- describe GirFFI::Builders::WithMethods do
5
+ describe GirFFI::Builders::RegisteredTypeBuilder do
6
6
  describe "#setup_instance_method" do
7
7
  it "restores a method that was removed" do
8
8
  Regress::TestObj.class_eval { remove_method "instance_method" }
@@ -0,0 +1,136 @@
1
+ require 'gir_ffi_test_helper'
2
+
3
+ describe GirFFI::Builders::SignalClosureBuilder do
4
+ let(:builder) { GirFFI::Builders::SignalClosureBuilder.new signal_info }
5
+
6
+ describe "#build_class" do
7
+ let(:signal_info) {
8
+ get_signal_introspection_data "Regress", "TestObj", "test" }
9
+
10
+ it "builds a descendant of RubyClosure" do
11
+ klass = builder.build_class
12
+ klass.ancestors.must_include GObject::RubyClosure
13
+ end
14
+ end
15
+
16
+ describe "#marshaller_definition" do
17
+ describe "for a signal with no arguments or return value" do
18
+ let(:signal_info) {
19
+ get_signal_introspection_data "Regress", "TestObj", "test" }
20
+
21
+ it "returns a valid marshaller converting only the receiver" do
22
+ expected = <<-CODE.reset_indentation
23
+ def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
24
+ _instance, _ = param_values.map(&:get_value_plain)
25
+ _v1 = _instance
26
+ wrap(closure.to_ptr).invoke_block(_v1)
27
+ end
28
+ CODE
29
+
30
+ builder.marshaller_definition.must_equal expected
31
+ end
32
+ end
33
+
34
+ describe "for a signal with an argument and a return value" do
35
+ let(:signal_info) {
36
+ get_signal_introspection_data "Regress", "TestObj", "sig-with-int64-prop" }
37
+
38
+ it "returns a valid mapping method" do
39
+ skip unless signal_info
40
+
41
+ expected = <<-CODE.reset_indentation
42
+ def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
43
+ _instance, i, _ = param_values.map(&:get_value_plain)
44
+ _v1 = _instance
45
+ _v2 = i
46
+ _v3 = wrap(closure.to_ptr).invoke_block(_v1, _v2)
47
+ return_value.set_value _v3
48
+ end
49
+ CODE
50
+
51
+ builder.marshaller_definition.must_equal expected
52
+ end
53
+ end
54
+
55
+ describe "for a signal with an enum argument" do
56
+ let(:signal_info) {
57
+ get_signal_introspection_data "Gio", "MountOperation", "reply" }
58
+
59
+ it "returns a valid mapping method" do
60
+ expected = <<-CODE.reset_indentation
61
+ def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
62
+ _instance, result, _ = param_values.map(&:get_value_plain)
63
+ _v1 = _instance
64
+ _v2 = result
65
+ wrap(closure.to_ptr).invoke_block(_v1, _v2)
66
+ end
67
+ CODE
68
+
69
+ builder.marshaller_definition.must_equal expected
70
+ end
71
+ end
72
+
73
+ describe "for a signal with a array plus length arguments" do
74
+ let(:signal_info) {
75
+ get_signal_introspection_data "Regress", "TestObj", "sig-with-array-len-prop" }
76
+
77
+ it "returns a valid mapping method" do
78
+ skip unless signal_info
79
+
80
+ expected = <<-CODE.reset_indentation
81
+ def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
82
+ _instance, arr, len, _ = param_values.map(&:get_value_plain)
83
+ _v1 = _instance
84
+ _v2 = len
85
+ _v3 = GirFFI::SizedArray.wrap(:guint32, _v2, arr)
86
+ wrap(closure.to_ptr).invoke_block(_v1, _v3)
87
+ end
88
+ CODE
89
+
90
+ builder.marshaller_definition.must_equal expected
91
+ end
92
+ end
93
+
94
+ describe "for a signal with a struct argument" do
95
+ let(:signal_info) {
96
+ get_signal_introspection_data "Regress", "TestObj", "test-with-static-scope-arg" }
97
+
98
+ it "returns a valid mapping method" do
99
+ skip unless signal_info
100
+
101
+ expected = <<-CODE.reset_indentation
102
+ def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
103
+ _instance, object, _ = param_values.map(&:get_value_plain)
104
+ _v1 = _instance
105
+ _v2 = Regress::TestSimpleBoxedA.wrap(object)
106
+ wrap(closure.to_ptr).invoke_block(_v1, _v2)
107
+ end
108
+ CODE
109
+
110
+ builder.marshaller_definition.must_equal expected
111
+ end
112
+ end
113
+
114
+ describe "for a signal returning an array of integers" do
115
+ let(:signal_info) {
116
+ get_signal_introspection_data "Regress", "TestObj", "sig-with-intarray-ret" }
117
+
118
+ it "returns a valid mapping method" do
119
+ skip unless signal_info
120
+
121
+ expected = <<-CODE.reset_indentation
122
+ def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
123
+ _instance, i, _ = param_values.map(&:get_value_plain)
124
+ _v1 = _instance
125
+ _v2 = i
126
+ _v3 = wrap(closure.to_ptr).invoke_block(_v1, _v2)
127
+ _v4 = GLib::Array.from(:gint32, _v3)
128
+ return_value.set_value _v4
129
+ end
130
+ CODE
131
+
132
+ builder.marshaller_definition.must_equal expected
133
+ end
134
+ end
135
+ end
136
+ end
@@ -100,7 +100,8 @@ describe GirFFI::Builders::UserDefinedBuilder do
100
100
  gtype = klass.get_gtype
101
101
  other_builder = GirFFI::Builders::UserDefinedBuilder.new info
102
102
  other_builder.build_class
103
- other_builder.gtype.must_equal gtype
103
+ # FIXME: Does not really test what we want to test: other_builder might lie!
104
+ other_builder.target_gtype.must_equal gtype
104
105
  end
105
106
  end
106
107
  end
@@ -25,15 +25,4 @@ describe GirFFI::InfoExt::ISignalInfo do
25
25
  result_boxed.some_int.must_equal boxed.some_int
26
26
  end
27
27
  end
28
-
29
- describe "#return_ffi_type" do
30
- # NOTE: This is needed because FFI callbacks are limited in the
31
- # accepted types.
32
- it "returns :bool for the :gboolean type" do
33
- stub(return_type_info = Object.new).to_ffitype { GLib::Boolean }
34
- stub(signal_info).return_type { return_type_info }
35
-
36
- signal_info.return_ffi_type.must_equal :bool
37
- end
38
- end
39
28
  end
@@ -437,6 +437,7 @@ describe GIMarshallingTests do
437
437
  derived_instance.int.must_equal 23
438
438
  end
439
439
 
440
+ # TODO: Check if this is fixed
440
441
  # See https://bugzilla.gnome.org/show_bug.cgi?id=727665
441
442
  it "has a working method #int8_out" do
442
443
  skip "Introspection data is not generated correctly"
@@ -1039,7 +1040,7 @@ describe GIMarshallingTests do
1039
1040
  end
1040
1041
  end
1041
1042
 
1042
- describe "its 'some-uuint' property" do
1043
+ describe "its 'some-uint' property" do
1043
1044
  it "can be retrieved with #get_property" do
1044
1045
  instance.get_property("some-uint").get_value.must_equal 0
1045
1046
  end
@@ -1355,6 +1356,18 @@ describe GIMarshallingTests do
1355
1356
  pass
1356
1357
  end
1357
1358
 
1359
+ it "has a working function #array_in_utf8_two_in" do
1360
+ skip unless get_introspection_data 'GIMarshallingTests', 'array_in_utf8_two_in'
1361
+ GIMarshallingTests.array_in_utf8_two_in [-1, 0, 1, 2], "1", "2"
1362
+ pass
1363
+ end
1364
+
1365
+ it "has a working function #array_in_utf8_two_in_out_of_order" do
1366
+ skip unless get_introspection_data 'GIMarshallingTests', 'array_in_utf8_two_in_out_of_order'
1367
+ GIMarshallingTests.array_in_utf8_two_in_out_of_order "1", [-1, 0, 1, 2], "2"
1368
+ pass
1369
+ end
1370
+
1358
1371
  it "has a working function #array_inout" do
1359
1372
  res = GIMarshallingTests.array_inout [-1, 0, 1, 2]
1360
1373
  res.must_be :==, [-2, -1, 0, 1, 2]
@@ -1545,6 +1558,21 @@ describe GIMarshallingTests do
1545
1558
  result.must_equal 42.0
1546
1559
  end
1547
1560
 
1561
+ it "has a working function #callback_owned_boxed" do
1562
+ skip unless get_introspection_data 'GIMarshallingTests', 'callback_owned_boxed'
1563
+ a = nil
1564
+
1565
+ callback = proc { |box, callback_data| a = box.long_ + callback_data }
1566
+
1567
+ result = GIMarshallingTests.callback_owned_boxed callback, 42
1568
+ result.must_equal 1
1569
+ a.must_equal 43
1570
+
1571
+ result = GIMarshallingTests.callback_owned_boxed callback, 42
1572
+ result.must_equal 2
1573
+ a.must_equal 44
1574
+ end
1575
+
1548
1576
  it "has a working function #callback_return_value_and_multiple_out_parameters" do
1549
1577
  result = GIMarshallingTests.callback_return_value_and_multiple_out_parameters proc { |*args|
1550
1578
  [42, -142, 3]
@@ -1756,6 +1784,7 @@ describe GIMarshallingTests do
1756
1784
  it "has a working function #gclosure_in" do
1757
1785
  cl = GObject::RubyClosure.new { 42 }
1758
1786
  GIMarshallingTests.gclosure_in cl
1787
+ pass
1759
1788
  end
1760
1789
 
1761
1790
  it "has a working function #gclosure_return" do
@@ -2143,7 +2172,6 @@ describe GIMarshallingTests do
2143
2172
  end
2144
2173
 
2145
2174
  it "has a working function #gvalue_flat_array_round_trip" do
2146
- skip "Fails on JRuby" if RUBY_PLATFORM == 'java'
2147
2175
  result = GIMarshallingTests.gvalue_flat_array_round_trip 42, "42", true
2148
2176
  arr = result.to_a
2149
2177
  arr[0].get_value.must_equal 42
@@ -2403,6 +2431,14 @@ describe GIMarshallingTests do
2403
2431
  assert_equal 0x7fffffff, res
2404
2432
  end
2405
2433
 
2434
+ it "has a working function #int_one_in_utf8_two_in_one_allows_none" do
2435
+ skip unless get_introspection_data('GIMarshallingTests',
2436
+ 'int_one_in_utf8_two_in_one_allows_none')
2437
+ GIMarshallingTests.int_one_in_utf8_two_in_one_allows_none 1, "2", "3"
2438
+ GIMarshallingTests.int_one_in_utf8_two_in_one_allows_none 1, nil, "3"
2439
+ pass
2440
+ end
2441
+
2406
2442
  it "has a working function #int_out_max" do
2407
2443
  res = GIMarshallingTests.int_out_max
2408
2444
  assert_equal 0x7fffffff, res
@@ -2438,6 +2474,14 @@ describe GIMarshallingTests do
2438
2474
  assert_equal [4, 5, 6], res
2439
2475
  end
2440
2476
 
2477
+ it "has a working function #int_two_in_utf8_two_in_with_allow_none" do
2478
+ skip unless get_introspection_data('GIMarshallingTests',
2479
+ 'int_two_in_utf8_two_in_with_allow_none')
2480
+ GIMarshallingTests.int_two_in_utf8_two_in_with_allow_none 1, 2, "3", "4"
2481
+ GIMarshallingTests.int_two_in_utf8_two_in_with_allow_none 1, 2, nil, nil
2482
+ pass
2483
+ end
2484
+
2441
2485
  it "has a working function #long_in_max" do
2442
2486
  GIMarshallingTests.long_in_max max_long
2443
2487
  pass
@@ -2514,6 +2558,7 @@ describe GIMarshallingTests do
2514
2558
  res.must_be_instance_of GIMarshallingTests::OverridesStruct
2515
2559
  end
2516
2560
 
2561
+ # TODO: Wait for fixed version of param_spec_in_bool to land in Debian/Ubuntu
2517
2562
  # See https://bugzilla.gnome.org/show_bug.cgi?id=728409
2518
2563
  it "has a working function #param_spec_in_bool" do
2519
2564
  skip "param_spec_in_bool tests the wrong type"
@@ -520,6 +520,12 @@ describe Regress do
520
520
  o = Regress::TestObj.new_callback Proc.new { a = 2 }, nil, nil
521
521
  assert_instance_of Regress::TestObj, o
522
522
  a.must_equal 2
523
+
524
+ # Regress::TestObj.new_callback adds a callback to the list of notified
525
+ # callbacks. Thaw the callbacks to make sure the list is cleared for
526
+ # later tests.
527
+ result = Regress.test_callback_thaw_notifications
528
+ result.must_equal 2
523
529
  end
524
530
 
525
531
  it "creates an instance using #new_from_file" do
@@ -582,7 +588,7 @@ describe Regress do
582
588
  end
583
589
 
584
590
  it "has a working method #emit_sig_with_int64" do
585
- skip "FFI doesn't seem to convert the returned :int64 properly yet"
591
+ skip unless get_signal_introspection_data "Regress", "TestObj", "sig-with-int64-prop"
586
592
  instance.signal_connect "sig-with-int64-prop" do |obj, i, ud|
587
593
  i
588
594
  end
@@ -600,7 +606,7 @@ describe Regress do
600
606
  end
601
607
 
602
608
  it "has a working method #emit_sig_with_uint64" do
603
- skip "FFI doesn't seem to convert the returned :int64 properly yet"
609
+ skip unless get_signal_introspection_data "Regress", "TestObj", "sig-with-uint64-prop"
604
610
  instance.signal_connect "sig-with-uint64-prop" do |obj, i, ud|
605
611
  i
606
612
  end
@@ -1024,9 +1030,10 @@ describe Regress do
1024
1030
  a = int64
1025
1031
  end
1026
1032
 
1027
- GObject.signal_emit instance, "sig-with-int64-prop", 0x7fffffffffffffff
1033
+ result = GObject.signal_emit instance, "sig-with-int64-prop", 0x7fff_ffff_ffff_ffff
1028
1034
 
1029
- a.must_equal 0x7fffffffffffffff
1035
+ a.must_equal 0x7fff_ffff_ffff_ffff
1036
+ result.get_value.must_equal 0x7fff_ffff_ffff_ffff
1030
1037
  end
1031
1038
 
1032
1039
  it "handles the 'sig-with-intarray-ret' signal" do
@@ -1043,9 +1050,8 @@ describe Regress do
1043
1050
 
1044
1051
  a.must_equal 3
1045
1052
 
1046
- # We would expect result to contain the int array, but regress.c uses the
1047
- # wrong marshalling function
1048
- result.get_value.must_be_nil
1053
+ # TODO: Use signal info to convert return value
1054
+ GLib::Array.wrap(:gint32, result.get_value_plain).to_a.must_equal [3, 2, 1]
1049
1055
  end
1050
1056
 
1051
1057
  it "handles the 'sig-with-obj' signal" do
@@ -1082,9 +1088,10 @@ describe Regress do
1082
1088
  a = uint64
1083
1089
  end
1084
1090
 
1085
- GObject.signal_emit instance, "sig-with-uint64-prop", 0xffffffffffffffff
1091
+ result = GObject.signal_emit instance, "sig-with-uint64-prop", 0xffff_ffff_ffff_ffff
1086
1092
 
1087
- a.must_equal 0xffffffffffffffff
1093
+ a.must_equal 0xffff_ffff_ffff_ffff
1094
+ result.get_value.must_equal 0xffff_ffff_ffff_ffff
1088
1095
  end
1089
1096
 
1090
1097
  it "handles the 'test' signal" do
@@ -1508,6 +1515,7 @@ describe Regress do
1508
1515
  instance.data1.read_int.must_equal 42
1509
1516
  end
1510
1517
 
1518
+ # TODO: Check what gobject-introspection should/will do with these fields.
1511
1519
  it "has a writable field data2" do
1512
1520
  skip "Introspection data cannot deal with type of this field yet"
1513
1521
  end
@@ -1950,8 +1958,9 @@ describe Regress do
1950
1958
  end
1951
1959
 
1952
1960
  it "has a working function #test_closure_variant" do
1953
- skip "This causes a core dump on some systems"
1954
1961
  arg = GLib::Variant.new_string "foo"
1962
+
1963
+ # TODO: Convert proc to RubyClosure automatically
1955
1964
  closure = GObject::RubyClosure.new do |variant|
1956
1965
  str = variant.get_string
1957
1966
  if str == "foo"
@@ -1961,7 +1970,6 @@ describe Regress do
1961
1970
  end
1962
1971
  end
1963
1972
 
1964
- # TODO: Convert proc to RubyClosure automatically
1965
1973
  result = Regress.test_closure_variant closure, arg
1966
1974
 
1967
1975
  result.get_int32.must_equal 40