[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lunar.h explained: subtable "userdata"
- From: Procházka Lukáš Ing. - Pontex s. r. o. <LPr@...>
- Date: Mon, 08 Sep 2014 10:31:05 +0200
Hello,
I'm trying to understand Lunar<T> code.
There is still one point I can't understand:
---
static int push(lua_State *L, T *obj, bool gc=false) {
if (!obj) { lua_pushnil(L); return 0; }
luaL_getmetatable(L, T::className); // lookup metatable in Lua registry
if (lua_isnil(L, -1)) luaL_error(L, "%s missing metatable", T::className);*/
int mt = lua_gettop(L);
subtable(L, mt, "userdata", "v"); // WHY THIS???
...
---
Lunar creates a metatable for each T; that's clear.
(
This metatable has also subtable named "do not trash", which contains keys=userdata for userdata which are to be ignored during GC cycle;
keys in "do not trash" table are weak; obviously.
)
But - why is there a subtable "userdata" with weak values?
It seems to me it is not used anywhere later, so why?
Thanks in advance for any hint or explanation.
Best regards,
Lukas
--
Ing. Lukáš Procházka | mailto:LPr@pontex.cz
Pontex s. r. o. | mailto:pontex@pontex.cz | http://www.pontex.cz
Bezová 1658
147 14 Praha 4
Tel: +420 241 096 751
Fax: +420 244 461 038