From 46347d768e571ba9b36581c36d11d2de1dee2cfb Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 31 Oct 2001 17:40:14 -0200 Subject: `ref' support goes to auxlib --- lua.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'lua.h') diff --git a/lua.h b/lua.h index 1325f5f4..1691b07f 100644 --- a/lua.h +++ b/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.104 2001/10/11 21:41:21 roberto Exp $ +** $Id: lua.h,v 1.105 2001/10/17 21:12:57 roberto Exp $ ** Lua - An Extensible Extension Language ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil ** e-mail: info@lua.org @@ -26,11 +26,6 @@ #define LUA_ERRORMESSAGE "_ERRORMESSAGE" -/* pre-defined references */ -#define LUA_NOREF (-2) -#define LUA_REFNIL (-1) - - /* option for multiple returns in `lua_call' */ #define LUA_MULTRET (-1) @@ -180,7 +175,6 @@ LUA_API void lua_rawset (lua_State *L, int index); LUA_API void lua_rawseti (lua_State *L, int index, int n); LUA_API void lua_setglobals (lua_State *L); LUA_API void lua_settagmethod (lua_State *L, int tag, const lua_char *event); -LUA_API int lua_ref (lua_State *L, int lock); /* @@ -214,8 +208,6 @@ LUA_API const lua_char *lua_tag2name (lua_State *L, int tag); LUA_API void lua_error (lua_State *L, const lua_char *s); -LUA_API void lua_unref (lua_State *L, int ref); - LUA_API int lua_next (lua_State *L, int index); LUA_API int lua_getn (lua_State *L, int index); @@ -253,7 +245,6 @@ LUA_API int lua_getweakmode (lua_State *L, int index); #define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX); -#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, ref) /* @@ -264,6 +255,20 @@ LUA_API int lua_getweakmode (lua_State *L, int index); LUA_API void lua_pushupvalues (lua_State *L); + +/* compatibility with ref system */ + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_error(L, l_s("unlocked references are obsolete")), 0)) + +#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) + +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, ref) + #endif -- cgit v1.2.3-55-g6feb