diff options
Diffstat (limited to 'src/lua/lua_common.h')
-rw-r--r-- | src/lua/lua_common.h | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index 5edec663b..f9ec8e2e3 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -63,11 +63,9 @@ static inline void lua_rawsetp (lua_State *L, int i, const void *p) { #endif /* Interface definitions */ -#define LUA_FUNCTION_DEF(class, name) static int lua_ ## class ## _ ## name ( \ - lua_State * L) -#define LUA_PUBLIC_FUNCTION_DEF(class, name) int lua_ ## class ## _ ## name ( \ - lua_State * L) -#define LUA_INTERFACE_DEF(class, name) { # name, lua_ ## class ## _ ## name } +#define LUA_FUNCTION_DEF(class, name) static int lua_##class##_##name (lua_State * L) +#define LUA_PUBLIC_FUNCTION_DEF(class, name) int lua_##class##_##name (lua_State * L) +#define LUA_INTERFACE_DEF(class, name) { #name, lua_##class##_##name } #ifdef __cplusplus extern "C" { @@ -162,6 +160,13 @@ void rspamd_lua_new_class (lua_State *L, void rspamd_lua_setclass (lua_State *L, const gchar *classname, gint objidx); /** + * Pushes the metatable for specific class on top of the stack + * @param L + * @param classname + */ +void rspamd_lua_class_metatable (lua_State *L, const gchar *classname); + +/** * Adds a new field to the class (metatable) identified by `classname` * @param L * @param classname @@ -600,6 +605,19 @@ gchar *rspamd_lua_get_module_name (lua_State *L); bool rspamd_lua_universal_pcall (lua_State *L, gint cbref, const gchar* strloc, gint nret, const gchar *args, GError **err, ...); +/** + * Wrapper for lua_geti from lua 5.3 + * @param L + * @param index + * @param i + * @return + */ +#if defined( LUA_VERSION_NUM ) && LUA_VERSION_NUM <= 502 +gint rspamd_lua_geti (lua_State *L, int index, int i); +#else +#define rspamd_lua_geti lua_geti +#endif + /* Paths defs */ #define RSPAMD_CONFDIR_INDEX "CONFDIR" #define RSPAMD_LOCAL_CONFDIR_INDEX "LOCAL_CONFDIR" |