Class: GirFFI::Builders::ArgumentBuilderCollection
- Inherits:
-
Object
- Object
- GirFFI::Builders::ArgumentBuilderCollection
- Defined in:
- lib/gir_ffi/builders/argument_builder_collection.rb
Overview
Class representing the argument and return value builders for a callback mapping function or marshaller. Implements collecting the conversion code and parameter and variable names for use by function builders.
Instance Attribute Summary collapse
-
#argument_builders ⇒ Object
readonly
Returns the value of attribute argument_builders.
-
#return_value_builder ⇒ Object
readonly
Returns the value of attribute return_value_builder.
Class Method Summary collapse
Instance Method Summary collapse
- #call_argument_names ⇒ Object
- #capture_variable_names ⇒ Object
-
#initialize(return_value_builder, argument_builders, options = {}) ⇒ ArgumentBuilderCollection
constructor
A new instance of ArgumentBuilderCollection.
- #method_argument_names ⇒ Object
- #parameter_preparation ⇒ Object
- #return_value_conversion ⇒ Object
- #return_value_name ⇒ Object
Constructor Details
#initialize(return_value_builder, argument_builders, options = {}) ⇒ ArgumentBuilderCollection
Returns a new instance of ArgumentBuilderCollection.
10 11 12 13 14 15 16 |
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 10 def initialize return_value_builder, argument_builders, = {} @receiver_builder = [:receiver_builder] @argument_builders = argument_builders @return_value_builder = return_value_builder self.class.set_up_argument_relations argument_builders @argument_builders.unshift @receiver_builder if @receiver_builder end |
Instance Attribute Details
#argument_builders ⇒ Object (readonly)
Returns the value of attribute argument_builders.
8 9 10 |
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 8 def argument_builders @argument_builders end |
#return_value_builder ⇒ Object (readonly)
Returns the value of attribute return_value_builder.
7 8 9 |
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 7 def return_value_builder @return_value_builder end |
Class Method Details
.set_up_argument_relations(argument_builders) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 44 def self.set_up_argument_relations argument_builders argument_builders.each do |arg| if (idx = arg.arginfo.closure) >= 0 argument_builders[idx].is_closure = true end end argument_builders.each do |bldr| if (idx = bldr.array_length_idx) >= 0 other = argument_builders[idx] bldr.length_arg = other other.array_arg = bldr end end end |
Instance Method Details
#call_argument_names ⇒ Object
32 33 34 |
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 32 def call_argument_names @call_argument_names ||= argument_builders.map(&:call_argument_name).compact end |
#capture_variable_names ⇒ Object
27 28 29 30 |
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 27 def capture_variable_names @capture_variable_names ||= all_builders.map(&:capture_variable_name).compact end |
#method_argument_names ⇒ Object
36 37 38 |
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 36 def method_argument_names @method_argument_names ||= argument_builders.map(&:method_argument_name) end |
#parameter_preparation ⇒ Object
18 19 20 21 |
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 18 def parameter_preparation argument_builders.sort_by.with_index {|arg, i| [arg.type_info.array_length, i] }.map(&:pre_conversion).flatten end |
#return_value_conversion ⇒ Object
23 24 25 |
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 23 def return_value_conversion all_builders.map(&:post_conversion).flatten end |
#return_value_name ⇒ Object
40 41 42 |
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 40 def return_value_name return_value_builder.return_value_name if return_value_builder.is_relevant? end |