gir_ffi 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/{README.rdoc → README.md} +31 -25
- data/Rakefile +1 -1
- data/TODO.rdoc +1 -1
- data/lib/ffi-glib.rb +5 -5
- data/lib/ffi-glib/container_class_methods.rb +1 -2
- data/lib/ffi-glib/list_methods.rb +16 -6
- data/lib/ffi-gobject.rb +4 -7
- data/lib/ffi-gobject/helper.rb +6 -6
- data/lib/ffi-gobject/object.rb +4 -4
- data/lib/ffi-gobject_introspection.rb +0 -1
- data/lib/ffi-gobject_introspection/g_error.rb +15 -5
- data/lib/ffi-gobject_introspection/i_base_info.rb +7 -4
- data/lib/ffi-gobject_introspection/i_function_info.rb +3 -1
- data/lib/ffi-gobject_introspection/i_repository.rb +8 -15
- data/lib/ffi-gobject_introspection/i_struct_info.rb +5 -10
- data/lib/gir_ffi-base.rb +2 -0
- data/lib/gir_ffi-base/glib/strv.rb +43 -0
- data/lib/{ffi-gobject_introspection/gobject_lib.rb → gir_ffi-base/gobject/lib.rb} +4 -2
- data/lib/gir_ffi/arg_helper.rb +4 -2
- data/lib/gir_ffi/builder.rb +1 -7
- data/lib/gir_ffi/builder/argument.rb +34 -108
- data/lib/gir_ffi/builder/argument/base.rb +26 -20
- data/lib/gir_ffi/builder/type/object.rb +14 -2
- data/lib/gir_ffi/builder/type/registered_type.rb +1 -11
- data/lib/gir_ffi/class_base.rb +21 -26
- data/lib/gir_ffi/in_pointer.rb +11 -5
- data/lib/gir_ffi/info_ext/i_type_info.rb +26 -0
- data/lib/gir_ffi/interface_base.rb +10 -0
- data/lib/gir_ffi/module_base.rb +14 -4
- data/lib/gir_ffi/object_base.rb +39 -0
- data/lib/gir_ffi/type_map.rb +1 -3
- data/lib/gir_ffi/version.rb +1 -1
- data/tasks/test.rake +33 -44
- data/test/{test_helper.rb → base_test_helper.rb} +2 -11
- data/test/ffi-glib/array_test.rb +1 -1
- data/test/ffi-glib/byte_array_test.rb +1 -1
- data/test/ffi-glib/hash_table_test.rb +30 -1
- data/test/ffi-glib/list_test.rb +1 -1
- data/test/ffi-glib/ptr_array_test.rb +1 -1
- data/test/ffi-glib/ruby_closure_test.rb +54 -0
- data/test/ffi-glib/s_list_test.rb +1 -1
- data/test/ffi-gobject/gobject_test.rb +1 -1
- data/test/ffi-gobject/helper_test.rb +103 -0
- data/test/ffi-gobject/object_class_test.rb +1 -1
- data/test/ffi-gobject/object_test.rb +1 -1
- data/test/ffi-gobject/ruby_style_test.rb +1 -1
- 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_introspection/i_constant_info_test.rb +1 -1
- data/test/ffi-gobject_introspection/i_function_info_test.rb +1 -1
- data/test/ffi-gobject_introspection/i_object_info_test.rb +1 -1
- data/test/ffi-gobject_introspection/i_repository_test.rb +1 -1
- data/test/ffi-gobject_introspection/lib_test.rb +1 -1
- data/test/ffi-gobject_test.rb +120 -0
- data/test/{ffi-glib → gir_ffi-base/glib}/strv_test.rb +8 -5
- data/test/{unit → gir_ffi}/arg_helper_test.rb +2 -2
- data/test/{unit/argument_builder_test.rb → gir_ffi/builder/argument/base_test.rb} +1 -13
- data/test/{unit/function_builder_test.rb → gir_ffi/builder/function_test.rb} +2 -2
- data/test/{unit/module_builder_test.rb → gir_ffi/builder/module_test.rb} +1 -1
- data/test/{unit/callback_builder_test.rb → gir_ffi/builder/type/callback_test.rb} +1 -1
- data/test/{unit/constant_builder_test.rb → gir_ffi/builder/type/constant_test.rb} +1 -1
- data/test/{unit/enum_builder_test.rb → gir_ffi/builder/type/enum_test.rb} +1 -1
- data/test/{unit/interface_builder_test.rb → gir_ffi/builder/type/interface_test.rb} +1 -4
- data/test/{unit/object_type_builder_test.rb → gir_ffi/builder/type/object_test.rb} +21 -2
- data/test/{unit/struct_builder_test.rb → gir_ffi/builder/type/struct_test.rb} +1 -1
- data/test/{unit/unintrospectable_type_builder_test.rb → gir_ffi/builder/type/unintrospectable_test.rb} +1 -1
- data/test/{unit/union_builder_test.rb → gir_ffi/builder/type/union_test.rb} +9 -3
- data/test/{unit/user_defined_type_builder_test.rb → gir_ffi/builder/type/user_defined_test.rb} +4 -2
- data/test/gir_ffi/builder_test.rb +398 -0
- data/test/{unit → gir_ffi}/callback_helper_test.rb +1 -1
- data/test/{unit → gir_ffi}/class_base_test.rb +1 -1
- data/test/{unit → gir_ffi}/in_out_pointer_test.rb +1 -1
- data/test/{unit → gir_ffi}/in_pointer_test.rb +24 -3
- data/test/{unit → gir_ffi/info_ext}/i_field_info_test.rb +1 -1
- data/test/gir_ffi/info_ext/i_type_info_test.rb +71 -0
- data/test/{unit/user_defined_object_info_test.rb → gir_ffi/user_defined/i_object_info_test.rb} +1 -1
- data/test/{unit/user_defined_property_info_test.rb → gir_ffi/user_defined/i_property_info_test.rb} +1 -1
- data/test/{unit/user_defined_registered_type_info_test.rb → gir_ffi/user_defined/i_registered_type_info_test.rb} +1 -1
- data/test/{unit → gir_ffi}/variable_name_generator_test.rb +1 -1
- data/test/{unit/gir_ffi_test.rb → gir_ffi_test.rb} +24 -4
- data/test/gir_ffi_test_helper.rb +1 -1
- data/test/integration/derived_classes_test.rb +1 -1
- data/test/integration/generated_gimarshallingtests_test.rb +1 -1
- data/test/integration/generated_gio_test.rb +1 -1
- data/test/integration/generated_gobject_test.rb +1 -1
- data/test/integration/generated_regress_test.rb +2 -3
- data/test/integration/method_lookup_test.rb +1 -1
- data/test/integration/pretty_print_test.rb +1 -1
- data/test/introspection_test_helper.rb +11 -0
- metadata +71 -77
- data/lib/ffi-glib/strv.rb +0 -31
- data/test/builder_test.rb +0 -264
- data/test/ffi-glib/glib_overrides_test.rb +0 -38
- data/test/ffi-gobject/g_object_overrides_test.rb +0 -274
- data/test/girffi_test.rb +0 -27
- data/test/integration/generated_pango_test.rb +0 -20
- data/test/type_builder_test.rb +0 -36
- data/test/unit/builder_test.rb +0 -143
- data/test/unit/hash_table_element_type_provider_test.rb +0 -16
- data/test/unit/i_type_info_test.rb +0 -23
- data/test/unit/list_element_type_provider_test.rb +0 -13
@@ -1,6 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require 'gir_ffi_test_helper'
|
2
2
|
|
3
3
|
describe GirFFI::Builder::Type::Union do
|
4
|
+
before do
|
5
|
+
@cbuilder = GirFFI::Builder::Type::Union.new get_introspection_data('GObject', 'TypeCValue')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns false looking for a method that doesn't exist" do
|
9
|
+
assert_equal false, @cbuilder.setup_instance_method('blub')
|
10
|
+
end
|
11
|
+
|
4
12
|
describe "#pretty_print" do
|
5
13
|
it "returns a class block" do
|
6
14
|
mock(info = Object.new).safe_name { "Bar" }
|
@@ -13,5 +21,3 @@ describe GirFFI::Builder::Type::Union do
|
|
13
21
|
end
|
14
22
|
end
|
15
23
|
|
16
|
-
|
17
|
-
|
data/test/{unit/user_defined_type_builder_test.rb → gir_ffi/builder/type/user_defined_test.rb}
RENAMED
@@ -1,10 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require 'gir_ffi_test_helper'
|
2
|
+
|
3
|
+
GirFFI.setup :GIMarshallingTests
|
2
4
|
|
3
5
|
describe GirFFI::Builder::Type::UserDefined do
|
4
6
|
describe "with a block with a call to #install_property" do
|
5
7
|
before do
|
6
8
|
@klass = Class.new GIMarshallingTests::OverridesObject
|
7
|
-
Object.const_set "
|
9
|
+
Object.const_set "DerivedC#{Sequence.next}", @klass
|
8
10
|
@builder = GirFFI::Builder::Type::UserDefined.new @klass do
|
9
11
|
install_property GObject.param_spec_int("foo", "foo bar",
|
10
12
|
"The Foo Bar Property",
|
@@ -0,0 +1,398 @@
|
|
1
|
+
require 'gir_ffi_test_helper'
|
2
|
+
|
3
|
+
describe GirFFI::Builder do
|
4
|
+
setup do
|
5
|
+
@gir = GObjectIntrospection::IRepository.default
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "::itypeinfo_to_callback_ffitype" do
|
9
|
+
describe "for an :interface argument" do
|
10
|
+
before do
|
11
|
+
@iface = Object.new
|
12
|
+
stub(@info = Object.new).interface { @iface }
|
13
|
+
stub(@info).tag { :interface }
|
14
|
+
stub(@info).pointer? { false }
|
15
|
+
end
|
16
|
+
|
17
|
+
it "correctly maps a :union argument to :pointer" do
|
18
|
+
stub(@iface).info_type { :union }
|
19
|
+
|
20
|
+
result = GirFFI::Builder.itypeinfo_to_callback_ffitype @info
|
21
|
+
|
22
|
+
assert_equal :pointer, result
|
23
|
+
end
|
24
|
+
|
25
|
+
it "correctly maps a :flags argument to :int32" do
|
26
|
+
stub(@iface).info_type { :flags }
|
27
|
+
|
28
|
+
result = GirFFI::Builder.itypeinfo_to_callback_ffitype @info
|
29
|
+
|
30
|
+
assert_equal :int32, result
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "building GObject::Object" do
|
36
|
+
before do
|
37
|
+
save_module :GObject
|
38
|
+
GirFFI::Builder.build_class get_introspection_data('GObject', 'Object')
|
39
|
+
end
|
40
|
+
|
41
|
+
should "create a Lib module in the parent namespace ready to attach functions from gobject-2.0" do
|
42
|
+
expected = @gir.shared_library('GObject')
|
43
|
+
assert_equal [expected], GObject::Lib.ffi_libraries.map(&:name)
|
44
|
+
end
|
45
|
+
|
46
|
+
should "create an array CALLBACKS inside the GObject::Lib module" do
|
47
|
+
assert_equal [], GObject::Lib::CALLBACKS
|
48
|
+
end
|
49
|
+
|
50
|
+
should "not replace existing classes" do
|
51
|
+
oldclass = GObject::Object
|
52
|
+
GirFFI::Builder.build_class get_introspection_data('GObject', 'Object')
|
53
|
+
assert_equal oldclass, GObject::Object
|
54
|
+
end
|
55
|
+
|
56
|
+
after do
|
57
|
+
restore_module :GObject
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "looking at Regress.test_callback_destroy_notify" do
|
62
|
+
before do
|
63
|
+
save_module :GObject
|
64
|
+
save_module :Regress
|
65
|
+
GirFFI::Builder.build_module 'GObject'
|
66
|
+
GirFFI::Builder.build_module 'Regress'
|
67
|
+
@go = get_introspection_data 'Regress', 'test_callback_destroy_notify'
|
68
|
+
end
|
69
|
+
|
70
|
+
should "have the correct types of the arguments for the attached function" do
|
71
|
+
argtypes = GirFFI::Builder.send(:ffi_function_argument_types, @go)
|
72
|
+
assert_equal [Regress::TestCallbackUserData, :pointer, GLib::DestroyNotify],
|
73
|
+
argtypes
|
74
|
+
end
|
75
|
+
|
76
|
+
should "define ffi callback types :Callback and :ClosureNotify" do
|
77
|
+
Regress._setup_method 'test_callback_destroy_notify'
|
78
|
+
tcud = Regress::Lib.find_type :TestCallbackUserData
|
79
|
+
dn = GLib::Lib.find_type :DestroyNotify
|
80
|
+
|
81
|
+
assert_equal FFI.find_type(:int32), tcud.result_type
|
82
|
+
assert_equal FFI.find_type(:void), dn.result_type
|
83
|
+
assert_equal [FFI.find_type(:pointer)], tcud.param_types
|
84
|
+
assert_equal [FFI.find_type(:pointer)], dn.param_types
|
85
|
+
end
|
86
|
+
|
87
|
+
# FIXME: Test passes but does not test what it claims to test.
|
88
|
+
should "define ffi enum type ConnectFlags" do
|
89
|
+
assert_equal({:after => 1, :swapped => 2}, GObject::ConnectFlags.to_h)
|
90
|
+
end
|
91
|
+
|
92
|
+
after do
|
93
|
+
restore_module :Regress
|
94
|
+
restore_module :GObject
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "building Regress::TestStructA" do
|
99
|
+
setup do
|
100
|
+
GirFFI::Builder.build_class get_introspection_data('Regress', 'TestStructA')
|
101
|
+
end
|
102
|
+
|
103
|
+
should "set up the correct struct members" do
|
104
|
+
assert_equal [:some_int, :some_int8, :some_double, :some_enum],
|
105
|
+
Regress::TestStructA::Struct.members
|
106
|
+
end
|
107
|
+
|
108
|
+
should "set up struct members with the correct offset" do
|
109
|
+
info = @gir.find_by_name 'Regress', 'TestStructA'
|
110
|
+
assert_equal info.fields.map{|f| [f.name.to_sym, f.offset]},
|
111
|
+
Regress::TestStructA::Struct.offsets
|
112
|
+
end
|
113
|
+
|
114
|
+
should "set up struct members with the correct types" do
|
115
|
+
tags = [:int, :int8, :double, Regress::TestEnum]
|
116
|
+
assert_equal tags.map {|t| FFI.find_type t},
|
117
|
+
Regress::TestStructA::Struct.layout.fields.map {|f| f.type}
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "building GObject::TypeCValue" do
|
122
|
+
setup do
|
123
|
+
GirFFI::Builder.build_class get_introspection_data('GObject', 'TypeCValue')
|
124
|
+
end
|
125
|
+
|
126
|
+
should "set up the correct union members" do
|
127
|
+
assert_equal [:v_int, :v_long, :v_int64, :v_double, :v_pointer],
|
128
|
+
GObject::TypeCValue::Struct.members
|
129
|
+
end
|
130
|
+
|
131
|
+
should "set up union members with the correct offset" do
|
132
|
+
assert_equal [0, 0, 0, 0, 0],
|
133
|
+
GObject::TypeCValue::Struct.offsets.map {|o| o[1]}
|
134
|
+
end
|
135
|
+
|
136
|
+
should "set up the inner class as derived from FFI::Union" do
|
137
|
+
assert_equal FFI::Union, GObject::TypeCValue::Struct.superclass
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "building GObject::ValueArray" do
|
142
|
+
should "use provided constructor if present" do
|
143
|
+
GirFFI::Builder.build_class get_introspection_data('GObject', 'ValueArray')
|
144
|
+
assert_nothing_raised {
|
145
|
+
GObject::ValueArray.new 2
|
146
|
+
}
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "building Regress::TestBoxed" do
|
151
|
+
setup do
|
152
|
+
GirFFI::Builder.build_class get_introspection_data('Regress', 'TestBoxed')
|
153
|
+
end
|
154
|
+
|
155
|
+
should "set up #wrap" do
|
156
|
+
assert Regress::TestBoxed.respond_to? "wrap"
|
157
|
+
end
|
158
|
+
|
159
|
+
should "set up #allocate" do
|
160
|
+
assert Regress::TestBoxed.respond_to? "allocate"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe "built Regress module" do
|
165
|
+
before do
|
166
|
+
save_module :Regress
|
167
|
+
GirFFI::Builder.build_module 'Regress'
|
168
|
+
end
|
169
|
+
|
170
|
+
should "autocreate singleton methods" do
|
171
|
+
refute_defines_singleton_method Regress, :test_uint
|
172
|
+
Regress.test_uint 31
|
173
|
+
assert_defines_singleton_method Regress, :test_uint
|
174
|
+
end
|
175
|
+
|
176
|
+
should "autocreate the TestObj class" do
|
177
|
+
assert !Regress.const_defined?(:TestObj)
|
178
|
+
assert_nothing_raised {Regress::TestObj}
|
179
|
+
assert Regress.const_defined? :TestObj
|
180
|
+
end
|
181
|
+
|
182
|
+
should "know its own module builder" do
|
183
|
+
assert GirFFI::Builder::Module === Regress._builder
|
184
|
+
end
|
185
|
+
|
186
|
+
after do
|
187
|
+
restore_module :Regress
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "built Regress::TestObj" do
|
192
|
+
before do
|
193
|
+
save_module :Regress
|
194
|
+
GirFFI::Builder.build_class get_introspection_data('Regress', 'TestObj')
|
195
|
+
end
|
196
|
+
|
197
|
+
should "make autocreated instance method available to all instances" do
|
198
|
+
o1 = Regress::TestObj.new_from_file("foo")
|
199
|
+
o2 = Regress::TestObj.new_from_file("foo")
|
200
|
+
o1.instance_method
|
201
|
+
Regress::TestObj.class_eval do
|
202
|
+
undef method_missing
|
203
|
+
end
|
204
|
+
assert_nothing_raised { o2.instance_method }
|
205
|
+
end
|
206
|
+
|
207
|
+
should "attach C functions to Regress::Lib" do
|
208
|
+
o = Regress::TestObj.new_from_file("foo")
|
209
|
+
o.instance_method
|
210
|
+
assert Regress::Lib.respond_to? :regress_test_obj_instance_method
|
211
|
+
end
|
212
|
+
|
213
|
+
should "know its own GIR info" do
|
214
|
+
assert_equal 'TestObj', Regress::TestObj.gir_info.name
|
215
|
+
end
|
216
|
+
|
217
|
+
should "know its own class builder" do
|
218
|
+
assert GirFFI::Builder::Type::Base === Regress::TestObj._builder
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "its #torture_signature_0 method" do
|
222
|
+
should "have the correct types of the arguments for the attached function" do
|
223
|
+
info = get_method_introspection_data 'Regress', 'TestObj',
|
224
|
+
'torture_signature_0'
|
225
|
+
assert_equal [:pointer, :int32, :pointer, :pointer, :pointer, :pointer, :uint32],
|
226
|
+
GirFFI::Builder.send(:ffi_function_argument_types, info)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
after do
|
231
|
+
restore_module :Regress
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe "built Regress::TestSubObj" do
|
236
|
+
before do
|
237
|
+
save_module :Regress
|
238
|
+
GirFFI::Builder.build_class get_introspection_data('Regress', 'TestSubObj')
|
239
|
+
end
|
240
|
+
|
241
|
+
should "autocreate parent class' set_bare inside the parent class" do
|
242
|
+
o1 = Regress::TestSubObj.new
|
243
|
+
o2 = Regress::TestObj.new_from_file("foo")
|
244
|
+
|
245
|
+
assert_nothing_raised {o1.set_bare(nil)}
|
246
|
+
|
247
|
+
Regress::TestObj.class_eval do
|
248
|
+
undef method_missing
|
249
|
+
end
|
250
|
+
|
251
|
+
assert_nothing_raised {o2.set_bare(nil)}
|
252
|
+
end
|
253
|
+
|
254
|
+
should "use its own version of instance_method when parent's version has been created" do
|
255
|
+
obj = Regress::TestObj.new_from_file("foo")
|
256
|
+
assert_equal(-1, obj.instance_method)
|
257
|
+
subobj = Regress::TestSubObj.new
|
258
|
+
assert_equal 0, subobj.instance_method
|
259
|
+
end
|
260
|
+
|
261
|
+
after do
|
262
|
+
restore_module :Regress
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
describe "built Gio::ThreadedSocketService" do
|
267
|
+
before do
|
268
|
+
save_module :Gio
|
269
|
+
GirFFI::Builder.build_module 'Gio'
|
270
|
+
end
|
271
|
+
|
272
|
+
describe "when parent constructor has been called" do
|
273
|
+
setup do
|
274
|
+
Gio::SocketService.new
|
275
|
+
end
|
276
|
+
|
277
|
+
should "still use its own constructor" do
|
278
|
+
assert_nothing_raised { Gio::ThreadedSocketService.new 2 }
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
after do
|
283
|
+
restore_module :Gio
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
describe "building Regress::TestSubObj" do
|
288
|
+
before do
|
289
|
+
save_module :Regress
|
290
|
+
save_module :GObject
|
291
|
+
GirFFI::Builder.build_class get_introspection_data('Regress', 'TestSubObj')
|
292
|
+
end
|
293
|
+
|
294
|
+
it "builds Regress namespace" do
|
295
|
+
assert Regress.const_defined? :Lib
|
296
|
+
assert Regress.respond_to? :method_missing
|
297
|
+
end
|
298
|
+
|
299
|
+
it "builds parent classes also" do
|
300
|
+
assert Regress.const_defined? :TestObj
|
301
|
+
assert Object.const_defined? :GObject
|
302
|
+
assert GObject.const_defined? :Object
|
303
|
+
end
|
304
|
+
|
305
|
+
it "sets up the inheritance chain" do
|
306
|
+
ancestors = Regress::TestSubObj.ancestors
|
307
|
+
assert_equal [
|
308
|
+
Regress::TestSubObj,
|
309
|
+
Regress::TestObj,
|
310
|
+
GObject::Object
|
311
|
+
], ancestors[0..2]
|
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
|
+
restore_module :GObject
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
describe "building Regress" do
|
325
|
+
before do
|
326
|
+
save_module :Regress
|
327
|
+
GirFFI::Builder.build_module 'Regress'
|
328
|
+
end
|
329
|
+
|
330
|
+
it "creates a Lib module ready to attach functions from the shared library" do
|
331
|
+
gir = GObjectIntrospection::IRepository.default
|
332
|
+
expected = [gir.shared_library('Regress')]
|
333
|
+
assert_equal expected, Regress::Lib.ffi_libraries.map(&:name)
|
334
|
+
end
|
335
|
+
|
336
|
+
it "creates an array CALLBACKS inside the Regress::Lib module" do
|
337
|
+
assert_equal [], Regress::Lib::CALLBACKS
|
338
|
+
end
|
339
|
+
|
340
|
+
it "does not replace existing module" do
|
341
|
+
oldmodule = Regress
|
342
|
+
GirFFI::Builder.build_module 'Regress'
|
343
|
+
assert_equal oldmodule, Regress
|
344
|
+
end
|
345
|
+
|
346
|
+
it "does not replace existing Lib module" do
|
347
|
+
oldmodule = Regress::Lib
|
348
|
+
GirFFI::Builder.build_module 'Regress'
|
349
|
+
assert_equal oldmodule, Regress::Lib
|
350
|
+
end
|
351
|
+
|
352
|
+
after do
|
353
|
+
restore_module :Regress
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
describe "looking at Regress.test_array_gint32_in" do
|
358
|
+
setup do
|
359
|
+
save_module :Regress
|
360
|
+
GirFFI::Builder.build_module 'Regress'
|
361
|
+
@go = get_introspection_data 'Regress', 'test_array_gint32_in'
|
362
|
+
end
|
363
|
+
|
364
|
+
it "has correct introspection data" do
|
365
|
+
gir = GObjectIntrospection::IRepository.default
|
366
|
+
gir.require "Regress", nil
|
367
|
+
go2 = gir.find_by_name "Regress", "test_array_gint32_in"
|
368
|
+
assert_equal go2, @go
|
369
|
+
end
|
370
|
+
|
371
|
+
it "attaches function to Regress::Lib" do
|
372
|
+
GirFFI::Builder.send :attach_ffi_function, Regress::Lib, @go
|
373
|
+
assert_defines_singleton_method Regress::Lib, :regress_test_array_gint32_in
|
374
|
+
end
|
375
|
+
|
376
|
+
it "has :pointer, :pointer as types of the arguments for the attached function" do
|
377
|
+
assert_equal [:int32, :pointer], GirFFI::Builder.send(:ffi_function_argument_types, @go)
|
378
|
+
end
|
379
|
+
|
380
|
+
it "has :void as return type for the attached function" do
|
381
|
+
assert_equal :int32, GirFFI::Builder.send(:ffi_function_return_type, @go)
|
382
|
+
end
|
383
|
+
|
384
|
+
after do
|
385
|
+
restore_module :Regress
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
describe "looking at Regress::TestObj#instance_method" do
|
390
|
+
setup do
|
391
|
+
@go = get_method_introspection_data 'Regress', 'TestObj', 'instance_method'
|
392
|
+
end
|
393
|
+
|
394
|
+
it "has :pointer as types of the arguments for the attached function" do
|
395
|
+
assert_equal [:pointer], GirFFI::Builder.send(:ffi_function_argument_types, @go)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|