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,32 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
|
-
require
|
5
|
+
require "ffi-gobject"
|
6
6
|
describe GObject::ParamSpec do
|
7
7
|
let(:pspec) do
|
8
|
-
GObject.param_spec_int(
|
9
|
-
|
8
|
+
GObject.param_spec_int("foo-bar", "foo bar",
|
9
|
+
"Foo Bar",
|
10
10
|
1, 3, 2,
|
11
11
|
readable: true, writable: true)
|
12
12
|
end
|
13
13
|
let(:pspec_struct) { GObject::ParamSpec::Struct.new(pspec.to_ptr) }
|
14
14
|
|
15
|
-
describe
|
16
|
-
it
|
15
|
+
describe "#ref" do
|
16
|
+
it "increases the ref count" do
|
17
17
|
old = pspec_struct[:ref_count]
|
18
18
|
pspec.ref
|
19
|
-
pspec_struct[:ref_count].must_equal old + 1
|
19
|
+
_(pspec_struct[:ref_count]).must_equal old + 1
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it
|
25
|
-
pspec.accessor_name.must_equal
|
23
|
+
describe "#accessor_name" do
|
24
|
+
it "returns a safe ruby method name" do
|
25
|
+
_(pspec.accessor_name).must_equal "foo_bar"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
30
|
-
proc { GObject::ParamSpec.new }.must_raise NoMethodError
|
29
|
+
it "cannot be instantiated directly" do
|
30
|
+
_(proc { GObject::ParamSpec.new }).must_raise NoMethodError
|
31
31
|
end
|
32
32
|
end
|
@@ -1,361 +1,381 @@
|
|
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
|
GirFFI.setup :Gio
|
7
7
|
|
8
8
|
describe GObject::Value do
|
9
|
-
describe
|
10
|
-
describe
|
9
|
+
describe "::Struct" do
|
10
|
+
describe "layout" do
|
11
11
|
let(:layout) { GObject::Value::Struct.layout }
|
12
12
|
|
13
|
-
it
|
14
|
-
layout.members.must_equal [:g_type, :data]
|
13
|
+
it "consists of :g_type and :data" do
|
14
|
+
_(layout.members).must_equal [:g_type, :data]
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it "has an array as its second element" do
|
18
18
|
types = layout.fields.map(&:type)
|
19
|
-
types[1].class.must_equal FFI::Type::Array
|
19
|
+
_(types[1].class).must_equal FFI::Type::Array
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
25
|
-
it
|
24
|
+
describe ".for_gtype" do
|
25
|
+
it "handles char" do
|
26
26
|
gv = GObject::Value.for_gtype GObject::TYPE_CHAR
|
27
|
-
gv.current_gtype.must_equal GObject::TYPE_CHAR
|
27
|
+
_(gv.current_gtype).must_equal GObject::TYPE_CHAR
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
30
|
+
it "handles invalid type" do
|
31
31
|
gv = GObject::Value.for_gtype GObject::TYPE_INVALID
|
32
|
-
gv.current_gtype.must_equal GObject::TYPE_INVALID
|
32
|
+
_(gv.current_gtype).must_equal GObject::TYPE_INVALID
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it "handles void type" do
|
36
36
|
gv = GObject::Value.for_gtype GObject::TYPE_NONE
|
37
|
-
gv.current_gtype.must_equal GObject::TYPE_INVALID
|
37
|
+
_(gv.current_gtype).must_equal GObject::TYPE_INVALID
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe
|
42
|
-
it
|
41
|
+
describe "::wrap_ruby_value" do
|
42
|
+
it "wraps a boolean false" do
|
43
43
|
gv = GObject::Value.wrap_ruby_value false
|
44
44
|
assert_instance_of GObject::Value, gv
|
45
|
-
gv.get_boolean.must_equal false
|
45
|
+
_(gv.get_boolean).must_equal false
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
48
|
+
it "wraps a boolean true" do
|
49
49
|
gv = GObject::Value.wrap_ruby_value true
|
50
50
|
assert_instance_of GObject::Value, gv
|
51
|
-
gv.get_boolean.must_equal true
|
51
|
+
_(gv.get_boolean).must_equal true
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
54
|
+
it "wraps an Integer" do
|
55
55
|
gv = GObject::Value.wrap_ruby_value 42
|
56
|
-
gv.get_int.must_equal 42
|
56
|
+
_(gv.get_int).must_equal 42
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
60
|
-
gv = GObject::Value.wrap_ruby_value
|
61
|
-
gv.get_string.must_equal
|
59
|
+
it "wraps a String" do
|
60
|
+
gv = GObject::Value.wrap_ruby_value "Some Random String"
|
61
|
+
_(gv.get_string).must_equal "Some Random String"
|
62
62
|
end
|
63
63
|
|
64
|
-
it
|
64
|
+
it "wraps nil" do
|
65
65
|
gv = GObject::Value.wrap_ruby_value nil
|
66
66
|
assert_instance_of GObject::Value, gv
|
67
|
-
gv.get_value.must_be_nil
|
67
|
+
_(gv.get_value).must_be_nil
|
68
68
|
end
|
69
69
|
|
70
|
-
it
|
70
|
+
it "wraps object values" do
|
71
71
|
value = GObject::Object.new({})
|
72
72
|
gv = GObject::Value.wrap_ruby_value value
|
73
|
-
object_ref_count(value).must_equal 2
|
74
|
-
gv.get_value.must_equal value
|
75
|
-
object_ref_count(value).must_equal 3
|
73
|
+
_(object_ref_count(value)).must_equal 2
|
74
|
+
_(gv.get_value).must_equal value
|
75
|
+
_(object_ref_count(value)).must_equal 3
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
describe
|
80
|
-
it
|
79
|
+
describe "#set_value" do
|
80
|
+
it "handles signed char values" do
|
81
81
|
value = -83
|
82
82
|
gv = GObject::Value.for_gtype GObject::TYPE_CHAR
|
83
83
|
gv.set_value value
|
84
|
-
gv.get_schar.must_equal value
|
84
|
+
_(gv.get_schar).must_equal value
|
85
85
|
end
|
86
86
|
|
87
|
-
it
|
87
|
+
it "handles unsigned char values" do
|
88
88
|
value = 174
|
89
89
|
gv = GObject::Value.for_gtype GObject::TYPE_UCHAR
|
90
90
|
gv.set_value value
|
91
|
-
gv.get_uchar.must_equal value
|
91
|
+
_(gv.get_uchar).must_equal value
|
92
92
|
end
|
93
93
|
|
94
|
-
it
|
94
|
+
it "handles enum values presented as symbols" do
|
95
95
|
value = :value2
|
96
96
|
gv = GObject::Value.for_gtype Regress::TestEnum.gtype
|
97
97
|
gv.set_value value
|
98
|
-
gv.get_value.must_equal value
|
98
|
+
_(gv.get_value).must_equal value
|
99
99
|
end
|
100
100
|
|
101
|
-
it
|
101
|
+
it "handles enum values presented as numbers" do
|
102
102
|
value = :value2
|
103
103
|
gv = GObject::Value.for_gtype Regress::TestEnum.gtype
|
104
104
|
gv.set_value Regress::TestEnum[value]
|
105
|
-
gv.get_value.must_equal value
|
105
|
+
_(gv.get_value).must_equal value
|
106
106
|
end
|
107
107
|
|
108
|
-
it
|
108
|
+
it "handles flag values presented as hashes" do
|
109
|
+
value = { flag2: true }
|
110
|
+
gv = GObject::Value.for_gtype Regress::TestFlags.gtype
|
111
|
+
gv.set_value value
|
112
|
+
_(gv.get_value).must_equal value
|
113
|
+
end
|
114
|
+
|
115
|
+
it "handles flag values presented as symbols" do
|
116
|
+
gv = GObject::Value.for_gtype Regress::TestFlags.gtype
|
117
|
+
gv.set_value :flag2
|
118
|
+
_(gv.get_value).must_equal(flag2: true)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "handles flag values presented as numbers" do
|
122
|
+
value = { flag2: true }
|
123
|
+
gv = GObject::Value.for_gtype Regress::TestFlags.gtype
|
124
|
+
gv.set_value Regress::TestFlags.to_native(value, nil)
|
125
|
+
_(gv.get_value).must_equal value
|
126
|
+
end
|
127
|
+
|
128
|
+
it "handles GType values" do
|
109
129
|
value = GObject::TYPE_STRING
|
110
130
|
gv = GObject::Value.for_gtype GObject::TYPE_GTYPE
|
111
131
|
gv.set_value value
|
112
|
-
gv.get_gtype.must_equal value
|
132
|
+
_(gv.get_gtype).must_equal value
|
113
133
|
end
|
114
134
|
|
115
|
-
it
|
135
|
+
it "handles int64 values" do
|
116
136
|
value = 0x1234_5678_9012_3456
|
117
137
|
gv = GObject::Value.for_gtype GObject::TYPE_INT64
|
118
138
|
gv.set_value value
|
119
|
-
gv.get_int64.must_equal value
|
139
|
+
_(gv.get_int64).must_equal value
|
120
140
|
end
|
121
141
|
|
122
|
-
it
|
142
|
+
it "handles long values" do
|
123
143
|
value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678
|
124
144
|
gv = GObject::Value.for_gtype GObject::TYPE_LONG
|
125
145
|
gv.set_value value
|
126
|
-
gv.get_long.must_equal value
|
146
|
+
_(gv.get_long).must_equal value
|
127
147
|
end
|
128
148
|
|
129
|
-
it
|
149
|
+
it "handles uchar values" do
|
130
150
|
value = 83
|
131
151
|
gv = GObject::Value.for_gtype GObject::TYPE_UCHAR
|
132
152
|
gv.set_value value
|
133
|
-
gv.get_uchar.must_equal value
|
153
|
+
_(gv.get_uchar).must_equal value
|
134
154
|
end
|
135
155
|
|
136
|
-
it
|
156
|
+
it "handles uint values" do
|
137
157
|
value = 0x1234_5678
|
138
158
|
gv = GObject::Value.for_gtype GObject::TYPE_UINT
|
139
159
|
gv.set_value value
|
140
|
-
gv.get_uint.must_equal value
|
160
|
+
_(gv.get_uint).must_equal value
|
141
161
|
end
|
142
162
|
|
143
|
-
it
|
163
|
+
it "handles uint64 values" do
|
144
164
|
value = 0x1234_5678_9012_3456
|
145
165
|
gv = GObject::Value.for_gtype GObject::TYPE_UINT64
|
146
166
|
gv.set_value value
|
147
|
-
gv.get_uint64.must_equal value
|
167
|
+
_(gv.get_uint64).must_equal value
|
148
168
|
end
|
149
169
|
|
150
|
-
it
|
170
|
+
it "handles ulong values" do
|
151
171
|
value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678
|
152
172
|
gv = GObject::Value.for_gtype GObject::TYPE_ULONG
|
153
173
|
gv.set_value value
|
154
|
-
gv.get_ulong.must_equal value
|
174
|
+
_(gv.get_ulong).must_equal value
|
155
175
|
end
|
156
176
|
|
157
|
-
it
|
158
|
-
value = GLib::Variant.new_string(
|
177
|
+
it "handles variant values" do
|
178
|
+
value = GLib::Variant.new_string("Foo")
|
159
179
|
gv = GObject::Value.for_gtype GObject::TYPE_VARIANT
|
160
180
|
gv.set_value value
|
161
|
-
gv.get_variant.must_equal value
|
181
|
+
_(gv.get_variant).must_equal value
|
162
182
|
end
|
163
183
|
|
164
|
-
it
|
184
|
+
it "handles object values" do
|
165
185
|
value = GObject::Object.new({})
|
166
186
|
gv = GObject::Value.for_gtype GObject::Object.gtype
|
167
187
|
gv.set_value value
|
168
|
-
gv.get_object.must_equal value
|
188
|
+
_(gv.get_object).must_equal value
|
169
189
|
end
|
170
190
|
|
171
|
-
it
|
172
|
-
value = Gio.file_new_for_path(
|
191
|
+
it "handles interface values" do
|
192
|
+
value = Gio.file_new_for_path("/")
|
173
193
|
gv = GObject::Value.for_gtype Gio::File.gtype
|
174
194
|
gv.set_value value
|
175
|
-
gv.get_object.must_equal value
|
195
|
+
_(gv.get_object).must_equal value
|
176
196
|
end
|
177
197
|
end
|
178
198
|
|
179
|
-
describe
|
180
|
-
it
|
199
|
+
describe "#get_value" do
|
200
|
+
it "unwraps a boolean false" do
|
181
201
|
gv = GObject::Value.wrap_ruby_value false
|
182
202
|
result = gv.get_value
|
183
|
-
result.must_equal false
|
203
|
+
_(result).must_equal false
|
184
204
|
end
|
185
205
|
|
186
|
-
it
|
206
|
+
it "unwraps a boolean true" do
|
187
207
|
gv = GObject::Value.wrap_ruby_value true
|
188
208
|
result = gv.get_value
|
189
|
-
result.must_equal true
|
209
|
+
_(result).must_equal true
|
190
210
|
end
|
191
211
|
|
192
|
-
it
|
212
|
+
it "unwraps a signed char" do
|
193
213
|
value = -42
|
194
214
|
gv = GObject::Value.for_gtype GObject::TYPE_CHAR
|
195
215
|
gv.set_schar value
|
196
|
-
gv.get_value.must_equal value
|
216
|
+
_(gv.get_value).must_equal value
|
197
217
|
end
|
198
218
|
|
199
|
-
it
|
219
|
+
it "unwraps an unsigned char" do
|
200
220
|
value = 173
|
201
221
|
gv = GObject::Value.for_gtype GObject::TYPE_UCHAR
|
202
222
|
gv.set_uchar value
|
203
|
-
gv.get_value.must_equal value
|
223
|
+
_(gv.get_value).must_equal value
|
204
224
|
end
|
205
225
|
|
206
|
-
it
|
226
|
+
it "unwraps an enum value" do
|
207
227
|
value = :value2
|
208
228
|
gv = GObject::Value.for_gtype Regress::TestEnum.gtype
|
209
229
|
gv.set_enum Regress::TestEnum[value]
|
210
|
-
gv.get_value.must_equal value
|
230
|
+
_(gv.get_value).must_equal value
|
211
231
|
end
|
212
232
|
|
213
|
-
it
|
214
|
-
value =
|
233
|
+
it "unwraps a flags value" do
|
234
|
+
value = { flag1: true, flag3: true }
|
215
235
|
gv = GObject::Value.for_gtype Regress::TestFlags.gtype
|
216
|
-
gv.set_flags value
|
217
|
-
gv.get_value.must_equal value
|
236
|
+
gv.set_flags Regress::TestFlags.to_native(value, nil)
|
237
|
+
_(gv.get_value).must_equal value
|
218
238
|
end
|
219
239
|
|
220
|
-
it
|
240
|
+
it "unwraps a GType" do
|
221
241
|
value = GObject::TYPE_STRING
|
222
242
|
gv = GObject::Value.for_gtype GObject::TYPE_GTYPE
|
223
243
|
gv.set_gtype value
|
224
|
-
gv.get_value.must_equal value
|
244
|
+
_(gv.get_value).must_equal value
|
225
245
|
end
|
226
246
|
|
227
|
-
it
|
247
|
+
it "unwraps an int64" do
|
228
248
|
value = 0x1234_5678_9012_3456
|
229
249
|
gv = GObject::Value.for_gtype GObject::TYPE_INT64
|
230
250
|
gv.set_int64 value
|
231
|
-
gv.get_value.must_equal value
|
251
|
+
_(gv.get_value).must_equal value
|
232
252
|
end
|
233
253
|
|
234
|
-
it
|
254
|
+
it "unwraps a long" do
|
235
255
|
value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678
|
236
256
|
gv = GObject::Value.for_gtype GObject::TYPE_LONG
|
237
257
|
gv.set_long value
|
238
|
-
gv.get_value.must_equal value
|
258
|
+
_(gv.get_value).must_equal value
|
239
259
|
end
|
240
260
|
|
241
|
-
it
|
261
|
+
it "unwraps an uchar" do
|
242
262
|
value = 3
|
243
263
|
gv = GObject::Value.for_gtype GObject::TYPE_UCHAR
|
244
264
|
gv.set_uchar value
|
245
|
-
gv.get_value.must_equal value
|
265
|
+
_(gv.get_value).must_equal value
|
246
266
|
end
|
247
267
|
|
248
|
-
it
|
268
|
+
it "unwraps an uint" do
|
249
269
|
value = 0x1234_5678
|
250
270
|
gv = GObject::Value.for_gtype GObject::TYPE_UINT
|
251
271
|
gv.set_uint value
|
252
|
-
gv.get_value.must_equal value
|
272
|
+
_(gv.get_value).must_equal value
|
253
273
|
end
|
254
274
|
|
255
|
-
it
|
275
|
+
it "unwraps an uint64" do
|
256
276
|
value = 0x1234_5678_9012_3456
|
257
277
|
gv = GObject::Value.for_gtype GObject::TYPE_UINT64
|
258
278
|
gv.set_uint64 value
|
259
|
-
gv.get_value.must_equal value
|
279
|
+
_(gv.get_value).must_equal value
|
260
280
|
end
|
261
281
|
|
262
|
-
it
|
282
|
+
it "unwraps an ulong" do
|
263
283
|
value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678
|
264
284
|
gv = GObject::Value.for_gtype GObject::TYPE_ULONG
|
265
285
|
gv.set_ulong value
|
266
|
-
gv.get_value.must_equal value
|
286
|
+
_(gv.get_value).must_equal value
|
267
287
|
end
|
268
288
|
|
269
|
-
it
|
270
|
-
value = GLib::Variant.new_string(
|
289
|
+
it "unwraps a variant" do
|
290
|
+
value = GLib::Variant.new_string("Foo")
|
271
291
|
gv = GObject::Value.for_gtype GObject::TYPE_VARIANT
|
272
292
|
gv.set_variant value
|
273
|
-
gv.get_value.must_equal value
|
293
|
+
_(gv.get_value).must_equal value
|
274
294
|
end
|
275
295
|
|
276
|
-
it
|
277
|
-
ba = GLib::ByteArray.new.append(
|
296
|
+
it "works with a ByteArray" do
|
297
|
+
ba = GLib::ByteArray.new.append("some bytes")
|
278
298
|
v = GObject::Value.for_gtype GObject::TYPE_BYTE_ARRAY
|
279
299
|
v.set_boxed ba
|
280
300
|
|
281
301
|
result = v.get_value
|
282
302
|
|
283
|
-
result.to_string.must_equal
|
284
|
-
result.must_be_kind_of GLib::ByteArray
|
303
|
+
_(result.to_string).must_equal "some bytes"
|
304
|
+
_(result).must_be_kind_of GLib::ByteArray
|
285
305
|
end
|
286
306
|
|
287
|
-
it
|
307
|
+
it "works with an Array" do
|
288
308
|
arr = GLib::Array.from(:uint, [1, 2, 3])
|
289
309
|
v = GObject::Value.for_gtype GObject::TYPE_ARRAY
|
290
310
|
v.set_boxed arr
|
291
311
|
|
292
312
|
result = v.get_value
|
293
313
|
|
294
|
-
result.must_be_kind_of GLib::Array
|
295
|
-
result.reset_typespec(:uint).to_a.must_equal [1, 2, 3]
|
314
|
+
_(result).must_be_kind_of GLib::Array
|
315
|
+
_(result.reset_typespec(:uint).to_a).must_equal [1, 2, 3]
|
296
316
|
end
|
297
317
|
|
298
|
-
it
|
318
|
+
it "unwraps a Strv" do
|
299
319
|
strv = GLib::Strv.from %w(foo bar)
|
300
320
|
val = GObject::Value.for_gtype GObject::TYPE_STRV
|
301
321
|
val.set_boxed strv
|
302
322
|
|
303
323
|
result = val.get_value
|
304
324
|
|
305
|
-
result.must_be_kind_of GLib::Strv
|
306
|
-
result.to_a.must_equal %w(foo bar)
|
325
|
+
_(result).must_be_kind_of GLib::Strv
|
326
|
+
_(result.to_a).must_equal %w(foo bar)
|
307
327
|
end
|
308
328
|
end
|
309
329
|
|
310
|
-
describe
|
311
|
-
it
|
330
|
+
describe "::from" do
|
331
|
+
it "creates a gint GValue from a Ruby Integer" do
|
312
332
|
gv = GObject::Value.from 21
|
313
|
-
gv.current_gtype_name.must_equal
|
314
|
-
gv.get_value.must_equal 21
|
333
|
+
_(gv.current_gtype_name).must_equal "gint"
|
334
|
+
_(gv.get_value).must_equal 21
|
315
335
|
end
|
316
336
|
|
317
|
-
it
|
337
|
+
it "returns its argument if given a GValue" do
|
318
338
|
gv = GObject::Value.from 21
|
319
339
|
gv2 = GObject::Value.from gv
|
320
|
-
gv2.current_gtype_name.must_equal
|
321
|
-
gv2.get_value.must_equal 21
|
340
|
+
_(gv2.current_gtype_name).must_equal "gint"
|
341
|
+
_(gv2.get_value).must_equal 21
|
322
342
|
end
|
323
343
|
|
324
|
-
it
|
344
|
+
it "creates a null GValue from a Ruby nil" do
|
325
345
|
gv = GObject::Value.from nil
|
326
|
-
gv.current_gtype.must_equal GObject::TYPE_INVALID
|
327
|
-
gv.get_value.must_be_nil
|
346
|
+
_(gv.current_gtype).must_equal GObject::TYPE_INVALID
|
347
|
+
_(gv.get_value).must_be_nil
|
328
348
|
end
|
329
349
|
end
|
330
350
|
|
331
|
-
describe
|
351
|
+
describe "#set_value" do
|
332
352
|
before do
|
333
353
|
GirFFI.setup :GIMarshallingTests
|
334
354
|
end
|
335
355
|
|
336
|
-
it
|
356
|
+
it "raises an error when setting an incompatible object type" do
|
337
357
|
o = GIMarshallingTests::Object.new 1
|
338
358
|
v = GObject::Value.new.init(GIMarshallingTests::OverridesObject.gtype)
|
339
|
-
proc { v.set_value o }.must_raise ArgumentError
|
359
|
+
_(proc { v.set_value o }).must_raise ArgumentError
|
340
360
|
end
|
341
361
|
|
342
|
-
it
|
343
|
-
ba = GLib::ByteArray.new.append(
|
344
|
-
v = GObject::Value.new.init(GObject.type_from_name(
|
362
|
+
it "works with a ByteArray" do
|
363
|
+
ba = GLib::ByteArray.new.append("some bytes")
|
364
|
+
v = GObject::Value.new.init(GObject.type_from_name("GByteArray"))
|
345
365
|
v.set_value ba
|
346
|
-
v.get_value.to_string.must_equal
|
366
|
+
_(v.get_value.to_string).must_equal "some bytes"
|
347
367
|
end
|
348
368
|
end
|
349
369
|
|
350
|
-
describe
|
351
|
-
it
|
352
|
-
skip
|
370
|
+
describe "upon garbage collection" do
|
371
|
+
it "restores the underlying GValue to its pristine state" do
|
372
|
+
skip "cannot be reliably tested on JRuby and Rubinius" if jruby? || rubinius?
|
353
373
|
|
354
374
|
value = GObject::Value.from 42
|
355
375
|
|
356
376
|
# Drop reference to original GObject::Value
|
357
377
|
value = GObject::Value.wrap value.to_ptr
|
358
|
-
value.current_gtype_name.must_equal
|
378
|
+
_(value.current_gtype_name).must_equal "gint"
|
359
379
|
|
360
380
|
GC.start
|
361
381
|
# Creating a new object is sometimes needed to trigger enough garbage collection.
|
@@ -364,7 +384,7 @@ describe GObject::Value do
|
|
364
384
|
GC.start
|
365
385
|
GC.start
|
366
386
|
|
367
|
-
value.current_gtype_name.wont_equal
|
387
|
+
_(value.current_gtype_name).wont_equal "gint"
|
368
388
|
end
|
369
389
|
end
|
370
390
|
end
|