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, #length_arg

Instance Method Summary collapse

Methods inherited from BaseArgumentBuilder

#argument_class_name, #array_length_idx, #call_argument_name, #closure=, #closure?, #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
# File 'lib/gir_ffi/builders/callback_return_value_builder.rb', line 13

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

#post_conversionObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gir_ffi/builders/callback_return_value_builder.rb', line 29

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



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

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

#relevant?Boolean

Returns:

  • (Boolean)


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

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

#return_value_nameObject



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

def return_value_name
  post_converted_name if has_return_value_name?
end