aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-12-11 11:40:44 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-12-11 11:40:44 -0200
commit2e5179259655ffd137067f5dc47803740b7937ac (patch)
tree8d103b047f96fc93d77c9abd6c94458e8f9e5a7e
parent3a9ae612a4982e5f543baf8eead0889369eb8260 (diff)
downloadlua-2e5179259655ffd137067f5dc47803740b7937ac.tar.gz
lua-2e5179259655ffd137067f5dc47803740b7937ac.tar.bz2
lua-2e5179259655ffd137067f5dc47803740b7937ac.zip
avoid using deprecated macros lua_[gs]etglobal
-rw-r--r--lbaselib.c10
-rw-r--r--linit.c4
-rw-r--r--lua.c8
-rw-r--r--lua.h5
4 files changed, 14 insertions, 13 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 15bab389..d5596d1f 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.229 2009/11/27 15:38:51 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.230 2009/12/10 18:17:37 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*/
@@ -23,7 +23,7 @@
23static int luaB_print (lua_State *L) { 23static int luaB_print (lua_State *L) {
24 int n = lua_gettop(L); /* number of arguments */ 24 int n = lua_gettop(L); /* number of arguments */
25 int i; 25 int i;
26 lua_getglobal(L, "tostring"); 26 lua_getfield(L, LUA_GLOBALSINDEX, "tostring");
27 for (i=1; i<=n; i++) { 27 for (i=1; i<=n; i++) {
28 const char *s; 28 const char *s;
29 size_t l; 29 size_t l;
@@ -695,11 +695,11 @@ static void auxopen (lua_State *L, const char *name,
695static void base_open (lua_State *L) { 695static void base_open (lua_State *L) {
696 /* set global _G */ 696 /* set global _G */
697 lua_pushvalue(L, LUA_GLOBALSINDEX); 697 lua_pushvalue(L, LUA_GLOBALSINDEX);
698 lua_setglobal(L, "_G"); 698 lua_setfield(L, LUA_GLOBALSINDEX, "_G");
699 /* open lib into global table */ 699 /* open lib into global table */
700 luaL_register(L, "_G", base_funcs); 700 luaL_register(L, "_G", base_funcs);
701 lua_pushliteral(L, LUA_VERSION); 701 lua_pushliteral(L, LUA_VERSION);
702 lua_setglobal(L, "_VERSION"); /* set global _VERSION */ 702 lua_setfield(L, LUA_GLOBALSINDEX, "_VERSION"); /* set global _VERSION */
703 /* `ipairs' and `pairs' need auxiliary functions as upvalues */ 703 /* `ipairs' and `pairs' need auxiliary functions as upvalues */
704 auxopen(L, "ipairs", luaB_ipairs, ipairsaux); 704 auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
705 auxopen(L, "pairs", luaB_pairs, luaB_next); 705 auxopen(L, "pairs", luaB_pairs, luaB_next);
@@ -710,7 +710,7 @@ static void base_open (lua_State *L) {
710 lua_pushliteral(L, "kv"); 710 lua_pushliteral(L, "kv");
711 lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ 711 lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */
712 lua_pushcclosure(L, luaB_newproxy, 1); 712 lua_pushcclosure(L, luaB_newproxy, 1);
713 lua_setglobal(L, "newproxy"); /* set global `newproxy' */ 713 lua_setfield(L, LUA_GLOBALSINDEX, "newproxy"); /* set global `newproxy' */
714} 714}
715 715
716 716
diff --git a/linit.c b/linit.c
index 7623b556..cb194d11 100644
--- a/linit.c
+++ b/linit.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: linit.c,v 1.19 2009/07/01 16:16:40 roberto Exp roberto $ 2** $Id: linit.c,v 1.20 2009/09/05 12:39:29 roberto Exp roberto $
3** Initialization of libraries for lua.c and other clients 3** Initialization of libraries for lua.c and other clients
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -64,7 +64,7 @@ LUALIB_API void luaL_openlibs (lua_State *L) {
64 } 64 }
65 lua_pop(L, 1); /* remove package.preload table */ 65 lua_pop(L, 1); /* remove package.preload table */
66#ifdef LUA_COMPAT_DEBUGLIB 66#ifdef LUA_COMPAT_DEBUGLIB
67 lua_getglobal(L, "require"); 67 lua_getfield(L, LUA_GLOBALSINDEX, "require");
68 lua_pushliteral(L, LUA_DBLIBNAME); 68 lua_pushliteral(L, LUA_DBLIBNAME);
69 lua_call(L, 1, 0); /* call 'require"debug"' */ 69 lua_call(L, 1, 0); /* call 'require"debug"' */
70#endif 70#endif
diff --git a/lua.c b/lua.c
index e1084f3b..071bc5b9 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.175 2009/08/10 16:23:19 roberto Exp roberto $ 2** $Id: lua.c,v 1.176 2009/11/24 18:05:12 roberto Exp roberto $
3** Lua stand-alone interpreter 3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -151,7 +151,7 @@ static int dostring (lua_State *L, const char *s, const char *name) {
151 151
152 152
153static int dolibrary (lua_State *L, const char *name) { 153static int dolibrary (lua_State *L, const char *name) {
154 lua_getglobal(L, "require"); 154 lua_getfield(L, LUA_GLOBALSINDEX, "require");
155 lua_pushstring(L, name); 155 lua_pushstring(L, name);
156 return report(L, docall(L, 1, 1)); 156 return report(L, docall(L, 1, 1));
157} 157}
@@ -231,7 +231,7 @@ static void dotty (lua_State *L) {
231 report(L, status); 231 report(L, status);
232 if (status == LUA_OK && lua_gettop(L) > 0) { /* any result to print? */ 232 if (status == LUA_OK && lua_gettop(L) > 0) { /* any result to print? */
233 luaL_checkstack(L, LUA_MINSTACK, "too many results to print"); 233 luaL_checkstack(L, LUA_MINSTACK, "too many results to print");
234 lua_getglobal(L, "print"); 234 lua_getfield(L, LUA_GLOBALSINDEX, "print");
235 lua_insert(L, 1); 235 lua_insert(L, 1);
236 if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != LUA_OK) 236 if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != LUA_OK)
237 l_message(progname, lua_pushfstring(L, 237 l_message(progname, lua_pushfstring(L,
@@ -250,7 +250,7 @@ static int handle_script (lua_State *L, char **argv, int n) {
250 int status; 250 int status;
251 const char *fname; 251 const char *fname;
252 int narg = getargs(L, argv, n); /* collect arguments */ 252 int narg = getargs(L, argv, n); /* collect arguments */
253 lua_setglobal(L, "arg"); 253 lua_setfield(L, LUA_GLOBALSINDEX, "arg");
254 fname = argv[n]; 254 fname = argv[n];
255 if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) 255 if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0)
256 fname = NULL; /* stdin */ 256 fname = NULL; /* stdin */
diff --git a/lua.h b/lua.h
index ead8422b..9cf92660 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.251 2009/11/25 15:27:51 roberto Exp roberto $ 2** $Id: lua.h,v 1.252 2009/11/26 11:39:20 roberto Exp roberto $
3** Lua - A Scripting Language 3** Lua - A Scripting Language
4** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 4** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
5** See Copyright Notice at the end of this file 5** See Copyright Notice at the end of this file
@@ -297,7 +297,8 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
297 297
298#define lua_newtable(L) lua_createtable(L, 0, 0) 298#define lua_newtable(L) lua_createtable(L, 0, 0)
299 299
300#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) 300#define lua_register(L,n,f) \
301 (lua_pushcfunction(L, (f)), lua_setfield(L, LUA_GLOBALSINDEX, (n)))
301 302
302#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) 303#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
303 304