Enable AoT and wamr-sdk, and change arguments of call wasm API (#157)

* Implement memory profiler, optimize memory usage, modify code indent

* Implement memory.grow and limit heap space base offset to 1G; modify iwasm build type to Release and 64 bit by default

* Add a new extension library: connection

* Fix bug of reading magic number and version in big endian platform

* Re-org platform APIs: move most platform APIs from iwasm to shared-lib

* Enhance wasm loader to fix some security issues

* Fix issue about illegal load of EXC_RETURN into PC on stm32 board

* Updates that let a restricted version of the interpreter run in SGX

* Enable native/app address validation and conversion for wasm app

* Remove wasm_application_exectue_* APIs from wasm_export.h which makes confused

* Refine binary size and fix several minor issues

Optimize interpreter LOAD/STORE opcodes to decrease the binary size
Fix issues when using iwasm library: _bh_log undefined, bh_memory.h not found
Remove unused _stdin/_stdout/_stderr global variables resolve in libc wrapper
Add macros of global heap size, stack size, heap size for Zephyr main.c
Clear compile warning of wasm_application.c

* Add more strict security checks for libc wrapper API's

* Use one libc wrapper copy for sgx and other platforms; remove bh_printf macro for other platform header files

* Enhance security of libc strcpy/sprintf wrapper function

* Fix issue of call native for x86_64/arm/mips, add module inst parameter for native wrapper functions

* Remove get_module_inst() and fix issue of call native

* Refine wgl lib: remove module_inst parameter from widget functions; move function index check to runtime instantiate

* Refine interpreter call native process, refine memory boudary check

* Fix issues of invokeNative function of arm/mips/general version

* Add a switch to build simple sample without gui support

* Add BUILD_TARGET setting in makefile to replace cpu compiler flags in source code

* Re-org shared lib header files, remove unused info; fix compile issues of vxworks

* Add build target general

* Remove unused files

* Update license header

* test push

* Restore file

* Sync up with internal/feature

* Sync up with internal/feature

* Rename build_wamr_app to build_wasm_app

* Fix small issues of README

* Enhance malformed wasm file checking
Fix issue of print hex int and implement utf8 string check
Fix wasi file read/write right issue
Fix minor issue of build wasm app doc

* Sync up with internal/feature

* Sync up with internal/feature: fix interpreter arm issue, fix read leb issue

* Sync up with internal/feature

* Fix bug of config.h and rename wasi config.h to ssp_config.h

* Sync up with internal/feature

* Import wamr aot

* update document

* update document

* Update document, disable WASI in 32bit

* update document

* remove files

* update document

* Update document

* update document

* update document

* update samples

* Sync up with internal repo
This commit is contained in:
wenyongh
2020-01-21 13:26:14 +08:00
committed by Wang Xin
parent 2a4528c749
commit 46b93b9d22
464 changed files with 25137 additions and 7911 deletions

View File

@ -0,0 +1,121 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "bh_platform.h"
#include "gui_api.h"
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_BTN_NATIVE_FUNC(id) wasm_btn_native_call(id, argv, ARGC)
wgl_obj_t wgl_btn_create(wgl_obj_t par, wgl_obj_t copy)
{
uint32 argv[2] = {0};
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_CREATE);
return (wgl_obj_t)argv[0];
}
void wgl_btn_set_toggle(wgl_obj_t btn, bool tgl)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
argv[1] = tgl;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_TOGGLE);
}
void wgl_btn_set_state(wgl_obj_t btn, wgl_btn_state_t state)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
argv[1] = state;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_STATE);
}
void wgl_btn_toggle(wgl_obj_t btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_TOGGLE);
}
void wgl_btn_set_ink_in_time(wgl_obj_t btn, uint16_t time)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
argv[1] = time;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_IN_TIME);
}
void wgl_btn_set_ink_wait_time(wgl_obj_t btn, uint16_t time)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
argv[1] = time;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_WAIT_TIME);
}
void wgl_btn_set_ink_out_time(wgl_obj_t btn, uint16_t time)
{
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)
//{
// //TODO: pack style
// //wasm_btn_set_style(btn, type, style);
//}
//
wgl_btn_state_t wgl_btn_get_state(const wgl_obj_t btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_STATE);
return (wgl_btn_state_t)argv[0];
}
bool wgl_btn_get_toggle(const wgl_obj_t btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_TOGGLE);
return (bool)argv[0];
}
uint16_t wgl_btn_get_ink_in_time(const wgl_obj_t btn)
{
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 wgl_btn_get_ink_wait_time(const wgl_obj_t btn)
{
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 wgl_btn_get_ink_out_time(const wgl_obj_t btn)
{
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)
//{
// //TODO: pack style
// //wasm_btn_get_style(btn, type);
// return NULL;
//}

View File

@ -0,0 +1,73 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "gui_api.h"
#include <string.h>
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_CB_NATIVE_FUNC(id) wasm_cb_native_call(id, argv, ARGC)
wgl_obj_t wgl_cb_create(wgl_obj_t par, const wgl_obj_t copy)
{
uint32 argv[2] = {0};
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_CREATE);
return (wgl_obj_t)argv[0];
}
void wgl_cb_set_text(wgl_obj_t cb, const char * txt)
{
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 wgl_cb_set_static_text(wgl_obj_t cb, const char * txt)
{
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)
//{
// //TODO:
//}
//
unsigned int wgl_cb_get_text_length(wgl_obj_t cb)
{
uint32 argv[1] = {0};
argv[0] = (uint32)cb;
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_GET_TEXT_LENGTH);
return argv[0];
}
char *wgl_cb_get_text(wgl_obj_t cb, char *buffer, int buffer_len)
{
uint32 argv[3] = {0};
argv[0] = (uint32)cb;
argv[1] = (uint32)buffer;
argv[2] = buffer_len;
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_GET_TEXT);
return (char *)argv[0];
}
//const wgl_style_t * wgl_cb_get_style(const wgl_obj_t cb, wgl_cb_style_t type)
//{
// //TODO
// return NULL;
//}
//

View File

@ -0,0 +1,252 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "gui_api.h"
#include <string.h>
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_LABEL_NATIVE_FUNC(id) wasm_label_native_call(id, argv, ARGC)
wgl_obj_t wgl_label_create(wgl_obj_t par, wgl_obj_t copy)
{
uint32 argv[2] = {0};
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_CREATE);
return (wgl_obj_t)argv[0];
}
void wgl_label_set_text(wgl_obj_t label, const char * text)
{
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 wgl_label_set_array_text(wgl_obj_t label, const char * array, uint16_t size)
{
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 wgl_label_set_static_text(wgl_obj_t label, const char * text)
{
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 wgl_label_set_long_mode(wgl_obj_t label, wgl_label_long_mode_t long_mode)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
argv[1] = long_mode;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_LONG_MODE);
}
void wgl_label_set_align(wgl_obj_t label, wgl_label_align_t align)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
argv[1] = align;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_ALIGN);
}
void wgl_label_set_recolor(wgl_obj_t label, bool en)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
argv[1] = en;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_RECOLOR);
}
void wgl_label_set_body_draw(wgl_obj_t label, bool en)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
argv[1] = en;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_BODY_DRAW);
}
void wgl_label_set_anim_speed(wgl_obj_t label, uint16_t anim_speed)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
argv[1] = anim_speed;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_ANIM_SPEED);
}
void wgl_label_set_text_sel_start(wgl_obj_t label, uint16_t index)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
argv[1] = index;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_TEXT_SEL_START);
}
void wgl_label_set_text_sel_end(wgl_obj_t label, uint16_t index)
{
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(wgl_obj_t label)
{
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(wgl_obj_t label, char *buffer, int buffer_len)
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
argv[1] = (uint32)buffer;
argv[2] = buffer_len;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_TEXT);
return (char *)argv[0];
}
wgl_label_long_mode_t wgl_label_get_long_mode(const wgl_obj_t label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_LONG_MODE);
return (wgl_label_long_mode_t)argv[0];
}
wgl_label_align_t wgl_label_get_align(const wgl_obj_t label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_ALIGN);
return (wgl_label_align_t)argv[0];
}
bool wgl_label_get_recolor(const wgl_obj_t label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_RECOLOR);
return (bool)argv[0];
}
bool wgl_label_get_body_draw(const wgl_obj_t label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_BODY_DRAW);
return (bool)argv[0];
}
uint16_t wgl_label_get_anim_speed(const wgl_obj_t label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_ANIM_SPEED);
return (uint16_t)argv[0];
}
void wgl_label_get_letter_pos(const wgl_obj_t label, uint16_t index, wgl_point_t * pos)
{
uint32 argv[4] = {0};
argv[0] = (uint32)label;
argv[1] = index;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_LETTER_POS);
pos->x = argv[2];
pos->y = argv[3];
}
uint16_t wgl_label_get_letter_on(const wgl_obj_t label, wgl_point_t * pos)
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
argv[1] = pos->x;
argv[2] = pos->y;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_LETTER_POS);
return (uint16_t)argv[0];
}
bool wgl_label_is_char_under_pos(const wgl_obj_t label, wgl_point_t * pos)
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
argv[1] = pos->x;
argv[2] = pos->y;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_LETTER_POS);
return (bool)argv[0];
}
uint16_t wgl_label_get_text_sel_start(const wgl_obj_t label)
{
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 wgl_label_get_text_sel_end(const wgl_obj_t label)
{
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 wgl_label_ins_text(wgl_obj_t label, uint32_t pos, const char * txt)
{
uint32 argv[4] = {0};
argv[0] = (uint32)label;
argv[1] = pos;
argv[2] = (uint32)txt;
argv[3] = strlen(txt) + 1;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_INS_TEXT);
}
void wgl_label_cut_text(wgl_obj_t label, uint32_t pos, uint32_t cnt)
{
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

@ -0,0 +1,154 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "gui_api.h"
#include <string.h>
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_LIST_NATIVE_FUNC(id) wasm_list_native_call(id, argv, ARGC)
wgl_obj_t wgl_list_create(wgl_obj_t par, const wgl_obj_t copy)
{
uint32 argv[2] = {0};
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
CALL_LIST_NATIVE_FUNC(LIST_FUNC_ID_CREATE);
return (wgl_obj_t)argv[0];
}
//
//
//void wgl_list_clean(wgl_obj_t obj)
//{
// wasm_list_clean(obj);
//}
//
wgl_obj_t wgl_list_add_btn(wgl_obj_t list, const void * img_src, const char * txt)
{
uint32 argv[3] = {0};
(void)img_src; /* doesn't support img src currently */
argv[0] = (uint32)list;
argv[1] = (uint32)txt;
argv[2] = strlen(txt) + 1;
CALL_LIST_NATIVE_FUNC(LIST_FUNC_ID_ADD_BTN);
return (wgl_obj_t)argv[0];
}
//
//
//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)
//{
// wasm_list_set_single_mode(list, mode);
//}
//
//#if LV_USE_GROUP
//
//
//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)
//{
// //TODO
//}
//
//
//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)
//{
// return wasm_list_get_btn_text(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)
//{
// 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)
//{
// 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)
//{
// 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)
//{
// return wasm_list_get_btn_index(list, btn);
//}
//
//
//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)
//{
// return wasm_list_get_btn_selected(list);
//}
//#endif
//
//
//
//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)
//{
// wasm_list_up(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)
//{
// wasm_list_focus(btn, anim);
//}
//

View File

@ -0,0 +1,116 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "gui_api.h"
#include <stdlib.h>
#include <string.h>
#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;
wgl_obj_t obj;
wgl_event_cb_t event_cb;
} obj_evt_cb_t;
static obj_evt_cb_t *g_obj_evt_cb_list = NULL;
/* For lvgl compatible */
char g_widget_text[100];
wgl_res_t wgl_obj_del(wgl_obj_t obj)
{
uint32 argv[1] = {0};
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_DEL);
return (wgl_res_t)argv[0];
}
void wgl_obj_del_async(wgl_obj_t obj)
{
uint32 argv[1] = {0};
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_DEL_ASYNC);
}
void wgl_obj_clean(wgl_obj_t obj)
{
uint32 argv[1] = {0};
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_CLEAN);
}
void wgl_obj_align(wgl_obj_t obj, const wgl_obj_t base, wgl_align_t align, wgl_coord_t x_mod, wgl_coord_t y_mod)
{
uint32 argv[5] = {0};
argv[0] = (uint32)obj;
argv[1] = (uint32)base;
argv[2] = align;
argv[3] = x_mod;
argv[4] = y_mod;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_ALIGN);
}
wgl_event_cb_t wgl_obj_get_event_cb(const wgl_obj_t obj)
{
obj_evt_cb_t *obj_evt_cb = g_obj_evt_cb_list;
while (obj_evt_cb != NULL) {
if (obj_evt_cb->obj == obj) {
return obj_evt_cb->event_cb;
}
obj_evt_cb = obj_evt_cb->next;
}
return NULL;
}
void wgl_obj_set_event_cb(wgl_obj_t obj, wgl_event_cb_t event_cb)
{
obj_evt_cb_t *obj_evt_cb;
uint32 argv[1] = {0};
obj_evt_cb = g_obj_evt_cb_list;
while (obj_evt_cb) {
if (obj_evt_cb->obj == obj) {
obj_evt_cb->event_cb = event_cb;
return;
}
}
obj_evt_cb = (obj_evt_cb_t *)malloc(sizeof(*obj_evt_cb));
if (obj_evt_cb == NULL)
return;
memset(obj_evt_cb, 0, sizeof(*obj_evt_cb));
obj_evt_cb->obj = obj;
obj_evt_cb->event_cb = 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 {
g_obj_evt_cb_list = obj_evt_cb;
}
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_SET_EVT_CB);
}
void on_widget_event(wgl_obj_t obj, wgl_event_t event)
{
obj_evt_cb_t *obj_evt_cb = g_obj_evt_cb_list;
while (obj_evt_cb != NULL) {
if (obj_evt_cb->obj == obj) {
obj_evt_cb->event_cb(obj, event);
return;
}
obj_evt_cb = obj_evt_cb->next;
}
}