[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaJit / Passing array pointer - Declaration problem
- From: Mike Pall <mikelu-1103@...>
- Date: Thu, 17 Mar 2011 19:51:59 +0100
Peter Mulle wrote:
> I am trying to run this FFI libcall (linux).
local inReal = ffi.new("double", 1, 2, 3, 4, 5, 6, 7, 8, 9)
local outReal = ffi.new("double")
local outBegIdx = ffi.new("int")
local outNbElement = ffi.new("int")
local retVal = ta_lib.TA_RSI(0, 8, inReal, 1, outBegIdx, outNbElement, outReal)
> I was trying a simpler call too without any error but don't know
> how to access the the outReal array.
for i=0,8 do io.write(outReal[i], " ") end
> how to convert this cdata to a lua-table?
Well, you don't. You can use it like a table, so why convert it?
You can pass it around like any other Lua object, too.
If you really, really need to have a plain Lua table, then write a
loop to copy the values to a new table.
> Looked at the docu but can't make it working since I am just
> start working with Lua.
The LuaJIT FFI is a low-level library and is probably not so easy
to deal with, if you have little experience with Lua.
> Any advise or hint where I can crawl further?
I suggest to start with plain Lua first: http://www.lua.org/pil/