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 collapse

Attributes inherited from BaseArgumentBuilder

#arginfo, #array_arg, #is_closure, #length_arg

Instance Method Summary collapse

Methods inherited from BaseArgumentBuilder

#argument_class_name, #array_length_idx, #callarg, #direction, #name, #new_variable, #safe, #specialized_type_tag, #type_info

Constructor Details

#initialize(var_gen, arginfo, is_constructor = 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, is_constructor = false
  super var_gen, arginfo
  @is_constructor = is_constructor
end

Instance Attribute Details

#is_constructorObject (readonly)

Returns the value of attribute is_constructor.



45
46
47
# File 'lib/gir_ffi/builders/return_value_builder.rb', line 45

def is_constructor
  @is_constructor
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
end

#is_relevant?Boolean

Returns:

  • (Boolean)


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

def is_relevant?
  !is_void_return_value? && !arginfo.skip?
end

#post_conversionObject



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

def post_conversion
  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

#return_value_nameObject



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

def return_value_name
  if is_relevant?
    post_converted_name unless array_arg
  end
end