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,7 +1,7 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::ClassBase do
4
- describe "a simple descendant" do
4
+ describe 'a simple descendant' do
5
5
  let(:klass) {
6
6
  Class.new(GirFFI::ClassBase) do
7
7
  self::Struct = Class.new(FFI::Struct) do
@@ -11,20 +11,20 @@ describe GirFFI::ClassBase do
11
11
  }
12
12
  let(:object) { klass.wrap FFI::MemoryPointer.new(:int32) }
13
13
 
14
- it "has #from as a pass-through method" do
14
+ it 'has #from as a pass-through method' do
15
15
  result = klass.from :foo
16
16
  result.must_equal :foo
17
17
  end
18
18
 
19
- describe "#==" do
20
- it "returns true when comparing to an object of the same class and pointer" do
19
+ describe '#==' do
20
+ it 'returns true when comparing to an object of the same class and pointer' do
21
21
  other = klass.wrap object.to_ptr
22
22
 
23
23
  object.must_be :==, other
24
24
  other.must_be :==, object
25
25
  end
26
26
 
27
- it "returns true when comparing to an object of the same class and a pointer with the same address" do
27
+ it 'returns true when comparing to an object of the same class and a pointer with the same address' do
28
28
  ptr = FFI::Pointer.new object.to_ptr
29
29
  other = klass.wrap ptr
30
30
 
@@ -32,7 +32,7 @@ describe GirFFI::ClassBase do
32
32
  other.must_be :==, object
33
33
  end
34
34
 
35
- it "returns false when comparing to an object of a sub/superclass and the same pointer" do
35
+ it 'returns false when comparing to an object of a sub/superclass and the same pointer' do
36
36
  subclass = Class.new(klass)
37
37
  other = subclass.wrap object.to_ptr
38
38
 
@@ -40,7 +40,7 @@ describe GirFFI::ClassBase do
40
40
  other.wont_be :==, object
41
41
  end
42
42
 
43
- it "returns false when comparing to an object of the same class and different pointer" do
43
+ it 'returns false when comparing to an object of the same class and different pointer' do
44
44
  other = klass.wrap FFI::MemoryPointer.new(:int32)
45
45
 
46
46
  object.wont_be :==, other
@@ -54,14 +54,14 @@ describe GirFFI::ClassBase do
54
54
  other.wont_be :==, object
55
55
  end
56
56
 
57
- it "returns false when comparing to an object of a different class and same pointer" do
57
+ it 'returns false when comparing to an object of a different class and same pointer' do
58
58
  stub(other = Object.new).to_ptr { object.to_ptr }
59
59
 
60
60
  object.wont_be :==, other
61
61
  other.wont_be :==, object
62
62
  end
63
63
 
64
- it "returns false when comparing to an object of a different class and different pointer" do
64
+ it 'returns false when comparing to an object of a different class and different pointer' do
65
65
  stub(other = Object.new).to_ptr { FFI::MemoryPointer.new(:int32) }
66
66
 
67
67
  object.wont_be :==, other
@@ -70,13 +70,13 @@ describe GirFFI::ClassBase do
70
70
  end
71
71
  end
72
72
 
73
- describe ".setup_and_call" do
74
- it "looks up class methods in all builders" do
75
- mock(builder = Object.new).setup_method("foo") { "foo" }
73
+ describe '.setup_and_call' do
74
+ it 'looks up class methods in all builders' do
75
+ mock(builder = Object.new).setup_method('foo') { 'foo' }
76
76
  klass = Class.new GirFFI::ClassBase
77
77
  klass.const_set :GIR_FFI_BUILDER, builder
78
78
 
79
- mock(sub_builder = Object.new).setup_method("foo") { nil }
79
+ mock(sub_builder = Object.new).setup_method('foo') { nil }
80
80
  sub_klass = Class.new klass do
81
81
  def self.foo; end
82
82
  end
@@ -85,32 +85,37 @@ describe GirFFI::ClassBase do
85
85
  sub_klass.setup_and_call :foo, []
86
86
  end
87
87
 
88
- it "calls the method given by the result of .setup_method" do
89
- mock(builder = Object.new).setup_method("foo") { "bar" }
88
+ it 'calls the method given by the result of .setup_method' do
89
+ mock(builder = Object.new).setup_method('foo') { 'bar' }
90
90
  klass = Class.new GirFFI::ClassBase do
91
91
  def self.bar
92
- "correct-result"
92
+ 'correct-result'
93
+ end
94
+ def self.new
95
+ _real_new
93
96
  end
94
- def self.new; self._real_new; end
95
97
  end
96
98
  klass.const_set :GIR_FFI_BUILDER, builder
97
99
 
98
100
  result = klass.setup_and_call :foo, []
99
- result.must_equal "correct-result"
101
+ result.must_equal 'correct-result'
100
102
  end
101
103
  end
102
104
 
103
- describe "#setup_and_call" do
104
- it "looks up instance methods in all builders" do
105
- mock(builder = Object.new).setup_instance_method("foo") { "foo" }
105
+ describe '#setup_and_call' do
106
+ it 'looks up instance methods in all builders' do
107
+ mock(builder = Object.new).setup_instance_method('foo') { 'foo' }
106
108
  klass = Class.new GirFFI::ClassBase
107
109
  klass.const_set :GIR_FFI_BUILDER, builder
108
110
 
109
- mock(sub_builder = Object.new).setup_instance_method("foo") { nil }
111
+ mock(sub_builder = Object.new).setup_instance_method('foo') { nil }
110
112
  sub_klass = Class.new klass do
111
113
  def foo; end
114
+
112
115
  def initialize; end
113
- def self.new; self._real_new; end
116
+ def self.new
117
+ _real_new
118
+ end
114
119
  end
115
120
  sub_klass.const_set :GIR_FFI_BUILDER, sub_builder
116
121
 
@@ -119,20 +124,22 @@ describe GirFFI::ClassBase do
119
124
  obj.setup_and_call :foo, []
120
125
  end
121
126
 
122
- it "calls the method given by the result of .setup_instance_method" do
123
- mock(builder = Object.new).setup_instance_method("foo") { "bar" }
127
+ it 'calls the method given by the result of .setup_instance_method' do
128
+ mock(builder = Object.new).setup_instance_method('foo') { 'bar' }
124
129
  klass = Class.new GirFFI::ClassBase do
125
130
  def bar
126
- "correct-result"
131
+ 'correct-result'
132
+ end
133
+ def self.new
134
+ _real_new
127
135
  end
128
- def self.new; self._real_new; end
129
136
  end
130
137
  klass.const_set :GIR_FFI_BUILDER, builder
131
138
 
132
139
  obj = klass.new
133
140
 
134
141
  result = obj.setup_and_call :foo, []
135
- result.must_equal "correct-result"
142
+ result.must_equal 'correct-result'
136
143
  end
137
144
  end
138
145
  end
@@ -4,44 +4,44 @@ require 'gir_ffi/error_type_info'
4
4
  describe GirFFI::ErrorTypeInfo do
5
5
  let(:instance) { GirFFI::ErrorTypeInfo.new }
6
6
 
7
- describe "#array_length" do
8
- it "returns the correct value" do
7
+ describe '#array_length' do
8
+ it 'returns the correct value' do
9
9
  instance.array_length.must_equal(-1)
10
10
  end
11
11
  end
12
12
 
13
- describe "#tag_or_class" do
14
- it "returns the correct value" do
13
+ describe '#tag_or_class' do
14
+ it 'returns the correct value' do
15
15
  instance.tag_or_class.must_equal [:pointer, :error]
16
16
  end
17
17
  end
18
18
 
19
- describe "#pointer?" do
20
- it "returns the correct value" do
19
+ describe '#pointer?' do
20
+ it 'returns the correct value' do
21
21
  instance.pointer?.must_equal true
22
22
  end
23
23
  end
24
24
 
25
- describe "#flattened_tag" do
26
- it "returns the correct value" do
25
+ describe '#flattened_tag' do
26
+ it 'returns the correct value' do
27
27
  instance.flattened_tag.must_equal :error
28
28
  end
29
29
  end
30
30
 
31
- describe "#extra_conversion_arguments" do
32
- it "returns the correct value" do
31
+ describe '#extra_conversion_arguments' do
32
+ it 'returns the correct value' do
33
33
  instance.extra_conversion_arguments.must_equal []
34
34
  end
35
35
  end
36
36
 
37
- describe "#argument_class_name" do
38
- it "returns the correct value" do
37
+ describe '#argument_class_name' do
38
+ it 'returns the correct value' do
39
39
  instance.argument_class_name.must_equal 'GLib::Error'
40
40
  end
41
41
  end
42
42
 
43
- describe "#needs_ruby_to_c_conversion_for_callbacks?" do
44
- it "returns the correct value" do
43
+ describe '#needs_ruby_to_c_conversion_for_callbacks?' do
44
+ it 'returns the correct value' do
45
45
  instance.needs_ruby_to_c_conversion_for_callbacks?.must_equal true
46
46
  end
47
47
  end
@@ -2,17 +2,17 @@ require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::FFIExt::Pointer do
4
4
  let(:klass) { Class.new { include GirFFI::FFIExt::Pointer } }
5
- describe "#to_object" do
6
- it "finds the wrapping class by gtype and wraps the pointer in it" do
5
+ describe '#to_object' do
6
+ it 'finds the wrapping class by gtype and wraps the pointer in it' do
7
7
  ptr = klass.new
8
8
  mock(ptr).null? { false }
9
9
  object_class = Class.new
10
10
 
11
11
  mock(GObject).type_from_instance_pointer(ptr) { 0xdeadbeef }
12
12
  mock(GirFFI::Builder).build_by_gtype(0xdeadbeef) { object_class }
13
- mock(object_class).direct_wrap(ptr) { "good-result" }
13
+ mock(object_class).direct_wrap(ptr) { 'good-result' }
14
14
 
15
- ptr.to_object.must_equal "good-result"
15
+ ptr.to_object.must_equal 'good-result'
16
16
  end
17
17
  end
18
18
  end
@@ -6,22 +6,22 @@ describe GirFFI::GType do
6
6
  let(:gobject_gtype) { GObject::Object.get_gtype }
7
7
  let(:gobject_type_query) { GObject.type_query gobject_gtype }
8
8
 
9
- describe "#to_i" do
10
- it "returns the integer gtype" do
9
+ describe '#to_i' do
10
+ it 'returns the integer gtype' do
11
11
  gt = GirFFI::GType.new(gobject_gtype)
12
12
  gt.to_i.must_equal gobject_gtype
13
13
  end
14
14
  end
15
15
 
16
- describe "#class_size" do
17
- it "returns the class size for object types" do
16
+ describe '#class_size' do
17
+ it 'returns the class size for object types' do
18
18
  gt = GirFFI::GType.new(gobject_gtype)
19
19
  gt.class_size.must_equal gobject_type_query.class_size
20
20
  end
21
21
  end
22
22
 
23
- describe "#instance_size" do
24
- it "returns the instance size for object types" do
23
+ describe '#instance_size' do
24
+ it 'returns the instance size for object types' do
25
25
  gt = GirFFI::GType.new(gobject_gtype)
26
26
  gt.instance_size.must_equal gobject_type_query.instance_size
27
27
  end
@@ -1,8 +1,8 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::InOutPointer do
4
- describe ".new" do
5
- it "wraps an existing pointer and a type" do
4
+ describe '.new' do
5
+ it 'wraps an existing pointer and a type' do
6
6
  ptr = GirFFI::AllocationHelper.safe_malloc(FFI.type_size(:int32))
7
7
  ptr.put_int32 0, 42
8
8
  instance = GirFFI::InOutPointer.new :gint32, ptr
@@ -10,89 +10,89 @@ describe GirFFI::InOutPointer do
10
10
  end
11
11
  end
12
12
 
13
- describe "an instance created with .from" do
13
+ describe 'an instance created with .from' do
14
14
  before do
15
15
  @result = GirFFI::InOutPointer.from :gint32, 23
16
16
  end
17
17
 
18
- it "holds a pointer to the given value" do
18
+ it 'holds a pointer to the given value' do
19
19
  assert_equal 23, @result.get_int32(0)
20
20
  end
21
21
 
22
- it "is an instance of GirFFI::InOutPointer" do
22
+ it 'is an instance of GirFFI::InOutPointer' do
23
23
  assert_instance_of GirFFI::InOutPointer, @result
24
24
  end
25
25
  end
26
26
 
27
- describe ".from" do
28
- it "handles :gboolean false" do
27
+ describe '.from' do
28
+ it 'handles :gboolean false' do
29
29
  ptr = GirFFI::InOutPointer.from :gboolean, false
30
30
  ptr.read_int.must_equal 0
31
31
  end
32
32
 
33
- it "handles :gboolean true" do
33
+ it 'handles :gboolean true' do
34
34
  ptr = GirFFI::InOutPointer.from :gboolean, true
35
35
  ptr.read_int.must_equal(1)
36
36
  end
37
37
 
38
- it "handles :utf8 pointers" do
39
- str_ptr = GirFFI::InPointer.from :utf8, "Hello"
38
+ it 'handles :utf8 pointers' do
39
+ str_ptr = GirFFI::InPointer.from :utf8, 'Hello'
40
40
  GirFFI::InOutPointer.from :utf8, str_ptr
41
41
  end
42
42
  end
43
43
 
44
- describe "in instance created with .for" do
44
+ describe 'in instance created with .for' do
45
45
  before do
46
46
  @result = GirFFI::InOutPointer.for :gint32
47
47
  end
48
48
 
49
- it "holds a pointer to a null value" do
49
+ it 'holds a pointer to a null value' do
50
50
  assert_equal 0, @result.get_int32(0)
51
51
  end
52
52
 
53
- it "is an instance of GirFFI::InOutPointer" do
53
+ it 'is an instance of GirFFI::InOutPointer' do
54
54
  assert_instance_of GirFFI::InOutPointer, @result
55
55
  end
56
56
  end
57
57
 
58
- describe ".for" do
59
- it "handles :gboolean" do
58
+ describe '.for' do
59
+ it 'handles :gboolean' do
60
60
  GirFFI::InOutPointer.for :gboolean
61
61
  end
62
62
 
63
- it "handles :utf8" do
63
+ it 'handles :utf8' do
64
64
  GirFFI::InOutPointer.for :utf8
65
65
  end
66
66
  end
67
67
 
68
- describe "#to_value" do
69
- it "returns the held value" do
68
+ describe '#to_value' do
69
+ it 'returns the held value' do
70
70
  ptr = GirFFI::InOutPointer.from :gint32, 123
71
71
  assert_equal 123, ptr.to_value
72
72
  end
73
73
 
74
- describe "for :gboolean values" do
75
- it "works when the value is false" do
74
+ describe 'for :gboolean values' do
75
+ it 'works when the value is false' do
76
76
  ptr = GirFFI::InOutPointer.from :gboolean, false
77
77
  ptr.to_value.must_equal false
78
78
  end
79
79
 
80
- it "works when the value is true" do
80
+ it 'works when the value is true' do
81
81
  ptr = GirFFI::InOutPointer.from :gboolean, true
82
82
  ptr.to_value.must_equal true
83
83
  end
84
84
  end
85
85
 
86
- describe "for :utf8 values" do
87
- it "returns a pointer to the held value" do
88
- str_ptr = GirFFI::InPointer.from :utf8, "Some value"
86
+ describe 'for :utf8 values' do
87
+ it 'returns a pointer to the held value' do
88
+ str_ptr = GirFFI::InPointer.from :utf8, 'Some value'
89
89
  ptr = GirFFI::InOutPointer.from :utf8, str_ptr
90
- assert_equal "Some value", ptr.to_value.read_string
90
+ assert_equal 'Some value', ptr.to_value.read_string
91
91
  end
92
92
  end
93
93
 
94
- describe "for struct values" do
95
- it "returns a pointer to the held value" do
94
+ describe 'for struct values' do
95
+ it 'returns a pointer to the held value' do
96
96
  val = GObject::EnumValue.new
97
97
  val.value = 3
98
98
  ptr = GirFFI::InOutPointer.from GObject::EnumValue, val
@@ -3,17 +3,17 @@ require 'gir_ffi_test_helper'
3
3
  require 'gir_ffi/in_pointer'
4
4
 
5
5
  describe GirFFI::InPointer do
6
- describe ".from_array" do
7
- it "returns nil when passed nil" do
6
+ describe '.from_array' do
7
+ it 'returns nil when passed nil' do
8
8
  result = GirFFI::InPointer.from_array :gint32, nil
9
9
  assert_nil result
10
10
  end
11
11
 
12
- it "handles type tag :GType" do
12
+ it 'handles type tag :GType' do
13
13
  GirFFI::InPointer.from_array :GType, [2]
14
14
  end
15
15
 
16
- it "handles enum types" do
16
+ it 'handles enum types' do
17
17
  e = Module.new do
18
18
  extend GirFFI::EnumBase
19
19
  self::Enum = FFI::Enum.new [:foo, :bar, :baz]
@@ -22,7 +22,7 @@ describe GirFFI::InPointer do
22
22
  ptr.read_array_of_int32(3).must_equal [1, 0, 2]
23
23
  end
24
24
 
25
- it "handles struct types" do
25
+ it 'handles struct types' do
26
26
  e = Class.new(GirFFI::StructBase) do
27
27
  self::Struct = Class.new(FFI::Struct) do
28
28
  layout :foo, :int32, :bar, :int32
@@ -38,7 +38,7 @@ describe GirFFI::InPointer do
38
38
  new_struct[:bar].must_equal 24
39
39
  end
40
40
 
41
- it "handles typed pointers" do
41
+ it 'handles typed pointers' do
42
42
  p1 = GirFFI::InPointer.from :gint32, 42
43
43
  p2 = GirFFI::InPointer.from :gint32, 24
44
44
 
@@ -47,94 +47,94 @@ describe GirFFI::InPointer do
47
47
  ptr.read_array_of_pointer(2).must_equal [p1, p2]
48
48
  end
49
49
 
50
- it "handles pointer casting" do
50
+ it 'handles pointer casting' do
51
51
  ptr = GirFFI::InPointer.from_array [:pointer, :gint32], [42, 24]
52
52
 
53
53
  ptr.read_array_of_pointer(2).map(&:address).must_equal [42, 24]
54
54
  end
55
55
  end
56
56
 
57
- describe "an instance created with .from_array :gint32" do
57
+ describe 'an instance created with .from_array :gint32' do
58
58
  before do
59
59
  @result = GirFFI::InPointer.from_array :gint32, [24, 13]
60
60
  end
61
61
 
62
- it "holds a pointer to the correct input values" do
62
+ it 'holds a pointer to the correct input values' do
63
63
  assert_equal 24, @result.get_int(0)
64
64
  assert_equal 13, @result.get_int(4)
65
65
  end
66
66
 
67
- it "is an instance of GirFFI::InPointer" do
67
+ it 'is an instance of GirFFI::InPointer' do
68
68
  assert_instance_of GirFFI::InPointer, @result
69
69
  end
70
70
 
71
- it "is zero-terminated" do
71
+ it 'is zero-terminated' do
72
72
  assert_equal 0, @result.get_int(8)
73
73
  end
74
74
  end
75
75
 
76
- describe "an instance created with .from_array :utf8" do
76
+ describe 'an instance created with .from_array :utf8' do
77
77
  before do
78
- @result = GirFFI::InPointer.from_array :utf8, ["foo", "bar", "baz"]
78
+ @result = GirFFI::InPointer.from_array :utf8, %w(foo bar baz)
79
79
  end
80
80
 
81
- it "returns an array of pointers to strings" do
81
+ it 'returns an array of pointers to strings' do
82
82
  ary = @result.read_array_of_pointer(3)
83
- assert_equal ["foo", "bar", "baz"], ary.map {|p| p.read_string}
83
+ assert_equal %w(foo bar baz), ary.map(&:read_string)
84
84
  end
85
85
  end
86
86
 
87
- describe "an instance created with .from_array :filename" do
87
+ describe 'an instance created with .from_array :filename' do
88
88
  before do
89
- @result = GirFFI::InPointer.from_array :filename, ["foo", "bar", "baz"]
89
+ @result = GirFFI::InPointer.from_array :filename, %w(foo bar baz)
90
90
  end
91
91
 
92
- it "returns an array of pointers to strings" do
92
+ it 'returns an array of pointers to strings' do
93
93
  ary = @result.read_array_of_pointer(3)
94
- assert_equal ["foo", "bar", "baz"], ary.map {|p| p.read_string}
94
+ assert_equal %w(foo bar baz), ary.map(&:read_string)
95
95
  end
96
96
  end
97
97
 
98
- describe "an instance created with .from :utf8" do
98
+ describe 'an instance created with .from :utf8' do
99
99
  before do
100
- @result = GirFFI::InPointer.from :utf8, "foo"
100
+ @result = GirFFI::InPointer.from :utf8, 'foo'
101
101
  end
102
102
 
103
- it "returns a pointer to the given string" do
104
- assert_equal "foo", @result.read_string
103
+ it 'returns a pointer to the given string' do
104
+ assert_equal 'foo', @result.read_string
105
105
  end
106
106
 
107
- it "is an instance of GirFFI::InPointer" do
107
+ it 'is an instance of GirFFI::InPointer' do
108
108
  assert_instance_of GirFFI::InPointer, @result
109
109
  end
110
110
  end
111
111
 
112
- describe "an instance created with .from :guint32" do
112
+ describe 'an instance created with .from :guint32' do
113
113
  before do
114
- @result = GirFFI::InPointer.from :guint32, 12345
114
+ @result = GirFFI::InPointer.from :guint32, 12_345
115
115
  end
116
116
 
117
- it "returns a pointer with an address equal to the given value" do
118
- assert_equal 12345, @result.address
117
+ it 'returns a pointer with an address equal to the given value' do
118
+ assert_equal 12_345, @result.address
119
119
  end
120
120
 
121
- it "is an instance of GirFFI::InPointer" do
121
+ it 'is an instance of GirFFI::InPointer' do
122
122
  assert_instance_of GirFFI::InPointer, @result
123
123
  end
124
124
  end
125
125
 
126
- describe "an instance created with .from :filename" do
126
+ describe 'an instance created with .from :filename' do
127
127
  before do
128
- @result = GirFFI::InPointer.from :filename, "foo"
128
+ @result = GirFFI::InPointer.from :filename, 'foo'
129
129
  end
130
130
 
131
- it "returns a pointer to the given string" do
132
- assert_equal "foo", @result.read_string
131
+ it 'returns a pointer to the given string' do
132
+ assert_equal 'foo', @result.read_string
133
133
  end
134
134
  end
135
135
 
136
- describe ".from" do
137
- it "returns nil when passed nil" do
136
+ describe '.from' do
137
+ it 'returns nil when passed nil' do
138
138
  result = GirFFI::InPointer.from :foo, nil
139
139
  assert_nil result
140
140
  end
@@ -144,10 +144,10 @@ describe GirFFI::InPointer do
144
144
  assert_equal 23, result.address
145
145
  end
146
146
 
147
- it "handles enum types" do
147
+ it 'handles enum types' do
148
148
  e = Module.new do
149
149
  self::Enum = FFI::Enum.new [:foo, :bar, :baz]
150
- def self.[](val)
150
+ def self.[] val
151
151
  self::Enum[val]
152
152
  end
153
153
  end
@@ -155,38 +155,42 @@ describe GirFFI::InPointer do
155
155
  ptr.address.must_equal 1
156
156
  end
157
157
 
158
- describe "for type :void" do
159
- it "returns the result of to_ptr" do
158
+ describe 'for type :void' do
159
+ it 'returns the result of to_ptr' do
160
160
  obj = Object.new
161
- def obj.to_ptr; :test_value; end
161
+ def obj.to_ptr
162
+ :test_value
163
+ end
162
164
  GirFFI::InPointer.from(:void, obj).must_equal :test_value
163
165
  end
164
166
 
165
- it "returns nil when passed nil" do
167
+ it 'returns nil when passed nil' do
166
168
  GirFFI::InPointer.from(:void, nil).must_equal nil
167
169
  end
168
170
  end
169
171
 
170
- describe "for types that are classes" do
171
- it "returns the result of to_ptr" do
172
+ describe 'for types that are classes' do
173
+ it 'returns the result of to_ptr' do
172
174
  klass = Class.new
173
175
  obj = klass.new
174
- def obj.to_ptr; :test_value; end
176
+ def obj.to_ptr
177
+ :test_value
178
+ end
175
179
  GirFFI::InPointer.from(klass, obj).must_equal :test_value
176
180
  end
177
181
  end
178
182
  end
179
183
 
180
- describe ".from_closure_data" do
181
- describe "when called with nil" do
182
- it "returns a pointer pointing to nil.object_id" do
184
+ describe '.from_closure_data' do
185
+ describe 'when called with nil' do
186
+ it 'returns a pointer pointing to nil.object_id' do
183
187
  GirFFI::InPointer.from_closure_data(nil).address.must_equal nil.object_id
184
188
  end
185
189
  end
186
190
 
187
- describe "when called with a string" do
188
- it "stores the string in GirFFI::ArgHelper::OBJECT_STORE" do
189
- str = "Foo"
191
+ describe 'when called with a string' do
192
+ it 'stores the string in GirFFI::ArgHelper::OBJECT_STORE' do
193
+ str = 'Foo'
190
194
  ptr = GirFFI::InPointer.from_closure_data(str)
191
195
  result = GirFFI::ArgHelper::OBJECT_STORE.fetch(ptr)
192
196
  result.must_equal str
@@ -1,23 +1,24 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::InfoExt::ICallableInfo do
4
- let(:klass) { Class.new do
5
- include GirFFI::InfoExt::ICallableInfo
6
- end }
4
+ let(:klass) {
5
+ Class.new do
6
+ include GirFFI::InfoExt::ICallableInfo
7
+ end
8
+ }
7
9
  let(:callable_info) { klass.new }
8
10
 
9
- describe "#argument_ffi_types" do
10
- describe "for a simple callable with several arguments" do
11
+ describe '#argument_ffi_types' do
12
+ describe 'for a simple callable with several arguments' do
11
13
  before do
12
14
  stub(arg_info1 = Object.new).to_ffitype { :type1 }
13
15
  stub(arg_info2 = Object.new).to_ffitype { :type2 }
14
16
  stub(callable_info).args { [arg_info1, arg_info2] }
15
17
  end
16
18
 
17
- it "returns the ffi types of the arguments" do
19
+ it 'returns the ffi types of the arguments' do
18
20
  callable_info.argument_ffi_types.must_equal [:type1, :type2]
19
21
  end
20
22
  end
21
23
  end
22
24
  end
23
-