Apply clang-format for more source files (#795)

Apply clang-format for C source files in folder core/app-mgr,
core/app-framework, and test-tools.
And rename folder component_test to component-test, update
zephyr build document.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
Wenyong Huang
2021-10-21 13:58:34 +08:00
committed by GitHub
parent 225f5d0a64
commit 32242988ed
143 changed files with 5377 additions and 4627 deletions

View File

@ -13,34 +13,32 @@
extern "C" {
#endif
/**
* gui interfaces
*/
void
wasm_obj_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 *argv, uint32 argc);
wasm_obj_native_call(wasm_exec_env_t exec_env, int32 func_id, uint32 *argv,
uint32 argc);
void
wasm_btn_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 *argv, uint32 argc);
wasm_btn_native_call(wasm_exec_env_t exec_env, int32 func_id, uint32 *argv,
uint32 argc);
void
wasm_label_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 *argv, uint32 argc);
wasm_label_native_call(wasm_exec_env_t exec_env, int32 func_id, uint32 *argv,
uint32 argc);
void
wasm_cb_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 *argv, uint32 argc);
wasm_cb_native_call(wasm_exec_env_t exec_env, int32 func_id, uint32 *argv,
uint32 argc);
void
wasm_list_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 *argv, uint32 argc);
wasm_list_native_call(wasm_exec_env_t exec_env, int32 func_id, uint32 *argv,
uint32 argc);
#ifdef __cplusplus
}
#endif
#endif /* end of _GUI_API_H_ */

View File

@ -10,8 +10,10 @@
extern "C" {
#endif
void wgl_init(void);
void wgl_exit(void);
void
wgl_init(void);
void
wgl_exit(void);
#ifdef __cplusplus
}

View File

@ -19,7 +19,8 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_btn_create_wrapper)
wgl_native_get_arg(uint32, copy_obj_id);
wasm_module_inst_t module_inst = get_module_inst(exec_env);
res = wgl_native_wigdet_create(WIDGET_TYPE_BTN, par_obj_id, copy_obj_id, module_inst);
res = wgl_native_wigdet_create(WIDGET_TYPE_BTN, par_obj_id, copy_obj_id,
module_inst);
wgl_native_set_return(res);
}
@ -131,33 +132,30 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_btn_toggle_wrapper)
lv_btn_toggle(btn);
}
/* clang-format off */
static WGLNativeFuncDef btn_native_func_defs[] = {
{ BTN_FUNC_ID_CREATE, lv_btn_create_wrapper, 2, false },
{ BTN_FUNC_ID_SET_TOGGLE, lv_btn_set_toggle_wrapper, 2, true },
{ BTN_FUNC_ID_SET_STATE, lv_btn_set_state_wrapper, 2, true },
{ BTN_FUNC_ID_SET_INK_IN_TIME, lv_btn_set_ink_in_time_wrapper, 2, true },
{ BTN_FUNC_ID_SET_INK_OUT_TIME, lv_btn_set_ink_out_time_wrapper, 2, true },
{ BTN_FUNC_ID_SET_INK_WAIT_TIME, lv_btn_set_ink_wait_time_wrapper, 2, true },
{ BTN_FUNC_ID_GET_INK_IN_TIME, lv_btn_get_ink_in_time_wrapper, 1, true },
{ BTN_FUNC_ID_GET_INK_OUT_TIME, lv_btn_get_ink_out_time_wrapper, 1, true },
{ BTN_FUNC_ID_GET_INK_WAIT_TIME, lv_btn_get_ink_wait_time_wrapper, 1, true },
{ BTN_FUNC_ID_GET_STATE, lv_btn_get_state_wrapper, 1, true },
{ BTN_FUNC_ID_GET_TOGGLE, lv_btn_get_toggle_wrapper, 1, true },
{ BTN_FUNC_ID_TOGGLE, lv_btn_toggle_wrapper, 1, true },
{ BTN_FUNC_ID_CREATE, lv_btn_create_wrapper, 2, false },
{ BTN_FUNC_ID_SET_TOGGLE, lv_btn_set_toggle_wrapper, 2, true },
{ BTN_FUNC_ID_SET_STATE, lv_btn_set_state_wrapper, 2, true },
{ BTN_FUNC_ID_SET_INK_IN_TIME, lv_btn_set_ink_in_time_wrapper, 2, true },
{ BTN_FUNC_ID_SET_INK_OUT_TIME, lv_btn_set_ink_out_time_wrapper, 2, true },
{ BTN_FUNC_ID_SET_INK_WAIT_TIME, lv_btn_set_ink_wait_time_wrapper, 2, true },
{ BTN_FUNC_ID_GET_INK_IN_TIME, lv_btn_get_ink_in_time_wrapper, 1, true },
{ BTN_FUNC_ID_GET_INK_OUT_TIME, lv_btn_get_ink_out_time_wrapper, 1, true },
{ BTN_FUNC_ID_GET_INK_WAIT_TIME, lv_btn_get_ink_wait_time_wrapper, 1, true },
{ BTN_FUNC_ID_GET_STATE, lv_btn_get_state_wrapper, 1, true },
{ BTN_FUNC_ID_GET_TOGGLE, lv_btn_get_toggle_wrapper, 1, true },
{ BTN_FUNC_ID_TOGGLE, lv_btn_toggle_wrapper, 1, true },
};
/* clang-format on */
/*************** Native Interface to Wasm App ***********/
void
wasm_btn_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 *argv, uint32 argc)
wasm_btn_native_call(wasm_exec_env_t exec_env, int32 func_id, uint32 *argv,
uint32 argc)
{
uint32 size = sizeof(btn_native_func_defs) / sizeof(WGLNativeFuncDef);
wgl_native_func_call(exec_env,
btn_native_func_defs,
size,
func_id,
argv,
wgl_native_func_call(exec_env, btn_native_func_defs, size, func_id, argv,
argc);
}

View File

@ -20,7 +20,8 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_cb_create_wrapper)
wgl_native_get_arg(uint32, copy_obj_id);
wasm_module_inst_t module_inst = get_module_inst(exec_env);
res = wgl_native_wigdet_create(WIDGET_TYPE_CB, par_obj_id, copy_obj_id, module_inst);
res = wgl_native_wigdet_create(WIDGET_TYPE_CB, par_obj_id, copy_obj_id,
module_inst);
wgl_native_set_return(res);
}
@ -63,7 +64,7 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_cb_get_text_length_wrapper)
(void)exec_env;
text = lv_cb_get_text(cb);
wgl_native_set_return(text ? strlen(text): 0);
wgl_native_set_return(text ? strlen(text) : 0);
}
DEFINE_WGL_NATIVE_WRAPPER(lv_cb_get_text_wrapper)
@ -89,24 +90,20 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_cb_get_text_wrapper)
}
static WGLNativeFuncDef cb_native_func_defs[] = {
{ CB_FUNC_ID_CREATE, lv_cb_create_wrapper, 2, false },
{ CB_FUNC_ID_SET_TEXT, lv_cb_set_text_wrapper, 3, true },
{ CB_FUNC_ID_SET_STATIC_TEXT, lv_cb_set_static_text_wrapper, 3, true },
{ CB_FUNC_ID_GET_TEXT_LENGTH, lv_cb_get_text_length_wrapper, 1, true },
{ CB_FUNC_ID_GET_TEXT, lv_cb_get_text_wrapper, 3, true },
{ CB_FUNC_ID_CREATE, lv_cb_create_wrapper, 2, false },
{ CB_FUNC_ID_SET_TEXT, lv_cb_set_text_wrapper, 3, true },
{ CB_FUNC_ID_SET_STATIC_TEXT, lv_cb_set_static_text_wrapper, 3, true },
{ CB_FUNC_ID_GET_TEXT_LENGTH, lv_cb_get_text_length_wrapper, 1, true },
{ CB_FUNC_ID_GET_TEXT, lv_cb_get_text_wrapper, 3, true },
};
/*************** Native Interface to Wasm App ***********/
void
wasm_cb_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 *argv, uint32 argc)
wasm_cb_native_call(wasm_exec_env_t exec_env, int32 func_id, uint32 *argv,
uint32 argc)
{
uint32 size = sizeof(cb_native_func_defs) / sizeof(WGLNativeFuncDef);
wgl_native_func_call(exec_env,
cb_native_func_defs,
size,
func_id,
argv,
wgl_native_func_call(exec_env, cb_native_func_defs, size, func_id, argv,
argc);
}

View File

@ -20,7 +20,8 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_label_create_wrapper)
wgl_native_get_arg(uint32, copy_obj_id);
wasm_module_inst_t module_inst = get_module_inst(exec_env);
res = wgl_native_wigdet_create(WIDGET_TYPE_LABEL, par_obj_id, copy_obj_id, module_inst);
res = wgl_native_wigdet_create(WIDGET_TYPE_LABEL, par_obj_id, copy_obj_id,
module_inst);
wgl_native_set_return(res);
}
@ -73,24 +74,22 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_label_get_text_wrapper)
wgl_native_set_return(buffer_offset);
}
/* clang-format off */
static WGLNativeFuncDef label_native_func_defs[] = {
{ LABEL_FUNC_ID_CREATE, lv_label_create_wrapper, 2, false },
{ LABEL_FUNC_ID_SET_TEXT, lv_label_set_text_wrapper, 3, true },
{ LABEL_FUNC_ID_GET_TEXT_LENGTH, lv_label_get_text_length_wrapper, 1, true },
{ LABEL_FUNC_ID_GET_TEXT, lv_label_get_text_wrapper, 3, true },
{ LABEL_FUNC_ID_CREATE, lv_label_create_wrapper, 2, false },
{ LABEL_FUNC_ID_SET_TEXT, lv_label_set_text_wrapper, 3, true },
{ LABEL_FUNC_ID_GET_TEXT_LENGTH, lv_label_get_text_length_wrapper, 1, true },
{ LABEL_FUNC_ID_GET_TEXT, lv_label_get_text_wrapper, 3, true },
};
/* clang-format on */
/*************** Native Interface to Wasm App ***********/
void
wasm_label_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 *argv, uint32 argc)
wasm_label_native_call(wasm_exec_env_t exec_env, int32 func_id, uint32 *argv,
uint32 argc)
{
uint32 size = sizeof(label_native_func_defs) / sizeof(WGLNativeFuncDef);
wgl_native_func_call(exec_env,
label_native_func_defs,
size,
func_id,
argv,
wgl_native_func_call(exec_env, label_native_func_defs, size, func_id, argv,
argc);
}

View File

@ -20,7 +20,8 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_list_create_wrapper)
wgl_native_get_arg(uint32, copy_obj_id);
wasm_module_inst_t module_inst = get_module_inst(exec_env);
res = wgl_native_wigdet_create(WIDGET_TYPE_LIST, par_obj_id, copy_obj_id, module_inst);
res = wgl_native_wigdet_create(WIDGET_TYPE_LIST, par_obj_id, copy_obj_id,
module_inst);
wgl_native_set_return(res);
}
@ -49,7 +50,8 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_list_add_btn_wrapper)
bh_assert(mod_id != ID_NONE);
if (!wgl_native_add_object(btn, mod_id, &btn_obj_id)) {
wasm_runtime_set_exception(module_inst, "add button to object list fail.");
wasm_runtime_set_exception(module_inst,
"add button to object list fail.");
return;
}
@ -57,21 +59,17 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_list_add_btn_wrapper)
}
static WGLNativeFuncDef list_native_func_defs[] = {
{ LIST_FUNC_ID_CREATE, lv_list_create_wrapper, 2, false },
{ LIST_FUNC_ID_ADD_BTN, lv_list_add_btn_wrapper, 3, true },
{ LIST_FUNC_ID_CREATE, lv_list_create_wrapper, 2, false },
{ LIST_FUNC_ID_ADD_BTN, lv_list_add_btn_wrapper, 3, true },
};
/*************** Native Interface to Wasm App ***********/
void
wasm_list_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 *argv, uint32 argc)
wasm_list_native_call(wasm_exec_env_t exec_env, int32 func_id, uint32 *argv,
uint32 argc)
{
uint32 size = sizeof(list_native_func_defs) / sizeof(WGLNativeFuncDef);
wgl_native_func_call(exec_env,
list_native_func_defs,
size,
func_id,
argv,
wgl_native_func_call(exec_env, list_native_func_defs, size, func_id, argv,
argc);
}

View File

@ -10,16 +10,15 @@
#define THROW_EXC(msg) wasm_runtime_set_exception(module_inst, msg);
uint32 wgl_native_wigdet_create(int8 widget_type,
uint32 par_obj_id,
uint32 copy_obj_id,
wasm_module_inst_t module_inst)
uint32
wgl_native_wigdet_create(int8 widget_type, uint32 par_obj_id,
uint32 copy_obj_id, wasm_module_inst_t module_inst)
{
uint32 obj_id;
lv_obj_t *wigdet = NULL, *par = NULL, *copy = NULL;
uint32 mod_id;
//TODO: limit total widget number
// TODO: limit total widget number
/* validate the parent object id if not equal to 0 */
if (par_obj_id != 0 && !wgl_native_validate_object(par_obj_id, &par)) {
@ -58,14 +57,11 @@ uint32 wgl_native_wigdet_create(int8 widget_type,
return 0;
}
void wgl_native_func_call(wasm_exec_env_t exec_env,
WGLNativeFuncDef *funcs,
uint32 size,
int32 func_id,
uint32 *argv,
uint32 argc)
void
wgl_native_func_call(wasm_exec_env_t exec_env, WGLNativeFuncDef *funcs,
uint32 size, int32 func_id, uint32 *argv, uint32 argc)
{
typedef void (*WGLNativeFuncPtr)(wasm_exec_env_t, uint64*, uint32*);
typedef void (*WGLNativeFuncPtr)(wasm_exec_env_t, uint64 *, uint32 *);
WGLNativeFuncPtr wglNativeFuncPtr;
wasm_module_inst_t module_inst = get_module_inst(exec_env);
WGLNativeFuncDef *func_def = funcs;
@ -74,12 +70,12 @@ void wgl_native_func_call(wasm_exec_env_t exec_env,
/* Note: argv is validated in wasm_runtime_invoke_native()
* with pointer length equals to 1. Here validate the argv
* buffer again but with its total length in bytes */
if (!wasm_runtime_validate_native_addr(module_inst, argv, argc * sizeof(uint32)))
if (!wasm_runtime_validate_native_addr(module_inst, argv,
argc * sizeof(uint32)))
return;
while (func_def < func_def_end) {
if (func_def->func_id == func_id
&& (uint32)func_def->arg_num == argc) {
if (func_def->func_id == func_id && (uint32)func_def->arg_num == argc) {
uint64 argv_copy_buf[16], size;
uint64 *argv_copy = argv_copy_buf;
int i;
@ -96,7 +92,7 @@ void wgl_native_func_call(wasm_exec_env_t exec_env,
/* Init argv_copy */
for (i = 0; i < func_def->arg_num; i++)
*(uint32*)&argv_copy[i] = argv[i];
*(uint32 *)&argv_copy[i] = argv[i];
/* Validate the first argument which is a lvgl object if needed */
if (func_def->check_obj) {
@ -128,4 +124,3 @@ void wgl_native_func_call(wasm_exec_env_t exec_env,
THROW_EXC("the native widget function is not found!");
}

View File

@ -15,21 +15,22 @@ extern "C" {
#include "wasm_export.h"
#include "bi-inc/wgl_shared_utils.h"
#define wgl_native_return_type(type) type *wgl_ret = (type*)(args_ret)
#define wgl_native_get_arg(type, name) type name = *((type*)(args++))
#define wgl_native_return_type(type) type *wgl_ret = (type *)(args_ret)
#define wgl_native_get_arg(type, name) type name = *((type *)(args++))
#define wgl_native_set_return(val) *wgl_ret = (val)
#define DEFINE_WGL_NATIVE_WRAPPER(func_name) \
static void func_name(wasm_exec_env_t exec_env, uint64 *args, uint32 *args_ret)
#define DEFINE_WGL_NATIVE_WRAPPER(func_name) \
static void func_name(wasm_exec_env_t exec_env, uint64 *args, \
uint32 *args_ret)
enum {
WIDGET_TYPE_BTN,
WIDGET_TYPE_LABEL,
WIDGET_TYPE_CB,
WIDGET_TYPE_LIST,
WIDGET_TYPE_DDLIST,
WIDGET_TYPE_BTN,
WIDGET_TYPE_LABEL,
WIDGET_TYPE_CB,
WIDGET_TYPE_LIST,
WIDGET_TYPE_DDLIST,
_WIDGET_TYPE_NUM,
_WIDGET_TYPE_NUM,
};
typedef struct WGLNativeFuncDef {
@ -46,21 +47,19 @@ typedef struct WGLNativeFuncDef {
bool check_obj;
} WGLNativeFuncDef;
bool wgl_native_validate_object(int32 obj_id, lv_obj_t **obj);
bool
wgl_native_validate_object(int32 obj_id, lv_obj_t **obj);
bool wgl_native_add_object(lv_obj_t *obj, uint32 module_id, uint32 *obj_id);
bool
wgl_native_add_object(lv_obj_t *obj, uint32 module_id, uint32 *obj_id);
uint32 wgl_native_wigdet_create(int8 widget_type,
uint32 par_obj_id,
uint32 copy_obj_id,
wasm_module_inst_t module_inst);
uint32
wgl_native_wigdet_create(int8 widget_type, uint32 par_obj_id,
uint32 copy_obj_id, wasm_module_inst_t module_inst);
void wgl_native_func_call(wasm_exec_env_t exec_env,
WGLNativeFuncDef *funcs,
uint32 size,
int32 func_id,
uint32 *argv,
uint32 argc);
void
wgl_native_func_call(wasm_exec_env_t exec_env, WGLNativeFuncDef *funcs,
uint32 size, int32 func_id, uint32 *argv, uint32 argc);
#ifdef __cplusplus
}

View File

@ -10,7 +10,6 @@
#include "wgl_native_utils.h"
#include "wgl.h"
typedef struct {
bh_list_link l;
@ -42,24 +41,24 @@ static korp_mutex task_handler_lock;
static korp_cond task_handler_cond;
static void app_mgr_object_event_callback(module_data *m_data, bh_message_t msg)
static void
app_mgr_object_event_callback(module_data *m_data, bh_message_t msg)
{
uint32 argv[2];
wasm_function_inst_t func_on_object_event;
bh_assert(WIDGET_EVENT_WASM == bh_message_type(msg));
wasm_data *wasm_app_data = (wasm_data*)m_data->internal_data;
wasm_data *wasm_app_data = (wasm_data *)m_data->internal_data;
wasm_module_inst_t inst = wasm_app_data->wasm_module_inst;
object_event_t *object_event
= (object_event_t *)bh_message_payload(msg);
object_event_t *object_event = (object_event_t *)bh_message_payload(msg);
if (object_event == NULL)
return;
func_on_object_event = wasm_runtime_lookup_function(inst, "_on_widget_event",
"(i32i32)");
func_on_object_event =
wasm_runtime_lookup_function(inst, "_on_widget_event", "(i32i32)");
if (!func_on_object_event)
func_on_object_event = wasm_runtime_lookup_function(inst, "on_widget_event",
"(i32i32)");
func_on_object_event =
wasm_runtime_lookup_function(inst, "on_widget_event", "(i32i32)");
if (!func_on_object_event) {
printf("Cannot find function on_widget_event\n");
return;
@ -71,14 +70,14 @@ static void app_mgr_object_event_callback(module_data *m_data, bh_message_t msg)
2, argv)) {
const char *exception = wasm_runtime_get_exception(inst);
bh_assert(exception);
printf(":Got exception running wasm code: %s\n",
exception);
printf(":Got exception running wasm code: %s\n", exception);
wasm_runtime_clear_exception(inst);
return;
}
}
static void cleanup_object_list(uint32 module_id)
static void
cleanup_object_list(uint32 module_id)
{
object_node_t *elem;
@ -89,8 +88,8 @@ static void cleanup_object_list(uint32 module_id)
elem = (object_node_t *)bh_list_first_elem(&g_object_list);
while (elem) {
/* delete the leaf node belongs to the module firstly */
if (module_id == elem->module_id &&
lv_obj_count_children(elem->obj) == 0) {
if (module_id == elem->module_id
&& lv_obj_count_children(elem->obj) == 0) {
object_node_t *next = (object_node_t *)bh_list_elem_next(elem);
found = true;
@ -98,7 +97,8 @@ static void cleanup_object_list(uint32 module_id)
bh_list_remove(&g_object_list, elem);
wasm_runtime_free(elem);
elem = next;
} else {
}
else {
elem = (object_node_t *)bh_list_elem_next(elem);
}
}
@ -110,7 +110,8 @@ static void cleanup_object_list(uint32 module_id)
os_mutex_unlock(&g_object_list_mutex);
}
static bool init_object_event_callback_framework()
static bool
init_object_event_callback_framework()
{
if (!wasm_register_cleanup_callback(cleanup_object_list)) {
goto fail;
@ -127,7 +128,8 @@ fail:
return false;
}
bool wgl_native_validate_object(int32 obj_id, lv_obj_t **obj)
bool
wgl_native_validate_object(int32 obj_id, lv_obj_t **obj)
{
object_node_t *elem;
@ -141,7 +143,7 @@ bool wgl_native_validate_object(int32 obj_id, lv_obj_t **obj)
os_mutex_unlock(&g_object_list_mutex);
return true;
}
elem = (object_node_t *) bh_list_elem_next(elem);
elem = (object_node_t *)bh_list_elem_next(elem);
}
os_mutex_unlock(&g_object_list_mutex);
@ -149,11 +151,12 @@ bool wgl_native_validate_object(int32 obj_id, lv_obj_t **obj)
return false;
}
bool wgl_native_add_object(lv_obj_t *obj, uint32 module_id, uint32 *obj_id)
bool
wgl_native_add_object(lv_obj_t *obj, uint32 module_id, uint32 *obj_id)
{
object_node_t *node;
node = (object_node_t *) wasm_runtime_malloc(sizeof(object_node_t));
node = (object_node_t *)wasm_runtime_malloc(sizeof(object_node_t));
if (node == NULL)
return false;
@ -178,11 +181,12 @@ bool wgl_native_add_object(lv_obj_t *obj, uint32 module_id, uint32 *obj_id)
return true;
}
static void _obj_del_recursive(lv_obj_t *obj)
static void
_obj_del_recursive(lv_obj_t *obj)
{
object_node_t *elem;
lv_obj_t * i;
lv_obj_t * i_next;
lv_obj_t *i;
lv_obj_t *i_next;
i = lv_ll_get_head(&(obj->child_ll));
@ -207,16 +211,17 @@ static void _obj_del_recursive(lv_obj_t *obj)
os_mutex_unlock(&g_object_list_mutex);
return;
}
elem = (object_node_t *) bh_list_elem_next(elem);
elem = (object_node_t *)bh_list_elem_next(elem);
}
os_mutex_unlock(&g_object_list_mutex);
}
static void _obj_clean_recursive(lv_obj_t *obj)
static void
_obj_clean_recursive(lv_obj_t *obj)
{
lv_obj_t * i;
lv_obj_t * i_next;
lv_obj_t *i;
lv_obj_t *i_next;
i = lv_ll_get_head(&(obj->child_ll));
@ -232,7 +237,8 @@ static void _obj_clean_recursive(lv_obj_t *obj)
}
}
static void post_widget_msg_to_module(object_node_t *object_node, lv_event_t event)
static void
post_widget_msg_to_module(object_node_t *object_node, lv_event_t event)
{
module_data *module = module_data_list_lookup_id(object_node->module_id);
object_event_t *object_event;
@ -248,13 +254,12 @@ static void post_widget_msg_to_module(object_node_t *object_node, lv_event_t eve
object_event->obj_id = object_node->obj_id;
object_event->event = event;
bh_post_msg(module->queue,
WIDGET_EVENT_WASM,
object_event,
bh_post_msg(module->queue, WIDGET_EVENT_WASM, object_event,
sizeof(*object_event));
}
static void internal_lv_obj_event_cb(lv_obj_t *obj, lv_event_t event)
static void
internal_lv_obj_event_cb(lv_obj_t *obj, lv_event_t event)
{
object_node_t *elem;
@ -267,13 +272,14 @@ static void internal_lv_obj_event_cb(lv_obj_t *obj, lv_event_t event)
os_mutex_unlock(&g_object_list_mutex);
return;
}
elem = (object_node_t *) bh_list_elem_next(elem);
elem = (object_node_t *)bh_list_elem_next(elem);
}
os_mutex_unlock(&g_object_list_mutex);
}
static void* lv_task_handler_thread_routine (void *arg)
static void *
lv_task_handler_thread_routine(void *arg)
{
os_mutex_lock(&task_handler_lock);
@ -287,7 +293,8 @@ static void* lv_task_handler_thread_routine (void *arg)
return NULL;
}
void wgl_init(void)
void
wgl_init(void)
{
korp_tid tid;
@ -306,13 +313,12 @@ void wgl_init(void)
init_object_event_callback_framework();
/* new a thread, call lv_task_handler periodically */
os_thread_create(&tid,
lv_task_handler_thread_routine,
NULL,
os_thread_create(&tid, lv_task_handler_thread_routine, NULL,
BH_APPLET_PRESERVED_STACK_SIZE);
}
void wgl_exit(void)
void
wgl_exit(void)
{
lv_task_handler_thread_run = false;
os_cond_destroy(&task_handler_cond);
@ -371,7 +377,8 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_obj_align_wrapper)
/* validate the base object id if not equal to 0 */
if (base_obj_id != 0 && !wgl_native_validate_object(base_obj_id, &base)) {
wasm_runtime_set_exception(module_inst, "align with invalid base object.");
wasm_runtime_set_exception(module_inst,
"align with invalid base object.");
return;
}
@ -388,24 +395,20 @@ DEFINE_WGL_NATIVE_WRAPPER(lv_obj_set_event_cb_wrapper)
/* ------------------------------------------------------------------------- */
static WGLNativeFuncDef obj_native_func_defs[] = {
{ OBJ_FUNC_ID_DEL, lv_obj_del_wrapper, 1, true },
{ OBJ_FUNC_ID_DEL_ASYNC, lv_obj_del_async_wrapper, 1, true },
{ OBJ_FUNC_ID_CLEAN, lv_obj_clean_wrapper, 1, true },
{ OBJ_FUNC_ID_ALIGN, lv_obj_align_wrapper, 5, true },
{ OBJ_FUNC_ID_SET_EVT_CB, lv_obj_set_event_cb_wrapper, 1, true },
{ OBJ_FUNC_ID_DEL, lv_obj_del_wrapper, 1, true },
{ OBJ_FUNC_ID_DEL_ASYNC, lv_obj_del_async_wrapper, 1, true },
{ OBJ_FUNC_ID_CLEAN, lv_obj_clean_wrapper, 1, true },
{ OBJ_FUNC_ID_ALIGN, lv_obj_align_wrapper, 5, true },
{ OBJ_FUNC_ID_SET_EVT_CB, lv_obj_set_event_cb_wrapper, 1, true },
};
/*************** Native Interface to Wasm App ***********/
void
wasm_obj_native_call(wasm_exec_env_t exec_env,
int32 func_id, uint32 *argv, uint32 argc)
wasm_obj_native_call(wasm_exec_env_t exec_env, int32 func_id, uint32 *argv,
uint32 argc)
{
uint32 size = sizeof(obj_native_func_defs) / sizeof(WGLNativeFuncDef);
wgl_native_func_call(exec_env,
obj_native_func_defs,
size,
func_id,
argv,
wgl_native_func_call(exec_env, obj_native_func_defs, size, func_id, argv,
argc);
}