gir_ffi 0.14.0 → 0.15.3

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 (265) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +45 -0
  3. data/Gemfile +6 -4
  4. data/README.md +11 -10
  5. data/Rakefile +5 -5
  6. data/lib/ffi-glib.rb +16 -16
  7. data/lib/ffi-glib/array.rb +14 -4
  8. data/lib/ffi-glib/byte_array.rb +7 -2
  9. data/lib/ffi-glib/container_class_methods.rb +1 -1
  10. data/lib/ffi-glib/error.rb +1 -1
  11. data/lib/ffi-glib/hash_table.rb +3 -3
  12. data/lib/ffi-glib/list.rb +1 -1
  13. data/lib/ffi-glib/list_methods.rb +1 -1
  14. data/lib/ffi-glib/main_loop.rb +3 -3
  15. data/lib/ffi-glib/ptr_array.rb +30 -8
  16. data/lib/ffi-glib/s_list.rb +1 -1
  17. data/lib/ffi-glib/variant.rb +1 -1
  18. data/lib/ffi-gobject.rb +13 -13
  19. data/lib/ffi-gobject/object.rb +23 -32
  20. data/lib/ffi-gobject/param_spec.rb +1 -1
  21. data/lib/ffi-gobject/ruby_closure.rb +2 -2
  22. data/lib/ffi-gobject/value.rb +40 -29
  23. data/lib/ffi-gobject_introspection.rb +20 -20
  24. data/lib/ffi-gobject_introspection/gobject_type_init.rb +2 -2
  25. data/lib/ffi-gobject_introspection/i_arg_info.rb +2 -2
  26. data/lib/ffi-gobject_introspection/i_base_info.rb +27 -17
  27. data/lib/ffi-gobject_introspection/i_callable_info.rb +4 -4
  28. data/lib/ffi-gobject_introspection/i_constant_info.rb +2 -2
  29. data/lib/ffi-gobject_introspection/i_enum_info.rb +1 -0
  30. data/lib/ffi-gobject_introspection/i_field_info.rb +1 -1
  31. data/lib/ffi-gobject_introspection/i_function_info.rb +1 -1
  32. data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -1
  33. data/lib/ffi-gobject_introspection/i_object_info.rb +2 -2
  34. data/lib/ffi-gobject_introspection/i_property_info.rb +2 -2
  35. data/lib/ffi-gobject_introspection/i_repository.rb +9 -6
  36. data/lib/ffi-gobject_introspection/i_struct_info.rb +2 -1
  37. data/lib/ffi-gobject_introspection/i_type_info.rb +13 -7
  38. data/lib/ffi-gobject_introspection/i_unresolved_info.rb +1 -1
  39. data/lib/ffi-gobject_introspection/i_vfunc_info.rb +1 -1
  40. data/lib/ffi-gobject_introspection/lib.rb +30 -19
  41. data/lib/ffi-gobject_introspection/strv.rb +1 -1
  42. data/lib/gir_ffi-base.rb +1 -1
  43. data/lib/gir_ffi-base/gobject.rb +26 -25
  44. data/lib/gir_ffi-base/gobject/lib.rb +3 -2
  45. data/lib/gir_ffi.rb +3 -3
  46. data/lib/gir_ffi/allocation_helper.rb +1 -1
  47. data/lib/gir_ffi/arg_helper.rb +4 -4
  48. data/lib/gir_ffi/{in_out_pointer.rb → array_element_convertor.rb} +16 -23
  49. data/lib/gir_ffi/boolean.rb +1 -1
  50. data/lib/gir_ffi/boxed_base.rb +1 -1
  51. data/lib/gir_ffi/builder.rb +18 -10
  52. data/lib/gir_ffi/builder_helper.rb +6 -1
  53. data/lib/gir_ffi/builders/argument_builder.rb +19 -19
  54. data/lib/gir_ffi/builders/argument_builder_collection.rb +2 -2
  55. data/lib/gir_ffi/builders/base_argument_builder.rb +1 -0
  56. data/lib/gir_ffi/builders/base_method_builder.rb +7 -7
  57. data/lib/gir_ffi/builders/base_return_value_builder.rb +1 -1
  58. data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
  59. data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +5 -5
  60. data/lib/gir_ffi/builders/callback_argument_builder.rb +8 -8
  61. data/lib/gir_ffi/builders/callback_builder.rb +16 -4
  62. data/lib/gir_ffi/builders/callback_return_value_builder.rb +2 -2
  63. data/lib/gir_ffi/builders/closure_argument_builder.rb +1 -1
  64. data/lib/gir_ffi/builders/closure_return_value_builder.rb +1 -1
  65. data/lib/gir_ffi/builders/constant_builder.rb +1 -1
  66. data/lib/gir_ffi/builders/constructor_builder.rb +9 -9
  67. data/lib/gir_ffi/builders/enum_builder.rb +16 -3
  68. data/lib/gir_ffi/builders/field_builder.rb +20 -18
  69. data/lib/gir_ffi/builders/flags_builder.rb +2 -2
  70. data/lib/gir_ffi/builders/full_c_to_ruby_convertor.rb +1 -1
  71. data/lib/gir_ffi/builders/function_builder.rb +11 -5
  72. data/lib/gir_ffi/builders/initializer_builder.rb +3 -3
  73. data/lib/gir_ffi/builders/initializer_return_value_builder.rb +2 -2
  74. data/lib/gir_ffi/builders/interface_builder.rb +2 -2
  75. data/lib/gir_ffi/builders/mapping_method_builder.rb +9 -9
  76. data/lib/gir_ffi/builders/marshalling_method_builder.rb +7 -7
  77. data/lib/gir_ffi/builders/method_template.rb +1 -1
  78. data/lib/gir_ffi/builders/module_builder.rb +7 -7
  79. data/lib/gir_ffi/builders/object_builder.rb +6 -6
  80. data/lib/gir_ffi/builders/property_argument_builder.rb +1 -1
  81. data/lib/gir_ffi/builders/property_builder.rb +13 -12
  82. data/lib/gir_ffi/builders/property_return_value_builder.rb +1 -1
  83. data/lib/gir_ffi/builders/registered_type_builder.rb +14 -5
  84. data/lib/gir_ffi/builders/return_value_builder.rb +4 -4
  85. data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +6 -6
  86. data/lib/gir_ffi/builders/signal_closure_builder.rb +2 -2
  87. data/lib/gir_ffi/builders/struct_builder.rb +6 -4
  88. data/lib/gir_ffi/builders/struct_like.rb +1 -1
  89. data/lib/gir_ffi/builders/type_builder.rb +12 -12
  90. data/lib/gir_ffi/builders/unintrospectable_boxed_builder.rb +2 -2
  91. data/lib/gir_ffi/builders/unintrospectable_builder.rb +2 -2
  92. data/lib/gir_ffi/builders/union_builder.rb +4 -4
  93. data/lib/gir_ffi/builders/user_defined_builder.rb +2 -2
  94. data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
  95. data/lib/gir_ffi/builders/vfunc_builder.rb +8 -8
  96. data/lib/gir_ffi/builders/with_layout.rb +2 -2
  97. data/lib/gir_ffi/callback_base.rb +4 -6
  98. data/lib/gir_ffi/class_base.rb +6 -5
  99. data/lib/gir_ffi/core.rb +19 -20
  100. data/lib/gir_ffi/enum_base.rb +1 -1
  101. data/lib/gir_ffi/enum_like_base.rb +2 -2
  102. data/lib/gir_ffi/error_argument_info.rb +2 -2
  103. data/lib/gir_ffi/error_type_info.rb +1 -1
  104. data/lib/gir_ffi/ffi_ext.rb +1 -1
  105. data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
  106. data/lib/gir_ffi/flags_base.rb +1 -1
  107. data/lib/gir_ffi/in_pointer.rb +10 -0
  108. data/lib/gir_ffi/info_ext.rb +15 -14
  109. data/lib/gir_ffi/info_ext/full_type_name.rb +3 -3
  110. data/lib/gir_ffi/info_ext/i_arg_info.rb +1 -1
  111. data/lib/gir_ffi/info_ext/i_callable_info.rb +1 -1
  112. data/lib/gir_ffi/info_ext/i_callback_info.rb +1 -1
  113. data/lib/gir_ffi/info_ext/i_field_info.rb +1 -1
  114. data/lib/gir_ffi/info_ext/i_function_info.rb +1 -1
  115. data/lib/gir_ffi/info_ext/i_property_info.rb +2 -2
  116. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +4 -5
  117. data/lib/gir_ffi/info_ext/i_signal_info.rb +7 -3
  118. data/lib/gir_ffi/info_ext/i_type_info.rb +48 -26
  119. data/lib/gir_ffi/info_ext/i_unresolved_info.rb +1 -1
  120. data/lib/gir_ffi/info_ext/i_value_info.rb +25 -0
  121. data/lib/gir_ffi/info_ext/i_vfunc_info.rb +2 -2
  122. data/lib/gir_ffi/info_ext/safe_constant_name.rb +8 -8
  123. data/lib/gir_ffi/info_ext/safe_function_name.rb +2 -2
  124. data/lib/gir_ffi/interface_base.rb +3 -3
  125. data/lib/gir_ffi/lib_c.rb +1 -1
  126. data/lib/gir_ffi/method_stubber.rb +1 -1
  127. data/lib/gir_ffi/module_base.rb +1 -1
  128. data/lib/gir_ffi/object_base.rb +3 -4
  129. data/lib/gir_ffi/receiver_argument_info.rb +1 -1
  130. data/lib/gir_ffi/receiver_type_info.rb +2 -2
  131. data/lib/gir_ffi/registered_type_base.rb +1 -1
  132. data/lib/gir_ffi/sized_array.rb +4 -2
  133. data/lib/gir_ffi/struct.rb +1 -1
  134. data/lib/gir_ffi/struct_base.rb +1 -1
  135. data/lib/gir_ffi/type_map.rb +2 -23
  136. data/lib/gir_ffi/unintrospectable_boxed_info.rb +2 -2
  137. data/lib/gir_ffi/unintrospectable_type_info.rb +5 -1
  138. data/lib/gir_ffi/union.rb +1 -1
  139. data/lib/gir_ffi/union_base.rb +1 -1
  140. data/lib/gir_ffi/user_defined_object_info.rb +6 -2
  141. data/lib/gir_ffi/user_defined_property_info.rb +33 -33
  142. data/lib/gir_ffi/version.rb +1 -1
  143. data/tasks/test.rake +3 -2
  144. data/test/base_test_helper.rb +16 -9
  145. data/test/ffi-glib/array_test.rb +71 -56
  146. data/test/ffi-glib/byte_array_test.rb +13 -7
  147. data/test/ffi-glib/bytes_test.rb +24 -19
  148. data/test/ffi-glib/closure_test.rb +11 -11
  149. data/test/ffi-glib/destroy_notify_test.rb +6 -6
  150. data/test/ffi-glib/hash_table_test.rb +27 -27
  151. data/test/ffi-glib/list_test.rb +22 -22
  152. data/test/ffi-glib/main_loop_test.rb +12 -12
  153. data/test/ffi-glib/ptr_array_test.rb +39 -39
  154. data/test/ffi-glib/ruby_closure_test.rb +10 -10
  155. data/test/ffi-glib/s_list_test.rb +20 -20
  156. data/test/ffi-glib/strv_test.rb +19 -19
  157. data/test/ffi-glib/variant_test.rb +5 -5
  158. data/test/ffi-gobject/gobject_test.rb +48 -44
  159. data/test/ffi-gobject/object_class_test.rb +8 -8
  160. data/test/ffi-gobject/object_test.rb +51 -68
  161. data/test/ffi-gobject/param_spec_test.rb +12 -12
  162. data/test/ffi-gobject/value_test.rb +145 -125
  163. data/test/ffi-gobject_introspection/gobject_type_init_test.rb +9 -9
  164. data/test/ffi-gobject_introspection/i_base_info_test.rb +15 -16
  165. data/test/ffi-gobject_introspection/i_constant_info_test.rb +9 -13
  166. data/test/ffi-gobject_introspection/i_enum_info_test.rb +7 -7
  167. data/test/ffi-gobject_introspection/i_function_info_test.rb +1 -1
  168. data/test/ffi-gobject_introspection/i_interface_info_test.rb +10 -10
  169. data/test/ffi-gobject_introspection/i_object_info_test.rb +23 -23
  170. data/test/ffi-gobject_introspection/i_property_info_test.rb +19 -19
  171. data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +10 -10
  172. data/test/ffi-gobject_introspection/i_repository_test.rb +34 -34
  173. data/test/ffi-gobject_introspection/i_struct_info_test.rb +10 -10
  174. data/test/ffi-gobject_introspection/i_type_info_test.rb +12 -15
  175. data/test/ffi-gobject_introspection/i_union_info_test.rb +7 -7
  176. data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +16 -16
  177. data/test/ffi-gobject_introspection/lib_test.rb +3 -3
  178. data/test/ffi-gobject_introspection/strv_test.rb +9 -9
  179. data/test/ffi-gobject_test.rb +47 -45
  180. data/test/gir_ffi/allocation_helper_test.rb +13 -13
  181. data/test/gir_ffi/arg_helper_test.rb +71 -65
  182. data/test/gir_ffi/boolean_test.rb +20 -20
  183. data/test/gir_ffi/boxed_base_test.rb +18 -18
  184. data/test/gir_ffi/builder_test.rb +81 -213
  185. data/test/gir_ffi/builders/argument_builder_test.rb +321 -287
  186. data/test/gir_ffi/builders/base_argument_builder_test.rb +1 -1
  187. data/test/gir_ffi/builders/callback_argument_builder_test.rb +57 -56
  188. data/test/gir_ffi/builders/callback_builder_test.rb +71 -72
  189. data/test/gir_ffi/builders/callback_return_value_builder_test.rb +40 -41
  190. data/test/gir_ffi/builders/constant_builder_test.rb +1 -1
  191. data/test/gir_ffi/builders/constructor_builder_test.rb +12 -10
  192. data/test/gir_ffi/builders/enum_builder_test.rb +12 -11
  193. data/test/gir_ffi/builders/field_builder_test.rb +48 -42
  194. data/test/gir_ffi/builders/function_builder_test.rb +256 -224
  195. data/test/gir_ffi/builders/initializer_builder_test.rb +16 -14
  196. data/test/gir_ffi/builders/interface_builder_test.rb +9 -9
  197. data/test/gir_ffi/builders/module_builder_test.rb +18 -18
  198. data/test/gir_ffi/builders/object_builder_test.rb +41 -41
  199. data/test/gir_ffi/builders/property_builder_test.rb +94 -94
  200. data/test/gir_ffi/builders/registered_type_builder_test.rb +35 -11
  201. data/test/gir_ffi/builders/return_value_builder_test.rb +227 -223
  202. data/test/gir_ffi/builders/signal_closure_builder_test.rb +124 -113
  203. data/test/gir_ffi/builders/struct_builder_test.rb +38 -35
  204. data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +8 -14
  205. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +34 -23
  206. data/test/gir_ffi/builders/union_builder_test.rb +12 -15
  207. data/test/gir_ffi/builders/user_defined_builder_test.rb +152 -148
  208. data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +46 -40
  209. data/test/gir_ffi/builders/vfunc_builder_test.rb +149 -157
  210. data/test/gir_ffi/callback_base_test.rb +9 -9
  211. data/test/gir_ffi/class_base_test.rb +56 -53
  212. data/test/gir_ffi/core_test.rb +36 -35
  213. data/test/gir_ffi/enum_base_test.rb +19 -19
  214. data/test/gir_ffi/error_type_info_test.rb +23 -23
  215. data/test/gir_ffi/ffi_ext/pointer_test.rb +9 -7
  216. data/test/gir_ffi/g_type_test.rb +11 -11
  217. data/test/gir_ffi/in_pointer_test.rb +70 -50
  218. data/test/gir_ffi/info_ext/i_callable_info_test.rb +5 -5
  219. data/test/gir_ffi/info_ext/i_callback_info_test.rb +6 -5
  220. data/test/gir_ffi/info_ext/i_field_info_test.rb +6 -6
  221. data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -17
  222. data/test/gir_ffi/info_ext/i_signal_info_test.rb +8 -8
  223. data/test/gir_ffi/info_ext/i_type_info_test.rb +231 -216
  224. data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +4 -4
  225. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +8 -8
  226. data/test/gir_ffi/info_ext/safe_function_name_test.rb +8 -8
  227. data/test/gir_ffi/interface_base_test.rb +8 -8
  228. data/test/gir_ffi/method_stubber_test.rb +21 -19
  229. data/test/gir_ffi/object_base_test.rb +23 -23
  230. data/test/gir_ffi/object_store_test.rb +13 -13
  231. data/test/gir_ffi/receiver_argument_info_test.rb +15 -15
  232. data/test/gir_ffi/sized_array_test.rb +68 -68
  233. data/test/gir_ffi/struct_base_test.rb +8 -8
  234. data/test/gir_ffi/struct_like_base_test.rb +64 -64
  235. data/test/gir_ffi/type_map_test.rb +8 -8
  236. data/test/gir_ffi/unintrospectable_type_info_test.rb +33 -33
  237. data/test/gir_ffi/union_base_test.rb +8 -8
  238. data/test/gir_ffi/user_defined_object_info_test.rb +34 -34
  239. data/test/gir_ffi/user_defined_property_info_test.rb +16 -16
  240. data/test/gir_ffi/variable_name_generator_test.rb +8 -8
  241. data/test/gir_ffi/version_test.rb +4 -4
  242. data/test/gir_ffi/zero_terminated_test.rb +34 -34
  243. data/test/gir_ffi_test_helper.rb +3 -3
  244. data/test/integration/callback_exceptions_test.rb +17 -21
  245. data/test/integration/derived_classes_test.rb +14 -13
  246. data/test/integration/generated_everything_test.rb +225 -224
  247. data/test/integration/generated_gimarshallingtests_test.rb +1174 -1060
  248. data/test/integration/generated_gio_test.rb +36 -36
  249. data/test/integration/generated_glib_test.rb +4 -6
  250. data/test/integration/generated_gobject_test.rb +43 -35
  251. data/test/integration/generated_gst_test.rb +20 -16
  252. data/test/integration/generated_gtk_source_test.rb +9 -15
  253. data/test/integration/generated_gtop_test.rb +8 -15
  254. data/test/integration/generated_pango_ft2_test.rb +2 -2
  255. data/test/integration/generated_pango_test.rb +4 -4
  256. data/test/integration/generated_regress_test.rb +1858 -1632
  257. data/test/integration/generated_secret_test.rb +8 -11
  258. data/test/integration/generated_utility_test.rb +81 -81
  259. data/test/integration/generated_warnlib_test.rb +17 -21
  260. data/test/integration/method_lookup_test.rb +6 -6
  261. data/test/introspection_test_helper.rb +49 -7
  262. data/test/minitest/stats_plugin.rb +1 -1
  263. metadata +21 -23
  264. data/lib/ffi-glib/array_methods.rb +0 -16
  265. 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,12 @@ 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) do
25
+ get_method_introspection_data "Regress", "TestObj", "new_from_file"
26
+ end
27
+ it "builds a custom constructor" do
28
+ _(code).must_equal <<~CODE
27
29
  def self.new_from_file(*args, &block)
28
30
  raise NoMethodError unless self == Regress::TestObj
29
31
  obj = allocate
@@ -1,22 +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 'creating Regress::TestEnum' do
7
- before do
8
- save_module :Regress
9
- end
6
+ describe "#build_class" do
7
+ let(:info) { get_introspection_data "Regress", "TestEnum" }
8
+ let(:builder) { GirFFI::Builders::EnumBuilder.new info }
10
9
 
11
- it 'makes the created type know its proper name' do
12
- info = get_introspection_data 'Regress', 'TestEnum'
13
- builder = GirFFI::Builders::EnumBuilder.new info
10
+ it "makes the created type know its proper name" do
14
11
  enum = builder.build_class
15
- enum.inspect.must_equal 'Regress::TestEnum'
12
+ _(enum.inspect).must_equal "Regress::TestEnum"
16
13
  end
17
14
 
18
- after do
19
- restore_module :Regress
15
+ it "adds constants for the values" do
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]
20
21
  end
21
22
  end
22
23
  end
@@ -1,40 +1,42 @@
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) do
11
+ get_field_introspection_data "Regress", "TestSimpleBoxedA", "some_int8"
12
+ end
13
+ it "creates the right getter method" do
14
+ expected = <<~CODE
13
15
  def some_int8
14
16
  _v1 = @struct.to_ptr
15
17
  _v2 = _v1.get_int8(#{field_info.offset})
16
18
  _v2
17
19
  end
18
20
  CODE
19
- instance.getter_def.must_equal expected
21
+ _(instance.getter_def).must_equal expected
20
22
  end
21
23
 
22
- it 'creates the right setter method' do
23
- expected = <<-CODE.reset_indentation
24
+ it "creates the right setter method" do
25
+ expected = <<~CODE
24
26
  def some_int8= value
25
27
  _v1 = @struct.to_ptr
26
28
  _v2 = value
27
29
  _v1.put_int8 #{field_info.offset}, _v2
28
30
  end
29
31
  CODE
30
- instance.setter_def.must_equal expected
32
+ _(instance.setter_def).must_equal expected
31
33
  end
32
34
  end
33
35
 
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
36
+ describe "for a field of type :struct" do
37
+ let(:field_info) { get_field_introspection_data "Regress", "TestBoxed", "nested_a" }
38
+ it "creates the right getter method" do
39
+ expected = <<~CODE
38
40
  def nested_a
39
41
  _v1 = @struct.to_ptr
40
42
  _v2 = Regress::TestSimpleBoxedA.get_value_from_pointer(_v1, #{field_info.offset})
@@ -42,39 +44,39 @@ describe GirFFI::Builders::FieldBuilder do
42
44
  _v3
43
45
  end
44
46
  CODE
45
- instance.getter_def.must_equal expected
47
+ _(instance.getter_def).must_equal expected
46
48
  end
47
49
 
48
- it 'creates the right setter method' do
49
- expected = <<-CODE.reset_indentation
50
+ it "creates the right setter method" do
51
+ expected = <<~CODE
50
52
  def nested_a= value
51
53
  _v1 = @struct.to_ptr
52
54
  _v2 = Regress::TestSimpleBoxedA.copy_from(value)
53
55
  Regress::TestSimpleBoxedA.copy_value_to_pointer(_v2, _v1, #{field_info.offset})
54
56
  end
55
57
  CODE
56
- instance.setter_def.must_equal expected
58
+ _(instance.setter_def).must_equal expected
57
59
  end
58
60
  end
59
61
 
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
62
+ describe "for a field of type :enum" do
63
+ let(:field_info) { get_field_introspection_data "Regress", "TestStructA", "some_enum" }
64
+ it "creates the right getter method" do
65
+ expected = <<~CODE
64
66
  def some_enum
65
67
  _v1 = @struct.to_ptr
66
68
  _v2 = Regress::TestEnum.get_value_from_pointer(_v1, #{field_info.offset})
67
69
  _v2
68
70
  end
69
71
  CODE
70
- instance.getter_def.must_equal expected
72
+ _(instance.getter_def).must_equal expected
71
73
  end
72
74
  end
73
75
 
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
76
+ describe "for an inline fixed-size array field" do
77
+ let(:field_info) { get_field_introspection_data "Regress", "TestStructE", "some_union" }
78
+ it "creates the right getter method" do
79
+ expected = <<~CODE
78
80
  def some_union
79
81
  _v1 = @struct.to_ptr
80
82
  _v2 = GirFFI::SizedArray.get_value_from_pointer(_v1, #{field_info.offset})
@@ -82,11 +84,11 @@ describe GirFFI::Builders::FieldBuilder do
82
84
  _v3
83
85
  end
84
86
  CODE
85
- instance.getter_def.must_equal expected
87
+ _(instance.getter_def).must_equal expected
86
88
  end
87
89
 
88
- it 'creates the right setter method' do
89
- expected = <<-CODE.reset_indentation
90
+ it "creates the right setter method" do
91
+ expected = <<~CODE
90
92
  def some_union= value
91
93
  _v1 = @struct.to_ptr
92
94
  GirFFI::ArgHelper.check_fixed_array_size 2, value, \"value\"
@@ -94,31 +96,35 @@ describe GirFFI::Builders::FieldBuilder do
94
96
  GirFFI::SizedArray.copy_value_to_pointer(_v2, _v1, #{field_info.offset})
95
97
  end
96
98
  CODE
97
- instance.setter_def.must_equal expected
99
+ _(instance.setter_def).must_equal expected
98
100
  end
99
101
  end
100
102
 
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
103
+ describe "for a field of type :callback" do
104
+ let(:field_info) { get_field_introspection_data "GObject", "TypeInfo", "class_init" }
105
+ it "creates the right setter method" do
106
+ expected = <<~CODE
105
107
  def class_init= value
106
108
  _v1 = @struct.to_ptr
107
109
  _v2 = GObject::ClassInitFunc.from(value)
108
110
  GObject::ClassInitFunc.copy_value_to_pointer(_v2, _v1, #{field_info.offset})
109
111
  end
110
112
  CODE
111
- instance.setter_def.must_equal expected
113
+ _(instance.setter_def).must_equal expected
112
114
  end
113
115
  end
114
116
 
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' }
117
+ describe "for a field with a related array length field" do
118
+ let(:field_info) do
119
+ get_field_introspection_data "GObject", "SignalQuery", "param_types"
120
+ end
121
+ let(:n_params_field_info) do
122
+ get_field_introspection_data "GObject", "SignalQuery", "n_params"
123
+ end
118
124
 
119
- it 'creates the right getter method' do
125
+ it "creates the right getter method" do
120
126
  skip if field_info.field_type.array_length < 0
121
- expected = <<-CODE.reset_indentation
127
+ expected = <<~CODE
122
128
  def param_types
123
129
  _v1 = @struct.to_ptr
124
130
  _v2 = _v1.get_uint32(#{n_params_field_info.offset})
@@ -128,7 +134,7 @@ describe GirFFI::Builders::FieldBuilder do
128
134
  _v5
129
135
  end
130
136
  CODE
131
- instance.getter_def.must_equal expected
137
+ _(instance.getter_def).must_equal expected
132
138
  end
133
139
  end
134
140
  end
@@ -1,27 +1,30 @@
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) do
12
+ get_method_introspection_data "GObject", "Object", "get_property"
13
+ end
12
14
 
13
- it 'returns the same result when called twice' do
15
+ it "returns the same result when called twice" do
14
16
  original = builder.method_definition
15
17
  copy = builder.method_definition
16
- copy.must_equal original
18
+ _(copy).must_equal original
17
19
  end
18
20
  end
19
21
 
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
22
+ describe "for Regress:test_array_fixed_out_objects" do
23
+ let(:function_info) do
24
+ get_introspection_data "Regress", "test_array_fixed_out_objects"
25
+ end
26
+ it "builds a correct definition" do
27
+ _(code).must_equal <<~CODE
25
28
  def self.test_array_fixed_out_objects
26
29
  _v1 = FFI::MemoryPointer.new :pointer
27
30
  Regress::Lib.regress_test_array_fixed_out_objects _v1
@@ -32,10 +35,10 @@ describe GirFFI::Builders::FunctionBuilder do
32
35
  end
33
36
  end
34
37
 
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
38
+ describe "for functions having a linked length argument" do
39
+ let(:function_info) { get_introspection_data "Regress", "test_array_gint16_in" }
40
+ it "builds a correct definition" do
41
+ _(code).must_equal <<~CODE
39
42
  def self.test_array_gint16_in(ints)
40
43
  n_ints = ints.nil? ? 0 : ints.length
41
44
  _v1 = n_ints
@@ -47,11 +50,12 @@ describe GirFFI::Builders::FunctionBuilder do
47
50
  end
48
51
  end
49
52
 
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
53
+ describe "for methods taking a zero-terminated array with length argument" do
54
+ let(:function_info) do
55
+ get_method_introspection_data "Regress", "AnnotationObject", "parse_args"
56
+ end
57
+ it "builds a correct definition" do
58
+ _(code).must_equal <<~CODE
55
59
  def parse_args(argv)
56
60
  argc = argv.nil? ? 0 : argv.length
57
61
  _v1 = FFI::MemoryPointer.new :int32
@@ -66,10 +70,12 @@ describe GirFFI::Builders::FunctionBuilder do
66
70
  end
67
71
  end
68
72
 
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
73
+ describe "for functions with callbacks" do
74
+ let(:function_info) do
75
+ get_introspection_data "Regress", "test_callback_destroy_notify"
76
+ end
77
+ it "builds a correct definition" do
78
+ _(code).must_equal <<~CODE
73
79
  def self.test_callback_destroy_notify(&callback)
74
80
  _v1 = Regress::TestCallbackUserData.from(callback)
75
81
  _v2 = GirFFI::ArgHelper.store(_v1)
@@ -81,10 +87,10 @@ describe GirFFI::Builders::FunctionBuilder do
81
87
  end
82
88
  end
83
89
 
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
90
+ describe "for functions that take a GValue" do
91
+ let(:function_info) { get_introspection_data "GIMarshallingTests", "gvalue_in" }
92
+ it "creates a call to GObject::Value#from" do
93
+ _(code).must_equal <<~CODE
88
94
  def self.gvalue_in(value)
89
95
  _v1 = GObject::Value.from(value)
90
96
  GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_in _v1
@@ -93,10 +99,10 @@ describe GirFFI::Builders::FunctionBuilder do
93
99
  end
94
100
  end
95
101
 
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
102
+ describe "for functions that return a GValue" do
103
+ let(:function_info) { get_introspection_data "GIMarshallingTests", "gvalue_return" }
104
+ it "creates a call to #get_value" do
105
+ _(code).must_equal <<~CODE
100
106
  def self.gvalue_return
101
107
  _v1 = GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_return
102
108
  _v2 = GObject::Value.wrap(_v1).get_value
@@ -106,10 +112,10 @@ describe GirFFI::Builders::FunctionBuilder do
106
112
  end
107
113
  end
108
114
 
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
115
+ describe "for functions that have a GValue out argument" do
116
+ let(:function_info) { get_introspection_data "GIMarshallingTests", "gvalue_out" }
117
+ it "creates a call to #get_value" do
118
+ _(code).must_equal <<~CODE
113
119
  def self.gvalue_out
114
120
  _v1 = FFI::MemoryPointer.new :pointer
115
121
  GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_out _v1
@@ -120,12 +126,13 @@ describe GirFFI::Builders::FunctionBuilder do
120
126
  end
121
127
  end
122
128
 
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' }
129
+ describe "for functions that have a caller-allocated GValue out argument" do
130
+ let(:function_info) do
131
+ get_introspection_data "GIMarshallingTests", "gvalue_out_caller_allocates"
132
+ end
125
133
 
126
- it 'creates a call to #get_value' do
127
- skip unless function_info
128
- code.must_equal <<-CODE.reset_indentation
134
+ it "creates a call to #get_value" do
135
+ _(code).must_equal <<~CODE
129
136
  def self.gvalue_out_caller_allocates
130
137
  _v1 = GObject::Value.new
131
138
  GIMarshallingTests::Lib.gi_marshalling_tests_gvalue_out_caller_allocates _v1
@@ -136,10 +143,10 @@ describe GirFFI::Builders::FunctionBuilder do
136
143
  end
137
144
  end
138
145
 
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
146
+ describe "for functions with a nullable input array" do
147
+ let(:function_info) { get_introspection_data "Regress", "test_array_int_null_in" }
148
+ it "builds correct definition" do
149
+ _(code).must_equal <<~CODE
143
150
  def self.test_array_int_null_in(arr = nil)
144
151
  len = arr.nil? ? 0 : arr.length
145
152
  _v1 = len
@@ -150,10 +157,10 @@ describe GirFFI::Builders::FunctionBuilder do
150
157
  end
151
158
  end
152
159
 
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
160
+ describe "for functions with a nullable output array" do
161
+ let(:function_info) { get_introspection_data "Regress", "test_array_int_null_out" }
162
+ it "builds correct definition" do
163
+ _(code).must_equal <<~CODE
157
164
  def self.test_array_int_null_out
158
165
  _v1 = FFI::MemoryPointer.new :int32
159
166
  _v2 = FFI::MemoryPointer.new :pointer
@@ -166,10 +173,12 @@ describe GirFFI::Builders::FunctionBuilder do
166
173
  end
167
174
  end
168
175
 
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
176
+ describe "for a method with an inout array with size argument" do
177
+ let(:function_info) do
178
+ get_method_introspection_data "GIMarshallingTests", "Object", "method_array_inout"
179
+ end
180
+ it "builds the correct definition" do
181
+ _(code).must_equal <<~CODE
173
182
  def method_array_inout(ints)
174
183
  length = ints.nil? ? 0 : ints.length
175
184
  _v1 = FFI::MemoryPointer.new :int32
@@ -185,11 +194,13 @@ describe GirFFI::Builders::FunctionBuilder do
185
194
  end
186
195
  end
187
196
 
188
- describe 'for a simple method' do
189
- let(:function_info) { get_method_introspection_data 'Regress', 'TestObj', 'instance_method' }
197
+ describe "for a simple method" do
198
+ let(:function_info) do
199
+ get_method_introspection_data "Regress", "TestObj", "instance_method"
200
+ end
190
201
 
191
- it 'builds a correct definition' do
192
- code.must_equal <<-CODE.reset_indentation
202
+ it "builds a correct definition" do
203
+ _(code).must_equal <<~CODE
193
204
  def instance_method
194
205
  _v1 = Regress::Lib.regress_test_obj_instance_method self
195
206
  return _v1
@@ -198,11 +209,11 @@ describe GirFFI::Builders::FunctionBuilder do
198
209
  end
199
210
  end
200
211
 
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
212
+ describe "for GLib::Variant.get_strv" do
213
+ let(:function_info) { get_method_introspection_data "GLib", "Variant", "get_strv" }
214
+ it "builds a correct definition" do
204
215
  size_type = ":uint#{FFI.type_size(:size_t) * 8}"
205
- code.must_equal <<-CODE.reset_indentation
216
+ _(code).must_equal <<~CODE
206
217
  def get_strv
207
218
  _v1 = FFI::MemoryPointer.new #{size_type}
208
219
  _v2 = GLib::Lib.g_variant_get_strv self, _v1
@@ -213,12 +224,11 @@ describe GirFFI::Builders::FunctionBuilder do
213
224
  end
214
225
  end
215
226
 
216
- describe 'for Regress.has_parameter_named_attrs' do
217
- let(:function_info) { get_introspection_data 'Regress', 'has_parameter_named_attrs' }
227
+ describe "for Regress.has_parameter_named_attrs" do
228
+ let(:function_info) { get_introspection_data "Regress", "has_parameter_named_attrs" }
218
229
 
219
- it 'builds a correct definition' do
220
- skip unless function_info
221
- code.must_equal <<-CODE.reset_indentation
230
+ it "builds a correct definition" do
231
+ _(code).must_equal <<~CODE
222
232
  def self.has_parameter_named_attrs(foo, attributes)
223
233
  _v1 = foo
224
234
  GirFFI::ArgHelper.check_fixed_array_size 32, attributes, \"attributes\"
@@ -229,15 +239,14 @@ describe GirFFI::Builders::FunctionBuilder do
229
239
  end
230
240
  end
231
241
 
232
- describe 'for GIMarshallingTests::Object#method_int8_arg_and_out_callee' do
242
+ describe "for GIMarshallingTests::Object#method_int8_arg_and_out_callee" do
233
243
  let(:function_info) do
234
- get_method_introspection_data('GIMarshallingTests', 'Object',
235
- 'method_int8_arg_and_out_callee')
244
+ get_method_introspection_data("GIMarshallingTests", "Object",
245
+ "method_int8_arg_and_out_callee")
236
246
  end
237
247
 
238
- it 'builds a correct definition' do
239
- skip unless function_info
240
- code.must_equal <<-CODE.reset_indentation
248
+ it "builds a correct definition" do
249
+ _(code).must_equal <<~CODE
241
250
  def method_int8_arg_and_out_callee(arg)
242
251
  _v1 = arg
243
252
  _v2 = FFI::MemoryPointer.new :pointer
@@ -249,237 +258,254 @@ describe GirFFI::Builders::FunctionBuilder do
249
258
  end
250
259
  end
251
260
 
252
- describe 'object ownership transfer' do
253
- describe 'for GIMarshallingTests::Object#full_in' do
261
+ describe "object ownership transfer" do
262
+ describe "for GIMarshallingTests::Object#full_in" do
254
263
  let(:function_info) do
255
- get_method_introspection_data('GIMarshallingTests', 'Object',
256
- 'full_in')
264
+ get_method_introspection_data("GIMarshallingTests", "Object",
265
+ "full_in")
257
266
  end
258
267
 
259
268
  # 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
269
+ it "builds a correct definition" do
270
+ _(code).must_equal <<~CODE
271
+ def full_in
272
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_full_in self
273
+ end
265
274
  CODE
266
275
  end
267
276
  end
268
277
 
269
- describe 'for GIMarshallingTests::Object.full_inout' do
278
+ describe "for GIMarshallingTests::Object.full_inout" do
270
279
  let(:function_info) do
271
- get_method_introspection_data('GIMarshallingTests', 'Object',
272
- 'full_inout')
280
+ get_method_introspection_data("GIMarshallingTests", "Object",
281
+ "full_inout")
273
282
  end
274
283
 
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
284
+ it "builds a correct definition" do
285
+ _(code).must_equal <<~CODE
286
+ def self.full_inout(object)
287
+ _v1 = FFI::MemoryPointer.new :pointer
288
+ _v1.put_pointer 0, GIMarshallingTests::Object.from(object && object.ref)
289
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_full_inout _v1
290
+ _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0))
291
+ return _v2
292
+ end
284
293
  CODE
285
294
  end
286
295
  end
287
296
 
288
- describe 'for GIMarshallingTests::Object.full_out' do
297
+ describe "for GIMarshallingTests::Object.full_out" do
289
298
  let(:function_info) do
290
- get_method_introspection_data('GIMarshallingTests', 'Object',
291
- 'full_out')
299
+ get_method_introspection_data("GIMarshallingTests", "Object",
300
+ "full_out")
292
301
  end
293
302
 
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
303
+ it "builds a correct definition" do
304
+ _(code).must_equal <<~CODE
305
+ def self.full_out
306
+ _v1 = FFI::MemoryPointer.new :pointer
307
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_full_out _v1
308
+ _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0))
309
+ return _v2
310
+ end
302
311
  CODE
303
312
  end
304
313
  end
305
314
 
306
- describe 'for GIMarshallingTests::Object.full_return' do
315
+ describe "for GIMarshallingTests::Object.full_return" do
307
316
  let(:function_info) do
308
- get_method_introspection_data('GIMarshallingTests', 'Object',
309
- 'full_return')
317
+ get_method_introspection_data("GIMarshallingTests", "Object",
318
+ "full_return")
310
319
  end
311
320
 
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
321
+ it "builds a correct definition" do
322
+ _(code).must_equal <<~CODE
323
+ def self.full_return
324
+ _v1 = GIMarshallingTests::Lib.gi_marshalling_tests_object_full_return
325
+ _v2 = GIMarshallingTests::Object.wrap(_v1)
326
+ return _v2
327
+ end
319
328
  CODE
320
329
  end
321
330
  end
322
331
 
323
- describe 'for GIMarshallingTests::Object#none_in' do
332
+ describe "for GIMarshallingTests::Object#none_in" do
324
333
  let(:function_info) do
325
- get_method_introspection_data('GIMarshallingTests', 'Object',
326
- 'none_in')
334
+ get_method_introspection_data("GIMarshallingTests", "Object",
335
+ "none_in")
327
336
  end
328
337
 
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
338
+ it "builds a correct definition" do
339
+ _(code).must_equal <<~CODE
340
+ def none_in
341
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_none_in self
342
+ end
334
343
  CODE
335
344
  end
336
345
  end
337
346
 
338
- describe 'for GIMarshallingTests::Object.none_inout' do
347
+ describe "for GIMarshallingTests::Object.none_inout" do
339
348
  let(:function_info) do
340
- get_method_introspection_data('GIMarshallingTests', 'Object',
341
- 'none_inout')
349
+ get_method_introspection_data("GIMarshallingTests", "Object",
350
+ "none_inout")
342
351
  end
343
352
 
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
353
+ it "builds a correct definition" do
354
+ _(code).must_equal <<~CODE
355
+ def self.none_inout(object)
356
+ _v1 = FFI::MemoryPointer.new :pointer
357
+ _v1.put_pointer 0, GIMarshallingTests::Object.from(object)
358
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_none_inout _v1
359
+ _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0)).tap { |it| it && it.ref }
360
+ return _v2
361
+ end
353
362
  CODE
354
363
  end
355
364
  end
356
365
 
357
- describe 'for GIMarshallingTests::Object.none_out' do
366
+ describe "for GIMarshallingTests::Object.none_out" do
358
367
  let(:function_info) do
359
- get_method_introspection_data('GIMarshallingTests', 'Object',
360
- 'none_out')
368
+ get_method_introspection_data("GIMarshallingTests", "Object",
369
+ "none_out")
361
370
  end
362
371
 
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
372
+ it "builds a correct definition" do
373
+ _(code).must_equal <<~CODE
374
+ def self.none_out
375
+ _v1 = FFI::MemoryPointer.new :pointer
376
+ GIMarshallingTests::Lib.gi_marshalling_tests_object_none_out _v1
377
+ _v2 = GIMarshallingTests::Object.wrap(_v1.get_pointer(0)).tap { |it| it && it.ref }
378
+ return _v2
379
+ end
371
380
  CODE
372
381
  end
373
382
  end
374
383
 
375
- describe 'for GIMarshallingTests::Object.none_return' do
384
+ describe "for GIMarshallingTests::Object.none_return" do
376
385
  let(:function_info) do
377
- get_method_introspection_data('GIMarshallingTests', 'Object',
378
- 'none_return')
386
+ get_method_introspection_data("GIMarshallingTests", "Object",
387
+ "none_return")
379
388
  end
380
389
 
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
390
+ it "builds a correct definition" do
391
+ _(code).must_equal <<~CODE
392
+ def self.none_return
393
+ _v1 = GIMarshallingTests::Lib.gi_marshalling_tests_object_none_return
394
+ _v2 = GIMarshallingTests::Object.wrap(_v1).tap { |it| it && it.ref }
395
+ return _v2
396
+ end
388
397
  CODE
389
398
  end
390
399
  end
391
400
 
392
- describe 'for Regress::TestObj#instance_method_full' do
401
+ describe "for Regress::TestObj#instance_method_full" do
393
402
  let(:function_info) do
394
- get_method_introspection_data('Regress', 'TestObj',
395
- 'instance_method_full')
403
+ get_method_introspection_data("Regress", "TestObj",
404
+ "instance_method_full")
396
405
  end
397
406
 
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
407
+ it "builds a correct definition including self.ref" do
408
+ _(code).must_equal <<~CODE
409
+ def instance_method_full
410
+ Regress::Lib.regress_test_obj_instance_method_full self.ref
411
+ end
404
412
  CODE
405
413
  end
406
414
  end
407
415
  end
408
416
 
409
- describe 'struct ownership transfer' do
410
- describe 'for GIMarshallingTests::BoxedStruct.inout' do
417
+ describe "struct ownership transfer" do
418
+ describe "for Regress::FooRectangle#add" do
411
419
  let(:function_info) do
412
- get_method_introspection_data('GIMarshallingTests', 'BoxedStruct', 'inout')
420
+ get_method_introspection_data("Regress", "FooRectangle",
421
+ "add")
413
422
  end
414
423
 
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
424
+ it "builds a correct definition without #ref" do
425
+ _(code).must_equal <<~CODE
426
+ def add(r2)
427
+ _v1 = Regress::FooRectangle.from(r2)
428
+ Regress::Lib.regress_foo_rectangle_add self, _v1
429
+ end
424
430
  CODE
425
431
  end
426
432
  end
433
+ end
427
434
 
428
- describe 'for GIMarshallingTests::BoxedStruct.out' do
435
+ describe "boxed struct ownership transfer" do
436
+ describe "for GIMarshallingTests::BoxedStruct.inout" do
429
437
  let(:function_info) do
430
- get_method_introspection_data('GIMarshallingTests', 'BoxedStruct', 'out')
438
+ get_method_introspection_data("GIMarshallingTests", "BoxedStruct", "inout")
431
439
  end
432
440
 
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
441
+ it "builds a correct definition" do
442
+ _(code).must_equal <<~CODE
443
+ def self.inout(struct_)
444
+ _v1 = FFI::MemoryPointer.new :pointer
445
+ _v1.put_pointer 0, GIMarshallingTests::BoxedStruct.copy_from(struct_)
446
+ GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_inout _v1
447
+ _v2 = GIMarshallingTests::BoxedStruct.wrap_own(_v1.get_pointer(0))
448
+ return _v2
449
+ end
441
450
  CODE
442
451
  end
443
452
  end
444
453
 
445
- describe 'for GIMarshallingTests::BoxedStruct.returnv' do
454
+ describe "for GIMarshallingTests::BoxedStruct.out" do
446
455
  let(:function_info) do
447
- get_method_introspection_data('GIMarshallingTests', 'BoxedStruct', 'returnv')
456
+ get_method_introspection_data("GIMarshallingTests", "BoxedStruct", "out")
448
457
  end
449
458
 
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
459
+ it "builds a correct definition" do
460
+ _(code).must_equal <<~CODE
461
+ def self.out
462
+ _v1 = FFI::MemoryPointer.new :pointer
463
+ GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_out _v1
464
+ _v2 = GIMarshallingTests::BoxedStruct.wrap_copy(_v1.get_pointer(0))
465
+ return _v2
466
+ end
457
467
  CODE
458
468
  end
459
469
  end
460
- end
461
470
 
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' }
471
+ describe "for GIMarshallingTests::BoxedStruct.returnv" do
472
+ let(:function_info) do
473
+ get_method_introspection_data("GIMarshallingTests", "BoxedStruct", "returnv")
474
+ end
465
475
 
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
476
+ it "builds a correct definition" do
477
+ _(code).must_equal <<~CODE
478
+ def self.returnv
479
+ _v1 = GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_returnv
480
+ _v2 = GIMarshallingTests::BoxedStruct.wrap_copy(_v1)
481
+ return _v2
482
+ end
483
+ CODE
484
+ end
485
+ end
486
+ end
487
+
488
+ describe "string ownership transfer" do
489
+ describe "for Regress.test_utf8_out" do
490
+ let(:function_info) { get_introspection_data "Regress", "test_utf8_out" }
491
+
492
+ it "builds a correct definition" do
493
+ _(code).must_equal <<~CODE
494
+ def self.test_utf8_out
495
+ _v1 = FFI::MemoryPointer.new :pointer
496
+ Regress::Lib.regress_test_utf8_out _v1
497
+ _v2 = GirFFI::AllocationHelper.free_after _v1.get_pointer(0), &:to_utf8
498
+ return _v2
499
+ end
474
500
  CODE
475
501
  end
476
502
  end
477
503
  end
478
504
 
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
505
+ describe "for functions with an allow-none ingoing parameter" do
506
+ let(:function_info) { get_introspection_data "Regress", "test_utf8_null_in" }
507
+ it "builds correct definition with default parameter value" do
508
+ _(code).must_equal <<~CODE
483
509
  def self.test_utf8_null_in(in_ = nil)
484
510
  _v1 = GirFFI::InPointer.from_utf8(in_)
485
511
  Regress::Lib.regress_test_utf8_null_in _v1
@@ -488,10 +514,12 @@ describe GirFFI::Builders::FunctionBuilder do
488
514
  end
489
515
  end
490
516
 
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
517
+ describe "for functions where some allow-none cannot be honored" do
518
+ let(:function_info) do
519
+ get_introspection_data "GIMarshallingTests", "array_in_utf8_two_in_out_of_order"
520
+ end
521
+ it "builds correct definition with default parameter value on the later arguments" do
522
+ _(code).must_equal <<~CODE
495
523
  def self.array_in_utf8_two_in_out_of_order(a, ints, b = nil)
496
524
  length = ints.nil? ? 0 : ints.length
497
525
  _v1 = length
@@ -504,12 +532,14 @@ describe GirFFI::Builders::FunctionBuilder do
504
532
  end
505
533
  end
506
534
 
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' }
535
+ describe "ownership transfer for an ingoing array of structs" do
536
+ describe "with no ownership transfer of the elements" do
537
+ let(:function_info) do
538
+ get_introspection_data "GIMarshallingTests", "array_struct_in"
539
+ end
510
540
 
511
- it 'builds a correct definition' do
512
- code.must_equal <<-CODE.reset_indentation
541
+ it "builds a correct definition" do
542
+ _(code).must_equal <<~CODE
513
543
  def self.array_struct_in(structs)
514
544
  length = structs.nil? ? 0 : structs.length
515
545
  _v1 = length
@@ -519,11 +549,13 @@ describe GirFFI::Builders::FunctionBuilder do
519
549
  CODE
520
550
  end
521
551
  end
522
- describe 'with ownership transfer of the elements' do
523
- let(:function_info) { get_introspection_data 'GIMarshallingTests', 'array_struct_take_in' }
552
+ describe "with ownership transfer of the elements" do
553
+ let(:function_info) do
554
+ get_introspection_data "GIMarshallingTests", "array_struct_take_in"
555
+ end
524
556
 
525
- it 'builds a correct definition' do
526
- code.must_equal <<-CODE.reset_indentation
557
+ it "builds a correct definition" do
558
+ _(code).must_equal <<~CODE
527
559
  def self.array_struct_take_in(structs)
528
560
  length = structs.nil? ? 0 : structs.length
529
561
  _v1 = length