Sha256: 18111144f9777970b491fc0efb612f0d18d2d5364f3558a411a3927d16fba6d9

Contents?: true

Size: 607 Bytes

Versions: 3

Compression:

Stored size: 607 Bytes

Contents

# frozen_string_literal: true
module GirFFI
  module Builders
    # Builder that generates code to convert values from Ruby to C. Used by
    # argument builders.
    class RubyToCConvertor
      def initialize(type_info, argument_name)
        @type_info = type_info
        @argument_name = argument_name
      end

      def conversion
        args = conversion_arguments @argument_name
        "#{@type_info.argument_class_name}.from(#{args})"
      end

      def conversion_arguments(name)
        @type_info.extra_conversion_arguments.map(&:inspect).push(name).join(', ')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.9.5 lib/gir_ffi/builders/ruby_to_c_convertor.rb
gir_ffi-0.9.4 lib/gir_ffi/builders/ruby_to_c_convertor.rb
gir_ffi-0.9.3 lib/gir_ffi/builders/ruby_to_c_convertor.rb