Implement native function pointer check, addr conversion and register, update documents (#185)
Modified WASM runtime API: - wasm_runtime_module_malloc() - wasm_runtime_lookup_function() Introduced runtime API - wasm_runtime_register_natives()
This commit is contained in:
@ -20,23 +20,23 @@ extern "C" {
|
||||
|
||||
void
|
||||
wasm_obj_native_call(wasm_exec_env_t exec_env,
|
||||
int32 func_id, uint32 argv_offset, uint32 argc);
|
||||
int32 func_id, uint32 *argv, uint32 argc);
|
||||
|
||||
void
|
||||
wasm_btn_native_call(wasm_exec_env_t exec_env,
|
||||
int32 func_id, uint32 argv_offset, uint32 argc);
|
||||
int32 func_id, uint32 *argv, uint32 argc);
|
||||
|
||||
void
|
||||
wasm_label_native_call(wasm_exec_env_t exec_env,
|
||||
int32 func_id, uint32 argv_offset, uint32 argc);
|
||||
int32 func_id, uint32 *argv, uint32 argc);
|
||||
|
||||
void
|
||||
wasm_cb_native_call(wasm_exec_env_t exec_env,
|
||||
int32 func_id, uint32 argv_offset, uint32 argc);
|
||||
int32 func_id, uint32 *argv, uint32 argc);
|
||||
|
||||
void
|
||||
wasm_list_native_call(wasm_exec_env_t exec_env,
|
||||
int32 func_id, uint32 argv_offset, uint32 argc);
|
||||
int32 func_id, uint32 *argv, uint32 argc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -4,25 +4,25 @@
|
||||
*/
|
||||
|
||||
/* button */
|
||||
EXPORT_WASM_API(wasm_btn_native_call),
|
||||
EXPORT_WASM_API_WITH_SIG(wasm_btn_native_call, "(i*i)"),
|
||||
|
||||
/* obj */
|
||||
EXPORT_WASM_API(wasm_obj_native_call),
|
||||
EXPORT_WASM_API_WITH_SIG(wasm_obj_native_call, "(i*i)"),
|
||||
|
||||
/* label */
|
||||
EXPORT_WASM_API(wasm_label_native_call),
|
||||
EXPORT_WASM_API_WITH_SIG(wasm_label_native_call, "(i*i)"),
|
||||
|
||||
/* cont */
|
||||
//EXPORT_WASM_API(wasm_cont_native_call),
|
||||
//EXPORT_WASM_API_WITH_SIG(wasm_cont_native_call, "(i*i)"),
|
||||
|
||||
/* page */
|
||||
//EXPORT_WASM_API(wasm_page_native_call),
|
||||
//EXPORT_WASM_API_WITH_SIG(wasm_page_native_call, "(i*i)"),
|
||||
|
||||
/* list */
|
||||
EXPORT_WASM_API(wasm_list_native_call),
|
||||
EXPORT_WASM_API_WITH_SIG(wasm_list_native_call, "(i*i)"),
|
||||
|
||||
/* drop down list */
|
||||
//EXPORT_WASM_API(wasm_ddlist_native_call),
|
||||
//EXPORT_WASM_API_WITH_SIG(wasm_ddlist_native_call, "(i*i)"),
|
||||
|
||||
/* check box */
|
||||
EXPORT_WASM_API(wasm_cb_native_call),
|
||||
EXPORT_WASM_API_WITH_SIG(wasm_cb_native_call, "(i*i)"),
|
||||
|
||||
@ -6,6 +6,7 @@ set (WASM_LIB_GUI_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
set (DEPS_DIR ${WASM_LIB_GUI_DIR}/../../../deps)
|
||||
|
||||
add_definitions(-DLV_CONF_INCLUDE_SIMPLE)
|
||||
add_definitions (-DAPP_FRAMEWORK_WGL)
|
||||
|
||||
include_directories(${WASM_LIB_GUI_DIR}
|
||||
${DEPS_DIR}
|
||||
|
||||
@ -126,7 +126,7 @@ static WGLNativeFuncDef btn_native_func_defs[] = {
|
||||
/*************** Native Interface to Wasm App ***********/
|
||||
void
|
||||
wasm_btn_native_call(wasm_exec_env_t exec_env,
|
||||
int32 func_id, uint32 argv_offset, uint32 argc)
|
||||
int32 func_id, uint32 *argv, uint32 argc)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
uint32 size = sizeof(btn_native_func_defs) / sizeof(WGLNativeFuncDef);
|
||||
@ -135,6 +135,6 @@ wasm_btn_native_call(wasm_exec_env_t exec_env,
|
||||
btn_native_func_defs,
|
||||
size,
|
||||
func_id,
|
||||
argv_offset,
|
||||
argv,
|
||||
argc);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ static WGLNativeFuncDef cb_native_func_defs[] = {
|
||||
/*************** Native Interface to Wasm App ***********/
|
||||
void
|
||||
wasm_cb_native_call(wasm_exec_env_t exec_env,
|
||||
int32 func_id, uint32 argv_offset, uint32 argc)
|
||||
int32 func_id, uint32 *argv, uint32 argc)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
uint32 size = sizeof(cb_native_func_defs) / sizeof(WGLNativeFuncDef);
|
||||
@ -82,6 +82,6 @@ wasm_cb_native_call(wasm_exec_env_t exec_env,
|
||||
cb_native_func_defs,
|
||||
size,
|
||||
func_id,
|
||||
argv_offset,
|
||||
argv,
|
||||
argc);
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ static WGLNativeFuncDef label_native_func_defs[] = {
|
||||
/*************** Native Interface to Wasm App ***********/
|
||||
void
|
||||
wasm_label_native_call(wasm_exec_env_t exec_env,
|
||||
int32 func_id, uint32 argv_offset, uint32 argc)
|
||||
int32 func_id, uint32 *argv, uint32 argc)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
uint32 size = sizeof(label_native_func_defs) / sizeof(WGLNativeFuncDef);
|
||||
@ -73,6 +73,6 @@ wasm_label_native_call(wasm_exec_env_t exec_env,
|
||||
label_native_func_defs,
|
||||
size,
|
||||
func_id,
|
||||
argv_offset,
|
||||
argv,
|
||||
argc);
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ static WGLNativeFuncDef list_native_func_defs[] = {
|
||||
/*************** Native Interface to Wasm App ***********/
|
||||
void
|
||||
wasm_list_native_call(wasm_exec_env_t exec_env,
|
||||
int32 func_id, uint32 argv_offset, uint32 argc)
|
||||
int32 func_id, uint32 *argv, uint32 argc)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
uint32 size = sizeof(list_native_func_defs) / sizeof(WGLNativeFuncDef);
|
||||
@ -58,6 +58,6 @@ wasm_list_native_call(wasm_exec_env_t exec_env,
|
||||
list_native_func_defs,
|
||||
size,
|
||||
func_id,
|
||||
argv_offset,
|
||||
argv,
|
||||
argc);
|
||||
}
|
||||
|
||||
@ -109,17 +109,11 @@ void wgl_native_func_call(wasm_module_inst_t module_inst,
|
||||
WGLNativeFuncDef *funcs,
|
||||
uint32 size,
|
||||
int32 func_id,
|
||||
uint32 argv_offset,
|
||||
uint32 *argv,
|
||||
uint32 argc)
|
||||
{
|
||||
WGLNativeFuncDef *func_def = funcs;
|
||||
WGLNativeFuncDef *func_def_end = func_def + size;
|
||||
uint32 *argv;
|
||||
|
||||
if (!validate_app_addr(argv_offset, argc * sizeof(uint32)))
|
||||
return;
|
||||
|
||||
argv = addr_app_to_native(argv_offset);
|
||||
|
||||
while (func_def < func_def_end) {
|
||||
if (func_def->func_id == func_id) {
|
||||
|
||||
@ -74,7 +74,7 @@ void wgl_native_func_call(wasm_module_inst_t module_inst,
|
||||
WGLNativeFuncDef *funcs,
|
||||
uint32 size,
|
||||
int32 func_id,
|
||||
uint32 argv_offset,
|
||||
uint32 *argv,
|
||||
uint32 argc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -378,7 +378,7 @@ static WGLNativeFuncDef obj_native_func_defs[] = {
|
||||
/*************** Native Interface to Wasm App ***********/
|
||||
void
|
||||
wasm_obj_native_call(wasm_exec_env_t exec_env,
|
||||
int32 func_id, uint32 argv_offset, uint32 argc)
|
||||
int32 func_id, uint32 *argv, uint32 argc)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
uint32 size = sizeof(obj_native_func_defs) / sizeof(WGLNativeFuncDef);
|
||||
@ -387,6 +387,6 @@ wasm_obj_native_call(wasm_exec_env_t exec_env,
|
||||
obj_native_func_defs,
|
||||
size,
|
||||
func_id,
|
||||
argv_offset,
|
||||
argv,
|
||||
argc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user