gir_ffi 0.15.1 → 0.15.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +42 -0
- data/README.md +10 -10
- data/TODO.md +14 -35
- data/docs/Documentation.md +6 -0
- data/docs/Subclassing.md +38 -0
- data/lib/ffi-glib.rb +8 -3
- data/lib/ffi-glib/byte_array.rb +2 -1
- data/lib/ffi-glib/container_class_methods.rb +1 -3
- data/lib/ffi-glib/destroy_notify.rb +2 -2
- data/lib/ffi-glib/hash_table.rb +1 -2
- data/lib/ffi-glib/list.rb +11 -5
- data/lib/ffi-glib/list_methods.rb +12 -0
- data/lib/ffi-glib/s_list.rb +10 -4
- data/lib/ffi-gobject.rb +2 -5
- data/lib/ffi-gobject/object.rb +102 -92
- data/lib/ffi-gobject/object_class.rb +1 -1
- data/lib/ffi-gobject/ruby_closure.rb +1 -1
- data/lib/ffi-gobject/value.rb +108 -117
- data/lib/ffi-gobject_introspection/i_base_info.rb +35 -27
- data/lib/ffi-gobject_introspection/lib.rb +1 -1
- data/lib/gir_ffi-base/gobject/lib.rb +4 -0
- data/lib/gir_ffi/array_element_convertor.rb +2 -3
- data/lib/gir_ffi/boxed_base.rb +13 -11
- data/lib/gir_ffi/builder.rb +3 -4
- data/lib/gir_ffi/builder_helper.rb +10 -2
- data/lib/gir_ffi/builders/base_argument_builder.rb +2 -2
- data/lib/gir_ffi/builders/base_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
- data/lib/gir_ffi/builders/callback_argument_builder.rb +2 -0
- data/lib/gir_ffi/builders/callback_builder.rb +25 -11
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +4 -6
- data/lib/gir_ffi/builders/enum_builder.rb +9 -5
- data/lib/gir_ffi/builders/field_builder.rb +2 -1
- data/lib/gir_ffi/builders/function_builder.rb +1 -1
- data/lib/gir_ffi/builders/interface_builder.rb +3 -1
- data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +5 -2
- data/lib/gir_ffi/builders/method_template.rb +4 -4
- data/lib/gir_ffi/builders/module_builder.rb +4 -2
- data/lib/gir_ffi/builders/null_argument_builder.rb +0 -2
- data/lib/gir_ffi/builders/null_return_value_builder.rb +0 -2
- data/lib/gir_ffi/builders/object_builder.rb +18 -6
- data/lib/gir_ffi/builders/property_builder.rb +1 -2
- data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -5
- data/lib/gir_ffi/builders/struct_builder.rb +34 -7
- data/lib/gir_ffi/builders/user_defined_builder.rb +8 -1
- data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
- data/lib/gir_ffi/callback_base.rb +7 -8
- data/lib/gir_ffi/class_base.rb +1 -0
- data/lib/gir_ffi/core.rb +17 -2
- data/lib/gir_ffi/glib_error.rb +1 -2
- data/lib/gir_ffi/in_pointer.rb +7 -0
- data/lib/gir_ffi/object_base.rb +27 -0
- data/lib/gir_ffi/return_value_info.rb +1 -2
- data/lib/gir_ffi/struct_base.rb +1 -9
- data/lib/gir_ffi/struct_like_base.rb +9 -5
- data/lib/gir_ffi/type_map.rb +1 -0
- data/lib/gir_ffi/unintrospectable_type_info.rb +1 -1
- data/lib/gir_ffi/union_base.rb +1 -9
- data/lib/gir_ffi/user_defined_object_info.rb +3 -2
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi/vfunc_implementation.rb +1 -0
- metadata +106 -143
- data/Gemfile +0 -14
- data/Rakefile +0 -9
- data/tasks/test.rake +0 -204
- data/test/base_test_helper.rb +0 -70
- data/test/ffi-glib/array_test.rb +0 -203
- data/test/ffi-glib/byte_array_test.rb +0 -28
- data/test/ffi-glib/bytes_test.rb +0 -61
- data/test/ffi-glib/closure_test.rb +0 -38
- data/test/ffi-glib/destroy_notify_test.rb +0 -18
- data/test/ffi-glib/hash_table_test.rb +0 -68
- data/test/ffi-glib/list_test.rb +0 -86
- data/test/ffi-glib/main_loop_test.rb +0 -53
- data/test/ffi-glib/ptr_array_test.rb +0 -112
- data/test/ffi-glib/ruby_closure_test.rb +0 -62
- data/test/ffi-glib/s_list_test.rb +0 -76
- data/test/ffi-glib/strv_test.rb +0 -60
- data/test/ffi-glib/variant_test.rb +0 -12
- data/test/ffi-gobject/gobject_test.rb +0 -76
- data/test/ffi-gobject/object_class_test.rb +0 -31
- data/test/ffi-gobject/object_test.rb +0 -122
- data/test/ffi-gobject/param_spec_test.rb +0 -32
- data/test/ffi-gobject/value_test.rb +0 -390
- data/test/ffi-gobject_introspection/gobject_type_init_test.rb +0 -26
- data/test/ffi-gobject_introspection/i_base_info_test.rb +0 -52
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +0 -29
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +0 -18
- data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -6
- data/test/ffi-gobject_introspection/i_interface_info_test.rb +0 -23
- data/test/ffi-gobject_introspection/i_object_info_test.rb +0 -49
- data/test/ffi-gobject_introspection/i_property_info_test.rb +0 -47
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +0 -27
- data/test/ffi-gobject_introspection/i_repository_test.rb +0 -81
- data/test/ffi-gobject_introspection/i_struct_info_test.rb +0 -23
- data/test/ffi-gobject_introspection/i_type_info_test.rb +0 -30
- data/test/ffi-gobject_introspection/i_union_info_test.rb +0 -17
- data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +0 -41
- data/test/ffi-gobject_introspection/lib_test.rb +0 -13
- data/test/ffi-gobject_introspection/strv_test.rb +0 -46
- data/test/ffi-gobject_test.rb +0 -151
- data/test/gir_ffi/allocation_helper_test.rb +0 -36
- data/test/gir_ffi/arg_helper_test.rb +0 -139
- data/test/gir_ffi/boolean_test.rb +0 -43
- data/test/gir_ffi/boxed_base_test.rb +0 -65
- data/test/gir_ffi/builder_test.rb +0 -322
- data/test/gir_ffi/builders/argument_builder_test.rb +0 -651
- data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -6
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +0 -126
- data/test/gir_ffi/builders/callback_builder_test.rb +0 -117
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +0 -81
- data/test/gir_ffi/builders/constant_builder_test.rb +0 -6
- data/test/gir_ffi/builders/constructor_builder_test.rb +0 -37
- data/test/gir_ffi/builders/enum_builder_test.rb +0 -23
- data/test/gir_ffi/builders/field_builder_test.rb +0 -134
- data/test/gir_ffi/builders/function_builder_test.rb +0 -550
- data/test/gir_ffi/builders/initializer_builder_test.rb +0 -54
- data/test/gir_ffi/builders/interface_builder_test.rb +0 -32
- data/test/gir_ffi/builders/module_builder_test.rb +0 -43
- data/test/gir_ffi/builders/object_builder_test.rb +0 -98
- data/test/gir_ffi/builders/property_builder_test.rb +0 -158
- data/test/gir_ffi/builders/registered_type_builder_test.rb +0 -54
- data/test/gir_ffi/builders/return_value_builder_test.rb +0 -433
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +0 -197
- data/test/gir_ffi/builders/struct_builder_test.rb +0 -93
- data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +0 -29
- data/test/gir_ffi/builders/unintrospectable_builder_test.rb +0 -84
- data/test/gir_ffi/builders/union_builder_test.rb +0 -28
- data/test/gir_ffi/builders/user_defined_builder_test.rb +0 -524
- data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +0 -101
- data/test/gir_ffi/builders/vfunc_builder_test.rb +0 -241
- data/test/gir_ffi/callback_base_test.rb +0 -22
- data/test/gir_ffi/class_base_test.rb +0 -166
- data/test/gir_ffi/core_test.rb +0 -98
- data/test/gir_ffi/enum_base_test.rb +0 -43
- data/test/gir_ffi/error_type_info_test.rb +0 -50
- data/test/gir_ffi/ffi_ext/pointer_test.rb +0 -20
- data/test/gir_ffi/g_type_test.rb +0 -31
- data/test/gir_ffi/in_pointer_test.rb +0 -203
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +0 -26
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +0 -21
- data/test/gir_ffi/info_ext/i_field_info_test.rb +0 -37
- data/test/gir_ffi/info_ext/i_function_info_test.rb +0 -74
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +0 -32
- data/test/gir_ffi/info_ext/i_type_info_test.rb +0 -711
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +0 -19
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +0 -26
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +0 -26
- data/test/gir_ffi/interface_base_test.rb +0 -20
- data/test/gir_ffi/method_stubber_test.rb +0 -65
- data/test/gir_ffi/object_base_test.rb +0 -64
- data/test/gir_ffi/object_store_test.rb +0 -41
- data/test/gir_ffi/receiver_argument_info_test.rb +0 -33
- data/test/gir_ffi/sized_array_test.rb +0 -206
- data/test/gir_ffi/struct_base_test.rb +0 -23
- data/test/gir_ffi/struct_like_base_test.rb +0 -167
- data/test/gir_ffi/type_map_test.rb +0 -17
- data/test/gir_ffi/unintrospectable_type_info_test.rb +0 -121
- data/test/gir_ffi/union_base_test.rb +0 -23
- data/test/gir_ffi/user_defined_object_info_test.rb +0 -119
- data/test/gir_ffi/user_defined_property_info_test.rb +0 -39
- data/test/gir_ffi/variable_name_generator_test.rb +0 -18
- data/test/gir_ffi/version_test.rb +0 -9
- data/test/gir_ffi/zero_terminated_test.rb +0 -108
- data/test/gir_ffi_test_helper.rb +0 -84
- data/test/integration/callback_exceptions_test.rb +0 -59
- data/test/integration/derived_classes_test.rb +0 -53
- data/test/integration/generated_everything_test.rb +0 -452
- data/test/integration/generated_gimarshallingtests_test.rb +0 -3096
- data/test/integration/generated_gio_test.rb +0 -116
- data/test/integration/generated_glib_test.rb +0 -10
- data/test/integration/generated_gobject_test.rb +0 -124
- data/test/integration/generated_gst_test.rb +0 -38
- data/test/integration/generated_gtk_source_test.rb +0 -32
- data/test/integration/generated_gtop_test.rb +0 -22
- data/test/integration/generated_pango_ft2_test.rb +0 -17
- data/test/integration/generated_pango_test.rb +0 -24
- data/test/integration/generated_regress_test.rb +0 -4038
- data/test/integration/generated_secret_test.rb +0 -14
- data/test/integration/generated_utility_test.rb +0 -174
- data/test/integration/generated_warnlib_test.rb +0 -43
- data/test/integration/method_lookup_test.rb +0 -34
- data/test/introspection_test_helper.rb +0 -93
- data/test/lib/Makefile.am +0 -110
- data/test/lib/autogen.sh +0 -4
- data/test/lib/configure.ac +0 -34
- data/test/lib/m4/jhflags.m4 +0 -21
- data/test/minitest/stats_plugin.rb +0 -30
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
describe GirFFI::InfoExt::ICallableInfo do
|
6
|
-
let(:info_class) do
|
7
|
-
Class.new do
|
8
|
-
include GirFFI::InfoExt::ICallableInfo
|
9
|
-
end
|
10
|
-
end
|
11
|
-
let(:callable_info) { info_class.new }
|
12
|
-
|
13
|
-
describe "#argument_ffi_types" do
|
14
|
-
describe "for a simple callable with several arguments" do
|
15
|
-
before do
|
16
|
-
allow(arg_info1 = Object.new).to receive(:to_ffi_type).and_return :type1
|
17
|
-
allow(arg_info2 = Object.new).to receive(:to_ffi_type).and_return :type2
|
18
|
-
allow(callable_info).to receive(:args).and_return [arg_info1, arg_info2]
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns the ffi types of the arguments" do
|
22
|
-
_(callable_info.argument_ffi_types).must_equal [:type1, :type2]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
describe GirFFI::InfoExt::ICallbackInfo do
|
6
|
-
let(:callback_class) do
|
7
|
-
Class.new do
|
8
|
-
include GirFFI::InfoExt::ICallbackInfo
|
9
|
-
end
|
10
|
-
end
|
11
|
-
let(:callback_info) { callback_class.new }
|
12
|
-
|
13
|
-
describe "#return_ffi_type" do
|
14
|
-
it "returns the callback ffi type of the return type" do
|
15
|
-
allow(return_type_info = Object.new).to receive(:to_callback_ffi_type).and_return :some_type
|
16
|
-
allow(callback_info).to receive(:return_type).and_return return_type_info
|
17
|
-
|
18
|
-
_(callback_info.return_ffi_type).must_equal :some_type
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
describe GirFFI::InfoExt::IFieldInfo do
|
6
|
-
let(:info_class) do
|
7
|
-
Class.new do
|
8
|
-
include GirFFI::InfoExt::IFieldInfo
|
9
|
-
end
|
10
|
-
end
|
11
|
-
let(:field_info) { info_class.new }
|
12
|
-
describe "#layout_specification" do
|
13
|
-
it "returns an array of name, typespec and offset" do
|
14
|
-
expect(type = Object.new).to receive(:to_ffi_type).and_return :bar
|
15
|
-
|
16
|
-
expect(field_info).to receive(:name).and_return "foo"
|
17
|
-
expect(field_info).to receive(:field_type).and_return type
|
18
|
-
expect(field_info).to receive(:offset).and_return 0
|
19
|
-
|
20
|
-
result = field_info.layout_specification
|
21
|
-
|
22
|
-
assert_equal [:foo, :bar, 0], result
|
23
|
-
end
|
24
|
-
|
25
|
-
it "keeps a complex typespec intact" do
|
26
|
-
expect(type = Object.new).to receive(:to_ffi_type).and_return [:bar, 2]
|
27
|
-
|
28
|
-
expect(field_info).to receive(:name).and_return "foo"
|
29
|
-
expect(field_info).to receive(:field_type).and_return type
|
30
|
-
expect(field_info).to receive(:offset).and_return 0
|
31
|
-
|
32
|
-
result = field_info.layout_specification
|
33
|
-
|
34
|
-
assert_equal [:foo, [:bar, 2], 0], result
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
describe GirFFI::InfoExt::IFunctionInfo do
|
6
|
-
let(:info_class) do
|
7
|
-
Class.new do
|
8
|
-
include GirFFI::InfoExt::ICallableInfo
|
9
|
-
include GirFFI::InfoExt::IFunctionInfo
|
10
|
-
end
|
11
|
-
end
|
12
|
-
let(:function_info) { info_class.new }
|
13
|
-
|
14
|
-
describe "#argument_ffi_types" do
|
15
|
-
before do
|
16
|
-
allow(arg_info1 = Object.new).to receive(:to_ffi_type).and_return :type1
|
17
|
-
allow(arg_info2 = Object.new).to receive(:to_ffi_type).and_return :type2
|
18
|
-
allow(function_info).to receive(:args).and_return [arg_info1, arg_info2]
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "for a simple function with several arguments" do
|
22
|
-
before do
|
23
|
-
allow(function_info).to receive(:method?).and_return false
|
24
|
-
allow(function_info).to receive(:throws?).and_return false
|
25
|
-
end
|
26
|
-
|
27
|
-
it "returns the ffi types of the arguments" do
|
28
|
-
_(function_info.argument_ffi_types).must_equal [:type1, :type2]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "for a throwing function with several arguments" do
|
33
|
-
before do
|
34
|
-
allow(function_info).to receive(:method?).and_return false
|
35
|
-
allow(function_info).to receive(:throws?).and_return true
|
36
|
-
end
|
37
|
-
|
38
|
-
it "appends :pointer to represent the error argument" do
|
39
|
-
_(function_info.argument_ffi_types).must_equal [:type1, :type2, :pointer]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "for a method with several arguments" do
|
44
|
-
before do
|
45
|
-
allow(function_info).to receive(:method?).and_return true
|
46
|
-
allow(function_info).to receive(:throws?).and_return false
|
47
|
-
end
|
48
|
-
|
49
|
-
it "prepends :pointer to represent the method reciever" do
|
50
|
-
_(function_info.argument_ffi_types).must_equal [:pointer, :type1, :type2]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "for a throwing method with several arguments" do
|
55
|
-
before do
|
56
|
-
allow(function_info).to receive(:method?).and_return true
|
57
|
-
allow(function_info).to receive(:throws?).and_return true
|
58
|
-
end
|
59
|
-
|
60
|
-
it "adds :pointer for both the reciever and the error argument" do
|
61
|
-
_(function_info.argument_ffi_types).must_equal [:pointer, :type1, :type2, :pointer]
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "#return_ffi_type" do
|
67
|
-
it "returns the ffi type of the return type" do
|
68
|
-
allow(return_type_info = Object.new).to receive(:to_ffi_type).and_return :some_type
|
69
|
-
allow(function_info).to receive(:return_type).and_return return_type_info
|
70
|
-
|
71
|
-
_(function_info.return_ffi_type).must_equal :some_type
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
GirFFI.setup :Regress
|
6
|
-
|
7
|
-
describe GirFFI::InfoExt::ISignalInfo do
|
8
|
-
let(:signal_class) do
|
9
|
-
Class.new do
|
10
|
-
include GirFFI::InfoExt::ICallableInfo
|
11
|
-
include GirFFI::InfoExt::ISignalInfo
|
12
|
-
end
|
13
|
-
end
|
14
|
-
let(:signal_info) { signal_class.new }
|
15
|
-
|
16
|
-
describe "#arguments_to_gvalues" do
|
17
|
-
let(:object) { Regress::TestSubObj.new }
|
18
|
-
let(:boxed) { Regress::TestSimpleBoxedA.const_return }
|
19
|
-
let(:signal_info) { Regress::TestSubObj.find_signal "test-with-static-scope-arg" }
|
20
|
-
let(:result) { signal_info.arguments_to_gvalues(object, [boxed]) }
|
21
|
-
|
22
|
-
it "correctly wraps :object" do
|
23
|
-
_(result[0].get_value).must_equal object
|
24
|
-
end
|
25
|
-
|
26
|
-
it "correctly wraps :struct" do
|
27
|
-
result_boxed = result[1].get_value
|
28
|
-
_(result_boxed.some_int8).must_equal boxed.some_int8
|
29
|
-
_(result_boxed.some_int).must_equal boxed.some_int
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,711 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
describe GirFFI::InfoExt::ITypeInfo do
|
6
|
-
let(:info_class) do
|
7
|
-
Class.new do
|
8
|
-
include GirFFI::InfoExt::ITypeInfo
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:type_info) { info_class.new }
|
13
|
-
let(:elmtype_info) { info_class.new }
|
14
|
-
let(:keytype_info) { info_class.new }
|
15
|
-
let(:valtype_info) { info_class.new }
|
16
|
-
let(:iface_info) { Object.new }
|
17
|
-
|
18
|
-
let(:callback_type_info) do
|
19
|
-
get_introspection_data("Regress", "test_callback").args[0].argument_type
|
20
|
-
end
|
21
|
-
let(:ghash_type_info) do
|
22
|
-
get_introspection_data("Regress",
|
23
|
-
"test_ghash_nested_everything_return").return_type
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#to_ffi_type" do
|
27
|
-
it "returns an array with elements subtype and size for type :array" do
|
28
|
-
expect(type_info).to receive(:pointer?).and_return false
|
29
|
-
allow(type_info).to receive(:tag).and_return :array
|
30
|
-
expect(type_info).to receive(:array_fixed_size).and_return 2
|
31
|
-
|
32
|
-
expect(elmtype_info).to receive(:to_ffi_type).and_return :foo
|
33
|
-
expect(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
34
|
-
|
35
|
-
result = type_info.to_ffi_type
|
36
|
-
assert_equal [:foo, 2], result
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "for an :interface type" do
|
40
|
-
before do
|
41
|
-
allow(type_info).to receive(:interface).and_return iface_info
|
42
|
-
allow(type_info).to receive(:tag).and_return :interface
|
43
|
-
allow(type_info).to receive(:pointer?).and_return false
|
44
|
-
end
|
45
|
-
|
46
|
-
it "maps a the interface's ffi_type" do
|
47
|
-
allow(iface_info).to receive(:to_ffi_type).and_return :foo
|
48
|
-
|
49
|
-
_(type_info.to_ffi_type).must_equal :foo
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "#element_type" do
|
55
|
-
it "returns the element type for lists" do
|
56
|
-
allow(elmtype_info).to receive(:tag).and_return :foo
|
57
|
-
expect(elmtype_info).to receive(:pointer?).and_return false
|
58
|
-
|
59
|
-
expect(type_info).to receive(:tag).and_return :glist
|
60
|
-
expect(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
61
|
-
|
62
|
-
result = type_info.element_type
|
63
|
-
_(result).must_equal :foo
|
64
|
-
end
|
65
|
-
|
66
|
-
it "returns the key and value types for ghashes" do
|
67
|
-
allow(keytype_info).to receive(:tag).and_return :foo
|
68
|
-
expect(keytype_info).to receive(:pointer?).and_return false
|
69
|
-
allow(valtype_info).to receive(:tag).and_return :bar
|
70
|
-
expect(valtype_info).to receive(:pointer?).and_return false
|
71
|
-
|
72
|
-
expect(type_info).to receive(:tag).and_return :ghash
|
73
|
-
expect(type_info).to receive(:param_type).with(0).and_return keytype_info
|
74
|
-
expect(type_info).to receive(:param_type).with(1).and_return valtype_info
|
75
|
-
|
76
|
-
result = type_info.element_type
|
77
|
-
_(result).must_equal [:foo, :bar]
|
78
|
-
end
|
79
|
-
|
80
|
-
it "returns nil for other types" do
|
81
|
-
expect(type_info).to receive(:tag).and_return :foo
|
82
|
-
|
83
|
-
result = type_info.element_type
|
84
|
-
_(result).must_be_nil
|
85
|
-
end
|
86
|
-
|
87
|
-
it "returns [:pointer, :void] if the element type is a pointer with tag :void" do
|
88
|
-
allow(elmtype_info).to receive(:tag_or_class).and_return [:pointer, :void]
|
89
|
-
|
90
|
-
expect(type_info).to receive(:tag).and_return :glist
|
91
|
-
expect(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
92
|
-
|
93
|
-
assert_equal [:pointer, :void], type_info.element_type
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "#flattened_tag" do
|
98
|
-
describe "for a simple type" do
|
99
|
-
it "returns the type tag" do
|
100
|
-
allow(type_info).to receive(:tag).and_return :uint32
|
101
|
-
|
102
|
-
_(type_info.flattened_tag).must_equal :uint32
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "for a zero-terminated array" do
|
107
|
-
before do
|
108
|
-
allow(type_info).to receive(:tag).and_return :array
|
109
|
-
allow(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
110
|
-
allow(type_info).to receive(:zero_terminated?).and_return true
|
111
|
-
end
|
112
|
-
|
113
|
-
describe "of utf8" do
|
114
|
-
it "returns :strv" do
|
115
|
-
allow(elmtype_info).to receive(:tag).and_return :utf8
|
116
|
-
allow(elmtype_info).to receive(:pointer?).and_return true
|
117
|
-
|
118
|
-
_(type_info.flattened_tag).must_equal :strv
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe "of filename" do
|
123
|
-
it "returns :strv" do
|
124
|
-
allow(elmtype_info).to receive(:tag).and_return :filename
|
125
|
-
allow(elmtype_info).to receive(:pointer?).and_return true
|
126
|
-
|
127
|
-
_(type_info.flattened_tag).must_equal :strv
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe "of another type" do
|
132
|
-
it "returns :zero_terminated" do
|
133
|
-
allow(elmtype_info).to receive(:tag).and_return :foo
|
134
|
-
allow(elmtype_info).to receive(:pointer?).and_return false
|
135
|
-
|
136
|
-
_(type_info.flattened_tag).must_equal :zero_terminated
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe "for a fixed length c-like array" do
|
142
|
-
it "returns :c" do
|
143
|
-
expect(type_info).to receive(:tag).and_return :array
|
144
|
-
expect(type_info).to receive(:zero_terminated?).and_return false
|
145
|
-
expect(type_info).to receive(:array_type).and_return :c
|
146
|
-
|
147
|
-
_(type_info.flattened_tag).must_equal :c
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
describe "for a GLib array" do
|
152
|
-
it "returns :c" do
|
153
|
-
expect(type_info).to receive(:tag).and_return :array
|
154
|
-
expect(type_info).to receive(:zero_terminated?).and_return false
|
155
|
-
expect(type_info).to receive(:array_type).and_return :array
|
156
|
-
|
157
|
-
_(type_info.flattened_tag).must_equal :array
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe "#tag_or_class" do
|
163
|
-
describe "for a simple type" do
|
164
|
-
it "returns the type's tag" do
|
165
|
-
allow(type_info).to receive(:tag).and_return :foo
|
166
|
-
expect(type_info).to receive(:pointer?).and_return false
|
167
|
-
|
168
|
-
_(type_info.tag_or_class).must_equal :foo
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
describe "for utf8 strings" do
|
173
|
-
it "returns the tag :utf8" do
|
174
|
-
allow(type_info).to receive(:tag).and_return :utf8
|
175
|
-
expect(type_info).to receive(:pointer?).and_return true
|
176
|
-
|
177
|
-
_(type_info.tag_or_class).must_equal :utf8
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
describe "for filename strings" do
|
182
|
-
it "returns the tag :filename" do
|
183
|
-
allow(type_info).to receive(:tag).and_return :filename
|
184
|
-
expect(type_info).to receive(:pointer?).and_return true
|
185
|
-
|
186
|
-
_(type_info.tag_or_class).must_equal :filename
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
describe "for an interface class" do
|
191
|
-
let(:interface) { Object.new }
|
192
|
-
|
193
|
-
before do
|
194
|
-
allow(type_info).to receive(:tag).and_return :interface
|
195
|
-
allow(type_info).to receive(:interface).and_return iface_info
|
196
|
-
expect(type_info).to receive(:pointer?).and_return false
|
197
|
-
|
198
|
-
expect(GirFFI::Builder).to receive(:build_class).with(iface_info).and_return interface
|
199
|
-
end
|
200
|
-
|
201
|
-
describe "when the interface type is :enum" do
|
202
|
-
it "returns the built interface module" do
|
203
|
-
allow(iface_info).to receive(:info_type).and_return :enum
|
204
|
-
|
205
|
-
_(type_info.tag_or_class).must_equal interface
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
describe "when the interface type is :object" do
|
210
|
-
it "returns the built interface class" do
|
211
|
-
allow(iface_info).to receive(:info_type).and_return :object
|
212
|
-
|
213
|
-
_(type_info.tag_or_class).must_equal interface
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
describe "when the interface type is :struct" do
|
218
|
-
it "returns the built interface class" do
|
219
|
-
allow(iface_info).to receive(:info_type).and_return :struct
|
220
|
-
|
221
|
-
_(type_info.tag_or_class).must_equal interface
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
describe "for a callback" do
|
227
|
-
it "returns the callback's wrapper class" do
|
228
|
-
_(callback_type_info.tag_or_class).must_equal Regress::TestCallback
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
describe "for a pointer to simple type :foo" do
|
233
|
-
it "returns [:pointer, :foo]" do
|
234
|
-
allow(type_info).to receive(:tag).and_return :foo
|
235
|
-
expect(type_info).to receive(:pointer?).and_return true
|
236
|
-
|
237
|
-
_(type_info.tag_or_class).must_equal [:pointer, :foo]
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
describe "for a pointer to :void" do
|
242
|
-
it "returns [:pointer, :void]" do
|
243
|
-
allow(type_info).to receive(:tag).and_return :void
|
244
|
-
allow(type_info).to receive(:pointer?).and_return true
|
245
|
-
|
246
|
-
_(type_info.tag_or_class).must_equal [:pointer, :void]
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
describe "for a complex nested hash type" do
|
251
|
-
it "returns a representeation of the nested structure" do
|
252
|
-
_(ghash_type_info.tag_or_class).must_equal(
|
253
|
-
[:pointer,
|
254
|
-
[:ghash,
|
255
|
-
:utf8,
|
256
|
-
[:pointer,
|
257
|
-
[:ghash, :utf8, :utf8]]]])
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
describe "#to_callback_ffi_type" do
|
263
|
-
describe "for an :interface argument" do
|
264
|
-
before do
|
265
|
-
allow(type_info).to receive(:interface).and_return iface_info
|
266
|
-
allow(type_info).to receive(:tag).and_return :interface
|
267
|
-
allow(type_info).to receive(:pointer?).and_return false
|
268
|
-
end
|
269
|
-
|
270
|
-
it "delegates to interface info" do
|
271
|
-
allow(iface_info).to receive(:to_callback_ffi_type).and_return :some_ffi_type
|
272
|
-
|
273
|
-
_(type_info.to_callback_ffi_type).must_equal :some_ffi_type
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
describe "#extra_conversion_arguments" do
|
279
|
-
describe "for normal types" do
|
280
|
-
before do
|
281
|
-
allow(type_info).to receive(:tag).and_return :foo
|
282
|
-
end
|
283
|
-
|
284
|
-
it "returns an empty array" do
|
285
|
-
_(type_info.extra_conversion_arguments).must_equal []
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
describe "for a fixed-size array" do
|
290
|
-
before do
|
291
|
-
allow(type_info).to receive(:tag).and_return :array
|
292
|
-
allow(type_info).to receive(:zero_terminated?).and_return false
|
293
|
-
allow(type_info).to receive(:array_type).and_return :c
|
294
|
-
allow(type_info).to receive(:array_fixed_size).and_return 3
|
295
|
-
|
296
|
-
allow(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
297
|
-
allow(elmtype_info).to receive(:tag_or_class).and_return :foo
|
298
|
-
end
|
299
|
-
|
300
|
-
it "returns an array containing the element type" do
|
301
|
-
_(type_info.extra_conversion_arguments).must_equal [:foo, 3]
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
describe "for a zero-terminated array" do
|
306
|
-
before do
|
307
|
-
allow(type_info).to receive(:tag).and_return :array
|
308
|
-
allow(type_info).to receive(:zero_terminated?).and_return true
|
309
|
-
|
310
|
-
allow(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
311
|
-
allow(elmtype_info).to receive(:tag_or_class).and_return :foo
|
312
|
-
end
|
313
|
-
|
314
|
-
it "returns an array containing the element type" do
|
315
|
-
_(type_info.extra_conversion_arguments).must_equal [:foo]
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
describe "for a GArray" do
|
320
|
-
before do
|
321
|
-
allow(type_info).to receive(:tag).and_return :array
|
322
|
-
allow(type_info).to receive(:zero_terminated?).and_return false
|
323
|
-
allow(type_info).to receive(:array_type).and_return :array
|
324
|
-
|
325
|
-
allow(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
326
|
-
allow(elmtype_info).to receive(:tag_or_class).and_return :foo
|
327
|
-
end
|
328
|
-
|
329
|
-
it "returns an array containing the element type" do
|
330
|
-
_(type_info.extra_conversion_arguments).must_equal [:foo]
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
|
-
describe "for a GHashTable" do
|
335
|
-
before do
|
336
|
-
allow(type_info).to receive(:tag).and_return :ghash
|
337
|
-
allow(type_info).to receive(:param_type).with(0).and_return keytype_info
|
338
|
-
allow(type_info).to receive(:param_type).with(1).and_return valtype_info
|
339
|
-
|
340
|
-
allow(keytype_info).to receive(:tag_or_class).and_return :foo
|
341
|
-
allow(valtype_info).to receive(:tag_or_class).and_return :bar
|
342
|
-
end
|
343
|
-
|
344
|
-
it "returns an array containing the element type pair" do
|
345
|
-
_(type_info.extra_conversion_arguments).must_equal [[:foo, :bar]]
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
describe "for a GList" do
|
350
|
-
before do
|
351
|
-
allow(type_info).to receive(:tag).and_return :glist
|
352
|
-
|
353
|
-
allow(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
354
|
-
allow(elmtype_info).to receive(:tag_or_class).and_return :foo
|
355
|
-
end
|
356
|
-
|
357
|
-
it "returns an array containing the element type" do
|
358
|
-
_(type_info.extra_conversion_arguments).must_equal [:foo]
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
describe "for a GSList" do
|
363
|
-
before do
|
364
|
-
allow(type_info).to receive(:tag).and_return :gslist
|
365
|
-
|
366
|
-
allow(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
367
|
-
allow(elmtype_info).to receive(:tag_or_class).and_return :foo
|
368
|
-
end
|
369
|
-
|
370
|
-
it "returns an array containing the element type" do
|
371
|
-
_(type_info.extra_conversion_arguments).must_equal [:foo]
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
describe "for a GPtrArray" do
|
376
|
-
before do
|
377
|
-
allow(type_info).to receive(:tag).and_return :array
|
378
|
-
allow(type_info).to receive(:zero_terminated?).and_return false
|
379
|
-
allow(type_info).to receive(:array_type).and_return :ptr_array
|
380
|
-
|
381
|
-
allow(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
382
|
-
allow(elmtype_info).to receive(:tag_or_class).and_return :foo
|
383
|
-
end
|
384
|
-
|
385
|
-
it "returns an array containing the element type" do
|
386
|
-
_(type_info.extra_conversion_arguments).must_equal [:foo]
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
describe "for a :callback" do
|
391
|
-
before do
|
392
|
-
allow(interface_type_info = Object.new).to receive(:namespace).and_return "Bar"
|
393
|
-
allow(interface_type_info).to receive(:name).and_return "Foo"
|
394
|
-
|
395
|
-
allow(type_info).to receive(:tag).and_return :callback
|
396
|
-
allow(type_info).to receive(:interface).and_return interface_type_info
|
397
|
-
end
|
398
|
-
|
399
|
-
it "returns an empty array" do
|
400
|
-
_(type_info.extra_conversion_arguments).must_equal []
|
401
|
-
end
|
402
|
-
end
|
403
|
-
end
|
404
|
-
|
405
|
-
describe "#argument_class_name" do
|
406
|
-
before do
|
407
|
-
allow(type_info).to receive(:tag).and_return tag
|
408
|
-
end
|
409
|
-
|
410
|
-
describe "for :gint32" do
|
411
|
-
let(:tag) { :gint32 }
|
412
|
-
|
413
|
-
it "is nil" do
|
414
|
-
_(type_info.argument_class_name).must_be_nil
|
415
|
-
end
|
416
|
-
end
|
417
|
-
|
418
|
-
describe "for interfaces" do
|
419
|
-
let(:tag) { :interface }
|
420
|
-
|
421
|
-
before do
|
422
|
-
allow(type_info).to receive(:interface).and_return iface_info
|
423
|
-
allow(iface_info).to receive(:info_type).and_return interface_type
|
424
|
-
allow(iface_info).to receive(:full_type_name).and_return "Bar::Foo"
|
425
|
-
end
|
426
|
-
|
427
|
-
describe "for :struct" do
|
428
|
-
let(:interface_type) { :struct }
|
429
|
-
it "equals the struct class name" do
|
430
|
-
_(type_info.argument_class_name).must_equal "Bar::Foo"
|
431
|
-
end
|
432
|
-
end
|
433
|
-
|
434
|
-
describe "for :union" do
|
435
|
-
let(:interface_type) { :union }
|
436
|
-
it "equals the union class name" do
|
437
|
-
_(type_info.argument_class_name).must_equal "Bar::Foo"
|
438
|
-
end
|
439
|
-
end
|
440
|
-
|
441
|
-
describe "for :interface" do
|
442
|
-
let(:interface_type) { :interface }
|
443
|
-
|
444
|
-
it "equals the interface module name" do
|
445
|
-
_(type_info.argument_class_name).must_equal "Bar::Foo"
|
446
|
-
end
|
447
|
-
end
|
448
|
-
|
449
|
-
describe "for :object" do
|
450
|
-
let(:interface_type) { :object }
|
451
|
-
|
452
|
-
it "equals the object class name" do
|
453
|
-
_(type_info.argument_class_name).must_equal "Bar::Foo"
|
454
|
-
end
|
455
|
-
end
|
456
|
-
|
457
|
-
describe "for :callback" do
|
458
|
-
let(:interface_type) { :callback }
|
459
|
-
|
460
|
-
it "equals the callback type name" do
|
461
|
-
_(type_info.argument_class_name).must_equal "Bar::Foo"
|
462
|
-
end
|
463
|
-
end
|
464
|
-
end
|
465
|
-
|
466
|
-
describe "for :strv" do
|
467
|
-
let(:tag) { :strv }
|
468
|
-
|
469
|
-
it "equals GLib::Strv" do
|
470
|
-
_(type_info.argument_class_name).must_equal "GLib::Strv"
|
471
|
-
end
|
472
|
-
end
|
473
|
-
|
474
|
-
describe "for arrays" do
|
475
|
-
let(:tag) { :array }
|
476
|
-
before do
|
477
|
-
allow(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
478
|
-
allow(elmtype_info).to receive(:tag_or_class).and_return :foo
|
479
|
-
end
|
480
|
-
|
481
|
-
describe "for :zero_terminated" do
|
482
|
-
before do
|
483
|
-
allow(type_info).to receive(:zero_terminated?).and_return true
|
484
|
-
end
|
485
|
-
|
486
|
-
it "equals GirFFI::ZeroTerminated" do
|
487
|
-
_(type_info.argument_class_name).must_equal "GirFFI::ZeroTerminated"
|
488
|
-
end
|
489
|
-
end
|
490
|
-
|
491
|
-
describe "for :byte_array" do
|
492
|
-
before do
|
493
|
-
allow(type_info).to receive(:zero_terminated?).and_return false
|
494
|
-
allow(type_info).to receive(:array_type).and_return :byte_array
|
495
|
-
end
|
496
|
-
|
497
|
-
it "equals GLib::ByteArray" do
|
498
|
-
_(type_info.argument_class_name).must_equal "GLib::ByteArray"
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
describe "for :ptr_array" do
|
503
|
-
before do
|
504
|
-
allow(type_info).to receive(:zero_terminated?).and_return false
|
505
|
-
allow(type_info).to receive(:array_type).and_return :ptr_array
|
506
|
-
end
|
507
|
-
|
508
|
-
it "equals GLib::PtrArray" do
|
509
|
-
_(type_info.argument_class_name).must_equal "GLib::PtrArray"
|
510
|
-
end
|
511
|
-
end
|
512
|
-
|
513
|
-
describe "for :array" do
|
514
|
-
before do
|
515
|
-
allow(type_info).to receive(:zero_terminated?).and_return false
|
516
|
-
allow(type_info).to receive(:array_type).and_return :array
|
517
|
-
end
|
518
|
-
|
519
|
-
it "equals GLib::Array" do
|
520
|
-
_(type_info.argument_class_name).must_equal "GLib::Array"
|
521
|
-
end
|
522
|
-
end
|
523
|
-
end
|
524
|
-
|
525
|
-
describe "for :glist" do
|
526
|
-
let(:tag) { :glist }
|
527
|
-
|
528
|
-
it "equals GLib::List" do
|
529
|
-
_(type_info.argument_class_name).must_equal "GLib::List"
|
530
|
-
end
|
531
|
-
end
|
532
|
-
|
533
|
-
describe "for :gslist" do
|
534
|
-
let(:tag) { :gslist }
|
535
|
-
|
536
|
-
it "equals GLib::SList" do
|
537
|
-
_(type_info.argument_class_name).must_equal "GLib::SList"
|
538
|
-
end
|
539
|
-
end
|
540
|
-
|
541
|
-
describe "for :ghash" do
|
542
|
-
let(:tag) { :ghash }
|
543
|
-
|
544
|
-
it "equals GLib::HashTable" do
|
545
|
-
_(type_info.argument_class_name).must_equal "GLib::HashTable"
|
546
|
-
end
|
547
|
-
end
|
548
|
-
|
549
|
-
describe "for :error" do
|
550
|
-
let(:tag) { :error }
|
551
|
-
|
552
|
-
it "equals GLib::Error" do
|
553
|
-
_(type_info.argument_class_name).must_equal "GLib::Error"
|
554
|
-
end
|
555
|
-
end
|
556
|
-
end
|
557
|
-
|
558
|
-
describe "#gtype" do
|
559
|
-
before do
|
560
|
-
allow(type_info).to receive(:tag).and_return tag
|
561
|
-
allow(type_info).to receive(:pointer?).and_return pointer?
|
562
|
-
end
|
563
|
-
|
564
|
-
describe "for non-pointers" do
|
565
|
-
let(:pointer?) { false }
|
566
|
-
describe "for :void" do
|
567
|
-
let(:tag) { :void }
|
568
|
-
|
569
|
-
it "equals the none type" do
|
570
|
-
_(GObject.type_name(type_info.gtype)).must_equal "void"
|
571
|
-
end
|
572
|
-
end
|
573
|
-
|
574
|
-
describe "for :gboolean" do
|
575
|
-
let(:tag) { :gboolean }
|
576
|
-
|
577
|
-
it "equals the gboolean type" do
|
578
|
-
_(GObject.type_name(type_info.gtype)).must_equal "gboolean"
|
579
|
-
end
|
580
|
-
end
|
581
|
-
|
582
|
-
describe "for :gint32" do
|
583
|
-
let(:tag) { :gint32 }
|
584
|
-
|
585
|
-
it "equals the gint type" do
|
586
|
-
_(GObject.type_name(type_info.gtype)).must_equal "gint"
|
587
|
-
end
|
588
|
-
end
|
589
|
-
|
590
|
-
describe "for :gint64" do
|
591
|
-
let(:tag) { :gint64 }
|
592
|
-
|
593
|
-
it "equals the gint64 type" do
|
594
|
-
_(GObject.type_name(type_info.gtype)).must_equal "gint64"
|
595
|
-
end
|
596
|
-
end
|
597
|
-
|
598
|
-
describe "for :guint64" do
|
599
|
-
let(:tag) { :guint64 }
|
600
|
-
|
601
|
-
it "equals the guint64 type" do
|
602
|
-
_(GObject.type_name(type_info.gtype)).must_equal "guint64"
|
603
|
-
end
|
604
|
-
end
|
605
|
-
end
|
606
|
-
|
607
|
-
describe "for pointers" do
|
608
|
-
let(:pointer?) { true }
|
609
|
-
|
610
|
-
describe "to :void" do
|
611
|
-
let(:tag) { :void }
|
612
|
-
|
613
|
-
it "equals the gpointer type" do
|
614
|
-
_(GObject.type_name(type_info.gtype)).must_equal "gpointer"
|
615
|
-
end
|
616
|
-
end
|
617
|
-
|
618
|
-
describe "to :utf8" do
|
619
|
-
let(:tag) { :utf8 }
|
620
|
-
|
621
|
-
it "equals the gchararray type" do
|
622
|
-
_(GObject.type_name(type_info.gtype)).must_equal "gchararray"
|
623
|
-
end
|
624
|
-
end
|
625
|
-
|
626
|
-
describe "to :ghash" do
|
627
|
-
let(:tag) { :ghash }
|
628
|
-
|
629
|
-
it "equals the GHashTable type" do
|
630
|
-
_(GObject.type_name(type_info.gtype)).must_equal "GHashTable"
|
631
|
-
end
|
632
|
-
end
|
633
|
-
|
634
|
-
describe "to :glist" do
|
635
|
-
let(:tag) { :glist }
|
636
|
-
|
637
|
-
it "equals the pointer type" do
|
638
|
-
_(GObject.type_name(type_info.gtype)).must_equal "gpointer"
|
639
|
-
end
|
640
|
-
end
|
641
|
-
|
642
|
-
describe "to :error" do
|
643
|
-
let(:tag) { :error }
|
644
|
-
|
645
|
-
it "equals the gpointer type" do
|
646
|
-
_(GObject.type_name(type_info.gtype)).must_equal "gpointer"
|
647
|
-
end
|
648
|
-
end
|
649
|
-
|
650
|
-
describe "to :guint32" do
|
651
|
-
let(:tag) { :guint32 }
|
652
|
-
|
653
|
-
it "equals the gpointer type" do
|
654
|
-
_(GObject.type_name(type_info.gtype)).must_equal "gpointer"
|
655
|
-
end
|
656
|
-
end
|
657
|
-
end
|
658
|
-
|
659
|
-
describe "for arrays" do
|
660
|
-
let(:tag) { :array }
|
661
|
-
let(:pointer?) { true }
|
662
|
-
|
663
|
-
describe "for pointer to GArray" do
|
664
|
-
before do
|
665
|
-
allow(type_info).to receive(:zero_terminated?).and_return false
|
666
|
-
allow(type_info).to receive(:array_type).and_return :array
|
667
|
-
end
|
668
|
-
|
669
|
-
it "equals the GArray type" do
|
670
|
-
_(GObject.type_name(type_info.gtype)).must_equal "GArray"
|
671
|
-
end
|
672
|
-
end
|
673
|
-
|
674
|
-
describe "for a C array" do
|
675
|
-
before do
|
676
|
-
allow(type_info).to receive(:zero_terminated?).and_return false
|
677
|
-
allow(type_info).to receive(:array_type).and_return :c
|
678
|
-
end
|
679
|
-
|
680
|
-
it "equals the gpointer type" do
|
681
|
-
_(GObject.type_name(type_info.gtype)).must_equal "gpointer"
|
682
|
-
end
|
683
|
-
end
|
684
|
-
|
685
|
-
describe "for a zero-terminated array" do
|
686
|
-
before do
|
687
|
-
allow(type_info).to receive(:param_type).with(0).and_return elmtype_info
|
688
|
-
allow(type_info).to receive(:zero_terminated?).and_return true
|
689
|
-
end
|
690
|
-
|
691
|
-
describe "of utf8" do
|
692
|
-
it "equals the GStrv type" do
|
693
|
-
allow(elmtype_info).to receive(:tag).and_return :utf8
|
694
|
-
allow(elmtype_info).to receive(:pointer?).and_return true
|
695
|
-
|
696
|
-
_(GObject.type_name(type_info.gtype)).must_equal "GStrv"
|
697
|
-
end
|
698
|
-
end
|
699
|
-
|
700
|
-
describe "of filename" do
|
701
|
-
it "equals the GStrv type" do
|
702
|
-
allow(elmtype_info).to receive(:tag).and_return :filename
|
703
|
-
allow(elmtype_info).to receive(:pointer?).and_return true
|
704
|
-
|
705
|
-
_(GObject.type_name(type_info.gtype)).must_equal "GStrv"
|
706
|
-
end
|
707
|
-
end
|
708
|
-
end
|
709
|
-
end
|
710
|
-
end
|
711
|
-
end
|