Class: GirFFI::Builders::ReturnValueBuilder

Inherits:
BaseArgumentBuilder show all
Defined in:
lib/gir_ffi/builders/return_value_builder.rb

Overview

Implements building post-processing statements for return values.

Constant Summary

Constants inherited from BaseArgumentBuilder

BaseArgumentBuilder::KEYWORDS

Instance Attribute Summary

Attributes inherited from BaseArgumentBuilder

#arginfo, #array_arg, #length_arg

Instance Method Summary collapse

Methods inherited from BaseArgumentBuilder

#argument_class_name, #array_length_idx, #call_argument_name, #closure=, #closure?, #direction, #name, #new_variable, #safe, #specialized_type_tag, #type_info

Constructor Details

#initialize(var_gen, arginfo, constructor_result = false) ⇒ ReturnValueBuilder

Returns a new instance of ReturnValueBuilder.



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

def initialize var_gen, arginfo, constructor_result = false
  super var_gen, arginfo
  @constructor_result = constructor_result
end

Instance Method Details

#capture_variable_nameObject



19
20
21
# File 'lib/gir_ffi/builders/return_value_builder.rb', line 19

def capture_variable_name
  @capture_variable_name ||= new_variable if relevant?
end

#post_conversionObject



35
36
37
38
39
40
41
42
# File 'lib/gir_ffi/builders/return_value_builder.rb', line 35

def post_conversion
  # TODO: Avoid conditional by using NullConvertor
  if has_post_conversion?
    ["#{post_converted_name} = #{post_convertor.conversion}"]
  else
    []
  end
end

#post_converted_nameObject



23
24
25
26
27
28
29
# File 'lib/gir_ffi/builders/return_value_builder.rb', line 23

def post_converted_name
  @post_converted_name ||= if has_post_conversion?
                             new_variable
                           else
                             capture_variable_name
                           end
end

#relevant?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/gir_ffi/builders/return_value_builder.rb', line 15

def relevant?
  !void_return_value? && !arginfo.skip?
end

#return_value_nameObject



31
32
33
# File 'lib/gir_ffi/builders/return_value_builder.rb', line 31

def return_value_name
  post_converted_name if has_return_value_name?
end