Sha256: cf922f484daa968c6b46a731856d5d2029d060522762314a010b68c1f94844cd
Contents?: true
Size: 1.04 KB
Versions: 13
Compression:
Stored size: 1.04 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 when :enum "to_int" else "from" end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems