gir_ffi 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +14 -0
- data/TODO.rdoc +23 -5
- data/lib/ffi-glib/array.rb +14 -15
- data/lib/ffi-glib/container_class_methods.rb +0 -1
- data/lib/ffi-glib/hash_table.rb +3 -4
- data/lib/ffi-glib/ptr_array.rb +12 -4
- data/lib/ffi-glib/sized_array.rb +27 -7
- data/lib/ffi-gobject.rb +14 -15
- data/lib/ffi-gobject/closure.rb +1 -1
- data/lib/ffi-gobject/object.rb +40 -15
- data/lib/ffi-gobject/ruby_closure.rb +0 -1
- data/lib/ffi-gobject/value.rb +45 -21
- data/lib/ffi-gobject_introspection/i_arg_info.rb +4 -0
- data/lib/ffi-gobject_introspection/i_base_info.rb +42 -2
- data/lib/ffi-gobject_introspection/i_callable_info.rb +8 -0
- data/lib/ffi-gobject_introspection/i_enum_info.rb +1 -4
- data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -0
- data/lib/ffi-gobject_introspection/i_object_info.rb +2 -0
- data/lib/ffi-gobject_introspection/i_repository.rb +2 -3
- data/lib/ffi-gobject_introspection/i_struct_info.rb +3 -8
- data/lib/ffi-gobject_introspection/lib.rb +3 -0
- data/lib/gir_ffi-base.rb +3 -1
- data/lib/gir_ffi-base/gir_ffi/struct.rb +27 -0
- data/lib/gir_ffi-base/glib/boolean.rb +13 -1
- data/lib/gir_ffi-base/gobject.rb +7 -0
- data/lib/gir_ffi-base/gobject/lib.rb +0 -2
- data/lib/gir_ffi.rb +1 -3
- data/lib/gir_ffi/arg_helper.rb +4 -85
- data/lib/gir_ffi/builder.rb +5 -5
- data/lib/gir_ffi/builder_helper.rb +7 -0
- data/lib/gir_ffi/builders/argument_builder.rb +132 -0
- data/lib/gir_ffi/{base_argument_builder.rb → builders/base_argument_builder.rb} +32 -41
- data/lib/gir_ffi/builders/base_type_builder.rb +47 -0
- data/lib/gir_ffi/builders/callback_builder.rb +38 -0
- data/lib/gir_ffi/builders/constant_builder.rb +18 -0
- data/lib/gir_ffi/builders/enum_builder.rb +62 -0
- data/lib/gir_ffi/builders/error_argument_builder.rb +18 -0
- data/lib/gir_ffi/builders/field_builder.rb +94 -0
- data/lib/gir_ffi/builders/function_builder.rb +123 -0
- data/lib/gir_ffi/builders/interface_builder.rb +29 -0
- data/lib/gir_ffi/builders/mapping_method_builder.rb +88 -0
- data/lib/gir_ffi/builders/module_builder.rb +124 -0
- data/lib/gir_ffi/{null_argument_builder.rb → builders/null_argument_builder.rb} +0 -0
- data/lib/gir_ffi/builders/null_builder.rb +11 -0
- data/lib/gir_ffi/builders/object_builder.rb +123 -0
- data/lib/gir_ffi/{builder/property.rb → builders/property_builder.rb} +0 -0
- data/lib/gir_ffi/builders/registered_type_builder.rb +50 -0
- data/lib/gir_ffi/builders/return_value_builder.rb +68 -0
- data/lib/gir_ffi/builders/signal_builder.rb +91 -0
- data/lib/gir_ffi/builders/struct_builder.rb +35 -0
- data/lib/gir_ffi/builders/type_builder.rb +40 -0
- data/lib/gir_ffi/builders/unintrospectable_builder.rb +35 -0
- data/lib/gir_ffi/builders/union_builder.rb +34 -0
- data/lib/gir_ffi/builders/user_defined_builder.rb +103 -0
- data/lib/gir_ffi/builders/with_layout.rb +55 -0
- data/lib/gir_ffi/builders/with_methods.rb +44 -0
- data/lib/gir_ffi/callback_base.rb +31 -0
- data/lib/gir_ffi/class_base.rb +16 -10
- data/lib/gir_ffi/enum_base.rb +8 -4
- data/lib/gir_ffi/ffi_ext/pointer.rb +19 -2
- data/lib/gir_ffi/in_out_pointer.rb +38 -39
- data/lib/gir_ffi/in_pointer.rb +33 -18
- data/lib/gir_ffi/info_ext.rb +0 -4
- data/lib/gir_ffi/info_ext/i_arg_info.rb +0 -18
- data/lib/gir_ffi/info_ext/i_callable_info.rb +2 -1
- data/lib/gir_ffi/info_ext/i_registered_type_info.rb +6 -8
- data/lib/gir_ffi/info_ext/i_signal_info.rb +6 -21
- data/lib/gir_ffi/info_ext/i_type_info.rb +54 -29
- data/lib/gir_ffi/info_ext/safe_constant_name.rb +8 -1
- data/lib/gir_ffi/interface_base.rb +1 -1
- data/lib/gir_ffi/module_base.rb +5 -1
- data/lib/gir_ffi/object_base.rb +5 -1
- data/lib/gir_ffi/setter_argument_info.rb +4 -0
- data/lib/gir_ffi/signal_base.rb +21 -0
- data/lib/gir_ffi/struct_base.rb +24 -0
- data/lib/gir_ffi/type_base.rb +11 -0
- data/lib/gir_ffi/type_map.rb +4 -2
- data/lib/gir_ffi/union_base.rb +24 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/tasks/test.rake +73 -7
- data/test/base_test_helper.rb +3 -19
- data/test/ffi-glib/array_test.rb +6 -0
- data/test/ffi-glib/ptr_array_test.rb +13 -0
- data/test/ffi-glib/ruby_closure_test.rb +7 -7
- data/test/ffi-glib/sized_array_test.rb +2 -2
- data/test/ffi-gobject/gobject_test.rb +3 -12
- data/test/ffi-gobject/object_test.rb +33 -2
- data/test/ffi-gobject/value_test.rb +114 -1
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +2 -2
- data/test/ffi-gobject_introspection/i_object_info_test.rb +3 -3
- data/test/ffi-gobject_introspection/i_repository_test.rb +26 -21
- data/test/ffi-gobject_test.rb +14 -14
- data/test/gir_ffi-base/glib/boolean_test.rb +6 -0
- data/test/gir_ffi/arg_helper_test.rb +2 -122
- data/test/gir_ffi/builder_test.rb +67 -204
- data/test/gir_ffi/{argument_builder_test.rb → builders/argument_builder_test.rb} +230 -108
- data/test/gir_ffi/builders/base_argument_builder_test.rb +5 -0
- data/test/gir_ffi/builders/callback_builder_test.rb +50 -0
- data/test/gir_ffi/builders/constant_builder_test.rb +4 -0
- data/test/gir_ffi/{builder/type/enum_test.rb → builders/enum_builder_test.rb} +2 -3
- data/test/gir_ffi/builders/field_builder_test.rb +94 -0
- data/test/gir_ffi/{function_builder_test.rb → builders/function_builder_test.rb} +43 -24
- data/test/gir_ffi/{builder/type/interface_test.rb → builders/interface_builder_test.rb} +2 -2
- data/test/gir_ffi/{builder/module_test.rb → builders/module_builder_test.rb} +12 -13
- data/test/gir_ffi/{builder/type/object_test.rb → builders/object_builder_test.rb} +9 -9
- data/test/gir_ffi/{return_value_builder_test.rb → builders/return_value_builder_test.rb} +94 -58
- data/test/gir_ffi/builders/signal_builder_test.rb +62 -0
- data/test/gir_ffi/{builder/type/struct_test.rb → builders/struct_builder_test.rb} +36 -19
- data/test/gir_ffi/{builder/type/unintrospectable_test.rb → builders/unintrospectable_builder_test.rb} +3 -3
- data/test/gir_ffi/builders/union_builder_test.rb +29 -0
- data/test/gir_ffi/{builder/type/user_defined_test.rb → builders/user_defined_builder_test.rb} +2 -2
- data/test/gir_ffi/callback_base_test.rb +11 -0
- data/test/gir_ffi/class_base_test.rb +22 -22
- data/test/gir_ffi/ffi_ext/pointer_test.rb +18 -0
- data/test/gir_ffi/in_out_pointer_test.rb +0 -7
- data/test/gir_ffi/in_pointer_test.rb +27 -3
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +16 -44
- data/test/gir_ffi/info_ext/i_type_info_test.rb +315 -74
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +6 -0
- data/test/gir_ffi/interface_base_test.rb +3 -5
- data/test/gir_ffi/object_base_test.rb +10 -6
- data/test/gir_ffi/type_map_test.rb +2 -2
- data/test/gir_ffi/unintrospectable_type_info_test.rb +2 -2
- data/test/gir_ffi_test_helper.rb +12 -4
- data/test/integration/generated_gimarshallingtests_test.rb +436 -76
- data/test/integration/generated_gio_test.rb +5 -11
- data/test/integration/generated_gobject_test.rb +8 -0
- data/test/integration/generated_regress_test.rb +755 -309
- data/test/integration/generated_secret_test.rb +2 -1
- metadata +73 -72
- data/lib/ffi-gobject/ruby_style.rb +0 -23
- data/lib/gir_ffi/argument_builder.rb +0 -154
- data/lib/gir_ffi/builder/field.rb +0 -60
- data/lib/gir_ffi/builder/module.rb +0 -127
- data/lib/gir_ffi/builder/type.rb +0 -39
- data/lib/gir_ffi/builder/type/base.rb +0 -48
- data/lib/gir_ffi/builder/type/callback.rb +0 -30
- data/lib/gir_ffi/builder/type/constant.rb +0 -22
- data/lib/gir_ffi/builder/type/enum.rb +0 -66
- data/lib/gir_ffi/builder/type/interface.rb +0 -33
- data/lib/gir_ffi/builder/type/object.rb +0 -134
- data/lib/gir_ffi/builder/type/registered_type.rb +0 -62
- data/lib/gir_ffi/builder/type/struct.rb +0 -34
- data/lib/gir_ffi/builder/type/unintrospectable.rb +0 -39
- data/lib/gir_ffi/builder/type/union.rb +0 -34
- data/lib/gir_ffi/builder/type/user_defined.rb +0 -107
- data/lib/gir_ffi/builder/type/with_layout.rb +0 -62
- data/lib/gir_ffi/builder/type/with_methods.rb +0 -64
- data/lib/gir_ffi/callback.rb +0 -72
- data/lib/gir_ffi/callback_helper.rb +0 -11
- data/lib/gir_ffi/error_argument_builder.rb +0 -17
- data/lib/gir_ffi/function_builder.rb +0 -112
- data/lib/gir_ffi/info_ext/i_enum_info.rb +0 -11
- data/lib/gir_ffi/info_ext/i_object_info.rb +0 -11
- data/lib/gir_ffi/info_ext/i_struct_info.rb +0 -11
- data/lib/gir_ffi/info_ext/i_union_info.rb +0 -12
- data/lib/gir_ffi/return_value_builder.rb +0 -81
- data/test/ffi-gobject/ruby_style_test.rb +0 -38
- data/test/gir_ffi/base_argument_builder_test.rb +0 -13
- data/test/gir_ffi/builder/type/callback_test.rb +0 -6
- data/test/gir_ffi/builder/type/constant_test.rb +0 -4
- data/test/gir_ffi/builder/type/union_test.rb +0 -12
- data/test/gir_ffi/callback_helper_test.rb +0 -10
- data/test/gir_ffi/callback_test.rb +0 -49
- data/test/gir_ffi/info_ext/i_arg_info_test.rb +0 -39
- data/test/gir_ffi/info_ext/i_object_info_test.rb +0 -14
@@ -1,32 +1,45 @@
|
|
1
1
|
require 'gir_ffi_test_helper'
|
2
2
|
|
3
|
-
|
3
|
+
# Dummy module
|
4
|
+
module Bar
|
5
|
+
module Foo
|
6
|
+
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# NOTE: All cooperating classes were originally stubbed, but this became
|
11
|
+
# unweildy as functionality was moved between classes. Also, IArgInfo and
|
12
|
+
# related classes are not really classes controlled by GirFFI, as part of their
|
13
|
+
# interface is dictated by GIR's implementation. Therefore, these tests are
|
14
|
+
# being converted to a situation where they test behavior agains real instances
|
15
|
+
# of IArgInfo.
|
16
|
+
describe GirFFI::Builders::ArgumentBuilder do
|
4
17
|
let(:argument_info) { Object.new }
|
5
18
|
let(:type_info) { Object.new }
|
6
19
|
let(:var_gen) { GirFFI::VariableNameGenerator.new }
|
7
|
-
let(:builder) { GirFFI::ArgumentBuilder.new(var_gen, argument_info) }
|
20
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, argument_info) }
|
21
|
+
let(:conversion_arguments) { [] }
|
22
|
+
let(:argument_class_name) { nil }
|
8
23
|
|
9
24
|
before do
|
10
25
|
stub(argument_info).name { 'foo' }
|
11
26
|
stub(argument_info).argument_type { type_info }
|
12
27
|
stub(argument_info).direction { direction }
|
13
|
-
stub(
|
28
|
+
stub(argument_info).skip? { false }
|
29
|
+
stub(type_info).argument_class_name { argument_class_name }
|
30
|
+
stub(type_info).extra_conversion_arguments { conversion_arguments }
|
14
31
|
end
|
15
32
|
|
16
33
|
describe "for an argument with direction :in" do
|
17
34
|
let(:direction) { :in }
|
18
35
|
|
19
36
|
describe "for :callback" do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
stub(type_info).flattened_tag { :callback }
|
25
|
-
stub(type_info).interface { interface_type_info }
|
26
|
-
end
|
37
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
38
|
+
let(:arg_info) {
|
39
|
+
get_introspection_data('Regress', 'test_callback_destroy_notify').args[0] }
|
27
40
|
|
28
41
|
it "has the correct value for #pre" do
|
29
|
-
builder.pre.must_equal [ "_v1 =
|
42
|
+
builder.pre.must_equal [ "_v1 = ::Regress::TestCallbackUserData.from(callback)" ]
|
30
43
|
end
|
31
44
|
|
32
45
|
it "has the correct value for #post" do
|
@@ -35,9 +48,11 @@ describe GirFFI::ArgumentBuilder do
|
|
35
48
|
end
|
36
49
|
|
37
50
|
describe "for :zero_terminated" do
|
51
|
+
let(:argument_class_name) { 'GirFFI::ZeroTerminated' }
|
52
|
+
let(:conversion_arguments) { [:foo] }
|
53
|
+
|
38
54
|
before do
|
39
55
|
stub(type_info).flattened_tag { :zero_terminated }
|
40
|
-
stub(type_info).element_type { :foo }
|
41
56
|
end
|
42
57
|
|
43
58
|
it "has the correct value for #pre" do
|
@@ -54,63 +69,68 @@ describe GirFFI::ArgumentBuilder do
|
|
54
69
|
let(:direction) { :out }
|
55
70
|
|
56
71
|
describe "for :enum" do
|
57
|
-
|
58
|
-
|
59
|
-
end
|
72
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
73
|
+
let(:arg_info) { get_introspection_data("GIMarshallingTests", "genum_out").args[0] }
|
60
74
|
|
61
75
|
it "has the correct value for #pre" do
|
62
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for
|
76
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for GIMarshallingTests::GEnum" ]
|
63
77
|
end
|
64
78
|
|
65
79
|
it "has the correct value for #post" do
|
66
|
-
builder.post.must_equal [ "_v2 =
|
80
|
+
builder.post.must_equal [ "_v2 = _v1.to_value" ]
|
67
81
|
end
|
68
82
|
end
|
69
83
|
|
70
84
|
describe "for :flags" do
|
71
|
-
|
72
|
-
|
73
|
-
|
85
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
86
|
+
let(:arg_info) {
|
87
|
+
get_introspection_data("GIMarshallingTests", "flags_out").args[0] }
|
74
88
|
|
75
89
|
it "has the correct value for #pre" do
|
76
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for
|
90
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for GIMarshallingTests::Flags" ]
|
77
91
|
end
|
78
92
|
|
79
93
|
it "has the correct value for #post" do
|
80
|
-
builder.post.must_equal [ "_v2 =
|
94
|
+
builder.post.must_equal [ "_v2 = _v1.to_value" ]
|
81
95
|
end
|
82
96
|
end
|
83
97
|
|
84
98
|
describe "for :object" do
|
99
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
100
|
+
let(:arg_info) {
|
101
|
+
get_introspection_data("GIMarshallingTests", "param_spec_out").args[0] }
|
102
|
+
|
85
103
|
before do
|
86
|
-
|
104
|
+
# FIXME: Find alternative info that doesn't need a guard.
|
105
|
+
skip unless get_introspection_data("GIMarshallingTests", "param_spec_out")
|
87
106
|
end
|
88
107
|
|
89
108
|
it "has the correct value for #pre" do
|
90
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for :
|
109
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for [:pointer, GObject::ParamSpec]" ]
|
91
110
|
end
|
92
111
|
|
93
112
|
it "has the correct value for #post" do
|
94
|
-
builder.post.must_equal [ "_v2 =
|
113
|
+
builder.post.must_equal [ "_v2 = ::GObject::ParamSpec.wrap(_v1.to_value)" ]
|
95
114
|
end
|
96
115
|
end
|
97
116
|
|
98
117
|
describe "for :struct" do
|
118
|
+
let(:argument_class_name) { 'Bar::Foo' }
|
99
119
|
before do
|
100
120
|
stub(type_info).flattened_tag { :struct }
|
101
121
|
end
|
102
122
|
|
103
123
|
describe "when not allocated by the caller" do
|
104
|
-
|
105
|
-
|
106
|
-
|
124
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
125
|
+
let(:arg_info) {
|
126
|
+
get_introspection_data("GIMarshallingTests", "boxed_struct_out").args[0] }
|
107
127
|
|
108
128
|
it "has the correct value for #pre" do
|
109
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for :
|
129
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for [:pointer, GIMarshallingTests::BoxedStruct]" ]
|
110
130
|
end
|
111
131
|
|
112
132
|
it "has the correct value for #post" do
|
113
|
-
builder.post.must_equal [ "_v2 =
|
133
|
+
builder.post.must_equal [ "_v2 = ::GIMarshallingTests::BoxedStruct.wrap(_v1.to_value)" ]
|
114
134
|
end
|
115
135
|
end
|
116
136
|
|
@@ -130,12 +150,12 @@ describe GirFFI::ArgumentBuilder do
|
|
130
150
|
end
|
131
151
|
|
132
152
|
describe "for :strv" do
|
133
|
-
|
134
|
-
|
135
|
-
|
153
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
154
|
+
let(:arg_info) {
|
155
|
+
get_introspection_data("GIMarshallingTests", "gstrv_out").args[0] }
|
136
156
|
|
137
157
|
it "has the correct value for #pre" do
|
138
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for :strv" ]
|
158
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for [:pointer, :strv]" ]
|
139
159
|
end
|
140
160
|
|
141
161
|
it "has the correct value for #post" do
|
@@ -144,30 +164,32 @@ describe GirFFI::ArgumentBuilder do
|
|
144
164
|
end
|
145
165
|
|
146
166
|
describe "for :array" do
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
167
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
168
|
+
|
169
|
+
describe "when allocated by the callee" do
|
170
|
+
let(:arg_info) {
|
171
|
+
get_introspection_data("GIMarshallingTests", "garray_utf8_none_out").args[0] }
|
151
172
|
|
152
|
-
context "when allocated by the callee" do
|
153
|
-
before do
|
154
|
-
stub(argument_info).caller_allocates? { false }
|
155
|
-
end
|
156
173
|
it "has the correct value for #pre" do
|
157
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for :array" ]
|
174
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for [:pointer, :array]" ]
|
158
175
|
end
|
159
176
|
|
160
177
|
it "has the correct value for #post" do
|
161
|
-
builder.post.must_equal [ "_v2 = GLib::Array.wrap(:
|
178
|
+
builder.post.must_equal [ "_v2 = GLib::Array.wrap(:utf8, _v1.to_value)" ]
|
162
179
|
end
|
163
180
|
end
|
164
181
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
182
|
+
describe "when allocated by the caller" do
|
183
|
+
let(:arg_info) {
|
184
|
+
get_introspection_data("GIMarshallingTests", "garray_utf8_full_out_caller_allocated").args[0] }
|
185
|
+
|
186
|
+
before do
|
187
|
+
# FIXME: Find alternative info that doesn't need a guard.
|
188
|
+
skip unless get_introspection_data("GIMarshallingTests", "garray_utf8_full_out_caller_allocated")
|
189
|
+
end
|
190
|
+
|
169
191
|
it "has the correct value for #pre" do
|
170
|
-
builder.pre.must_equal [ "_v1 = GLib::Array.new :
|
192
|
+
builder.pre.must_equal [ "_v1 = GLib::Array.new :utf8" ]
|
171
193
|
end
|
172
194
|
|
173
195
|
it "has the correct value for #post" do
|
@@ -177,27 +199,26 @@ describe GirFFI::ArgumentBuilder do
|
|
177
199
|
end
|
178
200
|
|
179
201
|
describe "for :ptr_array" do
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
end
|
202
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
203
|
+
let(:arg_info) {
|
204
|
+
get_introspection_data("GIMarshallingTests", "gptrarray_utf8_none_out").args[0] }
|
184
205
|
|
185
206
|
it "has the correct value for #pre" do
|
186
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for :ptr_array" ]
|
207
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for [:pointer, :ptr_array]" ]
|
187
208
|
end
|
188
209
|
|
189
210
|
it "has the correct value for #post" do
|
190
|
-
builder.post.must_equal [ "_v2 = GLib::PtrArray.wrap(:
|
211
|
+
builder.post.must_equal [ "_v2 = GLib::PtrArray.wrap(:utf8, _v1.to_value)" ]
|
191
212
|
end
|
192
213
|
end
|
193
214
|
|
194
215
|
describe "for :error" do
|
195
|
-
|
196
|
-
|
197
|
-
|
216
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
217
|
+
let(:arg_info) {
|
218
|
+
get_introspection_data("GIMarshallingTests", "gerror_out").args[0] }
|
198
219
|
|
199
220
|
it "has the correct value for #pre" do
|
200
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for :error" ]
|
221
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for [:pointer, :error]" ]
|
201
222
|
end
|
202
223
|
|
203
224
|
it "has the correct value for #post" do
|
@@ -206,85 +227,80 @@ describe GirFFI::ArgumentBuilder do
|
|
206
227
|
end
|
207
228
|
|
208
229
|
describe "for :c" do
|
209
|
-
|
210
|
-
stub(type_info).flattened_tag { :c }
|
211
|
-
stub(type_info).subtype_tag_or_class_name { ":foo" }
|
212
|
-
end
|
230
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
213
231
|
|
214
232
|
describe "with fixed size" do
|
215
|
-
|
216
|
-
|
217
|
-
end
|
233
|
+
let(:arg_info) {
|
234
|
+
get_introspection_data("GIMarshallingTests", "array_fixed_out").args[0] }
|
218
235
|
|
219
236
|
it "has the correct value for #pre" do
|
220
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for :c" ]
|
237
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for [:pointer, :c]" ]
|
221
238
|
end
|
222
239
|
|
223
240
|
it "has the correct value for #post" do
|
224
|
-
builder.post.must_equal [ "_v2 = GLib::SizedArray.wrap(:
|
241
|
+
builder.post.must_equal [ "_v2 = GLib::SizedArray.wrap(:gint32, 4, _v1.to_value)" ]
|
225
242
|
end
|
226
243
|
end
|
227
244
|
|
228
245
|
describe "with separate size parameter" do
|
246
|
+
let(:arg_info) {
|
247
|
+
get_introspection_data("GIMarshallingTests", "array_out").args[0] }
|
248
|
+
|
229
249
|
let(:length_argument) { Object.new }
|
230
250
|
before do
|
231
|
-
stub(type_info).array_fixed_size { -1 }
|
232
251
|
stub(length_argument).retname { "bar" }
|
233
252
|
builder.length_arg = length_argument
|
234
253
|
end
|
235
254
|
|
236
255
|
it "has the correct value for #pre" do
|
237
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for :c" ]
|
256
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for [:pointer, :c]" ]
|
238
257
|
end
|
239
258
|
|
240
259
|
it "has the correct value for #post" do
|
241
|
-
builder.post.must_equal [ "_v2 = GLib::SizedArray.wrap(:
|
260
|
+
builder.post.must_equal [ "_v2 = GLib::SizedArray.wrap(:gint32, bar, _v1.to_value)" ]
|
242
261
|
end
|
243
262
|
end
|
244
263
|
end
|
245
264
|
|
246
265
|
describe "for :glist" do
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
end
|
266
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
267
|
+
let(:arg_info) {
|
268
|
+
get_introspection_data("GIMarshallingTests", "glist_utf8_none_out").args[0] }
|
251
269
|
|
252
270
|
it "has the correct value for #pre" do
|
253
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for :glist" ]
|
271
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for [:pointer, :glist]" ]
|
254
272
|
end
|
255
273
|
|
256
274
|
it "has the correct value for #post" do
|
257
|
-
builder.post.must_equal [ "_v2 = GLib::List.wrap(:
|
275
|
+
builder.post.must_equal [ "_v2 = GLib::List.wrap(:utf8, _v1.to_value)" ]
|
258
276
|
end
|
259
277
|
end
|
260
278
|
|
261
279
|
describe "for :gslist" do
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
end
|
280
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
281
|
+
let(:arg_info) {
|
282
|
+
get_introspection_data("GIMarshallingTests", "gslist_utf8_none_out").args[0] }
|
266
283
|
|
267
284
|
it "has the correct value for #pre" do
|
268
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for :gslist" ]
|
285
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for [:pointer, :gslist]" ]
|
269
286
|
end
|
270
287
|
|
271
288
|
it "has the correct value for #post" do
|
272
|
-
builder.post.must_equal [ "_v2 = GLib::SList.wrap(:
|
289
|
+
builder.post.must_equal [ "_v2 = GLib::SList.wrap(:utf8, _v1.to_value)" ]
|
273
290
|
end
|
274
291
|
end
|
275
292
|
|
276
293
|
describe "for :ghash" do
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
end
|
294
|
+
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
295
|
+
let(:arg_info) {
|
296
|
+
get_introspection_data("GIMarshallingTests", "ghashtable_utf8_none_out").args[0] }
|
281
297
|
|
282
298
|
it "has the correct value for #pre" do
|
283
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for :ghash" ]
|
299
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.for [:pointer, :ghash]" ]
|
284
300
|
end
|
285
301
|
|
286
302
|
it "has the correct value for #post" do
|
287
|
-
builder.post.must_equal [ "_v2 = GLib::HashTable.wrap([:
|
303
|
+
builder.post.must_equal [ "_v2 = GLib::HashTable.wrap([:utf8, :utf8], _v1.to_value)" ]
|
288
304
|
end
|
289
305
|
end
|
290
306
|
end
|
@@ -293,36 +309,45 @@ describe GirFFI::ArgumentBuilder do
|
|
293
309
|
let(:direction) { :inout }
|
294
310
|
|
295
311
|
describe "for :enum" do
|
312
|
+
let(:argument_class_name) { 'Bar::Foo' }
|
296
313
|
before do
|
297
314
|
stub(type_info).flattened_tag { :enum }
|
315
|
+
stub(type_info).tag_or_class { Bar::Foo }
|
298
316
|
end
|
299
317
|
|
300
318
|
it "has the correct value for #pre" do
|
301
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.from
|
319
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.from Bar::Foo, foo" ]
|
302
320
|
end
|
303
321
|
|
304
322
|
it "has the correct value for #post" do
|
305
|
-
builder.post.must_equal [ "_v2 =
|
323
|
+
builder.post.must_equal [ "_v2 = _v1.to_value" ]
|
306
324
|
end
|
307
325
|
end
|
308
326
|
|
309
327
|
describe "for :flags" do
|
328
|
+
let(:argument_class_name) { 'Bar::Foo' }
|
310
329
|
before do
|
311
330
|
stub(type_info).flattened_tag { :flags }
|
331
|
+
stub(type_info).tag_or_class { Bar::Foo }
|
312
332
|
end
|
313
333
|
|
314
334
|
it "has the correct value for #pre" do
|
315
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.from
|
335
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.from Bar::Foo, foo" ]
|
316
336
|
end
|
317
337
|
|
318
338
|
it "has the correct value for #post" do
|
319
|
-
builder.post.must_equal [ "_v2 =
|
339
|
+
builder.post.must_equal [ "_v2 = _v1.to_value" ]
|
320
340
|
end
|
321
341
|
end
|
322
342
|
|
323
343
|
describe "for :gint32" do
|
324
344
|
before do
|
325
345
|
stub(type_info).flattened_tag { :gint32 }
|
346
|
+
stub(type_info).tag_or_class { :gint32 }
|
347
|
+
end
|
348
|
+
|
349
|
+
it "has the correct value for inarg" do
|
350
|
+
builder.inarg.must_equal "foo"
|
326
351
|
end
|
327
352
|
|
328
353
|
it "has the correct value for #pre" do
|
@@ -335,16 +360,22 @@ describe GirFFI::ArgumentBuilder do
|
|
335
360
|
end
|
336
361
|
|
337
362
|
describe "for an array length" do
|
338
|
-
let(:
|
363
|
+
let(:function_info) {
|
364
|
+
get_introspection_data('Regress', 'test_array_int_inout') }
|
365
|
+
let(:arg_info) { function_info.args[0] }
|
366
|
+
let(:array_arg_info) { function_info.args[1] }
|
367
|
+
let(:builder) {
|
368
|
+
GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
369
|
+
let(:array_arg_builder) {
|
370
|
+
GirFFI::Builders::ArgumentBuilder.new(var_gen, array_arg_info) }
|
371
|
+
|
339
372
|
before do
|
340
|
-
|
341
|
-
stub(array_argument).name { "foo_array" }
|
342
|
-
builder.array_arg = array_argument
|
373
|
+
builder.array_arg = array_arg_builder
|
343
374
|
end
|
344
375
|
|
345
376
|
it "has the correct value for #pre" do
|
346
|
-
builder.pre.must_equal [ "
|
347
|
-
"_v1 = GirFFI::InOutPointer.from :gint32,
|
377
|
+
builder.pre.must_equal [ "n_ints = ints.nil? ? 0 : ints.length",
|
378
|
+
"_v1 = GirFFI::InOutPointer.from :gint32, n_ints" ]
|
348
379
|
end
|
349
380
|
|
350
381
|
it "has the correct value for #post" do
|
@@ -353,12 +384,14 @@ describe GirFFI::ArgumentBuilder do
|
|
353
384
|
end
|
354
385
|
|
355
386
|
describe "for :strv" do
|
387
|
+
let(:argument_class_name) { 'GLib::Strv' }
|
356
388
|
before do
|
357
389
|
stub(type_info).flattened_tag { :strv }
|
390
|
+
stub(type_info).tag_or_class { [:pointer, :array] }
|
358
391
|
end
|
359
392
|
|
360
393
|
it "has the correct value for #pre" do
|
361
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.from :
|
394
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.from [:pointer, :array], GLib::Strv.from(foo)" ]
|
362
395
|
end
|
363
396
|
|
364
397
|
it "has the correct value for #post" do
|
@@ -367,13 +400,16 @@ describe GirFFI::ArgumentBuilder do
|
|
367
400
|
end
|
368
401
|
|
369
402
|
describe "for :ptr_array" do
|
403
|
+
let(:conversion_arguments) { [:foo] }
|
404
|
+
let(:argument_class_name) { 'GLib::PtrArray' }
|
405
|
+
|
370
406
|
before do
|
371
407
|
stub(type_info).flattened_tag { :ptr_array }
|
372
|
-
stub(type_info).
|
408
|
+
stub(type_info).tag_or_class { [:pointer, :array] }
|
373
409
|
end
|
374
410
|
|
375
411
|
it "has the correct value for #pre" do
|
376
|
-
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.from :
|
412
|
+
builder.pre.must_equal [ "_v1 = GirFFI::InOutPointer.from [:pointer, :array], GLib::PtrArray.from(:foo, foo)" ]
|
377
413
|
end
|
378
414
|
|
379
415
|
it "has the correct value for #post" do
|
@@ -382,8 +418,12 @@ describe GirFFI::ArgumentBuilder do
|
|
382
418
|
end
|
383
419
|
|
384
420
|
describe "for :utf8" do
|
421
|
+
let(:conversion_arguments) { [:utf8] }
|
422
|
+
let(:argument_class_name) { 'GirFFI::InPointer' }
|
423
|
+
|
385
424
|
before do
|
386
425
|
stub(type_info).flattened_tag { :utf8 }
|
426
|
+
stub(type_info).tag_or_class { :utf8 }
|
387
427
|
end
|
388
428
|
|
389
429
|
it "has the correct value for #pre" do
|
@@ -391,17 +431,22 @@ describe GirFFI::ArgumentBuilder do
|
|
391
431
|
end
|
392
432
|
|
393
433
|
it "has the correct value for #post" do
|
394
|
-
builder.post.must_equal [ "_v2 =
|
434
|
+
builder.post.must_equal [ "_v2 = _v1.to_value.to_utf8" ]
|
395
435
|
end
|
396
436
|
end
|
397
437
|
|
398
438
|
describe "for :c" do
|
439
|
+
let(:argument_class_name) { 'GLib::SizedArray' }
|
440
|
+
|
399
441
|
before do
|
400
442
|
stub(type_info).flattened_tag { :c }
|
401
|
-
stub(type_info).
|
443
|
+
stub(type_info).tag_or_class { [:pointer, :c] }
|
444
|
+
stub(type_info).subtype_tag_or_class { :bar }
|
402
445
|
end
|
403
446
|
|
404
447
|
describe "with fixed size" do
|
448
|
+
let(:conversion_arguments) { [:bar, 3] }
|
449
|
+
|
405
450
|
before do
|
406
451
|
stub(type_info).array_fixed_size { 3 }
|
407
452
|
end
|
@@ -409,7 +454,7 @@ describe GirFFI::ArgumentBuilder do
|
|
409
454
|
it "has the correct value for #pre" do
|
410
455
|
builder.pre.must_equal [
|
411
456
|
"GirFFI::ArgHelper.check_fixed_array_size 3, foo, \"foo\"",
|
412
|
-
"_v1 = GirFFI::InOutPointer.from :c, GLib::SizedArray.from(:bar, 3, foo)"
|
457
|
+
"_v1 = GirFFI::InOutPointer.from [:pointer, :c], GLib::SizedArray.from(:bar, 3, foo)"
|
413
458
|
]
|
414
459
|
end
|
415
460
|
|
@@ -420,6 +465,7 @@ describe GirFFI::ArgumentBuilder do
|
|
420
465
|
|
421
466
|
describe "with separate size parameter" do
|
422
467
|
let(:length_argument) { Object.new }
|
468
|
+
let(:conversion_arguments) { [:bar, -1] }
|
423
469
|
before do
|
424
470
|
stub(type_info).array_fixed_size { -1 }
|
425
471
|
stub(length_argument).retname { "baz" }
|
@@ -427,9 +473,8 @@ describe GirFFI::ArgumentBuilder do
|
|
427
473
|
end
|
428
474
|
|
429
475
|
it "has the correct value for #pre" do
|
430
|
-
# TODO: Perhaps this should include a length check as well.
|
431
476
|
builder.pre.must_equal [
|
432
|
-
"_v1 = GirFFI::InOutPointer.from :c, GLib::SizedArray.from(:bar, -1, foo)"
|
477
|
+
"_v1 = GirFFI::InOutPointer.from [:pointer, :c], GLib::SizedArray.from(:bar, -1, foo)"
|
433
478
|
]
|
434
479
|
end
|
435
480
|
|
@@ -439,5 +484,82 @@ describe GirFFI::ArgumentBuilder do
|
|
439
484
|
end
|
440
485
|
end
|
441
486
|
end
|
442
|
-
end
|
443
487
|
|
488
|
+
describe "for a skipped argument with direction :in" do
|
489
|
+
let(:direction) { :in }
|
490
|
+
|
491
|
+
before do
|
492
|
+
stub(argument_info).skip? { true }
|
493
|
+
end
|
494
|
+
|
495
|
+
describe "for :gint32" do
|
496
|
+
before do
|
497
|
+
stub(type_info).flattened_tag { :gint32 }
|
498
|
+
end
|
499
|
+
|
500
|
+
it "has the correct value for inarg" do
|
501
|
+
builder.inarg.must_be_nil
|
502
|
+
end
|
503
|
+
|
504
|
+
it "has the correct value for #pre" do
|
505
|
+
builder.pre.must_equal [ "_v1 = 0" ]
|
506
|
+
end
|
507
|
+
|
508
|
+
it "has the correct value for #post" do
|
509
|
+
builder.post.must_equal []
|
510
|
+
end
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
describe "for a skipped argument with direction :inout" do
|
515
|
+
let(:direction) { :inout }
|
516
|
+
|
517
|
+
before do
|
518
|
+
stub(argument_info).skip? { true }
|
519
|
+
end
|
520
|
+
|
521
|
+
describe "for :gint32" do
|
522
|
+
before do
|
523
|
+
stub(type_info).flattened_tag { :gint32 }
|
524
|
+
end
|
525
|
+
|
526
|
+
it "has the correct value for inarg" do
|
527
|
+
builder.inarg.must_be_nil
|
528
|
+
end
|
529
|
+
|
530
|
+
it "has the correct value for #pre" do
|
531
|
+
builder.pre.must_equal [ "_v1 = nil" ]
|
532
|
+
end
|
533
|
+
|
534
|
+
it "has the correct value for #post" do
|
535
|
+
builder.post.must_equal []
|
536
|
+
end
|
537
|
+
end
|
538
|
+
end
|
539
|
+
|
540
|
+
describe "for a skipped argument with direction :out" do
|
541
|
+
let(:direction) { :out }
|
542
|
+
|
543
|
+
before do
|
544
|
+
stub(argument_info).skip? { true }
|
545
|
+
end
|
546
|
+
|
547
|
+
describe "for :gint32" do
|
548
|
+
before do
|
549
|
+
stub(type_info).flattened_tag { :gint32 }
|
550
|
+
end
|
551
|
+
|
552
|
+
it "has the correct value for inarg" do
|
553
|
+
builder.inarg.must_be_nil
|
554
|
+
end
|
555
|
+
|
556
|
+
it "has the correct value for #pre" do
|
557
|
+
builder.pre.must_equal [ "_v1 = nil" ]
|
558
|
+
end
|
559
|
+
|
560
|
+
it "has the correct value for #post" do
|
561
|
+
builder.post.must_equal []
|
562
|
+
end
|
563
|
+
end
|
564
|
+
end
|
565
|
+
end
|