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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c32084045b640a22901bdd0d256ce8b8df1ace345930d3e4fccfd0e598b82b19
4
- data.tar.gz: 5ac1e06a4dd28b4589ca93e30c48218a4cffb40f18d9f8c87859fdd76460fc8c
3
+ metadata.gz: 99e99f94ba677daacfe98552b91f5221dea70d33dd992ac53e223e4ff05df898
4
+ data.tar.gz: d83b543e6408259e2fa9067faa74c393e117e94148a7d37b7825cfe840537d8e
5
5
  SHA512:
6
- metadata.gz: f70592c52c01f747ca9370007783231007ef535a0039337aaf42e46a17acbf2a54178b33c591ca8658e040496bb66a34ffd1f8126b2b323470783b97418418ae
7
- data.tar.gz: fd92518d3541a1c46ebfe4758af76e8f746cf7ae355797a7f5736cdb4bc4b8444f6e9b4be7bf08712155759b11e5d697c2bdb522f3a4241337446204e5fb13c3
6
+ metadata.gz: '02840b2cb293bd64f478f023d7267d20f37f35c24a3a15c9569a04e8f4095cb297d5e9319bd55f1105d8d4cd961c9cab7cc2b01092b1c822f04dab7dc70e9023'
7
+ data.tar.gz: 331e901b2c3c94800ad52576dd9127563ae9d41657f947be0543f7ad765e55d0bd64b2ad7642c58b6e36f243d4f5d719047de6d10d15c369cbc49e724b378bd4
data/Changelog.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.15.0 / 2019-10-19
4
+
5
+ * Drop support for gobject-introspection below 1.46, the version available in
6
+ Ubuntu Xenial.
7
+ * Merge extended property getter and setter into regular ones. This means you
8
+ can always just use `#get_property` and `#set_property`. The methods
9
+ `#get_property_extended` and `#set_property_extended` are deprecated and will
10
+ be removed in GirFFI version 0.16 or later.
11
+ * Support setting ByteArray properties directly with string values.
12
+ * Target Ruby 2.4+
13
+ * Implement getting and setting of flag properties and GValues.
14
+ * Add support for basic hashtable values larger than pointer.
15
+ * Support unintrospectable classes not derived from GObject but from some other
16
+ fundamental object type.
17
+ * Make GPtrArray work with boxed types.
18
+ * Do not try to ref method reciever for struct instance methods marking the
19
+ instance receiver as transfer `:everything`.
20
+ * Support signals with GError arguments.
21
+ * Cache various methods on IBaseInfo and its subclasses.
22
+ * Generate aliases for accessor methods instead of relying on `method_missing`.
23
+
3
24
  ## 0.14.1 / 2018-09-27
4
25
 
5
26
  * Add enum values as constants in the generated module.
data/Gemfile CHANGED
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  # The gem's dependencies are specified in gir_ffi.gemspec
6
6
  gemspec
7
7
 
8
- gem 'pry', '~> 0.11.0'
8
+ gem "pry", "~> 0.12.0"
9
+ gem "ruby-prof", platform: :mri
10
+ gem "test-prof", platform: :mri
9
11
 
10
- if ENV['CI']
11
- gem 'coveralls', group: :development if ENV['TRAVIS_RUBY_VERSION'] == '2.4'
12
+ if ENV["CI"]
13
+ gem "coveralls", group: :development if ENV["TRAVIS_RUBY_VERSION"] == "2.4"
12
14
  end
data/README.md CHANGED
@@ -53,7 +53,7 @@ examples can be found in `gir_ffi-gtk` and `gir_ffi-gst`.
53
53
 
54
54
  ## Requirements
55
55
 
56
- GirFFI is supported on CRuby 2.2, 2.3, 2.4 and 2.5, and JRuby 9.1 and 9.2
56
+ GirFFI is supported on CRuby 2.4, 2.5 and 2.6, and JRuby 9.2.
57
57
 
58
58
  You will also need gobject-introspection installed with some
59
59
  introspection data.
@@ -63,15 +63,15 @@ available under the name ending in plain `.so`. If GirFFI complains that it
63
63
  cannot find the library, try installing development packages for those
64
64
  libraries.
65
65
 
66
- GirFFI should work with gobject-introspection 1.32.0 and up.
66
+ GirFFI should work with gobject-introspection 1.46.0 and up.
67
67
 
68
68
  On Debian and Ubuntu, installing `libgirepository1.0-1` and `gir1.2-glib-2.0`
69
69
  should be enough to use GirFFI in your application.
70
70
 
71
71
  To run the tests, you should additionally install `libgirepository1.0-dev`,
72
72
  `libcairo2-dev`, `gobject-introspection`, `gir1.2-gtop-2.0`, `gir1.2-gtk-3.0`,
73
- `gir1.2-pango-1.0`, `gir1.2-secret-1` and `gir1.2-gstreamer-1.0`. This should
74
- be enough to get `rake test` working.
73
+ `gir1.2-gtksource-3.0`, `gir1.2-pango-1.0`, `gir1.2-secret-1` and
74
+ `gir1.2-gstreamer-1.0`. This should be enough to get `rake test` working.
75
75
 
76
76
  GirFFI has not been tested on Mac OS X or Microsoft Windows. YMMV.
77
77
 
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rake/clean'
4
- require 'bundler/gem_tasks'
3
+ require "rake/clean"
4
+ require "bundler/gem_tasks"
5
5
 
6
- load 'tasks/test.rake'
6
+ load "tasks/test.rake"
7
7
 
8
- task default: 'test:all'
9
- task default: 'test:features'
8
+ task default: "test:all"
9
+ task default: "test:features"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ffi-glib/container_class_methods'
4
- require 'ffi-glib/array_methods'
3
+ require "ffi-glib/container_class_methods"
4
+ require "gir_ffi/array_element_convertor"
5
5
 
6
6
  GLib.load_class :Array
7
7
 
@@ -10,7 +10,6 @@ module GLib
10
10
  # be necessary to create objects of this class from Ruby directly.
11
11
  class Array
12
12
  include Enumerable
13
- include ArrayMethods
14
13
  extend ContainerClassMethods
15
14
 
16
15
  attr_reader :element_type
@@ -70,6 +69,17 @@ module GLib
70
69
  self
71
70
  end
72
71
 
72
+ # Re-implementation of the g_array_index macro
73
+ def index(idx)
74
+ unless (0...length).cover? idx
75
+ raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
76
+ end
77
+
78
+ item_ptr = data_ptr + idx * element_size
79
+ convertor = GirFFI::ArrayElementConvertor.new element_type, item_ptr
80
+ convertor.to_ruby_value
81
+ end
82
+
73
83
  private
74
84
 
75
85
  def data_ptr
@@ -83,7 +93,7 @@ module GLib
83
93
  def check_element_size_match
84
94
  return if calculated_element_size == get_element_size
85
95
 
86
- warn 'WARNING: Element sizes do not match'
96
+ warn "WARNING: Element sizes do not match"
87
97
  end
88
98
 
89
99
  def guess_element_type
@@ -15,8 +15,13 @@ module GLib
15
15
  self.class.wrap Lib.g_byte_array_append(to_ptr, bytes, len)
16
16
  end
17
17
 
18
- def initialize
19
- store_pointer(Lib.g_byte_array_new)
18
+ def self.from(data)
19
+ case data
20
+ when self
21
+ data
22
+ else
23
+ new.append(data)
24
+ end
20
25
  end
21
26
  end
22
27
  end
@@ -18,7 +18,7 @@ module GLib
18
18
  end
19
19
 
20
20
  super(ptr).tap do |container|
21
- container.reset_typespec typespec if container
21
+ container&.reset_typespec typespec
22
22
  end
23
23
  end
24
24
 
@@ -5,7 +5,7 @@ GLib.load_class :Error
5
5
  module GLib
6
6
  # Overrides for GError, used by GLib for handling non-fatal errors.
7
7
  class Error
8
- GIR_FFI_DOMAIN = GLib.quark_from_string('gir_ffi')
8
+ GIR_FFI_DOMAIN = GLib.quark_from_string("gir_ffi")
9
9
 
10
10
  def self.from_exception(exception)
11
11
  new_literal GIR_FFI_DOMAIN, 0, exception.message
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ffi-glib/container_class_methods'
3
+ require "ffi-glib/container_class_methods"
4
4
 
5
5
  GLib.load_class :HashTable
6
6
 
@@ -63,7 +63,7 @@ module GLib
63
63
  when :utf8
64
64
  FFI::Function.new(:uint,
65
65
  [:pointer],
66
- find_support_function('g_str_hash'))
66
+ find_support_function("g_str_hash"))
67
67
  end
68
68
  end
69
69
 
@@ -72,7 +72,7 @@ module GLib
72
72
  when :utf8
73
73
  FFI::Function.new(:int,
74
74
  [:pointer, :pointer],
75
- find_support_function('g_str_equal'))
75
+ find_support_function("g_str_equal"))
76
76
  end
77
77
  end
78
78
 
data/lib/ffi-glib/list.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ffi-glib/list_methods'
3
+ require "ffi-glib/list_methods"
4
4
 
5
5
  GLib.load_class :List
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ffi-glib/container_class_methods'
3
+ require "ffi-glib/container_class_methods"
4
4
 
5
5
  module GLib
6
6
  # Common methods for List and SList.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'singleton'
3
+ require "singleton"
4
4
 
5
5
  GLib.load_class :MainLoop
6
6
 
@@ -40,7 +40,7 @@ module GLib
40
40
  setup_instance_method! :run
41
41
 
42
42
  def run_with_thread_enabler
43
- ThreadEnabler.instance.setup_idle_handler if RUBY_ENGINE == 'ruby'
43
+ ThreadEnabler.instance.setup_idle_handler if RUBY_ENGINE == "ruby"
44
44
  RUNNING_LOOPS << self
45
45
  result = run_without_thread_enabler
46
46
  exception = EXCEPTIONS.shift
@@ -63,6 +63,6 @@ module GLib
63
63
  end
64
64
  end
65
65
 
66
- Signal.trap 'INT' do
66
+ Signal.trap "INT" do
67
67
  GLib::MainLoop.handle_exception(Interrupt.new)
68
68
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ffi-glib/container_class_methods'
4
- require 'ffi-glib/array_methods'
3
+ require "ffi-glib/container_class_methods"
4
+ require "gir_ffi/array_element_convertor"
5
5
 
6
6
  GLib.load_class :PtrArray
7
7
 
@@ -10,7 +10,6 @@ module GLib
10
10
  # pointers.
11
11
  class PtrArray
12
12
  include Enumerable
13
- include ArrayMethods
14
13
  extend ContainerClassMethods
15
14
 
16
15
  attr_reader :element_type
@@ -49,12 +48,25 @@ module GLib
49
48
  ary.each { |item| add item }
50
49
  end
51
50
 
52
- def data_ptr
53
- struct[:pdata]
54
- end
51
+ # Re-implementation of the g_ptrarray_index macro
52
+ def index(idx)
53
+ unless (0...length).cover? idx
54
+ raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
55
+ end
55
56
 
56
- def element_size
57
- POINTER_SIZE
57
+ item_ptr = data_ptr + idx * element_size
58
+
59
+ convert_element_type = case element_type
60
+ when :utf8
61
+ :utf8
62
+ when GirFFI::ObjectBase
63
+ element_type
64
+ else
65
+ [:pointer, element_type]
66
+ end
67
+
68
+ convertor = GirFFI::ArrayElementConvertor.new convert_element_type, item_ptr
69
+ convertor.to_ruby_value
58
70
  end
59
71
 
60
72
  def each
@@ -70,5 +82,15 @@ module GLib
70
82
  def ==(other)
71
83
  to_a == other.to_a
72
84
  end
85
+
86
+ private
87
+
88
+ def element_size
89
+ POINTER_SIZE
90
+ end
91
+
92
+ def data_ptr
93
+ struct[:pdata]
94
+ end
73
95
  end
74
96
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ffi-glib/list_methods'
3
+ require "ffi-glib/list_methods"
4
4
 
5
5
  GLib.load_class :SList
6
6
 
@@ -5,7 +5,7 @@ GLib.load_class :Variant
5
5
  module GLib
6
6
  # Overrides for GVariant, GLib's variant data type.
7
7
  class Variant
8
- setup_instance_method! 'get_string'
8
+ setup_instance_method! "get_string"
9
9
 
10
10
  def get_string_with_override
11
11
  get_string_without_override.first
data/lib/ffi-glib.rb CHANGED
@@ -1,25 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Ensure GLib is defined by GirFFI itself
4
- raise 'The module GLib was already defined elsewhere' if Kernel.const_defined? :GLib
4
+ raise "The module GLib was already defined elsewhere" if Kernel.const_defined? :GLib
5
5
 
6
- require 'gir_ffi/core'
6
+ require "gir_ffi/core"
7
7
 
8
8
  # Bypass check for existing modules
9
- GirFFI::Builders::ModuleBuilder.new('GLib').generate
10
-
11
- require 'ffi-glib/array'
12
- require 'ffi-glib/byte_array'
13
- require 'ffi-glib/bytes'
14
- require 'ffi-glib/destroy_notify'
15
- require 'ffi-glib/error'
16
- require 'ffi-glib/hash_table'
17
- require 'ffi-glib/list'
18
- require 'ffi-glib/main_loop'
19
- require 'ffi-glib/ptr_array'
20
- require 'ffi-glib/s_list'
21
- require 'ffi-glib/strv'
22
- require 'ffi-glib/variant'
9
+ GirFFI::Builders::ModuleBuilder.new("GLib").generate
10
+
11
+ require "ffi-glib/array"
12
+ require "ffi-glib/byte_array"
13
+ require "ffi-glib/bytes"
14
+ require "ffi-glib/destroy_notify"
15
+ require "ffi-glib/error"
16
+ require "ffi-glib/hash_table"
17
+ require "ffi-glib/list"
18
+ require "ffi-glib/main_loop"
19
+ require "ffi-glib/ptr_array"
20
+ require "ffi-glib/s_list"
21
+ require "ffi-glib/strv"
22
+ require "ffi-glib/variant"
23
23
 
24
24
  # Module representing GLib's GLib namespace.
25
25
  module GLib
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gir_ffi/property_not_found_error'
3
+ require "gir_ffi/property_not_found_error"
4
4
 
5
5
  GObject.load_class :Object
6
6
 
@@ -44,7 +44,7 @@ module GObject
44
44
  obj
45
45
  end
46
46
  else
47
- setup_method! 'new'
47
+ setup_method! "new"
48
48
 
49
49
  # Before GLib 2.54.0, use g_object_newv, which takes an array of GParameter.
50
50
  def initialize_with_automatic_gtype(properties = {})
@@ -90,22 +90,6 @@ module GObject
90
90
  end
91
91
  end
92
92
 
93
- # TODO: Generate accessor methods from GIR at class definition time
94
- def method_missing(method, *args)
95
- getter_name = "get_#{method}"
96
- return send(getter_name, *args) if respond_to?(getter_name)
97
-
98
- if method.to_s =~ /(.*)=$/
99
- setter_name = "set_#{Regexp.last_match[1]}"
100
- return send(setter_name, *args) if respond_to?(setter_name)
101
- end
102
- super
103
- end
104
-
105
- def respond_to_missing?(*)
106
- false
107
- end
108
-
109
93
  def signal_connect(event, data = nil, &block)
110
94
  GObject.signal_connect(self, event, data, &block)
111
95
  end
@@ -114,30 +98,37 @@ module GObject
114
98
  GObject.signal_connect_after(self, event, data, &block)
115
99
  end
116
100
 
117
- setup_instance_method! 'get_property'
118
- setup_instance_method! 'set_property'
101
+ setup_instance_method! "get_property"
102
+ setup_instance_method! "set_property"
119
103
 
104
+ # @deprecated
120
105
  def get_property_extended(property_name)
121
- value = get_property(property_name)
122
- type_info = get_property_type property_name
123
- property_value_post_conversion value, type_info
106
+ get_property(property_name)
124
107
  end
125
108
 
126
109
  def get_property_with_override(property_name)
127
110
  gvalue = gvalue_for_property property_name
128
111
  get_property_without_override property_name, gvalue
129
- gvalue.get_value
112
+ value = gvalue.get_value
113
+
114
+ type_info = get_property_type property_name
115
+ value = property_value_post_conversion(value, type_info) if type_info
116
+
117
+ value
130
118
  end
131
119
 
120
+ # @deprecated
132
121
  def set_property_extended(property_name, value)
133
- type_info = get_property_type property_name
134
- adjusted_value = property_value_pre_conversion(value, type_info)
135
- set_property property_name, adjusted_value
122
+ set_property property_name, value
136
123
  end
137
124
 
138
125
  def set_property_with_override(property_name, value)
126
+ type_info = get_property_type property_name
127
+ value = property_value_pre_conversion(value, type_info) if type_info
128
+
139
129
  gvalue = gvalue_for_property(property_name)
140
130
  gvalue.set_value value
131
+
141
132
  set_property_without_override property_name, gvalue
142
133
  end
143
134
 
@@ -147,7 +138,7 @@ module GObject
147
138
  alias set_property_without_override set_property
148
139
  alias set_property set_property_with_override
149
140
 
150
- setup_instance_method! 'is_floating'
141
+ setup_instance_method! "is_floating"
151
142
  alias floating? is_floating
152
143
 
153
144
  private
@@ -165,8 +156,7 @@ module GObject
165
156
  end
166
157
 
167
158
  def get_property_type(property_name)
168
- prop = self.class.find_property(property_name)
169
- prop.property_type
159
+ self.class.find_property(property_name)&.property_type
170
160
  end
171
161
 
172
162
  def gvalue_for_property(property_name)
@@ -175,8 +165,7 @@ module GObject
175
165
  end
176
166
 
177
167
  def property_gtype(property_name)
178
- pspec = property_param_spec(property_name)
179
- pspec.value_type
168
+ property_param_spec(property_name).value_type
180
169
  end
181
170
 
182
171
  def property_param_spec(property_name)
@@ -207,6 +196,8 @@ module GObject
207
196
  GLib::List.from type_info.element_type, val
208
197
  when :strv
209
198
  GLib::Strv.from val
199
+ when :byte_array
200
+ GLib::ByteArray.from val
210
201
  when :callback
211
202
  GirFFI::Builder.build_class(type_info.interface).from val
212
203
  else