gir_ffi 0.15.3 → 0.15.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +15 -0
- data/README.md +5 -6
- data/TODO.md +14 -35
- data/docs/Documentation.md +6 -0
- data/docs/Subclassing.md +38 -0
- data/lib/ffi-glib.rb +8 -3
- data/lib/ffi-glib/byte_array.rb +2 -1
- data/lib/ffi-glib/destroy_notify.rb +2 -2
- data/lib/ffi-glib/hash_table.rb +1 -2
- data/lib/ffi-glib/list.rb +11 -5
- data/lib/ffi-glib/list_methods.rb +12 -0
- data/lib/ffi-glib/s_list.rb +10 -4
- data/lib/ffi-gobject.rb +0 -3
- data/lib/ffi-gobject/object.rb +77 -73
- data/lib/ffi-gobject/object_class.rb +1 -1
- data/lib/ffi-gobject/value.rb +107 -108
- data/lib/ffi-gobject_introspection/i_base_info.rb +20 -19
- data/lib/gir_ffi-base/gobject/lib.rb +4 -0
- data/lib/gir_ffi/array_element_convertor.rb +1 -2
- data/lib/gir_ffi/boxed_base.rb +1 -5
- data/lib/gir_ffi/builder.rb +1 -1
- data/lib/gir_ffi/builder_helper.rb +7 -4
- data/lib/gir_ffi/builders/base_argument_builder.rb +2 -2
- data/lib/gir_ffi/builders/base_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
- data/lib/gir_ffi/builders/callback_argument_builder.rb +2 -0
- data/lib/gir_ffi/builders/callback_builder.rb +14 -12
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +4 -6
- data/lib/gir_ffi/builders/class_struct_builder.rb +24 -0
- data/lib/gir_ffi/builders/enum_builder.rb +3 -3
- data/lib/gir_ffi/builders/interface_builder.rb +3 -1
- data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +5 -2
- data/lib/gir_ffi/builders/method_template.rb +4 -4
- data/lib/gir_ffi/builders/null_argument_builder.rb +0 -2
- data/lib/gir_ffi/builders/null_return_value_builder.rb +0 -2
- data/lib/gir_ffi/builders/object_builder.rb +16 -6
- data/lib/gir_ffi/builders/property_builder.rb +1 -2
- data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -5
- data/lib/gir_ffi/builders/struct_builder.rb +5 -5
- data/lib/gir_ffi/builders/user_defined_builder.rb +8 -1
- data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
- data/lib/gir_ffi/callback_base.rb +3 -3
- data/lib/gir_ffi/core.rb +17 -2
- data/lib/gir_ffi/glib_error.rb +1 -2
- data/lib/gir_ffi/in_pointer.rb +7 -0
- data/lib/gir_ffi/object_base.rb +27 -0
- data/lib/gir_ffi/return_value_info.rb +1 -2
- data/lib/gir_ffi/struct_base.rb +1 -9
- data/lib/gir_ffi/struct_like_base.rb +9 -5
- data/lib/gir_ffi/unintrospectable_type_info.rb +1 -1
- data/lib/gir_ffi/union_base.rb +1 -9
- data/lib/gir_ffi/user_defined_object_info.rb +3 -2
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi/vfunc_implementation.rb +1 -0
- metadata +86 -136
- data/Gemfile +0 -14
- data/Rakefile +0 -9
- data/tasks/test.rake +0 -204
- data/test/base_test_helper.rb +0 -70
- data/test/ffi-glib/array_test.rb +0 -203
- data/test/ffi-glib/byte_array_test.rb +0 -28
- data/test/ffi-glib/bytes_test.rb +0 -61
- data/test/ffi-glib/closure_test.rb +0 -38
- data/test/ffi-glib/destroy_notify_test.rb +0 -18
- data/test/ffi-glib/hash_table_test.rb +0 -68
- data/test/ffi-glib/list_test.rb +0 -86
- data/test/ffi-glib/main_loop_test.rb +0 -53
- data/test/ffi-glib/ptr_array_test.rb +0 -112
- data/test/ffi-glib/ruby_closure_test.rb +0 -62
- data/test/ffi-glib/s_list_test.rb +0 -76
- data/test/ffi-glib/strv_test.rb +0 -60
- data/test/ffi-glib/variant_test.rb +0 -12
- data/test/ffi-gobject/gobject_test.rb +0 -76
- data/test/ffi-gobject/object_class_test.rb +0 -31
- data/test/ffi-gobject/object_test.rb +0 -123
- data/test/ffi-gobject/param_spec_test.rb +0 -32
- data/test/ffi-gobject/value_test.rb +0 -390
- data/test/ffi-gobject_introspection/gobject_type_init_test.rb +0 -26
- data/test/ffi-gobject_introspection/i_base_info_test.rb +0 -52
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +0 -29
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +0 -18
- data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -6
- data/test/ffi-gobject_introspection/i_interface_info_test.rb +0 -23
- data/test/ffi-gobject_introspection/i_object_info_test.rb +0 -49
- data/test/ffi-gobject_introspection/i_property_info_test.rb +0 -47
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +0 -27
- data/test/ffi-gobject_introspection/i_repository_test.rb +0 -81
- data/test/ffi-gobject_introspection/i_struct_info_test.rb +0 -23
- data/test/ffi-gobject_introspection/i_type_info_test.rb +0 -30
- data/test/ffi-gobject_introspection/i_union_info_test.rb +0 -17
- data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +0 -41
- data/test/ffi-gobject_introspection/lib_test.rb +0 -13
- data/test/ffi-gobject_introspection/strv_test.rb +0 -46
- data/test/ffi-gobject_test.rb +0 -153
- data/test/gir_ffi/allocation_helper_test.rb +0 -36
- data/test/gir_ffi/arg_helper_test.rb +0 -146
- data/test/gir_ffi/boolean_test.rb +0 -43
- data/test/gir_ffi/boxed_base_test.rb +0 -65
- data/test/gir_ffi/builder_test.rb +0 -168
- data/test/gir_ffi/builders/argument_builder_test.rb +0 -691
- data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -6
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +0 -130
- data/test/gir_ffi/builders/callback_builder_test.rb +0 -117
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +0 -84
- data/test/gir_ffi/builders/constant_builder_test.rb +0 -6
- data/test/gir_ffi/builders/constructor_builder_test.rb +0 -39
- data/test/gir_ffi/builders/enum_builder_test.rb +0 -23
- data/test/gir_ffi/builders/field_builder_test.rb +0 -140
- data/test/gir_ffi/builders/function_builder_test.rb +0 -570
- data/test/gir_ffi/builders/initializer_builder_test.rb +0 -56
- data/test/gir_ffi/builders/interface_builder_test.rb +0 -32
- data/test/gir_ffi/builders/module_builder_test.rb +0 -43
- data/test/gir_ffi/builders/object_builder_test.rb +0 -98
- data/test/gir_ffi/builders/property_builder_test.rb +0 -161
- data/test/gir_ffi/builders/registered_type_builder_test.rb +0 -54
- data/test/gir_ffi/builders/return_value_builder_test.rb +0 -444
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +0 -199
- data/test/gir_ffi/builders/struct_builder_test.rb +0 -96
- data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +0 -29
- data/test/gir_ffi/builders/unintrospectable_builder_test.rb +0 -84
- data/test/gir_ffi/builders/union_builder_test.rb +0 -28
- data/test/gir_ffi/builders/user_defined_builder_test.rb +0 -528
- data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +0 -107
- data/test/gir_ffi/builders/vfunc_builder_test.rb +0 -245
- data/test/gir_ffi/callback_base_test.rb +0 -22
- data/test/gir_ffi/class_base_test.rb +0 -171
- data/test/gir_ffi/core_test.rb +0 -99
- data/test/gir_ffi/enum_base_test.rb +0 -43
- data/test/gir_ffi/error_type_info_test.rb +0 -50
- data/test/gir_ffi/ffi_ext/pointer_test.rb +0 -22
- data/test/gir_ffi/g_type_test.rb +0 -31
- data/test/gir_ffi/in_pointer_test.rb +0 -203
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +0 -26
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +0 -22
- data/test/gir_ffi/info_ext/i_field_info_test.rb +0 -37
- data/test/gir_ffi/info_ext/i_function_info_test.rb +0 -74
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +0 -32
- data/test/gir_ffi/info_ext/i_type_info_test.rb +0 -712
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +0 -19
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +0 -26
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +0 -26
- data/test/gir_ffi/interface_base_test.rb +0 -20
- data/test/gir_ffi/method_stubber_test.rb +0 -67
- data/test/gir_ffi/object_base_test.rb +0 -64
- data/test/gir_ffi/object_store_test.rb +0 -41
- data/test/gir_ffi/receiver_argument_info_test.rb +0 -33
- data/test/gir_ffi/sized_array_test.rb +0 -206
- data/test/gir_ffi/struct_base_test.rb +0 -23
- data/test/gir_ffi/struct_like_base_test.rb +0 -167
- data/test/gir_ffi/type_map_test.rb +0 -17
- data/test/gir_ffi/unintrospectable_type_info_test.rb +0 -121
- data/test/gir_ffi/union_base_test.rb +0 -23
- data/test/gir_ffi/user_defined_object_info_test.rb +0 -119
- data/test/gir_ffi/user_defined_property_info_test.rb +0 -39
- data/test/gir_ffi/variable_name_generator_test.rb +0 -18
- data/test/gir_ffi/version_test.rb +0 -9
- data/test/gir_ffi/zero_terminated_test.rb +0 -108
- data/test/gir_ffi_test_helper.rb +0 -84
- data/test/integration/callback_exceptions_test.rb +0 -59
- data/test/integration/derived_classes_test.rb +0 -54
- data/test/integration/generated_everything_test.rb +0 -453
- data/test/integration/generated_gimarshallingtests_test.rb +0 -3109
- data/test/integration/generated_gio_test.rb +0 -116
- data/test/integration/generated_glib_test.rb +0 -10
- data/test/integration/generated_gobject_test.rb +0 -124
- data/test/integration/generated_gst_test.rb +0 -38
- data/test/integration/generated_gtk_source_test.rb +0 -21
- data/test/integration/generated_gtop_test.rb +0 -22
- data/test/integration/generated_pango_ft2_test.rb +0 -17
- data/test/integration/generated_pango_test.rb +0 -24
- data/test/integration/generated_regress_test.rb +0 -4076
- data/test/integration/generated_secret_test.rb +0 -14
- data/test/integration/generated_utility_test.rb +0 -174
- data/test/integration/generated_warnlib_test.rb +0 -45
- data/test/integration/method_lookup_test.rb +0 -34
- data/test/introspection_test_helper.rb +0 -94
- data/test/lib/Makefile.am +0 -110
- data/test/lib/autogen.sh +0 -4
- data/test/lib/configure.ac +0 -34
- data/test/lib/m4/jhflags.m4 +0 -21
- data/test/minitest/stats_plugin.rb +0 -30
@@ -1,570 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
describe GirFFI::Builders::FunctionBuilder do
|
6
|
-
describe "#method_definition" do
|
7
|
-
let(:builder) { GirFFI::Builders::FunctionBuilder.new function_info }
|
8
|
-
let(:code) { builder.method_definition }
|
9
|
-
|
10
|
-
describe "generally" do
|
11
|
-
let(:function_info) do
|
12
|
-
get_method_introspection_data "GObject", "Object", "get_property"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns the same result when called twice" do
|
16
|
-
original = builder.method_definition
|
17
|
-
copy = builder.method_definition
|
18
|
-
_(copy).must_equal original
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "for Regress:test_array_fixed_out_objects" do
|
23
|
-
let(:function_info) do
|
24
|
-
get_introspection_data "Regress", "test_array_fixed_out_objects"
|
25
|
-
end
|
26
|
-
it "builds a correct definition" do
|
27
|
-
_(code).must_equal <<~CODE
|
28
|
-
def self.test_array_fixed_out_objects
|
29
|
-
_v1 = FFI::MemoryPointer.new :pointer
|
30
|
-
Regress::Lib.regress_test_array_fixed_out_objects _v1
|
31
|
-
_v2 = GirFFI::SizedArray.wrap([:pointer, Regress::TestObj], 2, _v1.get_pointer(0))
|
32
|
-
return _v2
|
33
|
-
end
|
34
|
-
CODE
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "for functions having a linked length argument" do
|
39
|
-
let(:function_info) { get_introspection_data "Regress", "test_array_gint16_in" }
|
40
|
-
it "builds a correct definition" do
|
41
|
-
_(code).must_equal <<~CODE
|
42
|
-
def self.test_array_gint16_in(ints)
|
43
|
-
n_ints = ints.nil? ? 0 : ints.length
|
44
|
-
_v1 = n_ints
|
45
|
-
_v2 = GirFFI::SizedArray.from(:gint16, -1, ints)
|
46
|
-
_v3 = Regress::Lib.regress_test_array_gint16_in _v1, _v2
|
47
|
-
return _v3
|
48
|
-
end
|
49
|
-
CODE
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "for methods taking a zero-terminated array with length argument" do
|
54
|
-
let(:function_info) do
|
55
|
-
get_method_introspection_data "Regress", "AnnotationObject", "parse_args"
|
56
|
-
end
|
57
|
-
it "builds a correct definition" do
|
58
|
-
_(code).must_equal <<~CODE
|
59
|
-
def parse_args(argv)
|
60
|
-
argc = argv.nil? ? 0 : argv.length
|
61
|
-
_v1 = FFI::MemoryPointer.new :int32
|
62
|
-
_v1.put_int32 0, argc
|
63
|
-
_v2 = FFI::MemoryPointer.new :pointer
|
64
|
-
_v2.put_pointer 0, GLib::Strv.from(argv)
|
65
|
-
Regress::Lib.regress_annotation_object_parse_args self, _v1, _v2
|
66
|
-
_v3 = GLib::Strv.wrap(_v2.get_pointer(0))
|
67
|
-
return _v3
|
68
|
-
end
|
69
|
-
CODE
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "for functions with callbacks" do
|
74
|
-
let(:function_info) do
|
75
|
-
get_introspection_data "Regress", "test_callback_destroy_notify"
|
76
|
-
end
|
77
|
-
it "builds a correct definition" do
|
78
|
-
_(code).must_equal <<~CODE
|
79
|
-
def self.test_callback_destroy_notify(&callback)
|
80
|
-
_v1 = Regress::TestCallbackUserData.from(callback)
|
81
|
-
_v2 = GirFFI::ArgHelper.store(_v1)
|
82
|
-
_v3 = GLib::DestroyNotify.default
|
83
|
-
_v4 = Regress::Lib.regress_test_callback_destroy_notify _v1, _v2, _v3
|
84
|
-
return _v4
|
85
|
-
end
|
86
|
-
CODE
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "for functions that take a GValue" do
|
91
|
-
let(:function_info) { get_introspection_data "GIMarshallingTests", "gvalue_in" }
|
92
|
-
it "creates a call to GObject::Value#from" do
|
93
|
-
_(code).must_equal <<~CODE
|
94
|
-
def self.gvalue_in(value)
|
95
|
-
_v1 = GObject::Value.from(value)
|
96
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_in _v1
|
97
|
-
end
|
98
|
-
CODE
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "for functions that return a GValue" do
|
103
|
-
let(:function_info) { get_introspection_data "GIMarshallingTests", "gvalue_return" }
|
104
|
-
it "creates a call to #get_value" do
|
105
|
-
_(code).must_equal <<~CODE
|
106
|
-
def self.gvalue_return
|
107
|
-
_v1 = GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_return
|
108
|
-
_v2 = GObject::Value.wrap(_v1).get_value
|
109
|
-
return _v2
|
110
|
-
end
|
111
|
-
CODE
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "for functions that have a GValue out argument" do
|
116
|
-
let(:function_info) { get_introspection_data "GIMarshallingTests", "gvalue_out" }
|
117
|
-
it "creates a call to #get_value" do
|
118
|
-
_(code).must_equal <<~CODE
|
119
|
-
def self.gvalue_out
|
120
|
-
_v1 = FFI::MemoryPointer.new :pointer
|
121
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_out _v1
|
122
|
-
_v2 = GObject::Value.wrap(_v1.get_pointer(0)).get_value
|
123
|
-
return _v2
|
124
|
-
end
|
125
|
-
CODE
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe "for functions that have a caller-allocated GValue out argument" do
|
130
|
-
let(:function_info) do
|
131
|
-
get_introspection_data "GIMarshallingTests", "gvalue_out_caller_allocates"
|
132
|
-
end
|
133
|
-
|
134
|
-
it "creates a call to #get_value" do
|
135
|
-
_(code).must_equal <<~CODE
|
136
|
-
def self.gvalue_out_caller_allocates
|
137
|
-
_v1 = GObject::Value.new
|
138
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_out_caller_allocates _v1
|
139
|
-
_v2 = _v1.get_value
|
140
|
-
return _v2
|
141
|
-
end
|
142
|
-
CODE
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
describe "for functions with a nullable input array" do
|
147
|
-
let(:function_info) { get_introspection_data "Regress", "test_array_int_null_in" }
|
148
|
-
it "builds correct definition" do
|
149
|
-
_(code).must_equal <<~CODE
|
150
|
-
def self.test_array_int_null_in(arr = nil)
|
151
|
-
len = arr.nil? ? 0 : arr.length
|
152
|
-
_v1 = len
|
153
|
-
_v2 = GirFFI::SizedArray.from(:gint32, -1, arr)
|
154
|
-
Regress::Lib.regress_test_array_int_null_in _v2, _v1
|
155
|
-
end
|
156
|
-
CODE
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe "for functions with a nullable output array" do
|
161
|
-
let(:function_info) { get_introspection_data "Regress", "test_array_int_null_out" }
|
162
|
-
it "builds correct definition" do
|
163
|
-
_(code).must_equal <<~CODE
|
164
|
-
def self.test_array_int_null_out
|
165
|
-
_v1 = FFI::MemoryPointer.new :int32
|
166
|
-
_v2 = FFI::MemoryPointer.new :pointer
|
167
|
-
Regress::Lib.regress_test_array_int_null_out _v2, _v1
|
168
|
-
_v3 = _v1.get_int32(0)
|
169
|
-
_v4 = GirFFI::SizedArray.wrap(:gint32, _v3, _v2.get_pointer(0))
|
170
|
-
return _v4
|
171
|
-
end
|
172
|
-
CODE
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe "for a method with an inout array with size argument" do
|
177
|
-
let(:function_info) do
|
178
|
-
get_method_introspection_data "GIMarshallingTests", "Object", "method_array_inout"
|
179
|
-
end
|
180
|
-
it "builds the correct definition" do
|
181
|
-
_(code).must_equal <<~CODE
|
182
|
-
def method_array_inout(ints)
|
183
|
-
length = ints.nil? ? 0 : ints.length
|
184
|
-
_v1 = FFI::MemoryPointer.new :int32
|
185
|
-
_v1.put_int32 0, length
|
186
|
-
_v2 = FFI::MemoryPointer.new :pointer
|
187
|
-
_v2.put_pointer 0, GirFFI::SizedArray.from(:gint32, -1, ints)
|
188
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_object_method_array_inout self, _v2, _v1
|
189
|
-
_v3 = _v1.get_int32(0)
|
190
|
-
_v4 = GirFFI::SizedArray.wrap(:gint32, _v3, _v2.get_pointer(0))
|
191
|
-
return _v4
|
192
|
-
end
|
193
|
-
CODE
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
describe "for a simple method" do
|
198
|
-
let(:function_info) do
|
199
|
-
get_method_introspection_data "Regress", "TestObj", "instance_method"
|
200
|
-
end
|
201
|
-
|
202
|
-
it "builds a correct definition" do
|
203
|
-
_(code).must_equal <<~CODE
|
204
|
-
def instance_method
|
205
|
-
_v1 = Regress::Lib.regress_test_obj_instance_method self
|
206
|
-
return _v1
|
207
|
-
end
|
208
|
-
CODE
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe "for GLib::Variant.get_strv" do
|
213
|
-
let(:function_info) { get_method_introspection_data "GLib", "Variant", "get_strv" }
|
214
|
-
it "builds a correct definition" do
|
215
|
-
size_type = ":uint#{FFI.type_size(:size_t) * 8}"
|
216
|
-
_(code).must_equal <<~CODE
|
217
|
-
def get_strv
|
218
|
-
_v1 = FFI::MemoryPointer.new #{size_type}
|
219
|
-
_v2 = GLib::Lib.g_variant_get_strv self, _v1
|
220
|
-
_v3 = GLib::Strv.wrap(_v2)
|
221
|
-
return _v3
|
222
|
-
end
|
223
|
-
CODE
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
describe "for Regress.has_parameter_named_attrs" do
|
228
|
-
let(:function_info) { get_introspection_data "Regress", "has_parameter_named_attrs" }
|
229
|
-
|
230
|
-
it "builds a correct definition" do
|
231
|
-
_(code).must_equal <<~CODE
|
232
|
-
def self.has_parameter_named_attrs(foo, attributes)
|
233
|
-
_v1 = foo
|
234
|
-
GirFFI::ArgHelper.check_fixed_array_size 32, attributes, \"attributes\"
|
235
|
-
_v2 = GirFFI::SizedArray.from([:pointer, :guint32], 32, attributes)
|
236
|
-
Regress::Lib.regress_has_parameter_named_attrs _v1, _v2
|
237
|
-
end
|
238
|
-
CODE
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
describe "for GIMarshallingTests::Object#method_int8_arg_and_out_callee" do
|
243
|
-
let(:function_info) do
|
244
|
-
get_method_introspection_data("GIMarshallingTests", "Object",
|
245
|
-
"method_int8_arg_and_out_callee")
|
246
|
-
end
|
247
|
-
|
248
|
-
it "builds a correct definition" do
|
249
|
-
_(code).must_equal <<~CODE
|
250
|
-
def method_int8_arg_and_out_callee(arg)
|
251
|
-
_v1 = arg
|
252
|
-
_v2 = FFI::MemoryPointer.new :pointer
|
253
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_object_method_int8_arg_and_out_callee self, _v1, _v2
|
254
|
-
_v3 = _v2.get_pointer(0).get_int8(0)
|
255
|
-
return _v3
|
256
|
-
end
|
257
|
-
CODE
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
describe "object ownership transfer" do
|
262
|
-
describe "for GIMarshallingTests::Object#full_in" do
|
263
|
-
let(:function_info) do
|
264
|
-
get_method_introspection_data("GIMarshallingTests", "Object",
|
265
|
-
"full_in")
|
266
|
-
end
|
267
|
-
|
268
|
-
# NOTE: This method is transfer-ownership: none, despite the name.
|
269
|
-
it "builds a correct definition" do
|
270
|
-
_(code).must_equal <<~CODE
|
271
|
-
def full_in
|
272
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_object_full_in self
|
273
|
-
end
|
274
|
-
CODE
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
describe "for GIMarshallingTests::Object.full_inout" do
|
279
|
-
let(:function_info) do
|
280
|
-
get_method_introspection_data("GIMarshallingTests", "Object",
|
281
|
-
"full_inout")
|
282
|
-
end
|
283
|
-
|
284
|
-
it "builds a correct definition" do
|
285
|
-
_(code).must_equal <<~CODE
|
286
|
-
def self.full_inout(object)
|
287
|
-
_v1 = FFI::MemoryPointer.new :pointer
|
288
|
-
_v1.put_pointer 0, GIMarshallingTests::Object.from(object && object.ref)
|
289
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_object_full_inout _v1
|
290
|
-
_v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0))
|
291
|
-
return _v2
|
292
|
-
end
|
293
|
-
CODE
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
describe "for GIMarshallingTests::Object.full_out" do
|
298
|
-
let(:function_info) do
|
299
|
-
get_method_introspection_data("GIMarshallingTests", "Object",
|
300
|
-
"full_out")
|
301
|
-
end
|
302
|
-
|
303
|
-
it "builds a correct definition" do
|
304
|
-
_(code).must_equal <<~CODE
|
305
|
-
def self.full_out
|
306
|
-
_v1 = FFI::MemoryPointer.new :pointer
|
307
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_object_full_out _v1
|
308
|
-
_v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0))
|
309
|
-
return _v2
|
310
|
-
end
|
311
|
-
CODE
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
describe "for GIMarshallingTests::Object.full_return" do
|
316
|
-
let(:function_info) do
|
317
|
-
get_method_introspection_data("GIMarshallingTests", "Object",
|
318
|
-
"full_return")
|
319
|
-
end
|
320
|
-
|
321
|
-
it "builds a correct definition" do
|
322
|
-
_(code).must_equal <<~CODE
|
323
|
-
def self.full_return
|
324
|
-
_v1 = GIMarshallingTests::Lib.gi_marshalling_tests_object_full_return
|
325
|
-
_v2 = GIMarshallingTests::Object.wrap(_v1)
|
326
|
-
return _v2
|
327
|
-
end
|
328
|
-
CODE
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
describe "for GIMarshallingTests::Object#none_in" do
|
333
|
-
let(:function_info) do
|
334
|
-
get_method_introspection_data("GIMarshallingTests", "Object",
|
335
|
-
"none_in")
|
336
|
-
end
|
337
|
-
|
338
|
-
it "builds a correct definition" do
|
339
|
-
_(code).must_equal <<~CODE
|
340
|
-
def none_in
|
341
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_object_none_in self
|
342
|
-
end
|
343
|
-
CODE
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
describe "for GIMarshallingTests::Object.none_inout" do
|
348
|
-
let(:function_info) do
|
349
|
-
get_method_introspection_data("GIMarshallingTests", "Object",
|
350
|
-
"none_inout")
|
351
|
-
end
|
352
|
-
|
353
|
-
it "builds a correct definition" do
|
354
|
-
_(code).must_equal <<~CODE
|
355
|
-
def self.none_inout(object)
|
356
|
-
_v1 = FFI::MemoryPointer.new :pointer
|
357
|
-
_v1.put_pointer 0, GIMarshallingTests::Object.from(object)
|
358
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_object_none_inout _v1
|
359
|
-
_v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0)).tap { |it| it && it.ref }
|
360
|
-
return _v2
|
361
|
-
end
|
362
|
-
CODE
|
363
|
-
end
|
364
|
-
end
|
365
|
-
|
366
|
-
describe "for GIMarshallingTests::Object.none_out" do
|
367
|
-
let(:function_info) do
|
368
|
-
get_method_introspection_data("GIMarshallingTests", "Object",
|
369
|
-
"none_out")
|
370
|
-
end
|
371
|
-
|
372
|
-
it "builds a correct definition" do
|
373
|
-
_(code).must_equal <<~CODE
|
374
|
-
def self.none_out
|
375
|
-
_v1 = FFI::MemoryPointer.new :pointer
|
376
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_object_none_out _v1
|
377
|
-
_v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0)).tap { |it| it && it.ref }
|
378
|
-
return _v2
|
379
|
-
end
|
380
|
-
CODE
|
381
|
-
end
|
382
|
-
end
|
383
|
-
|
384
|
-
describe "for GIMarshallingTests::Object.none_return" do
|
385
|
-
let(:function_info) do
|
386
|
-
get_method_introspection_data("GIMarshallingTests", "Object",
|
387
|
-
"none_return")
|
388
|
-
end
|
389
|
-
|
390
|
-
it "builds a correct definition" do
|
391
|
-
_(code).must_equal <<~CODE
|
392
|
-
def self.none_return
|
393
|
-
_v1 = GIMarshallingTests::Lib.gi_marshalling_tests_object_none_return
|
394
|
-
_v2 = GIMarshallingTests::Object.wrap(_v1).tap { |it| it && it.ref }
|
395
|
-
return _v2
|
396
|
-
end
|
397
|
-
CODE
|
398
|
-
end
|
399
|
-
end
|
400
|
-
|
401
|
-
describe "for Regress::TestObj#instance_method_full" do
|
402
|
-
let(:function_info) do
|
403
|
-
get_method_introspection_data("Regress", "TestObj",
|
404
|
-
"instance_method_full")
|
405
|
-
end
|
406
|
-
|
407
|
-
it "builds a correct definition including self.ref" do
|
408
|
-
_(code).must_equal <<~CODE
|
409
|
-
def instance_method_full
|
410
|
-
Regress::Lib.regress_test_obj_instance_method_full self.ref
|
411
|
-
end
|
412
|
-
CODE
|
413
|
-
end
|
414
|
-
end
|
415
|
-
end
|
416
|
-
|
417
|
-
describe "struct ownership transfer" do
|
418
|
-
describe "for Regress::FooRectangle#add" do
|
419
|
-
let(:function_info) do
|
420
|
-
get_method_introspection_data("Regress", "FooRectangle",
|
421
|
-
"add")
|
422
|
-
end
|
423
|
-
|
424
|
-
it "builds a correct definition without #ref" do
|
425
|
-
_(code).must_equal <<~CODE
|
426
|
-
def add(r2)
|
427
|
-
_v1 = Regress::FooRectangle.from(r2)
|
428
|
-
Regress::Lib.regress_foo_rectangle_add self, _v1
|
429
|
-
end
|
430
|
-
CODE
|
431
|
-
end
|
432
|
-
end
|
433
|
-
end
|
434
|
-
|
435
|
-
describe "boxed struct ownership transfer" do
|
436
|
-
describe "for GIMarshallingTests::BoxedStruct.inout" do
|
437
|
-
let(:function_info) do
|
438
|
-
get_method_introspection_data("GIMarshallingTests", "BoxedStruct", "inout")
|
439
|
-
end
|
440
|
-
|
441
|
-
it "builds a correct definition" do
|
442
|
-
_(code).must_equal <<~CODE
|
443
|
-
def self.inout(struct_)
|
444
|
-
_v1 = FFI::MemoryPointer.new :pointer
|
445
|
-
_v1.put_pointer 0, GIMarshallingTests::BoxedStruct.copy_from(struct_)
|
446
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_inout _v1
|
447
|
-
_v2 = GIMarshallingTests::BoxedStruct.wrap_own(_v1.get_pointer(0))
|
448
|
-
return _v2
|
449
|
-
end
|
450
|
-
CODE
|
451
|
-
end
|
452
|
-
end
|
453
|
-
|
454
|
-
describe "for GIMarshallingTests::BoxedStruct.out" do
|
455
|
-
let(:function_info) do
|
456
|
-
get_method_introspection_data("GIMarshallingTests", "BoxedStruct", "out")
|
457
|
-
end
|
458
|
-
|
459
|
-
it "builds a correct definition" do
|
460
|
-
_(code).must_equal <<~CODE
|
461
|
-
def self.out
|
462
|
-
_v1 = FFI::MemoryPointer.new :pointer
|
463
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_out _v1
|
464
|
-
_v2 = GIMarshallingTests::BoxedStruct.wrap_copy(_v1.get_pointer(0))
|
465
|
-
return _v2
|
466
|
-
end
|
467
|
-
CODE
|
468
|
-
end
|
469
|
-
end
|
470
|
-
|
471
|
-
describe "for GIMarshallingTests::BoxedStruct.returnv" do
|
472
|
-
let(:function_info) do
|
473
|
-
get_method_introspection_data("GIMarshallingTests", "BoxedStruct", "returnv")
|
474
|
-
end
|
475
|
-
|
476
|
-
it "builds a correct definition" do
|
477
|
-
_(code).must_equal <<~CODE
|
478
|
-
def self.returnv
|
479
|
-
_v1 = GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_returnv
|
480
|
-
_v2 = GIMarshallingTests::BoxedStruct.wrap_copy(_v1)
|
481
|
-
return _v2
|
482
|
-
end
|
483
|
-
CODE
|
484
|
-
end
|
485
|
-
end
|
486
|
-
end
|
487
|
-
|
488
|
-
describe "string ownership transfer" do
|
489
|
-
describe "for Regress.test_utf8_out" do
|
490
|
-
let(:function_info) { get_introspection_data "Regress", "test_utf8_out" }
|
491
|
-
|
492
|
-
it "builds a correct definition" do
|
493
|
-
_(code).must_equal <<~CODE
|
494
|
-
def self.test_utf8_out
|
495
|
-
_v1 = FFI::MemoryPointer.new :pointer
|
496
|
-
Regress::Lib.regress_test_utf8_out _v1
|
497
|
-
_v2 = GirFFI::AllocationHelper.free_after _v1.get_pointer(0), &:to_utf8
|
498
|
-
return _v2
|
499
|
-
end
|
500
|
-
CODE
|
501
|
-
end
|
502
|
-
end
|
503
|
-
end
|
504
|
-
|
505
|
-
describe "for functions with an allow-none ingoing parameter" do
|
506
|
-
let(:function_info) { get_introspection_data "Regress", "test_utf8_null_in" }
|
507
|
-
it "builds correct definition with default parameter value" do
|
508
|
-
_(code).must_equal <<~CODE
|
509
|
-
def self.test_utf8_null_in(in_ = nil)
|
510
|
-
_v1 = GirFFI::InPointer.from_utf8(in_)
|
511
|
-
Regress::Lib.regress_test_utf8_null_in _v1
|
512
|
-
end
|
513
|
-
CODE
|
514
|
-
end
|
515
|
-
end
|
516
|
-
|
517
|
-
describe "for functions where some allow-none cannot be honored" do
|
518
|
-
let(:function_info) do
|
519
|
-
get_introspection_data "GIMarshallingTests", "array_in_utf8_two_in_out_of_order"
|
520
|
-
end
|
521
|
-
it "builds correct definition with default parameter value on the later arguments" do
|
522
|
-
_(code).must_equal <<~CODE
|
523
|
-
def self.array_in_utf8_two_in_out_of_order(a, ints, b = nil)
|
524
|
-
length = ints.nil? ? 0 : ints.length
|
525
|
-
_v1 = length
|
526
|
-
_v2 = GirFFI::InPointer.from_utf8(a)
|
527
|
-
_v3 = GirFFI::InPointer.from_utf8(b)
|
528
|
-
_v4 = GirFFI::SizedArray.from(:gint32, -1, ints)
|
529
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_array_in_utf8_two_in_out_of_order _v1, _v2, _v4, _v3
|
530
|
-
end
|
531
|
-
CODE
|
532
|
-
end
|
533
|
-
end
|
534
|
-
|
535
|
-
describe "ownership transfer for an ingoing array of structs" do
|
536
|
-
describe "with no ownership transfer of the elements" do
|
537
|
-
let(:function_info) do
|
538
|
-
get_introspection_data "GIMarshallingTests", "array_struct_in"
|
539
|
-
end
|
540
|
-
|
541
|
-
it "builds a correct definition" do
|
542
|
-
_(code).must_equal <<~CODE
|
543
|
-
def self.array_struct_in(structs)
|
544
|
-
length = structs.nil? ? 0 : structs.length
|
545
|
-
_v1 = length
|
546
|
-
_v2 = GirFFI::SizedArray.from([:pointer, GIMarshallingTests::BoxedStruct], -1, structs)
|
547
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_array_struct_in _v2, _v1
|
548
|
-
end
|
549
|
-
CODE
|
550
|
-
end
|
551
|
-
end
|
552
|
-
describe "with ownership transfer of the elements" do
|
553
|
-
let(:function_info) do
|
554
|
-
get_introspection_data "GIMarshallingTests", "array_struct_take_in"
|
555
|
-
end
|
556
|
-
|
557
|
-
it "builds a correct definition" do
|
558
|
-
_(code).must_equal <<~CODE
|
559
|
-
def self.array_struct_take_in(structs)
|
560
|
-
length = structs.nil? ? 0 : structs.length
|
561
|
-
_v1 = length
|
562
|
-
_v2 = GirFFI::SizedArray.copy_from([:pointer, GIMarshallingTests::BoxedStruct], -1, structs)
|
563
|
-
GIMarshallingTests::Lib.gi_marshalling_tests_array_struct_take_in _v2, _v1
|
564
|
-
end
|
565
|
-
CODE
|
566
|
-
end
|
567
|
-
end
|
568
|
-
end
|
569
|
-
end
|
570
|
-
end
|