gir_ffi 0.14.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +21 -0
- data/Gemfile +6 -4
- data/README.md +4 -4
- data/Rakefile +5 -5
- data/lib/ffi-glib/array.rb +14 -4
- data/lib/ffi-glib/byte_array.rb +7 -2
- data/lib/ffi-glib/container_class_methods.rb +1 -1
- data/lib/ffi-glib/error.rb +1 -1
- data/lib/ffi-glib/hash_table.rb +3 -3
- data/lib/ffi-glib/list.rb +1 -1
- data/lib/ffi-glib/list_methods.rb +1 -1
- data/lib/ffi-glib/main_loop.rb +3 -3
- data/lib/ffi-glib/ptr_array.rb +30 -8
- data/lib/ffi-glib/s_list.rb +1 -1
- data/lib/ffi-glib/variant.rb +1 -1
- data/lib/ffi-glib.rb +16 -16
- data/lib/ffi-gobject/object.rb +23 -32
- data/lib/ffi-gobject/param_spec.rb +1 -1
- data/lib/ffi-gobject/ruby_closure.rb +2 -2
- data/lib/ffi-gobject/value.rb +37 -28
- data/lib/ffi-gobject.rb +13 -13
- data/lib/ffi-gobject_introspection/gobject_type_init.rb +2 -2
- data/lib/ffi-gobject_introspection/i_arg_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_base_info.rb +27 -17
- data/lib/ffi-gobject_introspection/i_callable_info.rb +4 -4
- data/lib/ffi-gobject_introspection/i_constant_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_enum_info.rb +1 -0
- data/lib/ffi-gobject_introspection/i_field_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_function_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_object_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_property_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_repository.rb +9 -6
- data/lib/ffi-gobject_introspection/i_struct_info.rb +2 -1
- data/lib/ffi-gobject_introspection/i_type_info.rb +13 -7
- data/lib/ffi-gobject_introspection/i_unresolved_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_vfunc_info.rb +1 -1
- data/lib/ffi-gobject_introspection/lib.rb +30 -19
- data/lib/ffi-gobject_introspection/strv.rb +1 -1
- data/lib/ffi-gobject_introspection.rb +20 -20
- data/lib/gir_ffi/allocation_helper.rb +1 -1
- data/lib/gir_ffi/arg_helper.rb +4 -4
- data/lib/gir_ffi/{in_out_pointer.rb → array_element_convertor.rb} +16 -23
- data/lib/gir_ffi/boolean.rb +1 -1
- data/lib/gir_ffi/boxed_base.rb +1 -1
- data/lib/gir_ffi/builder.rb +18 -10
- data/lib/gir_ffi/builders/argument_builder.rb +17 -17
- data/lib/gir_ffi/builders/base_argument_builder.rb +1 -0
- data/lib/gir_ffi/builders/base_method_builder.rb +7 -7
- data/lib/gir_ffi/builders/base_return_value_builder.rb +1 -1
- data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
- data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +5 -5
- data/lib/gir_ffi/builders/callback_argument_builder.rb +8 -8
- data/lib/gir_ffi/builders/callback_builder.rb +3 -3
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +2 -2
- data/lib/gir_ffi/builders/closure_argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/closure_return_value_builder.rb +1 -1
- data/lib/gir_ffi/builders/constant_builder.rb +1 -1
- data/lib/gir_ffi/builders/constructor_builder.rb +9 -9
- data/lib/gir_ffi/builders/enum_builder.rb +2 -2
- data/lib/gir_ffi/builders/field_builder.rb +16 -15
- data/lib/gir_ffi/builders/flags_builder.rb +2 -2
- data/lib/gir_ffi/builders/full_c_to_ruby_convertor.rb +1 -1
- data/lib/gir_ffi/builders/function_builder.rb +11 -5
- data/lib/gir_ffi/builders/initializer_builder.rb +3 -3
- data/lib/gir_ffi/builders/initializer_return_value_builder.rb +2 -2
- data/lib/gir_ffi/builders/interface_builder.rb +2 -2
- data/lib/gir_ffi/builders/mapping_method_builder.rb +9 -9
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +7 -7
- data/lib/gir_ffi/builders/method_template.rb +1 -1
- data/lib/gir_ffi/builders/module_builder.rb +4 -6
- data/lib/gir_ffi/builders/object_builder.rb +6 -6
- data/lib/gir_ffi/builders/property_argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/property_builder.rb +13 -12
- data/lib/gir_ffi/builders/property_return_value_builder.rb +1 -1
- data/lib/gir_ffi/builders/registered_type_builder.rb +14 -5
- data/lib/gir_ffi/builders/return_value_builder.rb +4 -4
- data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +6 -6
- data/lib/gir_ffi/builders/signal_closure_builder.rb +2 -2
- data/lib/gir_ffi/builders/struct_builder.rb +4 -4
- data/lib/gir_ffi/builders/struct_like.rb +1 -1
- data/lib/gir_ffi/builders/type_builder.rb +12 -12
- data/lib/gir_ffi/builders/unintrospectable_boxed_builder.rb +2 -2
- data/lib/gir_ffi/builders/unintrospectable_builder.rb +2 -2
- data/lib/gir_ffi/builders/union_builder.rb +4 -4
- data/lib/gir_ffi/builders/user_defined_builder.rb +2 -2
- data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/vfunc_builder.rb +6 -6
- data/lib/gir_ffi/builders/with_layout.rb +2 -2
- data/lib/gir_ffi/callback_base.rb +1 -1
- data/lib/gir_ffi/class_base.rb +5 -5
- data/lib/gir_ffi/core.rb +19 -20
- data/lib/gir_ffi/enum_base.rb +1 -1
- data/lib/gir_ffi/enum_like_base.rb +2 -2
- data/lib/gir_ffi/error_argument_info.rb +2 -2
- data/lib/gir_ffi/error_type_info.rb +1 -1
- data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
- data/lib/gir_ffi/ffi_ext.rb +1 -1
- data/lib/gir_ffi/flags_base.rb +1 -1
- data/lib/gir_ffi/in_pointer.rb +10 -0
- data/lib/gir_ffi/info_ext/full_type_name.rb +3 -3
- data/lib/gir_ffi/info_ext/i_arg_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_callable_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_callback_info.rb +1 -1
- 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_property_info.rb +2 -2
- data/lib/gir_ffi/info_ext/i_registered_type_info.rb +4 -5
- data/lib/gir_ffi/info_ext/i_signal_info.rb +7 -3
- data/lib/gir_ffi/info_ext/i_type_info.rb +48 -26
- data/lib/gir_ffi/info_ext/i_unresolved_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_value_info.rb +2 -2
- data/lib/gir_ffi/info_ext/i_vfunc_info.rb +2 -2
- data/lib/gir_ffi/info_ext/safe_constant_name.rb +8 -8
- data/lib/gir_ffi/info_ext/safe_function_name.rb +2 -2
- data/lib/gir_ffi/info_ext.rb +15 -15
- data/lib/gir_ffi/interface_base.rb +3 -3
- data/lib/gir_ffi/lib_c.rb +1 -1
- data/lib/gir_ffi/method_stubber.rb +1 -1
- data/lib/gir_ffi/module_base.rb +1 -1
- data/lib/gir_ffi/object_base.rb +3 -4
- data/lib/gir_ffi/receiver_argument_info.rb +1 -1
- data/lib/gir_ffi/receiver_type_info.rb +2 -2
- data/lib/gir_ffi/registered_type_base.rb +1 -1
- data/lib/gir_ffi/sized_array.rb +4 -2
- data/lib/gir_ffi/struct.rb +1 -1
- data/lib/gir_ffi/struct_base.rb +1 -1
- data/lib/gir_ffi/type_map.rb +2 -23
- data/lib/gir_ffi/unintrospectable_boxed_info.rb +2 -2
- data/lib/gir_ffi/unintrospectable_type_info.rb +1 -1
- data/lib/gir_ffi/union.rb +1 -1
- data/lib/gir_ffi/union_base.rb +1 -1
- data/lib/gir_ffi/user_defined_object_info.rb +6 -2
- data/lib/gir_ffi/user_defined_property_info.rb +33 -33
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi-base/gobject/lib.rb +3 -2
- data/lib/gir_ffi-base/gobject.rb +26 -25
- data/lib/gir_ffi-base.rb +1 -1
- data/lib/gir_ffi.rb +3 -3
- data/tasks/test.rake +3 -2
- data/test/base_test_helper.rb +16 -9
- data/test/ffi-glib/array_test.rb +71 -56
- data/test/ffi-glib/byte_array_test.rb +13 -7
- data/test/ffi-glib/bytes_test.rb +24 -19
- data/test/ffi-glib/closure_test.rb +11 -11
- data/test/ffi-glib/destroy_notify_test.rb +6 -6
- data/test/ffi-glib/hash_table_test.rb +27 -27
- data/test/ffi-glib/list_test.rb +22 -22
- data/test/ffi-glib/main_loop_test.rb +12 -12
- data/test/ffi-glib/ptr_array_test.rb +39 -39
- data/test/ffi-glib/ruby_closure_test.rb +10 -10
- data/test/ffi-glib/s_list_test.rb +20 -20
- data/test/ffi-glib/strv_test.rb +19 -19
- data/test/ffi-glib/variant_test.rb +5 -5
- data/test/ffi-gobject/gobject_test.rb +48 -44
- data/test/ffi-gobject/object_class_test.rb +8 -8
- data/test/ffi-gobject/object_test.rb +49 -67
- data/test/ffi-gobject/param_spec_test.rb +12 -12
- data/test/ffi-gobject/value_test.rb +145 -125
- data/test/ffi-gobject_introspection/gobject_type_init_test.rb +8 -8
- data/test/ffi-gobject_introspection/i_base_info_test.rb +15 -16
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +9 -13
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +7 -7
- data/test/ffi-gobject_introspection/i_function_info_test.rb +1 -1
- data/test/ffi-gobject_introspection/i_interface_info_test.rb +10 -10
- data/test/ffi-gobject_introspection/i_object_info_test.rb +23 -23
- data/test/ffi-gobject_introspection/i_property_info_test.rb +19 -19
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +10 -10
- data/test/ffi-gobject_introspection/i_repository_test.rb +31 -31
- data/test/ffi-gobject_introspection/i_struct_info_test.rb +10 -10
- data/test/ffi-gobject_introspection/i_type_info_test.rb +12 -15
- data/test/ffi-gobject_introspection/i_union_info_test.rb +7 -7
- data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +16 -16
- data/test/ffi-gobject_introspection/lib_test.rb +3 -3
- data/test/ffi-gobject_introspection/strv_test.rb +9 -9
- data/test/ffi-gobject_test.rb +44 -44
- data/test/gir_ffi/allocation_helper_test.rb +13 -13
- data/test/gir_ffi/arg_helper_test.rb +63 -64
- data/test/gir_ffi/boolean_test.rb +20 -20
- data/test/gir_ffi/boxed_base_test.rb +18 -18
- data/test/gir_ffi/builder_test.rb +115 -93
- data/test/gir_ffi/builders/argument_builder_test.rb +280 -286
- data/test/gir_ffi/builders/base_argument_builder_test.rb +1 -1
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +53 -56
- data/test/gir_ffi/builders/callback_builder_test.rb +71 -72
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +36 -40
- data/test/gir_ffi/builders/constant_builder_test.rb +1 -1
- data/test/gir_ffi/builders/constructor_builder_test.rb +10 -10
- data/test/gir_ffi/builders/enum_builder_test.rb +10 -10
- data/test/gir_ffi/builders/field_builder_test.rb +42 -42
- data/test/gir_ffi/builders/function_builder_test.rb +236 -224
- data/test/gir_ffi/builders/initializer_builder_test.rb +14 -14
- data/test/gir_ffi/builders/interface_builder_test.rb +9 -9
- data/test/gir_ffi/builders/module_builder_test.rb +18 -18
- data/test/gir_ffi/builders/object_builder_test.rb +38 -38
- data/test/gir_ffi/builders/property_builder_test.rb +91 -94
- data/test/gir_ffi/builders/registered_type_builder_test.rb +35 -11
- data/test/gir_ffi/builders/return_value_builder_test.rb +215 -222
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +122 -113
- data/test/gir_ffi/builders/struct_builder_test.rb +32 -32
- data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +8 -14
- data/test/gir_ffi/builders/unintrospectable_builder_test.rb +23 -23
- data/test/gir_ffi/builders/union_builder_test.rb +12 -15
- data/test/gir_ffi/builders/user_defined_builder_test.rb +147 -147
- data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +40 -40
- data/test/gir_ffi/builders/vfunc_builder_test.rb +145 -157
- data/test/gir_ffi/callback_base_test.rb +9 -9
- data/test/gir_ffi/class_base_test.rb +49 -51
- data/test/gir_ffi/core_test.rb +32 -32
- data/test/gir_ffi/enum_base_test.rb +19 -19
- data/test/gir_ffi/error_type_info_test.rb +23 -23
- data/test/gir_ffi/ffi_ext/pointer_test.rb +5 -5
- data/test/gir_ffi/g_type_test.rb +11 -11
- data/test/gir_ffi/in_pointer_test.rb +70 -50
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +5 -5
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +4 -4
- data/test/gir_ffi/info_ext/i_field_info_test.rb +6 -6
- data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -17
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +8 -8
- data/test/gir_ffi/info_ext/i_type_info_test.rb +229 -215
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +4 -4
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +8 -8
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +8 -8
- data/test/gir_ffi/interface_base_test.rb +8 -8
- data/test/gir_ffi/method_stubber_test.rb +19 -19
- data/test/gir_ffi/object_base_test.rb +19 -19
- data/test/gir_ffi/object_store_test.rb +13 -13
- data/test/gir_ffi/receiver_argument_info_test.rb +15 -15
- data/test/gir_ffi/sized_array_test.rb +68 -68
- data/test/gir_ffi/struct_base_test.rb +8 -8
- data/test/gir_ffi/struct_like_base_test.rb +64 -64
- data/test/gir_ffi/type_map_test.rb +6 -6
- data/test/gir_ffi/unintrospectable_type_info_test.rb +33 -33
- data/test/gir_ffi/union_base_test.rb +8 -8
- data/test/gir_ffi/user_defined_object_info_test.rb +34 -34
- data/test/gir_ffi/user_defined_property_info_test.rb +16 -16
- data/test/gir_ffi/variable_name_generator_test.rb +8 -8
- data/test/gir_ffi/version_test.rb +4 -4
- data/test/gir_ffi/zero_terminated_test.rb +34 -34
- data/test/gir_ffi_test_helper.rb +3 -3
- data/test/integration/callback_exceptions_test.rb +17 -21
- data/test/integration/derived_classes_test.rb +13 -13
- data/test/integration/generated_everything_test.rb +224 -224
- data/test/integration/generated_gimarshallingtests_test.rb +1118 -1017
- data/test/integration/generated_gio_test.rb +36 -36
- data/test/integration/generated_glib_test.rb +4 -6
- data/test/integration/generated_gobject_test.rb +43 -35
- data/test/integration/generated_gst_test.rb +16 -16
- data/test/integration/generated_gtk_source_test.rb +22 -17
- data/test/integration/generated_gtop_test.rb +8 -15
- data/test/integration/generated_pango_ft2_test.rb +2 -2
- data/test/integration/generated_pango_test.rb +4 -4
- data/test/integration/generated_regress_test.rb +1809 -1621
- data/test/integration/generated_secret_test.rb +8 -11
- data/test/integration/generated_utility_test.rb +81 -81
- data/test/integration/generated_warnlib_test.rb +13 -19
- data/test/integration/method_lookup_test.rb +6 -6
- data/test/introspection_test_helper.rb +48 -7
- data/test/minitest/stats_plugin.rb +1 -1
- metadata +11 -28
- data/lib/ffi-glib/array_methods.rb +0 -16
- data/test/gir_ffi/in_out_pointer_test.rb +0 -56
@@ -1,101 +1,101 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::VFuncArgumentBuilder do
|
6
6
|
let(:var_gen) { GirFFI::VariableNameGenerator.new }
|
7
7
|
let(:builder) { GirFFI::Builders::VFuncArgumentBuilder.new(var_gen, arg_info) }
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe "for a plain in argument" do
|
10
10
|
let(:vfunc_info) do
|
11
|
-
get_vfunc_introspection_data
|
11
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "method_int8_in"
|
12
12
|
end
|
13
13
|
let(:arg_info) { vfunc_info.args[0] }
|
14
14
|
|
15
|
-
it
|
16
|
-
builder.pre_conversion.must_equal [
|
15
|
+
it "has the correct value for #pre_conversion" do
|
16
|
+
_(builder.pre_conversion).must_equal ["_v1 = in_"]
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
builder.post_conversion.must_equal []
|
19
|
+
it "has the correct value for #post_conversion" do
|
20
|
+
_(builder.post_conversion).must_equal []
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
24
|
+
describe "for a transfer-none in argument" do
|
25
25
|
let(:vfunc_info) do
|
26
|
-
get_vfunc_introspection_data
|
26
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_in_object_transfer_none"
|
27
27
|
end
|
28
28
|
let(:arg_info) { vfunc_info.args[0] }
|
29
29
|
|
30
|
-
it
|
31
|
-
builder.pre_conversion.must_equal [
|
30
|
+
it "has the correct value for #pre_conversion" do
|
31
|
+
_(builder.pre_conversion).must_equal ["_v1 = GObject::Object.wrap(object)", "_v1.ref"]
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
35
|
-
builder.post_conversion.must_equal []
|
34
|
+
it "has the correct value for #post_conversion" do
|
35
|
+
_(builder.post_conversion).must_equal []
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
39
|
+
describe "for a transfer-none outgoing object argument" do
|
40
40
|
let(:vfunc_info) do
|
41
|
-
get_vfunc_introspection_data
|
41
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_out_object_transfer_none"
|
42
42
|
end
|
43
43
|
let(:arg_info) { vfunc_info.args[0] }
|
44
44
|
|
45
|
-
it
|
46
|
-
builder.pre_conversion.must_equal [
|
45
|
+
it "has the correct value for #pre_conversion" do
|
46
|
+
_(builder.pre_conversion).must_equal ["_v1 = object"]
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
50
|
-
builder.post_conversion.must_equal [
|
49
|
+
it "has the correct value for #post_conversion" do
|
50
|
+
_(builder.post_conversion).must_equal ["_v1.put_pointer 0, GObject::Object.from(_v2)"]
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe
|
54
|
+
describe "for a full-transfer outgoing object argument" do
|
55
55
|
let(:vfunc_info) do
|
56
|
-
get_vfunc_introspection_data
|
56
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_out_object_transfer_full"
|
57
57
|
end
|
58
58
|
let(:arg_info) { vfunc_info.args[0] }
|
59
59
|
|
60
|
-
it
|
61
|
-
builder.pre_conversion.must_equal [
|
60
|
+
it "has the correct value for #pre_conversion" do
|
61
|
+
_(builder.pre_conversion).must_equal ["_v1 = object"]
|
62
62
|
end
|
63
63
|
|
64
|
-
it
|
64
|
+
it "has the correct value for #post_conversion" do
|
65
65
|
builder.pre_conversion
|
66
|
-
builder.post_conversion.must_equal [
|
66
|
+
_(builder.post_conversion).must_equal ["_v2.ref", "_v1.put_pointer 0, GObject::Object.from(_v2)"]
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe
|
70
|
+
describe "for a full-transfer outgoing non-object argument" do
|
71
71
|
let(:vfunc_info) do
|
72
|
-
get_vfunc_introspection_data(
|
73
|
-
|
72
|
+
get_vfunc_introspection_data("GIMarshallingTests", "Object",
|
73
|
+
"method_int8_arg_and_out_callee")
|
74
74
|
end
|
75
75
|
let(:arg_info) { vfunc_info.args[1] }
|
76
76
|
|
77
|
-
it
|
78
|
-
builder.pre_conversion.
|
79
|
-
must_equal [
|
77
|
+
it "has the correct value for #pre_conversion" do
|
78
|
+
_(builder.pre_conversion).
|
79
|
+
must_equal ["_v1 = FFI::MemoryPointer.new(:int8).tap { |ptr| out.put_pointer 0, ptr }"]
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
83
|
-
builder.post_conversion.must_equal [
|
82
|
+
it "has the correct value for #post_conversion" do
|
83
|
+
_(builder.post_conversion).must_equal ["_v1.put_int8 0, _v2"]
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
describe
|
88
|
-
let(:object_info) { get_introspection_data(
|
87
|
+
describe "for a receiver argument" do
|
88
|
+
let(:object_info) { get_introspection_data("GIMarshallingTests", "Object") }
|
89
89
|
let(:type_info) { GirFFI::ReceiverTypeInfo.new(object_info) }
|
90
90
|
let(:arg_info) { GirFFI::ReceiverArgumentInfo.new(type_info) }
|
91
91
|
|
92
|
-
it
|
93
|
-
builder.pre_conversion.
|
94
|
-
must_equal [
|
92
|
+
it "has the correct value for #pre_conversion" do
|
93
|
+
_(builder.pre_conversion).
|
94
|
+
must_equal ["_v1 = GIMarshallingTests::Object.wrap(_instance)"]
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
98
|
-
builder.post_conversion.must_equal []
|
97
|
+
it "has the correct value for #post_conversion" do
|
98
|
+
_(builder.post_conversion).must_equal []
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -1,252 +1,240 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::VFuncBuilder do
|
6
6
|
let(:builder) { GirFFI::Builders::VFuncBuilder.new vfunc_info }
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe "#mapping_method_definition" do
|
9
9
|
let(:result) { builder.mapping_method_definition }
|
10
10
|
|
11
|
-
|
12
|
-
skip unless vfunc_info
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'for a vfunc with only one argument' do
|
11
|
+
describe "for a vfunc with only one argument" do
|
16
12
|
let(:vfunc_info) do
|
17
|
-
get_vfunc_introspection_data
|
13
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "method_int8_in"
|
18
14
|
end
|
19
15
|
|
20
|
-
it
|
21
|
-
expected =
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
it "returns a valid mapping method including receiver" do
|
17
|
+
expected = <<~CODE
|
18
|
+
def self.call_with_argument_mapping(_proc, _instance, in_)
|
19
|
+
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
20
|
+
_v2 = in_
|
21
|
+
_proc.call(_v1, _v2)
|
22
|
+
end
|
27
23
|
CODE
|
28
24
|
|
29
|
-
result.must_equal expected
|
25
|
+
_(result).must_equal expected
|
30
26
|
end
|
31
27
|
end
|
32
28
|
|
33
|
-
describe
|
29
|
+
describe "for a vfunc returning an enum" do
|
34
30
|
let(:vfunc_info) do
|
35
|
-
get_vfunc_introspection_data
|
31
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_return_enum"
|
36
32
|
end
|
37
33
|
|
38
|
-
it
|
39
|
-
expected =
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
34
|
+
it "returns a valid mapping method including receiver" do
|
35
|
+
expected = <<~CODE
|
36
|
+
def self.call_with_argument_mapping(_proc, _instance)
|
37
|
+
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
38
|
+
_v2 = _proc.call(_v1)
|
39
|
+
_v3 = GIMarshallingTests::Enum.to_int(_v2)
|
40
|
+
return _v3
|
41
|
+
end
|
46
42
|
CODE
|
47
43
|
|
48
|
-
result.must_equal expected
|
44
|
+
_(result).must_equal expected
|
49
45
|
end
|
50
46
|
end
|
51
47
|
|
52
|
-
describe
|
48
|
+
describe "for a vfunc with a callback argument" do
|
53
49
|
let(:vfunc_info) do
|
54
|
-
get_vfunc_introspection_data
|
50
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_with_callback"
|
55
51
|
end
|
56
52
|
|
57
|
-
it
|
58
|
-
expected =
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
53
|
+
it "returns a valid mapping method including receiver" do
|
54
|
+
expected = <<~CODE
|
55
|
+
def self.call_with_argument_mapping(_proc, _instance, callback, callback_data)
|
56
|
+
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
57
|
+
_v2 = GIMarshallingTests::CallbackIntInt.wrap(callback)
|
58
|
+
_v3 = GirFFI::ArgHelper::OBJECT_STORE.fetch(callback_data)
|
59
|
+
_proc.call(_v1, _v2, _v3)
|
60
|
+
end
|
65
61
|
CODE
|
66
62
|
|
67
|
-
result.must_equal expected
|
63
|
+
_(result).must_equal expected
|
68
64
|
end
|
69
65
|
end
|
70
66
|
|
71
|
-
describe
|
67
|
+
describe "for a vfunc with an out argument allocated by them, the caller" do
|
72
68
|
let(:vfunc_info) do
|
73
|
-
get_vfunc_introspection_data(
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
it
|
78
|
-
expected =
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
69
|
+
get_vfunc_introspection_data("GIMarshallingTests", "Object",
|
70
|
+
"method_int8_arg_and_out_caller")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "returns a valid mapping method including receiver" do
|
74
|
+
expected = <<~CODE
|
75
|
+
def self.call_with_argument_mapping(_proc, _instance, arg, out)
|
76
|
+
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
77
|
+
_v2 = arg
|
78
|
+
_v3 = out
|
79
|
+
_v4 = _proc.call(_v1, _v2)
|
80
|
+
_v3.put_int8 0, _v4
|
81
|
+
end
|
86
82
|
CODE
|
87
83
|
|
88
|
-
result.must_equal expected
|
84
|
+
_(result).must_equal expected
|
89
85
|
end
|
90
86
|
end
|
91
87
|
|
92
|
-
describe
|
88
|
+
describe "for a vfunc with an out argument allocated by us, the callee" do
|
93
89
|
let(:vfunc_info) do
|
94
|
-
get_vfunc_introspection_data(
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
it
|
99
|
-
expected =
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
90
|
+
get_vfunc_introspection_data("GIMarshallingTests", "Object",
|
91
|
+
"method_int8_arg_and_out_callee")
|
92
|
+
end
|
93
|
+
|
94
|
+
it "returns a valid mapping method including receiver" do
|
95
|
+
expected = <<~CODE
|
96
|
+
def self.call_with_argument_mapping(_proc, _instance, arg, out)
|
97
|
+
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
98
|
+
_v2 = arg
|
99
|
+
_v3 = FFI::MemoryPointer.new(:int8).tap { |ptr| out.put_pointer 0, ptr }
|
100
|
+
_v4 = _proc.call(_v1, _v2)
|
101
|
+
_v3.put_int8 0, _v4
|
102
|
+
end
|
107
103
|
CODE
|
108
104
|
|
109
|
-
result.must_equal expected
|
105
|
+
_(result).must_equal expected
|
110
106
|
end
|
111
107
|
end
|
112
108
|
|
113
|
-
describe
|
109
|
+
describe "for a vfunc with a GObject::Value out argument allocated by them, the caller" do
|
114
110
|
let(:vfunc_info) do
|
115
|
-
get_vfunc_introspection_data(
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
it
|
120
|
-
expected =
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
111
|
+
get_vfunc_introspection_data("GIMarshallingTests", "Object",
|
112
|
+
"vfunc_caller_allocated_out_parameter")
|
113
|
+
end
|
114
|
+
|
115
|
+
it "returns a valid mapping method including receiver" do
|
116
|
+
expected = <<~CODE
|
117
|
+
def self.call_with_argument_mapping(_proc, _instance, a)
|
118
|
+
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
119
|
+
_v2 = a
|
120
|
+
_v3 = _proc.call(_v1)
|
121
|
+
GObject::Value.copy_value_to_pointer(GObject::Value.from(_v3), _v2)
|
122
|
+
end
|
127
123
|
CODE
|
128
124
|
|
129
|
-
result.must_equal expected
|
125
|
+
_(result).must_equal expected
|
130
126
|
end
|
131
127
|
end
|
132
128
|
|
133
|
-
describe
|
129
|
+
describe "for a vfunc with an error argument" do
|
134
130
|
let(:vfunc_info) do
|
135
|
-
get_vfunc_introspection_data(
|
136
|
-
|
137
|
-
end
|
138
|
-
|
139
|
-
it
|
140
|
-
expected =
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
131
|
+
get_vfunc_introspection_data("GIMarshallingTests", "Object",
|
132
|
+
"vfunc_meth_with_err")
|
133
|
+
end
|
134
|
+
|
135
|
+
it "returns a valid mapping method including receiver" do
|
136
|
+
expected = <<~CODE
|
137
|
+
def self.call_with_argument_mapping(_proc, _instance, x, _error)
|
138
|
+
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
139
|
+
_v2 = x
|
140
|
+
_v3 = _error
|
141
|
+
begin
|
142
|
+
_v4 = _proc.call(_v1, _v2)
|
143
|
+
rescue => _v5
|
144
|
+
_v3.put_pointer 0, GLib::Error.from(_v5)
|
145
|
+
end
|
146
|
+
return _v4
|
149
147
|
end
|
150
|
-
return _v4
|
151
|
-
end
|
152
148
|
CODE
|
153
149
|
|
154
|
-
result.must_equal expected
|
150
|
+
_(result).must_equal expected
|
155
151
|
end
|
156
152
|
end
|
157
153
|
|
158
|
-
describe
|
154
|
+
describe "for a vfunc with a full-transfer return value" do
|
159
155
|
let(:vfunc_info) do
|
160
|
-
get_vfunc_introspection_data
|
161
|
-
end
|
162
|
-
|
163
|
-
it
|
164
|
-
expected =
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
156
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_return_object_transfer_full"
|
157
|
+
end
|
158
|
+
|
159
|
+
it "returns a valid mapping method" do
|
160
|
+
expected = <<~CODE
|
161
|
+
def self.call_with_argument_mapping(_proc, _instance)
|
162
|
+
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
163
|
+
_v2 = _proc.call(_v1)
|
164
|
+
_v2.ref
|
165
|
+
_v3 = GObject::Object.from(_v2).to_ptr
|
166
|
+
return _v3
|
167
|
+
end
|
172
168
|
CODE
|
173
169
|
|
174
|
-
result.must_equal expected
|
170
|
+
_(result).must_equal expected
|
175
171
|
end
|
176
172
|
end
|
177
173
|
|
178
|
-
describe
|
174
|
+
describe "for a vfunc with a transfer-none in argument" do
|
179
175
|
let(:vfunc_info) do
|
180
|
-
get_vfunc_introspection_data
|
176
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_in_object_transfer_none"
|
181
177
|
end
|
182
178
|
|
183
|
-
it
|
184
|
-
expected =
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
179
|
+
it "returns a valid mapping method" do
|
180
|
+
expected = <<~CODE
|
181
|
+
def self.call_with_argument_mapping(_proc, _instance, object)
|
182
|
+
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
183
|
+
_v2 = GObject::Object.wrap(object)
|
184
|
+
_v2.ref
|
185
|
+
_proc.call(_v1, _v2)
|
186
|
+
end
|
191
187
|
CODE
|
192
188
|
|
193
|
-
result.must_equal expected
|
189
|
+
_(result).must_equal expected
|
194
190
|
end
|
195
191
|
end
|
196
192
|
|
197
|
-
describe
|
193
|
+
describe "for a vfunc with a full-transfer outgoing argument" do
|
198
194
|
let(:vfunc_info) do
|
199
|
-
get_vfunc_introspection_data
|
200
|
-
end
|
201
|
-
|
202
|
-
it
|
203
|
-
expected =
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
195
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_out_object_transfer_full"
|
196
|
+
end
|
197
|
+
|
198
|
+
it "returns a valid mapping method" do
|
199
|
+
expected = <<~CODE
|
200
|
+
def self.call_with_argument_mapping(_proc, _instance, object)
|
201
|
+
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
202
|
+
_v2 = object
|
203
|
+
_v3 = _proc.call(_v1)
|
204
|
+
_v3.ref
|
205
|
+
_v2.put_pointer 0, GObject::Object.from(_v3)
|
206
|
+
end
|
211
207
|
CODE
|
212
208
|
|
213
|
-
result.must_equal expected
|
209
|
+
_(result).must_equal expected
|
214
210
|
end
|
215
211
|
end
|
216
212
|
end
|
217
213
|
|
218
|
-
describe
|
214
|
+
describe "#argument_ffi_types" do
|
219
215
|
let(:result) { builder.argument_ffi_types }
|
220
216
|
|
221
|
-
|
222
|
-
skip unless vfunc_info
|
223
|
-
end
|
224
|
-
|
225
|
-
describe 'for a vfunc with only one argument' do
|
217
|
+
describe "for a vfunc with only one argument" do
|
226
218
|
let(:vfunc_info) do
|
227
|
-
get_vfunc_introspection_data
|
219
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "method_int8_in"
|
228
220
|
end
|
229
221
|
|
230
|
-
it
|
231
|
-
result.must_equal [:pointer, :int8]
|
222
|
+
it "returns the correct FFI types including :pointer for the receiver" do
|
223
|
+
_(result).must_equal [:pointer, :int8]
|
232
224
|
end
|
233
225
|
end
|
234
226
|
end
|
235
227
|
|
236
|
-
describe
|
228
|
+
describe "#return_ffi_type" do
|
237
229
|
let(:result) { builder.return_ffi_type }
|
238
230
|
|
239
|
-
|
240
|
-
skip unless vfunc_info
|
241
|
-
end
|
242
|
-
|
243
|
-
describe 'for a vfunc returning an object' do
|
231
|
+
describe "for a vfunc returning an object" do
|
244
232
|
let(:vfunc_info) do
|
245
|
-
get_vfunc_introspection_data
|
233
|
+
get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_return_object_transfer_full"
|
246
234
|
end
|
247
235
|
|
248
|
-
it
|
249
|
-
result.must_equal :pointer
|
236
|
+
it "returns :pointer" do
|
237
|
+
_(result).must_equal :pointer
|
250
238
|
end
|
251
239
|
end
|
252
240
|
end
|