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,23 +1,23 @@
|
|
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::StructBase do
|
8
|
-
it
|
9
|
-
GirFFI::StructBase.must_include GirFFI::StructLikeBase
|
8
|
+
it "inherits from StructLikeBase" do
|
9
|
+
_(GirFFI::StructBase).must_include GirFFI::StructLikeBase
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
13
|
-
it
|
12
|
+
describe "new" do
|
13
|
+
it "creates an instance with an owned struct" do
|
14
14
|
instance = GIMarshallingTests::SimpleStruct.new
|
15
|
-
instance.struct.must_be :owned?
|
15
|
+
_(instance.struct).must_be :owned?
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it "ensures the wrapped pointer is not autoreleased" do
|
19
19
|
instance = GIMarshallingTests::SimpleStruct.new
|
20
|
-
instance.to_ptr.wont_be :autorelease?
|
20
|
+
_(instance.to_ptr).wont_be :autorelease?
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -1,167 +1,167 @@
|
|
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::StructLikeBase do
|
8
|
-
describe
|
9
|
-
it
|
8
|
+
describe "wrap_copy" do
|
9
|
+
it "returns a wrapped owned copy of structs" do
|
10
10
|
original = GIMarshallingTests::SimpleStruct.new
|
11
11
|
copy = GIMarshallingTests::SimpleStruct.wrap_copy(original.to_ptr)
|
12
|
-
copy.to_ptr.wont_be :==, original.to_ptr
|
13
|
-
copy.to_ptr.wont_be :autorelease?
|
14
|
-
copy.struct.must_be :owned?
|
12
|
+
_(copy.to_ptr).wont_be :==, original.to_ptr
|
13
|
+
_(copy.to_ptr).wont_be :autorelease?
|
14
|
+
_(copy.struct).must_be :owned?
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it "returns a wrapped owned copy of unions" do
|
18
18
|
original = GIMarshallingTests::Union.new
|
19
19
|
copy = GIMarshallingTests::Union.wrap_copy(original.to_ptr)
|
20
|
-
copy.to_ptr.wont_be :==, original.to_ptr
|
21
|
-
copy.to_ptr.wont_be :autorelease?
|
22
|
-
copy.struct.must_be :owned?
|
20
|
+
_(copy.to_ptr).wont_be :==, original.to_ptr
|
21
|
+
_(copy.to_ptr).wont_be :autorelease?
|
22
|
+
_(copy.struct).must_be :owned?
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it "returns a wrapped owned copy of boxed types" do
|
26
26
|
original = GIMarshallingTests::BoxedStruct.new
|
27
27
|
copy = GIMarshallingTests::BoxedStruct.wrap_copy(original.to_ptr)
|
28
28
|
ptr = copy.to_ptr
|
29
|
-
ptr.wont_be :==, original.to_ptr
|
30
|
-
ptr.wont_be :autorelease? if ptr.respond_to? :autorelease
|
31
|
-
copy.struct.must_be :owned?
|
29
|
+
_(ptr).wont_be :==, original.to_ptr
|
30
|
+
_(ptr).wont_be :autorelease? if ptr.respond_to? :autorelease
|
31
|
+
_(copy.struct).must_be :owned?
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
35
|
-
GIMarshallingTests::SimpleStruct.wrap_copy(nil).must_be_nil
|
34
|
+
it "returns nil when passed nil" do
|
35
|
+
_(GIMarshallingTests::SimpleStruct.wrap_copy(nil)).must_be_nil
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
40
|
-
it
|
39
|
+
describe "copy_from" do
|
40
|
+
it "returns an unowned copy of unions" do
|
41
41
|
original = GIMarshallingTests::Union.new
|
42
42
|
original.long_ = 42
|
43
43
|
copy = GIMarshallingTests::Union.copy_from(original)
|
44
|
-
copy.long_.must_equal 42
|
45
|
-
copy.to_ptr.wont_be :==, original.to_ptr
|
46
|
-
copy.to_ptr.wont_be :autorelease?
|
47
|
-
copy.struct.wont_be :owned?
|
44
|
+
_(copy.long_).must_equal 42
|
45
|
+
_(copy.to_ptr).wont_be :==, original.to_ptr
|
46
|
+
_(copy.to_ptr).wont_be :autorelease?
|
47
|
+
_(copy.struct).wont_be :owned?
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
50
|
+
it "returns an unowned copy of structs" do
|
51
51
|
original = GIMarshallingTests::SimpleStruct.new
|
52
52
|
copy = GIMarshallingTests::SimpleStruct.copy_from(original)
|
53
|
-
copy.to_ptr.wont_be :==, original.to_ptr
|
54
|
-
copy.to_ptr.wont_be :autorelease?
|
55
|
-
copy.struct.wont_be :owned?
|
53
|
+
_(copy.to_ptr).wont_be :==, original.to_ptr
|
54
|
+
_(copy.to_ptr).wont_be :autorelease?
|
55
|
+
_(copy.struct).wont_be :owned?
|
56
56
|
end
|
57
57
|
|
58
|
-
it
|
59
|
-
GIMarshallingTests::SimpleStruct.copy_from(nil).must_be_nil
|
58
|
+
it "returns nil when passed nil" do
|
59
|
+
_(GIMarshallingTests::SimpleStruct.copy_from(nil)).must_be_nil
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
63
|
-
GObject::Value.copy_from(4).must_be_instance_of GObject::Value
|
62
|
+
it "converts its argument if that is possible" do
|
63
|
+
_(GObject::Value.copy_from(4)).must_be_instance_of GObject::Value
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
describe
|
68
|
-
it
|
67
|
+
describe "wrap_own" do
|
68
|
+
it "wraps and owns the supplied pointer for structs" do
|
69
69
|
original = GIMarshallingTests::SimpleStruct.new
|
70
70
|
original.struct.owned = false
|
71
71
|
|
72
72
|
copy = GIMarshallingTests::SimpleStruct.wrap_own(original.to_ptr)
|
73
|
-
copy.to_ptr.must_equal original.to_ptr
|
74
|
-
copy.to_ptr.wont_be :autorelease?
|
75
|
-
copy.struct.must_be :owned?
|
73
|
+
_(copy.to_ptr).must_equal original.to_ptr
|
74
|
+
_(copy.to_ptr).wont_be :autorelease?
|
75
|
+
_(copy.struct).must_be :owned?
|
76
76
|
end
|
77
77
|
|
78
|
-
it
|
78
|
+
it "wraps and owns the supplied pointer for unions" do
|
79
79
|
original = GIMarshallingTests::Union.new
|
80
80
|
original.struct.owned = false
|
81
81
|
|
82
82
|
copy = GIMarshallingTests::Union.wrap_own(original.to_ptr)
|
83
|
-
copy.to_ptr.must_equal original.to_ptr
|
84
|
-
copy.to_ptr.wont_be :autorelease?
|
85
|
-
copy.struct.must_be :owned?
|
83
|
+
_(copy.to_ptr).must_equal original.to_ptr
|
84
|
+
_(copy.to_ptr).wont_be :autorelease?
|
85
|
+
_(copy.struct).must_be :owned?
|
86
86
|
end
|
87
87
|
|
88
|
-
it
|
89
|
-
GIMarshallingTests::SimpleStruct.wrap_own(nil).must_be_nil
|
88
|
+
it "returns nil when passed nil" do
|
89
|
+
_(GIMarshallingTests::SimpleStruct.wrap_own(nil)).must_be_nil
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
describe
|
93
|
+
describe ".native_type" do
|
94
94
|
let(:type) { GIMarshallingTests::SimpleStruct.native_type }
|
95
95
|
|
96
|
-
it
|
97
|
-
type.must_be_instance_of FFI::StructByValue
|
96
|
+
it "is a struct by value" do
|
97
|
+
_(type).must_be_instance_of FFI::StructByValue
|
98
98
|
end
|
99
99
|
|
100
|
-
it
|
101
|
-
type.struct_class.must_equal GIMarshallingTests::SimpleStruct::Struct
|
100
|
+
it "wraps the types nested struct class" do
|
101
|
+
_(type.struct_class).must_equal GIMarshallingTests::SimpleStruct::Struct
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
describe
|
105
|
+
describe ".to_native" do
|
106
106
|
it "returns the supplied value's struct" do
|
107
107
|
object = GIMarshallingTests::SimpleStruct.new
|
108
|
-
result = object.class.to_native(object,
|
109
|
-
result.must_equal object.struct
|
108
|
+
result = object.class.to_native(object, "some-context")
|
109
|
+
_(result).must_equal object.struct
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
describe
|
114
|
-
it
|
113
|
+
describe ".to_ffi_type" do
|
114
|
+
it "returns the class itself" do
|
115
115
|
struct_class = GIMarshallingTests::SimpleStruct
|
116
116
|
ffi_type = struct_class.to_ffi_type
|
117
|
-
ffi_type.must_equal struct_class
|
117
|
+
_(ffi_type).must_equal struct_class
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
describe
|
121
|
+
describe ".get_value_from_pointer" do
|
122
122
|
let(:struct_class) { GIMarshallingTests::SimpleStruct }
|
123
123
|
|
124
|
-
it
|
124
|
+
it "returns just a pointer" do
|
125
125
|
object = struct_class.new
|
126
126
|
ptr = object.to_ptr
|
127
127
|
result = struct_class.get_value_from_pointer(ptr, 0)
|
128
|
-
result.must_be :==, ptr
|
128
|
+
_(result).must_be :==, ptr
|
129
129
|
end
|
130
130
|
|
131
|
-
it
|
131
|
+
it "uses offset correctly" do
|
132
132
|
struct1 = struct_class.new.tap { |it| it.long_ = 42 }
|
133
133
|
struct2 = struct_class.new.tap { |it| it.long_ = 24 }
|
134
134
|
array_ptr = GirFFI::InPointer.from_array(struct_class, [struct1, struct2])
|
135
135
|
ptr = struct_class.get_value_from_pointer(array_ptr, struct_class.size)
|
136
136
|
result = struct_class.wrap(ptr)
|
137
|
-
result.long_.must_equal 24
|
137
|
+
_(result.long_).must_equal 24
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
describe
|
141
|
+
describe ".copy_value_to_pointer" do
|
142
142
|
let(:struct_class) { GIMarshallingTests::SimpleStruct }
|
143
143
|
let(:struct) { struct_class.new }
|
144
144
|
|
145
|
-
it
|
145
|
+
it "copies data correctly" do
|
146
146
|
struct.long_ = 42
|
147
147
|
target = FFI::MemoryPointer.new struct_class.size
|
148
148
|
struct_class.copy_value_to_pointer(struct, target)
|
149
149
|
result = struct_class.wrap(target)
|
150
|
-
result.long_.must_equal 42
|
150
|
+
_(result.long_).must_equal 42
|
151
151
|
end
|
152
152
|
|
153
|
-
it
|
153
|
+
it "uses offset correctly" do
|
154
154
|
struct.long_ = 42
|
155
155
|
target = FFI::MemoryPointer.new struct_class.size + 10
|
156
156
|
struct_class.copy_value_to_pointer(struct, target, 10)
|
157
157
|
result = struct_class.wrap(target + 10)
|
158
|
-
result.long_.must_equal 42
|
158
|
+
_(result.long_).must_equal 42
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
|
-
it
|
162
|
+
it "adds its class methods to classes that include it" do
|
163
163
|
struct_class = Class.new
|
164
164
|
struct_class.send :include, GirFFI::StructLikeBase
|
165
|
-
struct_class.singleton_class.must_include GirFFI::StructLikeBase::ClassMethods
|
165
|
+
_(struct_class.singleton_class).must_include GirFFI::StructLikeBase::ClassMethods
|
166
166
|
end
|
167
167
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::TypeMap do
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
GirFFI::TypeMap.type_specification_to_ffi_type(GLib::DateMonth).
|
6
|
+
describe ".type_specification_to_ffi_type" do
|
7
|
+
it "returns the nested FFI::Enum for an Enum module" do
|
8
|
+
_(GirFFI::TypeMap.type_specification_to_ffi_type(GLib::DateMonth)).
|
9
9
|
must_equal GLib::DateMonth
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
13
|
-
GirFFI::TypeMap.type_specification_to_ffi_type(GObject::EnumValue).
|
12
|
+
it "returns the class itself for a Struct class" do
|
13
|
+
_(GirFFI::TypeMap.type_specification_to_ffi_type(GObject::EnumValue)).
|
14
14
|
must_equal GObject::EnumValue
|
15
15
|
end
|
16
16
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
|
+
require "gir_ffi/unintrospectable_type_info"
|
5
5
|
|
6
6
|
describe GirFFI::UnintrospectableTypeInfo do
|
7
|
-
describe
|
8
|
-
it
|
7
|
+
describe "#info_type" do
|
8
|
+
it "returns :unintrospectable" do
|
9
9
|
info = GirFFI::UnintrospectableTypeInfo.new :some_type
|
10
|
-
info.info_type.must_equal :unintrospectable
|
10
|
+
_(info.info_type).must_equal :unintrospectable
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe
|
15
|
-
describe
|
14
|
+
describe "#parent" do
|
15
|
+
describe "when the GIR knows about the parent gtype" do
|
16
16
|
it "finds the parent's info by gtype" do
|
17
17
|
gobject = Object.new
|
18
18
|
gir = Object.new
|
@@ -22,12 +22,12 @@ describe GirFFI::UnintrospectableTypeInfo do
|
|
22
22
|
|
23
23
|
info = GirFFI::UnintrospectableTypeInfo.new(:some_type, gir, gobject)
|
24
24
|
|
25
|
-
info.parent.must_equal :foo_info
|
25
|
+
_(info.parent).must_equal :foo_info
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
30
|
-
it
|
29
|
+
describe "when the GIR does not know about the parent gtype" do
|
30
|
+
it "creates a new UnintrospectableTypeInfo from the parent gtype" do
|
31
31
|
gobject = Object.new
|
32
32
|
gir = Object.new
|
33
33
|
|
@@ -36,13 +36,13 @@ describe GirFFI::UnintrospectableTypeInfo do
|
|
36
36
|
|
37
37
|
info = GirFFI::UnintrospectableTypeInfo.new(:some_type, gir, gobject)
|
38
38
|
|
39
|
-
info.parent.g_type.must_equal :foo
|
39
|
+
_(info.parent.g_type).must_equal :foo
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
describe
|
45
|
-
it
|
44
|
+
describe "#interfaces" do
|
45
|
+
it "finds interface infos by gtype" do
|
46
46
|
gobject = Object.new
|
47
47
|
gir = Object.new
|
48
48
|
|
@@ -52,10 +52,10 @@ describe GirFFI::UnintrospectableTypeInfo do
|
|
52
52
|
|
53
53
|
info = GirFFI::UnintrospectableTypeInfo.new(:some_type, gir, gobject)
|
54
54
|
|
55
|
-
info.interfaces.must_equal [:foo_info, :bar_info]
|
55
|
+
_(info.interfaces).must_equal [:foo_info, :bar_info]
|
56
56
|
end
|
57
57
|
|
58
|
-
it
|
58
|
+
it "skips interfaces that have no introspection data" do
|
59
59
|
gobject = Object.new
|
60
60
|
gir = Object.new
|
61
61
|
|
@@ -65,25 +65,25 @@ describe GirFFI::UnintrospectableTypeInfo do
|
|
65
65
|
|
66
66
|
info = GirFFI::UnintrospectableTypeInfo.new(:some_type, gir, gobject)
|
67
67
|
|
68
|
-
info.interfaces.must_equal [:foo_info]
|
68
|
+
_(info.interfaces).must_equal [:foo_info]
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
describe
|
73
|
-
it
|
72
|
+
describe "#g_type" do
|
73
|
+
it "returns the passed-in gtype" do
|
74
74
|
info = GirFFI::UnintrospectableTypeInfo.new(:some_type)
|
75
|
-
info.g_type.must_equal :some_type
|
75
|
+
_(info.g_type).must_equal :some_type
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
describe
|
80
|
-
it
|
79
|
+
describe "#fields" do
|
80
|
+
it "returns an empty array" do
|
81
81
|
info = GirFFI::UnintrospectableTypeInfo.new(:some_type)
|
82
|
-
info.fields.must_equal []
|
82
|
+
_(info.fields).must_equal []
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
describe
|
86
|
+
describe "#namespace" do
|
87
87
|
it "returns the parent class' namespace" do
|
88
88
|
gobject = Object.new
|
89
89
|
gir = Object.new
|
@@ -91,31 +91,31 @@ describe GirFFI::UnintrospectableTypeInfo do
|
|
91
91
|
|
92
92
|
expect(gobject).to receive(:type_parent).with(:some_type).and_return :foo
|
93
93
|
expect(gir).to receive(:find_by_gtype).with(:foo).and_return parent_info
|
94
|
-
expect(parent_info).to receive(:namespace).and_return
|
94
|
+
expect(parent_info).to receive(:namespace).and_return "FooNamespace"
|
95
95
|
|
96
96
|
info = GirFFI::UnintrospectableTypeInfo.new(:some_type, gir, gobject)
|
97
97
|
|
98
|
-
info.namespace.must_equal
|
98
|
+
_(info.namespace).must_equal "FooNamespace"
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
describe
|
103
|
-
it
|
102
|
+
describe "#safe_name" do
|
103
|
+
it "finds the class name by gtype" do
|
104
104
|
gobject = Object.new
|
105
105
|
|
106
|
-
expect(gobject).to receive(:type_name).with(:some_type).and_return
|
106
|
+
expect(gobject).to receive(:type_name).with(:some_type).and_return "GSomeType"
|
107
107
|
|
108
108
|
info = GirFFI::UnintrospectableTypeInfo.new(:some_type, nil, gobject)
|
109
109
|
|
110
|
-
info.safe_name.must_equal
|
110
|
+
_(info.safe_name).must_equal "GSomeType"
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
describe
|
115
|
-
it
|
114
|
+
describe "#find_signal" do
|
115
|
+
it "indicates that no signals can be found" do
|
116
116
|
info = GirFFI::UnintrospectableTypeInfo.new(:some_type)
|
117
|
-
result = info.find_signal
|
118
|
-
result.must_be_nil
|
117
|
+
result = info.find_signal "any"
|
118
|
+
_(result).must_be_nil
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -1,23 +1,23 @@
|
|
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::UnionBase do
|
8
|
-
it
|
9
|
-
GirFFI::StructBase.must_include GirFFI::StructLikeBase
|
8
|
+
it "inherits from StructLikeBase" do
|
9
|
+
_(GirFFI::StructBase).must_include GirFFI::StructLikeBase
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
13
|
-
it
|
12
|
+
describe "new" do
|
13
|
+
it "creates an instance with an owned struct" do
|
14
14
|
instance = GIMarshallingTests::Union.new
|
15
|
-
instance.struct.must_be :owned?
|
15
|
+
_(instance.struct).must_be :owned?
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it "ensures the wrapped pointer is not autoreleased" do
|
19
19
|
instance = GIMarshallingTests::Union.new
|
20
|
-
instance.to_ptr.wont_be :autorelease?
|
20
|
+
_(instance.to_ptr).wont_be :autorelease?
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|