Class: GirFFI::Builders::CToRubyConvertor

Inherits:
Object
  • Object
show all
Defined in:
lib/gir_ffi/builders/c_to_ruby_convertor.rb

Overview

Builder that generates code to convert values from C to Ruby. Used by argument builders.

Direct Known Subclasses

FullCToRubyConvertor

Instance Method Summary collapse

Constructor Details

#initialize(type_info, argument_name, length_arg) ⇒ CToRubyConvertor

Returns a new instance of CToRubyConvertor.



6
7
8
9
10
# File 'lib/gir_ffi/builders/c_to_ruby_convertor.rb', line 6

def initialize(type_info, argument_name, length_arg)
  @type_info = type_info
  @argument_name = argument_name
  @length_arg = length_arg
end

Instance Method Details

#conversionObject



12
13
14
15
16
17
18
19
# File 'lib/gir_ffi/builders/c_to_ruby_convertor.rb', line 12

def conversion
  case @type_info.flattened_tag
  when :utf8, :filename
    "#{@argument_name}.to_utf8"
  else
    "#{@type_info.argument_class_name}.wrap(#{conversion_argument_list})"
  end
end