From: Rui Guo Date: Tue, 18 Aug 2009 17:48:22 +0000 (+0800) Subject: Some more dead code & comments removed. X-Git-Url: https://repo.or.cz/w/screen-lua.git/commitdiff_plain/356c3ac575efc9193098695c618edfa3f098cb20 Some more dead code & comments removed. --- diff --git a/src/lua.c b/src/lua.c index b69f2e3..ce8f2f1 100644 --- a/src/lua.c +++ b/src/lua.c @@ -1230,26 +1230,11 @@ LuaNewState(struct sfile *slist) /* To store handler funcs */ - /*_two kinds of information are mantained: - * + /* * funcreg[key]->func - * The 'func' part of the tables are weak. That means the registered funcs - * will be collected once the func is no longer available (e.g. overwritten - * by a new instance of the script) - * - * To make this process happens faster, GC is forced at the end of each - * source. - * TODO: What if some events are triggered within the sourcing - * procedure? * */ prepare_weak_table(L, "_funcreg", " "); - /* funcunhook[func]->listener - * The listener is the unhook ticket of the hook. which should be collected - * once the func is collected. The gc metamethod will be triggered - * accordingly. */ - prepare_weak_table(L, "_funcunhook", " "); - /* Hold a reference to the sfile structure to ease unloading the script.*/ luaL_getmetatable(L, "screen"); lua_pushstring(L, "_sfile"); @@ -1322,23 +1307,7 @@ int LuaSource(const char *file, int async) free(slist); return 0; } - else - { - /* It seems that I need two GC passes to really collect the unhook - * ticket, after changing the reference to ticket in the - * 'funcunhook' table from weak to strong. This should not be - * harmful, but how can I make sure that two passes is enough? - * - * Possible reason: - * This seems reasonable, since the first pass will collect the func - * itself and make the ticket garbage, and the second pass will - * collect the ticket itself. - * - * TODO: check this out. maybe ask some lua gurus. */ - lua_gc(slist->L, LUA_GCCOLLECT, 0); - lua_gc(slist->L, LUA_GCCOLLECT, 0); - scripts = slist; - } + scripts = slist; return 1; } return 0; @@ -1577,20 +1546,6 @@ LuaDispatch(void *handler, const char *params, va_list va) return retvalue; } -/*FIXME: what if a func is registered twice or more? */ -void -LuaRegAutoUnHook(lua_State *L, lua_handler lh, int ticket) -{ - int sc, funcunhook; - luaL_getmetatable(L, "screen"); - sc = lua_gettop(L); - funcunhook = LuaPushHTable(L, sc, "_funcunhook"); - LuaPushHandler(lh); - lua_pushvalue(L, ticket); - lua_rawset(L, funcunhook); - lua_pop(L, 2); -} - #define SEVNAME_MAX 30 static int LuaRegEvent(lua_State *L) @@ -1645,7 +1600,6 @@ LuaRegEvent(lua_State *L) if (sev) { struct listener *l; - int ticket; l = (struct listener *)malloc(sizeof(struct listener)); if (!l) return luaL_error(L, "Out of memory"); @@ -1655,9 +1609,6 @@ LuaRegEvent(lua_State *L) register_listener(sev, l); /* Return the ticket for un-register */ push_callback(L, &l); - ticket = lua_gettop(L); - - LuaRegAutoUnHook(L, lh, ticket); } else return luaL_error(L, "Invalid event specified: %s for object %s", event, objname);