Class: GirFFI::Builders::CallbackArgumentBuilder

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

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

#call_argument_nameObject



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

def call_argument_name
  if direction == :in
    pre_converted_name unless array_arg
  end
end

#capture_variable_nameObject



23
24
25
# File 'lib/gir_ffi/builders/callback_argument_builder.rb', line 23

def capture_variable_name
  result_name if direction == :out
end

#method_argument_nameObject



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

def method_argument_name
  @method_argument_name ||= name || new_variable
end

#post_conversionObject



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

def post_conversion
  case direction
  when :out
    [ outgoing_post_conversion ]
  when :error
    [
      "rescue => #{result_name}",
      outgoing_post_conversion,
      "end"
    ]
  else
    []
  end
end

#pre_conversionObject



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

def pre_conversion
  case direction
  when :in
    [ "#{pre_converted_name} = #{pre_convertor.conversion}" ]
  when :out
    [ "#{pre_converted_name} = #{out_parameter_preparation}" ]
  when :error
    [
      "#{pre_converted_name} = #{out_parameter_preparation}",
      "begin"
    ]
  end
end

#pre_converted_nameObject



13
14
15
# File 'lib/gir_ffi/builders/callback_argument_builder.rb', line 13

def pre_converted_name
  @pre_converted_name ||= new_variable
end