diff options
Diffstat (limited to 'src/lua_binding_function.c')
| -rw-r--r-- | src/lua_binding_function.c | 93 |
1 files changed, 53 insertions, 40 deletions
diff --git a/src/lua_binding_function.c b/src/lua_binding_function.c index 28f4358..5ed604c 100644 --- a/src/lua_binding_function.c +++ b/src/lua_binding_function.c @@ -2,12 +2,6 @@ #include "lua_binding_function.h" #include "lua_binding_cfunc.h" -#include "stellar/mq.h" -#include "stellar/module_manager.h" -#include "stellar/packet.h" -#include "stellar/packet_manager.h" -#include "stellar/session.h" -#include "stellar/session_manager.h" #include "stellar/utils.h" #include <stdlib.h> @@ -20,7 +14,7 @@ #define LUA_BINDING_FUNCTION_GET_VALUE_POINTER(func_name, param_type, value_type, value_func) \ int func_name(struct lua_state *state) \ { \ - lua_State *L = (lua_State *)lua_state_get_lua_State(state); \ + lua_State *L = (lua_State *)(state); \ if (lua_gettop(L) != 1) \ { \ lua_settop(L, 0); \ @@ -36,7 +30,7 @@ #define LUA_BINDING_FUNCTION_GET_VALUE_INT(func_name, param_type, value_func) \ int func_name(struct lua_state *state) \ { \ - lua_State *L = (lua_State *)lua_state_get_lua_State(state); \ + lua_State *L = (lua_State *)(state); \ if (lua_gettop(L) != 1) \ { \ lua_settop(L, 0); \ @@ -49,9 +43,56 @@ return 1; \ } +int lua_get_lua_module_manager(struct lua_state *state) +{ + lua_State *L = (lua_State *)(state); + lua_settop(L, 0); + struct lua_module_manager *lua_mod_mgr = lua_state_get_lua_module_manager(state); + lua_pushlightuserdata(L, (void *)lua_mod_mgr); + return 1; +} + +LUA_BINDING_FUNCTION_GET_VALUE_POINTER(lua_get_stellar_module_manager, + struct lua_module_manager, + struct stellar_module_manager, + lua_module_manager_get_stellar_module_manager) + +LUA_BINDING_FUNCTION_GET_VALUE_POINTER(lua_get_mq_schema, + struct lua_module_manager, + struct mq_schema, + lua_module_manager_get_mq_schema) + +LUA_BINDING_FUNCTION_GET_VALUE_POINTER(lua_get_mq_runtime, + struct lua_module_manager, + struct mq_runtime, + lua_module_manager_get_mq_runtime) + +LUA_BINDING_FUNCTION_GET_VALUE_POINTER(lua_get_logger, + struct lua_module_manager, + struct logger, + lua_module_manager_get_logger) + +LUA_BINDING_FUNCTION_GET_VALUE_POINTER(lua_get_packet_manager, + struct lua_module_manager, + struct packet_manager, + lua_module_manager_get_packet_manager) + +LUA_BINDING_FUNCTION_GET_VALUE_POINTER(lua_get_session_manager, + struct lua_module_manager, + struct session_manager, + lua_module_manager_get_session_manager) + +LUA_BINDING_FUNCTION_GET_VALUE_INT(lua_get_current_thread_id, + struct lua_module_manager, + lua_module_manager_get_current_thread_id) + +LUA_BINDING_FUNCTION_GET_VALUE_INT(lua_get_max_thread_num, + struct lua_module_manager, + lua_module_manager_get_max_thread_num) + int lua_mq_schema_get_topic_id(struct lua_state *state) { - lua_State *L = (lua_State *)lua_state_get_lua_State(state); + lua_State *L = (lua_State *)(state); if (lua_gettop(L) != 2 || lua_type(L, -1) != LUA_TSTRING || lua_type(L, -2) != LUA_TLIGHTUSERDATA) { lua_settop(L, 0); @@ -73,7 +114,7 @@ int lua_mq_schema_get_topic_id(struct lua_state *state) int lua_mq_schema_create_topic(struct lua_state *state) { - lua_State *L = (lua_State *)lua_state_get_lua_State(state); + lua_State *L = (lua_State *)(state); if (lua_gettop(L) != 6 || lua_type(L, -5) != LUA_TSTRING || lua_type(L, -6) != LUA_TLIGHTUSERDATA) { lua_settop(L, 0); @@ -269,34 +310,6 @@ int lua_mq_runtime_publish_message(struct lua_state *state) return 1; } -LUA_BINDING_FUNCTION_GET_VALUE_POINTER(lua_stellar_get_stellar_module_manager, - struct lua_module_manager, - struct stellar_module_manager, - lua_module_manager_get_stellar_module_manager) - -LUA_BINDING_FUNCTION_GET_VALUE_INT(lua_stellar_get_thread_id, - struct stellar_module_manager, - stellar_module_manager_get_thread_id) - -LUA_BINDING_FUNCTION_GET_VALUE_INT(lua_stellar_get_max_thread_num, - struct stellar_module_manager, - stellar_module_manager_get_max_thread_num) - -LUA_BINDING_FUNCTION_GET_VALUE_POINTER(lua_stellar_get_mq_runtime, - struct stellar_module_manager, - struct mq_runtime, - stellar_module_manager_get_mq_runtime) - -LUA_BINDING_FUNCTION_GET_VALUE_POINTER(lua_stellar_get_mq_schema, - struct stellar_module_manager, - struct mq_schema, - stellar_module_manager_get_mq_schema) - -LUA_BINDING_FUNCTION_GET_VALUE_POINTER(lua_stellar_get_logger, - struct stellar_module_manager, - struct logger, - stellar_module_manager_get_logger) - LUA_BINDING_FUNCTION_GET_VALUE_INT(lua_packet_get_direction, const struct packet, packet_get_direction) @@ -362,7 +375,7 @@ enum sess_mgr_sub_type static int lua_session_manager_subscribe(struct lua_state *state, enum sess_mgr_sub_type type) { - lua_State *L = (lua_State *)state; + lua_State *L = (lua_State *)(state); if (lua_gettop(L) != 3 || lua_type(L, -2) != LUA_TFUNCTION || lua_type(L, -3) != LUA_TLIGHTUSERDATA) { lua_settop(L, 0); @@ -425,7 +438,7 @@ int lua_session_manager_subscribe_control_packet(struct lua_state *state) int lua_session_manager_subscribe_tcp_stream(struct lua_state *state) { - lua_State *L = (lua_State *)state; + lua_State *L = (lua_State *)(state); if (lua_gettop(L) != 3 || lua_type(L, -2) != LUA_TFUNCTION || lua_type(L, -4) != LUA_TLIGHTUSERDATA) { lua_settop(L, 0); |
