Class: GirFFI::Builders::ReturnValueBuilder
- Inherits:
-
BaseArgumentBuilder
- Object
- BaseArgumentBuilder
- GirFFI::Builders::ReturnValueBuilder
- 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
Instance Attribute Summary collapse
-
#is_constructor ⇒ Object
readonly
Returns the value of attribute is_constructor.
Attributes inherited from BaseArgumentBuilder
#arginfo, #array_arg, #is_closure, #length_arg
Instance Method Summary collapse
- #capture_variable_name ⇒ Object
-
#initialize(var_gen, arginfo, is_constructor = false) ⇒ ReturnValueBuilder
constructor
A new instance of ReturnValueBuilder.
- #is_relevant? ⇒ Boolean
- #post_conversion ⇒ Object
- #post_converted_name ⇒ Object
- #return_value_name ⇒ Object
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_constructor ⇒ Object (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_name ⇒ Object
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
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_conversion ⇒ Object
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_name ⇒ Object
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_name ⇒ Object
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 |