diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 20 |
1 files changed, 1 insertions, 19 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.76 2002/06/25 19:15:21 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.77 2002/06/26 19:28:44 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -302,24 +302,6 @@ LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { | |||
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | LUALIB_API void luaL_weakregistry (lua_State *L) { | ||
306 | static const char dummy = '\0'; /* index for a weak table in registry */ | ||
307 | lua_pushudataval(L, (void *)&dummy); /* push index */ | ||
308 | lua_rawget(L, LUA_REGISTRYINDEX); /* get value */ | ||
309 | if (!lua_isnil(L, -1)) return; /* weak table already created? */ | ||
310 | /* else must create a weak table */ | ||
311 | lua_pop(L, 1); /* remove previous nil */ | ||
312 | lua_newtable(L); /* new table `w' */ | ||
313 | lua_pushvalue(L, -1); | ||
314 | lua_setmetatable(L, -2); /* setmetatable(w, w) */ | ||
315 | lua_pushliteral(L, "__mode"); | ||
316 | lua_pushliteral(L, "kv"); | ||
317 | lua_rawset(L, -3); /* metatable(w).__mode = "kv" */ | ||
318 | lua_pushudataval(L, (void *)&dummy); /* push index */ | ||
319 | lua_pushvalue(L, -2); /* push value */ | ||
320 | lua_rawset(L, LUA_REGISTRYINDEX); /* store new weak table into registry */ | ||
321 | } | ||
322 | |||
323 | 305 | ||
324 | /* | 306 | /* |
325 | ** {====================================================== | 307 | ** {====================================================== |