aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/lbaselib.c b/lbaselib.c
index d93a170a..7c18548d 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.119 2003/02/13 16:07:37 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.120 2003/02/18 16:02:13 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -127,32 +127,32 @@ static void getfunc (lua_State *L) {
127} 127}
128 128
129 129
130static int aux_getglobals (lua_State *L) { 130static int aux_getenvtable (lua_State *L) {
131 lua_getglobals(L, -1); 131 lua_getenvtable(L, -1);
132 lua_pushliteral(L, "__globals"); 132 lua_pushliteral(L, "__globals");
133 lua_rawget(L, -2); 133 lua_rawget(L, -2);
134 return !lua_isnil(L, -1); 134 return !lua_isnil(L, -1);
135} 135}
136 136
137 137
138static int luaB_getglobals (lua_State *L) { 138static int luaB_getenvtable (lua_State *L) {
139 getfunc(L); 139 getfunc(L);
140 if (!aux_getglobals(L)) /* __globals not defined? */ 140 if (!aux_getenvtable(L)) /* __globals not defined? */
141 lua_pop(L, 1); /* remove it, to return real globals */ 141 lua_pop(L, 1); /* remove it, to return real environment */
142 return 1; 142 return 1;
143} 143}
144 144
145 145
146static int luaB_setglobals (lua_State *L) { 146static int luaB_setenvtable (lua_State *L) {
147 luaL_checktype(L, 2, LUA_TTABLE); 147 luaL_checktype(L, 2, LUA_TTABLE);
148 getfunc(L); 148 getfunc(L);
149 if (aux_getglobals(L)) /* __globals defined? */ 149 if (aux_getenvtable(L)) /* __globals defined? */
150 luaL_error(L, "cannot change a protected global table"); 150 luaL_error(L, "cannot change a protected global table");
151 else 151 else
152 lua_pop(L, 2); /* remove __globals and real global table */ 152 lua_pop(L, 2); /* remove __globals and real environment table */
153 lua_pushvalue(L, 2); 153 lua_pushvalue(L, 2);
154 if (lua_setglobals(L, -2) == 0) 154 if (lua_setenvtable(L, -2) == 0)
155 luaL_error(L, "cannot change global table of given function"); 155 luaL_error(L, "cannot change environment of given function");
156 return 0; 156 return 0;
157} 157}
158 158
@@ -247,8 +247,8 @@ static int load_aux (lua_State *L, int status) {
247 lua_Debug ar; 247 lua_Debug ar;
248 lua_getstack(L, 1, &ar); 248 lua_getstack(L, 1, &ar);
249 lua_getinfo(L, "f", &ar); /* get calling function */ 249 lua_getinfo(L, "f", &ar); /* get calling function */
250 lua_getglobals(L, -1); /* get its global table */ 250 lua_getenvtable(L, -1); /* get its environment */
251 lua_setglobals(L, -3); /* set it as the global table of the new chunk */ 251 lua_setenvtable(L, -3); /* set it as the environment of the new chunk */
252 lua_pop(L, 1); /* remove calling function */ 252 lua_pop(L, 1); /* remove calling function */
253 return 1; 253 return 1;
254 } 254 }
@@ -494,8 +494,8 @@ static const luaL_reg base_funcs[] = {
494 {"error", luaB_error}, 494 {"error", luaB_error},
495 {"getmetatable", luaB_getmetatable}, 495 {"getmetatable", luaB_getmetatable},
496 {"setmetatable", luaB_setmetatable}, 496 {"setmetatable", luaB_setmetatable},
497 {"getglobals", luaB_getglobals}, 497 {"getenvtable", luaB_getenvtable},
498 {"setglobals", luaB_setglobals}, 498 {"setenvtable", luaB_setenvtable},
499 {"next", luaB_next}, 499 {"next", luaB_next},
500 {"ipairs", luaB_ipairs}, 500 {"ipairs", luaB_ipairs},
501 {"pairs", luaB_pairs}, 501 {"pairs", luaB_pairs},