mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
fscript add can_exec
This commit is contained in:
parent
b5dffbda18
commit
3d039b131f
@ -3,6 +3,7 @@
|
||||
2024/02/21
|
||||
* 资源配置新增STORAGE_DIR属性,用于生成位图字体资源时可通过在该属性指定的目录下获取原始字体和保留字符等文件(感谢培煌提供补丁)
|
||||
* 完善 widget\_is\_style\_exist(感谢兆坤提供补丁)
|
||||
* fscript增加 can_exec (感谢兆坤提供补丁)
|
||||
|
||||
2024/02/20
|
||||
* 修复拼写错误(感谢兆坤提供补丁)
|
||||
|
@ -915,6 +915,27 @@ exec("clear", "all")
|
||||
|
||||
> 具体功能与 object 的实现有关。
|
||||
|
||||
#### 4.1.26 can_exec
|
||||
|
||||
> 判断 object 里的一个命令是否可执行。
|
||||
----------------------------
|
||||
|
||||
##### 原型
|
||||
|
||||
```js
|
||||
can_exec(cmd, arg) => bool
|
||||
```
|
||||
|
||||
##### 示例
|
||||
|
||||
```js
|
||||
if (can_exec("clear", "all")) {
|
||||
exec("clear", "all")
|
||||
}
|
||||
```
|
||||
|
||||
> 具体功能与 object 的实现有关。
|
||||
|
||||
### 4.2 字符串函数
|
||||
|
||||
#### 4.2.1 join
|
||||
|
@ -3047,6 +3047,17 @@ static ret_t func_contains(fscript_t* fscript, fscript_args_t* args, value_t* re
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t func_can_exec(fscript_t* fscript, fscript_args_t* args, value_t* result) {
|
||||
char buff[64];
|
||||
const char* cmd = NULL;
|
||||
const char* cmd_args = NULL;
|
||||
FSCRIPT_FUNC_CHECK(args->size == 2, RET_BAD_PARAMS);
|
||||
cmd = value_str(args->args);
|
||||
cmd_args = value_str_ex(args->args + 1, buff, sizeof(buff) - 1);
|
||||
value_set_bool(result, tk_object_can_exec(fscript->obj, cmd, cmd_args));
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t func_exec(fscript_t* fscript, fscript_args_t* args, value_t* result) {
|
||||
char buff[64];
|
||||
const char* cmd = NULL;
|
||||
@ -3092,6 +3103,7 @@ static const func_entry_t s_builtin_funcs[] = {{"func", func_function_def, 4},
|
||||
{"minus", func_minus, 1},
|
||||
{"||", func_or, 2},
|
||||
{"and", func_and, 2},
|
||||
{"can_exec", func_can_exec, 2},
|
||||
{"exec", func_exec, 2},
|
||||
{"join", func_join, 8},
|
||||
{"one_of", func_one_of, 3},
|
||||
|
Loading…
Reference in New Issue
Block a user