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.
- checksums.yaml +4 -4
- data/Changelog.md +16 -0
- data/README.md +24 -11
- data/TODO.md +10 -2
- data/gir_ffi.gemspec +2 -2
- data/lib/ffi-glib/array.rb +1 -1
- data/lib/ffi-glib/hash_table.rb +0 -4
- data/lib/ffi-gobject.rb +10 -6
- data/lib/ffi-gobject/object.rb +17 -0
- data/lib/ffi-gobject/ruby_closure.rb +1 -1
- data/lib/ffi-gobject/value.rb +28 -4
- data/lib/ffi-gobject_introspection.rb +4 -0
- data/lib/ffi-gobject_introspection/g_error.rb +2 -2
- data/lib/ffi-gobject_introspection/i_base_info.rb +1 -3
- data/lib/ffi-gobject_introspection/i_callable_info.rb +8 -0
- data/lib/ffi-gobject_introspection/i_registered_type_info.rb +2 -0
- data/lib/ffi-gobject_introspection/i_repository.rb +4 -4
- data/lib/ffi-gobject_introspection/lib.rb +57 -32
- data/lib/gir_ffi.rb +1 -1
- data/lib/gir_ffi/boxed_base.rb +40 -0
- data/lib/gir_ffi/builders/argument_builder.rb +11 -3
- data/lib/gir_ffi/builders/base_argument_builder.rb +4 -0
- data/lib/gir_ffi/builders/boxed_builder.rb +29 -0
- data/lib/gir_ffi/builders/callback_builder.rb +3 -1
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +9 -1
- data/lib/gir_ffi/builders/field_builder.rb +68 -18
- data/lib/gir_ffi/builders/function_builder.rb +12 -2
- data/lib/gir_ffi/builders/mapping_method_builder.rb +7 -5
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/module_builder.rb +1 -1
- data/lib/gir_ffi/builders/registered_type_builder.rb +0 -9
- data/lib/gir_ffi/builders/return_value_builder.rb +0 -1
- data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -1
- data/lib/gir_ffi/builders/struct_builder.rb +4 -16
- data/lib/gir_ffi/builders/union_builder.rb +2 -13
- data/lib/gir_ffi/builders/user_defined_builder.rb +6 -6
- data/lib/gir_ffi/builders/vfunc_argument_builder.rb +44 -0
- data/lib/gir_ffi/builders/vfunc_builder.rb +3 -1
- data/lib/gir_ffi/callback_base.rb +5 -2
- data/lib/gir_ffi/class_base.rb +6 -7
- data/lib/gir_ffi/enum_base.rb +5 -0
- data/lib/gir_ffi/ffi_ext/pointer.rb +1 -0
- data/lib/gir_ffi/field_argument_info.rb +4 -0
- data/lib/gir_ffi/in_out_pointer.rb +1 -1
- data/lib/gir_ffi/in_pointer.rb +2 -2
- data/lib/gir_ffi/info_ext/i_arg_info.rb +12 -2
- data/lib/gir_ffi/info_ext/i_callable_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_callback_info.rb +7 -2
- data/lib/gir_ffi/info_ext/i_field_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_function_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_registered_type_info.rb +7 -2
- data/lib/gir_ffi/info_ext/i_type_info.rb +21 -9
- data/lib/gir_ffi/info_ext/i_unresolved_info.rb +5 -0
- data/lib/gir_ffi/interface_base.rb +5 -0
- data/lib/gir_ffi/object_base.rb +5 -0
- data/lib/gir_ffi/receiver_argument_info.rb +5 -0
- data/lib/gir_ffi/registered_type_base.rb +5 -0
- data/lib/gir_ffi/return_value_info.rb +3 -1
- data/lib/gir_ffi/sized_array.rb +1 -1
- data/lib/gir_ffi/struct_base.rb +2 -24
- data/lib/gir_ffi/type_map.rb +5 -1
- data/lib/gir_ffi/union_base.rb +2 -2
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi/zero_terminated.rb +1 -1
- data/test/base_test_helper.rb +6 -6
- data/test/ffi-glib/hash_table_test.rb +7 -7
- data/test/ffi-glib/iconv_test.rb +2 -3
- data/test/ffi-glib/main_loop_test.rb +2 -2
- data/test/ffi-gobject/gobject_test.rb +1 -1
- data/test/ffi-gobject/object_test.rb +5 -14
- data/test/ffi-gobject/value_test.rb +30 -6
- data/test/ffi-gobject_introspection/i_base_info_test.rb +6 -6
- data/test/ffi-gobject_introspection/i_repository_test.rb +2 -4
- data/test/gir_ffi/arg_helper_test.rb +1 -1
- data/test/gir_ffi/builder_test.rb +18 -12
- data/test/gir_ffi/builders/argument_builder_test.rb +2 -5
- data/test/gir_ffi/builders/callback_builder_test.rb +1 -1
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +11 -10
- data/test/gir_ffi/builders/field_builder_test.rb +0 -2
- data/test/gir_ffi/builders/function_builder_test.rb +156 -147
- data/test/gir_ffi/builders/interface_builder_test.rb +1 -1
- data/test/gir_ffi/builders/module_builder_test.rb +2 -2
- data/test/gir_ffi/builders/object_builder_test.rb +2 -2
- data/test/gir_ffi/builders/property_builder_test.rb +5 -5
- data/test/gir_ffi/builders/return_value_builder_test.rb +30 -30
- data/test/gir_ffi/builders/struct_builder_test.rb +14 -14
- data/test/gir_ffi/builders/user_defined_builder_test.rb +21 -22
- data/test/gir_ffi/builders/vfunc_builder_test.rb +57 -0
- data/test/gir_ffi/class_base_test.rb +8 -8
- data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -4
- data/test/gir_ffi/g_type_test.rb +1 -1
- data/test/gir_ffi/in_pointer_test.rb +2 -2
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +3 -3
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +2 -2
- data/test/gir_ffi/info_ext/i_field_info_test.rb +8 -8
- data/test/gir_ffi/info_ext/i_function_info_test.rb +13 -13
- data/test/gir_ffi/info_ext/i_type_info_test.rb +131 -132
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +2 -2
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +2 -2
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +2 -2
- data/test/gir_ffi/interface_base_test.rb +3 -3
- data/test/gir_ffi/object_base_test.rb +3 -3
- data/test/gir_ffi/sized_array_test.rb +2 -2
- data/test/gir_ffi/type_map_test.rb +3 -3
- data/test/gir_ffi/unintrospectable_type_info_test.rb +14 -14
- data/test/gir_ffi/user_defined_property_info_test.rb +1 -1
- data/test/gir_ffi/user_defined_type_info_test.rb +25 -12
- data/test/gir_ffi/zero_terminated_test.rb +0 -1
- data/test/gir_ffi_test.rb +3 -3
- data/test/gir_ffi_test_helper.rb +4 -0
- data/test/integration/generated_gimarshallingtests_test.rb +31 -25
- data/test/integration/generated_gio_test.rb +1 -1
- data/test/integration/generated_gobject_test.rb +1 -1
- data/test/integration/generated_regress_test.rb +18 -22
- 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 '#
|
12
|
+
describe '#to_ffi_type' do
|
13
13
|
it 'returns the most generic type' do
|
14
|
-
unresolved_info.
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 '.
|
13
|
+
describe '.to_ffi_type' do
|
14
14
|
it 'returns :pointer' do
|
15
|
-
interface.
|
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
|
-
|
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 '.
|
13
|
+
describe '.to_ffi_type' do
|
14
14
|
it 'returns :pointer' do
|
15
|
-
derived_class.
|
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
|
-
|
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
|
-
|
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 '.
|
4
|
+
describe '.type_specification_to_ffi_type' do
|
5
5
|
it 'returns the nested FFI::Enum for an Enum module' do
|
6
|
-
GirFFI::TypeMap.
|
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.
|
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
|
-
|
19
|
-
|
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
|
-
|
33
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
91
|
-
|
92
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
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
|
data/test/gir_ffi_test.rb
CHANGED
@@ -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.
|
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 #
|
42
|
-
@klass.
|
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
|
data/test/gir_ffi_test_helper.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
205
|
-
|
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
|
-
|
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
|
-
|
225
|
-
|
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
|
-
|
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
|
-
|
287
|
+
ref_count(ob).must_be :>, 0
|
288
|
+
ref_count(res).must_equal 1
|
287
289
|
|
288
|
-
|
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.
|
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
|
-
|
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
|
-
|
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.
|
383
|
-
|
384
|
-
|
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
|
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
|
-
|
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 [
|
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
|
-
|
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.
|
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.
|
2209
|
-
GIMarshallingTests.gvalue_in_with_type gv, GIMarshallingTests::Object.
|
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
|