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