Subject:
[ruby-ffi] Re: Array of double as an input argument of a function
From:
Wayne Meissner
Date:
3/18/11 4:07 PM
To:
ruby-ffi@googlegroups.com


You need to declare it as a :pointer, or :buffer_in argument, and then allocate some temporary memory yourself.

e.g.

module Foo
...
   attach_function :my_func, [ :pointer ], :void
end

ary = FFI::MemoryPointer.new(:double, 3)

# Fill the array with values
ary.write_array_of_double([ 0.1, 0.2, 0.3 ])

# pass it to the function
Foo.my_func(ary)