Sha256: c11f625b5b4dbbe392cb805cdeb0017f475538612b829ac087007ff1c922ffb2

Contents?: true

Size: 664 Bytes

Versions: 14

Compression:

Stored size: 664 Bytes

Contents

module FFI
  class VariadicInvoker    
    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 == FFI::NativeType::VARARGS
      end
    end
    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
  end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
ffi-ffi-0.5.0 lib/ffi/variadic.rb
remogatto-ffi-0.5.0 lib/ffi/variadic.rb
ffi-0.5.4-x86-mswin32 lib/ffi/variadic.rb
ffi-0.5.4-x86-mingw32 lib/ffi/variadic.rb
ffi-0.5.4 lib/ffi/variadic.rb
ffi-0.5.3-x86-mswin32 lib/ffi/variadic.rb
ffi-0.5.3 lib/ffi/variadic.rb
ffi-0.5.3-x86-mingw32 lib/ffi/variadic.rb
ffi-0.5.1-x86-mswin32 lib/ffi/variadic.rb
ffi-0.5.1 lib/ffi/variadic.rb
ffi-0.5.1-x86-mingw32 lib/ffi/variadic.rb
ffi-0.5.0-x86-mswin32 lib/ffi/variadic.rb
ffi-0.5.0-x86-mingw32 lib/ffi/variadic.rb
ffi-0.5.0 lib/ffi/variadic.rb