Class: GirFFI::Builders::ArgumentBuilderCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/gir_ffi/builders/argument_builder_collection.rb

Overview

Class representing the argument and return value builders for a method, callback mapping function or marshaller. Implements collecting the conversion code and parameter and variable names for use by function builders.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(return_value_builder, argument_builders, receiver_builder: nil, error_argument_builder: nil) ⇒ ArgumentBuilderCollection

Returns a new instance of ArgumentBuilderCollection.



12
13
14
15
16
17
18
19
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 12

def initialize(return_value_builder, argument_builders,
               receiver_builder: nil, error_argument_builder: nil)
  @receiver_builder = receiver_builder
  @error_argument_builder = error_argument_builder
  @base_argument_builders = argument_builders
  @return_value_builder = return_value_builder
  set_up_argument_relations
end

Instance Attribute Details

#return_value_builderObject (readonly)

Returns the value of attribute return_value_builder.



10
11
12
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 10

def return_value_builder
  @return_value_builder
end

Instance Method Details

#call_argument_namesObject



34
35
36
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 34

def call_argument_names
  @call_argument_names ||= argument_builders.filter_map(&:call_argument_name)
end

#capture_variable_namesObject



29
30
31
32
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 29

def capture_variable_names
  @capture_variable_names ||=
    all_builders.filter_map(&:capture_variable_name)
end

#has_return_values?Boolean

Returns:



56
57
58
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 56

def has_return_values?
  return_value_names.any?
end

#method_argument_namesObject



38
39
40
41
42
43
44
45
46
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 38

def method_argument_names
  @method_argument_names ||=
    begin
      base, block = split_off_block_argument
      args = base_argument_names(base)
      args << "&#{block.method_argument_name}" if block
      args
    end
end

#parameter_preparationObject



21
22
23
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 21

def parameter_preparation
  builders_for_pre_conversion.map(&:pre_conversion).flatten
end

#return_value_conversionObject



25
26
27
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 25

def return_value_conversion
  builders_for_post_conversion.map(&:post_conversion).flatten
end

#return_value_nameObject



48
49
50
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 48

def return_value_name
  return_value_builder.return_value_name
end

#return_value_namesObject



52
53
54
# File 'lib/gir_ffi/builders/argument_builder_collection.rb', line 52

def return_value_names
  @return_value_names ||= all_builders.filter_map(&:return_value_name)
end