summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-11-05 09:59:14 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-11-05 09:59:14 -0200
commitfa198197a0202bd3a7b68d228cd1c2fd88166ff7 (patch)
tree536f37e38fb5e80fa580c42f2d09d6e10410e075
parent1e944de6cb6a20f6abeaab6f5d1039d06d8d2812 (diff)
downloadlua-github-fa198197a0202bd3a7b68d228cd1c2fd88166ff7.tar.gz
lua_(set)getglobal are ok to use
-rw-r--r--lauxlib.c6
-rw-r--r--lbaselib.c6
-rw-r--r--ldblib.c4
-rw-r--r--lmathlib.c4
-rw-r--r--ltests.c3
-rw-r--r--lua.h7
6 files changed, 16 insertions, 14 deletions
diff --git a/lauxlib.c b/lauxlib.c
index d441f4fe..8dff62d9 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.c,v 1.106 2003/10/10 12:57:55 roberto Exp roberto $
+** $Id: lauxlib.c,v 1.107 2003/10/20 18:32:55 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -238,13 +238,13 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname,
const luaL_reg *l, int nup) {
if (libname) {
/* check whether lib already exists */
- lua_getfield(L, LUA_GLOBALSINDEX, libname);
+ lua_getglobal(L, libname);
if (lua_isnil(L, -1)) { /* no? */
lua_pop(L, 1);
lua_newtable(L); /* create it */
lua_pushvalue(L, -1);
/* register it with given name */
- lua_setfield(L, LUA_GLOBALSINDEX, libname);
+ lua_setglobal(L, libname);
}
lua_insert(L, -(nup+1)); /* move library table to below upvalues */
}
diff --git a/lbaselib.c b/lbaselib.c
index 2e04a9a4..262e80ca 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbaselib.c,v 1.135 2003/10/10 12:57:55 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.136 2003/10/23 18:06:22 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -218,7 +218,7 @@ static int luaB_next (lua_State *L) {
static int luaB_pairs (lua_State *L) {
luaL_checktype(L, 1, LUA_TTABLE);
- lua_getfield(L, LUA_GLOBALSINDEX, "next"); /* return generator, */
+ lua_getglobal(L, "next"); /* return generator, */
lua_pushvalue(L, 1); /* state, */
lua_pushnil(L); /* and initial value */
return 3;
@@ -229,7 +229,7 @@ static int luaB_ipairs (lua_State *L) {
int i = (int)lua_tointeger(L, 2);
luaL_checktype(L, 1, LUA_TTABLE);
if (i == 0 && lua_isnone(L, 2)) { /* `for' start? */
- lua_getfield(L, LUA_GLOBALSINDEX, "ipairs"); /* return generator, */
+ lua_getglobal(L, "ipairs"); /* return generator, */
lua_pushvalue(L, 1); /* state, */
lua_pushinteger(L, 0); /* and initial value */
return 3;
diff --git a/ldblib.c b/ldblib.c
index 440b4a9c..fb2ebd6d 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldblib.c,v 1.82 2003/10/07 20:13:41 roberto Exp roberto $
+** $Id: ldblib.c,v 1.83 2003/10/10 12:57:55 roberto Exp roberto $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@@ -339,7 +339,7 @@ static const luaL_reg dblib[] = {
LUALIB_API int luaopen_debug (lua_State *L) {
luaL_openlib(L, LUA_DBLIBNAME, dblib, 0);
lua_pushcfunction(L, errorfb);
- lua_setfield(L, LUA_GLOBALSINDEX, "_TRACEBACK");
+ lua_setglobal(L, "_TRACEBACK");
return 1;
}
diff --git a/lmathlib.c b/lmathlib.c
index c9397376..5c060218 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.57 2003/10/07 20:13:41 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.58 2003/10/10 12:57:55 roberto Exp roberto $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
@@ -238,7 +238,7 @@ LUALIB_API int luaopen_math (lua_State *L) {
lua_pushnumber(L, PI);
lua_setfield(L, -2, "pi");
lua_pushcfunction(L, math_pow);
- lua_setfield(L, LUA_GLOBALSINDEX, "__pow");
+ lua_setglobal(L, "__pow");
return 1;
}
diff --git a/ltests.c b/ltests.c
index 4d8a60f4..ead3d86e 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltests.c,v 1.166 2003/10/10 13:29:08 roberto Exp roberto $
+** $Id: ltests.c,v 1.167 2003/10/20 12:25:23 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
@@ -241,6 +241,7 @@ static int get_limits (lua_State *L) {
setnameval(L, "MAXVARS", MAXVARS);
setnameval(L, "MAXSTACK", MAXSTACK);
setnameval(L, "MAXUPVALUES", MAXUPVALUES);
+ setnameval(L, "NUM_OPCODES", NUM_OPCODES);
return 1;
}
diff --git a/lua.h b/lua.h
index efd633c5..319d5d06 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.183 2003/10/20 12:25:23 roberto Exp roberto $
+** $Id: lua.h,v 1.184 2003/10/21 10:58:58 roberto Exp roberto $
** Lua - An Extensible Extension Language
** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
** http://www.lua.org mailto:info@lua.org
@@ -277,6 +277,9 @@ LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud);
#define lua_pushliteral(L, s) \
lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
+#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, s)
+#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, s)
+
/*
@@ -286,8 +289,6 @@ LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud);
#define lua_open() luaL_newstate()
#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX)
-#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, s)
-#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, s)
/* compatibility with ref system */