Class: GirFFI::Builders::ArgumentBuilder

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

Overview

Implements building pre- and post-processing statements for arguments.

Constant Summary

Constants inherited from BaseArgumentBuilder

BaseArgumentBuilder::KEYWORDS

Instance Attribute Summary

Attributes inherited from BaseArgumentBuilder

#arginfo, #array_arg, #length_arg, #related_callback_builder

Instance Method Summary collapse

Methods inherited from BaseArgumentBuilder

#argument_class_name, #array_length_idx, #array_length_parameter?, #call_argument_name, #closure_idx, #destroy_idx, #destroy_notifier?, #direction, #helper_argument?, #initialize, #mark_as_destroy_notifier, #mark_as_user_data, #name, #new_variable, #ownership_transfer, #safe, #specialized_type_tag, #type_info, #user_data?

Constructor Details

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

Instance Method Details

#allow_none?Boolean

Returns:



22
23
24
# File 'lib/gir_ffi/builders/argument_builder.rb', line 22

def allow_none?
  arginfo.may_be_null?
end

#block_argument?Boolean

Returns:



18
19
20
# File 'lib/gir_ffi/builders/argument_builder.rb', line 18

def block_argument?
  specialized_type_tag == :callback
end

#capture_variable_nameObject



38
39
40
# File 'lib/gir_ffi/builders/argument_builder.rb', line 38

def capture_variable_name
  nil
end

#method_argument_nameObject



14
15
16
# File 'lib/gir_ffi/builders/argument_builder.rb', line 14

def method_argument_name
  name if has_input_value? && !helper_argument?
end

#post_conversionObject



55
56
57
58
59
60
61
62
63
64
# File 'lib/gir_ffi/builders/argument_builder.rb', line 55

def post_conversion
  if direction == :error
    ["GirFFI::ArgHelper.check_error(#{call_argument_name})"]
  elsif has_post_conversion?
    value = output_value
    ["#{post_converted_name} = #{value}"]
  else
    []
  end
end

#post_converted_nameObject



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

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

#pre_conversionObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gir_ffi/builders/argument_builder.rb', line 42

def pre_conversion
  case direction
  when :in
    pre_conversion_in
  when :inout
    pre_conversion_inout
  when :out
    pre_conversion_out
  when :error
    pre_conversion_error
  end
end

#return_value_nameObject



34
35
36
# File 'lib/gir_ffi/builders/argument_builder.rb', line 34

def return_value_name
  post_converted_name if has_output_value? && !array_length_parameter?
end