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

Instance Method Summary collapse

Methods inherited from BaseArgumentBuilder

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

Constructor Details

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

Returns a new instance of GetterArgumentBuilder.



14
15
16
17
18
19
20
# File 'lib/gir_ffi/builders/field_builder.rb', line 14

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.



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

def array_length_idx
  @array_length_idx
end

Instance Method Details

#capture_variable_nameObject



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

def capture_variable_name
  nil
end

#post_conversionObject



46
47
48
49
50
51
52
# File 'lib/gir_ffi/builders/field_builder.rb', line 46

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

#post_converted_nameObject



34
35
36
37
38
39
40
# File 'lib/gir_ffi/builders/field_builder.rb', line 34

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

#pre_conversionObject



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

def pre_conversion
  [
    "#{field_ptr} = @struct.to_ptr + #{field_offset}",
    "#{typed_ptr} = GirFFI::InOutPointer.new(#{field_type_tag}, #{field_ptr})",
    "#{bare_value} = #{typed_ptr}.to_value"
  ]
end

#return_value_nameObject



42
43
44
# File 'lib/gir_ffi/builders/field_builder.rb', line 42

def return_value_name
  post_converted_name
end