module GirFFI::Builder::OutArgument

Implements argument processing for arguments with direction :out.

Public Class Methods

build(var_gen, arginfo, libmodule) click to toggle source
# File lib/gir_ffi/builder/argument.rb, line 222
def self.build var_gen, arginfo, libmodule
  type = arginfo.argument_type
  direction = arginfo.direction
  klass = case type.tag
          when :interface
            case type.interface.info_type
            when :enum, :flags
              EnumOutArgument
            else
              if arginfo.caller_allocates?
                AllocatedInterfaceOutArgument
              else
                InterfaceOutArgument
              end
            end
          when :array
            if type.zero_terminated?
              InterfaceOutArgument
            else
              case type.array_type
              when :c
                CArrayOutArgument
              when :array
                it = PointerLikeOutArgument.new var_gen, arginfo.name, type, direction
                it.extend WithTypedContainerPostMethod
                return it
              end
            end
          when :glist, :gslist, :ghash
            it = PointerLikeOutArgument.new var_gen, arginfo.name, type, direction
            it.extend WithTypedContainerPostMethod
            return it
          else
            RegularArgument
          end
  klass.new var_gen, arginfo.name, type, direction
end