Sha256: 72487719f4c90f1d55d81d79755b04d22238c74f5fb55824d03391266f48de74
Contents?: true
Size: 1.01 KB
Versions: 6
Compression:
Stored size: 1.01 KB
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, ownership_transfer: nil) @type_info = type_info @argument_name = argument_name @ownership_transfer = ownership_transfer end def conversion args = conversion_arguments @argument_name "#{@type_info.argument_class_name}.#{conversion_method}(#{args})" end def conversion_arguments(name) @type_info.extra_conversion_arguments.map(&:inspect).push(name).join(', ') end private 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 else 'from' end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems