improve fscript

This commit is contained in:
lixianjing 2022-01-05 07:32:23 +08:00
parent 2b9d2d9071
commit fc4cf8547e
3 changed files with 17 additions and 7 deletions

View File

@ -1,4 +1,8 @@
# 最新动态
2022/01/05
* fscript公开函数value\_id/value\_func。
2022/01/04
* fscript支持保存函数名方便调试。

View File

@ -26,8 +26,6 @@
#define STR_GLOBAL_PREFIX "global."
#define GLOBAL_PREFIX_LEN 7
#define VALUE_TYPE_JSCRIPT_ID 128
#define VALUE_TYPE_JSCRIPT_FUNC VALUE_TYPE_JSCRIPT_ID + 1
static ret_t func_function_def(fscript_t* fscript, fscript_args_t* args, value_t* result) {
return RET_OK;
@ -86,11 +84,6 @@ static value_t* value_set_func(value_t* v, fscript_func_call_t* func) {
return v;
}
static fscript_func_call_t* value_func(const value_t* v) {
return_value_if_fail(v->type == VALUE_TYPE_JSCRIPT_FUNC, NULL);
return (fscript_func_call_t*)(v->value.ptr);
}
static bool_t value_is_digit(value_t* v) {
uint32_t type = 0;
bool_t ret = TRUE;

View File

@ -373,6 +373,19 @@ struct _fscript_func_call_t {
return code; \
}
#define VALUE_TYPE_JSCRIPT_ID 128
#define VALUE_TYPE_JSCRIPT_FUNC VALUE_TYPE_JSCRIPT_ID + 1
static inline fscript_func_call_t* value_func(const value_t* v) {
return_value_if_fail(v->type == VALUE_TYPE_JSCRIPT_FUNC, NULL);
return (fscript_func_call_t*)(v->value.ptr);
}
static inline fscript_func_call_t* value_id(value_t* v) {
return_value_if_fail(v->type == VALUE_TYPE_JSCRIPT_ID, NULL);
return (fscript_func_call_t*)(v->value.str);
}
END_C_DECLS
#endif /*TK_FSCRIPTS_H*/