gir_ffi 0.7.7 → 0.7.8
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 +9 -0
- data/lib/ffi-glib/array.rb +1 -1
- data/lib/ffi-glib/error.rb +1 -2
- data/lib/ffi-glib/hash_table.rb +2 -2
- data/lib/ffi-glib/variant.rb +1 -1
- data/lib/ffi-gobject/base.rb +23 -23
- data/lib/ffi-gobject/object.rb +7 -3
- data/lib/ffi-gobject/value.rb +6 -1
- data/lib/ffi-gobject.rb +9 -6
- data/lib/ffi-gobject_introspection/i_base_info.rb +3 -3
- data/lib/ffi-gobject_introspection/i_constant_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_repository.rb +4 -1
- data/lib/ffi-gobject_introspection/i_type_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_unresolved_info.rb +7 -0
- data/lib/ffi-gobject_introspection/lib.rb +1 -1
- data/lib/gir_ffi/builders/argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +37 -29
- data/lib/gir_ffi/builders/callback_argument_builder.rb +57 -27
- data/lib/gir_ffi/builders/closure_convertor.rb +12 -8
- data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +12 -8
- data/lib/gir_ffi/builders/constructor_result_convertor.rb +11 -7
- data/lib/gir_ffi/builders/field_builder.rb +1 -1
- data/lib/gir_ffi/builders/function_builder.rb +1 -1
- data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +2 -2
- data/lib/gir_ffi/builders/method_template.rb +1 -1
- data/lib/gir_ffi/builders/null_convertor.rb +11 -7
- data/lib/gir_ffi/builders/property_builder.rb +1 -1
- data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +17 -13
- data/lib/gir_ffi/error_argument_info.rb +1 -1
- data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
- data/lib/gir_ffi/info_ext/i_unresolved_info.rb +12 -0
- data/lib/gir_ffi/info_ext/safe_constant_name.rb +2 -2
- data/lib/gir_ffi/info_ext/safe_function_name.rb +1 -1
- data/lib/gir_ffi/info_ext.rb +1 -0
- data/lib/gir_ffi/module_base.rb +1 -1
- data/lib/gir_ffi/receiver_argument_info.rb +15 -12
- data/lib/gir_ffi/user_data_argument_info.rb +17 -15
- data/lib/gir_ffi/user_data_type_info.rb +14 -12
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi-base/gobject/lib.rb +1 -1
- data/test/base_test_helper.rb +15 -15
- data/test/ffi-glib/array_test.rb +38 -38
- data/test/ffi-glib/byte_array_test.rb +6 -7
- data/test/ffi-glib/bytes_test.rb +9 -9
- data/test/ffi-glib/hash_table_test.rb +26 -23
- data/test/ffi-glib/iconv_test.rb +5 -5
- data/test/ffi-glib/list_test.rb +16 -16
- data/test/ffi-glib/main_loop_test.rb +6 -6
- data/test/ffi-glib/ptr_array_test.rb +45 -45
- data/test/ffi-glib/ruby_closure_test.rb +6 -6
- data/test/ffi-glib/s_list_test.rb +15 -15
- data/test/ffi-glib/strv_test.rb +21 -21
- data/test/ffi-glib/variant_test.rb +4 -4
- data/test/ffi-gobject/gobject_test.rb +35 -35
- data/test/ffi-gobject/object_class_test.rb +1 -1
- data/test/ffi-gobject/object_test.rb +29 -6
- data/test/ffi-gobject/value_test.rb +66 -52
- data/test/ffi-gobject_introspection/i_base_info_test.rb +10 -11
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +6 -6
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +4 -5
- data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -2
- data/test/ffi-gobject_introspection/i_object_info_test.rb +5 -5
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +9 -8
- data/test/ffi-gobject_introspection/i_repository_test.rb +16 -16
- data/test/ffi-gobject_introspection/i_type_info_test.rb +16 -2
- data/test/ffi-gobject_introspection/lib_test.rb +2 -2
- data/test/ffi-gobject_test.rb +50 -40
- data/test/gir_ffi/arg_helper_test.rb +5 -5
- data/test/gir_ffi/builder_test.rb +41 -41
- data/test/gir_ffi/builders/argument_builder_test.rb +240 -207
- data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -1
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +81 -15
- data/test/gir_ffi/builders/callback_builder_test.rb +39 -14
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +41 -33
- data/test/gir_ffi/builders/enum_builder_test.rb +3 -3
- data/test/gir_ffi/builders/field_builder_test.rb +17 -17
- data/test/gir_ffi/builders/function_builder_test.rb +16 -16
- data/test/gir_ffi/builders/interface_builder_test.rb +9 -7
- data/test/gir_ffi/builders/module_builder_test.rb +5 -6
- data/test/gir_ffi/builders/object_builder_test.rb +24 -19
- data/test/gir_ffi/builders/property_builder_test.rb +25 -23
- data/test/gir_ffi/builders/registered_type_builder_test.rb +11 -11
- data/test/gir_ffi/builders/return_value_builder_test.rb +237 -197
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +29 -22
- data/test/gir_ffi/builders/struct_builder_test.rb +10 -10
- data/test/gir_ffi/builders/unintrospectable_builder_test.rb +8 -8
- data/test/gir_ffi/builders/union_builder_test.rb +5 -6
- data/test/gir_ffi/builders/user_defined_builder_test.rb +42 -33
- data/test/gir_ffi/builders/vfunc_builder_test.rb +37 -30
- data/test/gir_ffi/callback_base_test.rb +4 -5
- data/test/gir_ffi/class_base_test.rb +35 -28
- data/test/gir_ffi/error_type_info_test.rb +14 -14
- data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -4
- data/test/gir_ffi/g_type_test.rb +6 -6
- data/test/gir_ffi/in_out_pointer_test.rb +27 -27
- data/test/gir_ffi/in_pointer_test.rb +54 -50
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +8 -7
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +7 -7
- data/test/gir_ffi/info_ext/i_field_info_test.rb +10 -8
- data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -15
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +10 -8
- data/test/gir_ffi/info_ext/i_type_info_test.rb +158 -155
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +17 -0
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +12 -10
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +12 -10
- data/test/gir_ffi/interface_base_test.rb +6 -6
- data/test/gir_ffi/method_stubber_test.rb +16 -13
- data/test/gir_ffi/object_base_test.rb +6 -6
- data/test/gir_ffi/sized_array_test.rb +23 -23
- data/test/gir_ffi/type_map_test.rb +3 -3
- data/test/gir_ffi/unintrospectable_type_info_test.rb +18 -18
- data/test/gir_ffi/user_defined_property_info_test.rb +4 -4
- data/test/gir_ffi/user_defined_type_info_test.rb +16 -16
- data/test/gir_ffi/variable_name_generator_test.rb +6 -6
- data/test/gir_ffi/version_test.rb +1 -1
- data/test/gir_ffi/zero_terminated_test.rb +16 -17
- data/test/gir_ffi-base/glib/boolean_test.rb +13 -13
- data/test/gir_ffi-base/glib/strv_test.rb +11 -11
- data/test/gir_ffi_test.rb +18 -18
- data/test/gir_ffi_test_helper.rb +13 -18
- data/test/integration/derived_classes_test.rb +8 -8
- data/test/integration/generated_gimarshallingtests_test.rb +794 -792
- data/test/integration/generated_gio_test.rb +25 -26
- data/test/integration/generated_glib_test.rb +8 -2
- data/test/integration/generated_gobject_test.rb +16 -9
- data/test/integration/generated_pango_ft2_test.rb +1 -2
- data/test/integration/generated_pango_test.rb +2 -2
- data/test/integration/generated_regress_test.rb +785 -705
- data/test/integration/generated_secret_test.rb +5 -5
- data/test/integration/method_lookup_test.rb +5 -5
- data/test/introspection_test_helper.rb +3 -1
- data/test/minitest/stats_plugin.rb +3 -3
- metadata +6 -3
@@ -3,22 +3,24 @@ require 'gir_ffi_test_helper'
|
|
3
3
|
describe GirFFI::Builders::SignalClosureBuilder do
|
4
4
|
let(:builder) { GirFFI::Builders::SignalClosureBuilder.new signal_info }
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe '#build_class' do
|
7
7
|
let(:signal_info) {
|
8
|
-
get_signal_introspection_data
|
8
|
+
get_signal_introspection_data 'Regress', 'TestObj', 'test'
|
9
|
+
}
|
9
10
|
|
10
|
-
it
|
11
|
+
it 'builds a descendant of RubyClosure' do
|
11
12
|
klass = builder.build_class
|
12
13
|
klass.ancestors.must_include GObject::RubyClosure
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
describe
|
17
|
-
describe
|
17
|
+
describe '#marshaller_definition' do
|
18
|
+
describe 'for a signal with no arguments or return value' do
|
18
19
|
let(:signal_info) {
|
19
|
-
get_signal_introspection_data
|
20
|
+
get_signal_introspection_data 'Regress', 'TestObj', 'test'
|
21
|
+
}
|
20
22
|
|
21
|
-
it
|
23
|
+
it 'returns a valid marshaller converting only the receiver' do
|
22
24
|
expected = <<-CODE.reset_indentation
|
23
25
|
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
24
26
|
_instance = param_values.first.get_value_plain
|
@@ -31,11 +33,12 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
describe
|
36
|
+
describe 'for a signal with an argument and a return value' do
|
35
37
|
let(:signal_info) {
|
36
|
-
get_signal_introspection_data
|
38
|
+
get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-int64-prop'
|
39
|
+
}
|
37
40
|
|
38
|
-
it
|
41
|
+
it 'returns a valid mapping method' do
|
39
42
|
skip unless signal_info
|
40
43
|
|
41
44
|
expected = <<-CODE.reset_indentation
|
@@ -52,11 +55,12 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
52
55
|
end
|
53
56
|
end
|
54
57
|
|
55
|
-
describe
|
58
|
+
describe 'for a signal with an enum argument' do
|
56
59
|
let(:signal_info) {
|
57
|
-
get_signal_introspection_data
|
60
|
+
get_signal_introspection_data 'Gio', 'MountOperation', 'reply'
|
61
|
+
}
|
58
62
|
|
59
|
-
it
|
63
|
+
it 'returns a valid mapping method' do
|
60
64
|
expected = <<-CODE.reset_indentation
|
61
65
|
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
62
66
|
_instance, result = param_values.map(&:get_value_plain)
|
@@ -70,11 +74,12 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
70
74
|
end
|
71
75
|
end
|
72
76
|
|
73
|
-
describe
|
77
|
+
describe 'for a signal with a array plus length arguments' do
|
74
78
|
let(:signal_info) {
|
75
|
-
get_signal_introspection_data
|
79
|
+
get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-array-len-prop'
|
80
|
+
}
|
76
81
|
|
77
|
-
it
|
82
|
+
it 'returns a valid mapping method' do
|
78
83
|
skip unless signal_info
|
79
84
|
|
80
85
|
expected = <<-CODE.reset_indentation
|
@@ -91,11 +96,12 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
91
96
|
end
|
92
97
|
end
|
93
98
|
|
94
|
-
describe
|
99
|
+
describe 'for a signal with a struct argument' do
|
95
100
|
let(:signal_info) {
|
96
|
-
get_signal_introspection_data
|
101
|
+
get_signal_introspection_data 'Regress', 'TestObj', 'test-with-static-scope-arg'
|
102
|
+
}
|
97
103
|
|
98
|
-
it
|
104
|
+
it 'returns a valid mapping method' do
|
99
105
|
skip unless signal_info
|
100
106
|
|
101
107
|
expected = <<-CODE.reset_indentation
|
@@ -111,11 +117,12 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
111
117
|
end
|
112
118
|
end
|
113
119
|
|
114
|
-
describe
|
120
|
+
describe 'for a signal returning an array of integers' do
|
115
121
|
let(:signal_info) {
|
116
|
-
get_signal_introspection_data
|
122
|
+
get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-intarray-ret'
|
123
|
+
}
|
117
124
|
|
118
|
-
it
|
125
|
+
it 'returns a valid mapping method' do
|
119
126
|
skip unless signal_info
|
120
127
|
|
121
128
|
expected = <<-CODE.reset_indentation
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'gir_ffi_test_helper'
|
2
2
|
|
3
3
|
describe GirFFI::Builders::StructBuilder do
|
4
|
-
describe
|
5
|
-
it
|
4
|
+
describe '#layout_specification' do
|
5
|
+
it 'returns the correct layout for Regress::TestStructA' do
|
6
6
|
info = get_introspection_data 'Regress', 'TestStructA'
|
7
7
|
builder = GirFFI::Builders::StructBuilder.new info
|
8
8
|
builder.layout_specification.must_equal [:some_int, :int32, 0,
|
@@ -12,30 +12,30 @@ describe GirFFI::Builders::StructBuilder do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
15
|
+
describe 'for a struct with a simple layout' do
|
16
16
|
before do
|
17
17
|
@field = Object.new
|
18
18
|
|
19
19
|
@struct = Object.new
|
20
20
|
stub(@struct).namespace { 'Foo' }
|
21
21
|
stub(@struct).safe_name { 'Bar' }
|
22
|
-
stub(@struct).fields { [
|
22
|
+
stub(@struct).fields { [@field] }
|
23
23
|
|
24
24
|
@builder = GirFFI::Builders::StructBuilder.new @struct
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it 'creates the correct layout specification' do
|
28
28
|
mock(@field).layout_specification { [:bar, :int32, 0] }
|
29
29
|
spec = @builder.send :layout_specification
|
30
30
|
assert_equal [:bar, :int32, 0], spec
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
35
|
-
it
|
34
|
+
describe 'for a struct with a layout with a complex type' do
|
35
|
+
it 'does not flatten the complex type specification' do
|
36
36
|
mock(simplefield = Object.new).layout_specification { [:bar, :foo, 0] }
|
37
37
|
mock(complexfield = Object.new).layout_specification { [:baz, [:qux, 2], 0] }
|
38
|
-
mock(struct = Object.new).fields { [
|
38
|
+
mock(struct = Object.new).fields { [simplefield, complexfield] }
|
39
39
|
|
40
40
|
stub(struct).safe_name { 'Bar' }
|
41
41
|
stub(struct).namespace { 'Foo' }
|
@@ -46,8 +46,8 @@ describe GirFFI::Builders::StructBuilder do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
describe
|
50
|
-
it
|
49
|
+
describe 'for a struct without defined fields' do
|
50
|
+
it 'uses a single field of the parent struct type as the default layout' do
|
51
51
|
@gir = GObjectIntrospection::IRepository.default
|
52
52
|
@gir.require 'GObject', nil
|
53
53
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'gir_ffi_test_helper'
|
2
2
|
|
3
3
|
describe GirFFI::Builders::UnintrospectableBuilder do
|
4
|
-
describe
|
4
|
+
describe 'building the GLocalFile type' do
|
5
5
|
before do
|
6
6
|
# Ensure existence of GLocalFile type
|
7
7
|
GirFFI.setup :Gio
|
8
8
|
unless Gio::Lib.respond_to? :g_file_new_for_path
|
9
|
-
Gio.setup_method
|
9
|
+
Gio.setup_method 'file_new_for_path'
|
10
10
|
end
|
11
11
|
ptr = GirFFI::InPointer.from :utf8, '/'
|
12
12
|
Gio::Lib.g_file_new_for_path(ptr)
|
@@ -17,30 +17,30 @@ describe GirFFI::Builders::UnintrospectableBuilder do
|
|
17
17
|
@klass = @bldr.build_class
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it 'builds a class' do
|
21
21
|
assert_instance_of Class, @klass
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'builds a class derived from GObject::Object' do
|
25
25
|
assert_includes @klass.ancestors, GObject::Object
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'builds a class derived from Gio::File' do
|
29
29
|
assert_includes @klass.ancestors, Gio::File
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'returns the same class when built again' do
|
33
33
|
other_bldr = GirFFI::Builders::UnintrospectableBuilder.new(@info)
|
34
34
|
other_klass = other_bldr.build_class
|
35
35
|
|
36
36
|
assert_equal @klass, other_klass
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
39
|
+
describe 'its #find_signal method' do
|
40
40
|
it "raises correct error for a signal that doesn't exist" do
|
41
41
|
msg = nil
|
42
42
|
begin
|
43
|
-
@bldr.find_signal
|
43
|
+
@bldr.find_signal 'foo'
|
44
44
|
rescue RuntimeError => e
|
45
45
|
msg = e.message
|
46
46
|
end
|
@@ -4,14 +4,14 @@ describe GirFFI::Builders::UnionBuilder do
|
|
4
4
|
let(:union_info) { get_introspection_data('GObject', 'TypeCValue') }
|
5
5
|
let(:builder) { GirFFI::Builders::UnionBuilder.new union_info }
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe '#setup_instance_method' do
|
8
8
|
it "returns nil looking for a method that doesn't exist" do
|
9
9
|
builder.setup_instance_method('blub').must_be_nil
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
describe
|
14
|
-
it
|
13
|
+
describe '#layout_specification' do
|
14
|
+
it 'returns the correct layout for GObject::TypeCValue' do
|
15
15
|
long_type = FFI.type_size(:long) == 8 ? :int64 : :int32
|
16
16
|
builder.layout_specification.must_equal [:v_int, :int32, 0,
|
17
17
|
:v_long, long_type, 0,
|
@@ -21,10 +21,9 @@ describe GirFFI::Builders::UnionBuilder do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
25
|
-
it
|
24
|
+
describe '#layout_superclass' do
|
25
|
+
it 'returns FFI::Union' do
|
26
26
|
builder.layout_superclass.must_equal FFI::Union
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
@@ -3,100 +3,109 @@ require 'gir_ffi_test_helper'
|
|
3
3
|
GirFFI.setup :GIMarshallingTests
|
4
4
|
|
5
5
|
describe GirFFI::Builders::UserDefinedBuilder do
|
6
|
-
let(:klass) {
|
7
|
-
|
6
|
+
let(:klass) {
|
7
|
+
Object.const_set("DerivedClass#{Sequence.next}",
|
8
|
+
Class.new(GIMarshallingTests::Object))
|
9
|
+
}
|
8
10
|
let(:builder) { GirFFI::Builders::UserDefinedBuilder.new info }
|
9
11
|
let(:info) { GirFFI::UserDefinedTypeInfo.new klass }
|
10
12
|
|
11
|
-
describe
|
13
|
+
describe '#build_class' do
|
12
14
|
before do
|
13
15
|
builder.build_class
|
14
16
|
end
|
15
17
|
|
16
|
-
describe
|
17
|
-
let(:info) {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
describe 'with type info containing one property' do
|
19
|
+
let(:info) {
|
20
|
+
GirFFI::UserDefinedTypeInfo.new klass do |info|
|
21
|
+
info.install_property GObject.param_spec_int('foo', 'foo bar',
|
22
|
+
'The Foo Bar Property',
|
23
|
+
10, 20, 15,
|
24
|
+
3)
|
25
|
+
end
|
26
|
+
}
|
23
27
|
|
24
|
-
it
|
28
|
+
it 'registers a type that is bigger than the parent' do
|
25
29
|
gtype = klass.get_gtype
|
26
30
|
q = GObject.type_query gtype
|
27
31
|
q.instance_size.must_be :>, GIMarshallingTests::Object::Struct.size
|
28
32
|
end
|
29
33
|
|
30
|
-
it
|
34
|
+
it 'gives the types Struct the fields :parent and :foo' do
|
31
35
|
klass::Struct.members.must_equal [:parent, :foo]
|
32
36
|
end
|
33
37
|
|
34
|
-
it
|
38
|
+
it 'creates accessor functions for the property' do
|
35
39
|
obj = klass.new
|
36
40
|
obj.foo = 13
|
37
41
|
obj.foo.must_equal 13
|
38
42
|
end
|
39
43
|
|
40
|
-
it
|
44
|
+
it 'makes the property retrievable using #get_property' do
|
41
45
|
obj = klass.new
|
42
46
|
obj.foo = 13
|
43
|
-
obj.get_property(
|
47
|
+
obj.get_property('foo').get_value.must_equal 13
|
44
48
|
end
|
45
49
|
|
46
|
-
it
|
50
|
+
it 'makes the property settable using #set_property' do
|
47
51
|
obj = klass.new
|
48
|
-
obj.set_property(
|
52
|
+
obj.set_property('foo', 20)
|
49
53
|
obj.foo.must_equal 20
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
53
|
-
describe
|
54
|
-
let(:info) {
|
55
|
-
|
56
|
-
|
57
|
+
describe 'with type info containing an overridden g_name' do
|
58
|
+
let(:info) {
|
59
|
+
GirFFI::UserDefinedTypeInfo.new klass do |info|
|
60
|
+
info.g_name = "OtherName#{Sequence.next}"
|
61
|
+
end
|
62
|
+
}
|
57
63
|
|
58
|
-
it
|
64
|
+
it 'registers a type under the overridden name' do
|
59
65
|
registered_name = GObject.type_name(klass.get_gtype)
|
60
66
|
registered_name.must_equal info.g_name
|
61
67
|
registered_name.wont_equal klass.name
|
62
68
|
end
|
63
69
|
end
|
64
70
|
|
65
|
-
describe
|
66
|
-
let(:info) {
|
67
|
-
|
68
|
-
|
69
|
-
|
71
|
+
describe 'with type info containing a vfunc' do
|
72
|
+
let(:info) {
|
73
|
+
GirFFI::UserDefinedTypeInfo.new klass do |info|
|
74
|
+
info.install_vfunc_implementation :method_int8_in, proc {|instance, in_|
|
75
|
+
instance.int = in_
|
76
|
+
}
|
77
|
+
end
|
78
|
+
}
|
70
79
|
|
71
|
-
it
|
80
|
+
it 'allows the vfunc to be called through its invoker' do
|
72
81
|
obj = klass.new
|
73
82
|
obj.method_int8_in 12
|
74
83
|
obj.int.must_equal 12
|
75
84
|
end
|
76
85
|
end
|
77
86
|
|
78
|
-
describe
|
87
|
+
describe 'with type info containing a vfunc from an included Interface' do
|
79
88
|
let(:info) do
|
80
89
|
klass.class_eval { include GIMarshallingTests::Interface }
|
81
90
|
GirFFI::UserDefinedTypeInfo.new klass do |info|
|
82
91
|
info.install_vfunc_implementation :test_int8_in,
|
83
|
-
proc {|instance, in_| instance.int = in_ }
|
92
|
+
proc { |instance, in_| instance.int = in_ }
|
84
93
|
end
|
85
94
|
end
|
86
95
|
|
87
|
-
it
|
96
|
+
it 'marks the type as conforming to the included Interface' do
|
88
97
|
iface_gtype = GIMarshallingTests::Interface.get_gtype
|
89
98
|
GObject.type_interfaces(klass.get_gtype).to_a.must_equal [iface_gtype]
|
90
99
|
end
|
91
100
|
|
92
|
-
it
|
101
|
+
it 'allows the vfunc to be called through its invoker' do
|
93
102
|
obj = klass.new
|
94
103
|
obj.test_int8_in 12
|
95
104
|
obj.int.must_equal 12
|
96
105
|
end
|
97
106
|
end
|
98
107
|
|
99
|
-
it
|
108
|
+
it 'does not attempt to register a registered class' do
|
100
109
|
gtype = klass.get_gtype
|
101
110
|
other_builder = GirFFI::Builders::UserDefinedBuilder.new info
|
102
111
|
other_builder.build_class
|
@@ -3,18 +3,19 @@ require 'gir_ffi_test_helper'
|
|
3
3
|
describe GirFFI::Builders::VFuncBuilder do
|
4
4
|
let(:builder) { GirFFI::Builders::VFuncBuilder.new vfunc_info }
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe '#mapping_method_definition' do
|
7
7
|
let(:result) { builder.mapping_method_definition }
|
8
8
|
|
9
9
|
before do
|
10
10
|
skip unless vfunc_info
|
11
11
|
end
|
12
12
|
|
13
|
-
describe
|
13
|
+
describe 'for a vfunc with only one argument' do
|
14
14
|
let(:vfunc_info) {
|
15
|
-
get_vfunc_introspection_data
|
15
|
+
get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'method_int8_in'
|
16
|
+
}
|
16
17
|
|
17
|
-
it
|
18
|
+
it 'returns a valid mapping method including receiver' do
|
18
19
|
expected = <<-CODE.reset_indentation
|
19
20
|
def self.call_with_argument_mapping(_proc, _instance, in_)
|
20
21
|
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
@@ -27,11 +28,12 @@ describe GirFFI::Builders::VFuncBuilder do
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
|
-
describe
|
31
|
+
describe 'for a vfunc returning an enum' do
|
31
32
|
let(:vfunc_info) {
|
32
|
-
get_vfunc_introspection_data
|
33
|
+
get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'vfunc_return_enum'
|
34
|
+
}
|
33
35
|
|
34
|
-
it
|
36
|
+
it 'returns a valid mapping method including receiver' do
|
35
37
|
expected = <<-CODE.reset_indentation
|
36
38
|
def self.call_with_argument_mapping(_proc, _instance)
|
37
39
|
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
@@ -45,11 +47,12 @@ describe GirFFI::Builders::VFuncBuilder do
|
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
48
|
-
describe
|
50
|
+
describe 'for a vfunc with a callback argument' do
|
49
51
|
let(:vfunc_info) {
|
50
|
-
get_vfunc_introspection_data
|
52
|
+
get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'vfunc_with_callback'
|
53
|
+
}
|
51
54
|
|
52
|
-
it
|
55
|
+
it 'returns a valid mapping method including receiver' do
|
53
56
|
expected = <<-CODE.reset_indentation
|
54
57
|
def self.call_with_argument_mapping(_proc, _instance, callback, callback_data)
|
55
58
|
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
@@ -63,12 +66,13 @@ describe GirFFI::Builders::VFuncBuilder do
|
|
63
66
|
end
|
64
67
|
end
|
65
68
|
|
66
|
-
describe
|
69
|
+
describe 'for a vfunc with an out argument allocated by them, the caller' do
|
67
70
|
let(:vfunc_info) {
|
68
|
-
get_vfunc_introspection_data(
|
69
|
-
|
71
|
+
get_vfunc_introspection_data('GIMarshallingTests', 'Object',
|
72
|
+
'method_int8_arg_and_out_caller')
|
73
|
+
}
|
70
74
|
|
71
|
-
it
|
75
|
+
it 'returns a valid mapping method including receiver' do
|
72
76
|
expected = <<-CODE.reset_indentation
|
73
77
|
def self.call_with_argument_mapping(_proc, _instance, arg, out)
|
74
78
|
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
@@ -83,12 +87,13 @@ describe GirFFI::Builders::VFuncBuilder do
|
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
86
|
-
describe
|
90
|
+
describe 'for a vfunc with an out argument allocated by us, the callee' do
|
87
91
|
let(:vfunc_info) {
|
88
|
-
get_vfunc_introspection_data(
|
89
|
-
|
92
|
+
get_vfunc_introspection_data('GIMarshallingTests', 'Object',
|
93
|
+
'method_int8_arg_and_out_callee')
|
94
|
+
}
|
90
95
|
|
91
|
-
it
|
96
|
+
it 'returns a valid mapping method including receiver' do
|
92
97
|
expected = <<-CODE.reset_indentation
|
93
98
|
def self.call_with_argument_mapping(_proc, _instance, arg, out)
|
94
99
|
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
@@ -103,13 +108,13 @@ describe GirFFI::Builders::VFuncBuilder do
|
|
103
108
|
end
|
104
109
|
end
|
105
110
|
|
106
|
-
describe
|
111
|
+
describe 'for a vfunc with an error argument' do
|
107
112
|
let(:vfunc_info) {
|
108
|
-
get_vfunc_introspection_data(
|
109
|
-
|
113
|
+
get_vfunc_introspection_data('GIMarshallingTests', 'Object',
|
114
|
+
'vfunc_meth_with_err')
|
110
115
|
}
|
111
116
|
|
112
|
-
it
|
117
|
+
it 'returns a valid mapping method including receiver' do
|
113
118
|
expected = <<-CODE.reset_indentation
|
114
119
|
def self.call_with_argument_mapping(_proc, _instance, x, _error)
|
115
120
|
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
@@ -129,35 +134,37 @@ describe GirFFI::Builders::VFuncBuilder do
|
|
129
134
|
end
|
130
135
|
end
|
131
136
|
|
132
|
-
describe
|
137
|
+
describe '#argument_ffi_types' do
|
133
138
|
let(:result) { builder.argument_ffi_types }
|
134
139
|
|
135
140
|
before do
|
136
141
|
skip unless vfunc_info
|
137
142
|
end
|
138
143
|
|
139
|
-
describe
|
144
|
+
describe 'for a vfunc with only one argument' do
|
140
145
|
let(:vfunc_info) {
|
141
|
-
get_vfunc_introspection_data
|
146
|
+
get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'method_int8_in'
|
147
|
+
}
|
142
148
|
|
143
|
-
it
|
149
|
+
it 'returns the correct FFI types including :pointer for the receiver' do
|
144
150
|
result.must_equal [:pointer, :int8]
|
145
151
|
end
|
146
152
|
end
|
147
153
|
end
|
148
154
|
|
149
|
-
describe
|
155
|
+
describe '#return_ffi_type' do
|
150
156
|
let(:result) { builder.return_ffi_type }
|
151
157
|
|
152
158
|
before do
|
153
159
|
skip unless vfunc_info
|
154
160
|
end
|
155
161
|
|
156
|
-
describe
|
162
|
+
describe 'for a vfunc returning an object' do
|
157
163
|
let(:vfunc_info) {
|
158
|
-
get_vfunc_introspection_data
|
164
|
+
get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'vfunc_return_object_transfer_full'
|
165
|
+
}
|
159
166
|
|
160
|
-
it
|
167
|
+
it 'returns :pointer' do
|
161
168
|
result.must_equal :pointer
|
162
169
|
end
|
163
170
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'gir_ffi_test_helper'
|
2
2
|
|
3
3
|
describe GirFFI::CallbackBase do
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
GirFFI::CallbackBase.store_callback
|
7
|
-
GirFFI::CallbackBase::CALLBACKS.last.must_equal
|
4
|
+
describe '.store_callback' do
|
5
|
+
it 'stores the passed in proc in CALLBACKS' do
|
6
|
+
GirFFI::CallbackBase.store_callback 'some-callback'
|
7
|
+
GirFFI::CallbackBase::CALLBACKS.last.must_equal 'some-callback'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
11
|
-
|