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,27 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GLib::SList do
|
6
|
-
it
|
6
|
+
it "knows its element type" do
|
7
7
|
arr = GLib::SList.new :gint32
|
8
8
|
assert_equal :gint32, arr.element_type
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
12
|
-
it
|
11
|
+
describe "#prepend" do
|
12
|
+
it "prepends integer values" do
|
13
13
|
lst = GLib::SList.new :gint32
|
14
14
|
res = lst.prepend 1
|
15
15
|
assert_equal 1, res.data
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it "prepends string values" do
|
19
19
|
lst = GLib::SList.new :utf8
|
20
|
-
res = lst.prepend
|
21
|
-
assert_equal
|
20
|
+
res = lst.prepend "bla"
|
21
|
+
assert_equal "bla", res.data
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it "prepends multiple values into a single list" do
|
25
25
|
lst = GLib::SList.new :gint32
|
26
26
|
|
27
27
|
res = lst.prepend 1
|
@@ -33,44 +33,44 @@ describe GLib::SList do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe
|
37
|
-
it
|
36
|
+
describe "::from" do
|
37
|
+
it "creates a GSList from a Ruby array" do
|
38
38
|
lst = GLib::SList.from :gint32, [3, 2, 1]
|
39
39
|
assert_equal [3, 2, 1], lst.to_a
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
42
|
+
it "return its argument if given a GSList" do
|
43
43
|
lst = GLib::SList.from :gint32, [3, 2, 1]
|
44
44
|
lst2 = GLib::SList.from :gint32, lst
|
45
45
|
assert_equal lst, lst2
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
describe
|
50
|
-
it
|
49
|
+
describe "#==" do
|
50
|
+
it "returns true when comparing to an array with the same elements" do
|
51
51
|
list = GLib::SList.from :gint32, [1, 2, 3]
|
52
52
|
|
53
|
-
list.must_be :==, [1, 2, 3]
|
53
|
+
_(list).must_be :==, [1, 2, 3]
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it "returns false when comparing to an array with different elements" do
|
57
57
|
list = GLib::SList.from :gint32, [1, 2, 3]
|
58
58
|
|
59
|
-
list.wont_be :==, [1, 2]
|
59
|
+
_(list).wont_be :==, [1, 2]
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
62
|
+
it "returns true when comparing to a list with the same elements" do
|
63
63
|
list = GLib::SList.from :gint32, [1, 2, 3]
|
64
64
|
other = GLib::SList.from :gint32, [1, 2, 3]
|
65
65
|
|
66
|
-
list.must_be :==, other
|
66
|
+
_(list).must_be :==, other
|
67
67
|
end
|
68
68
|
|
69
|
-
it
|
69
|
+
it "returns false when comparing to a list with different elements" do
|
70
70
|
list = GLib::SList.from :gint32, [1, 2, 3]
|
71
71
|
other = GLib::SList.from :gint32, [1, 2]
|
72
72
|
|
73
|
-
list.wont_be :==, other
|
73
|
+
_(list).wont_be :==, other
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
data/test/ffi-glib/strv_test.rb
CHANGED
@@ -1,60 +1,60 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "base_test_helper"
|
4
4
|
|
5
5
|
describe GLib::Strv do
|
6
|
-
describe
|
7
|
-
it
|
6
|
+
describe "::from" do
|
7
|
+
it "creates a Strv from a Ruby array" do
|
8
8
|
strv = GLib::Strv.from %w(1 2 3)
|
9
|
-
strv.must_be_instance_of GLib::Strv
|
10
|
-
strv.to_a.must_equal %w(1 2 3)
|
9
|
+
_(strv).must_be_instance_of GLib::Strv
|
10
|
+
_(strv.to_a).must_equal %w(1 2 3)
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it "return its argument if given a Strv" do
|
14
14
|
strv = GLib::Strv.from %w(1 2 3)
|
15
15
|
strv2 = GLib::Strv.from strv
|
16
16
|
assert strv2.equal? strv
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it "wraps its argument if given a pointer" do
|
20
20
|
strv = GLib::Strv.from %w(1 2 3)
|
21
21
|
|
22
22
|
pointer = strv.to_ptr
|
23
|
-
pointer.must_be_kind_of FFI::Pointer
|
23
|
+
_(pointer).must_be_kind_of FFI::Pointer
|
24
24
|
|
25
25
|
strv2 = GLib::Strv.from pointer
|
26
26
|
|
27
|
-
strv2.must_be_kind_of GLib::Strv
|
27
|
+
_(strv2).must_be_kind_of GLib::Strv
|
28
28
|
refute strv2.equal? strv
|
29
|
-
strv2.to_a.must_equal strv.to_a
|
29
|
+
_(strv2.to_a).must_equal strv.to_a
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
describe
|
34
|
-
it
|
33
|
+
describe "#==" do
|
34
|
+
it "returns true when comparing to an array with the same elements" do
|
35
35
|
strv = GLib::Strv.from %w(1 2 3)
|
36
36
|
|
37
|
-
strv.must_be :==, %w(1 2 3)
|
37
|
+
_(strv).must_be :==, %w(1 2 3)
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
40
|
+
it "returns false when comparing to an array with different elements" do
|
41
41
|
strv = GLib::Strv.from %w(1 2 3)
|
42
42
|
|
43
|
-
strv.wont_be :==, %w(1 2)
|
43
|
+
_(strv).wont_be :==, %w(1 2)
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
46
|
+
it "returns true when comparing to a strv with the same elements" do
|
47
47
|
strv = GLib::Strv.from %w(1 2 3)
|
48
48
|
other = GLib::Strv.from %w(1 2 3)
|
49
49
|
|
50
|
-
strv.must_be :==, other
|
50
|
+
_(strv).must_be :==, other
|
51
51
|
end
|
52
52
|
|
53
|
-
it
|
53
|
+
it "returns false when comparing to a strv with different elements" do
|
54
54
|
strv = GLib::Strv.from %w(1 2 3)
|
55
55
|
other = GLib::Strv.from %w(1 2)
|
56
56
|
|
57
|
-
strv.wont_be :==, other
|
57
|
+
_(strv).wont_be :==, other
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GLib::Variant do
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
var = GLib::Variant.new_string(
|
9
|
-
var.get_string.must_equal
|
6
|
+
describe "#get_string" do
|
7
|
+
it "returns just the contained string" do
|
8
|
+
var = GLib::Variant.new_string("Foo")
|
9
|
+
_(var.get_string).must_equal "Foo"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,71 +1,75 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
|
-
require
|
5
|
+
require "ffi-gobject"
|
6
6
|
|
7
7
|
GirFFI.setup :GIMarshallingTests
|
8
8
|
|
9
9
|
describe GObject do
|
10
|
-
describe
|
11
|
-
it
|
10
|
+
describe ".type_init" do
|
11
|
+
it "does not raise an error" do
|
12
12
|
GObject.type_init
|
13
13
|
pass
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
18
|
-
GObject::TYPE_INVALID.must_equal GObject.type_from_name(
|
19
|
-
GObject.type_name(GObject::TYPE_INVALID).must_be_nil
|
17
|
+
it "has constants for the fundamental GTypes" do
|
18
|
+
_(GObject::TYPE_INVALID).must_equal GObject.type_from_name("invalid")
|
19
|
+
_(GObject.type_name(GObject::TYPE_INVALID)).must_be_nil
|
20
20
|
|
21
|
-
GObject.type_name(GObject::TYPE_NONE).must_equal
|
22
|
-
GObject.type_name(GObject::TYPE_INTERFACE).must_equal
|
23
|
-
GObject.type_name(GObject::TYPE_CHAR).must_equal
|
24
|
-
GObject.type_name(GObject::TYPE_UCHAR).must_equal
|
25
|
-
GObject.type_name(GObject::TYPE_BOOLEAN).must_equal
|
26
|
-
GObject.type_name(GObject::TYPE_INT).must_equal
|
27
|
-
GObject.type_name(GObject::TYPE_UINT).must_equal
|
28
|
-
GObject.type_name(GObject::TYPE_LONG).must_equal
|
29
|
-
GObject.type_name(GObject::TYPE_ULONG).must_equal
|
30
|
-
GObject.type_name(GObject::TYPE_INT64).must_equal
|
31
|
-
GObject.type_name(GObject::TYPE_UINT64).must_equal
|
32
|
-
GObject.type_name(GObject::TYPE_ENUM).must_equal
|
33
|
-
GObject.type_name(GObject::TYPE_FLAGS).must_equal
|
34
|
-
GObject.type_name(GObject::TYPE_FLOAT).must_equal
|
35
|
-
GObject.type_name(GObject::TYPE_DOUBLE).must_equal
|
36
|
-
GObject.type_name(GObject::TYPE_STRING).must_equal
|
37
|
-
GObject.type_name(GObject::TYPE_POINTER).must_equal
|
38
|
-
GObject.type_name(GObject::TYPE_BOXED).must_equal
|
39
|
-
GObject.type_name(GObject::TYPE_PARAM).must_equal
|
40
|
-
GObject.type_name(GObject::TYPE_OBJECT).must_equal
|
41
|
-
GObject.type_name(GObject::TYPE_GTYPE).must_equal
|
42
|
-
GObject.type_name(GObject::TYPE_VARIANT).must_equal
|
43
|
-
|
44
|
-
GObject.type_name(GObject::
|
21
|
+
_(GObject.type_name(GObject::TYPE_NONE)).must_equal "void"
|
22
|
+
_(GObject.type_name(GObject::TYPE_INTERFACE)).must_equal "GInterface"
|
23
|
+
_(GObject.type_name(GObject::TYPE_CHAR)).must_equal "gchar"
|
24
|
+
_(GObject.type_name(GObject::TYPE_UCHAR)).must_equal "guchar"
|
25
|
+
_(GObject.type_name(GObject::TYPE_BOOLEAN)).must_equal "gboolean"
|
26
|
+
_(GObject.type_name(GObject::TYPE_INT)).must_equal "gint"
|
27
|
+
_(GObject.type_name(GObject::TYPE_UINT)).must_equal "guint"
|
28
|
+
_(GObject.type_name(GObject::TYPE_LONG)).must_equal "glong"
|
29
|
+
_(GObject.type_name(GObject::TYPE_ULONG)).must_equal "gulong"
|
30
|
+
_(GObject.type_name(GObject::TYPE_INT64)).must_equal "gint64"
|
31
|
+
_(GObject.type_name(GObject::TYPE_UINT64)).must_equal "guint64"
|
32
|
+
_(GObject.type_name(GObject::TYPE_ENUM)).must_equal "GEnum"
|
33
|
+
_(GObject.type_name(GObject::TYPE_FLAGS)).must_equal "GFlags"
|
34
|
+
_(GObject.type_name(GObject::TYPE_FLOAT)).must_equal "gfloat"
|
35
|
+
_(GObject.type_name(GObject::TYPE_DOUBLE)).must_equal "gdouble"
|
36
|
+
_(GObject.type_name(GObject::TYPE_STRING)).must_equal "gchararray"
|
37
|
+
_(GObject.type_name(GObject::TYPE_POINTER)).must_equal "gpointer"
|
38
|
+
_(GObject.type_name(GObject::TYPE_BOXED)).must_equal "GBoxed"
|
39
|
+
_(GObject.type_name(GObject::TYPE_PARAM)).must_equal "GParam"
|
40
|
+
_(GObject.type_name(GObject::TYPE_OBJECT)).must_equal "GObject"
|
41
|
+
_(GObject.type_name(GObject::TYPE_GTYPE)).must_equal "GType"
|
42
|
+
_(GObject.type_name(GObject::TYPE_VARIANT)).must_equal "GVariant"
|
43
|
+
|
44
|
+
_(GObject.type_name(GObject::TYPE_ARRAY)).must_equal "GArray"
|
45
|
+
_(GObject.type_name(GObject::TYPE_BYTE_ARRAY)).must_equal "GByteArray"
|
46
|
+
_(GObject.type_name(GObject::TYPE_ERROR)).must_equal "GError"
|
47
|
+
_(GObject.type_name(GObject::TYPE_HASH_TABLE)).must_equal "GHashTable"
|
48
|
+
_(GObject.type_name(GObject::TYPE_STRV)).must_equal "GStrv"
|
45
49
|
end
|
46
50
|
|
47
|
-
describe
|
48
|
-
it
|
51
|
+
describe "::object_class_from_instance" do
|
52
|
+
it "returns a GObject::ObjectClass with the correct GType" do
|
49
53
|
obj = GIMarshallingTests::OverridesObject.new
|
50
54
|
object_class = GObject.object_class_from_instance obj
|
51
55
|
gtype = object_class.g_type_class.g_type
|
52
56
|
|
53
|
-
object_class.must_be_instance_of GObject::ObjectClass
|
54
|
-
gtype.must_equal GIMarshallingTests::OverridesObject.gtype
|
57
|
+
_(object_class).must_be_instance_of GObject::ObjectClass
|
58
|
+
_(gtype).must_equal GIMarshallingTests::OverridesObject.gtype
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
58
|
-
describe
|
59
|
-
describe
|
60
|
-
it
|
61
|
-
spec = GObject.param_spec_int(
|
62
|
-
|
62
|
+
describe "creating ParamSpecs" do
|
63
|
+
describe "#param_spec_int" do
|
64
|
+
it "creates a GObject::ParamSpecInt" do
|
65
|
+
spec = GObject.param_spec_int("foo", "foo bar",
|
66
|
+
"The Foo Bar Property",
|
63
67
|
10, 20, 15,
|
64
68
|
3)
|
65
|
-
spec.must_be_instance_of GObject::ParamSpecInt
|
66
|
-
spec.struct[:minimum].must_equal 10
|
67
|
-
spec.struct[:maximum].must_equal 20
|
68
|
-
spec.get_default_value.must_equal 15
|
69
|
+
_(spec).must_be_instance_of GObject::ParamSpecInt
|
70
|
+
_(spec.struct[:minimum]).must_equal 10
|
71
|
+
_(spec.struct[:maximum]).must_equal 20
|
72
|
+
_(spec.get_default_value).must_equal 15
|
69
73
|
end
|
70
74
|
end
|
71
75
|
end
|
@@ -1,31 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
|
-
require
|
5
|
+
require "ffi-gobject"
|
6
6
|
|
7
7
|
describe GObject::ObjectClass do
|
8
|
-
describe
|
8
|
+
describe "#list_properties" do
|
9
9
|
it "returns GIMarshallingTests::OverridesObject's properties" do
|
10
10
|
obj = GIMarshallingTests::OverridesObject.new
|
11
11
|
object_class = GObject.object_class_from_instance obj
|
12
12
|
|
13
|
-
info = get_introspection_data
|
13
|
+
info = get_introspection_data "GIMarshallingTests", "OverridesObject"
|
14
14
|
expected_props = info.properties.map(&:name)
|
15
15
|
expected_props += info.parent.properties.map(&:name)
|
16
16
|
|
17
17
|
props = object_class.list_properties
|
18
18
|
prop_names = props.map(&:get_name)
|
19
19
|
|
20
|
-
prop_names.sort.must_equal expected_props.sort
|
20
|
+
_(prop_names.sort).must_equal expected_props.sort
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
25
|
-
it
|
24
|
+
describe "#gtype" do
|
25
|
+
it "returns the correct GType" do
|
26
26
|
obj = GIMarshallingTests::OverridesObject.new
|
27
27
|
object_class = GObject.object_class_from_instance obj
|
28
|
-
object_class.gtype.must_equal GIMarshallingTests::OverridesObject.gtype
|
28
|
+
_(object_class.gtype).must_equal GIMarshallingTests::OverridesObject.gtype
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -1,130 +1,112 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
|
-
require
|
5
|
+
require "ffi-gobject"
|
6
6
|
GirFFI.setup :GIMarshallingTests
|
7
7
|
|
8
8
|
describe GObject::Object do
|
9
|
-
describe
|
10
|
-
it
|
11
|
-
GObject::Object.new({}).must_be_instance_of GObject::Object
|
9
|
+
describe ".new" do
|
10
|
+
it "is overridden to take only one argument" do
|
11
|
+
_(GObject::Object.new({})).must_be_instance_of GObject::Object
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
14
|
+
it "can be used to create objects with properties" do
|
15
15
|
obj = GIMarshallingTests::SubObject.new(int: 13)
|
16
|
-
obj.int.must_equal 13
|
16
|
+
_(obj.int).must_equal 13
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
GObject::Object.new.must_be_instance_of GObject::Object
|
19
|
+
it "allows omission of the first argument" do
|
20
|
+
_(GObject::Object.new).must_be_instance_of GObject::Object
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
24
|
-
proc { GObject::Object.new(dog:
|
23
|
+
it "raises an error for properties that do not exist" do
|
24
|
+
_(proc { GObject::Object.new(dog: "bark") }).must_raise GirFFI::PropertyNotFoundError
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe
|
29
|
-
it
|
30
|
-
GObject::Object.instance_method(
|
28
|
+
describe "#get_property" do
|
29
|
+
it "is overridden to have arity 1" do
|
30
|
+
_(GObject::Object.instance_method("get_property").arity).must_equal 1
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it "raises an error for a property that does not exist" do
|
34
34
|
instance = GObject::Object.new
|
35
|
-
proc { instance.get_property
|
35
|
+
_(proc { instance.get_property "foo-bar" }).must_raise GirFFI::PropertyNotFoundError
|
36
36
|
end
|
37
|
-
end
|
38
37
|
|
39
|
-
|
40
|
-
it 'raises an error for a property that does not exist' do
|
38
|
+
it "raises an error for a property that does not exist" do
|
41
39
|
instance = GObject::Object.new
|
42
|
-
proc { instance.
|
40
|
+
_(proc { instance.get_property "foo-bar" }).
|
43
41
|
must_raise GirFFI::PropertyNotFoundError
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
47
|
-
describe
|
48
|
-
it
|
45
|
+
describe "#get_property_extended" do
|
46
|
+
it "raises an error for a property that does not exist" do
|
49
47
|
instance = GObject::Object.new
|
50
|
-
proc { instance.
|
48
|
+
_(proc { instance.get_property_extended "foo-bar" }).
|
49
|
+
must_raise GirFFI::PropertyNotFoundError
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
54
|
-
describe
|
55
|
-
it
|
53
|
+
describe "#set_property" do
|
54
|
+
it "raises an error for a property that does not exist" do
|
56
55
|
instance = GObject::Object.new
|
57
|
-
proc { instance.
|
58
|
-
must_raise GirFFI::PropertyNotFoundError
|
56
|
+
_(proc { instance.set_property "foo-bar", 123 }).must_raise GirFFI::PropertyNotFoundError
|
59
57
|
end
|
60
58
|
end
|
61
59
|
|
62
|
-
describe
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
def set_x(val)
|
69
|
-
@x = val
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
subject { AccessorTest.new }
|
74
|
-
|
75
|
-
it 'reads x by calling get_x' do
|
76
|
-
subject.set_x(1)
|
77
|
-
assert_equal 1, subject.x
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'writes x by calling set_x' do
|
81
|
-
subject.x = 2
|
82
|
-
assert_equal 2, subject.x
|
60
|
+
describe "#set_property_extended" do
|
61
|
+
it "raises an error for a property that does not exist" do
|
62
|
+
instance = GObject::Object.new
|
63
|
+
_(proc { instance.set_property_extended "foo-bar", 123 }).
|
64
|
+
must_raise GirFFI::PropertyNotFoundError
|
83
65
|
end
|
84
66
|
end
|
85
67
|
|
86
|
-
describe
|
68
|
+
describe "#signal_connect" do
|
87
69
|
subject { GObject::Object.new }
|
88
70
|
|
89
|
-
it
|
90
|
-
expect(GObject).to receive(:signal_connect).with(subject,
|
91
|
-
subject.signal_connect(
|
71
|
+
it "delegates to GObject" do
|
72
|
+
expect(GObject).to receive(:signal_connect).with(subject, "some-event", nil)
|
73
|
+
subject.signal_connect("some-event") do
|
92
74
|
nothing
|
93
75
|
end
|
94
76
|
end
|
95
77
|
|
96
|
-
it
|
97
|
-
expect(GObject).to receive(:signal_connect).with(subject,
|
98
|
-
subject.signal_connect(
|
78
|
+
it "delegates to GObject if an optional data argument is passed" do
|
79
|
+
expect(GObject).to receive(:signal_connect).with(subject, "some-event", "data")
|
80
|
+
subject.signal_connect("some-event", "data") do
|
99
81
|
nothing
|
100
82
|
end
|
101
83
|
end
|
102
84
|
end
|
103
85
|
|
104
|
-
describe
|
86
|
+
describe "#signal_connect_after" do
|
105
87
|
subject { GObject::Object.new }
|
106
88
|
|
107
|
-
it
|
108
|
-
expect(GObject).to receive(:signal_connect_after).with(subject,
|
109
|
-
subject.signal_connect_after(
|
89
|
+
it "delegates to GObject" do
|
90
|
+
expect(GObject).to receive(:signal_connect_after).with(subject, "some-event", nil)
|
91
|
+
subject.signal_connect_after("some-event") do
|
110
92
|
nothing
|
111
93
|
end
|
112
94
|
end
|
113
95
|
|
114
|
-
it
|
115
|
-
expect(GObject).to receive(:signal_connect_after).with(subject,
|
116
|
-
subject.signal_connect_after(
|
96
|
+
it "delegates to GObject if an optional data argument is passed" do
|
97
|
+
expect(GObject).to receive(:signal_connect_after).with(subject, "some-event", "data")
|
98
|
+
subject.signal_connect_after("some-event", "data") do
|
117
99
|
nothing
|
118
100
|
end
|
119
101
|
end
|
120
102
|
end
|
121
103
|
|
122
|
-
describe
|
123
|
-
it
|
124
|
-
skip
|
104
|
+
describe "upon garbage collection" do
|
105
|
+
it "lowers the reference count" do
|
106
|
+
skip "cannot be reliably tested on JRuby and Rubinius" if jruby? || rubinius?
|
125
107
|
|
126
108
|
ptr = GObject::Object.new.to_ptr
|
127
|
-
object_ref_count(ptr).must_equal 1
|
109
|
+
_(object_ref_count(ptr)).must_equal 1
|
128
110
|
|
129
111
|
GC.start
|
130
112
|
# Creating a new object is sometimes needed to trigger enough garbage collection.
|
@@ -134,7 +116,7 @@ describe GObject::Object do
|
|
134
116
|
GC.start
|
135
117
|
GC.start
|
136
118
|
|
137
|
-
object_ref_count(ptr).must_equal 0
|
119
|
+
_(object_ref_count(ptr)).must_equal 0
|
138
120
|
end
|
139
121
|
end
|
140
122
|
end
|