gir_ffi 0.15.2 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog.md +11 -0
- data/Gemfile +1 -1
- data/lib/ffi-gobject/value.rb +3 -1
- data/lib/ffi-gobject_introspection/i_base_info.rb +1 -1
- data/lib/gir_ffi/builder_helper.rb +6 -1
- data/lib/gir_ffi/builders/callback_builder.rb +13 -1
- data/lib/gir_ffi/builders/enum_builder.rb +6 -2
- data/lib/gir_ffi/builders/field_builder.rb +2 -1
- data/lib/gir_ffi/builders/module_builder.rb +3 -1
- data/lib/gir_ffi/builders/struct_builder.rb +3 -1
- data/lib/gir_ffi/callback_base.rb +3 -5
- data/lib/gir_ffi/class_base.rb +1 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/test/ffi-gobject/object_test.rb +3 -2
- data/test/ffi-gobject/value_test.rb +1 -1
- data/test/ffi-gobject_introspection/i_base_info_test.rb +1 -1
- data/test/ffi-gobject_test.rb +4 -2
- data/test/gir_ffi/arg_helper_test.rb +13 -6
- data/test/gir_ffi/boxed_base_test.rb +1 -1
- data/test/gir_ffi/builder_test.rb +3 -157
- data/test/gir_ffi/builders/argument_builder_test.rb +73 -33
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +6 -2
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +5 -2
- data/test/gir_ffi/builders/constructor_builder_test.rb +3 -1
- data/test/gir_ffi/builders/field_builder_test.rb +9 -3
- data/test/gir_ffi/builders/function_builder_test.rb +30 -10
- data/test/gir_ffi/builders/initializer_builder_test.rb +3 -1
- data/test/gir_ffi/builders/object_builder_test.rb +6 -6
- data/test/gir_ffi/builders/property_builder_test.rb +5 -2
- data/test/gir_ffi/builders/return_value_builder_test.rb +20 -9
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +9 -7
- data/test/gir_ffi/builders/struct_builder_test.rb +6 -3
- data/test/gir_ffi/builders/user_defined_builder_test.rb +7 -3
- data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +11 -5
- data/test/gir_ffi/builders/vfunc_builder_test.rb +10 -6
- data/test/gir_ffi/class_base_test.rb +17 -12
- data/test/gir_ffi/core_test.rb +4 -3
- data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -2
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +2 -1
- data/test/gir_ffi/info_ext/i_type_info_test.rb +2 -1
- data/test/gir_ffi/method_stubber_test.rb +3 -1
- data/test/integration/derived_classes_test.rb +1 -0
- data/test/integration/generated_everything_test.rb +2 -1
- data/test/integration/generated_gimarshallingtests_test.rb +57 -44
- data/test/integration/generated_gtk_source_test.rb +6 -17
- data/test/integration/generated_regress_test.rb +16 -2
- data/test/integration/generated_warnlib_test.rb +4 -2
- data/test/introspection_test_helper.rb +2 -1
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ee5f86f4d4106139b51edf6855aa3a84bff5437b728dac4c0b878a61bbf86ea
|
4
|
+
data.tar.gz: de0aef98573ba69d41ffa094d08f576977928e6e55598586cf07c08c9c38da6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57de8a0753d8add11635ca497712988aa16507312d719bdc6ed7c8f63a707275622b73c1d968e742d13ba96094fe253baf6d60076dd186683851479cffa8cbe2
|
7
|
+
data.tar.gz: abc9d12f2590a325ab3d8deb087cc4dcf4f5e1eccf0a4dd2f74f48c50553c3b63c19cd799661830da3c13850d50b32cdcb6113ebfb0569b15e7875796a7287ed
|
data/Changelog.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.15.3 / 2020-06-14
|
4
|
+
|
5
|
+
* Officially support Ruby 2.7
|
6
|
+
* Officially drop support for Ruby 2.4
|
7
|
+
* Store classes representing inline callback types in the class that defines
|
8
|
+
them instead of in the main namespace, thus avoiding some potential name
|
9
|
+
clashes
|
10
|
+
* Update development dependencies
|
11
|
+
* Various code quality improvements
|
12
|
+
* Record approved licenses for dependencies
|
13
|
+
|
3
14
|
## 0.15.2 / 2019-11-29
|
4
15
|
|
5
16
|
* Load girepository-1.0 library in a way that does not require installing a
|
data/Gemfile
CHANGED
data/lib/ffi-gobject/value.rb
CHANGED
@@ -179,7 +179,9 @@ module GObject
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def check_type_compatibility(val)
|
182
|
-
|
182
|
+
if GObject::Value.type_compatible(GObject.type_from_instance(val), current_gtype)
|
183
|
+
return
|
184
|
+
end
|
183
185
|
|
184
186
|
raise ArgumentError, "#{val.class} is incompatible with #{current_gtype_name}"
|
185
187
|
end
|
@@ -107,10 +107,10 @@ module GObjectIntrospection
|
|
107
107
|
namespace.sub(/^[a-z]/, &:upcase)
|
108
108
|
end
|
109
109
|
|
110
|
-
# TODO: Avoid calling for IStructInfo
|
111
110
|
def container
|
112
111
|
@container ||= begin
|
113
112
|
ptr = Lib.g_base_info_get_container self
|
113
|
+
return if ptr.null?
|
114
114
|
Lib.g_base_info_ref ptr
|
115
115
|
IRepository.wrap_ibaseinfo_pointer ptr
|
116
116
|
end
|
@@ -12,7 +12,12 @@ module GirFFI
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def get_or_define_class(namespace, name, parent)
|
15
|
-
optionally_define_constant(namespace, name) { Class.new parent }
|
15
|
+
klass = optionally_define_constant(namespace, name) { Class.new parent }
|
16
|
+
unless klass.superclass == parent
|
17
|
+
raise "Expected superclass #{parent}, found #{klass.superclass}"
|
18
|
+
end
|
19
|
+
|
20
|
+
klass
|
16
21
|
end
|
17
22
|
|
18
23
|
def get_or_define_module(parent, name)
|
@@ -23,7 +23,19 @@ module GirFFI
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def klass
|
26
|
-
@klass ||= get_or_define_class
|
26
|
+
@klass ||= get_or_define_class container_module, @classname, CallbackBase
|
27
|
+
end
|
28
|
+
|
29
|
+
def container_module
|
30
|
+
@container_module ||=
|
31
|
+
if @info.container
|
32
|
+
type_info = @info.container
|
33
|
+
field_info = type_info.container
|
34
|
+
container_class_info = field_info.container
|
35
|
+
namespace_module.const_get container_class_info.safe_name
|
36
|
+
else
|
37
|
+
namespace_module
|
38
|
+
end
|
27
39
|
end
|
28
40
|
|
29
41
|
def mapping_method_definition
|
@@ -16,7 +16,7 @@ module GirFFI
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def value_spec
|
19
|
-
|
19
|
+
value_infos.map do |vinfo|
|
20
20
|
val = GirFFI::ArgHelper.cast_uint32_to_int32(vinfo.value)
|
21
21
|
[vinfo.name.to_sym, val]
|
22
22
|
end.flatten
|
@@ -42,7 +42,7 @@ module GirFFI
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def setup_value_constants
|
45
|
-
|
45
|
+
value_infos.each do |vinfo|
|
46
46
|
optionally_define_constant klass, vinfo.constant_name do
|
47
47
|
vinfo.value
|
48
48
|
end
|
@@ -64,6 +64,10 @@ module GirFFI
|
|
64
64
|
def superclass
|
65
65
|
EnumBase
|
66
66
|
end
|
67
|
+
|
68
|
+
def value_infos
|
69
|
+
@value_infos ||= info.values
|
70
|
+
end
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
@@ -58,7 +58,8 @@ module GirFFI
|
|
58
58
|
private
|
59
59
|
|
60
60
|
def pointer_to_value_conversion
|
61
|
-
PointerValueConvertor.new(field_type_tag)
|
61
|
+
PointerValueConvertor.new(field_type_tag)
|
62
|
+
.pointer_to_value(field_ptr, field_offset)
|
62
63
|
end
|
63
64
|
|
64
65
|
def field_offset
|
@@ -88,7 +88,9 @@ module GirFFI
|
|
88
88
|
lib.extend FFI::Library
|
89
89
|
lib.extend FFI::BitMasks
|
90
90
|
lib.ffi_lib_flags :global, :lazy
|
91
|
-
|
91
|
+
if shared_library_specification
|
92
|
+
lib.ffi_lib(*shared_library_specification.split(/,/))
|
93
|
+
end
|
92
94
|
end
|
93
95
|
|
94
96
|
def shared_library_specification
|
@@ -16,7 +16,9 @@ module GirFFI
|
|
16
16
|
|
17
17
|
def superclass
|
18
18
|
# HACK: Inheritance chain is not expressed in GObject's code correctly.
|
19
|
-
|
19
|
+
if info.full_type_name == "GObject::InitiallyUnownedClass"
|
20
|
+
return GObject::ObjectClass
|
21
|
+
end
|
20
22
|
return parent_field_type.tag_or_class if info.gtype_struct?
|
21
23
|
return BoxedBase if GObject.type_fundamental(info.gtype) == GObject::TYPE_BOXED
|
22
24
|
|
@@ -57,11 +57,9 @@ module GirFFI
|
|
57
57
|
return unless prc
|
58
58
|
|
59
59
|
new do |*args|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
GLib::MainLoop.handle_exception e
|
64
|
-
end
|
60
|
+
call_with_argument_mapping(prc, *args)
|
61
|
+
rescue StandardError => e
|
62
|
+
GLib::MainLoop.handle_exception e
|
65
63
|
end
|
66
64
|
end
|
67
65
|
|
data/lib/gir_ffi/class_base.rb
CHANGED
data/lib/gir_ffi/version.rb
CHANGED
@@ -53,7 +53,8 @@ describe GObject::Object do
|
|
53
53
|
describe "#set_property" do
|
54
54
|
it "raises an error for a property that does not exist" do
|
55
55
|
instance = GObject::Object.new
|
56
|
-
_(proc { instance.set_property "foo-bar", 123 })
|
56
|
+
_(proc { instance.set_property "foo-bar", 123 })
|
57
|
+
.must_raise GirFFI::PropertyNotFoundError
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
@@ -103,7 +104,7 @@ describe GObject::Object do
|
|
103
104
|
|
104
105
|
describe "upon garbage collection" do
|
105
106
|
it "lowers the reference count" do
|
106
|
-
skip "cannot be reliably tested on JRuby
|
107
|
+
skip "cannot be reliably tested on JRuby" if jruby?
|
107
108
|
|
108
109
|
ptr = GObject::Object.new.to_ptr
|
109
110
|
_(object_ref_count(ptr)).must_equal 1
|
@@ -369,7 +369,7 @@ describe GObject::Value do
|
|
369
369
|
|
370
370
|
describe "upon garbage collection" do
|
371
371
|
it "restores the underlying GValue to its pristine state" do
|
372
|
-
skip "cannot be reliably tested on JRuby
|
372
|
+
skip "cannot be reliably tested on JRuby" if jruby?
|
373
373
|
|
374
374
|
value = GObject::Value.from 42
|
375
375
|
|
@@ -32,7 +32,7 @@ describe GObjectIntrospection::IBaseInfo do
|
|
32
32
|
|
33
33
|
describe "upon garbage collection" do
|
34
34
|
it "calls g_base_info_unref" do
|
35
|
-
skip "cannot be reliably tested on JRuby
|
35
|
+
skip "cannot be reliably tested on JRuby" if jruby?
|
36
36
|
|
37
37
|
expect(ptr = Object.new).to receive(:null?).and_return false
|
38
38
|
expect(lib = Object.new).to receive(:g_base_info_unref).with(ptr).and_return nil
|
data/test/ffi-gobject_test.rb
CHANGED
@@ -40,7 +40,8 @@ describe GObject do
|
|
40
40
|
callback = FFI::Function.new(:void, argtypes) do |_a, b, _c|
|
41
41
|
b2 = b
|
42
42
|
end
|
43
|
-
::GObject::Lib.g_signal_connect_data
|
43
|
+
::GObject::Lib.g_signal_connect_data(o, "test-with-static-scope-arg",
|
44
|
+
callback, nil, nil, 0)
|
44
45
|
GObject.signal_emit o, "test-with-static-scope-arg", sb
|
45
46
|
|
46
47
|
sb2 = Regress::TestSimpleBoxedA.wrap b2
|
@@ -121,7 +122,8 @@ describe GObject do
|
|
121
122
|
sb = Regress::TestSimpleBoxedA.new
|
122
123
|
sb.some_int = 23
|
123
124
|
|
124
|
-
GObject.signal_connect(o, "test-with-static-scope-arg", 2)
|
125
|
+
GObject.signal_connect(o, "test-with-static-scope-arg", 2) \
|
126
|
+
do |_instance, object, user_data|
|
125
127
|
@a = user_data
|
126
128
|
@b = object
|
127
129
|
end
|
@@ -7,7 +7,8 @@ describe GirFFI::ArgHelper do
|
|
7
7
|
it "handles class types" do
|
8
8
|
klass = Class.new
|
9
9
|
expect(klass).to receive(:wrap).with(:pointer_value).and_return :wrapped_value
|
10
|
-
_(GirFFI::ArgHelper.cast_from_pointer(klass, :pointer_value))
|
10
|
+
_(GirFFI::ArgHelper.cast_from_pointer(klass, :pointer_value))
|
11
|
+
.must_equal :wrapped_value
|
11
12
|
end
|
12
13
|
|
13
14
|
describe "for :gint8" do
|
@@ -62,32 +63,38 @@ describe GirFFI::ArgHelper do
|
|
62
63
|
it "handles GHashTable" do
|
63
64
|
hash = GLib::HashTable.from [:utf8, :gint32], "foo" => 1, "bar" => 2
|
64
65
|
ptr = hash.to_ptr
|
65
|
-
result = GirFFI::ArgHelper.cast_from_pointer([:pointer, [:ghash, :utf8, :gint32]],
|
66
|
+
result = GirFFI::ArgHelper.cast_from_pointer([:pointer, [:ghash, :utf8, :gint32]],
|
67
|
+
ptr)
|
66
68
|
_(result.to_hash).must_equal hash.to_hash
|
67
69
|
end
|
68
70
|
|
69
71
|
describe "when passing a broken typespec" do
|
70
72
|
it "raises on unknown symbol" do
|
71
73
|
ptr = FFI::Pointer.new(0xffffffff)
|
72
|
-
exception = _(-> { GirFFI::ArgHelper.cast_from_pointer(:foo, ptr) })
|
74
|
+
exception = _(-> { GirFFI::ArgHelper.cast_from_pointer(:foo, ptr) })
|
75
|
+
.must_raise RuntimeError
|
73
76
|
_(exception.message).must_equal "Don't know how to cast foo"
|
74
77
|
end
|
75
78
|
|
76
79
|
it "raises on unexpected main type for complex type" do
|
77
80
|
ptr = FFI::Pointer.new(0xffffffff)
|
78
|
-
exception = _(-> { GirFFI::ArgHelper.cast_from_pointer([:utf8], ptr) })
|
81
|
+
exception = _(-> { GirFFI::ArgHelper.cast_from_pointer([:utf8], ptr) })
|
82
|
+
.must_raise RuntimeError
|
79
83
|
_(exception.message).must_equal "Don't know how to cast [:utf8]"
|
80
84
|
end
|
81
85
|
|
82
86
|
it "raises on unexpected sub type for complex type" do
|
83
87
|
ptr = FFI::Pointer.new(0xffffffff)
|
84
|
-
exception = _(-> { GirFFI::ArgHelper.cast_from_pointer([:pointer, :utf8], ptr) })
|
88
|
+
exception = _(-> { GirFFI::ArgHelper.cast_from_pointer([:pointer, :utf8], ptr) })
|
89
|
+
.must_raise RuntimeError
|
85
90
|
_(exception.message).must_equal "Don't know how to cast [:pointer, :utf8]"
|
86
91
|
end
|
87
92
|
|
88
93
|
it "raises on unexpected container type for complex type" do
|
89
94
|
ptr = FFI::Pointer.new(0xffffffff)
|
90
|
-
exception =
|
95
|
+
exception =
|
96
|
+
_(-> { GirFFI::ArgHelper.cast_from_pointer([:pointer, [:gint32]], ptr) })
|
97
|
+
.must_raise RuntimeError
|
91
98
|
_(exception.message).must_equal "Don't know how to cast [:pointer, [:gint32]]"
|
92
99
|
end
|
93
100
|
end
|
@@ -38,7 +38,7 @@ describe GirFFI::BoxedBase do
|
|
38
38
|
|
39
39
|
describe "upon garbage collection" do
|
40
40
|
it "frees and disowns the underlying struct if it is owned" do
|
41
|
-
skip "cannot be reliably tested on JRuby
|
41
|
+
skip "cannot be reliably tested on JRuby" if jruby?
|
42
42
|
|
43
43
|
allow(GObject).to receive(:boxed_free)
|
44
44
|
gtype = GIMarshallingTests::BoxedStruct.gtype
|
@@ -108,7 +108,7 @@ describe GirFFI::Builder do
|
|
108
108
|
describe ".attach_ffi_function" do
|
109
109
|
let(:lib) { Module.new }
|
110
110
|
|
111
|
-
it "
|
111
|
+
it "attaches regress_test_callback_destroy_notify with the correct types" do
|
112
112
|
function_info = get_introspection_data "Regress", "test_callback_destroy_notify"
|
113
113
|
|
114
114
|
expect(lib)
|
@@ -121,7 +121,7 @@ describe GirFFI::Builder do
|
|
121
121
|
GirFFI::Builder.attach_ffi_function(lib, function_info)
|
122
122
|
end
|
123
123
|
|
124
|
-
it "
|
124
|
+
it "attaches regress_test_obj_torture_signature_0 with the correct types" do
|
125
125
|
info = get_method_introspection_data "Regress", "TestObj", "torture_signature_0"
|
126
126
|
|
127
127
|
expect(lib)
|
@@ -134,7 +134,7 @@ describe GirFFI::Builder do
|
|
134
134
|
GirFFI::Builder.attach_ffi_function(lib, info)
|
135
135
|
end
|
136
136
|
|
137
|
-
it "
|
137
|
+
it "attaches regress_test_obj_instance_method with the correct types" do
|
138
138
|
info = get_method_introspection_data "Regress", "TestObj", "instance_method"
|
139
139
|
expect(lib).to receive(:attach_function)
|
140
140
|
.with("regress_test_obj_instance_method", [:pointer], :int32)
|
@@ -165,158 +165,4 @@ describe GirFFI::Builder do
|
|
165
165
|
GirFFI::Builder.attach_ffi_function(lib, info)
|
166
166
|
end
|
167
167
|
end
|
168
|
-
|
169
|
-
#
|
170
|
-
# NOTE: Legacy tests below.
|
171
|
-
#
|
172
|
-
|
173
|
-
describe "looking at Regress.test_callback_destroy_notify" do
|
174
|
-
before do
|
175
|
-
save_module :GObject
|
176
|
-
save_module :Regress
|
177
|
-
GirFFI::Builder.build_module "GObject"
|
178
|
-
GirFFI::Builder.build_module "Regress"
|
179
|
-
@go = get_introspection_data "Regress", "test_callback_destroy_notify"
|
180
|
-
end
|
181
|
-
|
182
|
-
it "defines ffi callback types :Callback and :ClosureNotify" do
|
183
|
-
Regress.setup_method! "test_callback_destroy_notify"
|
184
|
-
tcud = Regress::Lib.find_type :TestCallbackUserData
|
185
|
-
dn = GLib::Lib.find_type :DestroyNotify
|
186
|
-
|
187
|
-
assert_equal FFI.find_type(:int32), tcud.result_type
|
188
|
-
assert_equal FFI.find_type(:void), dn.result_type
|
189
|
-
assert_equal [FFI.find_type(:pointer)], tcud.param_types
|
190
|
-
assert_equal [FFI.find_type(:pointer)], dn.param_types
|
191
|
-
end
|
192
|
-
|
193
|
-
after do
|
194
|
-
restore_module :Regress
|
195
|
-
restore_module :GObject
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
describe "building Regress::TestBoxed" do
|
200
|
-
before do
|
201
|
-
GirFFI::Builder.build_class get_introspection_data("Regress", "TestBoxed")
|
202
|
-
end
|
203
|
-
|
204
|
-
it "sets up #wrap" do
|
205
|
-
assert Regress::TestBoxed.respond_to? "wrap"
|
206
|
-
end
|
207
|
-
|
208
|
-
it "sets up #allocate" do
|
209
|
-
assert Regress::TestBoxed.respond_to? "allocate"
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
describe "built Regress module" do
|
214
|
-
before do
|
215
|
-
save_module :Regress
|
216
|
-
GirFFI::Builder.build_module "Regress"
|
217
|
-
end
|
218
|
-
|
219
|
-
it "autocreates singleton methods" do
|
220
|
-
refute_defines_singleton_method Regress, :test_uint
|
221
|
-
Regress.test_uint 31
|
222
|
-
assert_defines_singleton_method Regress, :test_uint
|
223
|
-
end
|
224
|
-
|
225
|
-
it "autocreates the TestObj class on first access" do
|
226
|
-
assert !Regress.const_defined?(:TestObj)
|
227
|
-
_(Regress::TestObj).must_be_instance_of Class
|
228
|
-
assert Regress.const_defined? :TestObj
|
229
|
-
end
|
230
|
-
|
231
|
-
it "knows its own module builder" do
|
232
|
-
_(Regress.gir_ffi_builder).must_be_instance_of GirFFI::Builders::ModuleBuilder
|
233
|
-
end
|
234
|
-
|
235
|
-
after do
|
236
|
-
restore_module :Regress
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
describe "having built Regress::TestObj" do
|
241
|
-
before do
|
242
|
-
GirFFI::Builder.build_class get_introspection_data("Regress", "TestObj")
|
243
|
-
end
|
244
|
-
|
245
|
-
it "C functions for called instance methods get attached to Regress::Lib" do
|
246
|
-
o = Regress::TestObj.new_from_file("foo")
|
247
|
-
o.instance_method
|
248
|
-
_(Regress::Lib).must_respond_to :regress_test_obj_instance_method
|
249
|
-
end
|
250
|
-
|
251
|
-
it "the built class knows its own GIR info" do
|
252
|
-
_(Regress::TestObj.gir_info.name).must_equal "TestObj"
|
253
|
-
end
|
254
|
-
|
255
|
-
it "the built class knows its own class builder" do
|
256
|
-
_(Regress::TestObj.gir_ffi_builder).must_be_instance_of GirFFI::Builders::ObjectBuilder
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
describe "built Regress::TestSubObj" do
|
261
|
-
it "inherits #set_bare from its superclass" do
|
262
|
-
o1 = Regress::TestSubObj.new
|
263
|
-
o1.set_bare(nil)
|
264
|
-
pass
|
265
|
-
end
|
266
|
-
|
267
|
-
it "overrides #instance_method" do
|
268
|
-
obj = Regress::TestObj.new_from_file("foo")
|
269
|
-
subobj = Regress::TestSubObj.new
|
270
|
-
|
271
|
-
_(obj.instance_method).must_equal(-1)
|
272
|
-
_(subobj.instance_method).must_equal 0
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
describe "building Regress::TestSubObj" do
|
277
|
-
before do
|
278
|
-
save_module :Regress
|
279
|
-
GirFFI::Builder.build_class get_introspection_data("Regress", "TestSubObj")
|
280
|
-
end
|
281
|
-
|
282
|
-
it "sets up the Regress namespace" do
|
283
|
-
assert Regress.const_defined? :Lib
|
284
|
-
assert Regress.respond_to? :gir_ffi_builder
|
285
|
-
assert Regress.const_defined? :GIR_FFI_BUILDER
|
286
|
-
end
|
287
|
-
|
288
|
-
it "creates the Regress::Lib module ready to attach functions from the shared library" do
|
289
|
-
expected = [gir.shared_library("Regress")]
|
290
|
-
assert_equal expected, Regress::Lib.ffi_libraries.map(&:name)
|
291
|
-
end
|
292
|
-
|
293
|
-
it "builds parent classes also" do
|
294
|
-
assert Regress.const_defined? :TestObj
|
295
|
-
assert Object.const_defined? :GObject
|
296
|
-
assert GObject.const_defined? :Object
|
297
|
-
end
|
298
|
-
|
299
|
-
it "sets up the inheritance chain" do
|
300
|
-
# Introduced in version 1.59.1
|
301
|
-
expected = if Regress::TestSubObj.find_property :boolean
|
302
|
-
[Regress::TestSubObj,
|
303
|
-
Regress::TestInterface,
|
304
|
-
Regress::TestObj,
|
305
|
-
GObject::Object]
|
306
|
-
else
|
307
|
-
[Regress::TestSubObj,
|
308
|
-
Regress::TestObj,
|
309
|
-
GObject::Object]
|
310
|
-
end
|
311
|
-
_(Regress::TestSubObj.registered_ancestors).must_equal expected
|
312
|
-
end
|
313
|
-
|
314
|
-
it "creates a Regress::TestSubObj#to_ptr method" do
|
315
|
-
assert Regress::TestSubObj.public_method_defined? :to_ptr
|
316
|
-
end
|
317
|
-
|
318
|
-
after do
|
319
|
-
restore_module :Regress
|
320
|
-
end
|
321
|
-
end
|
322
168
|
end
|