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::Builders::ConstantBuilder do
6
6
  end
@@ -1,16 +1,16 @@
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::Builders::ConstructorBuilder do
6
- describe '#method_definition' do
6
+ describe "#method_definition" do
7
7
  let(:builder) { GirFFI::Builders::ConstructorBuilder.new function_info }
8
8
  let(:code) { builder.method_definition }
9
9
 
10
- describe 'for constructors with the default name' do
11
- let(:function_info) { get_method_introspection_data 'Regress', 'TestObj', 'new' }
12
- it 'builds a constructor' do
13
- code.must_equal <<-CODE.reset_indentation
10
+ describe "for constructors with the default name" do
11
+ let(:function_info) { get_method_introspection_data "Regress", "TestObj", "new" }
12
+ it "builds a constructor" do
13
+ _(code).must_equal <<~CODE
14
14
  def self.new(*args, &block)
15
15
  obj = allocate
16
16
  obj.__send__ :initialize, *args, &block
@@ -20,10 +20,10 @@ describe GirFFI::Builders::ConstructorBuilder do
20
20
  end
21
21
  end
22
22
 
23
- describe 'for constructors with a custom name' do
24
- let(:function_info) { get_method_introspection_data 'Regress', 'TestObj', 'new_from_file' }
25
- it 'builds a custom constructor' do
26
- code.must_equal <<-CODE.reset_indentation
23
+ describe "for constructors with a custom name" do
24
+ let(:function_info) { get_method_introspection_data "Regress", "TestObj", "new_from_file" }
25
+ it "builds a custom constructor" do
26
+ _(code).must_equal <<~CODE
27
27
  def self.new_from_file(*args, &block)
28
28
  raise NoMethodError unless self == Regress::TestObj
29
29
  obj = allocate
@@ -1,23 +1,23 @@
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::Builders::EnumBuilder do
6
- describe '#build_class' do
7
- let(:info) { get_introspection_data 'Regress', 'TestEnum' }
6
+ describe "#build_class" do
7
+ let(:info) { get_introspection_data "Regress", "TestEnum" }
8
8
  let(:builder) { GirFFI::Builders::EnumBuilder.new info }
9
9
 
10
- it 'makes the created type know its proper name' do
10
+ it "makes the created type know its proper name" do
11
11
  enum = builder.build_class
12
- enum.inspect.must_equal 'Regress::TestEnum'
12
+ _(enum.inspect).must_equal "Regress::TestEnum"
13
13
  end
14
14
 
15
- it 'adds constants for the values' do
15
+ it "adds constants for the values" do
16
16
  enum = builder.build_class
17
- enum::VALUE1.must_equal enum[:value1]
18
- enum::VALUE2.must_equal enum[:value2]
19
- enum::VALUE3.must_equal enum[:value3]
20
- enum::VALUE4.must_equal enum[:value4]
17
+ _(enum::VALUE1).must_equal enum[:value1]
18
+ _(enum::VALUE2).must_equal enum[:value2]
19
+ _(enum::VALUE3).must_equal enum[:value3]
20
+ _(enum::VALUE4).must_equal enum[:value4]
21
21
  end
22
22
  end
23
23
  end
@@ -1,40 +1,40 @@
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::Builders::FieldBuilder do
6
- let(:target_class) { 'dummy' }
6
+ let(:target_class) { "dummy" }
7
7
  let(:instance) { GirFFI::Builders::FieldBuilder.new field_info, target_class }
8
8
 
9
- describe 'for a field of type :gint8 with an offset' do
10
- let(:field_info) { get_field_introspection_data 'Regress', 'TestSimpleBoxedA', 'some_int8' }
11
- it 'creates the right getter method' do
12
- expected = <<-CODE.reset_indentation
9
+ describe "for a field of type :gint8 with an offset" do
10
+ let(:field_info) { get_field_introspection_data "Regress", "TestSimpleBoxedA", "some_int8" }
11
+ it "creates the right getter method" do
12
+ expected = <<~CODE
13
13
  def some_int8
14
14
  _v1 = @struct.to_ptr
15
15
  _v2 = _v1.get_int8(#{field_info.offset})
16
16
  _v2
17
17
  end
18
18
  CODE
19
- instance.getter_def.must_equal expected
19
+ _(instance.getter_def).must_equal expected
20
20
  end
21
21
 
22
- it 'creates the right setter method' do
23
- expected = <<-CODE.reset_indentation
22
+ it "creates the right setter method" do
23
+ expected = <<~CODE
24
24
  def some_int8= value
25
25
  _v1 = @struct.to_ptr
26
26
  _v2 = value
27
27
  _v1.put_int8 #{field_info.offset}, _v2
28
28
  end
29
29
  CODE
30
- instance.setter_def.must_equal expected
30
+ _(instance.setter_def).must_equal expected
31
31
  end
32
32
  end
33
33
 
34
- describe 'for a field of type :struct' do
35
- let(:field_info) { get_field_introspection_data 'Regress', 'TestBoxed', 'nested_a' }
36
- it 'creates the right getter method' do
37
- expected = <<-CODE.reset_indentation
34
+ describe "for a field of type :struct" do
35
+ let(:field_info) { get_field_introspection_data "Regress", "TestBoxed", "nested_a" }
36
+ it "creates the right getter method" do
37
+ expected = <<~CODE
38
38
  def nested_a
39
39
  _v1 = @struct.to_ptr
40
40
  _v2 = Regress::TestSimpleBoxedA.get_value_from_pointer(_v1, #{field_info.offset})
@@ -42,39 +42,39 @@ describe GirFFI::Builders::FieldBuilder do
42
42
  _v3
43
43
  end
44
44
  CODE
45
- instance.getter_def.must_equal expected
45
+ _(instance.getter_def).must_equal expected
46
46
  end
47
47
 
48
- it 'creates the right setter method' do
49
- expected = <<-CODE.reset_indentation
48
+ it "creates the right setter method" do
49
+ expected = <<~CODE
50
50
  def nested_a= value
51
51
  _v1 = @struct.to_ptr
52
52
  _v2 = Regress::TestSimpleBoxedA.copy_from(value)
53
53
  Regress::TestSimpleBoxedA.copy_value_to_pointer(_v2, _v1, #{field_info.offset})
54
54
  end
55
55
  CODE
56
- instance.setter_def.must_equal expected
56
+ _(instance.setter_def).must_equal expected
57
57
  end
58
58
  end
59
59
 
60
- describe 'for a field of type :enum' do
61
- let(:field_info) { get_field_introspection_data 'Regress', 'TestStructA', 'some_enum' }
62
- it 'creates the right getter method' do
63
- expected = <<-CODE.reset_indentation
60
+ describe "for a field of type :enum" do
61
+ let(:field_info) { get_field_introspection_data "Regress", "TestStructA", "some_enum" }
62
+ it "creates the right getter method" do
63
+ expected = <<~CODE
64
64
  def some_enum
65
65
  _v1 = @struct.to_ptr
66
66
  _v2 = Regress::TestEnum.get_value_from_pointer(_v1, #{field_info.offset})
67
67
  _v2
68
68
  end
69
69
  CODE
70
- instance.getter_def.must_equal expected
70
+ _(instance.getter_def).must_equal expected
71
71
  end
72
72
  end
73
73
 
74
- describe 'for an inline fixed-size array field' do
75
- let(:field_info) { get_field_introspection_data 'Regress', 'TestStructE', 'some_union' }
76
- it 'creates the right getter method' do
77
- expected = <<-CODE.reset_indentation
74
+ describe "for an inline fixed-size array field" do
75
+ let(:field_info) { get_field_introspection_data "Regress", "TestStructE", "some_union" }
76
+ it "creates the right getter method" do
77
+ expected = <<~CODE
78
78
  def some_union
79
79
  _v1 = @struct.to_ptr
80
80
  _v2 = GirFFI::SizedArray.get_value_from_pointer(_v1, #{field_info.offset})
@@ -82,11 +82,11 @@ describe GirFFI::Builders::FieldBuilder do
82
82
  _v3
83
83
  end
84
84
  CODE
85
- instance.getter_def.must_equal expected
85
+ _(instance.getter_def).must_equal expected
86
86
  end
87
87
 
88
- it 'creates the right setter method' do
89
- expected = <<-CODE.reset_indentation
88
+ it "creates the right setter method" do
89
+ expected = <<~CODE
90
90
  def some_union= value
91
91
  _v1 = @struct.to_ptr
92
92
  GirFFI::ArgHelper.check_fixed_array_size 2, value, \"value\"
@@ -94,31 +94,31 @@ describe GirFFI::Builders::FieldBuilder do
94
94
  GirFFI::SizedArray.copy_value_to_pointer(_v2, _v1, #{field_info.offset})
95
95
  end
96
96
  CODE
97
- instance.setter_def.must_equal expected
97
+ _(instance.setter_def).must_equal expected
98
98
  end
99
99
  end
100
100
 
101
- describe 'for a field of type :callback' do
102
- let(:field_info) { get_field_introspection_data 'GObject', 'TypeInfo', 'class_init' }
103
- it 'creates the right setter method' do
104
- expected = <<-CODE.reset_indentation
101
+ describe "for a field of type :callback" do
102
+ let(:field_info) { get_field_introspection_data "GObject", "TypeInfo", "class_init" }
103
+ it "creates the right setter method" do
104
+ expected = <<~CODE
105
105
  def class_init= value
106
106
  _v1 = @struct.to_ptr
107
107
  _v2 = GObject::ClassInitFunc.from(value)
108
108
  GObject::ClassInitFunc.copy_value_to_pointer(_v2, _v1, #{field_info.offset})
109
109
  end
110
110
  CODE
111
- instance.setter_def.must_equal expected
111
+ _(instance.setter_def).must_equal expected
112
112
  end
113
113
  end
114
114
 
115
- describe 'for a field with a related array length field' do
116
- let(:field_info) { get_field_introspection_data 'GObject', 'SignalQuery', 'param_types' }
117
- let(:n_params_field_info) { get_field_introspection_data 'GObject', 'SignalQuery', 'n_params' }
115
+ describe "for a field with a related array length field" do
116
+ let(:field_info) { get_field_introspection_data "GObject", "SignalQuery", "param_types" }
117
+ let(:n_params_field_info) { get_field_introspection_data "GObject", "SignalQuery", "n_params" }
118
118
 
119
- it 'creates the right getter method' do
119
+ it "creates the right getter method" do
120
120
  skip if field_info.field_type.array_length < 0
121
- expected = <<-CODE.reset_indentation
121
+ expected = <<~CODE
122
122
  def param_types
123
123
  _v1 = @struct.to_ptr
124
124
  _v2 = _v1.get_uint32(#{n_params_field_info.offset})
@@ -128,7 +128,7 @@ describe GirFFI::Builders::FieldBuilder do
128
128
  _v5
129
129
  end
130
130
  CODE
131
- instance.getter_def.must_equal expected
131
+ _(instance.getter_def).must_equal expected
132
132
  end
133
133
  end
134
134
  end
@@ -1,27 +1,26 @@
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::Builders::FunctionBuilder do
6
- describe '#method_definition' do
6
+ describe "#method_definition" do
7
7
  let(:builder) { GirFFI::Builders::FunctionBuilder.new function_info }
8
8
  let(:code) { builder.method_definition }
9
9
 
10
- describe 'generally' do
11
- let(:function_info) { get_method_introspection_data 'GObject', 'Object', 'get_property' }
10
+ describe "generally" do
11
+ let(:function_info) { get_method_introspection_data "GObject", "Object", "get_property" }
12
12
 
13
- it 'returns the same result when called twice' do
13
+ it "returns the same result when called twice" do
14
14
  original = builder.method_definition
15
15
  copy = builder.method_definition
16
- copy.must_equal original
16
+ _(copy).must_equal original
17
17
  end
18
18
  end
19
19
 
20
- describe 'for Regress:test_array_fixed_out_objects' do
21
- let(:function_info) { get_introspection_data 'Regress', 'test_array_fixed_out_objects' }
22
- it 'builds a correct definition' do
23
- skip unless function_info
24
- code.must_equal <<-CODE.reset_indentation
20
+ describe "for Regress:test_array_fixed_out_objects" do
21
+ let(:function_info) { get_introspection_data "Regress", "test_array_fixed_out_objects" }
22
+ it "builds a correct definition" do
23
+ _(code).must_equal <<~CODE
25
24
  def self.test_array_fixed_out_objects
26
25
  _v1 = FFI::MemoryPointer.new :pointer
27
26
  Regress::Lib.regress_test_array_fixed_out_objects _v1
@@ -32,10 +31,10 @@ describe GirFFI::Builders::FunctionBuilder do
32
31
  end
33
32
  end
34
33
 
35
- describe 'for functions having a linked length argument' do
36
- let(:function_info) { get_introspection_data 'Regress', 'test_array_gint16_in' }
37
- it 'builds a correct definition' do
38
- code.must_equal <<-CODE.reset_indentation
34
+ describe "for functions having a linked length argument" do
35
+ let(:function_info) { get_introspection_data "Regress", "test_array_gint16_in" }
36
+ it "builds a correct definition" do
37
+ _(code).must_equal <<~CODE
39
38
  def self.test_array_gint16_in(ints)
40
39
  n_ints = ints.nil? ? 0 : ints.length
41
40
  _v1 = n_ints
@@ -47,11 +46,10 @@ describe GirFFI::Builders::FunctionBuilder do
47
46
  end
48
47
  end
49
48
 
50
- describe 'for methods taking a zero-terminated array with length argument' do
51
- let(:function_info) { get_method_introspection_data 'Regress', 'AnnotationObject', 'parse_args' }
52
- it 'builds a correct definition' do
53
- skip unless function_info
54
- code.must_equal <<-CODE.reset_indentation
49
+ describe "for methods taking a zero-terminated array with length argument" do
50
+ let(:function_info) { get_method_introspection_data "Regress", "AnnotationObject", "parse_args" }
51
+ it "builds a correct definition" do
52
+ _(code).must_equal <<~CODE
55
53
  def parse_args(argv)
56
54
  argc = argv.nil? ? 0 : argv.length
57
55
  _v1 = FFI::MemoryPointer.new :int32
@@ -66,10 +64,10 @@ describe GirFFI::Builders::FunctionBuilder do
66
64
  end
67
65
  end
68
66
 
69
- describe 'for functions with callbacks' do
70
- let(:function_info) { get_introspection_data 'Regress', 'test_callback_destroy_notify' }
71
- it 'builds a correct definition' do
72
- code.must_equal <<-CODE.reset_indentation
67
+ describe "for functions with callbacks" do
68
+ let(:function_info) { get_introspection_data "Regress", "test_callback_destroy_notify" }
69
+ it "builds a correct definition" do
70
+ _(code).must_equal <<~CODE
73
71
  def self.test_callback_destroy_notify(&callback)
74
72
  _v1 = Regress::TestCallbackUserData.from(callback)
75
73
  _v2 = GirFFI::ArgHelper.store(_v1)
@@ -81,10 +79,10 @@ describe GirFFI::Builders::FunctionBuilder do
81
79
  end
82
80
  end
83
81
 
84
- describe 'for functions that take a GValue' do
85
- let(:function_info) { get_introspection_data 'GIMarshallingTests', 'gvalue_in' }
86
- it 'creates a call to GObject::Value#from' do
87
- code.must_equal <<-CODE.reset_indentation
82
+ describe "for functions that take a GValue" do
83
+ let(:function_info) { get_introspection_data "GIMarshallingTests", "gvalue_in" }
84
+ it "creates a call to GObject::Value#from" do
85
+ _(code).must_equal <<~CODE
88
86
  def self.gvalue_in(value)
89
87
  _v1 = GObject::Value.from(value)
90
88
  GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_in _v1
@@ -93,10 +91,10 @@ describe GirFFI::Builders::FunctionBuilder do
93
91
  end
94
92
  end
95
93
 
96
- describe 'for functions that return a GValue' do
97
- let(:function_info) { get_introspection_data 'GIMarshallingTests', 'gvalue_return' }
98
- it 'creates a call to #get_value' do
99
- code.must_equal <<-CODE.reset_indentation
94
+ describe "for functions that return a GValue" do
95
+ let(:function_info) { get_introspection_data "GIMarshallingTests", "gvalue_return" }
96
+ it "creates a call to #get_value" do
97
+ _(code).must_equal <<~CODE
100
98
  def self.gvalue_return
101
99
  _v1 = GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_return
102
100
  _v2 = GObject::Value.wrap(_v1).get_value
@@ -106,10 +104,10 @@ describe GirFFI::Builders::FunctionBuilder do
106
104
  end
107
105
  end
108
106
 
109
- describe 'for functions that have a GValue out argument' do
110
- let(:function_info) { get_introspection_data 'GIMarshallingTests', 'gvalue_out' }
111
- it 'creates a call to #get_value' do
112
- code.must_equal <<-CODE.reset_indentation
107
+ describe "for functions that have a GValue out argument" do
108
+ let(:function_info) { get_introspection_data "GIMarshallingTests", "gvalue_out" }
109
+ it "creates a call to #get_value" do
110
+ _(code).must_equal <<~CODE
113
111
  def self.gvalue_out
114
112
  _v1 = FFI::MemoryPointer.new :pointer
115
113
  GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_out _v1
@@ -120,12 +118,11 @@ describe GirFFI::Builders::FunctionBuilder do
120
118
  end
121
119
  end
122
120
 
123
- describe 'for functions that have a caller-allocated GValue out argument' do
124
- let(:function_info) { get_introspection_data 'GIMarshallingTests', 'gvalue_out_caller_allocates' }
121
+ describe "for functions that have a caller-allocated GValue out argument" do
122
+ let(:function_info) { get_introspection_data "GIMarshallingTests", "gvalue_out_caller_allocates" }
125
123
 
126
- it 'creates a call to #get_value' do
127
- skip unless function_info
128
- code.must_equal <<-CODE.reset_indentation
124
+ it "creates a call to #get_value" do
125
+ _(code).must_equal <<~CODE
129
126
  def self.gvalue_out_caller_allocates
130
127
  _v1 = GObject::Value.new
131
128
  GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_out_caller_allocates _v1
@@ -136,10 +133,10 @@ describe GirFFI::Builders::FunctionBuilder do
136
133
  end
137
134
  end
138
135
 
139
- describe 'for functions with a nullable input array' do
140
- let(:function_info) { get_introspection_data 'Regress', 'test_array_int_null_in' }
141
- it 'builds correct definition' do
142
- code.must_equal <<-CODE.reset_indentation
136
+ describe "for functions with a nullable input array" do
137
+ let(:function_info) { get_introspection_data "Regress", "test_array_int_null_in" }
138
+ it "builds correct definition" do
139
+ _(code).must_equal <<~CODE
143
140
  def self.test_array_int_null_in(arr = nil)
144
141
  len = arr.nil? ? 0 : arr.length
145
142
  _v1 = len
@@ -150,10 +147,10 @@ describe GirFFI::Builders::FunctionBuilder do
150
147
  end
151
148
  end
152
149
 
153
- describe 'for functions with a nullable output array' do
154
- let(:function_info) { get_introspection_data 'Regress', 'test_array_int_null_out' }
155
- it 'builds correct definition' do
156
- code.must_equal <<-CODE.reset_indentation
150
+ describe "for functions with a nullable output array" do
151
+ let(:function_info) { get_introspection_data "Regress", "test_array_int_null_out" }
152
+ it "builds correct definition" do
153
+ _(code).must_equal <<~CODE
157
154
  def self.test_array_int_null_out
158
155
  _v1 = FFI::MemoryPointer.new :int32
159
156
  _v2 = FFI::MemoryPointer.new :pointer
@@ -166,10 +163,10 @@ describe GirFFI::Builders::FunctionBuilder do
166
163
  end
167
164
  end
168
165
 
169
- describe 'for a method with an inout array with size argument' do
170
- let(:function_info) { get_method_introspection_data 'GIMarshallingTests', 'Object', 'method_array_inout' }
171
- it 'builds the correct definition' do
172
- code.must_equal <<-CODE.reset_indentation
166
+ describe "for a method with an inout array with size argument" do
167
+ let(:function_info) { get_method_introspection_data "GIMarshallingTests", "Object", "method_array_inout" }
168
+ it "builds the correct definition" do
169
+ _(code).must_equal <<~CODE
173
170
  def method_array_inout(ints)
174
171
  length = ints.nil? ? 0 : ints.length
175
172
  _v1 = FFI::MemoryPointer.new :int32
@@ -185,11 +182,11 @@ describe GirFFI::Builders::FunctionBuilder do
185
182
  end
186
183
  end
187
184
 
188
- describe 'for a simple method' do
189
- let(:function_info) { get_method_introspection_data 'Regress', 'TestObj', 'instance_method' }
185
+ describe "for a simple method" do
186
+ let(:function_info) { get_method_introspection_data "Regress", "TestObj", "instance_method" }
190
187
 
191
- it 'builds a correct definition' do
192
- code.must_equal <<-CODE.reset_indentation
188
+ it "builds a correct definition" do
189
+ _(code).must_equal <<~CODE
193
190
  def instance_method
194
191
  _v1 = Regress::Lib.regress_test_obj_instance_method self
195
192
  return _v1
@@ -198,11 +195,11 @@ describe GirFFI::Builders::FunctionBuilder do
198
195
  end
199
196
  end
200
197
 
201
- describe 'for GLib::Variant.get_strv' do
202
- let(:function_info) { get_method_introspection_data 'GLib', 'Variant', 'get_strv' }
203
- it 'builds a correct definition' do
198
+ describe "for GLib::Variant.get_strv" do
199
+ let(:function_info) { get_method_introspection_data "GLib", "Variant", "get_strv" }
200
+ it "builds a correct definition" do
204
201
  size_type = ":uint#{FFI.type_size(:size_t) * 8}"
205
- code.must_equal <<-CODE.reset_indentation
202
+ _(code).must_equal <<~CODE
206
203
  def get_strv
207
204
  _v1 = FFI::MemoryPointer.new #{size_type}
208
205
  _v2 = GLib::Lib.g_variant_get_strv self, _v1
@@ -213,12 +210,11 @@ describe GirFFI::Builders::FunctionBuilder do
213
210
  end
214
211
  end
215
212
 
216
- describe 'for Regress.has_parameter_named_attrs' do
217
- let(:function_info) { get_introspection_data 'Regress', 'has_parameter_named_attrs' }
213
+ describe "for Regress.has_parameter_named_attrs" do
214
+ let(:function_info) { get_introspection_data "Regress", "has_parameter_named_attrs" }
218
215
 
219
- it 'builds a correct definition' do
220
- skip unless function_info
221
- code.must_equal <<-CODE.reset_indentation
216
+ it "builds a correct definition" do
217
+ _(code).must_equal <<~CODE
222
218
  def self.has_parameter_named_attrs(foo, attributes)
223
219
  _v1 = foo
224
220
  GirFFI::ArgHelper.check_fixed_array_size 32, attributes, \"attributes\"
@@ -229,15 +225,14 @@ describe GirFFI::Builders::FunctionBuilder do
229
225
  end
230
226
  end
231
227
 
232
- describe 'for GIMarshallingTests::Object#method_int8_arg_and_out_callee' do
228
+ describe "for GIMarshallingTests::Object#method_int8_arg_and_out_callee" do
233
229
  let(:function_info) do
234
- get_method_introspection_data('GIMarshallingTests', 'Object',
235
- 'method_int8_arg_and_out_callee')
230
+ get_method_introspection_data("GIMarshallingTests", "Object",
231
+ "method_int8_arg_and_out_callee")
236
232
  end
237
233
 
238
- it 'builds a correct definition' do
239
- skip unless function_info
240
- code.must_equal <<-CODE.reset_indentation
234
+ it "builds a correct definition" do
235
+ _(code).must_equal <<~CODE
241
236
  def method_int8_arg_and_out_callee(arg)
242
237
  _v1 = arg
243
238
  _v2 = FFI::MemoryPointer.new :pointer
@@ -249,237 +244,254 @@ describe GirFFI::Builders::FunctionBuilder do
249
244
  end
250
245
  end
251
246
 
252
- describe 'object ownership transfer' do
253
- describe 'for GIMarshallingTests::Object#full_in' do
247
+ describe "object ownership transfer" do
248
+ describe "for GIMarshallingTests::Object#full_in" do
254
249
  let(:function_info) do
255
- get_method_introspection_data('GIMarshallingTests', 'Object',
256
- 'full_in')
250
+ get_method_introspection_data("GIMarshallingTests", "Object",
251
+ "full_in")
257
252
  end
258
253
 
259
254
  # NOTE: This method is transfer-ownership: none, despite the name.
260
- it 'builds a correct definition' do
261
- code.must_equal <<-CODE.reset_indentation
262
- def full_in
263
- GIMarshallingTests::Lib.gi_marshalling_tests_object_full_in self
264
- end
255
+ it "builds a correct definition" do
256
+ _(code).must_equal <<~CODE
257
+ def full_in
258
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_full_in self
259
+ end
265
260
  CODE
266
261
  end
267
262
  end
268
263
 
269
- describe 'for GIMarshallingTests::Object.full_inout' do
264
+ describe "for GIMarshallingTests::Object.full_inout" do
270
265
  let(:function_info) do
271
- get_method_introspection_data('GIMarshallingTests', 'Object',
272
- 'full_inout')
266
+ get_method_introspection_data("GIMarshallingTests", "Object",
267
+ "full_inout")
273
268
  end
274
269
 
275
- it 'builds a correct definition' do
276
- code.must_equal <<-CODE.reset_indentation
277
- def self.full_inout(object)
278
- _v1 = FFI::MemoryPointer.new :pointer
279
- _v1.put_pointer 0, GIMarshallingTests::Object.from(object && object.ref)
280
- GIMarshallingTests::Lib.gi_marshalling_tests_object_full_inout _v1
281
- _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0))
282
- return _v2
283
- end
270
+ it "builds a correct definition" do
271
+ _(code).must_equal <<~CODE
272
+ def self.full_inout(object)
273
+ _v1 = FFI::MemoryPointer.new :pointer
274
+ _v1.put_pointer 0, GIMarshallingTests::Object.from(object && object.ref)
275
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_full_inout _v1
276
+ _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0))
277
+ return _v2
278
+ end
284
279
  CODE
285
280
  end
286
281
  end
287
282
 
288
- describe 'for GIMarshallingTests::Object.full_out' do
283
+ describe "for GIMarshallingTests::Object.full_out" do
289
284
  let(:function_info) do
290
- get_method_introspection_data('GIMarshallingTests', 'Object',
291
- 'full_out')
285
+ get_method_introspection_data("GIMarshallingTests", "Object",
286
+ "full_out")
292
287
  end
293
288
 
294
- it 'builds a correct definition' do
295
- code.must_equal <<-CODE.reset_indentation
296
- def self.full_out
297
- _v1 = FFI::MemoryPointer.new :pointer
298
- GIMarshallingTests::Lib.gi_marshalling_tests_object_full_out _v1
299
- _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0))
300
- return _v2
301
- end
289
+ it "builds a correct definition" do
290
+ _(code).must_equal <<~CODE
291
+ def self.full_out
292
+ _v1 = FFI::MemoryPointer.new :pointer
293
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_full_out _v1
294
+ _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0))
295
+ return _v2
296
+ end
302
297
  CODE
303
298
  end
304
299
  end
305
300
 
306
- describe 'for GIMarshallingTests::Object.full_return' do
301
+ describe "for GIMarshallingTests::Object.full_return" do
307
302
  let(:function_info) do
308
- get_method_introspection_data('GIMarshallingTests', 'Object',
309
- 'full_return')
303
+ get_method_introspection_data("GIMarshallingTests", "Object",
304
+ "full_return")
310
305
  end
311
306
 
312
- it 'builds a correct definition' do
313
- code.must_equal <<-CODE.reset_indentation
314
- def self.full_return
315
- _v1 = GIMarshallingTests::Lib.gi_marshalling_tests_object_full_return
316
- _v2 = GIMarshallingTests::Object.wrap(_v1)
317
- return _v2
318
- end
307
+ it "builds a correct definition" do
308
+ _(code).must_equal <<~CODE
309
+ def self.full_return
310
+ _v1 = GIMarshallingTests::Lib.gi_marshalling_tests_object_full_return
311
+ _v2 = GIMarshallingTests::Object.wrap(_v1)
312
+ return _v2
313
+ end
319
314
  CODE
320
315
  end
321
316
  end
322
317
 
323
- describe 'for GIMarshallingTests::Object#none_in' do
318
+ describe "for GIMarshallingTests::Object#none_in" do
324
319
  let(:function_info) do
325
- get_method_introspection_data('GIMarshallingTests', 'Object',
326
- 'none_in')
320
+ get_method_introspection_data("GIMarshallingTests", "Object",
321
+ "none_in")
327
322
  end
328
323
 
329
- it 'builds a correct definition' do
330
- code.must_equal <<-CODE.reset_indentation
331
- def none_in
332
- GIMarshallingTests::Lib.gi_marshalling_tests_object_none_in self
333
- end
324
+ it "builds a correct definition" do
325
+ _(code).must_equal <<~CODE
326
+ def none_in
327
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_none_in self
328
+ end
334
329
  CODE
335
330
  end
336
331
  end
337
332
 
338
- describe 'for GIMarshallingTests::Object.none_inout' do
333
+ describe "for GIMarshallingTests::Object.none_inout" do
339
334
  let(:function_info) do
340
- get_method_introspection_data('GIMarshallingTests', 'Object',
341
- 'none_inout')
335
+ get_method_introspection_data("GIMarshallingTests", "Object",
336
+ "none_inout")
342
337
  end
343
338
 
344
- it 'builds a correct definition' do
345
- code.must_equal <<-CODE.reset_indentation
346
- def self.none_inout(object)
347
- _v1 = FFI::MemoryPointer.new :pointer
348
- _v1.put_pointer 0, GIMarshallingTests::Object.from(object)
349
- GIMarshallingTests::Lib.gi_marshalling_tests_object_none_inout _v1
350
- _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0)).tap { |it| it && it.ref }
351
- return _v2
352
- end
339
+ it "builds a correct definition" do
340
+ _(code).must_equal <<~CODE
341
+ def self.none_inout(object)
342
+ _v1 = FFI::MemoryPointer.new :pointer
343
+ _v1.put_pointer 0, GIMarshallingTests::Object.from(object)
344
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_none_inout _v1
345
+ _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0)).tap { |it| it && it.ref }
346
+ return _v2
347
+ end
353
348
  CODE
354
349
  end
355
350
  end
356
351
 
357
- describe 'for GIMarshallingTests::Object.none_out' do
352
+ describe "for GIMarshallingTests::Object.none_out" do
358
353
  let(:function_info) do
359
- get_method_introspection_data('GIMarshallingTests', 'Object',
360
- 'none_out')
354
+ get_method_introspection_data("GIMarshallingTests", "Object",
355
+ "none_out")
361
356
  end
362
357
 
363
- it 'builds a correct definition' do
364
- code.must_equal <<-CODE.reset_indentation
365
- def self.none_out
366
- _v1 = FFI::MemoryPointer.new :pointer
367
- GIMarshallingTests::Lib.gi_marshalling_tests_object_none_out _v1
368
- _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0)).tap { |it| it && it.ref }
369
- return _v2
370
- end
358
+ it "builds a correct definition" do
359
+ _(code).must_equal <<~CODE
360
+ def self.none_out
361
+ _v1 = FFI::MemoryPointer.new :pointer
362
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_none_out _v1
363
+ _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0)).tap { |it| it && it.ref }
364
+ return _v2
365
+ end
371
366
  CODE
372
367
  end
373
368
  end
374
369
 
375
- describe 'for GIMarshallingTests::Object.none_return' do
370
+ describe "for GIMarshallingTests::Object.none_return" do
376
371
  let(:function_info) do
377
- get_method_introspection_data('GIMarshallingTests', 'Object',
378
- 'none_return')
372
+ get_method_introspection_data("GIMarshallingTests", "Object",
373
+ "none_return")
379
374
  end
380
375
 
381
- it 'builds a correct definition' do
382
- code.must_equal <<-CODE.reset_indentation
383
- def self.none_return
384
- _v1 = GIMarshallingTests::Lib.gi_marshalling_tests_object_none_return
385
- _v2 = GIMarshallingTests::Object.wrap(_v1).tap { |it| it && it.ref }
386
- return _v2
387
- end
376
+ it "builds a correct definition" do
377
+ _(code).must_equal <<~CODE
378
+ def self.none_return
379
+ _v1 = GIMarshallingTests::Lib.gi_marshalling_tests_object_none_return
380
+ _v2 = GIMarshallingTests::Object.wrap(_v1).tap { |it| it && it.ref }
381
+ return _v2
382
+ end
388
383
  CODE
389
384
  end
390
385
  end
391
386
 
392
- describe 'for Regress::TestObj#instance_method_full' do
387
+ describe "for Regress::TestObj#instance_method_full" do
393
388
  let(:function_info) do
394
- get_method_introspection_data('Regress', 'TestObj',
395
- 'instance_method_full')
389
+ get_method_introspection_data("Regress", "TestObj",
390
+ "instance_method_full")
396
391
  end
397
392
 
398
- it 'builds a correct definition including self.ref' do
399
- skip unless function_info
400
- code.must_equal <<-CODE.reset_indentation
401
- def instance_method_full
402
- Regress::Lib.regress_test_obj_instance_method_full self.ref
403
- end
393
+ it "builds a correct definition including self.ref" do
394
+ _(code).must_equal <<~CODE
395
+ def instance_method_full
396
+ Regress::Lib.regress_test_obj_instance_method_full self.ref
397
+ end
404
398
  CODE
405
399
  end
406
400
  end
407
401
  end
408
402
 
409
- describe 'struct ownership transfer' do
410
- describe 'for GIMarshallingTests::BoxedStruct.inout' do
403
+ describe "struct ownership transfer" do
404
+ describe "for Regress::FooRectangle#add" do
411
405
  let(:function_info) do
412
- get_method_introspection_data('GIMarshallingTests', 'BoxedStruct', 'inout')
406
+ get_method_introspection_data("Regress", "FooRectangle",
407
+ "add")
413
408
  end
414
409
 
415
- it 'builds a correct definition' do
416
- code.must_equal <<-CODE.reset_indentation
417
- def self.inout(struct_)
418
- _v1 = FFI::MemoryPointer.new :pointer
419
- _v1.put_pointer 0, GIMarshallingTests::BoxedStruct.copy_from(struct_)
420
- GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_inout _v1
421
- _v2 = GIMarshallingTests::BoxedStruct.wrap_own(_v1.get_pointer(0))
422
- return _v2
423
- end
410
+ it "builds a correct definition without #ref" do
411
+ _(code).must_equal <<~CODE
412
+ def add(r2)
413
+ _v1 = Regress::FooRectangle.from(r2)
414
+ Regress::Lib.regress_foo_rectangle_add self, _v1
415
+ end
424
416
  CODE
425
417
  end
426
418
  end
419
+ end
427
420
 
428
- describe 'for GIMarshallingTests::BoxedStruct.out' do
421
+ describe "boxed struct ownership transfer" do
422
+ describe "for GIMarshallingTests::BoxedStruct.inout" do
429
423
  let(:function_info) do
430
- get_method_introspection_data('GIMarshallingTests', 'BoxedStruct', 'out')
424
+ get_method_introspection_data("GIMarshallingTests", "BoxedStruct", "inout")
431
425
  end
432
426
 
433
- it 'builds a correct definition' do
434
- code.must_equal <<-CODE.reset_indentation
435
- def self.out
436
- _v1 = FFI::MemoryPointer.new :pointer
437
- GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_out _v1
438
- _v2 = GIMarshallingTests::BoxedStruct.wrap_copy(_v1.get_pointer(0))
439
- return _v2
440
- end
427
+ it "builds a correct definition" do
428
+ _(code).must_equal <<~CODE
429
+ def self.inout(struct_)
430
+ _v1 = FFI::MemoryPointer.new :pointer
431
+ _v1.put_pointer 0, GIMarshallingTests::BoxedStruct.copy_from(struct_)
432
+ GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_inout _v1
433
+ _v2 = GIMarshallingTests::BoxedStruct.wrap_own(_v1.get_pointer(0))
434
+ return _v2
435
+ end
441
436
  CODE
442
437
  end
443
438
  end
444
439
 
445
- describe 'for GIMarshallingTests::BoxedStruct.returnv' do
440
+ describe "for GIMarshallingTests::BoxedStruct.out" do
446
441
  let(:function_info) do
447
- get_method_introspection_data('GIMarshallingTests', 'BoxedStruct', 'returnv')
442
+ get_method_introspection_data("GIMarshallingTests", "BoxedStruct", "out")
448
443
  end
449
444
 
450
- it 'builds a correct definition' do
451
- code.must_equal <<-CODE.reset_indentation
452
- def self.returnv
453
- _v1 = GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_returnv
454
- _v2 = GIMarshallingTests::BoxedStruct.wrap_copy(_v1)
455
- return _v2
456
- end
445
+ it "builds a correct definition" do
446
+ _(code).must_equal <<~CODE
447
+ def self.out
448
+ _v1 = FFI::MemoryPointer.new :pointer
449
+ GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_out _v1
450
+ _v2 = GIMarshallingTests::BoxedStruct.wrap_copy(_v1.get_pointer(0))
451
+ return _v2
452
+ end
457
453
  CODE
458
454
  end
459
455
  end
460
- end
461
456
 
462
- describe 'string ownership transfer' do
463
- describe 'for Regress.test_utf8_out' do
464
- let(:function_info) { get_introspection_data 'Regress', 'test_utf8_out' }
457
+ describe "for GIMarshallingTests::BoxedStruct.returnv" do
458
+ let(:function_info) do
459
+ get_method_introspection_data("GIMarshallingTests", "BoxedStruct", "returnv")
460
+ end
465
461
 
466
- it 'builds a correct definition' do
467
- code.must_equal <<-CODE.reset_indentation
468
- def self.test_utf8_out
469
- _v1 = FFI::MemoryPointer.new :pointer
470
- Regress::Lib.regress_test_utf8_out _v1
471
- _v2 = GirFFI::AllocationHelper.free_after _v1.get_pointer(0), &:to_utf8
472
- return _v2
473
- end
462
+ it "builds a correct definition" do
463
+ _(code).must_equal <<~CODE
464
+ def self.returnv
465
+ _v1 = GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_returnv
466
+ _v2 = GIMarshallingTests::BoxedStruct.wrap_copy(_v1)
467
+ return _v2
468
+ end
469
+ CODE
470
+ end
471
+ end
472
+ end
473
+
474
+ describe "string ownership transfer" do
475
+ describe "for Regress.test_utf8_out" do
476
+ let(:function_info) { get_introspection_data "Regress", "test_utf8_out" }
477
+
478
+ it "builds a correct definition" do
479
+ _(code).must_equal <<~CODE
480
+ def self.test_utf8_out
481
+ _v1 = FFI::MemoryPointer.new :pointer
482
+ Regress::Lib.regress_test_utf8_out _v1
483
+ _v2 = GirFFI::AllocationHelper.free_after _v1.get_pointer(0), &:to_utf8
484
+ return _v2
485
+ end
474
486
  CODE
475
487
  end
476
488
  end
477
489
  end
478
490
 
479
- describe 'for functions with an allow-none ingoing parameter' do
480
- let(:function_info) { get_introspection_data 'Regress', 'test_utf8_null_in' }
481
- it 'builds correct definition with default parameter value' do
482
- code.must_equal <<-CODE.reset_indentation
491
+ describe "for functions with an allow-none ingoing parameter" do
492
+ let(:function_info) { get_introspection_data "Regress", "test_utf8_null_in" }
493
+ it "builds correct definition with default parameter value" do
494
+ _(code).must_equal <<~CODE
483
495
  def self.test_utf8_null_in(in_ = nil)
484
496
  _v1 = GirFFI::InPointer.from_utf8(in_)
485
497
  Regress::Lib.regress_test_utf8_null_in _v1
@@ -488,10 +500,10 @@ describe GirFFI::Builders::FunctionBuilder do
488
500
  end
489
501
  end
490
502
 
491
- describe 'for functions where some allow-none cannot be honored' do
492
- let(:function_info) { get_introspection_data 'GIMarshallingTests', 'array_in_utf8_two_in_out_of_order' }
493
- it 'builds correct definition with default parameter value on the later arguments' do
494
- code.must_equal <<-CODE.reset_indentation
503
+ describe "for functions where some allow-none cannot be honored" do
504
+ let(:function_info) { get_introspection_data "GIMarshallingTests", "array_in_utf8_two_in_out_of_order" }
505
+ it "builds correct definition with default parameter value on the later arguments" do
506
+ _(code).must_equal <<~CODE
495
507
  def self.array_in_utf8_two_in_out_of_order(a, ints, b = nil)
496
508
  length = ints.nil? ? 0 : ints.length
497
509
  _v1 = length
@@ -504,12 +516,12 @@ describe GirFFI::Builders::FunctionBuilder do
504
516
  end
505
517
  end
506
518
 
507
- describe 'ownership transfer for an ingoing array of structs' do
508
- describe 'with no ownership transfer of the elements' do
509
- let(:function_info) { get_introspection_data 'GIMarshallingTests', 'array_struct_in' }
519
+ describe "ownership transfer for an ingoing array of structs" do
520
+ describe "with no ownership transfer of the elements" do
521
+ let(:function_info) { get_introspection_data "GIMarshallingTests", "array_struct_in" }
510
522
 
511
- it 'builds a correct definition' do
512
- code.must_equal <<-CODE.reset_indentation
523
+ it "builds a correct definition" do
524
+ _(code).must_equal <<~CODE
513
525
  def self.array_struct_in(structs)
514
526
  length = structs.nil? ? 0 : structs.length
515
527
  _v1 = length
@@ -519,11 +531,11 @@ describe GirFFI::Builders::FunctionBuilder do
519
531
  CODE
520
532
  end
521
533
  end
522
- describe 'with ownership transfer of the elements' do
523
- let(:function_info) { get_introspection_data 'GIMarshallingTests', 'array_struct_take_in' }
534
+ describe "with ownership transfer of the elements" do
535
+ let(:function_info) { get_introspection_data "GIMarshallingTests", "array_struct_take_in" }
524
536
 
525
- it 'builds a correct definition' do
526
- code.must_equal <<-CODE.reset_indentation
537
+ it "builds a correct definition" do
538
+ _(code).must_equal <<~CODE
527
539
  def self.array_struct_take_in(structs)
528
540
  length = structs.nil? ? 0 : structs.length
529
541
  _v1 = length