2021-01-11 12:12:59 +08:00
|
|
|
## value 扩展函数
|
|
|
|
|
|
|
|
value 相关的辅助函数。
|
|
|
|
|
2022-12-14 17:01:33 +08:00
|
|
|
### 1. value\_is\_valid
|
2021-01-11 12:12:59 +08:00
|
|
|
|
|
|
|
> 判断 value 是否有效。
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
#### 原型
|
|
|
|
|
2022-08-23 10:12:36 +08:00
|
|
|
```js
|
2021-01-13 14:08:27 +08:00
|
|
|
value_is_valid(v) => bool
|
2021-01-11 12:12:59 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
#### 示例
|
|
|
|
|
2022-08-23 10:12:36 +08:00
|
|
|
```js
|
2022-08-23 10:34:55 +08:00
|
|
|
var a = object_create()
|
2021-01-11 12:12:59 +08:00
|
|
|
print(value_is_valid(a))
|
|
|
|
```
|
|
|
|
|
2022-12-14 17:01:33 +08:00
|
|
|
### 2. value\_is\_null
|
2021-01-11 12:12:59 +08:00
|
|
|
|
|
|
|
> 判断 value 是否为 null。
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
#### 原型
|
|
|
|
|
2022-08-23 10:12:36 +08:00
|
|
|
```js
|
2021-01-13 14:08:27 +08:00
|
|
|
value_is_null(v) => bool
|
2021-01-11 12:12:59 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
#### 示例
|
|
|
|
|
2022-08-23 10:12:36 +08:00
|
|
|
```js
|
2022-08-23 10:34:55 +08:00
|
|
|
var a = object_create()
|
2021-01-11 12:12:59 +08:00
|
|
|
print(value_is_null(a))
|
|
|
|
```
|
|
|
|
|
2022-12-14 17:01:33 +08:00
|
|
|
### 3. value\_get\_binary\_data
|
2021-01-11 12:12:59 +08:00
|
|
|
|
|
|
|
> 获取 binary 的数据指针。
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
#### 原型
|
|
|
|
|
2022-08-23 10:12:36 +08:00
|
|
|
```js
|
2021-01-13 14:08:27 +08:00
|
|
|
value_get_binary_data(v) => pointer_t
|
2021-01-11 12:12:59 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
#### 示例
|
|
|
|
|
2022-08-23 10:12:36 +08:00
|
|
|
```js
|
2021-01-11 12:12:59 +08:00
|
|
|
print(value_get_binary_data(a))
|
|
|
|
```
|
|
|
|
|
2022-12-14 17:01:33 +08:00
|
|
|
### 4. value\_get\_binary\_size
|
2021-01-11 12:12:59 +08:00
|
|
|
|
|
|
|
> 获取 binary 的数据长度。
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
#### 原型
|
|
|
|
|
2022-08-23 10:12:36 +08:00
|
|
|
```js
|
2021-01-13 14:08:27 +08:00
|
|
|
value_get_binary_size(v) => uint32_t
|
2021-01-11 12:12:59 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
#### 示例
|
|
|
|
|
2022-08-23 10:12:36 +08:00
|
|
|
```js
|
2022-08-23 10:34:55 +08:00
|
|
|
var a = file_read_binary("test.bin")
|
2021-01-11 12:12:59 +08:00
|
|
|
assert(value_get_binary_size(a) == 5)
|
|
|
|
```
|