diff options
| author | 彭宣正 <[email protected]> | 2022-09-06 11:57:58 +0800 |
|---|---|---|
| committer | 彭宣正 <[email protected]> | 2022-09-06 11:57:58 +0800 |
| commit | 0647c299412d9a54fd331740e19e13d9e9328786 (patch) | |
| tree | 2f08b2a9e283e477b61b9dc48d862241c1953367 | |
| parent | c022c48a3b4abea0577faf4f3f625ee69684e454 (diff) | |
✨ feat(TSG-11870): 修改elua_cbinding_set_output_params 为elua_cbinding_append_output_params, 修改注释
| -rw-r--r-- | gtest/gtest_tsg_lua_exec_with_context.cpp | 2 | ||||
| -rw-r--r-- | gtest/gtest_tsg_lua_register_function.cpp | 20 | ||||
| -rw-r--r-- | src/elua.h | 75 | ||||
| -rw-r--r-- | src/elua_func.cpp | 2 |
4 files changed, 47 insertions, 52 deletions
diff --git a/gtest/gtest_tsg_lua_exec_with_context.cpp b/gtest/gtest_tsg_lua_exec_with_context.cpp index ca9acca..4c2d4cc 100644 --- a/gtest/gtest_tsg_lua_exec_with_context.cpp +++ b/gtest/gtest_tsg_lua_exec_with_context.cpp @@ -26,7 +26,7 @@ int get_userdata(elua_vm *L) edata.type = STRING; edata.buff = (char *)ud; edata.len = strlen((char *)ud); - elua_cbinding_set_output_params(L, &edata, 1); + elua_cbinding_append_output_params(L, &edata, 1); return 1; } diff --git a/gtest/gtest_tsg_lua_register_function.cpp b/gtest/gtest_tsg_lua_register_function.cpp index b826434..6374d56 100644 --- a/gtest/gtest_tsg_lua_register_function.cpp +++ b/gtest/gtest_tsg_lua_register_function.cpp @@ -12,7 +12,7 @@ int get_hello(elua_vm *L) ldata.type = STRING; ldata.buff = (char *)"hello"; ldata.len = 5; - elua_cbinding_set_output_params(L, &ldata, 1); + elua_cbinding_append_output_params(L, &ldata, 1); return 1; } @@ -43,7 +43,7 @@ int set_world(elua_vm *L) retvalue.len = argv[0].len + argv[1].len + 2; retvalue.buff = (char *)calloc(1, retvalue.len); sprintf(retvalue.buff, "%s %s.", argv[0].buff, argv[1].buff); - elua_cbinding_set_output_params(L, &retvalue, 1); + elua_cbinding_append_output_params(L, &retvalue, 1); free(retvalue.buff); return 1; @@ -75,7 +75,7 @@ int get_req_header(elua_vm *L) retvalue.table = etab; retvalue.len = sizeof(struct elua_data); - elua_cbinding_set_output_params(L, &retvalue, 1); + elua_cbinding_append_output_params(L, &retvalue, 1); elua_destroy_table(etab); return 1; @@ -105,7 +105,7 @@ int get_rsp_header(elua_vm *L) retvalue.table = etab; retvalue.len = sizeof(struct elua_data); - elua_cbinding_set_output_params(L, &retvalue, 1); + elua_cbinding_append_output_params(L, &retvalue, 1); elua_destroy_table(etab); return 1; @@ -117,7 +117,7 @@ int get_result(elua_vm *L) retvalue.type = BOOLEAN; retvalue.len = sizeof(bool); retvalue.true_or_false = false; - elua_cbinding_set_output_params(L, &retvalue, 1); + elua_cbinding_append_output_params(L, &retvalue, 1); return 1; } @@ -125,7 +125,7 @@ int get_nil(elua_vm *L) { struct elua_data retvalue; retvalue.type = NIL; - elua_cbinding_set_output_params(L, &retvalue, 1); + elua_cbinding_append_output_params(L, &retvalue, 1); return 1; } @@ -135,7 +135,7 @@ int get_time(elua_vm *L) retvalue.type = INTEGER; retvalue.len = sizeof(long); retvalue.integer = 0x12345678; - elua_cbinding_set_output_params(L, &retvalue, 1); + elua_cbinding_append_output_params(L, &retvalue, 1); return 1; } @@ -145,11 +145,11 @@ int set_repeat(elua_vm *L) retvalue.type = INTEGER; retvalue.len = sizeof(long); retvalue.integer = 0x12345678; - elua_cbinding_set_output_params(L, &retvalue, 1); + elua_cbinding_append_output_params(L, &retvalue, 1); retvalue.type = STRING; retvalue.len = 5; retvalue.buff = (char *)"hello"; - elua_cbinding_set_output_params(L, &retvalue, 1); + elua_cbinding_append_output_params(L, &retvalue, 1); return 1; } @@ -187,7 +187,7 @@ int set_multi_type_retvalue(elua_vm *L) retvalue.table = etab; retvalue.len = sizeof(struct elua_data); - elua_cbinding_set_output_params(L, &retvalue, 1); + elua_cbinding_append_output_params(L, &retvalue, 1); elua_destroy_table(etab); return 1; @@ -37,80 +37,75 @@ struct elua_vm; * return value: elua_handle successed,return a virtual machine; failed, return NULL*/ struct elua_vm *elua_create_vm(const char *vm_name); +/* input: vm a virtual machine + * elua_function the name of lua function + * return value : 0, successed; other failed.*/ int elua_remove_function(struct elua_vm *vm, const char *elua_function); const char *elua_get_last_error_string(struct elua_vm *vm); -/* function name: destroy_lua - * input: elua_handle L a virtual machine - * return value: int successed, return 0; failed, return error code */ +/* input: vm a virtual machine + * return value: successed, return 0; failed, return other */ int elua_destroy_vm(struct elua_vm *vm); int elua_cbinding_get_input_params_num(struct elua_vm *vm); int elua_cbinding_get_input_param(struct elua_vm *vm, int param_index, struct elua_data *param); -int elua_cbinding_set_output_params(struct elua_vm *vm, struct elua_data *params, int params_num); // only call once +int elua_cbinding_append_output_params(struct elua_vm *vm, struct elua_data *params, int params_num); struct elua_table *elua_create_table(struct elua_vm *vm); int elua_add_table(struct elua_table *table, struct elua_data *key, struct elua_data *value); int elua_update_table(struct elua_table *table, struct elua_data *key, struct elua_data *value); -int elua_delete_table(struct elua_table *table, struct elua_data *key, struct elua_data *value); +int elua_delete_table(struct elua_table *table, struct elua_data *key); struct elua_data *elua_search_table(struct elua_table *table, struct elua_data *key); void elua_destroy_table(struct elua_table *table); -/* function name: elua_get_userdata - * description: get C userdata +/* description: get C userdata * input: elua_handle L a virtual machine - * return value: int successed, return 0; failed, return error code */ + * return value: successed, return 0; failed, return other */ void *elua_get_execute_userdata(struct elua_vm *vm); typedef int (*elua_cbinding_func_ptr)(struct elua_vm *vm); -/* function name: elua_register_function - * description: Regist a c function to lua - * input: elua_handle L a virtual machine - * input: const char *function_set The function set to which the function belongs - * input: const char *function_name function name - * input: elua_function_ptr function function pointer - * return value: int successed, return 0; failed return 1 */ +/* description: Regist a c function to lua + * input: vm a virtual machine + * input: func_space_name The function space to which the function belongs + * input: elua_func_name function name + * input: c_func_ptr function pointer + * return value: int successed, return 0; failed, return other */ int elua_register_cbinding(struct elua_vm *vm, const char *func_space_name, const char *elua_func_name, elua_cbinding_func_ptr c_func_ptr); struct elua_context; -/* function name: elua_context_malloc - * input: elua_handle L - * return value: elua_context failed, return NULL; successed, return a context*/ +/* input: vm a virtual machine + * return value: ctx_name failed, return NULL; successed, return a context*/ struct elua_context *elua_create_context(struct elua_vm *vm, const char *ctx_name); -/* function name: elua_context_free - * input: elua_handle L - * input: elua_context context context waiting to free - * return value: int successed, return 0; failed, return -1 */ +/* input: context context waiting to free + * return value: int successed, return 0; failed, return other */ int elua_destroy_context(struct elua_context *ctx); struct elua_script; -/* function name: elua_cache_script - * input: elua_handle L a virtual machine - * char *script script waiting to be cached, which must be script`s content - * size_t *script_len the length of script waiting to be cached +/* input: vm a virtual machine + * script script waiting to be cached, which must be script`s content + * script_len the length of script waiting to be cached * - * return value: int successed, return a script id which is bigger than 1; failed, return error code */ + * return value: int successed, return a elua script; failed, return NULL */ struct elua_script *elua_cache_script(struct elua_vm *vm, const char *script, size_t script_len, size_t timeout_ms); struct elua_script *elua_cache_script_file(struct elua_vm *vm, const char *script, size_t timeout_ms); -/* function name: elua_execute_script - * input: elua_handle L a virtual machine - * size_t script_id a script id - * struct elua_data_t in data waiting to be handled - * void *userdata can get the userdata with elua_get_userdata(L) - * elua_context context Can accessed with lua-name.context in lua script - * size_t timeout_ms Maximum time to run the script.if timeout_ms > 0, jit.off; timeout_ms == 0, jit.on, not expired. - * output: struct estruct elua_data *outvalue Requires input of an expected type that is not NIL, the type of the result that will be output after the call is complete - * return value: int successed, return 0; failed, return error code */ +/* input: vm a virtual machine + * escript elua script + * input data waiting to be handled + * input_len input len + * userdata can get the userdata with elua_get_userdata(L) + * context can accessed with lua-name.context in lua script + * timeout_ms Maximum time to run the script.if timeout_ms > 0, jit.off; timeout_ms == 0, jit.on, not expired. + * output: outvalue Requires input of an expected type, the type of the result that will be output after the call is complete + * return value: int successed, return 0; failed, return other */ int elua_execute_script(struct elua_script *escript, const char *input, size_t input_len, void *userdata, struct elua_context *ctx, struct elua_data *output); -/* function name: unchache_script - * input: elua_handle L a virtual machine - * size_t script_id a script id - * return value: int successed, return 0; failed, return error code */ +/* input: vm a virtual machine + * escript elua script + * return value: int successed, return 0; failed, return other */ int elua_cleanup_script(struct elua_script *escript); diff --git a/src/elua_func.cpp b/src/elua_func.cpp index f59e164..78f5508 100644 --- a/src/elua_func.cpp +++ b/src/elua_func.cpp @@ -1476,7 +1476,7 @@ void elua_destroy_table(struct elua_table *table) return; } -int elua_cbinding_set_output_params(struct elua_vm *vm, struct elua_data *params, int params_num) +int elua_cbinding_append_output_params(struct elua_vm *vm, struct elua_data *params, int params_num) { lua_State *L = (lua_State *)vm; if (L == NULL) |
