gir_ffi 0.15.9 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +31 -18
  3. data/README.md +1 -1
  4. data/lib/ffi-glib/bytes.rb +0 -12
  5. data/lib/ffi-glib/main_loop.rb +1 -1
  6. data/lib/ffi-glib/ptr_array.rb +24 -15
  7. data/lib/ffi-glib/variant.rb +4 -6
  8. data/lib/ffi-gobject/object.rb +1 -11
  9. data/lib/ffi-gobject/object_class.rb +2 -10
  10. data/lib/ffi-gobject/value.rb +26 -26
  11. data/lib/ffi-gobject.rb +3 -17
  12. data/lib/ffi-gobject_introspection/i_constant_info.rb +10 -10
  13. data/lib/ffi-gobject_introspection/lib.rb +11 -11
  14. data/lib/ffi-gobject_introspection.rb +19 -19
  15. data/lib/gir_ffi/builder.rb +1 -1
  16. data/lib/gir_ffi/builders/argument_builder_collection.rb +5 -5
  17. data/lib/gir_ffi/builders/base_argument_builder.rb +2 -2
  18. data/lib/gir_ffi/builders/base_method_builder.rb +23 -23
  19. data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
  20. data/lib/gir_ffi/builders/marshalling_method_builder.rb +2 -2
  21. data/lib/gir_ffi/builders/object_builder.rb +10 -12
  22. data/lib/gir_ffi/builders/type_builder.rb +9 -9
  23. data/lib/gir_ffi/builders/user_defined_builder.rb +24 -26
  24. data/lib/gir_ffi/class_base.rb +1 -3
  25. data/lib/gir_ffi/core.rb +0 -5
  26. data/lib/gir_ffi/in_pointer.rb +6 -6
  27. data/lib/gir_ffi/info_ext/i_signal_info.rb +8 -6
  28. data/lib/gir_ffi/info_ext/i_type_info.rb +18 -24
  29. data/lib/gir_ffi/instance_method_setup.rb +3 -1
  30. data/lib/gir_ffi/object_base.rb +5 -5
  31. data/lib/gir_ffi/struct_like_base.rb +0 -1
  32. data/lib/gir_ffi/type_map.rb +30 -30
  33. data/lib/gir_ffi/unintrospectable_type_info.rb +2 -2
  34. data/lib/gir_ffi/user_defined_object_info.rb +0 -3
  35. data/lib/gir_ffi/user_defined_property_info.rb +33 -33
  36. data/lib/gir_ffi/version.rb +1 -1
  37. data/lib/gir_ffi/zero_terminated.rb +1 -1
  38. data/lib/gir_ffi-base/gobject.rb +1 -1
  39. metadata +18 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 240502b5086fedd9c4f52a114faf67c5021f03c4fedc10dd6fbfabd064a64aca
4
- data.tar.gz: b89d501796ee980af6d731758f144a9eba21472353bae02029548f6541787db4
3
+ metadata.gz: bfd3130c297141938f61b59a4e4be4ec2e76832cf38341533f18a5598ac6cd30
4
+ data.tar.gz: 2e94de2c70d365baa1fc1fd506e5cadbaf5d3b9aaa36dbde69e7813f742ce357
5
5
  SHA512:
6
- metadata.gz: a6f7df11953d3b1a88c3fa515207d3f15883e79de7114fb6ad55bf1545e1e023a6b1b7b83199fd3ef0a45ab762d240a9b59eec8c4aac660b1d8d83363de51c0a
7
- data.tar.gz: 18ca30c7f7f54daeff80c3045d24e1231d0a927e68f0ae8877a548b95cdc8602298b602925e3ad20e6b26049b62a7541b85d7f2d56b328594d22ca39b960146c
6
+ metadata.gz: 94de6fa54920e6c878d271f57c9c737aa5b6ca6025fe5d1d395e26e146208e8dafb9c43dc679984dcaa4216d373f658f25e8cdd676f96724cd7d8cbf7aae6012
7
+ data.tar.gz: d4f06ba95a49d8ad6476cda459dc93d3630533b9dc48f1fc48917c86d7124965700771a71084925f5382836352fe9b203536c0df686fb2a554530fb27e203cbb
data/Changelog.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.16.0 / 2022-05-21
4
+
5
+ * Support Ruby 3.1
6
+ * Rename `#object_class` to `#class_struct`
7
+ * Remove `GObject.object_class_from_instance`
8
+ * Limit public interface of `BaseMethodBuilder`
9
+ * Remove deprecated methods from `GObject::Object`
10
+ * Stop accepting blocks when defining a type
11
+ * Check parameter direction in signal argument conversion
12
+ * Drop support for JRuby
13
+ * Drop support for Ruby 2.6
14
+
3
15
  ## 0.15.9 / 2021-12-05
4
16
 
5
17
  * Skip setting destroy notifier state if types don't make sense
@@ -144,8 +156,8 @@
144
156
  changed.
145
157
  * Make `Strv#each` thread-safe.
146
158
  * Drop support for CRuby 2.0.
147
- * Move `::type_init` and base `Strv` implementation into `GObjectIntrospection`, making
148
- it stand-alone.
159
+ * Move `::type_init` and base `Strv` implementation into `GObjectIntrospection`,
160
+ making it stand-alone.
149
161
  * Move `GLib::Boolean` to `GirFFI::Boolean`.
150
162
  * Guard against instantiating abstract classes using the default constructor.
151
163
  * Handle user-defined properties containing dashes
@@ -166,7 +178,7 @@
166
178
  actual effect even on CRuby.
167
179
  - Immediately free string pointers whose ownership is transfered. Again, the
168
180
  #autorelease technique doesn't work on JRuby.
169
- - Fix handling of callee-allocated out parameters in vfuncs. The put_pointer
181
+ - Fix handling of callee-allocated out parameters in vfuncs. The `put_pointer`
170
182
  method was wrongly called, and JRuby is more picky about what types that
171
183
  method expects, exposing the bug.
172
184
 
@@ -185,7 +197,8 @@
185
197
 
186
198
  ## 0.9.5 / 2016-03-05
187
199
 
188
- * Abort if modules were defined earlier, e.g., through the gems from the ruby-gnome family.
200
+ * Abort if modules were defined earlier, e.g., through the gems from the
201
+ ruby-gnome family.
189
202
  * Extend integration testing with GObjectIntrospection's test libraries.
190
203
  * Find signals on user-defined types.
191
204
  * Allow getting and setting of properties with a callback value.
@@ -500,7 +513,7 @@
500
513
  ## 0.4.2 / 2012-09-22
501
514
 
502
515
  * Make objects and interfaces wrap poiners in the class that matches
503
- their GType.
516
+ their GType.
504
517
 
505
518
  ## 0.4.1 / 2012-09-18
506
519
 
@@ -516,7 +529,7 @@ their GType.
516
529
  ## 0.3.2 / 2012-08-24
517
530
 
518
531
  * Correctly set FFI return type when callbacks that return GObjects have
519
- incomplete type specification.
532
+ incomplete type specification.
520
533
 
521
534
  ## 0.3.1 / 2012-05-13
522
535
 
@@ -544,15 +557,15 @@ incomplete type specification.
544
557
 
545
558
  ## 0.2.2 / 2011-12-07
546
559
 
547
- * Fix issue #19: Check if a GLib::PtrArray.add method was generated
548
- before attempting to remove it.
560
+ * Fix issue #19: Check if a GLib::PtrArray.add method was generated before
561
+ attempting to remove it.
549
562
  * Fix two issues with pretty printing that made output for GLib have syntax
550
- errors.
563
+ errors.
551
564
 
552
565
  ## 0.2.1 / 2011-11-20
553
566
 
554
- * Fix handling of output parameters that are arrays of pointers to
555
- structures (i.e., of type `Foo***`).
567
+ * Fix handling of output parameters that are arrays of pointers to structures
568
+ (i.e., of type `Foo***`).
556
569
 
557
570
  ## 0.2.0 / 2011-11-19
558
571
 
@@ -562,9 +575,9 @@ structures (i.e., of type `Foo***`).
562
575
  - Get rid of `#[]` and `#[]=`.
563
576
  * Explicitely load `libgirepository` with ABI version 1.
564
577
  * Improve implementation of GLib container classes (GList etc.):
565
- - Real constructors.
566
- - `#append` and friends are instance methods now.
567
- - Conversion methods to cast Ruby containers to GLib containers.
578
+ - Real constructors.
579
+ - `#append` and friends are instance methods now.
580
+ - Conversion methods to cast Ruby containers to GLib containers.
568
581
  * Start implementing pretty printing.
569
582
  * Various refactorings.
570
583
 
@@ -577,10 +590,10 @@ structures (i.e., of type `Foo***`).
577
590
  ## 0.0.14 / 2011-10-28
578
591
 
579
592
  * Support GObject Introspection version 1.30:
580
- - Add support for layouts with fixed-length arrays.
581
- - Handle type names starting with underscores.
582
- - Call `g_signal_emitv` directly to avoid conflict in introspection info
583
- with earlier versions of GObject Introspection.
593
+ - Add support for layouts with fixed-length arrays.
594
+ - Handle type names starting with underscores.
595
+ - Call `g_signal_emitv` directly to avoid conflict in introspection info
596
+ with earlier versions of GObject Introspection.
584
597
 
585
598
  ## 0.0.13 / 2011-09-09
586
599
 
data/README.md CHANGED
@@ -51,7 +51,7 @@ examples can be found in `gir_ffi-gtk` and `gir_ffi-gst`.
51
51
 
52
52
  ## Requirements
53
53
 
54
- GirFFI is supported on CRuby 2.6, 2.7 and 3.0, and JRuby 9.3.
54
+ GirFFI is supported on CRuby 2.6, 2.7, 3.0 and 3.1.
55
55
 
56
56
  You will also need gobject-introspection installed with some
57
57
  introspection data.
@@ -7,18 +7,6 @@ module GLib
7
7
  class Bytes
8
8
  include Enumerable
9
9
 
10
- remove_method :get_data if method_defined? :get_data
11
-
12
- # @override
13
- # NOTE: Needed due to mis-identification of the element-type of the
14
- # resulting sized array for the default binding.
15
- def get_data
16
- length_ptr = FFI::MemoryPointer.new :size_t
17
- data_ptr = Lib.g_bytes_get_data self, length_ptr
18
- length = length_ptr.get_size_t(0)
19
- GirFFI::SizedArray.wrap(:guint8, length, data_ptr)
20
- end
21
-
22
10
  def each(&block)
23
11
  data.each(&block)
24
12
  end
@@ -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
44
44
  RUNNING_LOOPS << self
45
45
  result = run_without_thread_enabler
46
46
  exception = EXCEPTIONS.shift
@@ -50,21 +50,7 @@ module GLib
50
50
 
51
51
  # Re-implementation of the g_ptrarray_index macro
52
52
  def index(idx)
53
- unless (0...length).cover? idx
54
- raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
55
- end
56
-
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
-
53
+ item_ptr = item_pointer(idx)
68
54
  convertor = GirFFI::ArrayElementConvertor.new convert_element_type, item_ptr
69
55
  convertor.to_ruby_value
70
56
  end
@@ -85,6 +71,29 @@ module GLib
85
71
 
86
72
  private
87
73
 
74
+ def item_pointer(idx)
75
+ check_bounds(idx)
76
+
77
+ data_ptr + idx * element_size
78
+ end
79
+
80
+ def check_bounds(idx)
81
+ unless (0...length).cover? idx
82
+ raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
83
+ end
84
+ end
85
+
86
+ def convert_element_type
87
+ case element_type
88
+ when :utf8
89
+ :utf8
90
+ when GirFFI::ObjectBase
91
+ element_type
92
+ else
93
+ [:pointer, element_type]
94
+ end
95
+ end
96
+
88
97
  def element_size
89
98
  POINTER_SIZE
90
99
  end
@@ -14,13 +14,11 @@ module GLib
14
14
  alias get_string_without_override get_string
15
15
  alias get_string get_string_with_override
16
16
 
17
- # Initializing method used in constructors. For Variant, this needs to sink
18
- # the variant's floating reference.
19
- #
20
- # NOTE: This is very hard to test since it is not possible to get the
21
- # variant's ref count directely. However, there is an error when running
22
- # the tests on 32-bit systems.
17
+ # Initializing method used in constructors. For Variant the constructing
18
+ # functions all return floating references, so this is need to take full
19
+ # ownership.
23
20
  #
21
+ # Also see the documentation for g_variant_ref_sink.
24
22
  def store_pointer(ptr)
25
23
  Lib.g_variant_ref_sink ptr
26
24
  super
@@ -117,17 +117,12 @@ module GObject
117
117
  end
118
118
 
119
119
  def property_param_spec(property_name)
120
- object_class.find_property property_name or
120
+ class_struct.find_property property_name or
121
121
  raise GirFFI::PropertyNotFoundError.new(property_name, self.class)
122
122
  end
123
123
 
124
124
  # Overrides for GObject, GObject's generic base class.
125
125
  module Overrides
126
- # @deprecated
127
- def get_property_extended(property_name)
128
- get_property(property_name)
129
- end
130
-
131
126
  def get_property(property_name)
132
127
  gvalue = gvalue_for_property property_name
133
128
  super property_name, gvalue
@@ -139,11 +134,6 @@ module GObject
139
134
  value
140
135
  end
141
136
 
142
- # @deprecated
143
- def set_property_extended(property_name, value)
144
- set_property property_name, value
145
- end
146
-
147
137
  def set_property(property_name, value)
148
138
  type_info = get_property_type property_name
149
139
  value = property_value_pre_conversion(value, type_info) if type_info
@@ -1,18 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- GObject::Object.object_class
3
+ GObject::Object.class_struct
4
4
 
5
5
  module GObject
6
- # Overrides for GObjectClass, a struct containing GObject's class data
6
+ # Overrides for GObjectClass, the class struct for GObject::Object
7
7
  class ObjectClass
8
- def set_property=(callback)
9
- struct[:set_property] = GObject::ObjectSetPropertyFunc.from callback
10
- end
11
-
12
- def get_property=(callback)
13
- struct[:get_property] = GObject::ObjectGetPropertyFunc.from callback
14
- end
15
-
16
8
  def gtype
17
9
  to_ptr.get_gtype 0
18
10
  end
@@ -8,29 +8,29 @@ module GObject
8
8
  setup_instance_method! :init
9
9
 
10
10
  METHOD_MAP = {
11
- TYPE_INVALID => [:get_none, :set_none],
11
+ TYPE_INVALID => [:get_none, :set_none],
12
12
  # TYPE_NONE is skipped
13
- TYPE_INTERFACE => [:get_object, :set_instance_enhanced],
14
- TYPE_CHAR => [:get_schar, :set_schar],
15
- TYPE_UCHAR => [:get_uchar, :set_uchar],
16
- TYPE_BOOLEAN => [:get_boolean, :set_boolean],
17
- TYPE_INT => [:get_int, :set_int],
18
- TYPE_UINT => [:get_uint, :set_uint],
19
- TYPE_LONG => [:get_long, :set_long],
20
- TYPE_ULONG => [:get_ulong, :set_ulong],
21
- TYPE_INT64 => [:get_int64, :set_int64],
22
- TYPE_UINT64 => [:get_uint64, :set_uint64],
23
- TYPE_ENUM => [:get_enum_enhanced, :set_enum_enhanced],
24
- TYPE_FLAGS => [:get_flags_enhanced, :set_flags_enhanced],
25
- TYPE_FLOAT => [:get_float, :set_float],
26
- TYPE_DOUBLE => [:get_double, :set_double],
27
- TYPE_STRING => [:get_string, :set_string],
28
- TYPE_POINTER => [:get_pointer, :set_pointer],
29
- TYPE_BOXED => [:get_boxed, :set_boxed],
30
- TYPE_PARAM => [:get_param, :set_param],
31
- TYPE_OBJECT => [:get_object, :set_instance_enhanced],
32
- TYPE_GTYPE => [:get_gtype, :set_gtype],
33
- TYPE_VARIANT => [:get_variant, :set_variant]
13
+ TYPE_INTERFACE => [:get_object, :set_instance_enhanced],
14
+ TYPE_CHAR => [:get_schar, :set_schar],
15
+ TYPE_UCHAR => [:get_uchar, :set_uchar],
16
+ TYPE_BOOLEAN => [:get_boolean, :set_boolean],
17
+ TYPE_INT => [:get_int, :set_int],
18
+ TYPE_UINT => [:get_uint, :set_uint],
19
+ TYPE_LONG => [:get_long, :set_long],
20
+ TYPE_ULONG => [:get_ulong, :set_ulong],
21
+ TYPE_INT64 => [:get_int64, :set_int64],
22
+ TYPE_UINT64 => [:get_uint64, :set_uint64],
23
+ TYPE_ENUM => [:get_enum_enhanced, :set_enum_enhanced],
24
+ TYPE_FLAGS => [:get_flags_enhanced, :set_flags_enhanced],
25
+ TYPE_FLOAT => [:get_float, :set_float],
26
+ TYPE_DOUBLE => [:get_double, :set_double],
27
+ TYPE_STRING => [:get_string, :set_string],
28
+ TYPE_POINTER => [:get_pointer, :set_pointer],
29
+ TYPE_BOXED => [:get_boxed, :set_boxed],
30
+ TYPE_PARAM => [:get_param, :set_param],
31
+ TYPE_OBJECT => [:get_object, :set_instance_enhanced],
32
+ TYPE_GTYPE => [:get_gtype, :set_gtype],
33
+ TYPE_VARIANT => [:get_variant, :set_variant]
34
34
  }.freeze
35
35
 
36
36
  # TODO: Give more generic name
@@ -68,11 +68,11 @@ module GObject
68
68
  end
69
69
 
70
70
  CLASS_TO_GTYPE_MAP = {
71
- NilClass => TYPE_INVALID,
72
- TrueClass => TYPE_BOOLEAN,
71
+ NilClass => TYPE_INVALID,
72
+ TrueClass => TYPE_BOOLEAN,
73
73
  FalseClass => TYPE_BOOLEAN,
74
- Integer => TYPE_INT,
75
- String => TYPE_STRING
74
+ Integer => TYPE_INT,
75
+ String => TYPE_STRING
76
76
  }.freeze
77
77
 
78
78
  # Overrides for existing Value methods
data/lib/ffi-gobject.rb CHANGED
@@ -31,17 +31,6 @@ module GObject
31
31
  type_name type_from_instance instance
32
32
  end
33
33
 
34
- def self.object_class_from_instance(instance)
35
- object_class_from_instance_pointer instance.to_ptr
36
- end
37
-
38
- def self.object_class_from_instance_pointer(inst_ptr)
39
- return nil if inst_ptr.null?
40
-
41
- klsptr = inst_ptr.get_pointer 0
42
- ObjectClass.wrap klsptr
43
- end
44
-
45
34
  def self.signal_lookup_from_instance(signal, object)
46
35
  signal_lookup signal, type_from_instance(object)
47
36
  end
@@ -55,11 +44,7 @@ module GObject
55
44
  argument_gvalues = sig_info.arguments_to_gvalues object, args
56
45
  return_gvalue = sig_info.gvalue_for_return_value
57
46
 
58
- result = signal_emitv argument_gvalues, signal_id, detail_quark, return_gvalue
59
- # NOTE: Depending on the version of GObjectIntrospection, the result will
60
- # be stored in result or return_gvalue. This was changed between versions
61
- # 1.44 and 1.46.
62
- result || return_gvalue.get_value
47
+ signal_emitv argument_gvalues, signal_id, detail_quark, return_gvalue
63
48
  end
64
49
 
65
50
  def self.signal_connect(object, detailed_signal, data = nil, after = false, &block)
@@ -85,7 +70,8 @@ module GObject
85
70
  load_class :ClosureMarshal
86
71
  load_class :ParamFlags
87
72
 
88
- # NOTE: This Lib module is set up in `gir_ffi-base/gobject/lib.rb`.
73
+ # Attach some needed functions to the GObject Lib, which was set up in
74
+ # `gir_ffi-base/gobject/lib.rb`.
89
75
  Lib.class_eval do
90
76
  attach_function :g_object_ref_sink, [:pointer], :pointer
91
77
  attach_function :g_object_ref, [:pointer], :pointer
@@ -5,16 +5,16 @@ module GObjectIntrospection
5
5
  class IConstantInfo < IBaseInfo
6
6
  TYPE_TAG_TO_UNION_MEMBER = {
7
7
  gboolean: :v_boolean,
8
- gint8: :v_int8,
9
- gint16: :v_int16,
10
- gint32: :v_int32,
11
- gint64: :v_int64,
12
- guint8: :v_uint8,
13
- guint16: :v_uint16,
14
- guint32: :v_uint32,
15
- guint64: :v_uint64,
16
- gdouble: :v_double,
17
- utf8: :v_string
8
+ gint8: :v_int8,
9
+ gint16: :v_int16,
10
+ gint32: :v_int32,
11
+ gint64: :v_int64,
12
+ guint8: :v_uint8,
13
+ guint16: :v_uint16,
14
+ guint32: :v_uint32,
15
+ guint64: :v_uint64,
16
+ gdouble: :v_double,
17
+ utf8: :v_string
18
18
  }.freeze
19
19
 
20
20
  def value
@@ -63,12 +63,12 @@ module GObjectIntrospection
63
63
 
64
64
  # IFunctionInfo
65
65
  bit_mask :IFunctionInfoFlags,
66
- is_method: (1 << 0),
66
+ is_method: (1 << 0),
67
67
  is_constructor: (1 << 1),
68
- is_getter: (1 << 2),
69
- is_setter: (1 << 3),
70
- wraps_vfunc: (1 << 4),
71
- throws: (1 << 5)
68
+ is_getter: (1 << 2),
69
+ is_setter: (1 << 3),
70
+ wraps_vfunc: (1 << 4),
71
+ throws: (1 << 5)
72
72
 
73
73
  attach_function :g_function_info_get_symbol, [:pointer], :string
74
74
  attach_function :g_function_info_get_flags, [:pointer], :IFunctionInfoFlags
@@ -231,10 +231,10 @@ module GObjectIntrospection
231
231
 
232
232
  # IVFuncInfo
233
233
  bit_mask :IVFuncInfoFlags,
234
- must_chain_up: (1 << 0),
235
- must_override: (1 << 1),
234
+ must_chain_up: (1 << 0),
235
+ must_override: (1 << 1),
236
236
  must_not_override: (1 << 2),
237
- throws: (1 << 3)
237
+ throws: (1 << 3)
238
238
 
239
239
  attach_function :g_vfunc_info_get_flags, [:pointer], :IVFuncInfoFlags
240
240
  attach_function :g_vfunc_info_get_invoker, [:pointer], :pointer
@@ -294,9 +294,9 @@ module GObjectIntrospection
294
294
 
295
295
  # NOTE: This type has more values, but these are the ones used
296
296
  bit_mask :ParamFlags,
297
- readable: (1 << 0),
298
- writable: (1 << 1),
299
- construct: (1 << 2),
297
+ readable: (1 << 0),
298
+ writable: (1 << 1),
299
+ construct: (1 << 2),
300
300
  construct_only: (1 << 3)
301
301
 
302
302
  attach_function :g_property_info_get_flags, [:pointer], :ParamFlags
@@ -25,27 +25,27 @@ require "ffi-gobject_introspection/i_unresolved_info"
25
25
  module GObjectIntrospection
26
26
  # Map info type to class. Default is IBaseInfo.
27
27
  TYPEMAP = {
28
- invalid: IBaseInfo,
29
- function: IFunctionInfo,
30
- callback: ICallbackInfo,
31
- struct: IStructInfo,
28
+ invalid: IBaseInfo,
29
+ function: IFunctionInfo,
30
+ callback: ICallbackInfo,
31
+ struct: IStructInfo,
32
32
  # TODO: There's no GIBoxedInfo, so what does :boxed mean?
33
- boxed: IBaseInfo,
34
- enum: IEnumInfo,
35
- flags: IFlagsInfo,
36
- object: IObjectInfo,
37
- interface: IInterfaceInfo,
38
- constant: IConstantInfo,
33
+ boxed: IBaseInfo,
34
+ enum: IEnumInfo,
35
+ flags: IFlagsInfo,
36
+ object: IObjectInfo,
37
+ interface: IInterfaceInfo,
38
+ constant: IConstantInfo,
39
39
  invalid_was_error_domain: IBaseInfo,
40
- union: IUnionInfo,
41
- value: IValueInfo,
42
- signal: ISignalInfo,
43
- vfunc: IVFuncInfo,
44
- property: IPropertyInfo,
45
- field: IFieldInfo,
46
- arg: IArgInfo,
47
- type: ITypeInfo,
48
- unresolved: IUnresolvedInfo
40
+ union: IUnionInfo,
41
+ value: IValueInfo,
42
+ signal: ISignalInfo,
43
+ vfunc: IVFuncInfo,
44
+ property: IPropertyInfo,
45
+ field: IFieldInfo,
46
+ arg: IArgInfo,
47
+ type: ITypeInfo,
48
+ unresolved: IUnresolvedInfo
49
49
  }.freeze
50
50
  end
51
51
 
@@ -46,7 +46,7 @@ module GirFFI
46
46
  end
47
47
  Builders::ModuleBuilder.new(module_name,
48
48
  namespace: namespace,
49
- version: version).generate
49
+ version: version).generate
50
50
  end
51
51
 
52
52
  # TODO: Move elsewhere, perhaps to FunctionBuilder.
@@ -28,11 +28,11 @@ module GirFFI
28
28
 
29
29
  def capture_variable_names
30
30
  @capture_variable_names ||=
31
- all_builders.map(&:capture_variable_name).compact
31
+ all_builders.filter_map(&:capture_variable_name)
32
32
  end
33
33
 
34
34
  def call_argument_names
35
- @call_argument_names ||= argument_builders.map(&:call_argument_name).compact
35
+ @call_argument_names ||= argument_builders.filter_map(&:call_argument_name)
36
36
  end
37
37
 
38
38
  def method_argument_names
@@ -50,7 +50,7 @@ module GirFFI
50
50
  end
51
51
 
52
52
  def return_value_names
53
- @return_value_names ||= all_builders.map(&:return_value_name).compact
53
+ @return_value_names ||= all_builders.filter_map(&:return_value_name)
54
54
  end
55
55
 
56
56
  def has_return_values?
@@ -149,7 +149,7 @@ module GirFFI
149
149
 
150
150
  def base_argument_names(arguments)
151
151
  required_found = false
152
- arguments.reverse.map do |it|
152
+ arguments.reverse.filter_map do |it|
153
153
  name = it.method_argument_name
154
154
  if it.allow_none? && !required_found
155
155
  "#{name} = nil"
@@ -157,7 +157,7 @@ module GirFFI
157
157
  required_found = true
158
158
  name
159
159
  end
160
- end.compact.reverse
160
+ end.reverse
161
161
  end
162
162
  end
163
163
  end
@@ -6,13 +6,13 @@ module GirFFI
6
6
  # classes are used by FunctionBuilder to create the code that
7
7
  # processes each argument before and after the actual function call.
8
8
  class BaseArgumentBuilder
9
- KEYWORDS = %w(
9
+ KEYWORDS = %w[
10
10
  alias and begin break case class def do
11
11
  else elsif end ensure false for if in
12
12
  module next nil not or redo rescue retry
13
13
  return self super then true undef unless
14
14
  until when while yield
15
- ).freeze
15
+ ].freeze
16
16
 
17
17
  attr_reader :arginfo, :related_callback_builder
18
18
 
@@ -21,14 +21,30 @@ module GirFFI
21
21
  @receiver_info = receiver_info
22
22
  end
23
23
 
24
- def variable_generator
25
- @variable_generator ||= VariableNameGenerator.new
26
- end
27
-
28
24
  def method_definition
29
25
  template.method_definition
30
26
  end
31
27
 
28
+ # Methods used by MethodTemplate
29
+
30
+ def invocation
31
+ "#{lib_name}.#{@info.symbol} #{function_call_arguments.join(', ')}".strip
32
+ end
33
+
34
+ def method_arguments
35
+ argument_builder_collection.method_argument_names
36
+ end
37
+
38
+ def preparation
39
+ []
40
+ end
41
+
42
+ private
43
+
44
+ def variable_generator
45
+ @variable_generator ||= VariableNameGenerator.new
46
+ end
47
+
32
48
  def template
33
49
  @template ||= MethodTemplate.new(self, argument_builder_collection)
34
50
  end
@@ -47,8 +63,8 @@ module GirFFI
47
63
  end
48
64
 
49
65
  def return_value_builder
50
- @return_value_builder = @return_value_builder_class.new(variable_generator,
51
- return_value_info)
66
+ @return_value_builder ||= @return_value_builder_class.new(variable_generator,
67
+ return_value_info)
52
68
  end
53
69
 
54
70
  def receiver_builder
@@ -59,7 +75,7 @@ module GirFFI
59
75
  @argument_builder_collection ||=
60
76
  ArgumentBuilderCollection.new(return_value_builder, argument_builders,
61
77
  error_argument_builder: error_argument,
62
- receiver_builder: receiver_builder)
78
+ receiver_builder: receiver_builder)
63
79
  end
64
80
 
65
81
  def error_argument
@@ -71,22 +87,6 @@ module GirFFI
71
87
  end
72
88
  end
73
89
 
74
- # Methods used by MethodTemplate
75
-
76
- def invocation
77
- "#{lib_name}.#{@info.symbol} #{function_call_arguments.join(', ')}".strip
78
- end
79
-
80
- def method_arguments
81
- argument_builder_collection.method_argument_names
82
- end
83
-
84
- def preparation
85
- []
86
- end
87
-
88
- private
89
-
90
90
  def lib_name
91
91
  "#{@info.safe_namespace}::Lib"
92
92
  end