### Home Classes Methods

### In Files

- lib/ffi/variadic.rb

### Parent

Object

### Methods

- #attach
- #call
- #init

### Files

- Makefile
- ChangeLog
- LICENSE
- README
- compile
- configure
- depcomp
- stamp-vti
- install-sh
- libtool-version
- mdate-sh
- missing

### Class/Module Index

Quicksearch

- FFI
- FFI::AutoPointer
- FFI::AutoPointer::CallableReleaser
- FFI::AutoPointer::DefaultReleaser
- FFI::AutoPointer::Releaser
- FFI::ConstGenerator
- FFI::ConstGenerator::Constant
- FFI::Enum
- FFI::Enums
- FFI::FunctionType
- FFI::Generator
- FFI::Generator::Task
- FFI::IO
- FFI::Library
- FFI::ManagedStruct
- FFI::NotFoundError
- FFI::Platform
- FFI::PlatformError
- FFI::Pointer
- FFI::StrPtrConverter
- FFI::Struct
- FFI::Struct::ManagedStructConverter
- FFI::StructGenerator
- FFI::StructGenerator::Field
- FFI::StructLayout
- FFI::StructLayout::Array
- FFI::StructLayout::Enum
- FFI::StructLayout::Field
- FFI::StructLayout::Function
- FFI::StructLayout::InnerStruct
- FFI::StructLayout::Mapped
- FFI::StructLayout::Number
- FFI::StructLayout::Pointer
- FFI::StructLayout::String
- FFI::StructLayoutBuilder
- FFI::TypesGenerator
- FFI::Union
- FFI::VariadicInvoker

No matching classes.

# FFI::VariadicInvoker

### Public Instance Methods

attach(mod, mname) click to toggle source

Attach the invoker to module `mod` as `mname`

    # File lib/ffi/variadic.rb, line 49
    def attach(mod, mname)
      invoker = self
      params = "*args"
      call = "call"
      mod.module_eval       @@#{mname} = invoker      def self.#{mname}(#{params})        @@#{mname}.#{call}(#{params})      end      def #{mname}(#{params})        @@#{mname}.#{call}(#{params})      end
      invoker
    end

call(*args, &block) click to toggle source

    # File lib/ffi/variadic.rb, line 31
    def call(*args, &block)
      param_types = Array.new(@fixed)
      param_values = Array.new
      @fixed.each_with_index do |t, i|
        param_values << args[i]
      end
      i = @fixed.length
      while i < args.length
        param_types << FFI.find_type(args[i], @type_map)
        param_values << args[i + 1]
        i += 2
      end
      invoke(param_types, param_values, &block)
    end

init(arg_types, type_map) click to toggle source

    # File lib/ffi/variadic.rb, line 22
    def init(arg_types, type_map)
      @fixed = Array.new
      @type_map = type_map
      arg_types.each_with_index do |type, i|
        @fixed << type unless type == Type::VARARGS
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.