gir_ffi 0.7.7 → 0.7.8

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.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +9 -0
  3. data/lib/ffi-glib/array.rb +1 -1
  4. data/lib/ffi-glib/error.rb +1 -2
  5. data/lib/ffi-glib/hash_table.rb +2 -2
  6. data/lib/ffi-glib/variant.rb +1 -1
  7. data/lib/ffi-gobject/base.rb +23 -23
  8. data/lib/ffi-gobject/object.rb +7 -3
  9. data/lib/ffi-gobject/value.rb +6 -1
  10. data/lib/ffi-gobject.rb +9 -6
  11. data/lib/ffi-gobject_introspection/i_base_info.rb +3 -3
  12. data/lib/ffi-gobject_introspection/i_constant_info.rb +1 -1
  13. data/lib/ffi-gobject_introspection/i_repository.rb +4 -1
  14. data/lib/ffi-gobject_introspection/i_type_info.rb +1 -1
  15. data/lib/ffi-gobject_introspection/i_unresolved_info.rb +7 -0
  16. data/lib/ffi-gobject_introspection/lib.rb +1 -1
  17. data/lib/gir_ffi/builders/argument_builder.rb +1 -1
  18. data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +37 -29
  19. data/lib/gir_ffi/builders/callback_argument_builder.rb +57 -27
  20. data/lib/gir_ffi/builders/closure_convertor.rb +12 -8
  21. data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +12 -8
  22. data/lib/gir_ffi/builders/constructor_result_convertor.rb +11 -7
  23. data/lib/gir_ffi/builders/field_builder.rb +1 -1
  24. data/lib/gir_ffi/builders/function_builder.rb +1 -1
  25. data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
  26. data/lib/gir_ffi/builders/marshalling_method_builder.rb +2 -2
  27. data/lib/gir_ffi/builders/method_template.rb +1 -1
  28. data/lib/gir_ffi/builders/null_convertor.rb +11 -7
  29. data/lib/gir_ffi/builders/property_builder.rb +1 -1
  30. data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +17 -13
  31. data/lib/gir_ffi/error_argument_info.rb +1 -1
  32. data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
  33. data/lib/gir_ffi/info_ext/i_unresolved_info.rb +12 -0
  34. data/lib/gir_ffi/info_ext/safe_constant_name.rb +2 -2
  35. data/lib/gir_ffi/info_ext/safe_function_name.rb +1 -1
  36. data/lib/gir_ffi/info_ext.rb +1 -0
  37. data/lib/gir_ffi/module_base.rb +1 -1
  38. data/lib/gir_ffi/receiver_argument_info.rb +15 -12
  39. data/lib/gir_ffi/user_data_argument_info.rb +17 -15
  40. data/lib/gir_ffi/user_data_type_info.rb +14 -12
  41. data/lib/gir_ffi/version.rb +1 -1
  42. data/lib/gir_ffi-base/gobject/lib.rb +1 -1
  43. data/test/base_test_helper.rb +15 -15
  44. data/test/ffi-glib/array_test.rb +38 -38
  45. data/test/ffi-glib/byte_array_test.rb +6 -7
  46. data/test/ffi-glib/bytes_test.rb +9 -9
  47. data/test/ffi-glib/hash_table_test.rb +26 -23
  48. data/test/ffi-glib/iconv_test.rb +5 -5
  49. data/test/ffi-glib/list_test.rb +16 -16
  50. data/test/ffi-glib/main_loop_test.rb +6 -6
  51. data/test/ffi-glib/ptr_array_test.rb +45 -45
  52. data/test/ffi-glib/ruby_closure_test.rb +6 -6
  53. data/test/ffi-glib/s_list_test.rb +15 -15
  54. data/test/ffi-glib/strv_test.rb +21 -21
  55. data/test/ffi-glib/variant_test.rb +4 -4
  56. data/test/ffi-gobject/gobject_test.rb +35 -35
  57. data/test/ffi-gobject/object_class_test.rb +1 -1
  58. data/test/ffi-gobject/object_test.rb +29 -6
  59. data/test/ffi-gobject/value_test.rb +66 -52
  60. data/test/ffi-gobject_introspection/i_base_info_test.rb +10 -11
  61. data/test/ffi-gobject_introspection/i_constant_info_test.rb +6 -6
  62. data/test/ffi-gobject_introspection/i_enum_info_test.rb +4 -5
  63. data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -2
  64. data/test/ffi-gobject_introspection/i_object_info_test.rb +5 -5
  65. data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +9 -8
  66. data/test/ffi-gobject_introspection/i_repository_test.rb +16 -16
  67. data/test/ffi-gobject_introspection/i_type_info_test.rb +16 -2
  68. data/test/ffi-gobject_introspection/lib_test.rb +2 -2
  69. data/test/ffi-gobject_test.rb +50 -40
  70. data/test/gir_ffi/arg_helper_test.rb +5 -5
  71. data/test/gir_ffi/builder_test.rb +41 -41
  72. data/test/gir_ffi/builders/argument_builder_test.rb +240 -207
  73. data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -1
  74. data/test/gir_ffi/builders/callback_argument_builder_test.rb +81 -15
  75. data/test/gir_ffi/builders/callback_builder_test.rb +39 -14
  76. data/test/gir_ffi/builders/callback_return_value_builder_test.rb +41 -33
  77. data/test/gir_ffi/builders/enum_builder_test.rb +3 -3
  78. data/test/gir_ffi/builders/field_builder_test.rb +17 -17
  79. data/test/gir_ffi/builders/function_builder_test.rb +16 -16
  80. data/test/gir_ffi/builders/interface_builder_test.rb +9 -7
  81. data/test/gir_ffi/builders/module_builder_test.rb +5 -6
  82. data/test/gir_ffi/builders/object_builder_test.rb +24 -19
  83. data/test/gir_ffi/builders/property_builder_test.rb +25 -23
  84. data/test/gir_ffi/builders/registered_type_builder_test.rb +11 -11
  85. data/test/gir_ffi/builders/return_value_builder_test.rb +237 -197
  86. data/test/gir_ffi/builders/signal_closure_builder_test.rb +29 -22
  87. data/test/gir_ffi/builders/struct_builder_test.rb +10 -10
  88. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +8 -8
  89. data/test/gir_ffi/builders/union_builder_test.rb +5 -6
  90. data/test/gir_ffi/builders/user_defined_builder_test.rb +42 -33
  91. data/test/gir_ffi/builders/vfunc_builder_test.rb +37 -30
  92. data/test/gir_ffi/callback_base_test.rb +4 -5
  93. data/test/gir_ffi/class_base_test.rb +35 -28
  94. data/test/gir_ffi/error_type_info_test.rb +14 -14
  95. data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -4
  96. data/test/gir_ffi/g_type_test.rb +6 -6
  97. data/test/gir_ffi/in_out_pointer_test.rb +27 -27
  98. data/test/gir_ffi/in_pointer_test.rb +54 -50
  99. data/test/gir_ffi/info_ext/i_callable_info_test.rb +8 -7
  100. data/test/gir_ffi/info_ext/i_callback_info_test.rb +7 -7
  101. data/test/gir_ffi/info_ext/i_field_info_test.rb +10 -8
  102. data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -15
  103. data/test/gir_ffi/info_ext/i_signal_info_test.rb +10 -8
  104. data/test/gir_ffi/info_ext/i_type_info_test.rb +158 -155
  105. data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +17 -0
  106. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +12 -10
  107. data/test/gir_ffi/info_ext/safe_function_name_test.rb +12 -10
  108. data/test/gir_ffi/interface_base_test.rb +6 -6
  109. data/test/gir_ffi/method_stubber_test.rb +16 -13
  110. data/test/gir_ffi/object_base_test.rb +6 -6
  111. data/test/gir_ffi/sized_array_test.rb +23 -23
  112. data/test/gir_ffi/type_map_test.rb +3 -3
  113. data/test/gir_ffi/unintrospectable_type_info_test.rb +18 -18
  114. data/test/gir_ffi/user_defined_property_info_test.rb +4 -4
  115. data/test/gir_ffi/user_defined_type_info_test.rb +16 -16
  116. data/test/gir_ffi/variable_name_generator_test.rb +6 -6
  117. data/test/gir_ffi/version_test.rb +1 -1
  118. data/test/gir_ffi/zero_terminated_test.rb +16 -17
  119. data/test/gir_ffi-base/glib/boolean_test.rb +13 -13
  120. data/test/gir_ffi-base/glib/strv_test.rb +11 -11
  121. data/test/gir_ffi_test.rb +18 -18
  122. data/test/gir_ffi_test_helper.rb +13 -18
  123. data/test/integration/derived_classes_test.rb +8 -8
  124. data/test/integration/generated_gimarshallingtests_test.rb +794 -792
  125. data/test/integration/generated_gio_test.rb +25 -26
  126. data/test/integration/generated_glib_test.rb +8 -2
  127. data/test/integration/generated_gobject_test.rb +16 -9
  128. data/test/integration/generated_pango_ft2_test.rb +1 -2
  129. data/test/integration/generated_pango_test.rb +2 -2
  130. data/test/integration/generated_regress_test.rb +785 -705
  131. data/test/integration/generated_secret_test.rb +5 -5
  132. data/test/integration/method_lookup_test.rb +5 -5
  133. data/test/introspection_test_helper.rb +3 -1
  134. data/test/minitest/stats_plugin.rb +3 -3
  135. metadata +6 -3
@@ -1,24 +1,25 @@
1
1
  require 'introspection_test_helper'
2
2
 
3
3
  describe GObjectIntrospection::IRegisteredTypeInfo do
4
- describe "#get_type_name" do
5
- describe "for an interface" do
4
+ describe '#get_type_name' do
5
+ describe 'for an interface' do
6
6
  let(:registered_type_info) {
7
- get_introspection_data('GIMarshallingTests', 'Interface') }
7
+ get_introspection_data('GIMarshallingTests', 'Interface')
8
+ }
8
9
 
9
- it "returns interface name" do
10
+ it 'returns interface name' do
10
11
  registered_type_info.type_name.must_equal 'GIMarshallingTestsInterface'
11
12
  end
12
13
  end
13
14
 
14
- describe "for a type that is not an interface" do
15
+ describe 'for a type that is not an interface' do
15
16
  let(:registered_type_info) {
16
- get_introspection_data('GIMarshallingTests', 'Enum') }
17
+ get_introspection_data('GIMarshallingTests', 'Enum')
18
+ }
17
19
 
18
- it "returns nil" do
20
+ it 'returns nil' do
19
21
  registered_type_info.type_name.must_be_nil
20
22
  end
21
23
  end
22
24
  end
23
25
  end
24
-
@@ -1,19 +1,19 @@
1
1
  require 'introspection_test_helper'
2
2
 
3
3
  describe GObjectIntrospection::IRepository do
4
- describe "an instance" do
5
- it "is not created by calling new()" do
4
+ describe 'an instance' do
5
+ it 'is not created by calling new()' do
6
6
  assert_raises NoMethodError do
7
7
  GObjectIntrospection::IRepository.new
8
8
  end
9
9
  end
10
10
 
11
- it "is created by calling default()" do
11
+ it 'is created by calling default()' do
12
12
  gir = GObjectIntrospection::IRepository.default
13
13
  assert_kind_of GObjectIntrospection::IRepository, gir
14
14
  end
15
15
 
16
- it "is a singleton" do
16
+ it 'is a singleton' do
17
17
  gir = GObjectIntrospection::IRepository.default
18
18
  gir2 = GObjectIntrospection::IRepository.default
19
19
  assert_equal gir, gir2
@@ -22,40 +22,40 @@ describe GObjectIntrospection::IRepository do
22
22
 
23
23
  let(:gir) { GObjectIntrospection::IRepository.default }
24
24
 
25
- describe "#require" do
25
+ describe '#require' do
26
26
  it "raises an error if the namespace doesn't exist" do
27
27
  assert_raises RuntimeError do
28
28
  gir.require 'VeryUnlikelyGObjectNamespaceName', nil
29
29
  end
30
30
  end
31
31
 
32
- it "allows version to be nil" do
32
+ it 'allows version to be nil' do
33
33
  gir.require 'GObject', nil
34
34
  pass
35
35
  end
36
36
 
37
- it "allows version to be left out" do
37
+ it 'allows version to be left out' do
38
38
  gir.require 'GObject'
39
39
  pass
40
40
  end
41
41
  end
42
42
 
43
- describe "#find_by_gtype" do
44
- it "raises an error if 0 is passed as the gtype" do
43
+ describe '#find_by_gtype' do
44
+ it 'raises an error if 0 is passed as the gtype' do
45
45
  proc { gir.find_by_gtype 0 }.must_raise ArgumentError
46
46
  end
47
47
  end
48
48
 
49
- describe "enumerating the infos for GObject" do
50
- before do
51
- gir.require 'GObject', "2.0"
52
- end
53
-
54
- it "yields more than one object" do
49
+ describe '#n_infos' do
50
+ it 'yields more than one object for the GObject namespace' do
51
+ gir.require 'GObject', '2.0'
55
52
  assert_operator gir.n_infos('GObject'), :>, 0
56
53
  end
54
+ end
57
55
 
58
- it "yields IBaseInfo objects" do
56
+ describe '#info' do
57
+ it 'yields IBaseInfo objects' do
58
+ gir.require 'GObject', '2.0'
59
59
  assert_kind_of GObjectIntrospection::IBaseInfo, gir.info('GObject', 0)
60
60
  end
61
61
  end
@@ -1,17 +1,31 @@
1
1
  require 'introspection_test_helper'
2
2
 
3
3
  describe GObjectIntrospection::ITypeInfo do
4
- describe "#name?" do
4
+ describe '#name?' do
5
5
  let(:object_info) { get_introspection_data('GIMarshallingTests', 'Object') }
6
6
  let(:vfunc_info) { object_info.find_vfunc('vfunc_array_out_parameter') }
7
7
  let(:arg_info) { vfunc_info.args[0] }
8
8
  let(:type_info) { arg_info.argument_type }
9
9
 
10
- it "raises an error" do
10
+ it 'raises an error' do
11
11
  skip unless vfunc_info
12
12
  proc {
13
13
  type_info.name
14
14
  }.must_raise RuntimeError
15
15
  end
16
16
  end
17
+
18
+ describe '#interface' do
19
+ describe 'for unresolvable interface types' do
20
+ let(:function_info) { get_introspection_data 'GObject', 'signal_set_va_marshaller' }
21
+ let(:argument_info) { function_info.args.last }
22
+ let(:type_info) { argument_info.argument_type }
23
+
24
+ it 'returns an IUnresolvableInfo object' do
25
+ result = type_info.interface
26
+ result.info_type.must_equal :unresolved
27
+ result.must_be_kind_of GObjectIntrospection::IUnresolvedInfo
28
+ end
29
+ end
30
+ end
17
31
  end
@@ -1,8 +1,8 @@
1
1
  require 'introspection_test_helper'
2
2
 
3
3
  describe GObjectIntrospection::Lib::GIArgument do
4
- describe "its member :v_ssize" do
5
- it "is signed" do
4
+ describe 'its member :v_ssize' do
5
+ it 'is signed' do
6
6
  gia = GObjectIntrospection::Lib::GIArgument.new
7
7
  gia[:v_int64] = -1
8
8
  assert_equal(-1, gia[:v_ssize])
@@ -5,28 +5,28 @@ describe GObject do
5
5
  GirFFI.setup :Regress
6
6
  end
7
7
 
8
- describe "::signal_emit" do
9
- it "emits a signal" do
8
+ describe '::signal_emit' do
9
+ it 'emits a signal' do
10
10
  a = 1
11
11
  o = Regress::TestSubObj.new
12
12
  prc = proc { a = 2 }
13
13
  callback = GObject::Callback.from prc
14
- ::GObject::Lib.g_signal_connect_data o, "test", callback, nil, nil, 0
15
- GObject.signal_emit o, "test"
14
+ ::GObject::Lib.g_signal_connect_data o, 'test', callback, nil, nil, 0
15
+ GObject.signal_emit o, 'test'
16
16
  assert_equal 2, a
17
17
  end
18
18
 
19
- it "handles return values" do
19
+ it 'handles return values' do
20
20
  s = Gio::SocketService.new
21
21
 
22
22
  argtypes = [:pointer, :pointer, :pointer, :pointer]
23
- callback = FFI::Function.new(:bool, argtypes) { |a,b,c,d| true }
24
- ::GObject::Lib.g_signal_connect_data s, "incoming", callback, nil, nil, 0
25
- rv = GObject.signal_emit s, "incoming"
23
+ callback = FFI::Function.new(:bool, argtypes) { |_a, _b, _c, _d| true }
24
+ ::GObject::Lib.g_signal_connect_data s, 'incoming', callback, nil, nil, 0
25
+ rv = GObject.signal_emit s, 'incoming'
26
26
  assert_equal true, rv.get_value
27
27
  end
28
28
 
29
- it "passes in extra arguments" do
29
+ it 'passes in extra arguments' do
30
30
  o = Regress::TestSubObj.new
31
31
  sb = Regress::TestSimpleBoxedA.new
32
32
  sb.some_int8 = 31
@@ -35,85 +35,85 @@ describe GObject do
35
35
  b2 = nil
36
36
 
37
37
  argtypes = [:pointer, :pointer, :pointer]
38
- callback = FFI::Function.new(:void, argtypes) do |a,b,c|
38
+ callback = FFI::Function.new(:void, argtypes) do |_a, b, _c|
39
39
  b2 = b
40
40
  end
41
- ::GObject::Lib.g_signal_connect_data o, "test-with-static-scope-arg", callback, nil, nil, 0
42
- GObject.signal_emit o, "test-with-static-scope-arg", sb
41
+ ::GObject::Lib.g_signal_connect_data o, 'test-with-static-scope-arg', callback, nil, nil, 0
42
+ GObject.signal_emit o, 'test-with-static-scope-arg', sb
43
43
 
44
44
  sb2 = Regress::TestSimpleBoxedA.wrap b2
45
45
  assert sb.equals(sb2)
46
46
  end
47
47
 
48
- it "allows specifying signal detail" do
48
+ it 'allows specifying signal detail' do
49
49
  a = 1
50
50
  o = Regress::TestSubObj.new
51
51
 
52
52
  callback = FFI::Function.new(:void, [:pointer, :pointer, :pointer]) { a = 2 }
53
- ::GObject::Lib.g_signal_connect_data o, "notify::detail", callback, nil, nil, 0
53
+ ::GObject::Lib.g_signal_connect_data o, 'notify::detail', callback, nil, nil, 0
54
54
 
55
- GObject.signal_emit o, "notify::detail"
55
+ GObject.signal_emit o, 'notify::detail'
56
56
 
57
57
  a.must_equal 2
58
58
  end
59
59
  end
60
60
 
61
- describe "::signal_connect" do
62
- it "installs a signal handler" do
61
+ describe '::signal_connect' do
62
+ it 'installs a signal handler' do
63
63
  a = 1
64
64
  o = Regress::TestSubObj.new
65
- GObject.signal_connect(o, "test") { a = 2 }
66
- GObject.signal_emit o, "test"
65
+ GObject.signal_connect(o, 'test') { a = 2 }
66
+ GObject.signal_emit o, 'test'
67
67
  assert_equal 2, a
68
68
  end
69
69
 
70
- it "passes user data to handler" do
70
+ it 'passes user data to handler' do
71
71
  a = 1
72
72
  o = Regress::TestSubObj.new
73
- GObject.signal_connect(o, "test", 2) { |i, d| a = d }
74
- GObject.signal_emit o, "test"
73
+ GObject.signal_connect(o, 'test', 2) { |_i, d| a = d }
74
+ GObject.signal_emit o, 'test'
75
75
  assert_equal 2, a
76
76
  end
77
77
 
78
- it "passes object to handler" do
78
+ it 'passes object to handler' do
79
79
  o = Regress::TestSubObj.new
80
80
  o2 = nil
81
- GObject.signal_connect(o, "test") { |i, d| o2 = i }
82
- GObject.signal_emit o, "test"
81
+ GObject.signal_connect(o, 'test') { |i, _d| o2 = i }
82
+ GObject.signal_emit o, 'test'
83
83
  assert_instance_of Regress::TestSubObj, o2
84
84
  assert_equal o.to_ptr, o2.to_ptr
85
85
  end
86
86
 
87
- it "does not allow connecting an invalid signal" do
87
+ it 'does not allow connecting an invalid signal' do
88
88
  o = Regress::TestSubObj.new
89
89
  assert_raises RuntimeError do
90
- GObject.signal_connect(o, "not-really-a-signal") {}
90
+ GObject.signal_connect(o, 'not-really-a-signal') {}
91
91
  end
92
92
  end
93
93
 
94
- it "handles return values" do
94
+ it 'handles return values' do
95
95
  s = Gio::SocketService.new
96
- GObject.signal_connect(s, "incoming") { true }
97
- rv = GObject.signal_emit s, "incoming"
96
+ GObject.signal_connect(s, 'incoming') { true }
97
+ rv = GObject.signal_emit s, 'incoming'
98
98
  assert_equal true, rv.get_value
99
99
  end
100
100
 
101
- it "requires a block" do
101
+ it 'requires a block' do
102
102
  o = Regress::TestSubObj.new
103
103
  assert_raises ArgumentError do
104
- GObject.signal_connect o, "test"
104
+ GObject.signal_connect o, 'test'
105
105
  end
106
106
  end
107
107
 
108
- it "allows specifying signal detail" do
108
+ it 'allows specifying signal detail' do
109
109
  a = 1
110
110
  o = Regress::TestSubObj.new
111
- GObject.signal_connect(o, "notify::detail", 2) { |i, _, d| a = d }
112
- GObject.signal_emit o, "notify::detail"
111
+ GObject.signal_connect(o, 'notify::detail', 2) { |_i, _, d| a = d }
112
+ GObject.signal_emit o, 'notify::detail'
113
113
  assert_equal 2, a
114
114
  end
115
115
 
116
- describe "connecting a signal with extra arguments" do
116
+ describe 'connecting a signal with extra arguments' do
117
117
  before do
118
118
  @a = nil
119
119
  @b = 2
@@ -122,21 +122,31 @@ describe GObject do
122
122
  sb = Regress::TestSimpleBoxedA.new
123
123
  sb.some_int = 23
124
124
 
125
- GObject.signal_connect(o, "test-with-static-scope-arg", 2) { |instance, object, user_data|
125
+ GObject.signal_connect(o, 'test-with-static-scope-arg', 2) { |_instance, object, user_data|
126
126
  @a = user_data
127
127
  @b = object
128
128
  }
129
- GObject.signal_emit o, "test-with-static-scope-arg", sb
129
+ GObject.signal_emit o, 'test-with-static-scope-arg', sb
130
130
  end
131
131
 
132
- it "passes on the user data argument" do
132
+ it 'passes on the user data argument' do
133
133
  assert_equal 2, @a
134
134
  end
135
135
 
136
- it "passes on the extra arguments" do
136
+ it 'passes on the extra arguments' do
137
137
  assert_instance_of Regress::TestSimpleBoxedA, @b
138
138
  assert_equal 23, @b.some_int
139
139
  end
140
140
  end
141
141
  end
142
+
143
+ describe '::signal_connect_after' do
144
+ it 'installs a signal handler' do
145
+ a = 1
146
+ o = Regress::TestSubObj.new
147
+ GObject.signal_connect_after(o, 'test') { a = 2 }
148
+ GObject.signal_emit o, 'test'
149
+ assert_equal 2, a
150
+ end
151
+ end
142
152
  end
@@ -1,24 +1,24 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::ArgHelper do
4
- describe ".cast_from_pointer" do
5
- it "handles class types" do
4
+ describe '.cast_from_pointer' do
5
+ it 'handles class types' do
6
6
  klass = Class.new
7
7
  mock(klass).wrap(:pointer_value) { :wrapped_value }
8
8
  GirFFI::ArgHelper.cast_from_pointer(klass, :pointer_value).must_equal :wrapped_value
9
9
  end
10
10
 
11
- it "handles negative :gint8" do
11
+ it 'handles negative :gint8' do
12
12
  ptr = FFI::Pointer.new(-127)
13
13
  GirFFI::ArgHelper.cast_from_pointer(:gint8, ptr).must_equal(-127)
14
14
  end
15
15
 
16
- it "handles positive :gint8" do
16
+ it 'handles positive :gint8' do
17
17
  ptr = FFI::Pointer.new(128)
18
18
  GirFFI::ArgHelper.cast_from_pointer(:gint8, ptr).must_equal(128)
19
19
  end
20
20
 
21
- it "handles :guint32" do
21
+ it 'handles :guint32' do
22
22
  ptr = FFI::Pointer.new(0xffffffff)
23
23
  GirFFI::ArgHelper.cast_from_pointer(:guint32, ptr).must_equal(0xffffffff)
24
24
  end
@@ -6,7 +6,7 @@ describe GirFFI::Builder do
6
6
  let(:gir) { GObjectIntrospection::IRepository.default }
7
7
 
8
8
  describe '.build_class' do
9
- it "does not replace existing classes" do
9
+ it 'does not replace existing classes' do
10
10
  oldclass = GObject::Object
11
11
  GirFFI::Builder.build_class get_introspection_data('GObject', 'Object')
12
12
  GObject::Object.must_equal oldclass
@@ -15,44 +15,44 @@ describe GirFFI::Builder do
15
15
 
16
16
  describe '.attach_ffi_function' do
17
17
  let(:lib) { Module.new }
18
- it "calls attach_function with the correct types for Regress.test_callback_destroy_notify" do
18
+ it 'calls attach_function with the correct types for Regress.test_callback_destroy_notify' do
19
19
  function_info = get_introspection_data 'Regress', 'test_callback_destroy_notify'
20
20
 
21
21
  mock(lib).
22
- attach_function("regress_test_callback_destroy_notify",
23
- [ Regress::TestCallbackUserData, :pointer, GLib::DestroyNotify ],
22
+ attach_function('regress_test_callback_destroy_notify',
23
+ [Regress::TestCallbackUserData, :pointer, GLib::DestroyNotify],
24
24
  :int32) { true }
25
25
 
26
26
  GirFFI::Builder.attach_ffi_function(lib, function_info)
27
27
  end
28
28
 
29
- it "calls attach_function with the correct types for Regress::TestObj#torture_signature_0" do
29
+ it 'calls attach_function with the correct types for Regress::TestObj#torture_signature_0' do
30
30
  info = get_method_introspection_data 'Regress', 'TestObj', 'torture_signature_0'
31
31
 
32
32
  mock(lib).
33
- attach_function("regress_test_obj_torture_signature_0",
33
+ attach_function('regress_test_obj_torture_signature_0',
34
34
  [:pointer, :int32, :pointer, :pointer, :pointer, :pointer, :uint32],
35
35
  :void) { true }
36
36
 
37
37
  GirFFI::Builder.attach_ffi_function(lib, info)
38
38
  end
39
39
 
40
- it "calls attach_function with the correct types for Regress::TestObj#instance_method" do
40
+ it 'calls attach_function with the correct types for Regress::TestObj#instance_method' do
41
41
  info = get_method_introspection_data 'Regress', 'TestObj', 'instance_method'
42
- mock(lib).attach_function("regress_test_obj_instance_method",
42
+ mock(lib).attach_function('regress_test_obj_instance_method',
43
43
  [:pointer], :int32) { true }
44
44
  GirFFI::Builder.attach_ffi_function(lib, info)
45
45
  end
46
46
 
47
- it "calls attach_function with the correct types for Regress.test_array_gint32_in" do
47
+ it 'calls attach_function with the correct types for Regress.test_array_gint32_in' do
48
48
  info = get_introspection_data 'Regress', 'test_array_gint32_in'
49
- mock(lib).attach_function("regress_test_array_gint32_in",
49
+ mock(lib).attach_function('regress_test_array_gint32_in',
50
50
  [:int32, :pointer], :int32) { true }
51
51
  GirFFI::Builder.attach_ffi_function(lib, info)
52
52
  end
53
53
  end
54
54
 
55
- describe "looking at Regress.test_callback_destroy_notify" do
55
+ describe 'looking at Regress.test_callback_destroy_notify' do
56
56
  before do
57
57
  save_module :GObject
58
58
  save_module :Regress
@@ -61,7 +61,7 @@ describe GirFFI::Builder do
61
61
  @go = get_introspection_data 'Regress', 'test_callback_destroy_notify'
62
62
  end
63
63
 
64
- it "defines ffi callback types :Callback and :ClosureNotify" do
64
+ it 'defines ffi callback types :Callback and :ClosureNotify' do
65
65
  Regress.setup_method 'test_callback_destroy_notify'
66
66
  tcud = Regress::Lib.find_type :TestCallbackUserData
67
67
  dn = GLib::Lib.find_type :DestroyNotify
@@ -78,40 +78,40 @@ describe GirFFI::Builder do
78
78
  end
79
79
  end
80
80
 
81
- describe "building Regress::TestBoxed" do
81
+ describe 'building Regress::TestBoxed' do
82
82
  before do
83
83
  GirFFI::Builder.build_class get_introspection_data('Regress', 'TestBoxed')
84
84
  end
85
85
 
86
- it "sets up #wrap" do
87
- assert Regress::TestBoxed.respond_to? "wrap"
86
+ it 'sets up #wrap' do
87
+ assert Regress::TestBoxed.respond_to? 'wrap'
88
88
  end
89
89
 
90
- it "sets up #allocate" do
91
- assert Regress::TestBoxed.respond_to? "allocate"
90
+ it 'sets up #allocate' do
91
+ assert Regress::TestBoxed.respond_to? 'allocate'
92
92
  end
93
93
  end
94
94
 
95
- describe "built Regress module" do
95
+ describe 'built Regress module' do
96
96
  before do
97
97
  save_module :Regress
98
98
  GirFFI::Builder.build_module 'Regress'
99
99
  end
100
100
 
101
- it "autocreates singleton methods" do
101
+ it 'autocreates singleton methods' do
102
102
  refute_defines_singleton_method Regress, :test_uint
103
103
  Regress.test_uint 31
104
104
  assert_defines_singleton_method Regress, :test_uint
105
105
  end
106
106
 
107
- it "autocreates the TestObj class on first access" do
107
+ it 'autocreates the TestObj class on first access' do
108
108
  assert !Regress.const_defined?(:TestObj)
109
109
  Regress::TestObj.must_be_instance_of Class
110
110
  assert Regress.const_defined? :TestObj
111
111
  end
112
112
 
113
- it "knows its own module builder" do
114
- assert GirFFI::Builders::ModuleBuilder === Regress.gir_ffi_builder
113
+ it 'knows its own module builder' do
114
+ Regress.gir_ffi_builder.must_be_instance_of GirFFI::Builders::ModuleBuilder
115
115
  end
116
116
 
117
117
  after do
@@ -119,35 +119,35 @@ describe GirFFI::Builder do
119
119
  end
120
120
  end
121
121
 
122
- describe "having built Regress::TestObj" do
122
+ describe 'having built Regress::TestObj' do
123
123
  before do
124
124
  GirFFI::Builder.build_class get_introspection_data('Regress', 'TestObj')
125
125
  end
126
126
 
127
- it "C functions for called instance methods get attached to Regress::Lib" do
128
- o = Regress::TestObj.new_from_file("foo")
127
+ it 'C functions for called instance methods get attached to Regress::Lib' do
128
+ o = Regress::TestObj.new_from_file('foo')
129
129
  o.instance_method
130
130
  Regress::Lib.must_respond_to :regress_test_obj_instance_method
131
131
  end
132
132
 
133
- it "the built class knows its own GIR info" do
133
+ it 'the built class knows its own GIR info' do
134
134
  Regress::TestObj.gir_info.name.must_equal 'TestObj'
135
135
  end
136
136
 
137
- it "the built class knows its own class builder" do
137
+ it 'the built class knows its own class builder' do
138
138
  Regress::TestObj.gir_ffi_builder.must_be_instance_of GirFFI::Builders::ObjectBuilder
139
139
  end
140
140
  end
141
141
 
142
- describe "built Regress::TestSubObj" do
143
- it "inherits #set_bare from its superclass" do
142
+ describe 'built Regress::TestSubObj' do
143
+ it 'inherits #set_bare from its superclass' do
144
144
  o1 = Regress::TestSubObj.new
145
145
  o1.set_bare(nil)
146
146
  pass
147
147
  end
148
148
 
149
- it "overrides #instance_method" do
150
- obj = Regress::TestObj.new_from_file("foo")
149
+ it 'overrides #instance_method' do
150
+ obj = Regress::TestObj.new_from_file('foo')
151
151
  subobj = Regress::TestSubObj.new
152
152
 
153
153
  obj.instance_method.must_equal(-1)
@@ -155,30 +155,30 @@ describe GirFFI::Builder do
155
155
  end
156
156
  end
157
157
 
158
- describe "building Regress::TestSubObj" do
158
+ describe 'building Regress::TestSubObj' do
159
159
  before do
160
160
  save_module :Regress
161
161
  GirFFI::Builder.build_class get_introspection_data('Regress', 'TestSubObj')
162
162
  end
163
163
 
164
- it "sets up the Regress namespace" do
164
+ it 'sets up the Regress namespace' do
165
165
  assert Regress.const_defined? :Lib
166
166
  assert Regress.respond_to? :gir_ffi_builder
167
167
  assert Regress.const_defined? :GIR_FFI_BUILDER
168
168
  end
169
169
 
170
- it "creates the Regress::Lib module ready to attach functions from the shared library" do
170
+ it 'creates the Regress::Lib module ready to attach functions from the shared library' do
171
171
  expected = [gir.shared_library('Regress')]
172
172
  assert_equal expected, Regress::Lib.ffi_libraries.map(&:name)
173
173
  end
174
174
 
175
- it "builds parent classes also" do
175
+ it 'builds parent classes also' do
176
176
  assert Regress.const_defined? :TestObj
177
177
  assert Object.const_defined? :GObject
178
178
  assert GObject.const_defined? :Object
179
179
  end
180
180
 
181
- it "sets up the inheritance chain" do
181
+ it 'sets up the inheritance chain' do
182
182
  ancestors = Regress::TestSubObj.ancestors
183
183
  assert_equal [
184
184
  Regress::TestSubObj,
@@ -187,7 +187,7 @@ describe GirFFI::Builder do
187
187
  ], ancestors[0..2]
188
188
  end
189
189
 
190
- it "creates a Regress::TestSubObj#to_ptr method" do
190
+ it 'creates a Regress::TestSubObj#to_ptr method' do
191
191
  assert Regress::TestSubObj.public_method_defined? :to_ptr
192
192
  end
193
193
 
@@ -196,25 +196,25 @@ describe GirFFI::Builder do
196
196
  end
197
197
  end
198
198
 
199
- describe "building Regress" do
199
+ describe 'building Regress' do
200
200
  before do
201
201
  save_module :Regress
202
202
  GirFFI::Builder.build_module 'Regress'
203
203
  end
204
204
 
205
- it "creates a Lib module ready to attach functions from the shared library" do
205
+ it 'creates a Lib module ready to attach functions from the shared library' do
206
206
  gir = GObjectIntrospection::IRepository.default
207
207
  expected = [gir.shared_library('Regress')]
208
208
  assert_equal expected, Regress::Lib.ffi_libraries.map(&:name)
209
209
  end
210
210
 
211
- it "does not replace existing module" do
211
+ it 'does not replace existing module' do
212
212
  oldmodule = Regress
213
213
  GirFFI::Builder.build_module 'Regress'
214
214
  assert_equal oldmodule, Regress
215
215
  end
216
216
 
217
- it "does not replace existing Lib module" do
217
+ it 'does not replace existing Lib module' do
218
218
  oldmodule = Regress::Lib
219
219
  GirFFI::Builder.build_module 'Regress'
220
220
  assert_equal oldmodule, Regress::Lib