[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Number of results returned by lua_pcall?
- From: Antonio Vieiro <antonio@...>
- Date: Thu, 28 Jul 2011 14:03:01 +0200
Hi all,
I'm stuck with this problem. Maybe someone can shed some light here.
I have a C function 'myFunction' that in turn invokes any Lua function
'y'. I want my 'myFunction' to return the same results as 'y'.
Since I don't know how many return values 'y' is returning I'm using
LUA_MULTRET in lua_pcall, like so:
int myFunction(lua_State *L)
{
int result;
/* Prepare call to 'y' */
...
/* Call 'y' */
result = lua_pcall(L, 1, LUA_MULTRET ,0);
Now I can check for any errors, and I invoke "lua_error" if an error happens...
if (result != 0) {
lua_error(L);
Otherwise I wish to return the same number of results as 'y', but, how
do I know how many return values lua_pcall is returning?
} else {
return ??? /* What do I return here? */
}
}
Thanks in advance,
Antonio