gir_ffi 0.7.8 → 0.7.9

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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +16 -0
  3. data/README.md +24 -11
  4. data/TODO.md +10 -2
  5. data/gir_ffi.gemspec +2 -2
  6. data/lib/ffi-glib/array.rb +1 -1
  7. data/lib/ffi-glib/hash_table.rb +0 -4
  8. data/lib/ffi-gobject.rb +10 -6
  9. data/lib/ffi-gobject/object.rb +17 -0
  10. data/lib/ffi-gobject/ruby_closure.rb +1 -1
  11. data/lib/ffi-gobject/value.rb +28 -4
  12. data/lib/ffi-gobject_introspection.rb +4 -0
  13. data/lib/ffi-gobject_introspection/g_error.rb +2 -2
  14. data/lib/ffi-gobject_introspection/i_base_info.rb +1 -3
  15. data/lib/ffi-gobject_introspection/i_callable_info.rb +8 -0
  16. data/lib/ffi-gobject_introspection/i_registered_type_info.rb +2 -0
  17. data/lib/ffi-gobject_introspection/i_repository.rb +4 -4
  18. data/lib/ffi-gobject_introspection/lib.rb +57 -32
  19. data/lib/gir_ffi.rb +1 -1
  20. data/lib/gir_ffi/boxed_base.rb +40 -0
  21. data/lib/gir_ffi/builders/argument_builder.rb +11 -3
  22. data/lib/gir_ffi/builders/base_argument_builder.rb +4 -0
  23. data/lib/gir_ffi/builders/boxed_builder.rb +29 -0
  24. data/lib/gir_ffi/builders/callback_builder.rb +3 -1
  25. data/lib/gir_ffi/builders/callback_return_value_builder.rb +9 -1
  26. data/lib/gir_ffi/builders/field_builder.rb +68 -18
  27. data/lib/gir_ffi/builders/function_builder.rb +12 -2
  28. data/lib/gir_ffi/builders/mapping_method_builder.rb +7 -5
  29. data/lib/gir_ffi/builders/marshalling_method_builder.rb +1 -1
  30. data/lib/gir_ffi/builders/module_builder.rb +1 -1
  31. data/lib/gir_ffi/builders/registered_type_builder.rb +0 -9
  32. data/lib/gir_ffi/builders/return_value_builder.rb +0 -1
  33. data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -1
  34. data/lib/gir_ffi/builders/struct_builder.rb +4 -16
  35. data/lib/gir_ffi/builders/union_builder.rb +2 -13
  36. data/lib/gir_ffi/builders/user_defined_builder.rb +6 -6
  37. data/lib/gir_ffi/builders/vfunc_argument_builder.rb +44 -0
  38. data/lib/gir_ffi/builders/vfunc_builder.rb +3 -1
  39. data/lib/gir_ffi/callback_base.rb +5 -2
  40. data/lib/gir_ffi/class_base.rb +6 -7
  41. data/lib/gir_ffi/enum_base.rb +5 -0
  42. data/lib/gir_ffi/ffi_ext/pointer.rb +1 -0
  43. data/lib/gir_ffi/field_argument_info.rb +4 -0
  44. data/lib/gir_ffi/in_out_pointer.rb +1 -1
  45. data/lib/gir_ffi/in_pointer.rb +2 -2
  46. data/lib/gir_ffi/info_ext/i_arg_info.rb +12 -2
  47. data/lib/gir_ffi/info_ext/i_callable_info.rb +1 -1
  48. data/lib/gir_ffi/info_ext/i_callback_info.rb +7 -2
  49. data/lib/gir_ffi/info_ext/i_field_info.rb +1 -1
  50. data/lib/gir_ffi/info_ext/i_function_info.rb +1 -1
  51. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +7 -2
  52. data/lib/gir_ffi/info_ext/i_type_info.rb +21 -9
  53. data/lib/gir_ffi/info_ext/i_unresolved_info.rb +5 -0
  54. data/lib/gir_ffi/interface_base.rb +5 -0
  55. data/lib/gir_ffi/object_base.rb +5 -0
  56. data/lib/gir_ffi/receiver_argument_info.rb +5 -0
  57. data/lib/gir_ffi/registered_type_base.rb +5 -0
  58. data/lib/gir_ffi/return_value_info.rb +3 -1
  59. data/lib/gir_ffi/sized_array.rb +1 -1
  60. data/lib/gir_ffi/struct_base.rb +2 -24
  61. data/lib/gir_ffi/type_map.rb +5 -1
  62. data/lib/gir_ffi/union_base.rb +2 -2
  63. data/lib/gir_ffi/version.rb +1 -1
  64. data/lib/gir_ffi/zero_terminated.rb +1 -1
  65. data/test/base_test_helper.rb +6 -6
  66. data/test/ffi-glib/hash_table_test.rb +7 -7
  67. data/test/ffi-glib/iconv_test.rb +2 -3
  68. data/test/ffi-glib/main_loop_test.rb +2 -2
  69. data/test/ffi-gobject/gobject_test.rb +1 -1
  70. data/test/ffi-gobject/object_test.rb +5 -14
  71. data/test/ffi-gobject/value_test.rb +30 -6
  72. data/test/ffi-gobject_introspection/i_base_info_test.rb +6 -6
  73. data/test/ffi-gobject_introspection/i_repository_test.rb +2 -4
  74. data/test/gir_ffi/arg_helper_test.rb +1 -1
  75. data/test/gir_ffi/builder_test.rb +18 -12
  76. data/test/gir_ffi/builders/argument_builder_test.rb +2 -5
  77. data/test/gir_ffi/builders/callback_builder_test.rb +1 -1
  78. data/test/gir_ffi/builders/callback_return_value_builder_test.rb +11 -10
  79. data/test/gir_ffi/builders/field_builder_test.rb +0 -2
  80. data/test/gir_ffi/builders/function_builder_test.rb +156 -147
  81. data/test/gir_ffi/builders/interface_builder_test.rb +1 -1
  82. data/test/gir_ffi/builders/module_builder_test.rb +2 -2
  83. data/test/gir_ffi/builders/object_builder_test.rb +2 -2
  84. data/test/gir_ffi/builders/property_builder_test.rb +5 -5
  85. data/test/gir_ffi/builders/return_value_builder_test.rb +30 -30
  86. data/test/gir_ffi/builders/struct_builder_test.rb +14 -14
  87. data/test/gir_ffi/builders/user_defined_builder_test.rb +21 -22
  88. data/test/gir_ffi/builders/vfunc_builder_test.rb +57 -0
  89. data/test/gir_ffi/class_base_test.rb +8 -8
  90. data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -4
  91. data/test/gir_ffi/g_type_test.rb +1 -1
  92. data/test/gir_ffi/in_pointer_test.rb +2 -2
  93. data/test/gir_ffi/info_ext/i_callable_info_test.rb +3 -3
  94. data/test/gir_ffi/info_ext/i_callback_info_test.rb +2 -2
  95. data/test/gir_ffi/info_ext/i_field_info_test.rb +8 -8
  96. data/test/gir_ffi/info_ext/i_function_info_test.rb +13 -13
  97. data/test/gir_ffi/info_ext/i_type_info_test.rb +131 -132
  98. data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +2 -2
  99. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +2 -2
  100. data/test/gir_ffi/info_ext/safe_function_name_test.rb +2 -2
  101. data/test/gir_ffi/interface_base_test.rb +3 -3
  102. data/test/gir_ffi/object_base_test.rb +3 -3
  103. data/test/gir_ffi/sized_array_test.rb +2 -2
  104. data/test/gir_ffi/type_map_test.rb +3 -3
  105. data/test/gir_ffi/unintrospectable_type_info_test.rb +14 -14
  106. data/test/gir_ffi/user_defined_property_info_test.rb +1 -1
  107. data/test/gir_ffi/user_defined_type_info_test.rb +25 -12
  108. data/test/gir_ffi/zero_terminated_test.rb +0 -1
  109. data/test/gir_ffi_test.rb +3 -3
  110. data/test/gir_ffi_test_helper.rb +4 -0
  111. data/test/integration/generated_gimarshallingtests_test.rb +31 -25
  112. data/test/integration/generated_gio_test.rb +1 -1
  113. data/test/integration/generated_gobject_test.rb +1 -1
  114. data/test/integration/generated_regress_test.rb +18 -22
  115. metadata +11 -8
@@ -9,9 +9,9 @@ describe GirFFI::InfoExt::IUnresolvedInfo do
9
9
 
10
10
  let(:unresolved_info) { klass.new }
11
11
 
12
- describe '#to_ffitype' do
12
+ describe '#to_ffi_type' do
13
13
  it 'returns the most generic type' do
14
- unresolved_info.to_ffitype.must_equal :pointer
14
+ unresolved_info.to_ffi_type.must_equal :pointer
15
15
  end
16
16
  end
17
17
  end
@@ -10,13 +10,13 @@ describe GirFFI::InfoExt::SafeConstantName do
10
10
 
11
11
  describe '#safe_name' do
12
12
  it 'makes names starting with an underscore safe' do
13
- mock(info).name { '_foo' }
13
+ expect(info).to receive(:name).and_return '_foo'
14
14
 
15
15
  assert_equal 'Private___foo', info.safe_name
16
16
  end
17
17
 
18
18
  it 'makes names with dashes safe' do
19
- mock(info).name { 'this-could-be-a-signal-name' }
19
+ expect(info).to receive(:name).and_return 'this-could-be-a-signal-name'
20
20
 
21
21
  info.safe_name.must_equal 'This_could_be_a_signal_name'
22
22
  end
@@ -10,13 +10,13 @@ describe GirFFI::InfoExt::SafeFunctionName do
10
10
 
11
11
  describe '#safe_name' do
12
12
  it 'keeps lower case names lower case' do
13
- mock(info).name { 'foo' }
13
+ expect(info).to receive(:name).and_return 'foo'
14
14
 
15
15
  assert_equal 'foo', info.safe_name
16
16
  end
17
17
 
18
18
  it 'returns a non-empty string if name is empty' do
19
- mock(info).name { '' }
19
+ expect(info).to receive(:name).and_return ''
20
20
 
21
21
  assert_equal '_', info.safe_name
22
22
  end
@@ -5,14 +5,14 @@ describe GirFFI::InterfaceBase do
5
5
 
6
6
  describe '#wrap' do
7
7
  it 'delegates conversion to the wrapped pointer' do
8
- mock(ptr = Object.new).to_object { 'good-result' }
8
+ expect(ptr = Object.new).to receive(:to_object).and_return 'good-result'
9
9
  interface.wrap(ptr).must_equal 'good-result'
10
10
  end
11
11
  end
12
12
 
13
- describe '.to_ffitype' do
13
+ describe '.to_ffi_type' do
14
14
  it 'returns :pointer' do
15
- interface.to_ffitype.must_equal :pointer
15
+ interface.to_ffi_type.must_equal :pointer
16
16
  end
17
17
  end
18
18
  end
@@ -5,14 +5,14 @@ describe GirFFI::ObjectBase do
5
5
 
6
6
  describe '.wrap' do
7
7
  it 'delegates conversion to the wrapped pointer' do
8
- mock(ptr = Object.new).to_object { 'good-result' }
8
+ expect(ptr = Object.new).to receive(:to_object).and_return 'good-result'
9
9
  derived_class.wrap(ptr).must_equal 'good-result'
10
10
  end
11
11
  end
12
12
 
13
- describe '.to_ffitype' do
13
+ describe '.to_ffi_type' do
14
14
  it 'returns :pointer' do
15
- derived_class.to_ffitype.must_equal :pointer
15
+ derived_class.to_ffi_type.must_equal :pointer
16
16
  end
17
17
  end
18
18
  end
@@ -3,7 +3,7 @@ require 'gir_ffi_test_helper'
3
3
  describe GirFFI::SizedArray do
4
4
  describe '::wrap' do
5
5
  it 'takes a type, size and pointer and returns a GirFFI::SizedArray wrapping them' do
6
- mock(ptr = Object.new).null? { false }
6
+ expect(ptr = Object.new).to receive(:null?).and_return false
7
7
  sarr = GirFFI::SizedArray.wrap :gint32, 3, ptr
8
8
  assert_instance_of GirFFI::SizedArray, sarr
9
9
  assert_equal ptr, sarr.to_ptr
@@ -12,7 +12,7 @@ describe GirFFI::SizedArray do
12
12
  end
13
13
 
14
14
  it 'returns nil if the wrapped pointer is null' do
15
- mock(ptr = Object.new).null? { true }
15
+ expect(ptr = Object.new).to receive(:null?).and_return true
16
16
  sarr = GirFFI::SizedArray.wrap :gint32, 3, ptr
17
17
  sarr.must_be_nil
18
18
  end
@@ -1,14 +1,14 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::TypeMap do
4
- describe '.type_specification_to_ffitype' do
4
+ describe '.type_specification_to_ffi_type' do
5
5
  it 'returns the nested FFI::Enum for an Enum module' do
6
- GirFFI::TypeMap.type_specification_to_ffitype(GLib::DateMonth).
6
+ GirFFI::TypeMap.type_specification_to_ffi_type(GLib::DateMonth).
7
7
  must_equal GLib::DateMonth
8
8
  end
9
9
 
10
10
  it 'returns the class itself for a Struct class' do
11
- GirFFI::TypeMap.type_specification_to_ffitype(GObject::EnumValue).
11
+ GirFFI::TypeMap.type_specification_to_ffi_type(GObject::EnumValue).
12
12
  must_equal GObject::EnumValue
13
13
  end
14
14
  end
@@ -15,8 +15,8 @@ describe GirFFI::UnintrospectableTypeInfo do
15
15
  gobject = Object.new
16
16
  gir = Object.new
17
17
 
18
- mock(gobject).type_parent(:some_type) { :foo }
19
- mock(gir).find_by_gtype(:foo) { :foo_info }
18
+ expect(gobject).to receive(:type_parent).with(:some_type).and_return :foo
19
+ expect(gir).to receive(:find_by_gtype).with(:foo).and_return :foo_info
20
20
 
21
21
  info = GirFFI::UnintrospectableTypeInfo.new(:some_type, gir, gobject)
22
22
 
@@ -29,8 +29,8 @@ describe GirFFI::UnintrospectableTypeInfo do
29
29
  gobject = Object.new
30
30
  gir = Object.new
31
31
 
32
- mock(gobject).type_parent(:some_type) { :foo }
33
- mock(gir).find_by_gtype(:foo) { nil }
32
+ expect(gobject).to receive(:type_parent).with(:some_type).and_return :foo
33
+ expect(gir).to receive(:find_by_gtype).with(:foo).and_return nil
34
34
 
35
35
  info = GirFFI::UnintrospectableTypeInfo.new(:some_type, gir, gobject)
36
36
 
@@ -44,9 +44,9 @@ describe GirFFI::UnintrospectableTypeInfo do
44
44
  gobject = Object.new
45
45
  gir = Object.new
46
46
 
47
- mock(gobject).type_interfaces(:some_type) { [:foo, :bar] }
48
- mock(gir).find_by_gtype(:foo) { :foo_info }
49
- mock(gir).find_by_gtype(:bar) { :bar_info }
47
+ expect(gobject).to receive(:type_interfaces).with(:some_type).and_return [:foo, :bar]
48
+ expect(gir).to receive(:find_by_gtype).with(:foo).and_return :foo_info
49
+ expect(gir).to receive(:find_by_gtype).with(:bar).and_return :bar_info
50
50
 
51
51
  info = GirFFI::UnintrospectableTypeInfo.new(:some_type, gir, gobject)
52
52
 
@@ -57,9 +57,9 @@ describe GirFFI::UnintrospectableTypeInfo do
57
57
  gobject = Object.new
58
58
  gir = Object.new
59
59
 
60
- mock(gobject).type_interfaces(:some_type) { [:foo, :bar] }
61
- mock(gir).find_by_gtype(:foo) { :foo_info }
62
- mock(gir).find_by_gtype(:bar) { nil }
60
+ expect(gobject).to receive(:type_interfaces).with(:some_type).and_return [:foo, :bar]
61
+ expect(gir).to receive(:find_by_gtype).with(:foo).and_return :foo_info
62
+ expect(gir).to receive(:find_by_gtype).with(:bar).and_return nil
63
63
 
64
64
  info = GirFFI::UnintrospectableTypeInfo.new(:some_type, gir, gobject)
65
65
 
@@ -87,9 +87,9 @@ describe GirFFI::UnintrospectableTypeInfo do
87
87
  gir = Object.new
88
88
  parent_info = Object.new
89
89
 
90
- mock(gobject).type_parent(:some_type) { :foo }
91
- mock(gir).find_by_gtype(:foo) { parent_info }
92
- mock(parent_info).namespace { 'FooNamespace' }
90
+ expect(gobject).to receive(:type_parent).with(:some_type).and_return :foo
91
+ expect(gir).to receive(:find_by_gtype).with(:foo).and_return parent_info
92
+ expect(parent_info).to receive(:namespace).and_return 'FooNamespace'
93
93
 
94
94
  info = GirFFI::UnintrospectableTypeInfo.new(:some_type, gir, gobject)
95
95
 
@@ -101,7 +101,7 @@ describe GirFFI::UnintrospectableTypeInfo do
101
101
  it 'finds the class name by gtype' do
102
102
  gobject = Object.new
103
103
 
104
- mock(gobject).type_name(:some_type) { 'GSomeType' }
104
+ expect(gobject).to receive(:type_name).with(:some_type).and_return 'GSomeType'
105
105
 
106
106
  info = GirFFI::UnintrospectableTypeInfo.new(:some_type, nil, gobject)
107
107
 
@@ -11,7 +11,7 @@ describe GirFFI::UserDefinedPropertyInfo do
11
11
 
12
12
  describe '#name' do
13
13
  it 'returns the name retrieved from the parameter specification' do
14
- mock(param_spec = Object.new).get_name { :property_name }
14
+ expect(param_spec = Object.new).to receive(:get_name).and_return :property_name
15
15
  info = GirFFI::UserDefinedPropertyInfo.new param_spec
16
16
  info.name.must_equal :property_name
17
17
  end
@@ -3,17 +3,20 @@ require 'gir_ffi/user_defined_type_info'
3
3
 
4
4
  describe GirFFI::UserDefinedTypeInfo do
5
5
  describe '#described_class' do
6
+ let(:info) { GirFFI::UserDefinedTypeInfo.new :some_class }
7
+
6
8
  it 'returns the class passed to #initialize' do
7
- info = GirFFI::UserDefinedTypeInfo.new :some_class
8
9
  info.described_class.must_equal :some_class
9
10
  end
10
11
  end
11
12
 
12
13
  describe '#install_property' do
14
+ let(:info) { GirFFI::UserDefinedTypeInfo.new :some_class }
15
+ let(:foo_spec) { Object.new }
16
+
13
17
  it 'adds the passed in property to the list of properties' do
14
- mock(foo_spec = Object.new).get_name { :foo }
18
+ expect(foo_spec).to receive(:get_name).and_return :foo
15
19
 
16
- info = GirFFI::UserDefinedTypeInfo.new :some_class
17
20
  info.install_property foo_spec
18
21
  info.properties.map(&:name).must_equal [:foo]
19
22
  end
@@ -37,28 +40,38 @@ describe GirFFI::UserDefinedTypeInfo do
37
40
  end
38
41
 
39
42
  describe '#initialize' do
40
- it 'yields the new object to the block passed' do
41
- mock(foo_spec = Object.new).get_name { :foo }
42
- mock(bar_spec = Object.new).get_name { :bar }
43
-
44
- info = GirFFI::UserDefinedTypeInfo.new :some_class do |inf|
43
+ let(:foo_spec) { Object.new }
44
+ let(:bar_spec) { Object.new }
45
+ let(:info) {
46
+ GirFFI::UserDefinedTypeInfo.new :some_class do |inf|
45
47
  inf.install_property foo_spec
46
48
  inf.install_property bar_spec
47
49
  end
50
+ }
51
+
52
+ before do
53
+ expect(foo_spec).to receive(:get_name).and_return :foo
54
+ expect(bar_spec).to receive(:get_name).and_return :bar
55
+ end
56
+
57
+ it 'yields the new object to the block passed' do
48
58
  info.properties.map(&:name).must_equal [:foo, :bar]
49
59
  end
50
60
  end
51
61
 
52
62
  describe '#g_name' do
63
+ let(:klass) { Object.new }
64
+ let(:info) { GirFFI::UserDefinedTypeInfo.new klass }
65
+
66
+ before do
67
+ allow(klass).to receive(:name).and_return 'foo'
68
+ end
69
+
53
70
  it "returns the described class' name by default" do
54
- mock(klass = Object.new).name { 'foo' }
55
- info = GirFFI::UserDefinedTypeInfo.new klass
56
71
  info.g_name.must_equal 'foo'
57
72
  end
58
73
 
59
74
  it 'returns the the name set by #g_name= if present' do
60
- stub(klass = Object.new).name { 'foo' }
61
- info = GirFFI::UserDefinedTypeInfo.new klass
62
75
  info.g_name = 'bar'
63
76
  info.g_name.must_equal 'bar'
64
77
  end
@@ -48,7 +48,6 @@ describe GirFFI::ZeroTerminated do
48
48
  end
49
49
  arr.must_equal [1, 2, 3]
50
50
  end
51
-
52
51
  end
53
52
 
54
53
  describe '#==' do
@@ -33,13 +33,13 @@ describe GirFFI do
33
33
  end
34
34
 
35
35
  it 'returns a GType for the derived class' do
36
- parent_gtype = GIMarshallingTests::OverridesObject.get_gtype
36
+ parent_gtype = GIMarshallingTests::OverridesObject.gtype
37
37
  @gtype.wont_equal parent_gtype
38
38
  GObject.type_name(@gtype).must_equal @klass.name
39
39
  end
40
40
 
41
- it 'makes #get_gtype on the registered class return the new GType' do
42
- @klass.get_gtype.must_equal @gtype
41
+ it 'makes #gtype on the registered class return the new GType' do
42
+ @klass.gtype.must_equal @gtype
43
43
  end
44
44
 
45
45
  it 'registers a type with the same size as the parent' do
@@ -53,6 +53,10 @@ module GirFFITestExtensions
53
53
  GObject::Object::Struct.new(object.to_ptr)[:ref_count]
54
54
  end
55
55
 
56
+ def ref object
57
+ object.ref
58
+ end
59
+
56
60
  def max_for_unsigned_type type
57
61
  (1 << (FFI.type_size(type) * 8)) - 1
58
62
  end
@@ -9,7 +9,7 @@ GirFFI.setup :GIMarshallingTests
9
9
  describe GIMarshallingTests do
10
10
  let(:derived_klass) {
11
11
  Object.const_set("DerivedClass#{Sequence.next}",
12
- Class.new(GIMarshallingTests::Object))
12
+ Class.new(GIMarshallingTests::Object))
13
13
  }
14
14
 
15
15
  def make_derived_instance
@@ -87,12 +87,12 @@ describe GIMarshallingTests do
87
87
 
88
88
  it 'has the constant CONSTANT_GERROR_DOMAIN' do
89
89
  assert_equal 'gi-marshalling-tests-gerror-domain',
90
- GIMarshallingTests::CONSTANT_GERROR_DOMAIN
90
+ GIMarshallingTests::CONSTANT_GERROR_DOMAIN
91
91
  end
92
92
 
93
93
  it 'has the constant CONSTANT_GERROR_MESSAGE' do
94
94
  assert_equal 'gi-marshalling-tests-gerror-message',
95
- GIMarshallingTests::CONSTANT_GERROR_MESSAGE
95
+ GIMarshallingTests::CONSTANT_GERROR_MESSAGE
96
96
  end
97
97
 
98
98
  it 'has the constant CONSTANT_NUMBER' do
@@ -198,11 +198,11 @@ describe GIMarshallingTests do
198
198
  describe 'GIMarshallingTests::Interface' do
199
199
  it 'has a working method #test_int8_in' do
200
200
  derived_klass.class_eval { include GIMarshallingTests::Interface }
201
- instance = make_derived_instance do |info|
201
+ derived_instance = make_derived_instance do |info|
202
202
  info.install_vfunc_implementation :test_int8_in, proc { |obj, in_| obj.int = in_ }
203
203
  end
204
- instance.test_int8_in 8
205
- instance.int.must_equal 8
204
+ derived_instance.test_int8_in 8
205
+ derived_instance.int.must_equal 8
206
206
  end
207
207
  end
208
208
 
@@ -216,13 +216,13 @@ describe GIMarshallingTests do
216
216
  it 'has a working method #test_variant_array_in' do
217
217
  skip unless get_introspection_data 'GIMarshallingTests', 'Interface3'
218
218
  derived_klass.class_eval { include GIMarshallingTests::Interface3 }
219
- instance = make_derived_instance do |info|
219
+ derived_instance = make_derived_instance do |info|
220
220
  info.install_vfunc_implementation :test_variant_array_in, proc {|obj, in_|
221
221
  obj.int = in_.to_a.first.get_byte
222
222
  }
223
223
  end
224
- instance.test_variant_array_in [GLib::Variant.new_byte(42)]
225
- instance.int.must_equal 42
224
+ derived_instance.test_variant_array_in [GLib::Variant.new_byte(42)]
225
+ derived_instance.int.must_equal 42
226
226
  end
227
227
  end
228
228
 
@@ -230,7 +230,7 @@ describe GIMarshallingTests do
230
230
  let(:instance) { GIMarshallingTests::NestedStruct.new }
231
231
  it 'has a writable field simple_struct' do
232
232
  assert_instance_of GIMarshallingTests::SimpleStruct,
233
- instance.simple_struct
233
+ instance.simple_struct
234
234
  new_struct = GIMarshallingTests::SimpleStruct.new
235
235
  new_struct.int8 = 42
236
236
  instance.simple_struct = new_struct
@@ -280,12 +280,14 @@ describe GIMarshallingTests do
280
280
 
281
281
  it 'has a working function #full_inout' do
282
282
  ob = GIMarshallingTests::Object.new 42
283
+ ref_count(ob).must_equal 1
283
284
 
284
285
  res = GIMarshallingTests::Object.full_inout ob
285
286
 
286
- # TODO: Deal with the fact that ob is now invalid
287
+ ref_count(ob).must_be :>, 0
288
+ ref_count(res).must_equal 1
287
289
 
288
- assert_instance_of GIMarshallingTests::Object, res
290
+ res.must_be_instance_of GIMarshallingTests::Object
289
291
  res.int.must_equal 0
290
292
  end
291
293
 
@@ -364,7 +366,7 @@ describe GIMarshallingTests do
364
366
  }
365
367
  end
366
368
  result = derived_instance.
367
- get_ref_info_for_vfunc_in_object_transfer_full GIMarshallingTests::Object.get_gtype
369
+ get_ref_info_for_vfunc_in_object_transfer_full GIMarshallingTests::Object.gtype
368
370
  result.must_equal [1, false]
369
371
  obj.must_be_instance_of GIMarshallingTests::Object
370
372
  end
@@ -372,28 +374,32 @@ describe GIMarshallingTests do
372
374
  it 'has a working method #get_ref_info_for_vfunc_in_object_transfer_none' do
373
375
  skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
374
376
  'vfunc_in_object_transfer_none')
375
- klass = nil
377
+ obj = nil
376
378
  derived_instance = make_derived_instance do |info|
377
379
  info.install_vfunc_implementation :vfunc_in_object_transfer_none, proc {|_this, object|
378
- klass = object.class
380
+ obj = object
379
381
  }
380
382
  end
381
383
  result = derived_instance.
382
- get_ref_info_for_vfunc_in_object_transfer_none GIMarshallingTests::Object.get_gtype
383
- result.must_equal [1, false]
384
- klass.must_equal GIMarshallingTests::Object
384
+ get_ref_info_for_vfunc_in_object_transfer_none GIMarshallingTests::Object.gtype
385
+ ref_count(obj).must_be :>, 0
386
+ result.must_equal [2, false]
387
+ obj.must_be_instance_of GIMarshallingTests::Object
385
388
  end
386
389
 
387
390
  it 'has a working method #get_ref_info_for_vfunc_out_object_transfer_full' do
388
391
  skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
389
392
  'vfunc_out_object_transfer_full')
393
+ obj = nil
390
394
  derived_instance = make_derived_instance do |info|
391
395
  info.install_vfunc_implementation :vfunc_out_object_transfer_full, proc {|_obj|
392
- GIMarshallingTests::Object.new 42
396
+ obj = GIMarshallingTests::Object.new(42)
393
397
  }
394
398
  end
395
399
  result = derived_instance.get_ref_info_for_vfunc_out_object_transfer_full
396
- result.must_equal [1, false]
400
+ ref_count(obj).must_be :>, 0
401
+ # TODO: Check desired result
402
+ result.must_equal [2, false]
397
403
  end
398
404
 
399
405
  it 'has a working method #get_ref_info_for_vfunc_out_object_transfer_none' do
@@ -417,7 +423,7 @@ describe GIMarshallingTests do
417
423
  }
418
424
  end
419
425
  result = derived_instance.get_ref_info_for_vfunc_return_object_transfer_full
420
- result.must_equal [1, false]
426
+ result.must_equal [2, false]
421
427
  end
422
428
 
423
429
  it 'has a working method #get_ref_info_for_vfunc_return_object_transfer_none' do
@@ -1740,7 +1746,7 @@ describe GIMarshallingTests do
1740
1746
 
1741
1747
  it 'has a working function #garray_utf8_full_out_caller_allocated' do
1742
1748
  skip unless get_introspection_data 'GIMarshallingTests',
1743
- 'garray_utf8_full_out_caller_allocated'
1749
+ 'garray_utf8_full_out_caller_allocated'
1744
1750
  res = GIMarshallingTests.garray_utf8_full_out_caller_allocated
1745
1751
  res.must_be :==, %w(0 1 2)
1746
1752
  end
@@ -2190,7 +2196,7 @@ describe GIMarshallingTests do
2190
2196
 
2191
2197
  it 'has a working function #gvalue_in_enum' do
2192
2198
  gv = GObject::Value.new
2193
- gv.init GIMarshallingTests::GEnum.get_gtype
2199
+ gv.init GIMarshallingTests::GEnum.gtype
2194
2200
  gv.set_enum GIMarshallingTests::GEnum[:value3]
2195
2201
  GIMarshallingTests.gvalue_in_enum gv
2196
2202
  pass
@@ -2205,8 +2211,8 @@ describe GIMarshallingTests do
2205
2211
 
2206
2212
  it 'has a working function #gvalue_in_with_type' do
2207
2213
  gv = GObject::Value.new
2208
- gv.init GIMarshallingTests::SubSubObject.get_gtype
2209
- GIMarshallingTests.gvalue_in_with_type gv, GIMarshallingTests::Object.get_gtype
2214
+ gv.init GIMarshallingTests::SubSubObject.gtype
2215
+ GIMarshallingTests.gvalue_in_with_type gv, GIMarshallingTests::Object.gtype
2210
2216
  end
2211
2217
 
2212
2218
  it 'has a working function #gvalue_inout' do