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

@ -28,10 +28,8 @@ wasm_cb_native_call(int32 func_id, uint32 *argv, uint32 argc);
void
wasm_list_native_call(int32 func_id, uint32 *argv, uint32 argc);
#ifdef __cplusplus
}
#endif
#endif /* end of _GUI_API_H_ */

View File

@ -7,12 +7,13 @@
#include "bh_platform.h"
#include "gui_api.h"
#define ARGC sizeof(argv)/sizeof(uint32)
#define ARGC sizeof(argv) / sizeof(uint32)
#define CALL_BTN_NATIVE_FUNC(id) wasm_btn_native_call(id, argv, ARGC)
lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t *
lv_btn_create(lv_obj_t *par, const lv_obj_t *copy)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
@ -20,100 +21,113 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
return (lv_obj_t *)argv[0];
}
void lv_btn_set_toggle(lv_obj_t * btn, bool tgl)
void
lv_btn_set_toggle(lv_obj_t *btn, bool tgl)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)btn;
argv[1] = tgl;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_TOGGLE);
}
void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
void
lv_btn_set_state(lv_obj_t *btn, lv_btn_state_t state)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)btn;
argv[1] = state;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_STATE);
}
void lv_btn_toggle(lv_obj_t * btn)
void
lv_btn_toggle(lv_obj_t *btn)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_TOGGLE);
}
void lv_btn_set_ink_in_time(lv_obj_t * btn, uint16_t time)
void
lv_btn_set_ink_in_time(lv_obj_t *btn, uint16_t time)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)btn;
argv[1] = time;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_IN_TIME);
}
void lv_btn_set_ink_wait_time(lv_obj_t * btn, uint16_t time)
void
lv_btn_set_ink_wait_time(lv_obj_t *btn, uint16_t time)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)btn;
argv[1] = time;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_WAIT_TIME);
}
void lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time)
void
lv_btn_set_ink_out_time(lv_obj_t *btn, uint16_t time)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)btn;
argv[1] = time;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_OUT_TIME);
}
//void wgl_btn_set_style(wgl_obj_t btn, wgl_btn_style_t type, const wgl_style_t * style)
// void wgl_btn_set_style(wgl_obj_t btn, wgl_btn_style_t type,
// const wgl_style_t *style)
//{
// //TODO: pack style
// //wasm_btn_set_style(btn, type, style);
//}
//
lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn)
lv_btn_state_t
lv_btn_get_state(const lv_obj_t *btn)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_STATE);
return (lv_btn_state_t)argv[0];
}
bool lv_btn_get_toggle(const lv_obj_t * btn)
bool
lv_btn_get_toggle(const lv_obj_t *btn)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_TOGGLE);
return (bool)argv[0];
}
uint16_t lv_btn_get_ink_in_time(const lv_obj_t * btn)
uint16_t
lv_btn_get_ink_in_time(const lv_obj_t *btn)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_INK_IN_TIME);
return (uint16_t)argv[0];
}
uint16_t lv_btn_get_ink_wait_time(const lv_obj_t * btn)
uint16_t
lv_btn_get_ink_wait_time(const lv_obj_t *btn)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_INK_WAIT_TIME);
return (uint16_t)argv[0];
}
uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn)
uint16_t
lv_btn_get_ink_out_time(const lv_obj_t *btn)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_INK_OUT_TIME);
return (uint16_t)argv[0];
}
//
//const wgl_style_t * wgl_btn_get_style(const wgl_obj_t btn, wgl_btn_style_t type)
// const wgl_style_t * wgl_btn_get_style(const wgl_obj_t btn,
// wgl_btn_style_t type)
//{
// //TODO: pack style
// //wasm_btn_get_style(btn, type);

View File

@ -3,18 +3,18 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <string.h>
#define ARGC sizeof(argv)/sizeof(uint32)
#define ARGC sizeof(argv) / sizeof(uint32)
#define CALL_CB_NATIVE_FUNC(id) wasm_cb_native_call(id, argv, ARGC)
lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t *
lv_cb_create(lv_obj_t *par, const lv_obj_t *copy)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
@ -22,41 +22,46 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
return (lv_obj_t *)argv[0];
}
void lv_cb_set_text(lv_obj_t * cb, const char * txt)
void
lv_cb_set_text(lv_obj_t *cb, const char *txt)
{
uint32 argv[3] = {0};
uint32 argv[3] = { 0 };
argv[0] = (uint32)cb;
argv[1] = (uint32)txt;
argv[2] = strlen(txt) + 1;
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_SET_TEXT);
}
void lv_cb_set_static_text(lv_obj_t * cb, const char * txt)
void
lv_cb_set_static_text(lv_obj_t *cb, const char *txt)
{
uint32 argv[3] = {0};
uint32 argv[3] = { 0 };
argv[0] = (uint32)cb;
argv[1] = (uint32)txt;
argv[2] = strlen(txt) + 1;
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_SET_STATIC_TEXT);
}
//void wgl_cb_set_style(wgl_obj_t cb, wgl_cb_style_t type, const wgl_style_t * style)
// void wgl_cb_set_style(wgl_obj_t cb, wgl_cb_style_t type,
// const wgl_style_t *style)
//{
// //TODO:
//}
//
static unsigned int wgl_cb_get_text_length(lv_obj_t * cb)
static unsigned int
wgl_cb_get_text_length(lv_obj_t *cb)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)cb;
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_GET_TEXT_LENGTH);
return argv[0];
}
static char *wgl_cb_get_text(lv_obj_t * cb, char *buffer, int buffer_len)
static char *
wgl_cb_get_text(lv_obj_t *cb, char *buffer, int buffer_len)
{
uint32 argv[3] = {0};
uint32 argv[3] = { 0 };
argv[0] = (uint32)cb;
argv[1] = (uint32)buffer;
argv[2] = buffer_len;
@ -65,18 +70,17 @@ static char *wgl_cb_get_text(lv_obj_t * cb, char *buffer, int buffer_len)
}
// TODO: need to use a global data buffer for the returned text
const char * lv_cb_get_text(const lv_obj_t * cb)
const char *
lv_cb_get_text(const lv_obj_t *cb)
{
return NULL;
}
//const wgl_style_t * wgl_cb_get_style(const wgl_obj_t cb, wgl_cb_style_t type)
// const wgl_style_t * wgl_cb_get_style(const wgl_obj_t cb,
// wgl_cb_style_t type)
//{
// //TODO
// return NULL;
//}
//

View File

@ -3,19 +3,17 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <string.h>
#define ARGC sizeof(argv)/sizeof(uint32)
#define ARGC sizeof(argv) / sizeof(uint32)
#define CALL_LABEL_NATIVE_FUNC(id) wasm_label_native_call(id, argv, ARGC)
lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t *
lv_label_create(lv_obj_t *par, const lv_obj_t *copy)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
@ -23,109 +21,112 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
return (lv_obj_t *)argv[0];
}
void lv_label_set_text(lv_obj_t * label, const char * text)
void
lv_label_set_text(lv_obj_t *label, const char *text)
{
uint32 argv[3] = {0};
uint32 argv[3] = { 0 };
argv[0] = (uint32)label;
argv[1] = (uint32)text;
argv[2] = strlen(text) + 1;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_TEXT);
}
void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size)
void
lv_label_set_array_text(lv_obj_t *label, const char *array, uint16_t size)
{
uint32 argv[3] = {0};
uint32 argv[3] = { 0 };
argv[0] = (uint32)label;
argv[1] = (uint32)array;
argv[2] = size;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_ARRAY_TEXT);
}
void lv_label_set_static_text(lv_obj_t * label, const char * text)
void
lv_label_set_static_text(lv_obj_t *label, const char *text)
{
uint32 argv[3] = {0};
uint32 argv[3] = { 0 };
argv[0] = (uint32)label;
argv[1] = (uint32)text;
argv[2] = strlen(text) + 1;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_STATIC_TEXT);
}
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
void
lv_label_set_long_mode(lv_obj_t *label, lv_label_long_mode_t long_mode)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)label;
argv[1] = long_mode;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_LONG_MODE);
}
void lv_label_set_align(lv_obj_t * label, lv_label_align_t align)
void
lv_label_set_align(lv_obj_t *label, lv_label_align_t align)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)label;
argv[1] = align;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_ALIGN);
}
void lv_label_set_recolor(lv_obj_t * label, bool en)
void
lv_label_set_recolor(lv_obj_t *label, bool en)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)label;
argv[1] = en;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_RECOLOR);
}
void lv_label_set_body_draw(lv_obj_t * label, bool en)
void
lv_label_set_body_draw(lv_obj_t *label, bool en)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)label;
argv[1] = en;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_BODY_DRAW);
}
void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed)
void
lv_label_set_anim_speed(lv_obj_t *label, uint16_t anim_speed)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)label;
argv[1] = anim_speed;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_ANIM_SPEED);
}
void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index)
void
lv_label_set_text_sel_start(lv_obj_t *label, uint16_t index)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)label;
argv[1] = index;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_TEXT_SEL_START);
}
void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index)
void
lv_label_set_text_sel_end(lv_obj_t *label, uint16_t index)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)label;
argv[1] = index;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_TEXT_SEL_END);
}
unsigned int wgl_label_get_text_length(lv_obj_t * label)
unsigned int
wgl_label_get_text_length(lv_obj_t *label)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_TEXT_LENGTH);
return argv[0];
}
char * wgl_label_get_text(lv_obj_t * label, char *buffer, int buffer_len)
char *
wgl_label_get_text(lv_obj_t *label, char *buffer, int buffer_len)
{
uint32 argv[3] = {0};
uint32 argv[3] = { 0 };
argv[0] = (uint32)label;
argv[1] = (uint32)buffer;
argv[2] = buffer_len;
@ -133,63 +134,63 @@ char * wgl_label_get_text(lv_obj_t * label, char *buffer, int buffer_len)
return (char *)argv[0];
}
// TODO:
char * lv_label_get_text(const lv_obj_t * label)
// TODO:
char *
lv_label_get_text(const lv_obj_t *label)
{
return NULL;
}
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * label)
lv_label_long_mode_t
lv_label_get_long_mode(const lv_obj_t *label)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_LONG_MODE);
return (lv_label_long_mode_t)argv[0];
}
lv_label_align_t lv_label_get_align(const lv_obj_t * label)
lv_label_align_t
lv_label_get_align(const lv_obj_t *label)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_ALIGN);
return (lv_label_align_t)argv[0];
}
bool lv_label_get_recolor(const lv_obj_t * label)
bool
lv_label_get_recolor(const lv_obj_t *label)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_RECOLOR);
return (bool)argv[0];
}
bool lv_label_get_body_draw(const lv_obj_t * label)
bool
lv_label_get_body_draw(const lv_obj_t *label)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_BODY_DRAW);
return (bool)argv[0];
}
uint16_t lv_label_get_anim_speed(const lv_obj_t * label)
uint16_t
lv_label_get_anim_speed(const lv_obj_t *label)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_ANIM_SPEED);
return (uint16_t)argv[0];
}
void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t * pos)
void
lv_label_get_letter_pos(const lv_obj_t *label, uint16_t index, lv_point_t *pos)
{
uint32 argv[4] = {0};
uint32 argv[4] = { 0 };
argv[0] = (uint32)label;
argv[1] = index;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_LETTER_POS);
@ -197,10 +198,10 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t
pos->y = argv[3];
}
uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
uint16_t
lv_label_get_letter_on(const lv_obj_t *label, lv_point_t *pos)
{
uint32 argv[3] = {0};
uint32 argv[3] = { 0 };
argv[0] = (uint32)label;
argv[1] = pos->x;
argv[2] = pos->y;
@ -208,10 +209,10 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
return (uint16_t)argv[0];
}
bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
bool
lv_label_is_char_under_pos(const lv_obj_t *label, lv_point_t *pos)
{
uint32 argv[3] = {0};
uint32 argv[3] = { 0 };
argv[0] = (uint32)label;
argv[1] = pos->x;
argv[2] = pos->y;
@ -219,28 +220,28 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
return (bool)argv[0];
}
uint16_t lv_label_get_text_sel_start(const lv_obj_t * label)
uint16_t
lv_label_get_text_sel_start(const lv_obj_t *label)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_TEXT_SEL_START);
return (uint16_t)argv[0];
}
uint16_t lv_label_get_text_sel_end(const lv_obj_t * label)
uint16_t
lv_label_get_text_sel_end(const lv_obj_t *label)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_TEXT_SEL_END);
return (uint16_t)argv[0];
}
void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
void
lv_label_ins_text(lv_obj_t *label, uint32_t pos, const char *txt)
{
uint32 argv[4] = {0};
uint32 argv[4] = { 0 };
argv[0] = (uint32)label;
argv[1] = pos;
argv[2] = (uint32)txt;
@ -248,14 +249,12 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_INS_TEXT);
}
void lv_label_cut_text(lv_obj_t * label, uint32_t pos, uint32_t cnt)
void
lv_label_cut_text(lv_obj_t *label, uint32_t pos, uint32_t cnt)
{
uint32 argv[3] = {0};
uint32 argv[3] = { 0 };
argv[0] = (uint32)label;
argv[1] = pos;
argv[2] = cnt;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_CUT_TEXT);
}

View File

@ -3,19 +3,18 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <string.h>
#define ARGC sizeof(argv)/sizeof(uint32)
#define ARGC sizeof(argv) / sizeof(uint32)
#define CALL_LIST_NATIVE_FUNC(id) wasm_list_native_call(id, argv, ARGC)
lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t *
lv_list_create(lv_obj_t *par, const lv_obj_t *copy)
{
uint32 argv[2] = {0};
uint32 argv[2] = { 0 };
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
@ -25,15 +24,16 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
}
//
//
//void wgl_list_clean(wgl_obj_t obj)
// void wgl_list_clean(wgl_obj_t obj)
//{
// wasm_list_clean(obj);
//}
//
lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * txt)
lv_obj_t *
lv_list_add_btn(lv_obj_t *list, const void *img_src, const char *txt)
{
uint32 argv[3] = {0};
uint32 argv[3] = { 0 };
(void)img_src; /* doesn't support img src currently */
@ -45,13 +45,13 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
}
//
//
//bool wgl_list_remove(const wgl_obj_t list, uint16_t index)
// bool wgl_list_remove(const wgl_obj_t list, uint16_t index)
//{
// return wasm_list_remove(list, index);
//}
//
//
//void wgl_list_set_single_mode(wgl_obj_t list, bool mode)
// void wgl_list_set_single_mode(wgl_obj_t list, bool mode)
//{
// wasm_list_set_single_mode(list, mode);
//}
@ -59,68 +59,69 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
//#if LV_USE_GROUP
//
//
//void wgl_list_set_btn_selected(wgl_obj_t list, wgl_obj_t btn)
// void wgl_list_set_btn_selected(wgl_obj_t list, wgl_obj_t btn)
//{
// wasm_list_set_btn_selected(list, btn);
//}
//#endif
//
//
//void wgl_list_set_style(wgl_obj_t list, wgl_list_style_t type, const wgl_style_t * style)
// void wgl_list_set_style(wgl_obj_t list, wgl_list_style_t type,
// const wgl_style_t * style)
//{
// //TODO
//}
//
//
//bool wgl_list_get_single_mode(wgl_obj_t list)
// bool wgl_list_get_single_mode(wgl_obj_t list)
//{
// return wasm_list_get_single_mode(list);
//}
//
//
//const char * wgl_list_get_btn_text(const wgl_obj_t btn)
// const char * wgl_list_get_btn_text(const wgl_obj_t btn)
//{
// return wasm_list_get_btn_text(btn);
//}
//
//wgl_obj_t wgl_list_get_btn_label(const wgl_obj_t btn)
// wgl_obj_t wgl_list_get_btn_label(const wgl_obj_t btn)
//{
// return wasm_list_get_btn_label(btn);
//}
//
//
//wgl_obj_t wgl_list_get_btn_img(const wgl_obj_t btn)
// wgl_obj_t wgl_list_get_btn_img(const wgl_obj_t btn)
//{
// return wasm_list_get_btn_img(btn);
//}
//
//
//wgl_obj_t wgl_list_get_prev_btn(const wgl_obj_t list, wgl_obj_t prev_btn)
// wgl_obj_t wgl_list_get_prev_btn(const wgl_obj_t list, wgl_obj_t prev_btn)
//{
// return wasm_list_get_prev_btn(list, prev_btn);
//}
//
//
//wgl_obj_t wgl_list_get_next_btn(const wgl_obj_t list, wgl_obj_t prev_btn)
// wgl_obj_t wgl_list_get_next_btn(const wgl_obj_t list, wgl_obj_t prev_btn)
//{
// return wasm_list_get_next_btn(list, prev_btn);
//}
//
//
//int32_t wgl_list_get_btn_index(const wgl_obj_t list, const wgl_obj_t btn)
// int32_t wgl_list_get_btn_index(const wgl_obj_t list, const wgl_obj_t btn)
//{
// return wasm_list_get_btn_index(list, btn);
//}
//
//
//uint16_t wgl_list_get_size(const wgl_obj_t list)
// uint16_t wgl_list_get_size(const wgl_obj_t list)
//{
// return wasm_list_get_size(list);
//}
//
//#if LV_USE_GROUP
//
//wgl_obj_t wgl_list_get_btn_selected(const wgl_obj_t list)
// wgl_obj_t wgl_list_get_btn_selected(const wgl_obj_t list)
//{
// return wasm_list_get_btn_selected(list);
//}
@ -128,28 +129,27 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
//
//
//
//const wgl_style_t * wgl_list_get_style(const wgl_obj_t list, wgl_list_style_t type)
// const wgl_style_t * wgl_list_get_style(const wgl_obj_t list,
// wgl_list_style_t type)
//{
// //TODO
// return NULL;
//}
//
//
//void wgl_list_up(const wgl_obj_t list)
// void wgl_list_up(const wgl_obj_t list)
//{
// wasm_list_up(list);
//}
//
//void wgl_list_down(const wgl_obj_t list)
// void wgl_list_down(const wgl_obj_t list)
//{
// wasm_list_down(list);
//}
//
//
//void wgl_list_focus(const wgl_obj_t btn, wgl_anim_enable_t anim)
// void wgl_list_focus(const wgl_obj_t btn, wgl_anim_enable_t anim)
//{
// wasm_list_focus(btn, anim);
//}
//

View File

@ -3,19 +3,18 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <stdlib.h>
#include <string.h>
#define ARGC sizeof(argv)/sizeof(uint32)
#define ARGC sizeof(argv) / sizeof(uint32)
#define CALL_OBJ_NATIVE_FUNC(id) wasm_obj_native_call(id, argv, ARGC)
typedef struct _obj_evt_cb {
struct _obj_evt_cb *next;
lv_obj_t * obj;
lv_obj_t *obj;
lv_event_cb_t event_cb;
} obj_evt_cb_t;
@ -24,31 +23,36 @@ static obj_evt_cb_t *g_obj_evt_cb_list = NULL;
/* For lvgl compatible */
char g_widget_text[100];
lv_res_t lv_obj_del(lv_obj_t * obj)
lv_res_t
lv_obj_del(lv_obj_t *obj)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_DEL);
return (lv_res_t)argv[0];
}
void lv_obj_del_async(struct _lv_obj_t *obj)
void
lv_obj_del_async(struct _lv_obj_t *obj)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_DEL_ASYNC);
}
void lv_obj_clean(lv_obj_t * obj)
void
lv_obj_clean(lv_obj_t *obj)
{
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_CLEAN);
}
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
void
lv_obj_align(lv_obj_t *obj, const lv_obj_t *base, lv_align_t align,
lv_coord_t x_mod, lv_coord_t y_mod)
{
uint32 argv[5] = {0};
uint32 argv[5] = { 0 };
argv[0] = (uint32)obj;
argv[1] = (uint32)base;
argv[2] = align;
@ -57,7 +61,8 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_ALIGN);
}
lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj)
lv_event_cb_t
lv_obj_get_event_cb(const lv_obj_t *obj)
{
obj_evt_cb_t *obj_evt_cb = g_obj_evt_cb_list;
while (obj_evt_cb != NULL) {
@ -70,10 +75,11 @@ lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj)
return NULL;
}
void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb)
void
lv_obj_set_event_cb(lv_obj_t *obj, lv_event_cb_t event_cb)
{
obj_evt_cb_t *obj_evt_cb;
uint32 argv[1] = {0};
uint32 argv[1] = { 0 };
obj_evt_cb = g_obj_evt_cb_list;
while (obj_evt_cb) {
@ -94,7 +100,8 @@ void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb)
if (g_obj_evt_cb_list != NULL) {
obj_evt_cb->next = g_obj_evt_cb_list;
g_obj_evt_cb_list = obj_evt_cb;
} else {
}
else {
g_obj_evt_cb_list = obj_evt_cb;
}
@ -102,7 +109,8 @@ void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb)
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_SET_EVT_CB);
}
void on_widget_event(lv_obj_t * obj, lv_event_t event)
void
on_widget_event(lv_obj_t *obj, lv_event_t event)
{
obj_evt_cb_t *obj_evt_cb = g_obj_evt_cb_list;

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,6 @@
extern "C" {
#endif
//#include "bi-inc/wgl_shared_utils.h" /* shared types between app and native */
/*
#include "lvgl-compatible/lv_types.h"
@ -21,9 +20,6 @@ extern "C" {
#include "lvgl-compatible/lv_list.h"
*/
#include "src/lv_version.h"
#include "src/lv_misc/lv_log.h"

View File

@ -1,11 +1,9 @@
#include "lvgl.h"
int main()
int
main()
{
return 0;
return 0;
}

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);
}