[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: how to get count of result when lua_call(L, argnums, LUA_MULTRET)?
- From: "Samuel Chi" <princeofdatamining@...>
- Date: Wed, 14 Mar 2007 18:06:11 +0800
example for lua_call in lua-manual.html :
Lua code:
a = f("how", t.x, 14)
C:
lua_getfield(L, LUA_GLOBALSINDEX, "f"); /* function to be called */
lua_pushstring(L, "how"); /* 1st argument */
lua_getfield(L, LUA_GLOBALSINDEX, "t"); /* table to be indexed */
lua_getfield(L, -1, "x"); /* push result of t.x (2nd arg) */
lua_remove(L, -2); /* remove 't' from the stack */
lua_pushinteger(L, 14); /* 3rd argument */
lua_call(L, 3, 1); /* call function with 3 arguments and1 result */
lua_setfield(L, LUA_GLOBALSINDEX, "a"); /* set global variable 'a' */
----->
lua_call(L, 3, LUA_MULTRET);
// how to get count of result?