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,455 +1,449 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::ArgumentBuilder do
|
6
6
|
let(:var_gen) { GirFFI::VariableNameGenerator.new }
|
7
7
|
let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) }
|
8
8
|
|
9
|
-
describe
|
10
|
-
describe
|
11
|
-
describe
|
9
|
+
describe "for an argument with direction :in" do
|
10
|
+
describe "for :c" do
|
11
|
+
describe "with full ownership transfer" do
|
12
12
|
let(:arg_info) do
|
13
|
-
get_introspection_data(
|
13
|
+
get_introspection_data("GIMarshallingTests", "array_struct_take_in").args[0]
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
builder.pre_conversion.
|
18
|
-
must_equal [
|
16
|
+
it "has the correct value for #pre_conversion" do
|
17
|
+
_(builder.pre_conversion).
|
18
|
+
must_equal ["_v1 = GirFFI::SizedArray.copy_from([:pointer, GIMarshallingTests::BoxedStruct], -1, structs)"]
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
22
|
-
builder.post_conversion.must_equal []
|
21
|
+
it "has the correct value for #post_conversion" do
|
22
|
+
_(builder.post_conversion).must_equal []
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe
|
27
|
+
describe "for :callback" do
|
28
28
|
let(:arg_info) do
|
29
|
-
get_introspection_data(
|
29
|
+
get_introspection_data("Regress", "test_callback_destroy_notify").args[0]
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
33
|
-
builder.pre_conversion.must_equal [
|
32
|
+
it "has the correct value for #pre_conversion" do
|
33
|
+
_(builder.pre_conversion).must_equal ["_v1 = Regress::TestCallbackUserData.from(callback)"]
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
37
|
-
builder.post_conversion.must_equal []
|
36
|
+
it "has the correct value for #post_conversion" do
|
37
|
+
_(builder.post_conversion).must_equal []
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe
|
41
|
+
describe "for :zero_terminated" do
|
42
42
|
let(:arg_info) do
|
43
|
-
get_introspection_data(
|
44
|
-
|
43
|
+
get_introspection_data("GIMarshallingTests",
|
44
|
+
"array_in_len_zero_terminated").args[0]
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
48
|
-
builder.pre_conversion.must_equal [
|
47
|
+
it "has the correct value for #pre_conversion" do
|
48
|
+
_(builder.pre_conversion).must_equal ["_v1 = GirFFI::ZeroTerminated.from(:gint32, ints)"]
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
52
|
-
builder.post_conversion.must_equal []
|
51
|
+
it "has the correct value for #post_conversion" do
|
52
|
+
_(builder.post_conversion).must_equal []
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe
|
57
|
-
let(:arg_info) { get_introspection_data(
|
56
|
+
describe "for :void" do
|
57
|
+
let(:arg_info) { get_introspection_data("Regress", "test_callback_user_data").args[1] }
|
58
58
|
|
59
|
-
describe
|
60
|
-
it
|
61
|
-
builder.method_argument_name.must_equal arg_info.name
|
59
|
+
describe "when it is a regular argument" do
|
60
|
+
it "has the correct value for method_argument_name" do
|
61
|
+
_(builder.method_argument_name).must_equal arg_info.name
|
62
62
|
end
|
63
63
|
|
64
|
-
it
|
65
|
-
builder.pre_conversion.must_equal [
|
64
|
+
it "has the correct value for #pre_conversion" do
|
65
|
+
_(builder.pre_conversion).must_equal ["_v1 = user_data"]
|
66
66
|
end
|
67
67
|
|
68
|
-
it
|
69
|
-
builder.post_conversion.must_equal []
|
68
|
+
it "has the correct value for #post_conversion" do
|
69
|
+
_(builder.post_conversion).must_equal []
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
describe
|
73
|
+
describe "when it is a closure" do
|
74
74
|
before do
|
75
75
|
callback = Object.new
|
76
|
-
allow(callback).to receive(:call_argument_name).and_return
|
76
|
+
allow(callback).to receive(:call_argument_name).and_return "foo"
|
77
77
|
builder.mark_as_user_data callback
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
81
|
-
builder.method_argument_name.must_be_nil
|
80
|
+
it "has the correct value for method_argument_name" do
|
81
|
+
_(builder.method_argument_name).must_be_nil
|
82
82
|
end
|
83
83
|
|
84
|
-
it
|
85
|
-
builder.pre_conversion.must_equal [
|
84
|
+
it "has the correct value for #pre_conversion" do
|
85
|
+
_(builder.pre_conversion).must_equal ["_v1 = GirFFI::ArgHelper.store(foo)"]
|
86
86
|
end
|
87
87
|
|
88
|
-
it
|
89
|
-
builder.post_conversion.must_equal []
|
88
|
+
it "has the correct value for #post_conversion" do
|
89
|
+
_(builder.post_conversion).must_equal []
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
describe
|
96
|
-
describe
|
97
|
-
let(:arg_info) { get_introspection_data(
|
95
|
+
describe "for an argument with direction :out" do
|
96
|
+
describe "for :enum" do
|
97
|
+
let(:arg_info) { get_introspection_data("GIMarshallingTests", "genum_out").args[0] }
|
98
98
|
|
99
|
-
it
|
100
|
-
builder.pre_conversion.must_equal [
|
99
|
+
it "has the correct value for #pre_conversion" do
|
100
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new GIMarshallingTests::GEnum"]
|
101
101
|
end
|
102
102
|
|
103
|
-
it
|
104
|
-
builder.post_conversion.must_equal [
|
103
|
+
it "has the correct value for #post_conversion" do
|
104
|
+
_(builder.post_conversion).must_equal ["_v2 = GIMarshallingTests::GEnum.get_value_from_pointer(_v1, 0)"]
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
describe
|
108
|
+
describe "for :flags" do
|
109
109
|
let(:arg_info) do
|
110
|
-
get_introspection_data(
|
110
|
+
get_introspection_data("GIMarshallingTests", "flags_out").args[0]
|
111
111
|
end
|
112
112
|
|
113
|
-
it
|
114
|
-
builder.pre_conversion.must_equal [
|
113
|
+
it "has the correct value for #pre_conversion" do
|
114
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new GIMarshallingTests::Flags"]
|
115
115
|
end
|
116
116
|
|
117
|
-
it
|
118
|
-
builder.post_conversion.must_equal [
|
117
|
+
it "has the correct value for #post_conversion" do
|
118
|
+
_(builder.post_conversion).must_equal ["_v2 = GIMarshallingTests::Flags.get_value_from_pointer(_v1, 0)"]
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
describe
|
123
|
-
describe
|
122
|
+
describe "for :object" do
|
123
|
+
describe "with full ownership transfer" do
|
124
124
|
let(:arg_info) do
|
125
|
-
get_method_introspection_data(
|
125
|
+
get_method_introspection_data("Regress", "TestObj", "null_out").args[0]
|
126
126
|
end
|
127
127
|
|
128
|
-
it
|
129
|
-
builder.pre_conversion.must_equal [
|
128
|
+
it "has the correct value for #pre_conversion" do
|
129
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
130
130
|
end
|
131
131
|
|
132
|
-
it
|
133
|
-
builder.post_conversion.must_equal [
|
132
|
+
it "has the correct value for #post_conversion" do
|
133
|
+
_(builder.post_conversion).must_equal ["_v2 = Regress::TestObj.wrap(_v1.get_pointer(0))"]
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
describe
|
137
|
+
describe "with no ownership transfer" do
|
138
138
|
let(:arg_info) do
|
139
|
-
get_method_introspection_data(
|
139
|
+
get_method_introspection_data("GIMarshallingTests", "Object", "none_out").args[0]
|
140
140
|
end
|
141
141
|
|
142
|
-
it
|
143
|
-
builder.pre_conversion.must_equal [
|
142
|
+
it "has the correct value for #pre_conversion" do
|
143
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
144
144
|
end
|
145
145
|
|
146
|
-
it
|
147
|
-
builder.post_conversion.
|
148
|
-
must_equal [
|
146
|
+
it "has the correct value for #post_conversion" do
|
147
|
+
_(builder.post_conversion).
|
148
|
+
must_equal ["_v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0)).tap { |it| it && it.ref }"]
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
describe
|
154
|
-
describe
|
153
|
+
describe "for :struct" do
|
154
|
+
describe "when not allocated by the caller" do
|
155
155
|
let(:arg_info) do
|
156
|
-
get_introspection_data(
|
156
|
+
get_introspection_data("GIMarshallingTests", "boxed_struct_out").args[0]
|
157
157
|
end
|
158
158
|
|
159
|
-
it
|
160
|
-
builder.pre_conversion.must_equal [
|
161
|
-
|
159
|
+
it "has the correct value for #pre_conversion" do
|
160
|
+
_(builder.pre_conversion).must_equal [
|
161
|
+
"_v1 = FFI::MemoryPointer.new :pointer"
|
162
162
|
]
|
163
163
|
end
|
164
164
|
|
165
|
-
it
|
166
|
-
builder.post_conversion.
|
167
|
-
must_equal [
|
165
|
+
it "has the correct value for #post_conversion" do
|
166
|
+
_(builder.post_conversion).
|
167
|
+
must_equal ["_v2 = GIMarshallingTests::BoxedStruct.wrap_copy(_v1.get_pointer(0))"]
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
|
-
describe
|
171
|
+
describe "when allocated by the caller" do
|
172
172
|
let(:arg_info) do
|
173
|
-
get_method_introspection_data(
|
173
|
+
get_method_introspection_data("Regress", "TestStructA", "clone").args[0]
|
174
174
|
end
|
175
175
|
|
176
|
-
it
|
177
|
-
builder.pre_conversion.must_equal [
|
176
|
+
it "has the correct value for #pre_conversion" do
|
177
|
+
_(builder.pre_conversion).must_equal ["_v1 = Regress::TestStructA.new"]
|
178
178
|
end
|
179
179
|
|
180
|
-
it
|
181
|
-
builder.post_conversion.must_equal []
|
180
|
+
it "has empty #post_conversion" do
|
181
|
+
_(builder.post_conversion).must_equal []
|
182
182
|
end
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
-
describe
|
186
|
+
describe "for :strv" do
|
187
187
|
let(:arg_info) do
|
188
|
-
get_introspection_data(
|
188
|
+
get_introspection_data("GIMarshallingTests", "gstrv_out").args[0]
|
189
189
|
end
|
190
190
|
|
191
|
-
it
|
192
|
-
builder.pre_conversion.must_equal [
|
191
|
+
it "has the correct value for #pre_conversion" do
|
192
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
193
193
|
end
|
194
194
|
|
195
|
-
it
|
196
|
-
builder.post_conversion.must_equal [
|
195
|
+
it "has the correct value for #post_conversion" do
|
196
|
+
_(builder.post_conversion).must_equal ["_v2 = GLib::Strv.wrap(_v1.get_pointer(0))"]
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
200
|
-
describe
|
201
|
-
describe
|
200
|
+
describe "for :array" do
|
201
|
+
describe "when allocated by the callee" do
|
202
202
|
let(:arg_info) do
|
203
|
-
get_introspection_data(
|
203
|
+
get_introspection_data("GIMarshallingTests", "garray_utf8_none_out").args[0]
|
204
204
|
end
|
205
205
|
|
206
|
-
it
|
207
|
-
builder.pre_conversion.must_equal [
|
206
|
+
it "has the correct value for #pre_conversion" do
|
207
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
208
208
|
end
|
209
209
|
|
210
|
-
it
|
211
|
-
builder.post_conversion.must_equal [
|
210
|
+
it "has the correct value for #post_conversion" do
|
211
|
+
_(builder.post_conversion).must_equal ["_v2 = GLib::Array.wrap(:utf8, _v1.get_pointer(0))"]
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
-
describe
|
215
|
+
describe "when allocated by the caller" do
|
216
216
|
let(:function_info) do
|
217
|
-
get_introspection_data(
|
217
|
+
get_introspection_data("GIMarshallingTests", "garray_utf8_full_out_caller_allocated")
|
218
218
|
end
|
219
219
|
|
220
220
|
let(:arg_info) { function_info.args[0] }
|
221
221
|
|
222
|
-
|
223
|
-
|
224
|
-
end
|
225
|
-
|
226
|
-
it 'has the correct value for #pre_conversion' do
|
227
|
-
builder.pre_conversion.must_equal ['_v1 = GLib::Array.new :utf8']
|
222
|
+
it "has the correct value for #pre_conversion" do
|
223
|
+
_(builder.pre_conversion).must_equal ["_v1 = GLib::Array.new :utf8"]
|
228
224
|
end
|
229
225
|
|
230
|
-
it
|
231
|
-
builder.post_conversion.must_equal []
|
226
|
+
it "has empty #post_conversion" do
|
227
|
+
_(builder.post_conversion).must_equal []
|
232
228
|
end
|
233
229
|
end
|
234
230
|
end
|
235
231
|
|
236
|
-
describe
|
232
|
+
describe "for :ptr_array" do
|
237
233
|
let(:arg_info) do
|
238
|
-
get_introspection_data(
|
234
|
+
get_introspection_data("GIMarshallingTests", "gptrarray_utf8_none_out").args[0]
|
239
235
|
end
|
240
236
|
|
241
|
-
it
|
242
|
-
builder.pre_conversion.must_equal [
|
237
|
+
it "has the correct value for #pre_conversion" do
|
238
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
243
239
|
end
|
244
240
|
|
245
|
-
it
|
246
|
-
builder.post_conversion.must_equal [
|
241
|
+
it "has the correct value for #post_conversion" do
|
242
|
+
_(builder.post_conversion).must_equal ["_v2 = GLib::PtrArray.wrap(:utf8, _v1.get_pointer(0))"]
|
247
243
|
end
|
248
244
|
end
|
249
245
|
|
250
|
-
describe
|
246
|
+
describe "for :error" do
|
251
247
|
let(:arg_info) do
|
252
|
-
get_introspection_data(
|
248
|
+
get_introspection_data("GIMarshallingTests", "gerror_out").args[0]
|
253
249
|
end
|
254
250
|
|
255
|
-
it
|
256
|
-
builder.pre_conversion.must_equal [
|
251
|
+
it "has the correct value for #pre_conversion" do
|
252
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
257
253
|
end
|
258
254
|
|
259
|
-
it
|
260
|
-
builder.post_conversion.must_equal [
|
255
|
+
it "has the correct value for #post_conversion" do
|
256
|
+
_(builder.post_conversion).must_equal ["_v2 = GLib::Error.wrap(_v1.get_pointer(0))"]
|
261
257
|
end
|
262
258
|
end
|
263
259
|
|
264
|
-
describe
|
265
|
-
describe
|
260
|
+
describe "for :c" do
|
261
|
+
describe "with fixed size" do
|
266
262
|
let(:arg_info) do
|
267
|
-
get_introspection_data(
|
263
|
+
get_introspection_data("GIMarshallingTests", "array_fixed_out").args[0]
|
268
264
|
end
|
269
265
|
|
270
|
-
it
|
271
|
-
builder.pre_conversion.must_equal [
|
266
|
+
it "has the correct value for #pre_conversion" do
|
267
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
272
268
|
end
|
273
269
|
|
274
|
-
it
|
275
|
-
builder.post_conversion.must_equal [
|
270
|
+
it "has the correct value for #post_conversion" do
|
271
|
+
_(builder.post_conversion).must_equal ["_v2 = GirFFI::SizedArray.wrap(:gint32, 4, _v1.get_pointer(0))"]
|
276
272
|
end
|
277
273
|
end
|
278
274
|
|
279
|
-
describe
|
275
|
+
describe "with separate size parameter" do
|
280
276
|
let(:arg_info) do
|
281
|
-
get_introspection_data(
|
277
|
+
get_introspection_data("GIMarshallingTests", "array_out").args[0]
|
282
278
|
end
|
283
279
|
|
284
280
|
let(:length_argument) { Object.new }
|
285
281
|
before do
|
286
|
-
allow(length_argument).to receive(:post_converted_name).and_return
|
282
|
+
allow(length_argument).to receive(:post_converted_name).and_return "bar"
|
287
283
|
builder.length_arg = length_argument
|
288
284
|
end
|
289
285
|
|
290
|
-
it
|
291
|
-
builder.pre_conversion.must_equal [
|
286
|
+
it "has the correct value for #pre_conversion" do
|
287
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
292
288
|
end
|
293
289
|
|
294
|
-
it
|
295
|
-
builder.post_conversion.must_equal [
|
290
|
+
it "has the correct value for #post_conversion" do
|
291
|
+
_(builder.post_conversion).must_equal ["_v2 = GirFFI::SizedArray.wrap(:gint32, bar, _v1.get_pointer(0))"]
|
296
292
|
end
|
297
293
|
end
|
298
294
|
end
|
299
295
|
|
300
|
-
describe
|
296
|
+
describe "for :glist" do
|
301
297
|
let(:arg_info) do
|
302
|
-
get_introspection_data(
|
298
|
+
get_introspection_data("GIMarshallingTests", "glist_utf8_none_out").args[0]
|
303
299
|
end
|
304
300
|
|
305
|
-
it
|
306
|
-
builder.pre_conversion.must_equal [
|
301
|
+
it "has the correct value for #pre_conversion" do
|
302
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
307
303
|
end
|
308
304
|
|
309
|
-
it
|
310
|
-
builder.post_conversion.must_equal [
|
305
|
+
it "has the correct value for #post_conversion" do
|
306
|
+
_(builder.post_conversion).must_equal ["_v2 = GLib::List.wrap(:utf8, _v1.get_pointer(0))"]
|
311
307
|
end
|
312
308
|
end
|
313
309
|
|
314
|
-
describe
|
310
|
+
describe "for :gslist" do
|
315
311
|
let(:arg_info) do
|
316
|
-
get_introspection_data(
|
312
|
+
get_introspection_data("GIMarshallingTests", "gslist_utf8_none_out").args[0]
|
317
313
|
end
|
318
314
|
|
319
|
-
it
|
320
|
-
builder.pre_conversion.must_equal [
|
315
|
+
it "has the correct value for #pre_conversion" do
|
316
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
321
317
|
end
|
322
318
|
|
323
|
-
it
|
324
|
-
builder.post_conversion.must_equal [
|
319
|
+
it "has the correct value for #post_conversion" do
|
320
|
+
_(builder.post_conversion).must_equal ["_v2 = GLib::SList.wrap(:utf8, _v1.get_pointer(0))"]
|
325
321
|
end
|
326
322
|
end
|
327
323
|
|
328
|
-
describe
|
324
|
+
describe "for :ghash" do
|
329
325
|
let(:arg_info) do
|
330
|
-
get_introspection_data(
|
326
|
+
get_introspection_data("GIMarshallingTests", "ghashtable_utf8_none_out").args[0]
|
331
327
|
end
|
332
328
|
|
333
|
-
it
|
334
|
-
builder.pre_conversion.must_equal [
|
329
|
+
it "has the correct value for #pre_conversion" do
|
330
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
335
331
|
end
|
336
332
|
|
337
|
-
it
|
338
|
-
builder.post_conversion.must_equal [
|
333
|
+
it "has the correct value for #post_conversion" do
|
334
|
+
_(builder.post_conversion).must_equal ["_v2 = GLib::HashTable.wrap([:utf8, :utf8], _v1.get_pointer(0))"]
|
339
335
|
end
|
340
336
|
end
|
341
337
|
|
342
|
-
describe
|
343
|
-
describe
|
338
|
+
describe "for :utf8" do
|
339
|
+
describe "with full ownership transfer" do
|
344
340
|
let(:arg_info) do
|
345
|
-
get_introspection_data(
|
341
|
+
get_introspection_data("GIMarshallingTests", "utf8_full_out").args[0]
|
346
342
|
end
|
347
343
|
|
348
|
-
it
|
349
|
-
builder.pre_conversion.must_equal [
|
344
|
+
it "has the correct value for #pre_conversion" do
|
345
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
350
346
|
end
|
351
347
|
|
352
|
-
it
|
353
|
-
builder.post_conversion.must_equal [
|
354
|
-
|
348
|
+
it "has the correct value for #post_conversion" do
|
349
|
+
_(builder.post_conversion).must_equal [
|
350
|
+
"_v2 = GirFFI::AllocationHelper.free_after _v1.get_pointer(0), &:to_utf8"
|
355
351
|
]
|
356
352
|
end
|
357
353
|
|
358
|
-
it
|
354
|
+
it "has the correct value for #return_value_name" do
|
359
355
|
builder.post_conversion
|
360
|
-
builder.return_value_name.must_equal
|
356
|
+
_(builder.return_value_name).must_equal "_v2"
|
361
357
|
end
|
362
358
|
end
|
363
359
|
|
364
|
-
describe
|
360
|
+
describe "with no ownership transfer" do
|
365
361
|
let(:arg_info) do
|
366
|
-
get_introspection_data(
|
362
|
+
get_introspection_data("GIMarshallingTests", "utf8_none_out").args[0]
|
367
363
|
end
|
368
364
|
|
369
|
-
it
|
370
|
-
builder.pre_conversion.must_equal [
|
365
|
+
it "has the correct value for #pre_conversion" do
|
366
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
371
367
|
end
|
372
368
|
|
373
|
-
it
|
374
|
-
builder.post_conversion.must_equal [
|
369
|
+
it "has the correct value for #post_conversion" do
|
370
|
+
_(builder.post_conversion).must_equal ["_v2 = _v1.get_pointer(0).to_utf8"]
|
375
371
|
end
|
376
372
|
end
|
377
373
|
end
|
378
374
|
|
379
|
-
describe
|
375
|
+
describe "for :void" do
|
380
376
|
let(:function_info) do
|
381
|
-
get_introspection_data(
|
377
|
+
get_introspection_data("Everything", "one_outparam_gpointer")
|
382
378
|
end
|
383
379
|
let(:arg_info) { function_info.args[0] }
|
384
380
|
|
385
|
-
before
|
386
|
-
skip unless function_info
|
387
|
-
end
|
381
|
+
before { skip_below "1.47.1" }
|
388
382
|
|
389
|
-
it
|
390
|
-
builder.pre_conversion.must_equal [
|
383
|
+
it "has the correct value for #pre_conversion" do
|
384
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer"]
|
391
385
|
end
|
392
386
|
|
393
|
-
it
|
394
|
-
builder.post_conversion.must_equal [
|
387
|
+
it "has the correct value for #post_conversion" do
|
388
|
+
_(builder.post_conversion).must_equal ["_v2 = _v1.get_pointer(0)"]
|
395
389
|
end
|
396
390
|
end
|
397
391
|
end
|
398
392
|
|
399
|
-
describe
|
400
|
-
describe
|
393
|
+
describe "for an argument with direction :inout" do
|
394
|
+
describe "for :enum" do
|
401
395
|
let(:arg_info) do
|
402
|
-
get_introspection_data(
|
396
|
+
get_introspection_data("GIMarshallingTests", "enum_inout").args[0]
|
403
397
|
end
|
404
398
|
|
405
|
-
it
|
406
|
-
builder.pre_conversion.must_equal [
|
407
|
-
|
399
|
+
it "has the correct value for #pre_conversion" do
|
400
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new GIMarshallingTests::Enum",
|
401
|
+
"GIMarshallingTests::Enum.copy_value_to_pointer(#{arg_info.name}, _v1)"]
|
408
402
|
end
|
409
403
|
|
410
|
-
it
|
411
|
-
builder.post_conversion.must_equal [
|
404
|
+
it "has the correct value for #post_conversion" do
|
405
|
+
_(builder.post_conversion).must_equal ["_v2 = GIMarshallingTests::Enum.get_value_from_pointer(_v1, 0)"]
|
412
406
|
end
|
413
407
|
end
|
414
408
|
|
415
|
-
describe
|
409
|
+
describe "for :flags" do
|
416
410
|
let(:arg_info) do
|
417
|
-
get_introspection_data(
|
411
|
+
get_introspection_data("GIMarshallingTests", "no_type_flags_inout").args[0]
|
418
412
|
end
|
419
413
|
|
420
|
-
it
|
421
|
-
builder.pre_conversion.
|
422
|
-
must_equal [
|
414
|
+
it "has the correct value for #pre_conversion" do
|
415
|
+
_(builder.pre_conversion).
|
416
|
+
must_equal ["_v1 = FFI::MemoryPointer.new GIMarshallingTests::NoTypeFlags",
|
423
417
|
"GIMarshallingTests::NoTypeFlags.copy_value_to_pointer(#{arg_info.name}, _v1)"]
|
424
418
|
end
|
425
419
|
|
426
|
-
it
|
427
|
-
builder.post_conversion.must_equal [
|
420
|
+
it "has the correct value for #post_conversion" do
|
421
|
+
_(builder.post_conversion).must_equal ["_v2 = GIMarshallingTests::NoTypeFlags.get_value_from_pointer(_v1, 0)"]
|
428
422
|
end
|
429
423
|
end
|
430
424
|
|
431
|
-
describe
|
425
|
+
describe "for :gint32" do
|
432
426
|
let(:arg_info) do
|
433
|
-
get_introspection_data(
|
427
|
+
get_introspection_data("GIMarshallingTests", "int32_inout_min_max").args[0]
|
434
428
|
end
|
435
429
|
|
436
|
-
it
|
437
|
-
builder.method_argument_name.must_equal arg_info.name
|
430
|
+
it "has the correct value for method_argument_name" do
|
431
|
+
_(builder.method_argument_name).must_equal arg_info.name
|
438
432
|
end
|
439
433
|
|
440
|
-
it
|
441
|
-
builder.pre_conversion.must_equal [
|
442
|
-
|
434
|
+
it "has the correct value for #pre_conversion" do
|
435
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :int32",
|
436
|
+
"_v1.put_int32 0, #{arg_info.name}"]
|
443
437
|
end
|
444
438
|
|
445
|
-
it
|
446
|
-
builder.post_conversion.must_equal [
|
439
|
+
it "has the correct value for #post_conversion" do
|
440
|
+
_(builder.post_conversion).must_equal ["_v2 = _v1.get_int32(0)"]
|
447
441
|
end
|
448
442
|
end
|
449
443
|
|
450
|
-
describe
|
444
|
+
describe "for an array length" do
|
451
445
|
let(:function_info) do
|
452
|
-
get_introspection_data(
|
446
|
+
get_introspection_data("Regress", "test_array_int_inout")
|
453
447
|
end
|
454
448
|
let(:arg_info) { function_info.args[0] }
|
455
449
|
let(:array_arg_info) { function_info.args[1] }
|
@@ -461,104 +455,104 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
461
455
|
builder.array_arg = array_arg_builder
|
462
456
|
end
|
463
457
|
|
464
|
-
it
|
465
|
-
builder.pre_conversion.must_equal [
|
466
|
-
|
467
|
-
|
458
|
+
it "has the correct value for #pre_conversion" do
|
459
|
+
_(builder.pre_conversion).must_equal ["n_ints = ints.nil? ? 0 : ints.length",
|
460
|
+
"_v1 = FFI::MemoryPointer.new :int32",
|
461
|
+
"_v1.put_int32 0, n_ints"]
|
468
462
|
end
|
469
463
|
|
470
|
-
it
|
471
|
-
builder.post_conversion.must_equal [
|
464
|
+
it "has the correct value for #post_conversion" do
|
465
|
+
_(builder.post_conversion).must_equal ["_v2 = _v1.get_int32(0)"]
|
472
466
|
end
|
473
467
|
end
|
474
468
|
|
475
|
-
describe
|
469
|
+
describe "for :strv" do
|
476
470
|
let(:arg_info) do
|
477
|
-
get_introspection_data(
|
471
|
+
get_introspection_data("GIMarshallingTests", "gstrv_inout").args[0]
|
478
472
|
end
|
479
473
|
|
480
|
-
it
|
481
|
-
builder.pre_conversion.must_equal [
|
482
|
-
|
474
|
+
it "has the correct value for #pre_conversion" do
|
475
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer",
|
476
|
+
"_v1.put_pointer 0, GLib::Strv.from(g_strv)"]
|
483
477
|
end
|
484
478
|
|
485
|
-
it
|
486
|
-
builder.post_conversion.must_equal [
|
479
|
+
it "has the correct value for #post_conversion" do
|
480
|
+
_(builder.post_conversion).must_equal ["_v2 = GLib::Strv.wrap(_v1.get_pointer(0))"]
|
487
481
|
end
|
488
482
|
end
|
489
483
|
|
490
|
-
describe
|
484
|
+
describe "for :ptr_array" do
|
491
485
|
let(:arg_info) do
|
492
|
-
get_introspection_data(
|
486
|
+
get_introspection_data("GIMarshallingTests", "gptrarray_utf8_none_inout").args[0]
|
493
487
|
end
|
494
488
|
|
495
|
-
it
|
496
|
-
builder.pre_conversion.must_equal [
|
497
|
-
|
489
|
+
it "has the correct value for #pre_conversion" do
|
490
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer",
|
491
|
+
"_v1.put_pointer 0, GLib::PtrArray.from(:utf8, parray_)"]
|
498
492
|
end
|
499
493
|
|
500
|
-
it
|
501
|
-
builder.post_conversion.must_equal [
|
494
|
+
it "has the correct value for #post_conversion" do
|
495
|
+
_(builder.post_conversion).must_equal ["_v2 = GLib::PtrArray.wrap(:utf8, _v1.get_pointer(0))"]
|
502
496
|
end
|
503
497
|
end
|
504
498
|
|
505
|
-
describe
|
499
|
+
describe "for :utf8" do
|
506
500
|
let(:arg_info) do
|
507
|
-
get_introspection_data(
|
501
|
+
get_introspection_data("GIMarshallingTests", "utf8_none_inout").args[0]
|
508
502
|
end
|
509
503
|
|
510
|
-
it
|
511
|
-
builder.pre_conversion.must_equal [
|
512
|
-
|
504
|
+
it "has the correct value for #pre_conversion" do
|
505
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :pointer",
|
506
|
+
"_v1.put_pointer 0, GirFFI::InPointer.from_utf8(utf8)"]
|
513
507
|
end
|
514
508
|
|
515
|
-
it
|
516
|
-
builder.post_conversion.must_equal [
|
509
|
+
it "has the correct value for #post_conversion" do
|
510
|
+
_(builder.post_conversion).must_equal ["_v2 = _v1.get_pointer(0).to_utf8"]
|
517
511
|
end
|
518
512
|
end
|
519
513
|
|
520
|
-
describe
|
521
|
-
describe
|
514
|
+
describe "for :struct" do
|
515
|
+
describe "with full ownership transfer" do
|
522
516
|
let(:arg_info) do
|
523
|
-
get_introspection_data(
|
517
|
+
get_introspection_data("GIMarshallingTests", "boxed_struct_inout").args[0]
|
524
518
|
end
|
525
519
|
|
526
|
-
it
|
527
|
-
builder.pre_conversion.must_equal [
|
528
|
-
|
529
|
-
|
520
|
+
it "has the correct value for #pre_conversion" do
|
521
|
+
_(builder.pre_conversion).must_equal [
|
522
|
+
"_v1 = FFI::MemoryPointer.new :pointer",
|
523
|
+
"_v1.put_pointer 0, GIMarshallingTests::BoxedStruct.copy_from(struct_)"
|
530
524
|
]
|
531
525
|
end
|
532
526
|
|
533
|
-
it
|
534
|
-
builder.post_conversion.
|
535
|
-
must_equal [
|
527
|
+
it "has the correct value for #post_conversion" do
|
528
|
+
_(builder.post_conversion).
|
529
|
+
must_equal ["_v2 = GIMarshallingTests::BoxedStruct.wrap_own(_v1.get_pointer(0))"]
|
536
530
|
end
|
537
531
|
end
|
538
532
|
end
|
539
533
|
|
540
|
-
describe
|
541
|
-
describe
|
534
|
+
describe "for :c" do
|
535
|
+
describe "with fixed size" do
|
542
536
|
let(:arg_info) do
|
543
|
-
get_introspection_data(
|
537
|
+
get_introspection_data("GIMarshallingTests", "array_fixed_inout").args[0]
|
544
538
|
end
|
545
539
|
|
546
|
-
it
|
547
|
-
builder.pre_conversion.must_equal [
|
540
|
+
it "has the correct value for #pre_conversion" do
|
541
|
+
_(builder.pre_conversion).must_equal [
|
548
542
|
'GirFFI::ArgHelper.check_fixed_array_size 4, ints, "ints"',
|
549
|
-
|
550
|
-
|
543
|
+
"_v1 = FFI::MemoryPointer.new :pointer",
|
544
|
+
"_v1.put_pointer 0, GirFFI::SizedArray.from(:gint32, 4, ints)"
|
551
545
|
]
|
552
546
|
end
|
553
547
|
|
554
|
-
it
|
555
|
-
builder.post_conversion.must_equal [
|
548
|
+
it "has the correct value for #post_conversion" do
|
549
|
+
_(builder.post_conversion).must_equal ["_v2 = GirFFI::SizedArray.wrap(:gint32, 4, _v1.get_pointer(0))"]
|
556
550
|
end
|
557
551
|
end
|
558
552
|
|
559
|
-
describe
|
553
|
+
describe "with separate size parameter" do
|
560
554
|
let(:function_info) do
|
561
|
-
get_introspection_data(
|
555
|
+
get_introspection_data("Regress", "test_array_int_inout")
|
562
556
|
end
|
563
557
|
let(:length_arg_info) { function_info.args[0] }
|
564
558
|
let(:arg_info) { function_info.args[1] }
|
@@ -570,87 +564,87 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
570
564
|
builder.length_arg = length_arg_builder
|
571
565
|
end
|
572
566
|
|
573
|
-
it
|
574
|
-
builder.pre_conversion.must_equal [
|
575
|
-
|
576
|
-
|
567
|
+
it "has the correct value for #pre_conversion" do
|
568
|
+
_(builder.pre_conversion).must_equal [
|
569
|
+
"_v1 = FFI::MemoryPointer.new :pointer",
|
570
|
+
"_v1.put_pointer 0, GirFFI::SizedArray.copy_from(:gint32, -1, ints)"
|
577
571
|
]
|
578
572
|
end
|
579
573
|
|
580
|
-
it
|
581
|
-
builder.post_conversion.must_equal [
|
574
|
+
it "has the correct value for #post_conversion" do
|
575
|
+
_(builder.post_conversion).must_equal ["_v3 = GirFFI::SizedArray.wrap(:gint32, _v2, _v1.get_pointer(0))"]
|
582
576
|
end
|
583
577
|
end
|
584
578
|
end
|
585
579
|
end
|
586
580
|
|
587
|
-
describe
|
581
|
+
describe "for a skipped argument with direction :in" do
|
588
582
|
let(:arg_info) do
|
589
|
-
get_method_introspection_data(
|
583
|
+
get_method_introspection_data("Regress", "TestObj", "skip_param").args[2]
|
590
584
|
end
|
591
585
|
|
592
|
-
it
|
593
|
-
builder.method_argument_name.must_be_nil
|
586
|
+
it "has the correct value for method_argument_name" do
|
587
|
+
_(builder.method_argument_name).must_be_nil
|
594
588
|
end
|
595
589
|
|
596
|
-
it
|
597
|
-
builder.pre_conversion.must_equal [
|
590
|
+
it "has the correct value for #pre_conversion" do
|
591
|
+
_(builder.pre_conversion).must_equal ["_v1 = 0"]
|
598
592
|
end
|
599
593
|
|
600
|
-
it
|
601
|
-
builder.post_conversion.must_equal []
|
594
|
+
it "has the correct value for #post_conversion" do
|
595
|
+
_(builder.post_conversion).must_equal []
|
602
596
|
end
|
603
597
|
end
|
604
598
|
|
605
|
-
describe
|
599
|
+
describe "for a skipped argument with direction :inout" do
|
606
600
|
let(:arg_info) do
|
607
|
-
get_method_introspection_data(
|
601
|
+
get_method_introspection_data("Regress", "TestObj", "skip_inout_param").args[3]
|
608
602
|
end
|
609
603
|
|
610
|
-
it
|
611
|
-
builder.method_argument_name.must_be_nil
|
604
|
+
it "has the correct value for method_argument_name" do
|
605
|
+
_(builder.method_argument_name).must_be_nil
|
612
606
|
end
|
613
607
|
|
614
|
-
it
|
615
|
-
builder.pre_conversion.must_equal [
|
616
|
-
|
608
|
+
it "has the correct value for #pre_conversion" do
|
609
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :int32",
|
610
|
+
"_v1.put_int32 0, 0"]
|
617
611
|
end
|
618
612
|
|
619
|
-
it
|
620
|
-
builder.post_conversion.must_equal []
|
613
|
+
it "has the correct value for #post_conversion" do
|
614
|
+
_(builder.post_conversion).must_equal []
|
621
615
|
end
|
622
616
|
end
|
623
617
|
|
624
|
-
describe
|
618
|
+
describe "for a skipped argument with direction :out" do
|
625
619
|
let(:arg_info) do
|
626
|
-
get_method_introspection_data(
|
620
|
+
get_method_introspection_data("Regress", "TestObj", "skip_out_param").args[1]
|
627
621
|
end
|
628
622
|
|
629
|
-
it
|
630
|
-
builder.method_argument_name.must_be_nil
|
623
|
+
it "has the correct value for method_argument_name" do
|
624
|
+
_(builder.method_argument_name).must_be_nil
|
631
625
|
end
|
632
626
|
|
633
|
-
it
|
634
|
-
builder.pre_conversion.must_equal [
|
627
|
+
it "has the correct value for #pre_conversion" do
|
628
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new :int32"]
|
635
629
|
end
|
636
630
|
|
637
|
-
it
|
638
|
-
builder.post_conversion.must_equal []
|
631
|
+
it "has the correct value for #post_conversion" do
|
632
|
+
_(builder.post_conversion).must_equal []
|
639
633
|
end
|
640
634
|
end
|
641
635
|
|
642
|
-
describe
|
636
|
+
describe "for an argument with direction :error" do
|
643
637
|
let(:arg_info) { GirFFI::ErrorArgumentInfo.new }
|
644
638
|
|
645
|
-
it
|
646
|
-
builder.pre_conversion.must_equal [
|
647
|
-
|
639
|
+
it "has the correct value for #pre_conversion" do
|
640
|
+
_(builder.pre_conversion).must_equal [
|
641
|
+
"_v1 = FFI::MemoryPointer.new(:pointer).write_pointer nil"
|
648
642
|
]
|
649
643
|
end
|
650
644
|
|
651
|
-
it
|
652
|
-
builder.post_conversion.must_equal [
|
653
|
-
|
645
|
+
it "has the correct value for #post_conversion" do
|
646
|
+
_(builder.post_conversion).must_equal [
|
647
|
+
"GirFFI::ArgHelper.check_error(_v1)"
|
654
648
|
]
|
655
649
|
end
|
656
650
|
end
|