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,60 +1,60 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
GirFFI.setup :Gio
|
6
6
|
GirFFI.setup :Gst
|
7
7
|
|
8
8
|
describe GirFFI::Builders::UnintrospectableBuilder do
|
9
|
-
describe
|
9
|
+
describe "building the GLocalFile type" do
|
10
10
|
before do
|
11
|
-
Gio.file_new_for_path
|
11
|
+
Gio.file_new_for_path "/"
|
12
12
|
|
13
|
-
@gtype = GObject.type_from_name
|
13
|
+
@gtype = GObject.type_from_name "GLocalFile"
|
14
14
|
@info = GirFFI::UnintrospectableTypeInfo.new(@gtype)
|
15
15
|
@bldr = GirFFI::Builders::UnintrospectableBuilder.new(@info)
|
16
16
|
@klass = @bldr.build_class
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it "builds a class" do
|
20
20
|
assert_instance_of Class, @klass
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it "builds a class derived from GObject::Object" do
|
24
24
|
assert_includes @klass.registered_ancestors, GObject::Object
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it "builds a class derived from Gio::File" do
|
28
28
|
assert_includes @klass.registered_ancestors, Gio::File
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
31
|
+
it "returns the same class when built again" do
|
32
32
|
other_bldr = GirFFI::Builders::UnintrospectableBuilder.new(@info)
|
33
33
|
other_klass = other_bldr.build_class
|
34
34
|
|
35
35
|
assert_equal @klass, other_klass
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
38
|
+
describe "its #find_signal method" do
|
39
39
|
it "returns nil for a signal that doesn't exist" do
|
40
|
-
@bldr.find_signal(
|
40
|
+
_(@bldr.find_signal("foo")).must_be_nil
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
44
|
-
signal = @bldr.find_signal
|
45
|
-
signal.name.must_equal
|
43
|
+
it "finds signals in ancestor classes" do
|
44
|
+
signal = @bldr.find_signal "notify"
|
45
|
+
_(signal.name).must_equal "notify"
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
describe
|
50
|
-
it
|
51
|
-
@bldr.object_class_struct.must_equal GObject::ObjectClass
|
49
|
+
describe "#object_class_struct" do
|
50
|
+
it "returns the parent class struct" do
|
51
|
+
_(@bldr.object_class_struct).must_equal GObject::ObjectClass
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe
|
57
|
-
let(:instance) { Gst::ElementFactory.make(
|
56
|
+
describe "building the GstFakeSink type" do
|
57
|
+
let(:instance) { Gst::ElementFactory.make("fakesink", "sink") }
|
58
58
|
let(:sink_class) { instance.class }
|
59
59
|
let(:builder) { sink_class.gir_ffi_builder }
|
60
60
|
|
@@ -62,11 +62,11 @@ describe GirFFI::Builders::UnintrospectableBuilder do
|
|
62
62
|
Gst.init []
|
63
63
|
end
|
64
64
|
|
65
|
-
describe
|
66
|
-
it
|
67
|
-
signal = builder.find_signal
|
68
|
-
signal.wont_be_nil
|
69
|
-
signal.name.must_equal
|
65
|
+
describe "its #find_signal method" do
|
66
|
+
it "finds signals that are not defined in the GIR" do
|
67
|
+
signal = builder.find_signal "handoff"
|
68
|
+
_(signal).wont_be_nil
|
69
|
+
_(signal.name).must_equal "handoff"
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -1,31 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::UnionBuilder do
|
6
|
-
let(:union_info) { get_introspection_data(
|
6
|
+
let(:union_info) { get_introspection_data("Regress", "FooBUnion") }
|
7
7
|
let(:builder) { GirFFI::Builders::UnionBuilder.new union_info }
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe "#setup_instance_method" do
|
10
10
|
it "returns nil looking for a method that doesn't exist" do
|
11
|
-
builder.setup_instance_method(
|
11
|
+
_(builder.setup_instance_method("blub")).must_be_nil
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
16
|
-
it
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
:v_int64, :int64, 0,
|
21
|
-
:v_double, :double, 0,
|
22
|
-
:v_pointer, :pointer, 0]
|
15
|
+
describe "#layout_specification" do
|
16
|
+
it "returns the correct layout for Regress::FooBUnion" do
|
17
|
+
_(builder.layout_specification).must_equal [:type, :int32, 0,
|
18
|
+
:v, :double, 0,
|
19
|
+
:rect, :pointer, 0]
|
23
20
|
end
|
24
21
|
end
|
25
22
|
|
26
|
-
describe
|
27
|
-
it
|
28
|
-
builder.layout_superclass.must_equal GirFFI::Union
|
23
|
+
describe "#layout_superclass" do
|
24
|
+
it "returns GirFFI::Union" do
|
25
|
+
_(builder.layout_superclass).must_equal GirFFI::Union
|
29
26
|
end
|
30
27
|
end
|
31
28
|
end
|
@@ -1,6 +1,6 @@
|
|
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
|
GirFFI.setup :Regress
|
@@ -13,392 +13,392 @@ describe GirFFI::Builders::UserDefinedBuilder do
|
|
13
13
|
let(:builder) { GirFFI::Builders::UserDefinedBuilder.new info }
|
14
14
|
let(:info) { GirFFI::UserDefinedObjectInfo.new derived_class }
|
15
15
|
|
16
|
-
describe
|
16
|
+
describe "#build_class" do
|
17
17
|
before do
|
18
18
|
builder.build_class
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
21
|
+
describe "with type info containing one integer property" do
|
22
22
|
let(:info) do
|
23
23
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
24
|
-
it.install_property GObject.param_spec_int(
|
25
|
-
|
24
|
+
it.install_property GObject.param_spec_int("foo-bar", "foo bar",
|
25
|
+
"The Foo Bar Property",
|
26
26
|
10, 20, 15,
|
27
27
|
readable: true, writable: true)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
31
|
+
it "registers a type that is bigger than the parent" do
|
32
32
|
gtype = derived_class.gtype
|
33
33
|
q = GObject.type_query gtype
|
34
|
-
q.instance_size.must_be :>, GIMarshallingTests::Object::Struct.size
|
34
|
+
_(q.instance_size).must_be :>, GIMarshallingTests::Object::Struct.size
|
35
35
|
end
|
36
36
|
|
37
37
|
it "gives the type's Struct fields for the parent and the property" do
|
38
|
-
derived_class::Struct.members.must_equal [:parent, :foo_bar]
|
38
|
+
_(derived_class::Struct.members).must_equal [:parent, :foo_bar]
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it "creates accessor functions for the property" do
|
42
42
|
obj = derived_class.new
|
43
43
|
obj.foo_bar = 13
|
44
|
-
obj.foo_bar.must_equal 13
|
44
|
+
_(obj.foo_bar).must_equal 13
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
47
|
+
it "makes the property retrievable using #get_property" do
|
48
48
|
obj = derived_class.new
|
49
49
|
obj.foo_bar = 13
|
50
|
-
obj.get_property(
|
50
|
+
_(obj.get_property("foo-bar")).must_equal 13
|
51
51
|
end
|
52
52
|
|
53
|
-
it
|
53
|
+
it "makes the property settable using #set_property" do
|
54
54
|
obj = derived_class.new
|
55
|
-
obj.set_property(
|
56
|
-
obj.foo_bar.must_equal 20
|
55
|
+
obj.set_property("foo-bar", 20)
|
56
|
+
_(obj.foo_bar).must_equal 20
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
59
|
+
it "keeps parent properties accessible through their accessors" do
|
60
60
|
obj = derived_class.new
|
61
61
|
obj.int = 24
|
62
|
-
obj.int.must_equal 24
|
62
|
+
_(obj.int).must_equal 24
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
65
|
+
it "keeps parent properties accessible through get_property and set_property" do
|
66
66
|
obj = derived_class.new
|
67
|
-
obj.set_property(
|
68
|
-
obj.get_property(
|
67
|
+
obj.set_property("int", 24)
|
68
|
+
_(obj.get_property("int")).must_equal 24
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
describe
|
72
|
+
describe "with type info containing properties of several different types" do
|
73
73
|
let(:info) do
|
74
74
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
75
|
-
it.install_property GObject.param_spec_string(
|
76
|
-
|
77
|
-
|
75
|
+
it.install_property GObject.param_spec_string("string-prop", "string property",
|
76
|
+
"The String Property",
|
77
|
+
"this is the default value",
|
78
78
|
readable: true, writable: true)
|
79
|
-
it.install_property GObject.param_spec_int(
|
80
|
-
|
79
|
+
it.install_property GObject.param_spec_int("int-prop", "integer property",
|
80
|
+
"The Integer Property",
|
81
81
|
10, 20, 15,
|
82
82
|
readable: true, writable: true)
|
83
|
-
it.install_property GObject.param_spec_long(
|
84
|
-
|
83
|
+
it.install_property GObject.param_spec_long("long-prop", "long property",
|
84
|
+
"The Long Property",
|
85
85
|
10.0, 50.0, 42.0,
|
86
86
|
readable: true, writable: true)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
it
|
90
|
+
it "registers a type of the proper size" do
|
91
91
|
expected_size = derived_class::Struct.size
|
92
92
|
gtype = derived_class.gtype
|
93
93
|
q = GObject.type_query gtype
|
94
|
-
q.instance_size.must_equal expected_size
|
94
|
+
_(q.instance_size).must_equal expected_size
|
95
95
|
end
|
96
96
|
|
97
97
|
it "gives the type's Struct fields for the parent and the properties with the correct offsets" do
|
98
98
|
offsets = derived_class::Struct.offsets
|
99
99
|
alignment = derived_class::Struct.alignment
|
100
|
-
alignment.must_equal 8 # TODO: Fix tests for platforms where this fails.
|
101
|
-
offsets.must_equal [[:parent, 0], [:string_prop, 32], [:int_prop, 40], [:long_prop, 48]]
|
100
|
+
_(alignment).must_equal 8 # TODO: Fix tests for platforms where this fails.
|
101
|
+
_(offsets).must_equal [[:parent, 0], [:string_prop, 32], [:int_prop, 40], [:long_prop, 48]]
|
102
102
|
end
|
103
103
|
|
104
|
-
it
|
104
|
+
it "creates accessor functions for the string property" do
|
105
105
|
obj = derived_class.new
|
106
|
-
obj.string_prop =
|
107
|
-
obj.string_prop.must_equal
|
106
|
+
obj.string_prop = "hello!"
|
107
|
+
_(obj.string_prop).must_equal "hello!"
|
108
108
|
end
|
109
109
|
|
110
|
-
it
|
110
|
+
it "creates accessor functions for the integer property" do
|
111
111
|
obj = derived_class.new
|
112
112
|
obj.int_prop = 13
|
113
|
-
obj.int_prop.must_equal 13
|
113
|
+
_(obj.int_prop).must_equal 13
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
describe
|
117
|
+
describe "with a boxed property" do
|
118
118
|
let(:boxed_gtype) { GIMarshallingTests::BoxedStruct.gtype }
|
119
119
|
let(:info) do
|
120
120
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
121
|
-
it.install_property GObject.param_spec_boxed(
|
122
|
-
|
121
|
+
it.install_property GObject.param_spec_boxed("boxed-prop", "boxed property",
|
122
|
+
"The Boxed Property",
|
123
123
|
boxed_gtype,
|
124
124
|
readable: true, writable: true)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
it
|
128
|
+
it "registers a type of the proper size" do
|
129
129
|
expected_size = derived_class::Struct.size
|
130
130
|
gtype = derived_class.gtype
|
131
131
|
q = GObject.type_query gtype
|
132
|
-
q.instance_size.must_equal expected_size
|
132
|
+
_(q.instance_size).must_equal expected_size
|
133
133
|
end
|
134
134
|
|
135
135
|
it "gives the type's Struct fields for the parent and the property" do
|
136
|
-
derived_class::Struct.members.must_equal [:parent, :boxed_prop]
|
136
|
+
_(derived_class::Struct.members).must_equal [:parent, :boxed_prop]
|
137
137
|
end
|
138
138
|
|
139
|
-
it
|
139
|
+
it "creates accessor functions for the property" do
|
140
140
|
obj = derived_class.new
|
141
141
|
boxed = GIMarshallingTests::BoxedStruct.new
|
142
142
|
boxed.long_ = 423
|
143
143
|
obj.boxed_prop = boxed
|
144
|
-
obj.boxed_prop.long_.must_equal 423
|
144
|
+
_(obj.boxed_prop.long_).must_equal 423
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
describe
|
148
|
+
describe "with an object property" do
|
149
149
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
150
150
|
let(:info) do
|
151
151
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
152
|
-
it.install_property GObject.param_spec_object(
|
153
|
-
|
152
|
+
it.install_property GObject.param_spec_object("object-prop", "object property",
|
153
|
+
"The Object Property",
|
154
154
|
object_gtype,
|
155
155
|
readable: true, writable: true)
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
-
it
|
159
|
+
it "registers a type of the proper size" do
|
160
160
|
expected_size = derived_class::Struct.size
|
161
161
|
gtype = derived_class.gtype
|
162
162
|
q = GObject.type_query gtype
|
163
|
-
q.instance_size.must_equal expected_size
|
163
|
+
_(q.instance_size).must_equal expected_size
|
164
164
|
end
|
165
165
|
|
166
166
|
it "gives the type's Struct fields for the parent and the property" do
|
167
|
-
derived_class::Struct.members.must_equal [:parent, :object_prop]
|
167
|
+
_(derived_class::Struct.members).must_equal [:parent, :object_prop]
|
168
168
|
end
|
169
169
|
|
170
|
-
it
|
170
|
+
it "creates accessor functions for the property" do
|
171
171
|
obj = derived_class.new
|
172
172
|
object = GIMarshallingTests::Object.new 42
|
173
173
|
object.int = 423
|
174
174
|
obj.object_prop = object
|
175
|
-
obj.object_prop.int.must_equal 423
|
175
|
+
_(obj.object_prop.int).must_equal 423
|
176
176
|
end
|
177
177
|
|
178
|
-
it
|
178
|
+
it "allows clearing the property throught the setter method" do
|
179
179
|
obj = derived_class.new
|
180
180
|
obj.object_prop = nil
|
181
|
-
obj.object_prop.must_be_nil
|
181
|
+
_(obj.object_prop).must_be_nil
|
182
182
|
end
|
183
183
|
|
184
|
-
it
|
184
|
+
it "handles reference counting correctly when using the accessor" do
|
185
185
|
obj = derived_class.new
|
186
186
|
object = GIMarshallingTests::Object.new 42
|
187
187
|
obj.object_prop = object
|
188
|
-
object_ref_count(object).must_equal 2
|
188
|
+
_(object_ref_count(object)).must_equal 2
|
189
189
|
end
|
190
190
|
|
191
|
-
it
|
191
|
+
it "handles reference counting correctly when using the set_property method" do
|
192
192
|
obj = derived_class.new
|
193
193
|
object = GIMarshallingTests::Object.new 42
|
194
194
|
|
195
|
-
object_ref_count(object).must_equal 1
|
196
|
-
obj.set_property(
|
197
|
-
object_ref_count(object).must_equal 4 # Due to extra Value#set_value + Value#get_value
|
195
|
+
_(object_ref_count(object)).must_equal 1
|
196
|
+
obj.set_property("object_prop", object)
|
197
|
+
_(object_ref_count(object)).must_equal 4 # Due to extra Value#set_value + Value#get_value
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
201
|
-
describe
|
201
|
+
describe "with a boolean property" do
|
202
202
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
203
203
|
let(:info) do
|
204
204
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
205
|
-
it.install_property GObject.param_spec_boolean(
|
206
|
-
|
205
|
+
it.install_property GObject.param_spec_boolean("the-prop", "the property",
|
206
|
+
"The Property",
|
207
207
|
true,
|
208
208
|
readable: true, writable: true)
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
212
|
-
it
|
212
|
+
it "creates accessor functions for the property" do
|
213
213
|
obj = derived_class.new
|
214
214
|
obj.the_prop = true
|
215
|
-
obj.the_prop.must_equal true
|
215
|
+
_(obj.the_prop).must_equal true
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
219
|
-
describe
|
219
|
+
describe "with a char property" do
|
220
220
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
221
221
|
let(:info) do
|
222
222
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
223
|
-
it.install_property GObject.param_spec_char(
|
224
|
-
|
223
|
+
it.install_property GObject.param_spec_char("the-prop", "the property",
|
224
|
+
"The Property",
|
225
225
|
-20, 100, 15,
|
226
226
|
readable: true, writable: true)
|
227
227
|
end
|
228
228
|
end
|
229
229
|
|
230
|
-
it
|
230
|
+
it "creates accessor functions for the property" do
|
231
231
|
obj = derived_class.new
|
232
232
|
obj.the_prop = -13
|
233
|
-
obj.the_prop.must_equal(-13)
|
233
|
+
_(obj.the_prop).must_equal(-13)
|
234
234
|
end
|
235
235
|
end
|
236
236
|
|
237
|
-
describe
|
237
|
+
describe "with a uchar property" do
|
238
238
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
239
239
|
let(:info) do
|
240
240
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
241
|
-
it.install_property GObject.param_spec_uchar(
|
242
|
-
|
241
|
+
it.install_property GObject.param_spec_uchar("the-prop", "the property",
|
242
|
+
"The Property",
|
243
243
|
10, 100, 15,
|
244
244
|
readable: true, writable: true)
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
248
|
-
it
|
248
|
+
it "creates accessor functions for the property" do
|
249
249
|
obj = derived_class.new
|
250
250
|
obj.the_prop = 13
|
251
|
-
obj.the_prop.must_equal 13
|
251
|
+
_(obj.the_prop).must_equal 13
|
252
252
|
end
|
253
253
|
end
|
254
254
|
|
255
|
-
describe
|
255
|
+
describe "with a uint property" do
|
256
256
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
257
257
|
let(:info) do
|
258
258
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
259
|
-
it.install_property GObject.param_spec_uint(
|
260
|
-
|
259
|
+
it.install_property GObject.param_spec_uint("the-prop", "the property",
|
260
|
+
"The Property",
|
261
261
|
10, 100, 15,
|
262
262
|
readable: true, writable: true)
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
-
it
|
266
|
+
it "creates accessor functions for the property" do
|
267
267
|
obj = derived_class.new
|
268
268
|
obj.the_prop = 423
|
269
|
-
obj.the_prop.must_equal 423
|
269
|
+
_(obj.the_prop).must_equal 423
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
|
-
describe
|
273
|
+
describe "with a ulong property" do
|
274
274
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
275
275
|
let(:info) do
|
276
276
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
277
|
-
it.install_property GObject.param_spec_ulong(
|
278
|
-
|
277
|
+
it.install_property GObject.param_spec_ulong("the-prop", "the property",
|
278
|
+
"The Property",
|
279
279
|
10, 100, 15,
|
280
280
|
readable: true, writable: true)
|
281
281
|
end
|
282
282
|
end
|
283
283
|
|
284
|
-
it
|
284
|
+
it "creates accessor functions for the property" do
|
285
285
|
obj = derived_class.new
|
286
286
|
obj.the_prop = 423_432
|
287
|
-
obj.the_prop.must_equal 423_432
|
287
|
+
_(obj.the_prop).must_equal 423_432
|
288
288
|
end
|
289
289
|
end
|
290
290
|
|
291
|
-
describe
|
291
|
+
describe "with a int64 property" do
|
292
292
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
293
293
|
let(:info) do
|
294
294
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
295
|
-
it.install_property GObject.param_spec_int64(
|
296
|
-
|
295
|
+
it.install_property GObject.param_spec_int64("the-prop", "the property",
|
296
|
+
"The Property",
|
297
297
|
10, 100, 15,
|
298
298
|
readable: true, writable: true)
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
302
|
-
it
|
302
|
+
it "creates accessor functions for the property" do
|
303
303
|
obj = derived_class.new
|
304
304
|
obj.the_prop = -423_432
|
305
|
-
obj.the_prop.must_equal(-423_432)
|
305
|
+
_(obj.the_prop).must_equal(-423_432)
|
306
306
|
end
|
307
307
|
end
|
308
308
|
|
309
|
-
describe
|
309
|
+
describe "with a uint64 property" do
|
310
310
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
311
311
|
let(:info) do
|
312
312
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
313
|
-
it.install_property GObject.param_spec_uint64(
|
314
|
-
|
313
|
+
it.install_property GObject.param_spec_uint64("the-prop", "the property",
|
314
|
+
"The Property",
|
315
315
|
10, 100, 15,
|
316
316
|
readable: true, writable: true)
|
317
317
|
end
|
318
318
|
end
|
319
319
|
|
320
|
-
it
|
320
|
+
it "creates accessor functions for the property" do
|
321
321
|
obj = derived_class.new
|
322
322
|
obj.the_prop = 423_432
|
323
|
-
obj.the_prop.must_equal 423_432
|
323
|
+
_(obj.the_prop).must_equal 423_432
|
324
324
|
end
|
325
325
|
end
|
326
326
|
|
327
|
-
describe
|
327
|
+
describe "with a float property" do
|
328
328
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
329
329
|
let(:info) do
|
330
330
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
331
|
-
it.install_property GObject.param_spec_float(
|
332
|
-
|
331
|
+
it.install_property GObject.param_spec_float("the-prop", "the property",
|
332
|
+
"The Property",
|
333
333
|
10.0, 100.0, 15.0,
|
334
334
|
readable: true, writable: true)
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
338
|
-
it
|
338
|
+
it "creates accessor functions for the property" do
|
339
339
|
obj = derived_class.new
|
340
340
|
obj.the_prop = 42.23
|
341
|
-
obj.the_prop.must_be_within_epsilon 42.23
|
341
|
+
_(obj.the_prop).must_be_within_epsilon 42.23
|
342
342
|
end
|
343
343
|
end
|
344
344
|
|
345
|
-
describe
|
345
|
+
describe "with a double property" do
|
346
346
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
347
347
|
let(:info) do
|
348
348
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
349
|
-
it.install_property GObject.param_spec_double(
|
350
|
-
|
349
|
+
it.install_property GObject.param_spec_double("the-prop", "the property",
|
350
|
+
"The Property",
|
351
351
|
10.0, 100.0, 15.0,
|
352
352
|
readable: true, writable: true)
|
353
353
|
end
|
354
354
|
end
|
355
355
|
|
356
|
-
it
|
356
|
+
it "creates accessor functions for the property" do
|
357
357
|
obj = derived_class.new
|
358
358
|
obj.the_prop = 42.23
|
359
|
-
obj.the_prop.must_equal 42.23
|
359
|
+
_(obj.the_prop).must_equal 42.23
|
360
360
|
end
|
361
361
|
end
|
362
362
|
|
363
|
-
describe
|
363
|
+
describe "with an enum property" do
|
364
364
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
365
365
|
let(:info) do
|
366
366
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
367
|
-
prop = GObject.param_spec_enum(
|
368
|
-
|
367
|
+
prop = GObject.param_spec_enum("the-prop", "the property",
|
368
|
+
"The Property",
|
369
369
|
GIMarshallingTests::GEnum.gtype, 0,
|
370
370
|
readable: true, writable: true)
|
371
371
|
it.install_property prop
|
372
372
|
end
|
373
373
|
end
|
374
374
|
|
375
|
-
it
|
375
|
+
it "creates accessor functions for the property" do
|
376
376
|
obj = derived_class.new
|
377
377
|
obj.the_prop = :value2
|
378
|
-
obj.the_prop.must_equal :value2
|
378
|
+
_(obj.the_prop).must_equal :value2
|
379
379
|
end
|
380
380
|
end
|
381
381
|
|
382
|
-
describe
|
382
|
+
describe "with a flags property" do
|
383
383
|
let(:object_gtype) { GIMarshallingTests::Object.gtype }
|
384
384
|
let(:info) do
|
385
385
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
386
|
-
prop = GObject.param_spec_flags(
|
387
|
-
|
386
|
+
prop = GObject.param_spec_flags("the-prop", "the property",
|
387
|
+
"The Property",
|
388
388
|
GIMarshallingTests::Flags.gtype, 0,
|
389
389
|
readable: true, writable: true)
|
390
390
|
it.install_property prop
|
391
391
|
end
|
392
392
|
end
|
393
393
|
|
394
|
-
it
|
394
|
+
it "creates accessor functions for the property" do
|
395
395
|
obj = derived_class.new
|
396
396
|
obj.the_prop = { value2: true }
|
397
|
-
obj.the_prop.must_equal value2: true
|
397
|
+
_(obj.the_prop).must_equal value2: true
|
398
398
|
end
|
399
399
|
end
|
400
400
|
|
401
|
-
describe
|
401
|
+
describe "when deriving from a class with hidden struct size" do
|
402
402
|
let(:parent_class) { Regress::TestInheritDrawable }
|
403
403
|
let(:parent_size) do
|
404
404
|
GObject.type_query(parent_class.gtype).instance_size
|
@@ -408,39 +408,39 @@ describe GirFFI::Builders::UserDefinedBuilder do
|
|
408
408
|
end
|
409
409
|
let(:info) do
|
410
410
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
411
|
-
it.install_property GObject.param_spec_int(
|
412
|
-
|
411
|
+
it.install_property GObject.param_spec_int("int-prop", "integer property",
|
412
|
+
"Integer Property",
|
413
413
|
10, 20, 15,
|
414
414
|
readable: true, writable: true)
|
415
415
|
end
|
416
416
|
end
|
417
417
|
|
418
|
-
it
|
418
|
+
it "registers a type that is bigger than the parent" do
|
419
419
|
class_size = GObject.type_query(derived_class.gtype).instance_size
|
420
|
-
class_size.must_be :>, parent_size
|
420
|
+
_(class_size).must_be :>, parent_size
|
421
421
|
end
|
422
422
|
|
423
|
-
it
|
423
|
+
it "leaves enough space in derived struct layout" do
|
424
424
|
struct_size = derived_class::Struct.size
|
425
|
-
struct_size.must_be :>, parent_size
|
425
|
+
_(struct_size).must_be :>, parent_size
|
426
426
|
end
|
427
427
|
end
|
428
428
|
|
429
|
-
describe
|
429
|
+
describe "with type info containing an overridden g_name" do
|
430
430
|
let(:info) do
|
431
431
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
432
432
|
it.g_name = "OtherName#{Sequence.next}"
|
433
433
|
end
|
434
434
|
end
|
435
435
|
|
436
|
-
it
|
436
|
+
it "registers a type under the overridden name" do
|
437
437
|
registered_name = GObject.type_name(derived_class.gtype)
|
438
|
-
registered_name.must_equal info.g_name
|
439
|
-
registered_name.wont_equal derived_class.name
|
438
|
+
_(registered_name).must_equal info.g_name
|
439
|
+
_(registered_name).wont_equal derived_class.name
|
440
440
|
end
|
441
441
|
end
|
442
442
|
|
443
|
-
describe
|
443
|
+
describe "with type info containing a vfunc" do
|
444
444
|
let(:info) do
|
445
445
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
446
446
|
it.install_vfunc_implementation :method_int8_in, proc { |instance, in_|
|
@@ -449,14 +449,14 @@ describe GirFFI::Builders::UserDefinedBuilder do
|
|
449
449
|
end
|
450
450
|
end
|
451
451
|
|
452
|
-
it
|
452
|
+
it "allows the vfunc to be called through its invoker" do
|
453
453
|
obj = derived_class.new
|
454
454
|
obj.method_int8_in 12
|
455
|
-
obj.int.must_equal 12
|
455
|
+
_(obj.int).must_equal 12
|
456
456
|
end
|
457
457
|
end
|
458
458
|
|
459
|
-
describe
|
459
|
+
describe "when using a default vfunc implementation" do
|
460
460
|
let(:base_class) { Regress::TestObj }
|
461
461
|
let(:info) do
|
462
462
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
@@ -472,13 +472,13 @@ describe GirFFI::Builders::UserDefinedBuilder do
|
|
472
472
|
end
|
473
473
|
end
|
474
474
|
|
475
|
-
it
|
475
|
+
it "allows the vfunc to be called through its invoker" do
|
476
476
|
obj = derived_class.new
|
477
|
-
obj.do_matrix(
|
477
|
+
_(obj.do_matrix("bar")).must_equal 44
|
478
478
|
end
|
479
479
|
end
|
480
480
|
|
481
|
-
describe
|
481
|
+
describe "with type info containing a vfunc from an included Interface" do
|
482
482
|
let(:info) do
|
483
483
|
derived_class.class_eval { include GIMarshallingTests::Interface }
|
484
484
|
GirFFI::UserDefinedObjectInfo.new derived_class do |it|
|
@@ -487,38 +487,38 @@ describe GirFFI::Builders::UserDefinedBuilder do
|
|
487
487
|
end
|
488
488
|
end
|
489
489
|
|
490
|
-
it
|
490
|
+
it "marks the type as conforming to the included Interface" do
|
491
491
|
iface_gtype = GIMarshallingTests::Interface.gtype
|
492
|
-
GObject.type_interfaces(derived_class.gtype).to_a.must_equal [iface_gtype]
|
492
|
+
_(GObject.type_interfaces(derived_class.gtype).to_a).must_equal [iface_gtype]
|
493
493
|
end
|
494
494
|
|
495
|
-
it
|
495
|
+
it "allows the vfunc to be called through its invoker" do
|
496
496
|
obj = derived_class.new
|
497
497
|
obj.test_int8_in 12
|
498
|
-
obj.int.must_equal 12
|
498
|
+
_(obj.int).must_equal 12
|
499
499
|
end
|
500
500
|
end
|
501
501
|
|
502
|
-
it
|
502
|
+
it "keeps the gtype for an already registered class" do
|
503
503
|
gtype = derived_class.gtype
|
504
504
|
other_builder = GirFFI::Builders::UserDefinedBuilder.new info
|
505
505
|
other_class = other_builder.build_class
|
506
|
-
other_class.gtype.must_equal gtype
|
506
|
+
_(other_class.gtype).must_equal gtype
|
507
507
|
end
|
508
508
|
|
509
|
-
it
|
510
|
-
derived_class.gtype.wont_equal GIMarshallingTests::Object.gtype
|
509
|
+
it "creates a class with a new GType" do
|
510
|
+
_(derived_class.gtype).wont_equal GIMarshallingTests::Object.gtype
|
511
511
|
end
|
512
512
|
|
513
|
-
it
|
513
|
+
it "makes the registered class return objects with the correct GType" do
|
514
514
|
obj = derived_class.new
|
515
|
-
GObject.type_from_instance(obj).must_equal derived_class.gtype
|
515
|
+
_(GObject.type_from_instance(obj)).must_equal derived_class.gtype
|
516
516
|
end
|
517
517
|
end
|
518
518
|
|
519
|
-
describe
|
520
|
-
it
|
521
|
-
builder.object_class_struct.must_equal GIMarshallingTests::ObjectClass
|
519
|
+
describe "#object_class_struct" do
|
520
|
+
it "returns the parent class struct" do
|
521
|
+
_(builder.object_class_struct).must_equal GIMarshallingTests::ObjectClass
|
522
522
|
end
|
523
523
|
end
|
524
524
|
end
|