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,22 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::CallbackBase do
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
dummy_proc =
|
6
|
+
describe ".store_callback" do
|
7
|
+
it "stores the passed in proc in CALLBACKS" do
|
8
|
+
dummy_proc = "some-callback"
|
9
9
|
GirFFI::CallbackBase.store_callback dummy_proc
|
10
|
-
GirFFI::CallbackBase::CALLBACKS[dummy_proc.object_id].must_equal dummy_proc
|
10
|
+
_(GirFFI::CallbackBase::CALLBACKS[dummy_proc.object_id]).must_equal dummy_proc
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe
|
15
|
-
it
|
16
|
-
dummy_proc =
|
14
|
+
describe ".drop_callback" do
|
15
|
+
it "removes the corresponding proc from CALLBACKS" do
|
16
|
+
dummy_proc = "some-callback"
|
17
17
|
GirFFI::CallbackBase.store_callback dummy_proc
|
18
18
|
GirFFI::CallbackBase.drop_callback dummy_proc
|
19
|
-
GirFFI::CallbackBase::CALLBACKS[dummy_proc.object_id].must_be_nil
|
19
|
+
_(GirFFI::CallbackBase::CALLBACKS[dummy_proc.object_id]).must_be_nil
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::ClassBase do
|
6
|
-
describe
|
6
|
+
describe "a simple descendant" do
|
7
7
|
let(:object_class) do
|
8
8
|
Class.new(GirFFI::ClassBase) do
|
9
9
|
self::Struct = Class.new(GirFFI::Struct) do
|
@@ -13,72 +13,72 @@ describe GirFFI::ClassBase do
|
|
13
13
|
end
|
14
14
|
let(:object) { object_class.wrap FFI::MemoryPointer.new(:int32) }
|
15
15
|
|
16
|
-
it
|
16
|
+
it "has #from as a pass-through method" do
|
17
17
|
result = object_class.from :foo
|
18
|
-
result.must_equal :foo
|
18
|
+
_(result).must_equal :foo
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
22
|
-
it
|
21
|
+
describe "#==" do
|
22
|
+
it "returns true when comparing to an object of the same class and pointer" do
|
23
23
|
other = object_class.wrap object.to_ptr
|
24
24
|
|
25
|
-
object.must_be :==, other
|
26
|
-
other.must_be :==, object
|
25
|
+
_(object).must_be :==, other
|
26
|
+
_(other).must_be :==, object
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it "returns true when comparing to an object of the same class and a pointer with the same address" do
|
30
30
|
ptr = FFI::Pointer.new object.to_ptr
|
31
31
|
other = object_class.wrap ptr
|
32
32
|
|
33
|
-
object.must_be :==, other
|
34
|
-
other.must_be :==, object
|
33
|
+
_(object).must_be :==, other
|
34
|
+
_(other).must_be :==, object
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it "returns false when comparing to an object of a sub/superclass and the same pointer" do
|
38
38
|
subclass = Class.new(object_class)
|
39
39
|
other = subclass.wrap object.to_ptr
|
40
40
|
|
41
|
-
object.wont_be :==, other
|
42
|
-
other.wont_be :==, object
|
41
|
+
_(object).wont_be :==, other
|
42
|
+
_(other).wont_be :==, object
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it "returns false when comparing to an object of the same class and different pointer" do
|
46
46
|
other = object_class.wrap FFI::MemoryPointer.new(:int32)
|
47
47
|
|
48
|
-
object.wont_be :==, other
|
49
|
-
other.wont_be :==, object
|
48
|
+
_(object).wont_be :==, other
|
49
|
+
_(other).wont_be :==, object
|
50
50
|
end
|
51
51
|
|
52
52
|
it "returns false when comparing to an object that doesn't respond to #to_ptr" do
|
53
53
|
other = Object.new
|
54
54
|
|
55
|
-
object.wont_be :==, other
|
56
|
-
other.wont_be :==, object
|
55
|
+
_(object).wont_be :==, other
|
56
|
+
_(other).wont_be :==, object
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
59
|
+
it "returns false when comparing to an object of a different class and same pointer" do
|
60
60
|
allow(other = Object.new).to receive(:to_ptr).and_return object.to_ptr
|
61
61
|
|
62
|
-
object.wont_be :==, other
|
63
|
-
other.wont_be :==, object
|
62
|
+
_(object).wont_be :==, other
|
63
|
+
_(other).wont_be :==, object
|
64
64
|
end
|
65
65
|
|
66
|
-
it
|
66
|
+
it "returns false when comparing to an object of a different class and different pointer" do
|
67
67
|
allow(other = Object.new).to receive(:to_ptr).and_return FFI::MemoryPointer.new(:int32)
|
68
68
|
|
69
|
-
object.wont_be :==, other
|
70
|
-
other.wont_be :==, object
|
69
|
+
_(object).wont_be :==, other
|
70
|
+
_(other).wont_be :==, object
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe
|
76
|
-
it
|
77
|
-
expect(builder = Object.new).to receive(:setup_method).with(
|
75
|
+
describe ".setup_and_call" do
|
76
|
+
it "looks up class methods in all builders" do
|
77
|
+
expect(builder = Object.new).to receive(:setup_method).with("foo").and_return "foo"
|
78
78
|
klass = Class.new GirFFI::ClassBase
|
79
79
|
klass.const_set :GIR_FFI_BUILDER, builder
|
80
80
|
|
81
|
-
expect(sub_builder = Object.new).to receive(:setup_method).with(
|
81
|
+
expect(sub_builder = Object.new).to receive(:setup_method).with("foo").and_return nil
|
82
82
|
sub_klass = Class.new klass do
|
83
83
|
def self.foo; end
|
84
84
|
end
|
@@ -87,11 +87,11 @@ describe GirFFI::ClassBase do
|
|
87
87
|
sub_klass.setup_and_call :foo, []
|
88
88
|
end
|
89
89
|
|
90
|
-
it
|
91
|
-
expect(builder = Object.new).to receive(:setup_method).with(
|
90
|
+
it "calls the method given by the result of .setup_method" do
|
91
|
+
expect(builder = Object.new).to receive(:setup_method).with("foo").and_return "bar"
|
92
92
|
klass = Class.new GirFFI::ClassBase do
|
93
93
|
def self.bar
|
94
|
-
|
94
|
+
"correct-result"
|
95
95
|
end
|
96
96
|
|
97
97
|
def initialize; end
|
@@ -99,29 +99,28 @@ describe GirFFI::ClassBase do
|
|
99
99
|
klass.const_set :GIR_FFI_BUILDER, builder
|
100
100
|
|
101
101
|
result = klass.setup_and_call :foo, []
|
102
|
-
result.must_equal
|
102
|
+
_(result).must_equal "correct-result"
|
103
103
|
end
|
104
104
|
|
105
|
-
it
|
106
|
-
expect(builder = Object.new).to receive(:setup_method).with(
|
105
|
+
it "raises a sensible error if the method is not found" do
|
106
|
+
expect(builder = Object.new).to receive(:setup_method).with("foo").and_return nil
|
107
107
|
klass = Class.new GirFFI::ClassBase do
|
108
108
|
def initialize; end
|
109
109
|
end
|
110
110
|
klass.const_set :GIR_FFI_BUILDER, builder
|
111
111
|
|
112
|
-
proc { klass.setup_and_call :foo, [] }.
|
113
|
-
|
114
|
-
must_match(/^undefined method `foo' for/)
|
112
|
+
exception = _(proc { klass.setup_and_call :foo, [] }).must_raise(NoMethodError)
|
113
|
+
_(exception.message).must_match(/^undefined method `foo' for/)
|
115
114
|
end
|
116
115
|
end
|
117
116
|
|
118
|
-
describe
|
119
|
-
it
|
120
|
-
expect(builder = Object.new).to receive(:setup_instance_method).with(
|
117
|
+
describe "#setup_and_call" do
|
118
|
+
it "looks up instance methods in all builders" do
|
119
|
+
expect(builder = Object.new).to receive(:setup_instance_method).with("foo").and_return "foo"
|
121
120
|
klass = Class.new GirFFI::ClassBase
|
122
121
|
klass.const_set :GIR_FFI_BUILDER, builder
|
123
122
|
|
124
|
-
expect(sub_builder = Object.new).to receive(:setup_instance_method).with(
|
123
|
+
expect(sub_builder = Object.new).to receive(:setup_instance_method).with("foo").and_return nil
|
125
124
|
sub_klass = Class.new klass do
|
126
125
|
def foo; end
|
127
126
|
|
@@ -134,11 +133,11 @@ describe GirFFI::ClassBase do
|
|
134
133
|
obj.setup_and_call :foo, []
|
135
134
|
end
|
136
135
|
|
137
|
-
it
|
138
|
-
expect(builder = Object.new).to receive(:setup_instance_method).with(
|
136
|
+
it "calls the method given by the result of .setup_instance_method" do
|
137
|
+
expect(builder = Object.new).to receive(:setup_instance_method).with("foo").and_return "bar"
|
139
138
|
klass = Class.new GirFFI::ClassBase do
|
140
139
|
def bar
|
141
|
-
|
140
|
+
"correct-result"
|
142
141
|
end
|
143
142
|
|
144
143
|
def initialize; end
|
@@ -148,11 +147,11 @@ describe GirFFI::ClassBase do
|
|
148
147
|
obj = klass.new
|
149
148
|
|
150
149
|
result = obj.setup_and_call :foo, []
|
151
|
-
result.must_equal
|
150
|
+
_(result).must_equal "correct-result"
|
152
151
|
end
|
153
152
|
|
154
|
-
it
|
155
|
-
expect(builder = Object.new).to receive(:setup_instance_method).with(
|
153
|
+
it "raises a sensible error if the method is not found" do
|
154
|
+
expect(builder = Object.new).to receive(:setup_instance_method).with("foo").and_return nil
|
156
155
|
klass = Class.new GirFFI::ClassBase do
|
157
156
|
def initialize; end
|
158
157
|
end
|
@@ -160,9 +159,8 @@ describe GirFFI::ClassBase do
|
|
160
159
|
|
161
160
|
obj = klass.new
|
162
161
|
|
163
|
-
proc { obj.setup_and_call :foo, [] }.
|
164
|
-
|
165
|
-
must_match(/^undefined method `foo' for/)
|
162
|
+
exception = _(proc { obj.setup_and_call :foo, [] }).must_raise(NoMethodError)
|
163
|
+
_(exception.message).must_match(/^undefined method `foo' for/)
|
166
164
|
end
|
167
165
|
end
|
168
166
|
end
|
data/test/gir_ffi/core_test.rb
CHANGED
@@ -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::Core do
|
8
|
-
it
|
8
|
+
it "sets up cairo as Cairo" do
|
9
9
|
GirFFI.setup :cairo
|
10
10
|
assert Object.const_defined?(:Cairo)
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it "sets up xlib, which has no shared library" do
|
14
14
|
gir = GObjectIntrospection::IRepository.default
|
15
|
-
gir.require
|
16
|
-
assert_nil gir.shared_library(
|
15
|
+
gir.require "xlib"
|
16
|
+
assert_nil gir.shared_library("xlib"), "Precondition for test failed"
|
17
17
|
GirFFI.setup :xlib
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it "sets up dependencies" do
|
21
21
|
save_module :GObject
|
22
22
|
save_module :Regress
|
23
23
|
GirFFI.setup :Regress
|
@@ -26,72 +26,72 @@ describe GirFFI::Core do
|
|
26
26
|
restore_module :GObject
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
30
|
-
it
|
31
|
-
expect(GirFFI::Builder).to receive(:build_module).with(
|
32
|
-
GirFFI.setup :Regress,
|
29
|
+
describe ".setup" do
|
30
|
+
it "passes the desired version down to the module builder" do
|
31
|
+
expect(GirFFI::Builder).to receive(:build_module).with("Regress", "0.1")
|
32
|
+
GirFFI.setup :Regress, "0.1"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe
|
37
|
-
describe
|
36
|
+
describe "::define_type" do
|
37
|
+
describe "without a block" do
|
38
38
|
before do
|
39
39
|
@klass = Class.new GIMarshallingTests::OverridesObject
|
40
40
|
Object.const_set "DerivedA#{Sequence.next}", @klass
|
41
41
|
@gtype = GirFFI.define_type @klass
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
44
|
+
it "returns a GType for the derived class" do
|
45
45
|
parent_gtype = GIMarshallingTests::OverridesObject.gtype
|
46
|
-
@gtype.wont_equal parent_gtype
|
47
|
-
GObject.type_name(@gtype).must_equal @klass.name
|
46
|
+
_(@gtype).wont_equal parent_gtype
|
47
|
+
_(GObject.type_name(@gtype)).must_equal @klass.name
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
51
|
-
@klass.gtype.must_equal @gtype
|
50
|
+
it "makes #gtype on the registered class return the new GType" do
|
51
|
+
_(@klass.gtype).must_equal @gtype
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
54
|
+
it "registers a type with the same size as the parent" do
|
55
55
|
q = GObject.type_query @gtype
|
56
|
-
q.instance_size.must_equal GIMarshallingTests::OverridesObject::Struct.size
|
56
|
+
_(q.instance_size).must_equal GIMarshallingTests::OverridesObject::Struct.size
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
60
|
-
@klass::Struct.members.must_equal [:parent]
|
59
|
+
it "creates a struct class for the derived class with just one member" do
|
60
|
+
_(@klass::Struct.members).must_equal [:parent]
|
61
61
|
end
|
62
62
|
|
63
|
-
it
|
63
|
+
it "allows the new class to be instantiated" do
|
64
64
|
obj = @klass.new
|
65
65
|
type = GObject.type_from_instance obj
|
66
|
-
type.must_equal @gtype
|
66
|
+
_(type).must_equal @gtype
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe
|
70
|
+
describe "with a block with a call to #install_property" do
|
71
71
|
before do
|
72
72
|
@klass = Class.new GIMarshallingTests::OverridesObject
|
73
73
|
Object.const_set "DerivedB#{Sequence.next}", @klass
|
74
74
|
@gtype = GirFFI.define_type @klass do |info|
|
75
|
-
info.install_property GObject.param_spec_int(
|
76
|
-
|
75
|
+
info.install_property GObject.param_spec_int("foo", "foo bar",
|
76
|
+
"The Foo Bar Property",
|
77
77
|
10, 20, 15,
|
78
78
|
3)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
82
|
+
it "registers a type that is bigger than the parent" do
|
83
83
|
q = GObject.type_query @gtype
|
84
|
-
q.instance_size.must_be :>, GIMarshallingTests::OverridesObject::Struct.size
|
84
|
+
_(q.instance_size).must_be :>, GIMarshallingTests::OverridesObject::Struct.size
|
85
85
|
end
|
86
86
|
|
87
|
-
it
|
88
|
-
@klass::Struct.members.must_equal [:parent, :foo]
|
87
|
+
it "gives the types Struct the fields :parent and :foo" do
|
88
|
+
_(@klass::Struct.members).must_equal [:parent, :foo]
|
89
89
|
end
|
90
90
|
|
91
|
-
it
|
91
|
+
it "creates accessor functions for the property" do
|
92
92
|
obj = @klass.new
|
93
93
|
obj.foo = 13
|
94
|
-
obj.foo.must_equal 13
|
94
|
+
_(obj.foo).must_equal 13
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -1,43 +1,43 @@
|
|
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
|
describe GirFFI::EnumBase do
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
Regress::TestEnum.wrap(1).must_equal :value2
|
8
|
+
describe ".wrap" do
|
9
|
+
it "converts an integer to a symbol if possible" do
|
10
|
+
_(Regress::TestEnum.wrap(1)).must_equal :value2
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
14
|
-
Regress::TestEnum.wrap(32).must_equal 32
|
13
|
+
it "passes an integer if it cannot be converted" do
|
14
|
+
_(Regress::TestEnum.wrap(32)).must_equal 32
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
18
|
-
Regress::TestEnum.wrap(:value1).must_equal :value1
|
17
|
+
it "passes a known symbol untouched" do
|
18
|
+
_(Regress::TestEnum.wrap(:value1)).must_equal :value1
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
22
|
-
Regress::TestEnum.wrap(:foo).must_equal :foo
|
21
|
+
it "passes an unknown symbol untouched" do
|
22
|
+
_(Regress::TestEnum.wrap(:foo)).must_equal :foo
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
27
|
-
it
|
28
|
-
Regress::TestEnum.to_int(1).must_equal 1
|
26
|
+
describe ".to_int" do
|
27
|
+
it "passes a known integer untouched" do
|
28
|
+
_(Regress::TestEnum.to_int(1)).must_equal 1
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
32
|
-
Regress::TestEnum.to_int(32).must_equal 32
|
31
|
+
it "passes an unknown integer untouched" do
|
32
|
+
_(Regress::TestEnum.to_int(32)).must_equal 32
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
36
|
-
Regress::TestEnum.to_int(:value1).must_equal 0
|
35
|
+
it "convertes a known symbol to an integer" do
|
36
|
+
_(Regress::TestEnum.to_int(:value1)).must_equal 0
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
40
|
-
-> { Regress::TestEnum.to_int(:foo) }.must_raise ArgumentError
|
39
|
+
it "raises an error for an unknown symbol" do
|
40
|
+
_(-> { Regress::TestEnum.to_int(:foo) }).must_raise ArgumentError
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -1,50 +1,50 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
|
+
require "gir_ffi/error_type_info"
|
5
5
|
|
6
6
|
describe GirFFI::ErrorTypeInfo do
|
7
7
|
let(:instance) { GirFFI::ErrorTypeInfo.new }
|
8
8
|
|
9
|
-
describe
|
10
|
-
it
|
11
|
-
instance.array_length.must_equal(-1)
|
9
|
+
describe "#array_length" do
|
10
|
+
it "returns the correct value" do
|
11
|
+
_(instance.array_length).must_equal(-1)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
16
|
-
it
|
17
|
-
instance.tag_or_class.must_equal [:pointer, :error]
|
15
|
+
describe "#tag_or_class" do
|
16
|
+
it "returns the correct value" do
|
17
|
+
_(instance.tag_or_class).must_equal [:pointer, :error]
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
22
|
-
it
|
23
|
-
instance.pointer
|
21
|
+
describe "#pointer?" do
|
22
|
+
it "returns the correct value" do
|
23
|
+
_(instance.pointer?).must_equal true
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe
|
28
|
-
it
|
29
|
-
instance.flattened_tag.must_equal :error
|
27
|
+
describe "#flattened_tag" do
|
28
|
+
it "returns the correct value" do
|
29
|
+
_(instance.flattened_tag).must_equal :error
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
describe
|
34
|
-
it
|
35
|
-
instance.extra_conversion_arguments.must_equal []
|
33
|
+
describe "#extra_conversion_arguments" do
|
34
|
+
it "returns the correct value" do
|
35
|
+
_(instance.extra_conversion_arguments).must_equal []
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
40
|
-
it
|
41
|
-
instance.argument_class_name.must_equal
|
39
|
+
describe "#argument_class_name" do
|
40
|
+
it "returns the correct value" do
|
41
|
+
_(instance.argument_class_name).must_equal "GLib::Error"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe
|
46
|
-
it
|
47
|
-
instance.needs_ruby_to_c_conversion_for_callbacks
|
45
|
+
describe "#needs_ruby_to_c_conversion_for_callbacks?" do
|
46
|
+
it "returns the correct value" do
|
47
|
+
_(instance.needs_ruby_to_c_conversion_for_callbacks?).must_equal true
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|