[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: LUA_ENVIRONINDEX, LUA_GLOBALSINDEX and lua_getglobal/lua_setglobal
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Thu, 20 Dec 2007 10:45:39 -0500
Leo Razoumov wrote:
> I would like to use lua_setglobal and lua_getglobal. These functions
> use LUA_GLOBALSINDEX.
These are macros. Redefine them to do what you want:
#undef lua_setglobal
#undef lua_getglobal
#define lua_setglobal(L,s) lua_setfield(L, LUA_ENVIRONINDEX, (s))
#define lua_getglobal(L,s) lua_getfield(L, LUA_ENVIRONINDEX, (s))
Or you can have two versions for thread globals and function globals:
#define lua_settglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s))
#define lua_gettglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))
#define lua_setfglobal(L,s) lua_setfield(L, LUA_ENVIRONINDEX, (s))
#define lua_getfglobal(L,s) lua_getfield(L, LUA_ENVIRONINDEX, (s))