diff options
-rw-r--r-- | lauxlib.c | 6 | ||||
-rw-r--r-- | lbaselib.c | 6 | ||||
-rw-r--r-- | ldblib.c | 4 | ||||
-rw-r--r-- | lmathlib.c | 4 | ||||
-rw-r--r-- | ltests.c | 3 | ||||
-rw-r--r-- | lua.h | 7 |
6 files changed, 16 insertions, 14 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.106 2003/10/10 12:57:55 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.107 2003/10/20 18:32:55 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -238,13 +238,13 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, | |||
238 | const luaL_reg *l, int nup) { | 238 | const luaL_reg *l, int nup) { |
239 | if (libname) { | 239 | if (libname) { |
240 | /* check whether lib already exists */ | 240 | /* check whether lib already exists */ |
241 | lua_getfield(L, LUA_GLOBALSINDEX, libname); | 241 | lua_getglobal(L, libname); |
242 | if (lua_isnil(L, -1)) { /* no? */ | 242 | if (lua_isnil(L, -1)) { /* no? */ |
243 | lua_pop(L, 1); | 243 | lua_pop(L, 1); |
244 | lua_newtable(L); /* create it */ | 244 | lua_newtable(L); /* create it */ |
245 | lua_pushvalue(L, -1); | 245 | lua_pushvalue(L, -1); |
246 | /* register it with given name */ | 246 | /* register it with given name */ |
247 | lua_setfield(L, LUA_GLOBALSINDEX, libname); | 247 | lua_setglobal(L, libname); |
248 | } | 248 | } |
249 | lua_insert(L, -(nup+1)); /* move library table to below upvalues */ | 249 | lua_insert(L, -(nup+1)); /* move library table to below upvalues */ |
250 | } | 250 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.135 2003/10/10 12:57:55 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.136 2003/10/23 18:06:22 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 | */ |
@@ -218,7 +218,7 @@ static int luaB_next (lua_State *L) { | |||
218 | 218 | ||
219 | static int luaB_pairs (lua_State *L) { | 219 | static int luaB_pairs (lua_State *L) { |
220 | luaL_checktype(L, 1, LUA_TTABLE); | 220 | luaL_checktype(L, 1, LUA_TTABLE); |
221 | lua_getfield(L, LUA_GLOBALSINDEX, "next"); /* return generator, */ | 221 | lua_getglobal(L, "next"); /* return generator, */ |
222 | lua_pushvalue(L, 1); /* state, */ | 222 | lua_pushvalue(L, 1); /* state, */ |
223 | lua_pushnil(L); /* and initial value */ | 223 | lua_pushnil(L); /* and initial value */ |
224 | return 3; | 224 | return 3; |
@@ -229,7 +229,7 @@ static int luaB_ipairs (lua_State *L) { | |||
229 | int i = (int)lua_tointeger(L, 2); | 229 | int i = (int)lua_tointeger(L, 2); |
230 | luaL_checktype(L, 1, LUA_TTABLE); | 230 | luaL_checktype(L, 1, LUA_TTABLE); |
231 | if (i == 0 && lua_isnone(L, 2)) { /* `for' start? */ | 231 | if (i == 0 && lua_isnone(L, 2)) { /* `for' start? */ |
232 | lua_getfield(L, LUA_GLOBALSINDEX, "ipairs"); /* return generator, */ | 232 | lua_getglobal(L, "ipairs"); /* return generator, */ |
233 | lua_pushvalue(L, 1); /* state, */ | 233 | lua_pushvalue(L, 1); /* state, */ |
234 | lua_pushinteger(L, 0); /* and initial value */ | 234 | lua_pushinteger(L, 0); /* and initial value */ |
235 | return 3; | 235 | return 3; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.82 2003/10/07 20:13:41 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.83 2003/10/10 12:57:55 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -339,7 +339,7 @@ static const luaL_reg dblib[] = { | |||
339 | LUALIB_API int luaopen_debug (lua_State *L) { | 339 | LUALIB_API int luaopen_debug (lua_State *L) { |
340 | luaL_openlib(L, LUA_DBLIBNAME, dblib, 0); | 340 | luaL_openlib(L, LUA_DBLIBNAME, dblib, 0); |
341 | lua_pushcfunction(L, errorfb); | 341 | lua_pushcfunction(L, errorfb); |
342 | lua_setfield(L, LUA_GLOBALSINDEX, "_TRACEBACK"); | 342 | lua_setglobal(L, "_TRACEBACK"); |
343 | return 1; | 343 | return 1; |
344 | } | 344 | } |
345 | 345 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.57 2003/10/07 20:13:41 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.58 2003/10/10 12:57:55 roberto Exp roberto $ |
3 | ** Standard mathematical library | 3 | ** Standard mathematical library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -238,7 +238,7 @@ LUALIB_API int luaopen_math (lua_State *L) { | |||
238 | lua_pushnumber(L, PI); | 238 | lua_pushnumber(L, PI); |
239 | lua_setfield(L, -2, "pi"); | 239 | lua_setfield(L, -2, "pi"); |
240 | lua_pushcfunction(L, math_pow); | 240 | lua_pushcfunction(L, math_pow); |
241 | lua_setfield(L, LUA_GLOBALSINDEX, "__pow"); | 241 | lua_setglobal(L, "__pow"); |
242 | return 1; | 242 | return 1; |
243 | } | 243 | } |
244 | 244 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.166 2003/10/10 13:29:08 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.167 2003/10/20 12:25:23 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -241,6 +241,7 @@ static int get_limits (lua_State *L) { | |||
241 | setnameval(L, "MAXVARS", MAXVARS); | 241 | setnameval(L, "MAXVARS", MAXVARS); |
242 | setnameval(L, "MAXSTACK", MAXSTACK); | 242 | setnameval(L, "MAXSTACK", MAXSTACK); |
243 | setnameval(L, "MAXUPVALUES", MAXUPVALUES); | 243 | setnameval(L, "MAXUPVALUES", MAXUPVALUES); |
244 | setnameval(L, "NUM_OPCODES", NUM_OPCODES); | ||
244 | return 1; | 245 | return 1; |
245 | } | 246 | } |
246 | 247 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.183 2003/10/20 12:25:23 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.184 2003/10/21 10:58:58 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 |
@@ -277,6 +277,9 @@ LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud); | |||
277 | #define lua_pushliteral(L, s) \ | 277 | #define lua_pushliteral(L, s) \ |
278 | lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) | 278 | lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) |
279 | 279 | ||
280 | #define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, s) | ||
281 | #define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, s) | ||
282 | |||
280 | 283 | ||
281 | 284 | ||
282 | /* | 285 | /* |
@@ -286,8 +289,6 @@ LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud); | |||
286 | #define lua_open() luaL_newstate() | 289 | #define lua_open() luaL_newstate() |
287 | 290 | ||
288 | #define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) | 291 | #define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) |
289 | #define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, s) | ||
290 | #define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, s) | ||
291 | 292 | ||
292 | 293 | ||
293 | /* compatibility with ref system */ | 294 | /* compatibility with ref system */ |