gir_ffi 0.7.5 → 0.7.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 +17 -1
- data/README.md +1 -1
- data/Rakefile +0 -7
- data/examples/main_loop.rb +12 -0
- data/lib/ffi-glib/array.rb +18 -5
- data/lib/ffi-glib/array_methods.rb +1 -1
- data/lib/ffi-glib/list.rb +1 -1
- data/lib/ffi-glib/list_methods.rb +1 -1
- data/lib/ffi-glib/main_loop.rb +51 -0
- data/lib/ffi-glib/ptr_array.rb +2 -2
- data/lib/ffi-glib/s_list.rb +1 -1
- data/lib/ffi-glib/variant.rb +3 -3
- data/lib/ffi-glib.rb +1 -0
- data/lib/ffi-gobject/initially_unowned.rb +1 -1
- data/lib/ffi-gobject/object.rb +14 -12
- data/lib/ffi-gobject/ruby_closure.rb +3 -2
- data/lib/ffi-gobject/value.rb +12 -16
- data/lib/ffi-gobject.rb +4 -21
- data/lib/ffi-gobject_introspection/i_base_info.rb +3 -3
- data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_repository.rb +1 -1
- data/lib/ffi-gobject_introspection/lib.rb +1 -1
- data/lib/gir_ffi/arg_helper.rb +2 -2
- data/lib/gir_ffi/builder.rb +1 -1
- data/lib/gir_ffi/builders/argument_builder.rb +19 -17
- data/lib/gir_ffi/builders/argument_builder_collection.rb +51 -16
- data/lib/gir_ffi/builders/base_argument_builder.rb +20 -10
- data/lib/gir_ffi/builders/base_type_builder.rb +6 -5
- data/lib/gir_ffi/builders/callback_argument_builder.rb +5 -5
- data/lib/gir_ffi/builders/callback_builder.rb +0 -4
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +11 -11
- data/lib/gir_ffi/builders/constant_builder.rb +2 -4
- data/lib/gir_ffi/builders/enum_builder.rb +7 -7
- data/lib/gir_ffi/builders/error_argument_builder.rb +16 -4
- data/lib/gir_ffi/builders/field_builder.rb +5 -17
- data/lib/gir_ffi/builders/function_builder.rb +36 -86
- data/lib/gir_ffi/builders/interface_builder.rb +2 -7
- data/lib/gir_ffi/builders/mapping_method_builder.rb +42 -33
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +44 -33
- data/lib/gir_ffi/builders/method_template.rb +81 -0
- data/lib/gir_ffi/builders/module_builder.rb +5 -5
- data/lib/gir_ffi/builders/object_builder.rb +44 -25
- data/lib/gir_ffi/builders/property_builder.rb +6 -2
- data/lib/gir_ffi/builders/registered_type_builder.rb +1 -5
- data/lib/gir_ffi/builders/return_value_builder.rb +20 -15
- data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -6
- data/lib/gir_ffi/builders/type_builder.rb +1 -1
- data/lib/gir_ffi/builders/unintrospectable_builder.rb +1 -5
- data/lib/gir_ffi/builders/user_defined_builder.rb +17 -21
- data/lib/gir_ffi/builders/vfunc_builder.rb +3 -6
- data/lib/gir_ffi/builders/with_layout.rb +2 -6
- data/lib/gir_ffi/callback_base.rb +10 -5
- data/lib/gir_ffi/class_base.rb +4 -7
- data/lib/gir_ffi/enum_base.rb +1 -1
- data/lib/gir_ffi/g_type.rb +21 -19
- data/lib/gir_ffi/in_out_pointer.rb +2 -4
- data/lib/gir_ffi/in_pointer.rb +9 -8
- data/lib/gir_ffi/info_ext/i_field_info.rb +1 -3
- data/lib/gir_ffi/info_ext/i_signal_info.rb +4 -4
- data/lib/gir_ffi/info_ext/i_type_info.rb +6 -6
- data/lib/gir_ffi/module_base.rb +3 -2
- data/lib/gir_ffi/object_base.rb +1 -1
- data/lib/gir_ffi/struct_base.rb +1 -1
- data/lib/gir_ffi/type_base.rb +2 -2
- data/lib/gir_ffi/unintrospectable_type_info.rb +2 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi/zero_terminated.rb +1 -1
- data/lib/gir_ffi-base/glib/strv.rb +2 -2
- data/lib/gir_ffi.rb +1 -1
- data/test/ffi-glib/array_test.rb +28 -0
- data/test/ffi-glib/byte_array_test.rb +1 -1
- data/test/ffi-glib/bytes_test.rb +1 -1
- data/test/ffi-gobject/object_test.rb +11 -1
- data/test/ffi-gobject/value_test.rb +12 -1
- data/test/ffi-gobject_introspection/i_base_info_test.rb +14 -0
- data/test/ffi-gobject_introspection/i_object_info_test.rb +8 -6
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +24 -0
- data/test/ffi-gobject_introspection/i_type_info_test.rb +17 -0
- data/test/gir_ffi/builder_test.rb +3 -2
- data/test/gir_ffi/builders/argument_builder_test.rb +2 -2
- data/test/gir_ffi/builders/function_builder_test.rb +27 -27
- data/test/gir_ffi/builders/object_builder_test.rb +10 -0
- data/test/gir_ffi/builders/return_value_builder_test.rb +3 -3
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +6 -6
- data/test/gir_ffi/in_out_pointer_test.rb +0 -2
- data/test/gir_ffi/info_ext/i_type_info_test.rb +1 -1
- data/test/gir_ffi_test_helper.rb +0 -4
- data/test/integration/generated_gimarshallingtests_test.rb +1 -1
- data/test/integration/generated_regress_test.rb +2 -2
- data/test/integration/idle_loop_test.rb +25 -0
- data/test/minitest/stats_plugin.rb +26 -0
- metadata +13 -62
- data/lib/gir_ffi/builders/null_argument_builder.rb +0 -12
- data/lib/gir_ffi/builders/null_builder.rb +0 -12
- data/tasks/yard.rake +0 -6
data/test/ffi-glib/bytes_test.rb
CHANGED
@@ -35,13 +35,23 @@ describe GObject::Object do
|
|
35
35
|
|
36
36
|
describe "#signal_connect" do
|
37
37
|
subject { GObject::Object.new GObject::TYPE_OBJECT, nil }
|
38
|
+
|
38
39
|
it 'delegates to GObject' do
|
39
|
-
mock(GObject).signal_connect(subject, 'some-event')
|
40
|
+
mock(GObject).signal_connect(subject, 'some-event', nil)
|
40
41
|
subject.signal_connect('some-event') do
|
41
42
|
nothing
|
42
43
|
end
|
43
44
|
|
44
45
|
RR.verify
|
45
46
|
end
|
47
|
+
|
48
|
+
it 'delegates to GObject if an optional data argument is passed' do
|
49
|
+
mock(GObject).signal_connect(subject, 'some-event', 'data')
|
50
|
+
subject.signal_connect('some-event', 'data') do
|
51
|
+
nothing
|
52
|
+
end
|
53
|
+
|
54
|
+
RR.verify
|
55
|
+
end
|
46
56
|
end
|
47
57
|
end
|
@@ -200,7 +200,7 @@ describe GObject::Value do
|
|
200
200
|
|
201
201
|
it "works with a ByteArray" do
|
202
202
|
ba = GLib::ByteArray.new.append("some bytes")
|
203
|
-
v = GObject::Value.for_g_type GObject
|
203
|
+
v = GObject::Value.for_g_type GObject::TYPE_BYTE_ARRAY
|
204
204
|
v.set_boxed ba
|
205
205
|
|
206
206
|
result = v.get_value
|
@@ -208,6 +208,17 @@ describe GObject::Value do
|
|
208
208
|
result.to_string.must_equal "some bytes"
|
209
209
|
result.must_be_kind_of GLib::ByteArray
|
210
210
|
end
|
211
|
+
|
212
|
+
it "works with an Array" do
|
213
|
+
arr = GLib::Array.from(:uint, [1, 2, 3])
|
214
|
+
v = GObject::Value.for_g_type GObject::TYPE_ARRAY
|
215
|
+
v.set_boxed arr
|
216
|
+
|
217
|
+
result = v.get_value
|
218
|
+
|
219
|
+
result.must_be_kind_of GLib::Array
|
220
|
+
result.reset_typespec(:uint).to_a.must_equal [1, 2, 3]
|
221
|
+
end
|
211
222
|
end
|
212
223
|
|
213
224
|
describe "::from" do
|
@@ -15,6 +15,20 @@ describe GObjectIntrospection::IBaseInfo do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
describe "#deprecated?" do
|
19
|
+
let(:deprecated_info) { get_introspection_data 'Regress', 'test_versioning' }
|
20
|
+
let(:other_info) { get_introspection_data 'Regress', 'test_value_return' }
|
21
|
+
|
22
|
+
it "returns true for a deprecated item" do
|
23
|
+
skip unless deprecated_info
|
24
|
+
deprecated_info.must_be :deprecated?
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns false for a non-deprecated item" do
|
28
|
+
other_info.wont_be :deprecated?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
18
32
|
describe "upon garbage collection" do
|
19
33
|
it "calls g_base_info_unref" do
|
20
34
|
if defined?(RUBY_ENGINE) && ['jruby', 'rbx'].include?(RUBY_ENGINE)
|
@@ -1,15 +1,17 @@
|
|
1
1
|
require 'introspection_test_helper'
|
2
2
|
|
3
3
|
describe GObjectIntrospection::IObjectInfo do
|
4
|
+
let(:object_info) { get_introspection_data('GObject', 'Object') }
|
5
|
+
|
4
6
|
describe "#find_vfunc" do
|
5
|
-
|
6
|
-
|
7
|
-
gir.require 'GObject', nil
|
8
|
-
@info = gir.find_by_name 'GObject', 'Object'
|
7
|
+
it "finds a vfunc by name" do
|
8
|
+
object_info.find_vfunc("finalize").wont_be_nil
|
9
9
|
end
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
describe "#type_name" do
|
13
|
+
it "returns the correct name" do
|
14
|
+
object_info.type_name.must_equal 'GObject'
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'introspection_test_helper'
|
2
|
+
|
3
|
+
describe GObjectIntrospection::IRegisteredTypeInfo do
|
4
|
+
describe "#get_type_name" do
|
5
|
+
describe "for an interface" do
|
6
|
+
let(:registered_type_info) {
|
7
|
+
get_introspection_data('GIMarshallingTests', 'Interface') }
|
8
|
+
|
9
|
+
it "returns interface name" do
|
10
|
+
registered_type_info.type_name.must_equal 'GIMarshallingTestsInterface'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "for a type that is not an interface" do
|
15
|
+
let(:registered_type_info) {
|
16
|
+
get_introspection_data('GIMarshallingTests', 'Enum') }
|
17
|
+
|
18
|
+
it "returns nil" do
|
19
|
+
registered_type_info.type_name.must_be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'introspection_test_helper'
|
2
|
+
|
3
|
+
describe GObjectIntrospection::ITypeInfo do
|
4
|
+
describe "#name?" do
|
5
|
+
let(:object_info) { get_introspection_data('GIMarshallingTests', 'Object') }
|
6
|
+
let(:vfunc_info) { object_info.find_vfunc('vfunc_array_out_parameter') }
|
7
|
+
let(:arg_info) { vfunc_info.args[0] }
|
8
|
+
let(:type_info) { arg_info.argument_type }
|
9
|
+
|
10
|
+
it "raises an error" do
|
11
|
+
skip unless vfunc_info
|
12
|
+
proc {
|
13
|
+
type_info.name
|
14
|
+
}.must_raise RuntimeError
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -161,9 +161,10 @@ describe GirFFI::Builder do
|
|
161
161
|
GirFFI::Builder.build_class get_introspection_data('Regress', 'TestSubObj')
|
162
162
|
end
|
163
163
|
|
164
|
-
it "
|
164
|
+
it "sets up the Regress namespace" do
|
165
165
|
assert Regress.const_defined? :Lib
|
166
|
-
assert Regress.respond_to? :
|
166
|
+
assert Regress.respond_to? :gir_ffi_builder
|
167
|
+
assert Regress.const_defined? :GIR_FFI_BUILDER
|
167
168
|
end
|
168
169
|
|
169
170
|
it "creates the Regress::Lib module ready to attach functions from the shared library" do
|
@@ -36,7 +36,7 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
36
36
|
|
37
37
|
describe "when it is a regular argument" do
|
38
38
|
before do
|
39
|
-
builder.
|
39
|
+
builder.closure = false
|
40
40
|
end
|
41
41
|
|
42
42
|
it "has the correct value for #pre_conversion" do
|
@@ -50,7 +50,7 @@ describe GirFFI::Builders::ArgumentBuilder do
|
|
50
50
|
|
51
51
|
describe "when it is a closure" do
|
52
52
|
before do
|
53
|
-
builder.
|
53
|
+
builder.closure = true
|
54
54
|
end
|
55
55
|
|
56
56
|
it "has the correct value for #pre_conversion" do
|
@@ -8,7 +8,7 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
8
8
|
code = fbuilder.generate
|
9
9
|
|
10
10
|
expected = <<-CODE
|
11
|
-
def self.test_array_fixed_out_objects
|
11
|
+
def self.test_array_fixed_out_objects
|
12
12
|
_v1 = GirFFI::InOutPointer.for [:pointer, :c]
|
13
13
|
Regress::Lib.regress_test_array_fixed_out_objects _v1
|
14
14
|
_v2 = GirFFI::SizedArray.wrap([:pointer, Regress::TestObj], 2, _v1.to_value)
|
@@ -25,7 +25,7 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
25
25
|
code = fbuilder.generate
|
26
26
|
|
27
27
|
expected = <<-CODE
|
28
|
-
def self.test_array_gint16_in
|
28
|
+
def self.test_array_gint16_in(ints)
|
29
29
|
n_ints = ints.nil? ? 0 : ints.length
|
30
30
|
_v1 = n_ints
|
31
31
|
_v2 = GirFFI::SizedArray.from(:gint16, -1, ints)
|
@@ -43,7 +43,7 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
43
43
|
code = fbuilder.generate
|
44
44
|
|
45
45
|
expected = <<-CODE
|
46
|
-
def self.test_callback_destroy_notify
|
46
|
+
def self.test_callback_destroy_notify(callback, user_data, notify)
|
47
47
|
_v1 = Regress::TestCallbackUserData.from(callback)
|
48
48
|
_v2 = GirFFI::InPointer.from_closure_data(user_data)
|
49
49
|
_v3 = GLib::DestroyNotify.from(notify)
|
@@ -61,7 +61,7 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
61
61
|
code = fbuilder.generate
|
62
62
|
|
63
63
|
expected = <<-CODE
|
64
|
-
def self.new_from_file
|
64
|
+
def self.new_from_file(x)
|
65
65
|
_v1 = GirFFI::InPointer.from(:utf8, x)
|
66
66
|
_v2 = FFI::MemoryPointer.new(:pointer).write_pointer nil
|
67
67
|
_v3 = Regress::Lib.regress_test_obj_new_from_file _v1, _v2
|
@@ -80,7 +80,7 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
80
80
|
code = fbuilder.generate
|
81
81
|
|
82
82
|
expected = <<-CODE
|
83
|
-
def self.gvalue_in
|
83
|
+
def self.gvalue_in(value)
|
84
84
|
_v1 = GObject::Value.from(value)
|
85
85
|
GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_in _v1
|
86
86
|
end
|
@@ -95,11 +95,11 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
95
95
|
code = fbuilder.generate
|
96
96
|
|
97
97
|
expected = <<-CODE
|
98
|
-
def self.test_array_int_null_in
|
99
|
-
_v1 = GirFFI::SizedArray.from(:gint32, -1, arr)
|
98
|
+
def self.test_array_int_null_in(arr)
|
100
99
|
len = arr.nil? ? 0 : arr.length
|
101
|
-
|
102
|
-
|
100
|
+
_v1 = len
|
101
|
+
_v2 = GirFFI::SizedArray.from(:gint32, -1, arr)
|
102
|
+
Regress::Lib.regress_test_array_int_null_in _v2, _v1
|
103
103
|
end
|
104
104
|
CODE
|
105
105
|
|
@@ -112,12 +112,12 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
112
112
|
code = fbuilder.generate
|
113
113
|
|
114
114
|
expected = <<-CODE
|
115
|
-
def self.test_array_int_null_out
|
116
|
-
_v1 = GirFFI::InOutPointer.for
|
117
|
-
_v2 = GirFFI::InOutPointer.for :
|
118
|
-
Regress::Lib.regress_test_array_int_null_out
|
119
|
-
_v3 =
|
120
|
-
_v4 = GirFFI::SizedArray.wrap(:gint32, _v3,
|
115
|
+
def self.test_array_int_null_out
|
116
|
+
_v1 = GirFFI::InOutPointer.for :gint32
|
117
|
+
_v2 = GirFFI::InOutPointer.for [:pointer, :c]
|
118
|
+
Regress::Lib.regress_test_array_int_null_out _v2, _v1
|
119
|
+
_v3 = _v1.to_value
|
120
|
+
_v4 = GirFFI::SizedArray.wrap(:gint32, _v3, _v2.to_value)
|
121
121
|
return _v4
|
122
122
|
end
|
123
123
|
CODE
|
@@ -131,15 +131,15 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
131
131
|
code = fbuilder.generate
|
132
132
|
|
133
133
|
expected = <<-CODE
|
134
|
-
def method_array_inout
|
135
|
-
_v1 = GirFFI::InOutPointer.for [:pointer, :c]
|
136
|
-
_v1.set_value GirFFI::SizedArray.from(:gint32, -1, ints)
|
134
|
+
def method_array_inout(ints)
|
137
135
|
length = ints.nil? ? 0 : ints.length
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
136
|
+
_v1 = GirFFI::InOutPointer.for :gint32
|
137
|
+
_v1.set_value length
|
138
|
+
_v2 = GirFFI::InOutPointer.for [:pointer, :c]
|
139
|
+
_v2.set_value GirFFI::SizedArray.from(:gint32, -1, ints)
|
140
|
+
GIMarshallingTests::Lib.gi_marshalling_tests_object_method_array_inout self, _v2, _v1
|
141
|
+
_v3 = _v1.to_value
|
142
|
+
_v4 = GirFFI::SizedArray.wrap(:gint32, _v3, _v2.to_value)
|
143
143
|
return _v4
|
144
144
|
end
|
145
145
|
CODE
|
@@ -153,7 +153,7 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
153
153
|
code = fbuilder.generate
|
154
154
|
|
155
155
|
expected = <<-CODE
|
156
|
-
def instance_method
|
156
|
+
def instance_method
|
157
157
|
_v1 = Regress::Lib.regress_test_obj_instance_method self
|
158
158
|
return _v1
|
159
159
|
end
|
@@ -171,7 +171,7 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
171
171
|
it "builds a correct definition" do
|
172
172
|
size_type = ":guint#{FFI.type_size(:size_t) * 8}"
|
173
173
|
code.must_equal <<-CODE.reset_indentation
|
174
|
-
def get_strv
|
174
|
+
def get_strv
|
175
175
|
_v1 = GirFFI::InOutPointer.for #{size_type}
|
176
176
|
_v2 = GLib::Lib.g_variant_get_strv self, _v1
|
177
177
|
_v3 = GLib::Strv.wrap(_v2)
|
@@ -187,7 +187,7 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
187
187
|
it "builds a correct definition" do
|
188
188
|
skip unless function_info
|
189
189
|
code.must_equal <<-CODE.reset_indentation
|
190
|
-
def self.has_parameter_named_attrs
|
190
|
+
def self.has_parameter_named_attrs(foo, attributes)
|
191
191
|
_v1 = foo
|
192
192
|
GirFFI::ArgHelper.check_fixed_array_size 32, attributes, \"attributes\"
|
193
193
|
_v2 = GirFFI::SizedArray.from([:pointer, :guint32], 32, attributes)
|
@@ -206,7 +206,7 @@ describe GirFFI::Builders::FunctionBuilder do
|
|
206
206
|
it "builds a correct definition" do
|
207
207
|
skip unless function_info
|
208
208
|
code.must_equal <<-CODE.reset_indentation
|
209
|
-
def method_int8_arg_and_out_callee
|
209
|
+
def method_int8_arg_and_out_callee(arg)
|
210
210
|
_v1 = arg
|
211
211
|
_v2 = GirFFI::InOutPointer.for [:pointer, :gint8]
|
212
212
|
GIMarshallingTests::Lib.gi_marshalling_tests_object_method_int8_arg_and_out_callee self, _v1, _v2
|
@@ -22,6 +22,16 @@ describe GirFFI::Builders::ObjectBuilder do
|
|
22
22
|
sig = builder.find_signal 'changed'
|
23
23
|
sig.name.must_equal 'changed'
|
24
24
|
end
|
25
|
+
|
26
|
+
it "raises an error for a signal that doesn't exist" do
|
27
|
+
msg = nil
|
28
|
+
begin
|
29
|
+
obj_builder.find_signal 'foo'
|
30
|
+
rescue RuntimeError => e
|
31
|
+
msg = e.message
|
32
|
+
end
|
33
|
+
assert_match(/^Signal/, msg)
|
34
|
+
end
|
25
35
|
end
|
26
36
|
|
27
37
|
describe "#find_property" do
|
@@ -329,7 +329,7 @@ describe GirFFI::Builders::ReturnValueBuilder do
|
|
329
329
|
end
|
330
330
|
|
331
331
|
it "marks itself as irrelevant" do
|
332
|
-
builder.
|
332
|
+
builder.relevant?.must_equal false
|
333
333
|
end
|
334
334
|
|
335
335
|
it "returns nothing" do
|
@@ -342,7 +342,7 @@ describe GirFFI::Builders::ReturnValueBuilder do
|
|
342
342
|
get_introspection_data("Regress", "TestCallbackUserData").args[0].argument_type }
|
343
343
|
|
344
344
|
before do
|
345
|
-
builder.
|
345
|
+
builder.closure = true
|
346
346
|
end
|
347
347
|
|
348
348
|
it "fetches the stored object in #post_conversion" do
|
@@ -366,7 +366,7 @@ describe GirFFI::Builders::ReturnValueBuilder do
|
|
366
366
|
end
|
367
367
|
|
368
368
|
it "marks itself as irrelevant" do
|
369
|
-
builder.
|
369
|
+
builder.relevant?.must_equal false
|
370
370
|
end
|
371
371
|
|
372
372
|
it "returns nothing" do
|
@@ -21,7 +21,7 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
21
21
|
it "returns a valid marshaller converting only the receiver" do
|
22
22
|
expected = <<-CODE.reset_indentation
|
23
23
|
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
24
|
-
_instance
|
24
|
+
_instance = param_values.first.get_value_plain
|
25
25
|
_v1 = _instance
|
26
26
|
wrap(closure.to_ptr).invoke_block(_v1)
|
27
27
|
end
|
@@ -40,7 +40,7 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
40
40
|
|
41
41
|
expected = <<-CODE.reset_indentation
|
42
42
|
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
43
|
-
_instance, i
|
43
|
+
_instance, i = param_values.map(&:get_value_plain)
|
44
44
|
_v1 = _instance
|
45
45
|
_v2 = i
|
46
46
|
_v3 = wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
@@ -59,7 +59,7 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
59
59
|
it "returns a valid mapping method" do
|
60
60
|
expected = <<-CODE.reset_indentation
|
61
61
|
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
62
|
-
_instance, result
|
62
|
+
_instance, result = param_values.map(&:get_value_plain)
|
63
63
|
_v1 = _instance
|
64
64
|
_v2 = result
|
65
65
|
wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
@@ -79,7 +79,7 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
79
79
|
|
80
80
|
expected = <<-CODE.reset_indentation
|
81
81
|
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
82
|
-
_instance, arr, len
|
82
|
+
_instance, arr, len = param_values.map(&:get_value_plain)
|
83
83
|
_v1 = _instance
|
84
84
|
_v2 = len
|
85
85
|
_v3 = GirFFI::SizedArray.wrap(:guint32, _v2, arr)
|
@@ -100,7 +100,7 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
100
100
|
|
101
101
|
expected = <<-CODE.reset_indentation
|
102
102
|
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
103
|
-
_instance, object
|
103
|
+
_instance, object = param_values.map(&:get_value_plain)
|
104
104
|
_v1 = _instance
|
105
105
|
_v2 = Regress::TestSimpleBoxedA.wrap(object)
|
106
106
|
wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
@@ -120,7 +120,7 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
120
120
|
|
121
121
|
expected = <<-CODE.reset_indentation
|
122
122
|
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
123
|
-
_instance, i
|
123
|
+
_instance, i = param_values.map(&:get_value_plain)
|
124
124
|
_v1 = _instance
|
125
125
|
_v2 = i
|
126
126
|
_v3 = wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
@@ -408,7 +408,7 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
408
408
|
stub(type_info).interface { interface_type_info }
|
409
409
|
end
|
410
410
|
|
411
|
-
it "
|
411
|
+
it "returns an empty array" do
|
412
412
|
type_info.extra_conversion_arguments.must_equal []
|
413
413
|
end
|
414
414
|
end
|
data/test/gir_ffi_test_helper.rb
CHANGED
@@ -59,10 +59,6 @@ class Minitest::Test
|
|
59
59
|
GObject::Object::Struct.new(object.to_ptr)[:ref_count]
|
60
60
|
end
|
61
61
|
|
62
|
-
def is_floating? object
|
63
|
-
(GObject::Object::Struct.new(object.to_ptr)[:qdata].address & 2) == 2
|
64
|
-
end
|
65
|
-
|
66
62
|
def max_for_unsigned_type type
|
67
63
|
( 1 << (FFI.type_size(type) * 8) ) - 1
|
68
64
|
end
|
@@ -242,7 +242,7 @@ describe GIMarshallingTests do
|
|
242
242
|
it "has the member :value2" do
|
243
243
|
assert_equal 2, GIMarshallingTests::NoTypeFlags[:value2]
|
244
244
|
end
|
245
|
-
it "has the member :
|
245
|
+
it "has the member :value3" do
|
246
246
|
assert_equal 4, GIMarshallingTests::NoTypeFlags[:value3]
|
247
247
|
end
|
248
248
|
it "has the member :mask" do
|
@@ -435,7 +435,7 @@ describe Regress do
|
|
435
435
|
end
|
436
436
|
|
437
437
|
it "has been sunk" do
|
438
|
-
|
438
|
+
@o.wont_be :floating?
|
439
439
|
end
|
440
440
|
end
|
441
441
|
end
|
@@ -564,7 +564,7 @@ describe Regress do
|
|
564
564
|
end
|
565
565
|
|
566
566
|
it "does not float" do
|
567
|
-
|
567
|
+
instance.wont_be :floating?
|
568
568
|
end
|
569
569
|
|
570
570
|
it "has a working method #matrix" do
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'gir_ffi_test_helper'
|
2
|
+
|
3
|
+
describe "threading" do
|
4
|
+
it "works while a MainLoop is running" do
|
5
|
+
main_loop = GLib::MainLoop.new nil, false
|
6
|
+
|
7
|
+
a = []
|
8
|
+
GLib.timeout_add(GLib::PRIORITY_DEFAULT, 100,
|
9
|
+
proc { main_loop.quit },
|
10
|
+
nil, nil)
|
11
|
+
|
12
|
+
slow_thread = Thread.new do
|
13
|
+
sleep 0.001
|
14
|
+
a << "During run"
|
15
|
+
end
|
16
|
+
|
17
|
+
a << "Before run"
|
18
|
+
main_loop.run
|
19
|
+
a << "After run"
|
20
|
+
|
21
|
+
slow_thread.join
|
22
|
+
|
23
|
+
a.last.must_equal "After run"
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Minitest
|
2
|
+
class StatsReporter < AbstractReporter
|
3
|
+
def initialize _options
|
4
|
+
@results = []
|
5
|
+
end
|
6
|
+
|
7
|
+
def start
|
8
|
+
@current_time = Time.now
|
9
|
+
end
|
10
|
+
|
11
|
+
def record result
|
12
|
+
@results << result
|
13
|
+
end
|
14
|
+
|
15
|
+
def report
|
16
|
+
slowest = @results.sort_by(&:time).reverse.first(10)
|
17
|
+
slowest.each do |result|
|
18
|
+
puts "%10.4f %s" % [result.time, result.location]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.plugin_stats_init(options)
|
24
|
+
self.reporter << StatsReporter.new(options)
|
25
|
+
end
|
26
|
+
end
|