`set/getenvtable' -> `set/getfenv'

This commit is contained in:
Roberto Ierusalimschy 2003-02-24 13:54:20 -03:00
parent 07e210e655
commit 5cd99b82b7
3 changed files with 18 additions and 18 deletions

6
lapi.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 1.229 2003/02/18 16:13:15 roberto Exp roberto $
** $Id: lapi.c,v 1.230 2003/02/20 19:33:23 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@ -542,7 +542,7 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) {
}
LUA_API void lua_getenvtable (lua_State *L, int index) {
LUA_API void lua_getfenv (lua_State *L, int index) {
StkId o;
lua_lock(L);
o = luaA_index(L, index);
@ -620,7 +620,7 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
}
LUA_API int lua_setenvtable (lua_State *L, int index) {
LUA_API int lua_setfenv (lua_State *L, int index) {
StkId o;
int res = 0;
lua_lock(L);

View File

@ -1,5 +1,5 @@
/*
** $Id: lbaselib.c,v 1.121 2003/02/18 16:13:15 roberto Exp roberto $
** $Id: lbaselib.c,v 1.122 2003/02/24 16:50:41 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
@ -127,31 +127,31 @@ static void getfunc (lua_State *L) {
}
static int aux_getenvtable (lua_State *L) {
lua_getenvtable(L, -1);
static int aux_getfenv (lua_State *L) {
lua_getfenv(L, -1);
lua_pushliteral(L, "__globals");
lua_rawget(L, -2);
return !lua_isnil(L, -1);
}
static int luaB_getenvtable (lua_State *L) {
static int luaB_getfenv (lua_State *L) {
getfunc(L);
if (!aux_getenvtable(L)) /* __globals not defined? */
if (!aux_getfenv(L)) /* __globals not defined? */
lua_pop(L, 1); /* remove it, to return real environment */
return 1;
}
static int luaB_setenvtable (lua_State *L) {
static int luaB_setfenv (lua_State *L) {
luaL_checktype(L, 2, LUA_TTABLE);
getfunc(L);
if (aux_getenvtable(L)) /* __globals defined? */
if (aux_getfenv(L)) /* __globals defined? */
luaL_error(L, "cannot change a protected global table");
else
lua_pop(L, 2); /* remove __globals and real environment table */
lua_pushvalue(L, 2);
if (lua_setenvtable(L, -2) == 0)
if (lua_setfenv(L, -2) == 0)
luaL_error(L, "cannot change environment of given function");
return 0;
}
@ -247,8 +247,8 @@ static int load_aux (lua_State *L, int status) {
lua_Debug ar;
lua_getstack(L, 1, &ar);
lua_getinfo(L, "f", &ar); /* get calling function */
lua_getenvtable(L, -1); /* get its environment */
lua_setenvtable(L, -3); /* set it as the environment of the new chunk */
lua_getfenv(L, -1); /* get its environment */
lua_setfenv(L, -3); /* set it as the environment of the new chunk */
lua_pop(L, 1); /* remove calling function */
return 1;
}
@ -499,8 +499,8 @@ static const luaL_reg base_funcs[] = {
{"error", luaB_error},
{"getmetatable", luaB_getmetatable},
{"setmetatable", luaB_setmetatable},
{"getenvtable", luaB_getenvtable},
{"setenvtable", luaB_setenvtable},
{"getfenv", luaB_getfenv},
{"setfenv", luaB_setfenv},
{"next", luaB_next},
{"ipairs", luaB_ipairs},
{"pairs", luaB_pairs},

6
lua.h
View File

@ -1,5 +1,5 @@
/*
** $Id: lua.h,v 1.171 2003/02/18 16:01:57 roberto Exp roberto $
** $Id: lua.h,v 1.172 2003/02/18 16:13:15 roberto Exp roberto $
** Lua - An Extensible Extension Language
** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
** http://www.lua.org mailto:info@lua.org
@ -168,7 +168,7 @@ LUA_API void lua_rawget (lua_State *L, int idx);
LUA_API void lua_rawgeti (lua_State *L, int idx, int n);
LUA_API void lua_newtable (lua_State *L);
LUA_API int lua_getmetatable (lua_State *L, int objindex);
LUA_API void lua_getenvtable (lua_State *L, int idx);
LUA_API void lua_getfenv (lua_State *L, int idx);
/*
@ -178,7 +178,7 @@ LUA_API void lua_settable (lua_State *L, int idx);
LUA_API void lua_rawset (lua_State *L, int idx);
LUA_API void lua_rawseti (lua_State *L, int idx, int n);
LUA_API int lua_setmetatable (lua_State *L, int objindex);
LUA_API int lua_setenvtable (lua_State *L, int idx);
LUA_API int lua_setfenv (lua_State *L, int idx);
/*