Class: GirFFI::Builders::CallbackReturnValueBuilder

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

Overview

Implements building post-processing statements for return values of callbacks.

Constant Summary

Constants inherited from BaseArgumentBuilder

BaseArgumentBuilder::KEYWORDS

Instance Attribute Summary

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, #initialize, #name, #new_variable, #safe, #specialized_type_tag, #type_info

Constructor Details

This class inherits a constructor from GirFFI::Builders::BaseArgumentBuilder

Instance Method Details

#capture_variable_nameObject



13
14
15
16
17
# File 'lib/gir_ffi/builders/callback_return_value_builder.rb', line 13

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

#is_relevant?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/gir_ffi/builders/callback_return_value_builder.rb', line 9

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

#post_conversionObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gir_ffi/builders/callback_return_value_builder.rb', line 33

def post_conversion
  if has_post_conversion?
    if type_info.flattened_tag == :object
      [ "#{post_converted_name} = #{post_convertor.conversion}.to_ptr" ]
    else
      [ "#{post_converted_name} = #{post_convertor.conversion}" ]
    end
  else
    []
  end
end

#post_converted_nameObject



19
20
21
22
23
24
25
# File 'lib/gir_ffi/builders/callback_return_value_builder.rb', line 19

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

#return_value_nameObject



27
28
29
30
31
# File 'lib/gir_ffi/builders/callback_return_value_builder.rb', line 27

def return_value_name
  if is_relevant?
    post_converted_name unless array_arg
  end
end