From f84b575cfa52dc832751846aa0b4c8ff437d3ca3 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 22 Dec 2009 13:32:50 -0200 Subject: no more pseudoindex LUA_GLOBALSINDEX; global table now accessible through registry --- lbaselib.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lbaselib.c') diff --git a/lbaselib.c b/lbaselib.c index 80b0039d..6e176990 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.232 2009/12/15 11:25:16 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.233 2009/12/17 16:20:01 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -23,7 +23,7 @@ static int luaB_print (lua_State *L) { int n = lua_gettop(L); /* number of arguments */ int i; - lua_getfield(L, LUA_GLOBALSINDEX, "tostring"); + lua_getfield(L, LUA_ENVIRONINDEX, "tostring"); for (i=1; i<=n; i++) { const char *s; size_t l; @@ -125,7 +125,7 @@ static void getfunc (lua_State *L, int opt) { static int luaB_getfenv (lua_State *L) { getfunc(L, 1); if (lua_iscfunction(L, -1)) /* is a C function? */ - lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the global env. */ + lua_pushglobaltable(L); /* return the global env. */ else lua_getfenv(L, -1); return 1; @@ -695,12 +695,12 @@ static void auxopen (lua_State *L, const char *name, static void base_open (lua_State *L) { /* set global _G */ - lua_pushvalue(L, LUA_GLOBALSINDEX); - lua_setfield(L, LUA_GLOBALSINDEX, "_G"); + lua_pushglobaltable(L); + lua_setfield(L, LUA_ENVIRONINDEX, "_G"); /* open lib into global table */ luaL_register(L, "_G", base_funcs); lua_pushliteral(L, LUA_VERSION); - lua_setfield(L, LUA_GLOBALSINDEX, "_VERSION"); /* set global _VERSION */ + lua_setfield(L, LUA_ENVIRONINDEX, "_VERSION"); /* set global _VERSION */ /* `ipairs' and `pairs' need auxiliary functions as upvalues */ auxopen(L, "ipairs", luaB_ipairs, ipairsaux); auxopen(L, "pairs", luaB_pairs, luaB_next); @@ -711,7 +711,7 @@ static void base_open (lua_State *L) { lua_pushliteral(L, "kv"); lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ lua_pushcclosure(L, luaB_newproxy, 1); - lua_setfield(L, LUA_GLOBALSINDEX, "newproxy"); /* set global `newproxy' */ + lua_setfield(L, LUA_ENVIRONINDEX, "newproxy"); /* set global `newproxy' */ } -- cgit v1.2.3-55-g6feb