diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-03-13 00:57:46 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-03-13 00:57:46 -0300 |
commit | 489253d7530e372da8807f1ad083928c3545f772 (patch) | |
tree | 27af73f0d2809bef0b2366fee6e26cbbbe748887 /lua.h | |
parent | 25c557ec6367870c127e879cce8ed8fa21f34398 (diff) | |
download | lua-489253d7530e372da8807f1ad083928c3545f772.tar.gz lua-489253d7530e372da8807f1ad083928c3545f772.tar.bz2 lua-489253d7530e372da8807f1ad083928c3545f772.zip |
better definitions for lua_[gs]etglobal + less uses of ENVIRONINDEX
Diffstat (limited to 'lua.h')
-rw-r--r-- | lua.h | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.260 2010/01/06 15:08:00 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.261 2010/01/11 17:15:11 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,8 +297,12 @@ 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_setglobal(L,s) lua_setfield(L, LUA_ENVIRONINDEX, (s)) | 300 | #define lua_setglobal(L,s) \ |
301 | #define lua_getglobal(L,s) lua_getfield(L, LUA_ENVIRONINDEX, (s)) | 301 | (lua_pushglobaltable(L), lua_pushvalue(L, -2), \ |
302 | lua_setfield(L, -2, (s)), lua_pop(L, 2)) | ||
303 | |||
304 | #define lua_getglobal(L,s) \ | ||
305 | (lua_pushglobaltable(L), lua_getfield(L, -1, (s)), lua_remove(L, -2)) | ||
302 | 306 | ||
303 | #define lua_register(L,n,f) \ | 307 | #define lua_register(L,n,f) \ |
304 | (lua_pushcfunction(L, (f)), lua_setfield(L, LUA_ENVIRONINDEX, (n))) | 308 | (lua_pushcfunction(L, (f)), lua_setfield(L, LUA_ENVIRONINDEX, (n))) |