aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-07-01 16:23:58 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-07-01 16:23:58 -0300
commitaa3da1605ceb50fe8353ecb7d03b6f074e131284 (patch)
tree8f57b48267660e3631368f8e579b5cd7816cab65 /lauxlib.c
parent9f4b5b52327497e3ce82cb0af1d94ad6c09b1da2 (diff)
downloadlua-aa3da1605ceb50fe8353ecb7d03b6f074e131284.tar.gz
lua-aa3da1605ceb50fe8353ecb7d03b6f074e131284.tar.bz2
lua-aa3da1605ceb50fe8353ecb7d03b6f074e131284.zip
`newproxy' uses its own weaktable
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c20
1 files changed, 1 insertions, 19 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 26a81287..d66250b3 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -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
305LUALIB_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** {======================================================