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

Instance Method Summary collapse

Methods inherited from BaseArgumentBuilder

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

Constructor Details

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

Instance Method Details

#block_argument?Boolean

TODO: Improve this so each method can only have one block argument.

Returns:

  • (Boolean)


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

def block_argument?
  specialized_type_tag == :callback
end

#capture_variable_nameObject



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

def capture_variable_name
  nil
end

#method_argument_nameObject



12
13
14
# File 'lib/gir_ffi/builders/argument_builder.rb', line 12

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

#post_conversionObject



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

def post_conversion
  if has_post_conversion?
    value = output_value
    ["#{post_converted_name} = #{value}"]
  else
    []
  end
end

#post_converted_nameObject



21
22
23
24
25
26
27
# File 'lib/gir_ffi/builders/argument_builder.rb', line 21

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

#pre_conversionObject



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

def pre_conversion
  pr = []
  case direction
  when :in
    pr << fixed_array_size_check if needs_size_check?
    pr << array_length_assignment if array_length_parameter?
    pr << "#{call_argument_name} = #{ingoing_convertor.conversion}"
  when :inout
    pr << fixed_array_size_check if needs_size_check?
    pr << array_length_assignment if array_length_parameter?
    pr << out_parameter_preparation
    pr << "#{call_argument_name}.set_value #{ingoing_convertor.conversion}"
  when :out
    pr << out_parameter_preparation
  end
  pr
end

#return_value_nameObject



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

def return_value_name
  if has_output_value?
    post_converted_name unless array_length_parameter?
  end
end