add fscript_set_global_object

This commit is contained in:
lixianjing 2022-02-18 12:17:24 +08:00
parent 3390b185e9
commit 20365c638e
3 changed files with 28 additions and 5 deletions

View File

@ -1,4 +1,6 @@
# 最新动态
2022/02/18
* 增加函数fscript\_set\_global\_object。
2022/02/16
* 增加函数ui\_loader\_load\_widget\_from\_xml。

View File

@ -2736,12 +2736,23 @@ tk_object_t* fscript_get_global_object(void) {
return s_global_obj;
}
ret_t fscript_global_init(void) {
tk_object_t* obj = object_default_create_ex(FALSE);
return_value_if_fail(obj != NULL, RET_BAD_PARAMS);
ret_t fscript_set_global_object(tk_object_t* obj) {
TK_OBJECT_UNREF(s_global_obj);
s_global_obj = object_locker_create(obj);
TK_OBJECT_UNREF(obj);
TK_OBJECT_REF(obj);
s_global_obj = obj;
return RET_OK;
}
ret_t fscript_global_init(void) {
if (s_global_obj != NULL) {
tk_object_t* obj = object_default_create_ex(FALSE);
return_value_if_fail(obj != NULL, RET_BAD_PARAMS);
s_global_obj = object_locker_create(obj);
TK_OBJECT_UNREF(obj);
}
return RET_OK;
}

View File

@ -330,6 +330,16 @@ ret_t fscript_eval(tk_object_t* obj, const char* script, value_t* result);
*/
ret_t fscript_global_init(void);
/**
* @method fscript_set_global_object
*
* >
* @param {tk_object_t*} obj
*
* @return {ret_t} RET_OK表示成功
*/
ret_t fscript_set_global_object(tk_object_t* obj);
/**
* @method fscript_register_func
*