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,53 +1,53 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
|
+
require "gir_ffi/user_defined_object_info"
|
5
5
|
|
6
6
|
GirFFI.setup :GIMarshallingTests
|
7
7
|
|
8
8
|
describe GirFFI::UserDefinedObjectInfo do
|
9
|
-
describe
|
9
|
+
describe "#described_class" do
|
10
10
|
let(:info) { GirFFI::UserDefinedObjectInfo.new :some_class }
|
11
11
|
|
12
|
-
it
|
13
|
-
info.described_class.must_equal :some_class
|
12
|
+
it "returns the class passed to #initialize" do
|
13
|
+
_(info.described_class).must_equal :some_class
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
17
|
+
describe "#install_property" do
|
18
18
|
let(:info) { GirFFI::UserDefinedObjectInfo.new :some_class }
|
19
19
|
let(:foo_spec) { Object.new }
|
20
20
|
|
21
|
-
it
|
21
|
+
it "adds the passed in property to the list of properties" do
|
22
22
|
info.install_property foo_spec
|
23
|
-
info.properties.must_equal [foo_spec]
|
23
|
+
_(info.properties).must_equal [foo_spec]
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe
|
27
|
+
describe "#install_vfunc_implementation" do
|
28
28
|
let(:info) { GirFFI::UserDefinedObjectInfo.new :some_class }
|
29
29
|
let(:implementation) { Object.new }
|
30
30
|
|
31
|
-
it
|
32
|
-
info.vfunc_implementations.must_equal []
|
31
|
+
it "adds to the list of vfunc implementations" do
|
32
|
+
_(info.vfunc_implementations).must_equal []
|
33
33
|
info.install_vfunc_implementation :foo, implementation
|
34
|
-
info.vfunc_implementations.map(&:name).must_equal [:foo]
|
34
|
+
_(info.vfunc_implementations.map(&:name)).must_equal [:foo]
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it "stores the passed-in implementation in the implementation object" do
|
38
38
|
info.install_vfunc_implementation :foo, implementation
|
39
39
|
impl = info.vfunc_implementations.first
|
40
|
-
impl.implementation.must_equal implementation
|
40
|
+
_(impl.implementation).must_equal implementation
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
43
|
+
it "provides a default implementation" do
|
44
44
|
info.install_vfunc_implementation :foo
|
45
45
|
impl = info.vfunc_implementations.first
|
46
|
-
impl.implementation.class.must_equal Proc
|
46
|
+
_(impl.implementation.class).must_equal Proc
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
50
|
+
describe "#initialize" do
|
51
51
|
let(:foo_spec) { Object.new }
|
52
52
|
let(:bar_spec) { Object.new }
|
53
53
|
let(:info) do
|
@@ -62,48 +62,48 @@ describe GirFFI::UserDefinedObjectInfo do
|
|
62
62
|
allow(bar_spec).to receive(:get_name).and_return :bar
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
66
|
-
info.properties.map(&:get_name).must_equal [:foo, :bar]
|
65
|
+
it "yields the new object to the block passed" do
|
66
|
+
_(info.properties.map(&:get_name)).must_equal [:foo, :bar]
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe
|
70
|
+
describe "#g_name" do
|
71
71
|
let(:user_class) { Object.new }
|
72
72
|
let(:info) { GirFFI::UserDefinedObjectInfo.new user_class }
|
73
73
|
|
74
74
|
before do
|
75
|
-
allow(user_class).to receive(:name).and_return
|
75
|
+
allow(user_class).to receive(:name).and_return "foo"
|
76
76
|
end
|
77
77
|
|
78
78
|
it "returns the described class' name by default" do
|
79
|
-
info.g_name.must_equal
|
79
|
+
_(info.g_name).must_equal "foo"
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
83
|
-
info.g_name =
|
84
|
-
info.g_name.must_equal
|
82
|
+
it "returns the the name set by #g_name= if present" do
|
83
|
+
info.g_name = "bar"
|
84
|
+
_(info.g_name).must_equal "bar"
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
describe
|
88
|
+
describe "#find_method" do
|
89
89
|
let(:user_class) { Object.new }
|
90
90
|
let(:info) { GirFFI::UserDefinedObjectInfo.new user_class }
|
91
91
|
|
92
|
-
it
|
93
|
-
info.find_method(
|
92
|
+
it "finds no methods" do
|
93
|
+
_(info.find_method("foo")).must_be_nil
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
describe
|
97
|
+
describe "#find_signal" do
|
98
98
|
let(:user_class) { Object.new }
|
99
99
|
let(:info) { GirFFI::UserDefinedObjectInfo.new user_class }
|
100
100
|
|
101
|
-
it
|
102
|
-
info.find_signal(
|
101
|
+
it "finds no signals" do
|
102
|
+
_(info.find_signal("foo")).must_be_nil
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
describe
|
106
|
+
describe "#interfaces" do
|
107
107
|
let(:modul) { GIMarshallingTests::Interface }
|
108
108
|
let(:user_class) { Class.new GIMarshallingTests::Object }
|
109
109
|
let(:info) { GirFFI::UserDefinedObjectInfo.new user_class }
|
@@ -112,8 +112,8 @@ describe GirFFI::UserDefinedObjectInfo do
|
|
112
112
|
user_class.send :include, modul
|
113
113
|
end
|
114
114
|
|
115
|
-
it
|
116
|
-
info.interfaces.must_equal [modul.gir_info]
|
115
|
+
it "returns the interface infos for the include modules" do
|
116
|
+
_(info.interfaces).must_equal [modul.gir_info]
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -1,39 +1,39 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
|
+
require "gir_ffi/user_defined_property_info"
|
5
5
|
|
6
6
|
describe GirFFI::UserDefinedPropertyInfo do
|
7
7
|
let(:pspec) do
|
8
|
-
GObject.param_spec_int(
|
9
|
-
|
8
|
+
GObject.param_spec_int("foo-bar", "foo bar",
|
9
|
+
"Foo Bar",
|
10
10
|
1, 3, 2,
|
11
11
|
readable: true, writable: true)
|
12
12
|
end
|
13
13
|
let(:container) { Object.new }
|
14
14
|
let(:info) { GirFFI::UserDefinedPropertyInfo.new pspec, container, 24 }
|
15
15
|
|
16
|
-
describe
|
17
|
-
it
|
18
|
-
info.param_spec.must_equal pspec
|
16
|
+
describe "#param_spec" do
|
17
|
+
it "returns the passed in parameter specification" do
|
18
|
+
_(info.param_spec).must_equal pspec
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
describe
|
23
|
-
it
|
24
|
-
info.name.must_equal
|
22
|
+
describe "#name" do
|
23
|
+
it "returns the accessor name from the parameter specification" do
|
24
|
+
_(info.name).must_equal "foo_bar"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe
|
29
|
-
it
|
30
|
-
info.ffi_type.must_equal :int
|
28
|
+
describe "#ffi_type" do
|
29
|
+
it "returns the ffi type corresponding to the type tag" do
|
30
|
+
_(info.ffi_type).must_equal :int
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
35
|
-
it
|
36
|
-
info.field_type.tag.must_equal :gint
|
34
|
+
describe "#field_type.tag" do
|
35
|
+
it "returns the mapped type symbol" do
|
36
|
+
_(info.field_type.tag).must_equal :gint
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
|
-
require
|
5
|
+
require "gir_ffi/variable_name_generator"
|
6
6
|
|
7
7
|
describe GirFFI::VariableNameGenerator do
|
8
|
-
describe
|
9
|
-
it
|
8
|
+
describe "#new_var" do
|
9
|
+
it "generates a sequence of predictable variable names" do
|
10
10
|
gen = GirFFI::VariableNameGenerator.new
|
11
11
|
|
12
|
-
assert_equal
|
13
|
-
assert_equal
|
14
|
-
assert_equal
|
15
|
-
assert_equal
|
12
|
+
assert_equal "_v1", gen.new_var
|
13
|
+
assert_equal "_v2", gen.new_var
|
14
|
+
assert_equal "_v3", gen.new_var
|
15
|
+
assert_equal "_v4", gen.new_var
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
|
-
describe
|
6
|
-
it
|
7
|
-
GirFFI::VERSION.must_match(/\d+\.\d+\.\d+/)
|
5
|
+
describe "GirFFI::VERSION" do
|
6
|
+
it "is set to a valid version number" do
|
7
|
+
_(GirFFI::VERSION).must_match(/\d+\.\d+\.\d+/)
|
8
8
|
end
|
9
9
|
end
|
@@ -1,108 +1,108 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::ZeroTerminated do
|
6
|
-
describe
|
6
|
+
describe ".from" do
|
7
7
|
let(:result) { GirFFI::ZeroTerminated.from :int32, [1, 2, 3] }
|
8
8
|
|
9
|
-
it
|
9
|
+
it "converts the passed array into a zero-terminated c array" do
|
10
10
|
ptr = result.to_ptr
|
11
|
-
ptr.read_array_of_int32(4).must_equal [1, 2, 3, 0]
|
11
|
+
_(ptr.read_array_of_int32(4)).must_equal [1, 2, 3, 0]
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
15
|
-
result.must_be_instance_of GirFFI::ZeroTerminated
|
14
|
+
it "returns a GirFFI::ZeroTerminated object" do
|
15
|
+
_(result).must_be_instance_of GirFFI::ZeroTerminated
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it "works for Regress::TestEnum from numbers" do
|
19
19
|
GirFFI.setup :Regress
|
20
20
|
enum_arr = GirFFI::ZeroTerminated.from Regress::TestEnum, [1, -1, 48]
|
21
21
|
ptr = enum_arr.to_ptr
|
22
|
-
ptr.read_array_of_int32(4).must_equal [1, -1, 48, 0]
|
22
|
+
_(ptr.read_array_of_int32(4)).must_equal [1, -1, 48, 0]
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it "works for Regress::TestEnum from symbols" do
|
26
26
|
GirFFI.setup :Regress
|
27
27
|
enum_arr = GirFFI::ZeroTerminated.from Regress::TestEnum, [:value2, :value3, :value4]
|
28
28
|
ptr = enum_arr.to_ptr
|
29
|
-
ptr.read_array_of_int32(4).must_equal [1, -1, 48, 0]
|
29
|
+
_(ptr.read_array_of_int32(4)).must_equal [1, -1, 48, 0]
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
describe
|
34
|
-
it
|
33
|
+
describe ".wrap" do
|
34
|
+
it "wraps the given type and pointer" do
|
35
35
|
ptr = GirFFI::InPointer.from_array :int32, [1, 2, 3, 0]
|
36
36
|
zt = GirFFI::ZeroTerminated.wrap :foo, ptr
|
37
|
-
zt.element_type.must_equal :foo
|
38
|
-
zt.to_ptr.must_equal ptr
|
37
|
+
_(zt.element_type).must_equal :foo
|
38
|
+
_(zt.to_ptr).must_equal ptr
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
describe
|
43
|
-
it
|
42
|
+
describe "#each" do
|
43
|
+
it "yields each element" do
|
44
44
|
zt = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
|
45
45
|
arr = []
|
46
46
|
zt.each do |int|
|
47
47
|
arr << int
|
48
48
|
end
|
49
|
-
arr.must_equal [1, 2, 3]
|
49
|
+
_(arr).must_equal [1, 2, 3]
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
52
|
+
it "yields zero times for a ZeroTerminated wrapping a null pointer" do
|
53
53
|
zt = GirFFI::ZeroTerminated.wrap :int32, FFI::Pointer.new(0)
|
54
54
|
zt.each do |_str|
|
55
55
|
flunk
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
59
|
+
it "works for :int8" do
|
60
60
|
zt = GirFFI::ZeroTerminated.from :int8, [1, 2, 3]
|
61
61
|
arr = []
|
62
62
|
zt.each do |int|
|
63
63
|
arr << int
|
64
64
|
end
|
65
|
-
arr.must_equal [1, 2, 3]
|
65
|
+
_(arr).must_equal [1, 2, 3]
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
describe
|
70
|
-
it
|
69
|
+
describe "#==" do
|
70
|
+
it "returns true when comparing to an array with the same elements" do
|
71
71
|
zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
|
72
72
|
|
73
|
-
(zero_terminated == [1, 2, 3]).must_equal true
|
73
|
+
_(zero_terminated == [1, 2, 3]).must_equal true
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it "returns false when comparing to an array with different elements" do
|
77
77
|
zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
|
78
78
|
|
79
|
-
(zero_terminated == [1, 2]).must_equal false
|
79
|
+
_(zero_terminated == [1, 2]).must_equal false
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
82
|
+
it "returns true when comparing to a zero-terminated array with the same elements" do
|
83
83
|
zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
|
84
84
|
other = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
|
85
85
|
|
86
|
-
(zero_terminated == other).must_equal true
|
86
|
+
_(zero_terminated == other).must_equal true
|
87
87
|
end
|
88
88
|
|
89
|
-
it
|
89
|
+
it "returns false when comparing to a zero-terminated array with different elements" do
|
90
90
|
zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
|
91
91
|
other = GirFFI::ZeroTerminated.from :int32, [1, 2]
|
92
92
|
|
93
|
-
(zero_terminated == other).must_equal false
|
93
|
+
_(zero_terminated == other).must_equal false
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
98
|
-
GirFFI::ZeroTerminated.must_include Enumerable
|
97
|
+
it "includes Enumerable" do
|
98
|
+
_(GirFFI::ZeroTerminated).must_include Enumerable
|
99
99
|
end
|
100
100
|
|
101
|
-
describe
|
102
|
-
it
|
101
|
+
describe "#to_a" do
|
102
|
+
it "works for Regress::TestEnum" do
|
103
103
|
GirFFI.setup :Regress
|
104
104
|
enum_arr = GirFFI::ZeroTerminated.from Regress::TestEnum, [1, 48, -1]
|
105
|
-
enum_arr.to_a.must_equal [:value2, :value4, :value3]
|
105
|
+
_(enum_arr.to_a).must_equal [:value2, :value4, :value3]
|
106
106
|
end
|
107
107
|
end
|
108
108
|
end
|
data/test/gir_ffi_test_helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "introspection_test_helper"
|
4
4
|
|
5
|
-
require
|
5
|
+
require "gir_ffi"
|
6
6
|
|
7
7
|
# Global sequence provider. Needed to make unique class names.
|
8
8
|
class Sequence
|
@@ -81,4 +81,4 @@ module GirFFITestExtensions
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
Minitest::Test.
|
84
|
+
Minitest::Test.include GirFFITestExtensions
|
@@ -1,62 +1,58 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
GirFFI.setup :Regress
|
6
6
|
|
7
7
|
class CallbackTestException < RuntimeError; end
|
8
8
|
|
9
|
-
describe
|
10
|
-
describe
|
9
|
+
describe "An exception in a callback" do
|
10
|
+
describe "for signals" do
|
11
11
|
let(:object) { Regress::TestSubObj.new }
|
12
12
|
|
13
13
|
before do
|
14
|
-
object.signal_connect
|
15
|
-
raise CallbackTestException,
|
14
|
+
object.signal_connect "test" do
|
15
|
+
raise CallbackTestException, "Boom"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
20
|
-
it
|
21
|
-
proc { GObject.signal_emit object,
|
19
|
+
describe "when the signal is emitted synchronously" do
|
20
|
+
it "raises an error" do
|
21
|
+
_(proc { GObject.signal_emit object, "test" }).must_raise CallbackTestException
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
26
|
-
it
|
25
|
+
describe "when the signal is emitted during an event loop" do
|
26
|
+
it "causes loop run to be terminated with an exception" do
|
27
27
|
main_loop = GLib::MainLoop.new nil, false
|
28
28
|
|
29
29
|
GLib.timeout_add GLib::PRIORITY_DEFAULT, 1 do
|
30
|
-
GObject.signal_emit object,
|
30
|
+
GObject.signal_emit object, "test"
|
31
31
|
false
|
32
32
|
end
|
33
33
|
# Guard against runaway loop
|
34
34
|
GLib.timeout_add GLib::PRIORITY_DEFAULT, 500 do
|
35
35
|
main_loop.quit
|
36
36
|
end
|
37
|
-
proc
|
38
|
-
main_loop.run
|
39
|
-
end.must_raise CallbackTestException
|
37
|
+
_(proc { main_loop.run }).must_raise CallbackTestException
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
43
41
|
|
44
|
-
describe
|
45
|
-
describe
|
46
|
-
it
|
42
|
+
describe "for other callbacks" do
|
43
|
+
describe "when the callback occurs during an event loop" do
|
44
|
+
it "causes loop run to be terminated with an exception" do
|
47
45
|
main_loop = GLib::MainLoop.new nil, false
|
48
46
|
|
49
47
|
GLib.timeout_add GLib::PRIORITY_DEFAULT, 1 do
|
50
|
-
raise CallbackTestException,
|
48
|
+
raise CallbackTestException, "Boom"
|
51
49
|
end
|
52
50
|
# Guard against runaway loop
|
53
51
|
GLib.timeout_add GLib::PRIORITY_DEFAULT, 500 do
|
54
52
|
main_loop.quit
|
55
53
|
end
|
56
54
|
|
57
|
-
proc
|
58
|
-
main_loop.run
|
59
|
-
end.must_raise CallbackTestException
|
55
|
+
_(proc { main_loop.run }).must_raise CallbackTestException
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|