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,187 +1,196 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::SignalClosureBuilder do
|
6
6
|
let(:builder) { GirFFI::Builders::SignalClosureBuilder.new signal_info }
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe "#build_class" do
|
9
9
|
let(:signal_info) do
|
10
|
-
get_signal_introspection_data
|
10
|
+
get_signal_introspection_data "Regress", "TestObj", "test"
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it "builds a descendant of RubyClosure" do
|
14
14
|
klass = builder.build_class
|
15
|
-
klass.superclass.must_equal GObject::RubyClosure
|
15
|
+
_(klass.superclass).must_equal GObject::RubyClosure
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
20
|
-
describe
|
19
|
+
describe "#marshaller_definition" do
|
20
|
+
describe "for a signal with no arguments or return value" do
|
21
21
|
let(:signal_info) do
|
22
|
-
get_signal_introspection_data
|
22
|
+
get_signal_introspection_data "Regress", "TestObj", "test"
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
expected =
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
it "returns a valid marshaller converting only the receiver" do
|
26
|
+
expected = <<~CODE
|
27
|
+
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
28
|
+
_instance = param_values.first.get_value_plain
|
29
|
+
_v1 = _instance
|
30
|
+
wrap(closure.to_ptr).invoke_block(_v1)
|
31
|
+
end
|
32
32
|
CODE
|
33
33
|
|
34
|
-
builder.marshaller_definition.must_equal expected
|
34
|
+
_(builder.marshaller_definition).must_equal expected
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
38
|
+
describe "for a signal with an argument and a return value" do
|
39
39
|
let(:signal_info) do
|
40
|
-
get_signal_introspection_data
|
41
|
-
end
|
42
|
-
|
43
|
-
it
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
return_value.set_value _v3
|
53
|
-
end
|
40
|
+
get_signal_introspection_data "Regress", "TestObj", "sig-with-int64-prop"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns a valid mapping method" do
|
44
|
+
expected = <<~CODE
|
45
|
+
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
46
|
+
_instance, i = param_values.map(&:get_value_plain)
|
47
|
+
_v1 = _instance
|
48
|
+
_v2 = i
|
49
|
+
_v3 = wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
50
|
+
return_value.set_value _v3
|
51
|
+
end
|
54
52
|
CODE
|
55
53
|
|
56
|
-
builder.marshaller_definition.must_equal expected
|
54
|
+
_(builder.marshaller_definition).must_equal expected
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
60
|
-
describe
|
58
|
+
describe "for a signal with an enum argument" do
|
61
59
|
let(:signal_info) do
|
62
|
-
get_signal_introspection_data
|
60
|
+
get_signal_introspection_data "Gio", "MountOperation", "reply"
|
63
61
|
end
|
64
62
|
|
65
|
-
it
|
66
|
-
expected =
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
63
|
+
it "returns a valid mapping method" do
|
64
|
+
expected = <<~CODE
|
65
|
+
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
66
|
+
_instance, result = param_values.map(&:get_value_plain)
|
67
|
+
_v1 = _instance
|
68
|
+
_v2 = result
|
69
|
+
wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
70
|
+
end
|
73
71
|
CODE
|
74
72
|
|
75
|
-
builder.marshaller_definition.must_equal expected
|
73
|
+
_(builder.marshaller_definition).must_equal expected
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
79
|
-
describe
|
77
|
+
describe "for a signal with a array plus length arguments" do
|
80
78
|
let(:signal_info) do
|
81
|
-
get_signal_introspection_data
|
82
|
-
end
|
83
|
-
|
84
|
-
it
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
wrap(closure.to_ptr).invoke_block(_v1, _v3)
|
94
|
-
end
|
79
|
+
get_signal_introspection_data "Regress", "TestObj", "sig-with-array-len-prop"
|
80
|
+
end
|
81
|
+
|
82
|
+
it "returns a valid mapping method" do
|
83
|
+
expected = <<~CODE
|
84
|
+
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
85
|
+
_instance, arr, len = param_values.map(&:get_value_plain)
|
86
|
+
_v1 = _instance
|
87
|
+
_v2 = len
|
88
|
+
_v3 = GirFFI::SizedArray.wrap(:guint32, _v2, arr)
|
89
|
+
wrap(closure.to_ptr).invoke_block(_v1, _v3)
|
90
|
+
end
|
95
91
|
CODE
|
96
92
|
|
97
|
-
builder.marshaller_definition.must_equal expected
|
93
|
+
_(builder.marshaller_definition).must_equal expected
|
98
94
|
end
|
99
95
|
end
|
100
96
|
|
101
|
-
describe
|
97
|
+
describe "for a signal with a struct argument" do
|
102
98
|
let(:signal_info) do
|
103
|
-
get_signal_introspection_data
|
99
|
+
get_signal_introspection_data "Regress", "TestObj", "test-with-static-scope-arg"
|
104
100
|
end
|
105
101
|
|
106
|
-
it
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
115
|
-
end
|
102
|
+
it "returns a valid mapping method" do
|
103
|
+
expected = <<~CODE
|
104
|
+
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
105
|
+
_instance, object = param_values.map(&:get_value_plain)
|
106
|
+
_v1 = _instance
|
107
|
+
_v2 = Regress::TestSimpleBoxedA.wrap(object)
|
108
|
+
wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
109
|
+
end
|
116
110
|
CODE
|
117
111
|
|
118
|
-
builder.marshaller_definition.must_equal expected
|
112
|
+
_(builder.marshaller_definition).must_equal expected
|
119
113
|
end
|
120
114
|
end
|
121
115
|
|
122
|
-
describe
|
116
|
+
describe "for a signal returning an array of integers" do
|
123
117
|
let(:signal_info) do
|
124
|
-
get_signal_introspection_data
|
125
|
-
end
|
118
|
+
get_signal_introspection_data "Regress", "TestObj", "sig-with-intarray-ret"
|
119
|
+
end
|
120
|
+
|
121
|
+
it "returns a valid mapping method" do
|
122
|
+
expected = <<~CODE
|
123
|
+
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
124
|
+
_instance, i = param_values.map(&:get_value_plain)
|
125
|
+
_v1 = _instance
|
126
|
+
_v2 = i
|
127
|
+
_v3 = wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
128
|
+
_v4 = GLib::Array.from(:gint32, _v3)
|
129
|
+
return_value.set_value _v4
|
130
|
+
end
|
131
|
+
CODE
|
126
132
|
|
127
|
-
|
128
|
-
|
133
|
+
_(builder.marshaller_definition).must_equal expected
|
134
|
+
end
|
135
|
+
end
|
129
136
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
137
|
+
describe "for a signal returning an string" do
|
138
|
+
let(:signal_info) do
|
139
|
+
get_signal_introspection_data "Gtk", "Scale", "format-value"
|
140
|
+
end
|
141
|
+
|
142
|
+
it "returns a mapping method that passes the string result to return_value directly" do
|
143
|
+
expected = <<~CODE
|
144
|
+
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
145
|
+
_instance, value = param_values.map(&:get_value_plain)
|
146
|
+
_v1 = _instance
|
147
|
+
_v2 = value
|
148
|
+
_v3 = wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
149
|
+
return_value.set_value _v3
|
150
|
+
end
|
139
151
|
CODE
|
140
152
|
|
141
|
-
builder.marshaller_definition.must_equal expected
|
153
|
+
_(builder.marshaller_definition).must_equal expected
|
142
154
|
end
|
143
155
|
end
|
144
156
|
|
145
|
-
describe
|
157
|
+
describe "for a signal with GList argument" do
|
146
158
|
let(:signal_info) do
|
147
|
-
get_signal_introspection_data
|
159
|
+
get_signal_introspection_data "Regress", "AnnotationObject", "list-signal"
|
148
160
|
end
|
149
161
|
|
150
|
-
it
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
_v3 = wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
159
|
-
return_value.set_value _v3
|
160
|
-
end
|
162
|
+
it "returns a valid mapping method" do
|
163
|
+
expected = <<~CODE
|
164
|
+
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
165
|
+
_instance, list = param_values.map(&:get_value_plain)
|
166
|
+
_v1 = _instance
|
167
|
+
_v2 = GLib::List.wrap(:utf8, list)
|
168
|
+
wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
169
|
+
end
|
161
170
|
CODE
|
162
171
|
|
163
|
-
builder.marshaller_definition.must_equal expected
|
172
|
+
_(builder.marshaller_definition).must_equal expected
|
164
173
|
end
|
165
174
|
end
|
166
175
|
|
167
|
-
describe
|
176
|
+
describe "for a signal with GError argument" do
|
168
177
|
let(:signal_info) do
|
169
|
-
get_signal_introspection_data
|
178
|
+
get_signal_introspection_data "Regress", "TestObj", "sig-with-gerror"
|
170
179
|
end
|
171
180
|
|
172
|
-
it
|
173
|
-
|
181
|
+
it "returns a valid mapping method" do
|
182
|
+
skip_below "1.61.1"
|
174
183
|
|
175
|
-
expected =
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
184
|
+
expected = <<~CODE
|
185
|
+
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
186
|
+
_instance, error = param_values.map(&:get_value_plain)
|
187
|
+
_v1 = _instance
|
188
|
+
_v2 = GLib::Error.wrap(error)
|
189
|
+
wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
190
|
+
end
|
182
191
|
CODE
|
183
192
|
|
184
|
-
builder.marshaller_definition.must_equal expected
|
193
|
+
_(builder.marshaller_definition).must_equal expected
|
185
194
|
end
|
186
195
|
end
|
187
196
|
end
|
@@ -1,45 +1,45 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::StructBuilder do
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
info = get_introspection_data
|
6
|
+
describe "#layout_specification" do
|
7
|
+
it "returns the correct layout for Regress::TestStructA" do
|
8
|
+
info = get_introspection_data "Regress", "TestStructA"
|
9
9
|
builder = GirFFI::Builders::StructBuilder.new info
|
10
|
-
builder.layout_specification.must_equal [:some_int, :int32, 0,
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
_(builder.layout_specification).must_equal [:some_int, :int32, 0,
|
11
|
+
:some_int8, :int8, 4,
|
12
|
+
:some_double, :double, 8,
|
13
|
+
:some_enum, Regress::TestEnum, 16]
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
16
|
+
describe "for a struct with a simple layout" do
|
17
17
|
before do
|
18
18
|
@field = Object.new
|
19
19
|
|
20
20
|
@struct = Object.new
|
21
|
-
allow(@struct).to receive(:namespace).and_return
|
22
|
-
allow(@struct).to receive(:safe_name).and_return
|
21
|
+
allow(@struct).to receive(:namespace).and_return "Foo"
|
22
|
+
allow(@struct).to receive(:safe_name).and_return "Bar"
|
23
23
|
allow(@struct).to receive(:fields).and_return [@field]
|
24
24
|
|
25
25
|
@builder = GirFFI::Builders::StructBuilder.new @struct
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it "creates the correct layout specification" do
|
29
29
|
expect(@field).to receive(:layout_specification).and_return [:bar, :int32, 0]
|
30
30
|
spec = @builder.layout_specification
|
31
31
|
assert_equal [:bar, :int32, 0], spec
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe
|
36
|
-
it
|
35
|
+
describe "for a struct with a layout with a complex type" do
|
36
|
+
it "does not flatten the complex type specification" do
|
37
37
|
expect(simplefield = Object.new).to receive(:layout_specification).and_return [:bar, :foo, 0]
|
38
38
|
expect(complexfield = Object.new).to receive(:layout_specification).and_return [:baz, [:qux, 2], 0]
|
39
39
|
expect(struct = Object.new).to receive(:fields).and_return [simplefield, complexfield]
|
40
40
|
|
41
|
-
allow(struct).to receive(:safe_name).and_return
|
42
|
-
allow(struct).to receive(:namespace).and_return
|
41
|
+
allow(struct).to receive(:safe_name).and_return "Bar"
|
42
|
+
allow(struct).to receive(:namespace).and_return "Foo"
|
43
43
|
|
44
44
|
builder = GirFFI::Builders::StructBuilder.new struct
|
45
45
|
spec = builder.layout_specification
|
@@ -48,39 +48,39 @@ describe GirFFI::Builders::StructBuilder do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
describe
|
52
|
-
it
|
53
|
-
info = get_introspection_data
|
51
|
+
describe "#superclass" do
|
52
|
+
it "returns StructBase for a normal struct" do
|
53
|
+
info = get_introspection_data "Regress", "TestStructA"
|
54
54
|
builder = GirFFI::Builders::StructBuilder.new info
|
55
|
-
builder.superclass.must_equal GirFFI::StructBase
|
55
|
+
_(builder.superclass).must_equal GirFFI::StructBase
|
56
56
|
end
|
57
57
|
|
58
|
-
it
|
59
|
-
info = get_introspection_data
|
58
|
+
it "returns BoxedBase for a boxed type" do
|
59
|
+
info = get_introspection_data "Regress", "TestSimpleBoxedB"
|
60
60
|
builder = GirFFI::Builders::StructBuilder.new info
|
61
|
-
builder.superclass.must_equal GirFFI::BoxedBase
|
61
|
+
_(builder.superclass).must_equal GirFFI::BoxedBase
|
62
62
|
end
|
63
63
|
|
64
|
-
it
|
65
|
-
info = get_introspection_data
|
64
|
+
it "returns the GObject parent class for a type class" do
|
65
|
+
info = get_introspection_data "GIMarshallingTests", "SubSubObjectClass"
|
66
66
|
builder = GirFFI::Builders::StructBuilder.new info
|
67
|
-
builder.superclass.must_equal GIMarshallingTests::SubObjectClass
|
67
|
+
_(builder.superclass).must_equal GIMarshallingTests::SubObjectClass
|
68
68
|
end
|
69
69
|
|
70
|
-
it
|
71
|
-
info = get_introspection_data
|
70
|
+
it "returns ObjectClass for InitiallyUnownedClass" do
|
71
|
+
info = get_introspection_data "GObject", "InitiallyUnownedClass"
|
72
72
|
builder = GirFFI::Builders::StructBuilder.new info
|
73
|
-
builder.superclass.must_equal GObject::ObjectClass
|
73
|
+
_(builder.superclass).must_equal GObject::ObjectClass
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
describe
|
77
|
+
describe "#setup_class" do
|
78
78
|
before do
|
79
79
|
save_module :Regress
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
83
|
-
info = get_introspection_data
|
82
|
+
it "stubs the structs methods" do
|
83
|
+
info = get_introspection_data "Regress", "TestStructA"
|
84
84
|
builder = GirFFI::Builders::StructBuilder.new info
|
85
85
|
builder.setup_class
|
86
86
|
assert_defines_instance_method Regress::TestStructA, :clone
|
@@ -1,35 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
GirFFI.setup :GIMarshallingTests
|
6
6
|
|
7
7
|
describe GirFFI::Builders::UnintrospectableBoxedBuilder do
|
8
8
|
let(:instance) { GIMarshallingTests::PropertiesObject.new }
|
9
|
-
let(:property) { instance.object_class.find_property
|
9
|
+
let(:property) { instance.object_class.find_property "some-boxed-glist" }
|
10
10
|
let(:gtype) { property.value_type }
|
11
11
|
let(:info) { GirFFI::UnintrospectableBoxedInfo.new(gtype) }
|
12
12
|
let(:bldr) { GirFFI::Builders::UnintrospectableBoxedBuilder.new(info) }
|
13
13
|
let(:boxed_class) { bldr.build_class }
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
'PropertiesObject',
|
18
|
-
'some-boxed-glist')
|
15
|
+
it "builds a class" do
|
16
|
+
_(boxed_class).must_be_instance_of Class
|
19
17
|
end
|
20
18
|
|
21
|
-
it
|
22
|
-
boxed_class.
|
19
|
+
it "builds a class derived from GirFFI::BoxedBase" do
|
20
|
+
_(boxed_class.superclass).must_equal GirFFI::BoxedBase
|
23
21
|
end
|
24
22
|
|
25
|
-
it
|
26
|
-
boxed_class.superclass.must_equal GirFFI::BoxedBase
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'returns the same class when built again' do
|
23
|
+
it "returns the same class when built again" do
|
30
24
|
other_bldr = GirFFI::Builders::UnintrospectableBoxedBuilder.new(info)
|
31
25
|
other_class = other_bldr.build_class
|
32
26
|
|
33
|
-
other_class.must_equal boxed_class
|
27
|
+
_(other_class).must_equal boxed_class
|
34
28
|
end
|
35
29
|
end
|