aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_common.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-28 18:07:11 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-28 18:07:11 +0100
commita014c2274bf178774697ce2a2b83a02bf6a3ac1c (patch)
tree84e6a626206973162fc8a633d98d510ea4d59c37 /src/lua/lua_common.c
parent90fa147ca70698661da0cce271d6ac0982a92c37 (diff)
downloadrspamd-a014c2274bf178774697ce2a2b83a02bf6a3ac1c.tar.gz
rspamd-a014c2274bf178774697ce2a2b83a02bf6a3ac1c.zip
[Minor] Fix various cases in Lua API
Diffstat (limited to 'src/lua/lua_common.c')
-rw-r--r--src/lua/lua_common.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index a33f33791..785042b8e 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -47,7 +47,7 @@ lua_error_quark (void)
/* Util functions */
/**
- * Create new class and store metatable on top of the stack
+ * Create new class and store metatable on top of the stack (must be popped if not needed)
* @param L
* @param classname name of class
* @param func table of class methods
@@ -62,10 +62,14 @@ rspamd_lua_new_class (lua_State * L,
lua_pushvalue (L, -2); /* pushes the metatable */
lua_settable (L, -3); /* metatable.__index = metatable */
- lua_pushstring (L, "class"); /* mt,"__index",it,"class" */
- lua_pushstring (L, classname); /* mt,"__index",it,"class",classname */
- lua_rawset (L, -3); /* mt,"__index",it */
- luaL_register (L, NULL, methods);
+ lua_pushstring (L, "class"); /* mt,"class" */
+ lua_pushstring (L, classname); /* mt,"class",classname */
+ lua_rawset (L, -3); /* mt */
+
+ if (methods) {
+ luaL_register (L, NULL, methods); /* pushes all methods as MT fields */
+ }
+ /* MT is left on stack ! */
}
/**
@@ -915,6 +919,7 @@ rspamd_lua_init (bool wipe_mem)
luaopen_dns (L);
luaopen_udp (L);
luaopen_worker (L);
+ luaopen_kann (L);
luaL_newmetatable (L, "rspamd{ev_base}");
lua_pushstring (L, "class");