'cpcall' renamed to 'ccall' as it does not do a protected call

This commit is contained in:
Roberto Ierusalimschy 2010-03-19 18:04:17 -03:00
parent 62840c5fad
commit caf74dd731
3 changed files with 10 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/*
** $Id: lauxlib.c,v 1.202 2010/03/12 18:59:32 roberto Exp roberto $
** $Id: lauxlib.c,v 1.203 2010/03/17 21:37:37 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@ -789,7 +789,7 @@ LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) {
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_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_CCALL);
lua_insert(L, -nargs);
lua_pushlightuserdata(L, &f);
lua_insert(L, -nargs);

View File

@ -1,5 +1,5 @@
/*
** $Id: lstate.c,v 2.68 2009/12/22 15:32:50 roberto Exp roberto $
** $Id: lstate.c,v 2.69 2010/03/13 15:55:42 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@ -115,10 +115,10 @@ static void freestack (lua_State *L) {
** (Userdata cannot point directly to the function because pointer to
** function is not compatible with void*.)
*/
static int cpcall (lua_State *L) {
static int ccall (lua_State *L) {
lua_CFunction f = *(lua_CFunction *)lua_touserdata(L, 1);
lua_remove(L, 1); /* remove f from stack */
/* restore original environment for 'cpcall' */
/* restore original environment for 'ccall' */
lua_pushglobaltable(L);
lua_replace(L, LUA_ENVIRONINDEX);
return f(L);
@ -138,11 +138,11 @@ static void init_registry (lua_State *L, global_State *g) {
/* registry[LUA_RIDX_MAINTHREAD] = L */
setthvalue(L, &mt, L);
setobj2t(L, luaH_setint(L, registry, LUA_RIDX_MAINTHREAD), &mt);
/* registry[LUA_RIDX_CPCALL] = cpcall */
/* registry[LUA_RIDX_CCALL] = ccall */
cp = luaF_newCclosure(L, 0, g->l_gt);
cp->c.f = cpcall;
cp->c.f = ccall;
setclvalue(L, &mt, cp);
setobj2t(L, luaH_setint(L, registry, LUA_RIDX_CPCALL), &mt);
setobj2t(L, luaH_setint(L, registry, LUA_RIDX_CCALL), &mt);
/* registry[LUA_RIDX_GLOBALS] = l_gt */
sethvalue(L, &mt, g->l_gt);
setobj2t(L, luaH_setint(L, registry, LUA_RIDX_GLOBALS), &mt);

4
lua.h
View File

@ -1,5 +1,5 @@
/*
** $Id: lua.h,v 1.261 2010/01/11 17:15:11 roberto Exp roberto $
** $Id: lua.h,v 1.262 2010/03/13 03:57:46 roberto Exp roberto $
** Lua - A Scripting Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
@ -90,7 +90,7 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
/* predefined values in the registry */
#define LUA_RIDX_MAINTHREAD 1
#define LUA_RIDX_CPCALL 2
#define LUA_RIDX_CCALL 2
#define LUA_RIDX_GLOBALS 3
#define LUA_RIDX_LAST LUA_RIDX_GLOBALS