diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-18 13:13:15 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-18 13:13:15 -0300 |
commit | 9866fb0ef1bd40afe47dd2cffdea5e66f9c048c1 (patch) | |
tree | 23746ca83bf7b11d623b730028fb7364a76e9556 | |
parent | 60c83ded3080a23bc661ab440c36d0a71b399e2e (diff) | |
download | lua-9866fb0ef1bd40afe47dd2cffdea5e66f9c048c1.tar.gz lua-9866fb0ef1bd40afe47dd2cffdea5e66f9c048c1.tar.bz2 lua-9866fb0ef1bd40afe47dd2cffdea5e66f9c048c1.zip |
`set/getglobals' -> `set/getenvtable'
-rw-r--r-- | lapi.c | 6 | ||||
-rw-r--r-- | lbaselib.c | 30 | ||||
-rw-r--r-- | lua.h | 6 |
3 files changed, 21 insertions, 21 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.227 2002/12/19 11:11:55 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.228 2003/02/11 10:46:24 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -542,7 +542,7 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) { | |||
542 | } | 542 | } |
543 | 543 | ||
544 | 544 | ||
545 | LUA_API void lua_getglobals (lua_State *L, int index) { | 545 | LUA_API void lua_getenvtable (lua_State *L, int index) { |
546 | StkId o; | 546 | StkId o; |
547 | lua_lock(L); | 547 | lua_lock(L); |
548 | o = luaA_index(L, index); | 548 | o = luaA_index(L, index); |
@@ -620,7 +620,7 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { | |||
620 | } | 620 | } |
621 | 621 | ||
622 | 622 | ||
623 | LUA_API int lua_setglobals (lua_State *L, int index) { | 623 | LUA_API int lua_setenvtable (lua_State *L, int index) { |
624 | StkId o; | 624 | StkId o; |
625 | int res = 0; | 625 | int res = 0; |
626 | lua_lock(L); | 626 | lua_lock(L); |
@@ -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 | ||
130 | static int aux_getglobals (lua_State *L) { | 130 | static 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 | ||
138 | static int luaB_getglobals (lua_State *L) { | 138 | static 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 | ||
146 | static int luaB_setglobals (lua_State *L) { | 146 | static 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}, |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.170 2002/12/19 11:11:55 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.171 2003/02/18 16:01:57 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil | 4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil |
5 | ** http://www.lua.org mailto:info@lua.org | 5 | ** http://www.lua.org mailto:info@lua.org |
@@ -168,7 +168,7 @@ LUA_API void lua_rawget (lua_State *L, int idx); | |||
168 | LUA_API void lua_rawgeti (lua_State *L, int idx, int n); | 168 | LUA_API void lua_rawgeti (lua_State *L, int idx, int n); |
169 | LUA_API void lua_newtable (lua_State *L); | 169 | LUA_API void lua_newtable (lua_State *L); |
170 | LUA_API int lua_getmetatable (lua_State *L, int objindex); | 170 | LUA_API int lua_getmetatable (lua_State *L, int objindex); |
171 | LUA_API void lua_getglobals (lua_State *L, int idx); | 171 | LUA_API void lua_getenvtable (lua_State *L, int idx); |
172 | 172 | ||
173 | 173 | ||
174 | /* | 174 | /* |
@@ -178,7 +178,7 @@ LUA_API void lua_settable (lua_State *L, int idx); | |||
178 | LUA_API void lua_rawset (lua_State *L, int idx); | 178 | LUA_API void lua_rawset (lua_State *L, int idx); |
179 | LUA_API void lua_rawseti (lua_State *L, int idx, int n); | 179 | LUA_API void lua_rawseti (lua_State *L, int idx, int n); |
180 | LUA_API int lua_setmetatable (lua_State *L, int objindex); | 180 | LUA_API int lua_setmetatable (lua_State *L, int objindex); |
181 | LUA_API int lua_setglobals (lua_State *L, int idx); | 181 | LUA_API int lua_setenvtable (lua_State *L, int idx); |
182 | 182 | ||
183 | 183 | ||
184 | /* | 184 | /* |