new function 'luaL_cpcall'
This commit is contained in:
13
lauxlib.c
13
lauxlib.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lauxlib.c,v 1.195 2009/12/17 16:20:01 roberto Exp roberto $
|
||||
** $Id: lauxlib.c,v 1.196 2009/12/22 15:32:50 roberto Exp roberto $
|
||||
** Auxiliary functions for building Lua libraries
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -773,3 +773,14 @@ LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) {
|
||||
ver, *v);
|
||||
}
|
||||
|
||||
|
||||
LUALIB_API int luaL_cpcall (lua_State *L, lua_CFunction f, int nargs,
|
||||
int nresults) {
|
||||
nargs++; /* to include function itself */
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_CPCALL);
|
||||
lua_insert(L, -nargs);
|
||||
lua_pushlightuserdata(L, &f);
|
||||
lua_insert(L, -nargs);
|
||||
return lua_pcall(L, nargs, nresults, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user