class GirFFI::Builders::RubyToCConvertor
Builder
that generates code to convert values from Ruby to C. Used by argument builders.
Public Class Methods
new(type_info, argument_name, ownership_transfer: nil)
click to toggle source
# File lib/gir_ffi/builders/ruby_to_c_convertor.rb, line 8 def initialize(type_info, argument_name, ownership_transfer: nil) @type_info = type_info @argument_name = argument_name @ownership_transfer = ownership_transfer end
Public Instance Methods
conversion()
click to toggle source
# File lib/gir_ffi/builders/ruby_to_c_convertor.rb, line 14 def conversion args = conversion_arguments @argument_name "#{@type_info.argument_class_name}.#{conversion_method}(#{args})" end
conversion_arguments(name)
click to toggle source
# File lib/gir_ffi/builders/ruby_to_c_convertor.rb, line 19 def conversion_arguments(name) @type_info.extra_conversion_arguments.map(&:inspect).push(name).join(", ") end
Private Instance Methods
conversion_method()
click to toggle source
# File lib/gir_ffi/builders/ruby_to_c_convertor.rb, line 25 def conversion_method case @type_info.flattened_tag when :utf8 "from_utf8" when :struct, :c case @ownership_transfer when :everything "copy_from" else "from" end when :enum "to_int" else "from" end end