Simplify register_lsyncd(), too

This commit is contained in:
Dennis Schridde 2012-10-01 22:58:25 +02:00
parent 702f6d3d4e
commit 68982e6e5b
1 changed files with 9 additions and 11 deletions

View File

@ -1373,26 +1373,24 @@ register_lsyncd(lua_State *L)
// creates the metatable for jiffies userdata
luaL_newmetatable(L, "Lsyncd.jiffies");
lua_pushstring(L, "__add");
int mt = lua_gettop(L);
lua_pushcfunction(L, l_jiffies_add);
lua_settable(L, -3);
lua_setfield(L, mt, "__add");
lua_pushstring(L, "__sub");
lua_pushcfunction(L, l_jiffies_sub);
lua_settable(L, -3);
lua_setfield(L, mt, "__sub");
lua_pushstring(L, "__lt");
lua_pushcfunction(L, l_jiffies_lt);
lua_settable(L, -3);
lua_setfield(L, mt, "__lt");
lua_pushstring(L, "__le");
lua_pushcfunction(L, l_jiffies_le);
lua_settable(L, -3);
lua_setfield(L, mt, "__le");
lua_pushstring(L, "__eq");
lua_pushcfunction(L, l_jiffies_eq);
lua_settable(L, -3);
lua_pop(L, 1);
lua_setfield(L, mt, "__eq");
lua_pop(L, 1); // pop(mt)
#ifdef LSYNCD_WITH_INOTIFY
lua_getglobal(L, "lsyncd");