lua-users home
lua-l archive

RE: lua_pcall

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


> lua_getglobal( l, "some_func" );
> lua_pushstring( l, "a" );
> lua_pushstring( l, "b" );
> 
> my_pcall();
> 
> But if my_pcall does stack manipulation in 
> order to retrieve the err_func, my values 
> are gonna be out of whack from what the called
> function is expecting?
That's what lua_insert is for. :-)
So that's roughly
int my_pcall(L, nargs, nresults)
{
 int err_func = lua_gettop(L) - (nargs + 1);
 ... get the error function on the top of the stack ...
 lua_insert(L, err_func);
 return lua_pcall(L, nargs, nresults, err_func);
}

AltStyle によって変換されたページ (->オリジナル) /