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)


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

def block_argument?
  specialized_type_tag == :callback
end

#capture_variable_nameObject



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

def capture_variable_name
  nil
end

#method_argument_nameObject



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

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

#post_conversionObject



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

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

#post_converted_nameObject



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

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

#pre_conversionObject



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

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



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

def return_value_name
  if has_output_value?
    post_converted_name unless array_length_parameter?
  end
end