Class: GirFFI::Builders::FieldBuilder::GetterArgumentBuilder

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

Overview

Convertor for fields for field getters. Used when building getter methods.

Constant Summary

Constants inherited from BaseArgumentBuilder

BaseArgumentBuilder::KEYWORDS

Instance Attribute Summary collapse

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_parameter?, #call_argument_name, #closure_idx, #destroy_idx, #destroy_notifier?, #direction, #helper_argument?, #mark_as_destroy_notifier, #mark_as_user_data, #name, #new_variable, #ownership_transfer, #safe, #specialized_type_tag, #type_info, #user_data?

Constructor Details

#initialize(var_gen, field_argument_info, field_info, array_length_idx: -1)) ⇒ GetterArgumentBuilder

Returns a new instance of GetterArgumentBuilder.



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

def initialize(var_gen, field_argument_info, field_info,
               array_length_idx: -1)
  super(var_gen, field_argument_info)
  @field_info = field_info
  @length_arg = NullArgumentBuilder.new
  @array_length_idx = array_length_idx
end

Instance Attribute Details

#array_length_idxObject (readonly)

Returns the value of attribute array_length_idx.



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

def array_length_idx
  @array_length_idx
end

Instance Method Details

#capture_variable_nameObject



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

def capture_variable_name
  nil
end

#post_conversionObject



50
51
52
53
54
55
56
# File 'lib/gir_ffi/builders/field_builder.rb', line 50

def post_conversion
  if has_post_conversion?
    ["#{post_converted_name} = #{post_convertor.conversion}"]
  else
    []
  end
end

#post_converted_nameObject



38
39
40
41
42
43
44
# File 'lib/gir_ffi/builders/field_builder.rb', line 38

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

#pre_conversionObject



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

def pre_conversion
  [
    "#{field_ptr} = @struct.to_ptr",
    "#{bare_value} = #{pointer_to_value_conversion}"
  ]
end

#return_value_nameObject



46
47
48
# File 'lib/gir_ffi/builders/field_builder.rb', line 46

def return_value_name
  post_converted_name
end