gir_ffi 0.14.1 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +21 -0
  3. data/Gemfile +6 -4
  4. data/README.md +4 -4
  5. data/Rakefile +5 -5
  6. data/lib/ffi-glib/array.rb +14 -4
  7. data/lib/ffi-glib/byte_array.rb +7 -2
  8. data/lib/ffi-glib/container_class_methods.rb +1 -1
  9. data/lib/ffi-glib/error.rb +1 -1
  10. data/lib/ffi-glib/hash_table.rb +3 -3
  11. data/lib/ffi-glib/list.rb +1 -1
  12. data/lib/ffi-glib/list_methods.rb +1 -1
  13. data/lib/ffi-glib/main_loop.rb +3 -3
  14. data/lib/ffi-glib/ptr_array.rb +30 -8
  15. data/lib/ffi-glib/s_list.rb +1 -1
  16. data/lib/ffi-glib/variant.rb +1 -1
  17. data/lib/ffi-glib.rb +16 -16
  18. data/lib/ffi-gobject/object.rb +23 -32
  19. data/lib/ffi-gobject/param_spec.rb +1 -1
  20. data/lib/ffi-gobject/ruby_closure.rb +2 -2
  21. data/lib/ffi-gobject/value.rb +37 -28
  22. data/lib/ffi-gobject.rb +13 -13
  23. data/lib/ffi-gobject_introspection/gobject_type_init.rb +2 -2
  24. data/lib/ffi-gobject_introspection/i_arg_info.rb +2 -2
  25. data/lib/ffi-gobject_introspection/i_base_info.rb +27 -17
  26. data/lib/ffi-gobject_introspection/i_callable_info.rb +4 -4
  27. data/lib/ffi-gobject_introspection/i_constant_info.rb +2 -2
  28. data/lib/ffi-gobject_introspection/i_enum_info.rb +1 -0
  29. data/lib/ffi-gobject_introspection/i_field_info.rb +1 -1
  30. data/lib/ffi-gobject_introspection/i_function_info.rb +1 -1
  31. data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -1
  32. data/lib/ffi-gobject_introspection/i_object_info.rb +2 -2
  33. data/lib/ffi-gobject_introspection/i_property_info.rb +2 -2
  34. data/lib/ffi-gobject_introspection/i_repository.rb +9 -6
  35. data/lib/ffi-gobject_introspection/i_struct_info.rb +2 -1
  36. data/lib/ffi-gobject_introspection/i_type_info.rb +13 -7
  37. data/lib/ffi-gobject_introspection/i_unresolved_info.rb +1 -1
  38. data/lib/ffi-gobject_introspection/i_vfunc_info.rb +1 -1
  39. data/lib/ffi-gobject_introspection/lib.rb +30 -19
  40. data/lib/ffi-gobject_introspection/strv.rb +1 -1
  41. data/lib/ffi-gobject_introspection.rb +20 -20
  42. data/lib/gir_ffi/allocation_helper.rb +1 -1
  43. data/lib/gir_ffi/arg_helper.rb +4 -4
  44. data/lib/gir_ffi/{in_out_pointer.rb → array_element_convertor.rb} +16 -23
  45. data/lib/gir_ffi/boolean.rb +1 -1
  46. data/lib/gir_ffi/boxed_base.rb +1 -1
  47. data/lib/gir_ffi/builder.rb +18 -10
  48. data/lib/gir_ffi/builders/argument_builder.rb +17 -17
  49. data/lib/gir_ffi/builders/base_argument_builder.rb +1 -0
  50. data/lib/gir_ffi/builders/base_method_builder.rb +7 -7
  51. data/lib/gir_ffi/builders/base_return_value_builder.rb +1 -1
  52. data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
  53. data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +5 -5
  54. data/lib/gir_ffi/builders/callback_argument_builder.rb +8 -8
  55. data/lib/gir_ffi/builders/callback_builder.rb +3 -3
  56. data/lib/gir_ffi/builders/callback_return_value_builder.rb +2 -2
  57. data/lib/gir_ffi/builders/closure_argument_builder.rb +1 -1
  58. data/lib/gir_ffi/builders/closure_return_value_builder.rb +1 -1
  59. data/lib/gir_ffi/builders/constant_builder.rb +1 -1
  60. data/lib/gir_ffi/builders/constructor_builder.rb +9 -9
  61. data/lib/gir_ffi/builders/enum_builder.rb +2 -2
  62. data/lib/gir_ffi/builders/field_builder.rb +16 -15
  63. data/lib/gir_ffi/builders/flags_builder.rb +2 -2
  64. data/lib/gir_ffi/builders/full_c_to_ruby_convertor.rb +1 -1
  65. data/lib/gir_ffi/builders/function_builder.rb +11 -5
  66. data/lib/gir_ffi/builders/initializer_builder.rb +3 -3
  67. data/lib/gir_ffi/builders/initializer_return_value_builder.rb +2 -2
  68. data/lib/gir_ffi/builders/interface_builder.rb +2 -2
  69. data/lib/gir_ffi/builders/mapping_method_builder.rb +9 -9
  70. data/lib/gir_ffi/builders/marshalling_method_builder.rb +7 -7
  71. data/lib/gir_ffi/builders/method_template.rb +1 -1
  72. data/lib/gir_ffi/builders/module_builder.rb +4 -6
  73. data/lib/gir_ffi/builders/object_builder.rb +6 -6
  74. data/lib/gir_ffi/builders/property_argument_builder.rb +1 -1
  75. data/lib/gir_ffi/builders/property_builder.rb +13 -12
  76. data/lib/gir_ffi/builders/property_return_value_builder.rb +1 -1
  77. data/lib/gir_ffi/builders/registered_type_builder.rb +14 -5
  78. data/lib/gir_ffi/builders/return_value_builder.rb +4 -4
  79. data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +6 -6
  80. data/lib/gir_ffi/builders/signal_closure_builder.rb +2 -2
  81. data/lib/gir_ffi/builders/struct_builder.rb +4 -4
  82. data/lib/gir_ffi/builders/struct_like.rb +1 -1
  83. data/lib/gir_ffi/builders/type_builder.rb +12 -12
  84. data/lib/gir_ffi/builders/unintrospectable_boxed_builder.rb +2 -2
  85. data/lib/gir_ffi/builders/unintrospectable_builder.rb +2 -2
  86. data/lib/gir_ffi/builders/union_builder.rb +4 -4
  87. data/lib/gir_ffi/builders/user_defined_builder.rb +2 -2
  88. data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
  89. data/lib/gir_ffi/builders/vfunc_builder.rb +6 -6
  90. data/lib/gir_ffi/builders/with_layout.rb +2 -2
  91. data/lib/gir_ffi/callback_base.rb +1 -1
  92. data/lib/gir_ffi/class_base.rb +5 -5
  93. data/lib/gir_ffi/core.rb +19 -20
  94. data/lib/gir_ffi/enum_base.rb +1 -1
  95. data/lib/gir_ffi/enum_like_base.rb +2 -2
  96. data/lib/gir_ffi/error_argument_info.rb +2 -2
  97. data/lib/gir_ffi/error_type_info.rb +1 -1
  98. data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
  99. data/lib/gir_ffi/ffi_ext.rb +1 -1
  100. data/lib/gir_ffi/flags_base.rb +1 -1
  101. data/lib/gir_ffi/in_pointer.rb +10 -0
  102. data/lib/gir_ffi/info_ext/full_type_name.rb +3 -3
  103. data/lib/gir_ffi/info_ext/i_arg_info.rb +1 -1
  104. data/lib/gir_ffi/info_ext/i_callable_info.rb +1 -1
  105. data/lib/gir_ffi/info_ext/i_callback_info.rb +1 -1
  106. data/lib/gir_ffi/info_ext/i_field_info.rb +1 -1
  107. data/lib/gir_ffi/info_ext/i_function_info.rb +1 -1
  108. data/lib/gir_ffi/info_ext/i_property_info.rb +2 -2
  109. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +4 -5
  110. data/lib/gir_ffi/info_ext/i_signal_info.rb +7 -3
  111. data/lib/gir_ffi/info_ext/i_type_info.rb +48 -26
  112. data/lib/gir_ffi/info_ext/i_unresolved_info.rb +1 -1
  113. data/lib/gir_ffi/info_ext/i_value_info.rb +2 -2
  114. data/lib/gir_ffi/info_ext/i_vfunc_info.rb +2 -2
  115. data/lib/gir_ffi/info_ext/safe_constant_name.rb +8 -8
  116. data/lib/gir_ffi/info_ext/safe_function_name.rb +2 -2
  117. data/lib/gir_ffi/info_ext.rb +15 -15
  118. data/lib/gir_ffi/interface_base.rb +3 -3
  119. data/lib/gir_ffi/lib_c.rb +1 -1
  120. data/lib/gir_ffi/method_stubber.rb +1 -1
  121. data/lib/gir_ffi/module_base.rb +1 -1
  122. data/lib/gir_ffi/object_base.rb +3 -4
  123. data/lib/gir_ffi/receiver_argument_info.rb +1 -1
  124. data/lib/gir_ffi/receiver_type_info.rb +2 -2
  125. data/lib/gir_ffi/registered_type_base.rb +1 -1
  126. data/lib/gir_ffi/sized_array.rb +4 -2
  127. data/lib/gir_ffi/struct.rb +1 -1
  128. data/lib/gir_ffi/struct_base.rb +1 -1
  129. data/lib/gir_ffi/type_map.rb +2 -23
  130. data/lib/gir_ffi/unintrospectable_boxed_info.rb +2 -2
  131. data/lib/gir_ffi/unintrospectable_type_info.rb +1 -1
  132. data/lib/gir_ffi/union.rb +1 -1
  133. data/lib/gir_ffi/union_base.rb +1 -1
  134. data/lib/gir_ffi/user_defined_object_info.rb +6 -2
  135. data/lib/gir_ffi/user_defined_property_info.rb +33 -33
  136. data/lib/gir_ffi/version.rb +1 -1
  137. data/lib/gir_ffi-base/gobject/lib.rb +3 -2
  138. data/lib/gir_ffi-base/gobject.rb +26 -25
  139. data/lib/gir_ffi-base.rb +1 -1
  140. data/lib/gir_ffi.rb +3 -3
  141. data/tasks/test.rake +3 -2
  142. data/test/base_test_helper.rb +16 -9
  143. data/test/ffi-glib/array_test.rb +71 -56
  144. data/test/ffi-glib/byte_array_test.rb +13 -7
  145. data/test/ffi-glib/bytes_test.rb +24 -19
  146. data/test/ffi-glib/closure_test.rb +11 -11
  147. data/test/ffi-glib/destroy_notify_test.rb +6 -6
  148. data/test/ffi-glib/hash_table_test.rb +27 -27
  149. data/test/ffi-glib/list_test.rb +22 -22
  150. data/test/ffi-glib/main_loop_test.rb +12 -12
  151. data/test/ffi-glib/ptr_array_test.rb +39 -39
  152. data/test/ffi-glib/ruby_closure_test.rb +10 -10
  153. data/test/ffi-glib/s_list_test.rb +20 -20
  154. data/test/ffi-glib/strv_test.rb +19 -19
  155. data/test/ffi-glib/variant_test.rb +5 -5
  156. data/test/ffi-gobject/gobject_test.rb +48 -44
  157. data/test/ffi-gobject/object_class_test.rb +8 -8
  158. data/test/ffi-gobject/object_test.rb +49 -67
  159. data/test/ffi-gobject/param_spec_test.rb +12 -12
  160. data/test/ffi-gobject/value_test.rb +145 -125
  161. data/test/ffi-gobject_introspection/gobject_type_init_test.rb +8 -8
  162. data/test/ffi-gobject_introspection/i_base_info_test.rb +15 -16
  163. data/test/ffi-gobject_introspection/i_constant_info_test.rb +9 -13
  164. data/test/ffi-gobject_introspection/i_enum_info_test.rb +7 -7
  165. data/test/ffi-gobject_introspection/i_function_info_test.rb +1 -1
  166. data/test/ffi-gobject_introspection/i_interface_info_test.rb +10 -10
  167. data/test/ffi-gobject_introspection/i_object_info_test.rb +23 -23
  168. data/test/ffi-gobject_introspection/i_property_info_test.rb +19 -19
  169. data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +10 -10
  170. data/test/ffi-gobject_introspection/i_repository_test.rb +31 -31
  171. data/test/ffi-gobject_introspection/i_struct_info_test.rb +10 -10
  172. data/test/ffi-gobject_introspection/i_type_info_test.rb +12 -15
  173. data/test/ffi-gobject_introspection/i_union_info_test.rb +7 -7
  174. data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +16 -16
  175. data/test/ffi-gobject_introspection/lib_test.rb +3 -3
  176. data/test/ffi-gobject_introspection/strv_test.rb +9 -9
  177. data/test/ffi-gobject_test.rb +44 -44
  178. data/test/gir_ffi/allocation_helper_test.rb +13 -13
  179. data/test/gir_ffi/arg_helper_test.rb +63 -64
  180. data/test/gir_ffi/boolean_test.rb +20 -20
  181. data/test/gir_ffi/boxed_base_test.rb +18 -18
  182. data/test/gir_ffi/builder_test.rb +115 -93
  183. data/test/gir_ffi/builders/argument_builder_test.rb +280 -286
  184. data/test/gir_ffi/builders/base_argument_builder_test.rb +1 -1
  185. data/test/gir_ffi/builders/callback_argument_builder_test.rb +53 -56
  186. data/test/gir_ffi/builders/callback_builder_test.rb +71 -72
  187. data/test/gir_ffi/builders/callback_return_value_builder_test.rb +36 -40
  188. data/test/gir_ffi/builders/constant_builder_test.rb +1 -1
  189. data/test/gir_ffi/builders/constructor_builder_test.rb +10 -10
  190. data/test/gir_ffi/builders/enum_builder_test.rb +10 -10
  191. data/test/gir_ffi/builders/field_builder_test.rb +42 -42
  192. data/test/gir_ffi/builders/function_builder_test.rb +236 -224
  193. data/test/gir_ffi/builders/initializer_builder_test.rb +14 -14
  194. data/test/gir_ffi/builders/interface_builder_test.rb +9 -9
  195. data/test/gir_ffi/builders/module_builder_test.rb +18 -18
  196. data/test/gir_ffi/builders/object_builder_test.rb +38 -38
  197. data/test/gir_ffi/builders/property_builder_test.rb +91 -94
  198. data/test/gir_ffi/builders/registered_type_builder_test.rb +35 -11
  199. data/test/gir_ffi/builders/return_value_builder_test.rb +215 -222
  200. data/test/gir_ffi/builders/signal_closure_builder_test.rb +122 -113
  201. data/test/gir_ffi/builders/struct_builder_test.rb +32 -32
  202. data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +8 -14
  203. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +23 -23
  204. data/test/gir_ffi/builders/union_builder_test.rb +12 -15
  205. data/test/gir_ffi/builders/user_defined_builder_test.rb +147 -147
  206. data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +40 -40
  207. data/test/gir_ffi/builders/vfunc_builder_test.rb +145 -157
  208. data/test/gir_ffi/callback_base_test.rb +9 -9
  209. data/test/gir_ffi/class_base_test.rb +49 -51
  210. data/test/gir_ffi/core_test.rb +32 -32
  211. data/test/gir_ffi/enum_base_test.rb +19 -19
  212. data/test/gir_ffi/error_type_info_test.rb +23 -23
  213. data/test/gir_ffi/ffi_ext/pointer_test.rb +5 -5
  214. data/test/gir_ffi/g_type_test.rb +11 -11
  215. data/test/gir_ffi/in_pointer_test.rb +70 -50
  216. data/test/gir_ffi/info_ext/i_callable_info_test.rb +5 -5
  217. data/test/gir_ffi/info_ext/i_callback_info_test.rb +4 -4
  218. data/test/gir_ffi/info_ext/i_field_info_test.rb +6 -6
  219. data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -17
  220. data/test/gir_ffi/info_ext/i_signal_info_test.rb +8 -8
  221. data/test/gir_ffi/info_ext/i_type_info_test.rb +229 -215
  222. data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +4 -4
  223. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +8 -8
  224. data/test/gir_ffi/info_ext/safe_function_name_test.rb +8 -8
  225. data/test/gir_ffi/interface_base_test.rb +8 -8
  226. data/test/gir_ffi/method_stubber_test.rb +19 -19
  227. data/test/gir_ffi/object_base_test.rb +19 -19
  228. data/test/gir_ffi/object_store_test.rb +13 -13
  229. data/test/gir_ffi/receiver_argument_info_test.rb +15 -15
  230. data/test/gir_ffi/sized_array_test.rb +68 -68
  231. data/test/gir_ffi/struct_base_test.rb +8 -8
  232. data/test/gir_ffi/struct_like_base_test.rb +64 -64
  233. data/test/gir_ffi/type_map_test.rb +6 -6
  234. data/test/gir_ffi/unintrospectable_type_info_test.rb +33 -33
  235. data/test/gir_ffi/union_base_test.rb +8 -8
  236. data/test/gir_ffi/user_defined_object_info_test.rb +34 -34
  237. data/test/gir_ffi/user_defined_property_info_test.rb +16 -16
  238. data/test/gir_ffi/variable_name_generator_test.rb +8 -8
  239. data/test/gir_ffi/version_test.rb +4 -4
  240. data/test/gir_ffi/zero_terminated_test.rb +34 -34
  241. data/test/gir_ffi_test_helper.rb +3 -3
  242. data/test/integration/callback_exceptions_test.rb +17 -21
  243. data/test/integration/derived_classes_test.rb +13 -13
  244. data/test/integration/generated_everything_test.rb +224 -224
  245. data/test/integration/generated_gimarshallingtests_test.rb +1118 -1017
  246. data/test/integration/generated_gio_test.rb +36 -36
  247. data/test/integration/generated_glib_test.rb +4 -6
  248. data/test/integration/generated_gobject_test.rb +43 -35
  249. data/test/integration/generated_gst_test.rb +16 -16
  250. data/test/integration/generated_gtk_source_test.rb +22 -17
  251. data/test/integration/generated_gtop_test.rb +8 -15
  252. data/test/integration/generated_pango_ft2_test.rb +2 -2
  253. data/test/integration/generated_pango_test.rb +4 -4
  254. data/test/integration/generated_regress_test.rb +1809 -1621
  255. data/test/integration/generated_secret_test.rb +8 -11
  256. data/test/integration/generated_utility_test.rb +81 -81
  257. data/test/integration/generated_warnlib_test.rb +13 -19
  258. data/test/integration/method_lookup_test.rb +6 -6
  259. data/test/introspection_test_helper.rb +48 -7
  260. data/test/minitest/stats_plugin.rb +1 -1
  261. metadata +11 -28
  262. data/lib/ffi-glib/array_methods.rb +0 -16
  263. data/test/gir_ffi/in_out_pointer_test.rb +0 -56
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gir_ffi_test_helper'
3
+ require "gir_ffi_test_helper"
4
4
 
5
5
  describe GirFFI::InfoExt::IUnresolvedInfo do
6
6
  let(:info_class) do
@@ -11,9 +11,9 @@ describe GirFFI::InfoExt::IUnresolvedInfo do
11
11
 
12
12
  let(:unresolved_info) { info_class.new }
13
13
 
14
- describe '#to_ffi_type' do
15
- it 'returns the most generic type' do
16
- unresolved_info.to_ffi_type.must_equal :pointer
14
+ describe "#to_ffi_type" do
15
+ it "returns the most generic type" do
16
+ _(unresolved_info.to_ffi_type).must_equal :pointer
17
17
  end
18
18
  end
19
19
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gir_ffi_test_helper'
3
+ require "gir_ffi_test_helper"
4
4
 
5
5
  describe GirFFI::InfoExt::SafeConstantName do
6
6
  let(:info_class) do
@@ -10,17 +10,17 @@ describe GirFFI::InfoExt::SafeConstantName do
10
10
  end
11
11
  let(:info) { info_class.new }
12
12
 
13
- describe '#safe_name' do
14
- it 'makes names starting with an underscore safe' do
15
- expect(info).to receive(:name).and_return '_foo'
13
+ describe "#safe_name" do
14
+ it "makes names starting with an underscore safe" do
15
+ expect(info).to receive(:name).and_return "_foo"
16
16
 
17
- assert_equal 'Private___foo', info.safe_name
17
+ assert_equal "Private___foo", info.safe_name
18
18
  end
19
19
 
20
- it 'makes names with dashes safe' do
21
- expect(info).to receive(:name).and_return 'this-could-be-a-signal-name'
20
+ it "makes names with dashes safe" do
21
+ expect(info).to receive(:name).and_return "this-could-be-a-signal-name"
22
22
 
23
- info.safe_name.must_equal 'This_could_be_a_signal_name'
23
+ _(info.safe_name).must_equal "This_could_be_a_signal_name"
24
24
  end
25
25
  end
26
26
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gir_ffi_test_helper'
3
+ require "gir_ffi_test_helper"
4
4
 
5
5
  describe GirFFI::InfoExt::SafeFunctionName do
6
6
  let(:info_class) do
@@ -10,17 +10,17 @@ describe GirFFI::InfoExt::SafeFunctionName do
10
10
  end
11
11
  let(:info) { info_class.new }
12
12
 
13
- describe '#safe_name' do
14
- it 'keeps lower case names lower case' do
15
- expect(info).to receive(:name).and_return 'foo'
13
+ describe "#safe_name" do
14
+ it "keeps lower case names lower case" do
15
+ expect(info).to receive(:name).and_return "foo"
16
16
 
17
- assert_equal 'foo', info.safe_name
17
+ assert_equal "foo", info.safe_name
18
18
  end
19
19
 
20
- it 'returns a non-empty string if name is empty' do
21
- expect(info).to receive(:name).and_return ''
20
+ it "returns a non-empty string if name is empty" do
21
+ expect(info).to receive(:name).and_return ""
22
22
 
23
- assert_equal '_', info.safe_name
23
+ assert_equal "_", info.safe_name
24
24
  end
25
25
  end
26
26
  end
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gir_ffi_test_helper'
3
+ require "gir_ffi_test_helper"
4
4
 
5
5
  describe GirFFI::InterfaceBase do
6
6
  let(:interface) { Module.new { extend GirFFI::InterfaceBase } }
7
7
 
8
- describe '#wrap' do
9
- it 'delegates conversion to the wrapped pointer' do
10
- expect(ptr = Object.new).to receive(:to_object).and_return 'good-result'
11
- interface.wrap(ptr).must_equal 'good-result'
8
+ describe "#wrap" do
9
+ it "delegates conversion to the wrapped pointer" do
10
+ expect(ptr = Object.new).to receive(:to_object).and_return "good-result"
11
+ _(interface.wrap(ptr)).must_equal "good-result"
12
12
  end
13
13
  end
14
14
 
15
- describe '.to_ffi_type' do
16
- it 'returns :pointer' do
17
- interface.to_ffi_type.must_equal :pointer
15
+ describe ".to_ffi_type" do
16
+ it "returns :pointer" do
17
+ _(interface.to_ffi_type).must_equal :pointer
18
18
  end
19
19
  end
20
20
  end
@@ -1,19 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gir_ffi_test_helper'
3
+ require "gir_ffi_test_helper"
4
4
 
5
5
  describe GirFFI::MethodStubber do
6
- describe '#method_stub' do
6
+ describe "#method_stub" do
7
7
  let(:stubber) { GirFFI::MethodStubber.new(method_info) }
8
8
  let(:result) { stubber.method_stub }
9
9
 
10
- describe 'for a regular method' do
10
+ describe "for a regular method" do
11
11
  let(:method_info) do
12
- get_method_introspection_data('Regress', 'TestObj', 'instance_method')
12
+ get_method_introspection_data("Regress", "TestObj", "instance_method")
13
13
  end
14
14
 
15
- it 'creates a method stub' do
16
- result.must_equal <<-STUB.reset_indentation
15
+ it "creates a method stub" do
16
+ _(result).must_equal <<~STUB
17
17
  def instance_method *args, &block
18
18
  setup_and_call "instance_method", args, &block
19
19
  end
@@ -21,13 +21,13 @@ describe GirFFI::MethodStubber do
21
21
  end
22
22
  end
23
23
 
24
- describe 'for a static method' do
24
+ describe "for a static method" do
25
25
  let(:method_info) do
26
- get_method_introspection_data('Regress', 'TestObj', 'static_method')
26
+ get_method_introspection_data("Regress", "TestObj", "static_method")
27
27
  end
28
28
 
29
- it 'creates a class method stub' do
30
- result.must_equal <<-STUB.reset_indentation
29
+ it "creates a class method stub" do
30
+ _(result).must_equal <<~STUB
31
31
  def self.static_method *args, &block
32
32
  setup_and_call "static_method", args, &block
33
33
  end
@@ -35,13 +35,13 @@ describe GirFFI::MethodStubber do
35
35
  end
36
36
  end
37
37
 
38
- describe 'for a module function' do
38
+ describe "for a module function" do
39
39
  let(:method_info) do
40
- get_introspection_data('Regress', 'test_int')
40
+ get_introspection_data("Regress", "test_int")
41
41
  end
42
42
 
43
- it 'creates a module method stub' do
44
- result.must_equal <<-STUB.reset_indentation
43
+ it "creates a module method stub" do
44
+ _(result).must_equal <<~STUB
45
45
  def self.test_int *args, &block
46
46
  setup_and_call "test_int", args, &block
47
47
  end
@@ -49,12 +49,12 @@ describe GirFFI::MethodStubber do
49
49
  end
50
50
  end
51
51
 
52
- describe 'for a method with an empty name' do
53
- let(:method_info) { get_method_introspection_data('Regress', 'TestObj', 'instance_method') }
52
+ describe "for a method with an empty name" do
53
+ let(:method_info) { get_method_introspection_data("Regress", "TestObj", "instance_method") }
54
54
 
55
- it 'creates a method stub with a safe name that sets up the unsafe method' do
56
- allow(method_info).to receive(:name).and_return ''
57
- result.must_equal <<-STUB.reset_indentation
55
+ it "creates a method stub with a safe name that sets up the unsafe method" do
56
+ allow(method_info).to receive(:name).and_return ""
57
+ _(result).must_equal <<~STUB
58
58
  def _ *args, &block
59
59
  setup_and_call "", args, &block
60
60
  end
@@ -1,38 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gir_ffi_test_helper'
3
+ require "gir_ffi_test_helper"
4
4
 
5
5
  GirFFI.setup :Regress
6
6
 
7
7
  describe GirFFI::ObjectBase do
8
8
  let(:derived_class) { Class.new GirFFI::ObjectBase }
9
9
 
10
- describe '.wrap' do
11
- it 'delegates conversion to the wrapped pointer' do
12
- expect(ptr = Object.new).to receive(:to_object).and_return 'good-result'
13
- derived_class.wrap(ptr).must_equal 'good-result'
10
+ describe ".wrap" do
11
+ it "delegates conversion to the wrapped pointer" do
12
+ expect(ptr = Object.new).to receive(:to_object).and_return "good-result"
13
+ _(derived_class.wrap(ptr)).must_equal "good-result"
14
14
  end
15
15
  end
16
16
 
17
- describe '.to_ffi_type' do
18
- it 'returns itself' do
19
- derived_class.to_ffi_type.must_equal derived_class
17
+ describe ".to_ffi_type" do
18
+ it "returns itself" do
19
+ _(derived_class.to_ffi_type).must_equal derived_class
20
20
  end
21
21
  end
22
22
 
23
- describe '.object_class' do
24
- it 'returns an object of the class struct type' do
25
- Regress::TestObj.object_class.must_be_instance_of Regress::TestObjClass
23
+ describe ".object_class" do
24
+ it "returns an object of the class struct type" do
25
+ _(Regress::TestObj.object_class).must_be_instance_of Regress::TestObjClass
26
26
  end
27
27
 
28
- it 'caches its result' do
28
+ it "caches its result" do
29
29
  first = Regress::TestObj.object_class
30
30
  second = Regress::TestObj.object_class
31
- second.must_be :eql?, first
31
+ _(second).must_be :eql?, first
32
32
  end
33
33
  end
34
34
 
35
- describe '#included_interfaces' do
35
+ describe "#included_interfaces" do
36
36
  let(:base_class) { GIMarshallingTests::Object }
37
37
  let(:derived_class) { Class.new(base_class) }
38
38
 
@@ -40,12 +40,12 @@ describe GirFFI::ObjectBase do
40
40
  derived_class.class_eval { include GIMarshallingTests::Interface }
41
41
  end
42
42
 
43
- it 'finds the included interface' do
44
- derived_class.included_interfaces.must_equal [GIMarshallingTests::Interface]
43
+ it "finds the included interface" do
44
+ _(derived_class.included_interfaces).must_equal [GIMarshallingTests::Interface]
45
45
  end
46
46
  end
47
47
 
48
- describe '#registered_ancestors' do
48
+ describe "#registered_ancestors" do
49
49
  let(:base_class) { GIMarshallingTests::Object }
50
50
  let(:derived_class) { Class.new(base_class) }
51
51
 
@@ -53,8 +53,8 @@ describe GirFFI::ObjectBase do
53
53
  derived_class.class_eval { include GIMarshallingTests::Interface }
54
54
  end
55
55
 
56
- it 'finds the ancestor classes and included interface' do
57
- derived_class.registered_ancestors.
56
+ it "finds the ancestor classes and included interface" do
57
+ _(derived_class.registered_ancestors).
58
58
  must_equal [derived_class,
59
59
  GIMarshallingTests::Interface,
60
60
  GIMarshallingTests::Object,
@@ -1,41 +1,41 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gir_ffi_test_helper'
3
+ require "gir_ffi_test_helper"
4
4
 
5
5
  describe GirFFI::ObjectStore do
6
6
  let(:store) { GirFFI::ObjectStore.new }
7
7
 
8
- describe '#store' do
9
- it 'returns a non-null pointer when storing objects' do
8
+ describe "#store" do
9
+ it "returns a non-null pointer when storing objects" do
10
10
  obj = Object.new
11
11
  ptr = store.store obj
12
- ptr.wont_be :null?
12
+ _(ptr).wont_be :null?
13
13
  end
14
14
 
15
- it 'returns a null pointer when storing nil' do
15
+ it "returns a null pointer when storing nil" do
16
16
  ptr = store.store nil
17
- ptr.must_be :null?
17
+ _(ptr).must_be :null?
18
18
  end
19
19
  end
20
20
 
21
- describe '#fetch' do
22
- it 'returns the stored object when passed the key pointer' do
21
+ describe "#fetch" do
22
+ it "returns the stored object when passed the key pointer" do
23
23
  obj = Object.new
24
24
  ptr = store.store obj
25
25
  result = store.fetch ptr
26
- result.must_equal obj
26
+ _(result).must_equal obj
27
27
  end
28
28
 
29
- it 'returns the nil object when passed a null pointer' do
29
+ it "returns the nil object when passed a null pointer" do
30
30
  ptr = FFI::Pointer.new(0)
31
31
  result = store.fetch ptr
32
- result.must_be_nil
32
+ _(result).must_be_nil
33
33
  end
34
34
 
35
- it 'returns the pointer itself when passed an unknown pointer' do
35
+ it "returns the pointer itself when passed an unknown pointer" do
36
36
  ptr = FFI::Pointer.new(42)
37
37
  result = store.fetch ptr
38
- result.must_equal ptr
38
+ _(result).must_equal ptr
39
39
  end
40
40
  end
41
41
  end
@@ -1,33 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gir_ffi_test_helper'
4
- require 'gir_ffi/receiver_argument_info'
3
+ require "gir_ffi_test_helper"
4
+ require "gir_ffi/receiver_argument_info"
5
5
 
6
6
  describe GirFFI::ReceiverArgumentInfo do
7
- let(:dummy_type) { 'foo' }
7
+ let(:dummy_type) { "foo" }
8
8
  let(:instance) { GirFFI::ReceiverArgumentInfo.new dummy_type }
9
9
 
10
- describe '#argument_type' do
11
- it 'returns the argument type' do
12
- instance.argument_type.must_equal dummy_type
10
+ describe "#argument_type" do
11
+ it "returns the argument type" do
12
+ _(instance.argument_type).must_equal dummy_type
13
13
  end
14
14
  end
15
15
 
16
- describe '#direction' do
17
- it 'returns the correct value' do
18
- instance.direction.must_equal :in
16
+ describe "#direction" do
17
+ it "returns the correct value" do
18
+ _(instance.direction).must_equal :in
19
19
  end
20
20
  end
21
21
 
22
- describe '#ownership_transfer' do
23
- it 'returns the correct value' do
24
- instance.ownership_transfer.must_equal :everything
22
+ describe "#ownership_transfer" do
23
+ it "returns the correct value" do
24
+ _(instance.ownership_transfer).must_equal :everything
25
25
  end
26
26
  end
27
27
 
28
- describe '#name' do
29
- it 'returns the correct value' do
30
- instance.name.must_equal '_instance'
28
+ describe "#name" do
29
+ it "returns the correct value" do
30
+ _(instance.name).must_equal "_instance"
31
31
  end
32
32
  end
33
33
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gir_ffi_test_helper'
3
+ require "gir_ffi_test_helper"
4
4
 
5
5
  describe GirFFI::SizedArray do
6
- describe '::wrap' do
7
- it 'takes a type, size and pointer and returns a GirFFI::SizedArray wrapping them' do
6
+ describe "::wrap" do
7
+ it "takes a type, size and pointer and returns a GirFFI::SizedArray wrapping them" do
8
8
  expect(ptr = Object.new).to receive(:null?).and_return false
9
9
  sarr = GirFFI::SizedArray.wrap :gint32, 3, ptr
10
10
  assert_instance_of GirFFI::SizedArray, sarr
@@ -13,15 +13,15 @@ describe GirFFI::SizedArray do
13
13
  assert_equal :gint32, sarr.element_type
14
14
  end
15
15
 
16
- it 'returns nil if the wrapped pointer is null' do
16
+ it "returns nil if the wrapped pointer is null" do
17
17
  expect(ptr = Object.new).to receive(:null?).and_return true
18
18
  sarr = GirFFI::SizedArray.wrap :gint32, 3, ptr
19
- sarr.must_be_nil
19
+ _(sarr).must_be_nil
20
20
  end
21
21
  end
22
22
 
23
- describe '#each' do
24
- it 'yields each element' do
23
+ describe "#each" do
24
+ it "yields each element" do
25
25
  ary = %w(one two three)
26
26
  ptrs = ary.map { |a| FFI::MemoryPointer.from_string(a) }
27
27
  ptrs << nil
@@ -37,170 +37,170 @@ describe GirFFI::SizedArray do
37
37
  end
38
38
  end
39
39
 
40
- describe '::from' do
41
- describe 'from a Ruby array' do
42
- it 'creates a GirFFI::SizedArray with the same elements' do
40
+ describe "::from" do
41
+ describe "from a Ruby array" do
42
+ it "creates a GirFFI::SizedArray with the same elements" do
43
43
  arr = GirFFI::SizedArray.from :gint32, 3, [3, 2, 1]
44
- arr.must_be_instance_of GirFFI::SizedArray
44
+ _(arr).must_be_instance_of GirFFI::SizedArray
45
45
  assert_equal [3, 2, 1], arr.to_a
46
46
  end
47
47
 
48
- it 'raises an error if the array has the wrong number of elements' do
49
- proc { GirFFI::SizedArray.from :gint32, 4, [3, 2, 1] }.must_raise ArgumentError
48
+ it "raises an error if the array has the wrong number of elements" do
49
+ _(proc { GirFFI::SizedArray.from :gint32, 4, [3, 2, 1] }).must_raise ArgumentError
50
50
  end
51
51
 
52
52
  it "uses the array's size if passed -1 as the size" do
53
53
  arr = GirFFI::SizedArray.from :gint32, -1, [3, 2, 1]
54
- arr.size.must_equal 3
54
+ _(arr.size).must_equal 3
55
55
  end
56
56
  end
57
57
 
58
- describe 'from a GirFFI::SizedArray' do
59
- it 'return its argument' do
58
+ describe "from a GirFFI::SizedArray" do
59
+ it "return its argument" do
60
60
  arr = GirFFI::SizedArray.from :gint32, 3, [3, 2, 1]
61
61
  arr2 = GirFFI::SizedArray.from :gint32, 3, arr
62
62
  assert_equal arr, arr2
63
63
  end
64
64
 
65
- it 'raises an error if the argument has the wrong number of elements' do
65
+ it "raises an error if the argument has the wrong number of elements" do
66
66
  arr = GirFFI::SizedArray.from :gint32, 3, [3, 2, 1]
67
- proc { GirFFI::SizedArray.from :gint32, 4, arr }.must_raise ArgumentError
67
+ _(proc { GirFFI::SizedArray.from :gint32, 4, arr }).must_raise ArgumentError
68
68
  end
69
69
  end
70
70
 
71
- it 'returns nil when passed nil' do
71
+ it "returns nil when passed nil" do
72
72
  arr = GirFFI::SizedArray.from :gint32, 0, nil
73
- arr.must_be_nil
73
+ _(arr).must_be_nil
74
74
  end
75
75
 
76
- it 'wraps its argument if given a pointer' do
76
+ it "wraps its argument if given a pointer" do
77
77
  arr = GirFFI::SizedArray.from :gint32, 3, [3, 2, 1]
78
78
  arr2 = GirFFI::SizedArray.from :gint32, 3, arr.to_ptr
79
79
  assert_instance_of GirFFI::SizedArray, arr2
80
80
  refute arr2.equal? arr
81
- arr2.to_ptr.must_equal arr.to_ptr
81
+ _(arr2.to_ptr).must_equal arr.to_ptr
82
82
  end
83
83
  end
84
84
 
85
- describe '.copy_from' do
86
- describe 'from a Ruby array' do
87
- it 'creates an unowned GirFFI::SizedArray with the same elements' do
85
+ describe ".copy_from" do
86
+ describe "from a Ruby array" do
87
+ it "creates an unowned GirFFI::SizedArray with the same elements" do
88
88
  arr = GirFFI::SizedArray.copy_from :gint32, 3, [3, 2, 1]
89
- arr.must_be_instance_of GirFFI::SizedArray
89
+ _(arr).must_be_instance_of GirFFI::SizedArray
90
90
  assert_equal [3, 2, 1], arr.to_a
91
- arr.to_ptr.wont_be :autorelease?
91
+ _(arr.to_ptr).wont_be :autorelease?
92
92
  end
93
93
 
94
- it 'creates unowned copies of struct pointer elements' do
94
+ it "creates unowned copies of struct pointer elements" do
95
95
  struct = GIMarshallingTests::BoxedStruct.new
96
96
  struct.long_ = 2342
97
- struct.struct.must_be :owned?
97
+ _(struct.struct).must_be :owned?
98
98
 
99
99
  arr = GirFFI::SizedArray.copy_from([:pointer, GIMarshallingTests::BoxedStruct],
100
100
  1,
101
101
  [struct])
102
- arr.must_be_instance_of GirFFI::SizedArray
103
- arr.to_ptr.wont_be :autorelease?
102
+ _(arr).must_be_instance_of GirFFI::SizedArray
103
+ _(arr.to_ptr).wont_be :autorelease?
104
104
 
105
105
  struct_copy = arr.first
106
- struct_copy.long_.must_equal struct.long_
107
- struct_copy.to_ptr.wont_be :==, struct.to_ptr
108
- struct_copy.struct.wont_be :owned?
106
+ _(struct_copy.long_).must_equal struct.long_
107
+ _(struct_copy.to_ptr).wont_be :==, struct.to_ptr
108
+ _(struct_copy.struct).wont_be :owned?
109
109
  end
110
110
 
111
- it 'increases the ref count of object pointer elements' do
111
+ it "increases the ref count of object pointer elements" do
112
112
  obj = GIMarshallingTests::Object.new 42
113
113
  arr = GirFFI::SizedArray.copy_from([:pointer, GIMarshallingTests::Object],
114
114
  -1,
115
115
  [obj, nil])
116
- arr.must_be_instance_of GirFFI::SizedArray
117
- arr.to_ptr.wont_be :autorelease?
116
+ _(arr).must_be_instance_of GirFFI::SizedArray
117
+ _(arr.to_ptr).wont_be :autorelease?
118
118
 
119
- arr.to_a.must_equal [obj, nil]
120
- object_ref_count(obj).must_equal 2
119
+ _(arr.to_a).must_equal [obj, nil]
120
+ _(object_ref_count(obj)).must_equal 2
121
121
  end
122
122
  end
123
123
 
124
- describe 'from a GirFFI::SizedArray' do
125
- it 'return an unowned copy of its argument' do
124
+ describe "from a GirFFI::SizedArray" do
125
+ it "return an unowned copy of its argument" do
126
126
  arr = GirFFI::SizedArray.from :gint32, 3, [3, 2, 1]
127
127
  arr2 = GirFFI::SizedArray.copy_from :gint32, 3, arr
128
- arr.to_ptr.wont_be :==, arr2.to_ptr
129
- arr2.to_a.must_equal [3, 2, 1]
130
- arr2.to_ptr.wont_be :autorelease?
128
+ _(arr.to_ptr).wont_be :==, arr2.to_ptr
129
+ _(arr2.to_a).must_equal [3, 2, 1]
130
+ _(arr2.to_ptr).wont_be :autorelease?
131
131
  end
132
132
  end
133
133
 
134
- it 'returns nil when passed nil' do
134
+ it "returns nil when passed nil" do
135
135
  arr = GirFFI::SizedArray.copy_from :gint32, 0, nil
136
- arr.must_be_nil
136
+ _(arr).must_be_nil
137
137
  end
138
138
  end
139
139
 
140
- describe '#==' do
141
- it 'returns true when comparing to an array with the same elements' do
140
+ describe "#==" do
141
+ it "returns true when comparing to an array with the same elements" do
142
142
  sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3]
143
143
 
144
- sized.must_be :==, [1, 2, 3]
144
+ _(sized).must_be :==, [1, 2, 3]
145
145
  end
146
146
 
147
- it 'returns false when comparing to an array with different elements' do
147
+ it "returns false when comparing to an array with different elements" do
148
148
  sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3]
149
149
 
150
- sized.wont_be :==, [1, 2]
150
+ _(sized).wont_be :==, [1, 2]
151
151
  end
152
152
 
153
- it 'returns true when comparing to a sized array with the same elements' do
153
+ it "returns true when comparing to a sized array with the same elements" do
154
154
  sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3]
155
155
  other = GirFFI::SizedArray.from :int32, 3, [1, 2, 3]
156
156
 
157
- sized.must_be :==, other
157
+ _(sized).must_be :==, other
158
158
  end
159
159
 
160
- it 'returns false when comparing to a sized array with different elements' do
160
+ it "returns false when comparing to a sized array with different elements" do
161
161
  sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3]
162
162
  other = GirFFI::SizedArray.from :int32, 2, [1, 2]
163
163
 
164
- sized.wont_be :==, other
164
+ _(sized).wont_be :==, other
165
165
  end
166
166
  end
167
167
 
168
- describe '#size_in_bytes' do
169
- it 'returns the correct value' do
168
+ describe "#size_in_bytes" do
169
+ it "returns the correct value" do
170
170
  sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3]
171
171
 
172
- sized.size_in_bytes.must_equal 12
172
+ _(sized.size_in_bytes).must_equal 12
173
173
  end
174
174
  end
175
175
 
176
- describe '.get_value_from_pointer' do
177
- it 'returns just a pointer' do
176
+ describe ".get_value_from_pointer" do
177
+ it "returns just a pointer" do
178
178
  sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3]
179
179
  ptr = sized.to_ptr
180
180
  result = GirFFI::SizedArray.get_value_from_pointer(ptr, 0)
181
- result.must_be :==, ptr
181
+ _(result).must_be :==, ptr
182
182
  end
183
183
 
184
- it 'offsets correctly' do
184
+ it "offsets correctly" do
185
185
  sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3]
186
186
  ptr = sized.to_ptr
187
187
  next_ptr = GirFFI::SizedArray.get_value_from_pointer(ptr, 4)
188
188
  tail = GirFFI::SizedArray.from(:int32, 2, next_ptr)
189
- tail.must_be :==, [2, 3]
189
+ _(tail).must_be :==, [2, 3]
190
190
  end
191
191
  end
192
192
 
193
- describe '.copy_value_to_pointer' do
194
- it 'copies data correctly' do
193
+ describe ".copy_value_to_pointer" do
194
+ it "copies data correctly" do
195
195
  sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3]
196
196
  target = FFI::MemoryPointer.new sized.size_in_bytes
197
197
  GirFFI::SizedArray.copy_value_to_pointer(sized, target)
198
198
  result = GirFFI::SizedArray.from :int32, 3, target
199
- result.must_be :==, [1, 2, 3]
199
+ _(result).must_be :==, [1, 2, 3]
200
200
  end
201
201
  end
202
202
 
203
- it 'includes Enumerable' do
204
- GirFFI::SizedArray.must_include Enumerable
203
+ it "includes Enumerable" do
204
+ _(GirFFI::SizedArray).must_include Enumerable
205
205
  end
206
206
  end