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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +17 -1
  3. data/README.md +1 -1
  4. data/Rakefile +0 -7
  5. data/examples/main_loop.rb +12 -0
  6. data/lib/ffi-glib/array.rb +18 -5
  7. data/lib/ffi-glib/array_methods.rb +1 -1
  8. data/lib/ffi-glib/list.rb +1 -1
  9. data/lib/ffi-glib/list_methods.rb +1 -1
  10. data/lib/ffi-glib/main_loop.rb +51 -0
  11. data/lib/ffi-glib/ptr_array.rb +2 -2
  12. data/lib/ffi-glib/s_list.rb +1 -1
  13. data/lib/ffi-glib/variant.rb +3 -3
  14. data/lib/ffi-glib.rb +1 -0
  15. data/lib/ffi-gobject/initially_unowned.rb +1 -1
  16. data/lib/ffi-gobject/object.rb +14 -12
  17. data/lib/ffi-gobject/ruby_closure.rb +3 -2
  18. data/lib/ffi-gobject/value.rb +12 -16
  19. data/lib/ffi-gobject.rb +4 -21
  20. data/lib/ffi-gobject_introspection/i_base_info.rb +3 -3
  21. data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -1
  22. data/lib/ffi-gobject_introspection/i_repository.rb +1 -1
  23. data/lib/ffi-gobject_introspection/lib.rb +1 -1
  24. data/lib/gir_ffi/arg_helper.rb +2 -2
  25. data/lib/gir_ffi/builder.rb +1 -1
  26. data/lib/gir_ffi/builders/argument_builder.rb +19 -17
  27. data/lib/gir_ffi/builders/argument_builder_collection.rb +51 -16
  28. data/lib/gir_ffi/builders/base_argument_builder.rb +20 -10
  29. data/lib/gir_ffi/builders/base_type_builder.rb +6 -5
  30. data/lib/gir_ffi/builders/callback_argument_builder.rb +5 -5
  31. data/lib/gir_ffi/builders/callback_builder.rb +0 -4
  32. data/lib/gir_ffi/builders/callback_return_value_builder.rb +11 -11
  33. data/lib/gir_ffi/builders/constant_builder.rb +2 -4
  34. data/lib/gir_ffi/builders/enum_builder.rb +7 -7
  35. data/lib/gir_ffi/builders/error_argument_builder.rb +16 -4
  36. data/lib/gir_ffi/builders/field_builder.rb +5 -17
  37. data/lib/gir_ffi/builders/function_builder.rb +36 -86
  38. data/lib/gir_ffi/builders/interface_builder.rb +2 -7
  39. data/lib/gir_ffi/builders/mapping_method_builder.rb +42 -33
  40. data/lib/gir_ffi/builders/marshalling_method_builder.rb +44 -33
  41. data/lib/gir_ffi/builders/method_template.rb +81 -0
  42. data/lib/gir_ffi/builders/module_builder.rb +5 -5
  43. data/lib/gir_ffi/builders/object_builder.rb +44 -25
  44. data/lib/gir_ffi/builders/property_builder.rb +6 -2
  45. data/lib/gir_ffi/builders/registered_type_builder.rb +1 -5
  46. data/lib/gir_ffi/builders/return_value_builder.rb +20 -15
  47. data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -6
  48. data/lib/gir_ffi/builders/type_builder.rb +1 -1
  49. data/lib/gir_ffi/builders/unintrospectable_builder.rb +1 -5
  50. data/lib/gir_ffi/builders/user_defined_builder.rb +17 -21
  51. data/lib/gir_ffi/builders/vfunc_builder.rb +3 -6
  52. data/lib/gir_ffi/builders/with_layout.rb +2 -6
  53. data/lib/gir_ffi/callback_base.rb +10 -5
  54. data/lib/gir_ffi/class_base.rb +4 -7
  55. data/lib/gir_ffi/enum_base.rb +1 -1
  56. data/lib/gir_ffi/g_type.rb +21 -19
  57. data/lib/gir_ffi/in_out_pointer.rb +2 -4
  58. data/lib/gir_ffi/in_pointer.rb +9 -8
  59. data/lib/gir_ffi/info_ext/i_field_info.rb +1 -3
  60. data/lib/gir_ffi/info_ext/i_signal_info.rb +4 -4
  61. data/lib/gir_ffi/info_ext/i_type_info.rb +6 -6
  62. data/lib/gir_ffi/module_base.rb +3 -2
  63. data/lib/gir_ffi/object_base.rb +1 -1
  64. data/lib/gir_ffi/struct_base.rb +1 -1
  65. data/lib/gir_ffi/type_base.rb +2 -2
  66. data/lib/gir_ffi/unintrospectable_type_info.rb +2 -0
  67. data/lib/gir_ffi/version.rb +1 -1
  68. data/lib/gir_ffi/zero_terminated.rb +1 -1
  69. data/lib/gir_ffi-base/glib/strv.rb +2 -2
  70. data/lib/gir_ffi.rb +1 -1
  71. data/test/ffi-glib/array_test.rb +28 -0
  72. data/test/ffi-glib/byte_array_test.rb +1 -1
  73. data/test/ffi-glib/bytes_test.rb +1 -1
  74. data/test/ffi-gobject/object_test.rb +11 -1
  75. data/test/ffi-gobject/value_test.rb +12 -1
  76. data/test/ffi-gobject_introspection/i_base_info_test.rb +14 -0
  77. data/test/ffi-gobject_introspection/i_object_info_test.rb +8 -6
  78. data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +24 -0
  79. data/test/ffi-gobject_introspection/i_type_info_test.rb +17 -0
  80. data/test/gir_ffi/builder_test.rb +3 -2
  81. data/test/gir_ffi/builders/argument_builder_test.rb +2 -2
  82. data/test/gir_ffi/builders/function_builder_test.rb +27 -27
  83. data/test/gir_ffi/builders/object_builder_test.rb +10 -0
  84. data/test/gir_ffi/builders/return_value_builder_test.rb +3 -3
  85. data/test/gir_ffi/builders/signal_closure_builder_test.rb +6 -6
  86. data/test/gir_ffi/in_out_pointer_test.rb +0 -2
  87. data/test/gir_ffi/info_ext/i_type_info_test.rb +1 -1
  88. data/test/gir_ffi_test_helper.rb +0 -4
  89. data/test/integration/generated_gimarshallingtests_test.rb +1 -1
  90. data/test/integration/generated_regress_test.rb +2 -2
  91. data/test/integration/idle_loop_test.rb +25 -0
  92. data/test/minitest/stats_plugin.rb +26 -0
  93. metadata +13 -62
  94. data/lib/gir_ffi/builders/null_argument_builder.rb +0 -12
  95. data/lib/gir_ffi/builders/null_builder.rb +0 -12
  96. data/tasks/yard.rake +0 -6
@@ -1,7 +1,7 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GLib::ByteArray do
4
- it "can succesfully be created with Glib::ByteArray.new" do
4
+ it "can succesfully be created with GLib::ByteArray.new" do
5
5
  ba = GLib::ByteArray.new
6
6
  assert_instance_of GLib::ByteArray, ba
7
7
  end
@@ -1,7 +1,7 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GLib::Bytes do
4
- it "can succesfully be created with Glib::Bytes.new" do
4
+ it "can succesfully be created with GLib::Bytes.new" do
5
5
  bytes = GLib::Bytes.new [1, 2, 3]
6
6
  bytes.must_be_instance_of GLib::Bytes
7
7
  end
@@ -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.type_from_name("GByteArray")
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
- before do
6
- gir = GObjectIntrospection::IRepository.default
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
- it "finds a vfunc by name" do
12
- @info.find_vfunc("finalize").wont_be_nil
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 "builds Regress namespace" do
164
+ it "sets up the Regress namespace" do
165
165
  assert Regress.const_defined? :Lib
166
- assert Regress.respond_to? :method_missing
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.is_closure = false
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.is_closure = true
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 ints
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 callback, user_data, 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 x
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 value
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 arr
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
- _v2 = len
102
- Regress::Lib.regress_test_array_int_null_in _v1, _v2
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 [:pointer, :c]
117
- _v2 = GirFFI::InOutPointer.for :gint32
118
- Regress::Lib.regress_test_array_int_null_out _v1, _v2
119
- _v3 = _v2.to_value
120
- _v4 = GirFFI::SizedArray.wrap(:gint32, _v3, _v1.to_value)
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 ints
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
- _v2 = GirFFI::InOutPointer.for :gint32
139
- _v2.set_value length
140
- GIMarshallingTests::Lib.gi_marshalling_tests_object_method_array_inout self, _v1, _v2
141
- _v3 = _v2.to_value
142
- _v4 = GirFFI::SizedArray.wrap(:gint32, _v3, _v1.to_value)
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 foo, attributes
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 arg
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.is_relevant?.must_equal false
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.is_closure = true
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.is_relevant?.must_equal false
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, _ = param_values.map(&:get_value_plain)
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, _ = param_values.map(&:get_value_plain)
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, _ = param_values.map(&:get_value_plain)
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, _ = param_values.map(&:get_value_plain)
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, _ = param_values.map(&:get_value_plain)
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, _ = param_values.map(&:get_value_plain)
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)
@@ -1,7 +1,5 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
- require 'gir_ffi/in_out_pointer'
4
-
5
3
  describe GirFFI::InOutPointer do
6
4
  describe ".new" do
7
5
  it "wraps an existing pointer and a type" do
@@ -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 "has the correct value for #pre" do
411
+ it "returns an empty array" do
412
412
  type_info.extra_conversion_arguments.must_equal []
413
413
  end
414
414
  end
@@ -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 :value" do
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
- assert !is_floating?(@o)
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
- assert !is_floating?(instance)
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