aboutsummaryrefslogtreecommitdiff
path: root/lua.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-12-22 13:32:50 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-12-22 13:32:50 -0200
commitf84b575cfa52dc832751846aa0b4c8ff437d3ca3 (patch)
tree246ef484b08d132d006c16a6c8cbe55e61c3bfce /lua.h
parent3cb343efd644fb771b6d8193406afd49527dc1ec (diff)
downloadlua-f84b575cfa52dc832751846aa0b4c8ff437d3ca3.tar.gz
lua-f84b575cfa52dc832751846aa0b4c8ff437d3ca3.tar.bz2
lua-f84b575cfa52dc832751846aa0b4c8ff437d3ca3.zip
no more pseudoindex LUA_GLOBALSINDEX; global table now accessible
through registry
Diffstat (limited to 'lua.h')
-rw-r--r--lua.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/lua.h b/lua.h
index 39b1601c..63bcf922 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.254 2009/12/17 16:20:01 roberto Exp roberto $ 2** $Id: lua.h,v 1.255 2009/12/18 15:32:36 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
@@ -35,8 +35,7 @@
35*/ 35*/
36#define LUA_REGISTRYINDEX LUAI_FIRSTPSEUDOIDX 36#define LUA_REGISTRYINDEX LUAI_FIRSTPSEUDOIDX
37#define LUA_ENVIRONINDEX (LUA_REGISTRYINDEX - 1) 37#define LUA_ENVIRONINDEX (LUA_REGISTRYINDEX - 1)
38#define LUA_GLOBALSINDEX (LUA_ENVIRONINDEX - 1) 38#define lua_upvalueindex(i) (LUA_ENVIRONINDEX - (i))
39#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
40 39
41 40
42/* thread status */ 41/* thread status */
@@ -92,7 +91,8 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
92/* predefined values in the registry */ 91/* predefined values in the registry */
93#define LUA_RIDX_MAINTHREAD 1 92#define LUA_RIDX_MAINTHREAD 1
94#define LUA_RIDX_CPCALL 2 93#define LUA_RIDX_CPCALL 2
95#define LUA_RIDX_LAST LUA_RIDX_CPCALL 94#define LUA_RIDX_GLOBALS 3
95#define LUA_RIDX_LAST LUA_RIDX_GLOBALS
96 96
97 97
98/* type of numbers in Lua */ 98/* type of numbers in Lua */
@@ -315,8 +315,8 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
315#define lua_pushliteral(L, s) \ 315#define lua_pushliteral(L, s) \
316 lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) 316 lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
317 317
318#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) 318#define lua_pushglobaltable(L) \
319#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) 319 lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)
320 320
321#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) 321#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
322 322
@@ -343,6 +343,9 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
343#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) 343#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
344#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) 344#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
345 345
346#define lua_setglobal(L,s) lua_setfield(L, LUA_ENVIRONINDEX, (s))
347#define lua_getglobal(L,s) lua_getfield(L, LUA_ENVIRONINDEX, (s))
348
346#endif 349#endif
347 350
348 351