【优化】修改部分函数定义位置,减少内部接口函数
This commit is contained in:
@@ -43,6 +43,15 @@ struct lua_binding_data lua_bind_datas[] = {
|
||||
{DATATYPE_END, NULL, NULL, NULL},
|
||||
};
|
||||
|
||||
/* 向lua状态机中注册一个函数 */
|
||||
int lua_cbinding_function(lua_State *state, lua_CFunction bind_function, const char *function_name, const char *space_name);
|
||||
/* 从lua状态机中移除一个已经注册的函数 */
|
||||
int lua_cbinding_function_remove(lua_State *state, const char *function_name, const char *space_name);
|
||||
/* 将一个全局数据注册至状态机中 */
|
||||
int lua_cbinding_data(lua_State *state, struct lua_binding_data *data);
|
||||
/* 从状态机中移除一个已经注册的全局数据 */
|
||||
int lua_cbinding_data_remove(lua_State *state, const char *data_name, const char *space_name);
|
||||
|
||||
/*
|
||||
* Function: lua_cbinding_function
|
||||
* Input: | lua_State * | state | 需要注册函数的状态机
|
||||
@@ -481,7 +490,7 @@ int lua_plugin_manage_session_regist(lua_State *state)
|
||||
}
|
||||
|
||||
/* 取出处理第四个参数 */
|
||||
struct lua_plugin_env *plugin_env = (struct lua_plugin_env *)lua_topointer(state, -1);
|
||||
struct lua_plugin_env *plugin_env = (struct lua_plugin_env *)lua_topointer(state, -1); /* stack 4 */
|
||||
if (!plugin_env)
|
||||
{
|
||||
lua_settop(state, 0);
|
||||
@@ -490,39 +499,43 @@ int lua_plugin_manage_session_regist(lua_State *state)
|
||||
lua_pop(state, 1);
|
||||
|
||||
/* 取出处理第三个参数 */
|
||||
int ctx_free_id = luaL_ref(state, LUA_REGISTRYINDEX);
|
||||
int ctx_free_id = luaL_ref(state, LUA_REGISTRYINDEX); /* stack 3 */
|
||||
if (ctx_free_id == LUA_REFNIL)
|
||||
{
|
||||
lua_settop(state, 0);
|
||||
return 0;
|
||||
}
|
||||
lua_pop(state, 1);
|
||||
|
||||
/* 取出处理第二个参数 */
|
||||
int ctx_new_id = luaL_ref(state, LUA_REGISTRYINDEX);
|
||||
int ctx_new_id = luaL_ref(state, LUA_REGISTRYINDEX); /* stack 2 */
|
||||
if (ctx_new_id == LUA_REFNIL)
|
||||
{
|
||||
lua_settop(state, 0);
|
||||
return 0;
|
||||
}
|
||||
lua_pop(state, 1);
|
||||
|
||||
/* 取出处理第一个参数 */
|
||||
struct stellar * st = (struct stellar *)lua_topointer(state, -1);
|
||||
struct stellar * st = (struct stellar *)lua_topointer(state, -1); /* stack 1 */
|
||||
if ( !st ) {
|
||||
lua_settop(state, 0);
|
||||
return 0;
|
||||
}
|
||||
lua_pop(state, 1);
|
||||
|
||||
/* 在stellar中注册, 获取注册id */
|
||||
int plugin_id = stellar_session_plugin_register(st, lpm_ctx_new_func, lpm_ctx_free_func, (void *)plugin_env);
|
||||
|
||||
#ifdef LUAPLUGIN_BASIC_UNITTEST
|
||||
printf("now regist new plugin, plugin id is %d\n", plugin_id);
|
||||
#endif
|
||||
|
||||
/* 将注册完成的新插件插入到队列中 */
|
||||
struct lua_session_plugin session_plugin;
|
||||
memset(&session_plugin, 0, sizeof(session_plugin));
|
||||
session_plugin_instance_init(&session_plugin, state, plugin_id, ctx_new_id, ctx_free_id);
|
||||
|
||||
utarray_push_back(plugin_env->plugin_env_plugin_array, &session_plugin);
|
||||
|
||||
lua_settop(state, 0);
|
||||
lua_pushinteger(state, plugin_id);
|
||||
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user