浏览代码

no more compatibility with (veryyyy) old ref system

Roberto Ierusalimschy 14 年之前
父节点
当前提交
50334faad6
共有 2 个文件被更改,包括 9 次插入23 次删除
  1. 5 18
      lauxlib.h
  2. 4 5
      ltests.c

+ 5 - 18
lauxlib.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.h,v 1.110 2010/11/10 17:38:10 roberto Exp roberto $
+** $Id: lauxlib.h,v 1.111 2010/11/10 18:05:36 roberto Exp roberto $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
@@ -62,6 +62,10 @@ LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
 LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
                                    const char *const lst[]);
 
+/* pre-defined references */
+#define LUA_NOREF       (-2)
+#define LUA_REFNIL      (-1)
+
 LUALIB_API int (luaL_ref) (lua_State *L, int t);
 LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
 
@@ -164,23 +168,6 @@ LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
                                 const luaL_Reg *l, int nup);
 
 
-/* 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_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
-
-#define lua_unref(L,ref)        luaL_unref(L, LUA_REGISTRYINDEX, (ref))
-
-#define lua_getref(L,ref)       lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
-
-
-#define luaL_reg	luaL_Reg
-
-
 #endif
 
 

+ 4 - 5
ltests.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltests.c,v 2.111 2010/07/02 11:38:13 roberto Exp roberto $
+** $Id: ltests.c,v 2.112 2010/07/28 15:51:59 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 */
@@ -727,24 +727,23 @@ static int string_query (lua_State *L) {
 
 static int tref (lua_State *L) {
   int level = lua_gettop(L);
-  int lock = luaL_optint(L, 2, 1);
   luaL_checkany(L, 1);
   lua_pushvalue(L, 1);
-  lua_pushinteger(L, lua_ref(L, lock));
+  lua_pushinteger(L, luaL_ref(L, LUA_REGISTRYINDEX));
   lua_assert(lua_gettop(L) == level+1);  /* +1 for result */
   return 1;
 }
 
 static int getref (lua_State *L) {
   int level = lua_gettop(L);
-  lua_getref(L, luaL_checkint(L, 1));
+  lua_rawgeti(L, LUA_REGISTRYINDEX, luaL_checkint(L, 1));
   lua_assert(lua_gettop(L) == level+1);
   return 1;
 }
 
 static int unref (lua_State *L) {
   int level = lua_gettop(L);
-  lua_unref(L, luaL_checkint(L, 1));
+  luaL_unref(L, LUA_REGISTRYINDEX, luaL_checkint(L, 1));
   lua_assert(lua_gettop(L) == level);
   return 0;
 }