lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Peter Mulle wrote:
> I am trying to run this FFI libcall (linux).

local inReal ="double[9]", 1, 2, 3, 4, 5, 6, 7, 8, 9)
local outReal ="double[9]")
local outBegIdx ="int[1]")
local outNbElement ="int[1]")
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: