From: Vsevolod Stakhov Date: Wed, 2 Oct 2013 14:37:56 +0000 (+0100) Subject: Add preliminary implementation of lua to rcl converter. X-Git-Tag: 0.6.0~144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2d1109c8f7a450febae4d160b23bdd8f2a27465;p=thirdparty%2Frspamd.git Add preliminary implementation of lua to rcl converter. --- diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt index 762c9a10de..4713b34051 100644 --- a/src/lua/CMakeLists.txt +++ b/src/lua/CMakeLists.txt @@ -3,6 +3,7 @@ SET(LUASRC lua_common.c lua_task.c lua_message.c lua_config.c + lua_rcl.c lua_classifier.c lua_cfg_file.c lua_regexp.c @@ -15,8 +16,7 @@ SET(LUASRC lua_common.c lua_session.c lua_buffer.c lua_dns.c - lua_rsa.c - lua_rcl.c) + lua_rsa.c) ADD_LIBRARY(rspamd-lua ${LINK_TYPE} ${LUASRC}) SET_TARGET_PROPERTIES(rspamd-lua PROPERTIES VERSION ${RSPAMD_VERSION}) diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index c83433d810..7416297f77 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -109,6 +109,13 @@ void free_lua_locked (struct lua_locked_state *st); */ gint lua_rcl_obj_push (lua_State *L, rspamd_cl_object_t *obj); +/** + * Extract rcl object from lua object + * @param L + * @return + */ +rspamd_cl_object_t * lua_rcl_obj_get (lua_State *L); + /** * Open libraries functions */ diff --git a/src/lua/lua_rcl.c b/src/lua/lua_rcl.c index c992b553e6..1dc17bde55 100644 --- a/src/lua/lua_rcl.c +++ b/src/lua/lua_rcl.c @@ -41,7 +41,7 @@ static void lua_rcl_obj_push_elt (lua_State *L, const char *key, rspamd_cl_object_t *obj) { lua_pushstring (L, key); - lua_push_obj_simple (L, obj); + lua_rcl_obj_push (L, obj); lua_settable (L, -3); } @@ -146,3 +146,23 @@ lua_rcl_obj_push (lua_State *L, rspamd_cl_object_t *obj) return lua_rcl_obj_push_simple (L, obj); } } + +/** + * Extract rcl object from lua object + * @param L + * @return + */ +rspamd_cl_object_t * +lua_rcl_obj_get (lua_State *L) +{ + rspamd_cl_object_t *obj; + gint t; + + obj = rspamd_cl_object_new (); + + if (obj != NULL) { + t = lua_type (L, 1); + } + + return obj; +} diff --git a/src/rcl/rcl.h b/src/rcl/rcl.h index 3f3e5fa20a..5cfe03c3b1 100644 --- a/src/rcl/rcl.h +++ b/src/rcl/rcl.h @@ -80,6 +80,23 @@ typedef struct rspamd_cl_object_s { UT_hash_handle hh; /**< hash handle */ } rspamd_cl_object_t; + +/** + * Creates a new object + * @return new object + */ +static inline rspamd_cl_object_t * +rspamd_cl_object_new (void) +{ + rspamd_cl_object_t *new; + new = g_slice_alloc0 (sizeof (rspamd_cl_object_t)); + if (new != NULL) { + new->ref = 1; + } + return new; +} + + /** * Converts an object to double value * @param obj CL object diff --git a/src/rcl/rcl_parser.c b/src/rcl/rcl_parser.c index 713330ca80..7d981db913 100644 --- a/src/rcl/rcl_parser.c +++ b/src/rcl/rcl_parser.c @@ -31,19 +31,6 @@ * The implementation of rcl parser */ -/** - * Create a new object - * @return new object - */ -static inline rspamd_cl_object_t * -rspamd_cl_object_new (void) -{ - rspamd_cl_object_t *new; - new = g_slice_alloc0 (sizeof (rspamd_cl_object_t)); - new->ref = 1; - return new; -} - /** * Move up to len characters * @param parser