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,71 +1,69 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::CallbackArgumentBuilder do
|
6
6
|
let(:var_gen) { GirFFI::VariableNameGenerator.new }
|
7
7
|
let(:builder) { GirFFI::Builders::CallbackArgumentBuilder.new(var_gen, arg_info) }
|
8
8
|
|
9
|
-
describe
|
10
|
-
describe
|
9
|
+
describe "for an argument with direction :out" do
|
10
|
+
describe "for :zero_terminated" do
|
11
11
|
let(:vfunc_info) do
|
12
|
-
get_vfunc_introspection_data(
|
13
|
-
|
12
|
+
get_vfunc_introspection_data("GIMarshallingTests", "Object",
|
13
|
+
"vfunc_array_out_parameter")
|
14
14
|
end
|
15
15
|
let(:arg_info) { vfunc_info.args[0] }
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
it 'has the correct value for #pre_conversion' do
|
20
|
-
builder.pre_conversion.must_equal ['_v1 = a']
|
17
|
+
it "has the correct value for #pre_conversion" do
|
18
|
+
_(builder.pre_conversion).must_equal ["_v1 = a"]
|
21
19
|
end
|
22
20
|
|
23
|
-
it
|
24
|
-
builder.post_conversion.must_equal [
|
21
|
+
it "has the correct value for #post_conversion" do
|
22
|
+
_(builder.post_conversion).must_equal ["_v1.put_pointer 0, GirFFI::ZeroTerminated.from(:gfloat, _v2)"]
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
28
|
-
describe
|
26
|
+
describe "when the argument is allocated by us, the callee" do
|
29
27
|
let(:vfunc_info) do
|
30
|
-
get_vfunc_introspection_data(
|
31
|
-
|
28
|
+
get_vfunc_introspection_data("GIMarshallingTests", "Object",
|
29
|
+
"method_int8_arg_and_out_callee")
|
32
30
|
end
|
33
31
|
|
34
32
|
let(:arg_info) { vfunc_info.args[1] }
|
35
33
|
|
36
|
-
it
|
37
|
-
builder.pre_conversion.must_equal [
|
34
|
+
it "has the correct value for #pre_conversion" do
|
35
|
+
_(builder.pre_conversion).must_equal ["_v1 = FFI::MemoryPointer.new(:int8).tap { |ptr| out.put_pointer 0, ptr }"]
|
38
36
|
end
|
39
37
|
|
40
|
-
it
|
41
|
-
builder.post_conversion.must_equal [
|
38
|
+
it "has the correct value for #post_conversion" do
|
39
|
+
_(builder.post_conversion).must_equal ["_v1.put_int8 0, _v2"]
|
42
40
|
end
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
46
|
-
describe
|
44
|
+
describe "for an argument with direction :error" do
|
47
45
|
let(:arg_info) { GirFFI::ErrorArgumentInfo.new }
|
48
46
|
|
49
|
-
it
|
50
|
-
builder.pre_conversion.must_equal [
|
51
|
-
|
52
|
-
|
47
|
+
it "sets up a rescueing block in #pre_conversion" do
|
48
|
+
_(builder.pre_conversion).must_equal [
|
49
|
+
"_v1 = _error",
|
50
|
+
"begin"
|
53
51
|
]
|
54
52
|
end
|
55
53
|
|
56
|
-
it
|
57
|
-
builder.post_conversion.must_equal [
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
it "converts any exceptions to GLib::Error in #post_conversion" do
|
55
|
+
_(builder.post_conversion).must_equal [
|
56
|
+
"rescue => _v1",
|
57
|
+
"_v2.put_pointer 0, GLib::Error.from(_v1)",
|
58
|
+
"end"
|
61
59
|
]
|
62
60
|
end
|
63
61
|
end
|
64
62
|
|
65
|
-
describe
|
63
|
+
describe "for an argument with direction :inout" do
|
66
64
|
let(:callback_info) do
|
67
|
-
get_introspection_data(
|
68
|
-
|
65
|
+
get_introspection_data("Regress",
|
66
|
+
"TestCallbackArrayInOut")
|
69
67
|
end
|
70
68
|
let(:array_arg_info) { callback_info.args[0] }
|
71
69
|
let(:array_arg_builder) do
|
@@ -77,52 +75,51 @@ describe GirFFI::Builders::CallbackArgumentBuilder do
|
|
77
75
|
end
|
78
76
|
|
79
77
|
before do
|
80
|
-
skip unless callback_info
|
81
78
|
length_arg_builder.array_arg = array_arg_builder
|
82
79
|
array_arg_builder.length_arg = length_arg_builder
|
83
80
|
end
|
84
81
|
|
85
|
-
describe
|
86
|
-
it
|
87
|
-
array_arg_builder.call_argument_name.must_equal
|
82
|
+
describe "for arrays with a length argument" do
|
83
|
+
it "provides a call argument name" do
|
84
|
+
_(array_arg_builder.call_argument_name).must_equal "_v1"
|
88
85
|
end
|
89
86
|
|
90
|
-
it
|
91
|
-
array_arg_builder.capture_variable_name.must_equal
|
87
|
+
it "provides a capture variable name" do
|
88
|
+
_(array_arg_builder.capture_variable_name).must_equal "_v1"
|
92
89
|
end
|
93
90
|
|
94
|
-
it
|
95
|
-
array_arg_builder.pre_conversion.
|
96
|
-
must_equal [
|
97
|
-
|
91
|
+
it "has the correct value for #pre_conversion" do
|
92
|
+
_(array_arg_builder.pre_conversion).
|
93
|
+
must_equal ["_v1 = ints",
|
94
|
+
"_v2 = GirFFI::SizedArray.wrap(:gint32, _v3, _v1.get_pointer(0))"]
|
98
95
|
end
|
99
96
|
|
100
|
-
it
|
97
|
+
it "has the correct value for #post_conversion" do
|
101
98
|
array_arg_builder.pre_conversion
|
102
|
-
array_arg_builder.post_conversion.
|
103
|
-
must_equal [
|
99
|
+
_(array_arg_builder.post_conversion).
|
100
|
+
must_equal ["_v1.put_pointer 0, GirFFI::SizedArray.from(:gint32, -1, _v4)"]
|
104
101
|
end
|
105
102
|
end
|
106
103
|
|
107
|
-
describe
|
108
|
-
it
|
109
|
-
length_arg_builder.call_argument_name.must_be_nil
|
104
|
+
describe "for an array length argument" do
|
105
|
+
it "does not provide a call argument name" do
|
106
|
+
_(length_arg_builder.call_argument_name).must_be_nil
|
110
107
|
end
|
111
108
|
|
112
|
-
it
|
113
|
-
length_arg_builder.capture_variable_name.must_be_nil
|
109
|
+
it "does not provide a capture variable name" do
|
110
|
+
_(length_arg_builder.capture_variable_name).must_be_nil
|
114
111
|
end
|
115
112
|
|
116
|
-
it
|
117
|
-
length_arg_builder.pre_conversion.
|
118
|
-
must_equal [
|
119
|
-
|
113
|
+
it "has the correct value for #pre_conversion" do
|
114
|
+
_(length_arg_builder.pre_conversion).
|
115
|
+
must_equal ["_v1 = length",
|
116
|
+
"_v2 = _v1.get_int32(0)"]
|
120
117
|
end
|
121
118
|
|
122
|
-
it
|
119
|
+
it "has the correct value for #post_conversion" do
|
123
120
|
length_arg_builder.pre_conversion
|
124
|
-
length_arg_builder.post_conversion.
|
125
|
-
must_equal [
|
121
|
+
_(length_arg_builder.post_conversion).
|
122
|
+
must_equal ["_v1.put_int32 0, _v3.length"]
|
126
123
|
end
|
127
124
|
end
|
128
125
|
end
|
@@ -1,117 +1,116 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::CallbackBuilder do
|
6
6
|
let(:builder) { GirFFI::Builders::CallbackBuilder.new callback_info }
|
7
7
|
|
8
|
-
describe
|
9
|
-
describe
|
10
|
-
let(:callback_info) { get_introspection_data
|
11
|
-
it
|
12
|
-
expected =
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
describe "#mapping_method_definition" do
|
9
|
+
describe "for a callback with arguments and return value" do
|
10
|
+
let(:callback_info) { get_introspection_data "Regress", "TestCallbackFull" }
|
11
|
+
it "returns a valid mapping method" do
|
12
|
+
expected = <<~CODE
|
13
|
+
def self.call_with_argument_mapping(_proc, foo, bar, path)
|
14
|
+
_v1 = foo
|
15
|
+
_v2 = bar
|
16
|
+
_v3 = path.to_utf8
|
17
|
+
_v4 = _proc.call(_v1, _v2, _v3)
|
18
|
+
return _v4
|
19
|
+
end
|
20
20
|
CODE
|
21
21
|
|
22
|
-
builder.mapping_method_definition.must_equal expected
|
22
|
+
_(builder.mapping_method_definition).must_equal expected
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
27
|
-
let(:callback_info) { get_introspection_data
|
28
|
-
it
|
29
|
-
expected =
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
describe "for a callback with no arguments or return value" do
|
27
|
+
let(:callback_info) { get_introspection_data "Regress", "TestSimpleCallback" }
|
28
|
+
it "returns a valid mapping method" do
|
29
|
+
expected = <<~CODE
|
30
|
+
def self.call_with_argument_mapping(_proc)
|
31
|
+
_proc.call()
|
32
|
+
end
|
33
33
|
CODE
|
34
34
|
|
35
|
-
builder.mapping_method_definition.must_equal expected
|
35
|
+
_(builder.mapping_method_definition).must_equal expected
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
40
|
-
let(:callback_info) { get_introspection_data
|
41
|
-
it
|
42
|
-
expected =
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
describe "for a callback with a closure argument" do
|
40
|
+
let(:callback_info) { get_introspection_data "Regress", "TestCallbackUserData" }
|
41
|
+
it "returns a valid mapping method" do
|
42
|
+
expected = <<~CODE
|
43
|
+
def self.call_with_argument_mapping(_proc, user_data)
|
44
|
+
_v1 = GirFFI::ArgHelper::OBJECT_STORE.fetch(user_data)
|
45
|
+
_v2 = _proc.call(_v1)
|
46
|
+
return _v2
|
47
|
+
end
|
48
48
|
CODE
|
49
49
|
|
50
|
-
builder.mapping_method_definition.must_equal expected
|
50
|
+
_(builder.mapping_method_definition).must_equal expected
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe
|
54
|
+
describe "for a callback with one out argument" do
|
55
55
|
let(:callback_info) do
|
56
|
-
get_introspection_data(
|
57
|
-
|
56
|
+
get_introspection_data("GIMarshallingTests",
|
57
|
+
"CallbackOneOutParameter")
|
58
58
|
end
|
59
|
-
it
|
60
|
-
expected =
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
it "returns a valid mapping method" do
|
60
|
+
expected = <<~CODE
|
61
|
+
def self.call_with_argument_mapping(_proc, a)
|
62
|
+
_v1 = a
|
63
|
+
_v2 = _proc.call()
|
64
|
+
_v1.put_float 0, _v2
|
65
|
+
end
|
66
66
|
CODE
|
67
67
|
|
68
|
-
builder.mapping_method_definition.must_equal expected
|
68
|
+
_(builder.mapping_method_definition).must_equal expected
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
describe
|
72
|
+
describe "for a callback with an inout array argument" do
|
73
73
|
let(:callback_info) do
|
74
|
-
get_introspection_data(
|
75
|
-
|
74
|
+
get_introspection_data("Regress",
|
75
|
+
"TestCallbackArrayInOut")
|
76
76
|
end
|
77
|
-
it
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
77
|
+
it "returns a valid mapping method" do
|
78
|
+
expected = <<~CODE
|
79
|
+
def self.call_with_argument_mapping(_proc, ints, length)
|
80
|
+
_v1 = length
|
81
|
+
_v2 = _v1.get_int32(0)
|
82
|
+
_v3 = ints
|
83
|
+
_v4 = GirFFI::SizedArray.wrap(:gint32, _v2, _v3.get_pointer(0))
|
84
|
+
_v5 = _proc.call(_v4)
|
85
|
+
_v1.put_int32 0, _v5.length
|
86
|
+
_v3.put_pointer 0, GirFFI::SizedArray.from(:gint32, -1, _v5)
|
87
|
+
end
|
89
88
|
CODE
|
90
89
|
|
91
|
-
builder.mapping_method_definition.must_equal expected
|
90
|
+
_(builder.mapping_method_definition).must_equal expected
|
92
91
|
end
|
93
92
|
end
|
94
93
|
|
95
|
-
describe
|
94
|
+
describe "for a callback with a value in argument" do
|
96
95
|
let(:field_info) do
|
97
|
-
get_field_introspection_data(
|
98
|
-
|
96
|
+
get_field_introspection_data("GObject",
|
97
|
+
"ObjectClass", "get_property")
|
99
98
|
end
|
100
99
|
let(:callback_info) do
|
101
100
|
field_info.field_type.interface
|
102
101
|
end
|
103
|
-
it
|
104
|
-
expected =
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
102
|
+
it "returns a valid mapping method" do
|
103
|
+
expected = <<~CODE
|
104
|
+
def self.call_with_argument_mapping(_proc, object, property_id, value, pspec)
|
105
|
+
_v1 = GObject::Object.wrap(object)
|
106
|
+
_v2 = property_id
|
107
|
+
_v3 = GObject::Value.wrap(value)
|
108
|
+
_v4 = GObject::ParamSpec.wrap(pspec)
|
109
|
+
_proc.call(_v1, _v2, _v3, _v4)
|
110
|
+
end
|
112
111
|
CODE
|
113
112
|
|
114
|
-
builder.mapping_method_definition.must_equal expected
|
113
|
+
_(builder.mapping_method_definition).must_equal expected
|
115
114
|
end
|
116
115
|
end
|
117
116
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::CallbackReturnValueBuilder do
|
6
6
|
let(:var_gen) { GirFFI::VariableNameGenerator.new }
|
@@ -12,74 +12,70 @@ describe GirFFI::Builders::CallbackReturnValueBuilder do
|
|
12
12
|
return_value_info)
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'for :gint32' do
|
20
|
-
let(:callback_info) { get_introspection_data('GIMarshallingTests', 'CallbackIntInt') }
|
15
|
+
describe "for :gint32" do
|
16
|
+
let(:callback_info) { get_introspection_data("GIMarshallingTests", "CallbackIntInt") }
|
21
17
|
|
22
|
-
it
|
23
|
-
builder.post_conversion.must_equal []
|
18
|
+
it "has no statements in #post_conversion" do
|
19
|
+
_(builder.post_conversion).must_equal []
|
24
20
|
end
|
25
21
|
|
26
|
-
it
|
27
|
-
builder.capture_variable_name.must_equal
|
28
|
-
builder.return_value_name.must_equal
|
22
|
+
it "returns the result of the callback directly" do
|
23
|
+
_(builder.capture_variable_name).must_equal "_v1"
|
24
|
+
_(builder.return_value_name).must_equal "_v1"
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
32
|
-
describe
|
28
|
+
describe "for :void" do
|
33
29
|
let(:callback_info) do
|
34
|
-
get_introspection_data(
|
35
|
-
|
30
|
+
get_introspection_data("GIMarshallingTests",
|
31
|
+
"CallbackMultipleOutParameters")
|
36
32
|
end
|
37
33
|
|
38
|
-
it
|
39
|
-
builder.post_conversion.must_equal []
|
34
|
+
it "has no statements in #post_conversion" do
|
35
|
+
_(builder.post_conversion).must_equal []
|
40
36
|
end
|
41
37
|
|
42
|
-
it
|
43
|
-
builder.capture_variable_name.must_be_nil
|
44
|
-
builder.return_value_name.must_be_nil
|
38
|
+
it "returns nothing" do
|
39
|
+
_(builder.capture_variable_name).must_be_nil
|
40
|
+
_(builder.return_value_name).must_be_nil
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
|
-
describe
|
44
|
+
describe "for :enum" do
|
49
45
|
let(:callback_info) do
|
50
|
-
get_vfunc_introspection_data(
|
51
|
-
|
52
|
-
|
46
|
+
get_vfunc_introspection_data("GIMarshallingTests",
|
47
|
+
"Object",
|
48
|
+
"vfunc_return_enum")
|
53
49
|
end
|
54
50
|
|
55
|
-
it
|
51
|
+
it "converts the result" do
|
56
52
|
# Ensure variable names are generated in order
|
57
|
-
builder.capture_variable_name.must_equal
|
58
|
-
builder.post_conversion.must_equal [
|
53
|
+
_(builder.capture_variable_name).must_equal "_v1"
|
54
|
+
_(builder.post_conversion).must_equal ["_v2 = GIMarshallingTests::Enum.to_int(_v1)"]
|
59
55
|
end
|
60
56
|
|
61
|
-
it
|
62
|
-
builder.capture_variable_name.must_equal
|
63
|
-
builder.return_value_name.must_equal
|
57
|
+
it "returns the result of the conversion" do
|
58
|
+
_(builder.capture_variable_name).must_equal "_v1"
|
59
|
+
_(builder.return_value_name).must_equal "_v2"
|
64
60
|
end
|
65
61
|
end
|
66
62
|
|
67
|
-
describe
|
63
|
+
describe "for :object with full transfer" do
|
68
64
|
let(:callback_info) do
|
69
|
-
get_vfunc_introspection_data(
|
70
|
-
|
71
|
-
|
65
|
+
get_vfunc_introspection_data("GIMarshallingTests",
|
66
|
+
"Object",
|
67
|
+
"vfunc_return_object_transfer_full")
|
72
68
|
end
|
73
69
|
|
74
|
-
it
|
70
|
+
it "increases the refcount of the result and converts it to a pointer" do
|
75
71
|
# Ensure variable names are generated in order
|
76
|
-
builder.capture_variable_name.must_equal
|
77
|
-
builder.post_conversion.must_equal [
|
72
|
+
_(builder.capture_variable_name).must_equal "_v1"
|
73
|
+
_(builder.post_conversion).must_equal ["_v1.ref", "_v2 = GObject::Object.from(_v1).to_ptr"]
|
78
74
|
end
|
79
75
|
|
80
|
-
it
|
81
|
-
builder.capture_variable_name.must_equal
|
82
|
-
builder.return_value_name.must_equal
|
76
|
+
it "returns the result of the conversion" do
|
77
|
+
_(builder.capture_variable_name).must_equal "_v1"
|
78
|
+
_(builder.return_value_name).must_equal "_v2"
|
83
79
|
end
|
84
80
|
end
|
85
81
|
end
|