|great! thanks mike.|
now it's running fast and smooth.
didn't knew I can access the array via loop this way.
very nice to see such a responsive community.
thx again mike
--- Mike Pall <firstname.lastname@example.org> schrieb am Do, 17.3.2011:
Von: Mike Pall <email@example.com>
Betreff: Re: LuaJit / Passing array pointer - Declaration problem
An: "Lua mailing list" <firstname.lastname@example.org>
Datum: Donnerstag, 17. März, 2011 18:51 Uhr
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")
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/