1e41f4b71Sopenharmony_ci# JSVM
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## 概述
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci提供标准的JavaScript引擎能力。
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci功能概述: 标准JS引擎是严格遵守Ecmascript规范的JavaScript代码执行引擎。 支持Ecmascript规范定义的标准库,提供完备的C++交互JS的native API。 通过jit加速代码执行,为应用提供安全、高效的JS执行能力。 标准JS引擎的能力通过一套稳定的ABI,即JSVM-API提供。JSVM-API支持动态链接到不同版本的JS引擎库, 从而为开发者屏蔽掉不同引擎接口的差异。JSVM-API提供引擎生命周期管理、JS context管理、 JS代码执行、JS/C++互操作、执行环境快照、codecache等能力。
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci使用平台:arm64平台。
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci使用方法:链接SDK中的libjsvm.so,并在C++代码中包含ark_runtime/jsvm.h头文件。
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci通过API接口为开发者提供独立、标准、完整的JavaScript引擎能力, 包括管理引擎生命周期、编译运行JS代码、实现JS/C++跨语言调用、拍摄快照等。
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci**起始版本:** 11
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci## 汇总
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci### 文件
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci| 名称 | 描述 | 
25e41f4b71Sopenharmony_ci| -------- | -------- |
26e41f4b71Sopenharmony_ci| [jsvm.h](jsvm_8h.md) | 提供JSVM-API接口定义。 | 
27e41f4b71Sopenharmony_ci| [jsvm_types.h](jsvm__types_8h.md) | 提供JSVM-API类型定义。 | 
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci### 结构体
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci| 名称 | 描述 | 
33e41f4b71Sopenharmony_ci| -------- | -------- |
34e41f4b71Sopenharmony_ci| struct  [JSVM_CallbackStruct](_j_s_v_m___callback_struct.md) | 用户提供的native回调函数的指针和数据,这些函数通过JSVM-API接口暴露给JavaScript。 | 
35e41f4b71Sopenharmony_ci| struct  [JSVM_HeapStatistics](_j_s_v_m___heap_statistics.md) | Heapstatisics结构体,用于保存有关JavaScript堆内存使用情况的统计信息。 | 
36e41f4b71Sopenharmony_ci| struct  [JSVM_InitOptions](_j_s_v_m___init_options.md) | 初始化选项,用于初始化JavaScript虚拟机。 | 
37e41f4b71Sopenharmony_ci| struct  [JSVM_CreateVMOptions](_j_s_v_m___create_v_m_options.md) | 创建JavaScript虚拟机的选项。 | 
38e41f4b71Sopenharmony_ci| struct  [JSVM_VMInfo](_j_s_v_m___v_m_info.md) | JavaScript虚拟机信息。 | 
39e41f4b71Sopenharmony_ci| struct  [JSVM_PropertyDescriptor](_j_s_v_m___property_descriptor.md) | 属性描述符。 | 
40e41f4b71Sopenharmony_ci| struct  [JSVM_ExtendedErrorInfo](_j_s_v_m___extended_error_info.md) | 扩展的异常信息。 | 
41e41f4b71Sopenharmony_ci| struct  [JSVM_TypeTag](_j_s_v_m___type_tag.md) | 类型标记,存储为两个无符号64位整数的128位值。 作为一个UUID,通过它,JavaScript对象可以是"tagged", 以确保它们的类型保持不变。 | 
42e41f4b71Sopenharmony_ci| struct  [JSVM_PropertyHandlerConfigurationStruct](_j_s_v_m___property_handler_configuration_struct.md) | 当执行对象的getter、setter、deleter和enumerator操作时,该结构体中对应的函数回调将会触发。 | 
43e41f4b71Sopenharmony_ci| struct  [JSVM_ScriptOrigin](_j_s_v_m___script_origin.md) | Source code information. | 
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci### 宏定义
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci| 名称 | 描述 | 
49e41f4b71Sopenharmony_ci| -------- | -------- |
50e41f4b71Sopenharmony_ci| **JSVM_VERSION_EXPERIMENTAL**   2147483647 |  | 
51e41f4b71Sopenharmony_ci| **JSVM_VERSION**   8 |  | 
52e41f4b71Sopenharmony_ci| **JSVM_EXTERN**   __attribute__((visibility("default"))) |  | 
53e41f4b71Sopenharmony_ci| [JSVM_AUTO_LENGTH](#jsvm_auto_length)   SIZE_MAX | 自动长度。 | 
54e41f4b71Sopenharmony_ci| **EXTERN_C_START** |  | 
55e41f4b71Sopenharmony_ci| **EXTERN_C_END** |  | 
56e41f4b71Sopenharmony_ci| **JSVM_CDECL** |  | 
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci### 类型定义
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci| 名称 | 描述 | 
62e41f4b71Sopenharmony_ci| -------- | -------- |
63e41f4b71Sopenharmony_ci| typedef uint16_t **char16_t** |  | 
64e41f4b71Sopenharmony_ci| typedef struct JSVM_VM__ \* [JSVM_VM](#jsvm_vm) | 表示JavaScript虚拟机实例。 | 
65e41f4b71Sopenharmony_ci| typedef struct JSVM_VMScope__ \* [JSVM_VMScope](#jsvm_vmscope) | 表示JavaScript虚拟机作用域。 | 
66e41f4b71Sopenharmony_ci| typedef struct JSVM_EnvScope__ \* [JSVM_EnvScope](#jsvm_envscope) | 表示用于控制附加到当前虚拟机实例的环境。只有当线程通过 OH_JSVM_OpenEnvScope进入该环境的JSVM_EnvScope后,该环境才 对线程的虚拟机实例可用。 | 
67e41f4b71Sopenharmony_ci| typedef struct JSVM_Script__ \* [JSVM_Script](#jsvm_script) | 表示一段JavaScript代码。 | 
68e41f4b71Sopenharmony_ci| typedef struct JSVM_Env__ \* [JSVM_Env](#jsvm_env) | 表示虚拟机特定状态的上下文环境,需要在调用native函数时作为参数传递, 并且传递给后续任何的JSVM-API嵌套调用。 | 
69e41f4b71Sopenharmony_ci| typedef struct JSVM_CpuProfiler__ \* [JSVM_CpuProfiler](#jsvm_cpuprofiler) | 表示一个JavaScript CPU时间性能分析器。 | 
70e41f4b71Sopenharmony_ci| typedef struct JSVM_Value__ \* [JSVM_Value](#jsvm_value) | 表示JavaScript值。 | 
71e41f4b71Sopenharmony_ci| typedef struct JSVM_Ref__ \* [JSVM_Ref](#jsvm_ref) | 表示JavaScript值的引用。 | 
72e41f4b71Sopenharmony_ci| typedef struct JSVM_HandleScope__ \* [JSVM_HandleScope](#jsvm_handlescope) | 表示JavaScript值的作用域,用于控制和修改在特定范围内创建的对象的生命周期。 通常,JSVM-API值是在JSVM_HandleScope的上下文中创建的。当从JavaScript调用native方法时, 将存在默认JSVM_HandleScope。如果用户没有显式创建新的JSVM_HandleScope,将在默认 JSVM_HandleScope中创建JSVM-API值。对于native方法执行之外的任何代码调用(例如,在libuv回调调用期间), 模块需要在调用任何可能导致创建JavaScript值的函数之前创建一个作用域。JSVM_HandleScope是使用 OH_JSVM_OpenHandleScope创建的,并使用OH_JSVM_CloseHandleScope销毁的。 关闭作用域代表向GC指示在JSVM_HandleScope作用域的生命周期内创建的所有JSVM_Value将不再从当前堆的栈帧中引用。 | 
73e41f4b71Sopenharmony_ci| typedef struct JSVM_EscapableHandleScope__ \* [JSVM_EscapableHandleScope](#jsvm_escapablehandlescope) | 表示一种特殊类型的handle scope,用于将在特定handle scope内创建的值返回到父作用域。 | 
74e41f4b71Sopenharmony_ci| typedef struct JSVM_CallbackInfo__ \* [JSVM_CallbackInfo](#jsvm_callbackinfo) | 表示传递给回调函数的不透明数据类型。可用于获取调用该函数的上下文的附加信息。 | 
75e41f4b71Sopenharmony_ci| typedef struct JSVM_Deferred__ \* [JSVM_Deferred](#jsvm_deferred) | 表示Promise延迟对象。 | 
76e41f4b71Sopenharmony_ci| typedef [JSVM_CallbackStruct](_j_s_v_m___callback_struct.md) \* [JSVM_Callback](#jsvm_callback) | 用户提供的native函数的函数指针类型,这些函数通过JSVM-API接口暴露给JavaScript。 | 
77e41f4b71Sopenharmony_ci| typedef void(JSVM_CDECL \* [JSVM_Finalize](#jsvm_finalize)) ([JSVM_Env](#jsvm_env) env, void \*finalizeData, void \*finalizeHint) | 函数指针类型,当native类型对象或数据与JS对象被关联时,传入该指针。该函数将会 在关联的JS对象被GC回收时被调用,用以执行native的清理动作。 | 
78e41f4b71Sopenharmony_ci| typedef bool(JSVM_CDECL \* [JSVM_OutputStream](#jsvm_outputstream)) (const char \*data, int size, void \*streamData) | ASCII输出流回调的函数指针类型。参数data是指输出的数据指针。参数size是指输出的数据大小。 空数据指针指示流的结尾。参数streamData是指与回调一起传递给API函数的指针,该API函数向输出流生成数据。回 调返回true表示流可以继续接受数据。否则,它将中止流。 | 
79e41f4b71Sopenharmony_ci| typedef [JSVM_PropertyHandlerConfigurationStruct](_j_s_v_m___property_handler_configuration_struct.md) \* [JSVM_PropertyHandlerCfg](#jsvm_propertyhandlercfg) | 包含属性监听回调的结构的指针类型。 | 
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci### 枚举
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci| 名称 | 描述 | 
85e41f4b71Sopenharmony_ci| -------- | -------- |
86e41f4b71Sopenharmony_ci| [JSVM_PropertyAttributes](#jsvm_propertyattributes) {<br/>JSVM_DEFAULT = 0, JSVM_WRITABLE = 1 &lt;&lt; 0, JSVM_ENUMERABLE = 1 &lt;&lt; 1, JSVM_CONFIGURABLE = 1 &lt;&lt; 2,<br/>JSVM_STATIC = 1 &lt;&lt; 10, JSVM_DEFAULT_METHOD = JSVM_WRITABLE \| JSVM_CONFIGURABLE, JSVM_DEFAULT_JSPROPERTY = JSVM_WRITABLE \| JSVM_ENUMERABLE \| JSVM_CONFIGURABLE<br/>} | 用于控制JavaScript对象属性的行为。 | 
87e41f4b71Sopenharmony_ci| [JSVM_ValueType](#jsvm_valuetype) {<br/>JSVM_UNDEFINED, JSVM_NULL, JSVM_BOOLEAN, JSVM_NUMBER,<br/>JSVM_STRING, JSVM_SYMBOL, JSVM_OBJECT, JSVM_FUNCTION,<br/>JSVM_EXTERNAL, JSVM_BIGINT<br/>} | 描述JSVM_Value的类型。 | 
88e41f4b71Sopenharmony_ci| [JSVM_TypedarrayType](#jsvm_typedarraytype) {<br/>JSVM_INT8_ARRAY, JSVM_UINT8_ARRAY, JSVM_UINT8_CLAMPED_ARRAY, JSVM_INT16_ARRAY,<br/>JSVM_UINT16_ARRAY, JSVM_INT32_ARRAY, JSVM_UINT32_ARRAY, JSVM_FLOAT32_ARRAY,<br/>JSVM_FLOAT64_ARRAY, JSVM_BIGINT64_ARRAY, JSVM_BIGUINT64_ARRAY<br/>} | 描述TypedArray的类型。 | 
89e41f4b71Sopenharmony_ci| [JSVM_Status](#jsvm_status) {<br/>JSVM_OK, JSVM_INVALID_ARG, JSVM_OBJECT_EXPECTED, JSVM_STRING_EXPECTED,<br/>JSVM_NAME_EXPECTED, JSVM_FUNCTION_EXPECTED, JSVM_NUMBER_EXPECTED, JSVM_BOOLEAN_EXPECTED,<br/>JSVM_ARRAY_EXPECTED, JSVM_GENERIC_FAILURE, JSVM_PENDING_EXCEPTION, JSVM_CANCELLED,<br/>JSVM_ESCAPE_CALLED_TWICE, JSVM_HANDLE_SCOPE_MISMATCH, JSVM_CALLBACK_SCOPE_MISMATCH, JSVM_QUEUE_FULL,<br/>JSVM_CLOSING, JSVM_BIGINT_EXPECTED, JSVM_DATE_EXPECTED, JSVM_ARRAYBUFFER_EXPECTED,<br/>JSVM_DETACHABLE_ARRAYBUFFER_EXPECTED, JSVM_WOULD_DEADLOCK, JSVM_NO_EXTERNAL_BUFFERS_ALLOWED, JSVM_CANNOT_RUN_JS<br/>} | 表示JSVM-API调用成功或失败的完整状态码。 | 
90e41f4b71Sopenharmony_ci| [JSVM_KeyCollectionMode](#jsvm_keycollectionmode) { JSVM_KEY_INCLUDE_PROTOTYPES, JSVM_KEY_OWN_ONLY } | 限制查找属性的范围。 | 
91e41f4b71Sopenharmony_ci| [JSVM_KeyFilter](#jsvm_keyfilter) {<br/>JSVM_KEY_ALL_PROPERTIES = 0, JSVM_KEY_WRITABLE = 1, JSVM_KEY_ENUMERABLE = 1 &lt;&lt; 1, JSVM_KEY_CONFIGURABLE = 1 &lt;&lt; 2,<br/>JSVM_KEY_SKIP_STRINGS = 1 &lt;&lt; 3, JSVM_KEY_SKIP_SYMBOLS = 1 &lt;&lt; 4<br/>} | 属性过滤器,可以通过使用or来构造一个复合过滤器。 | 
92e41f4b71Sopenharmony_ci| [JSVM_KeyConversion](#jsvm_keyconversion) { JSVM_KEY_KEEP_NUMBERS, JSVM_KEY_NUMBERS_TO_STRINGS } | 键转换选项。 | 
93e41f4b71Sopenharmony_ci| [JSVM_MemoryPressureLevel](#jsvm_memorypressurelevel) { JSVM_MEMORY_PRESSURE_LEVEL_NONE, JSVM_MEMORY_PRESSURE_LEVEL_MODERATE, JSVM_MEMORY_PRESSURE_LEVEL_CRITICAL } | 内存压力水平。 | 
94e41f4b71Sopenharmony_ci| [JSVM_RegExpFlags](#jsvm_regexpflags) {<br/>JSVM_REGEXP_NONE = 0, JSVM_REGEXP_GLOBAL = 1 &lt;&lt; 0, JSVM_REGEXP_IGNORE_CASE = 1 &lt;&lt; 1, JSVM_REGEXP_MULTILINE = 1 &lt;&lt; 2,<br/>JSVM_REGEXP_STICKY = 1 &lt;&lt; 3, JSVM_REGEXP_UNICODE = 1 &lt;&lt; 4, JSVM_REGEXP_DOT_ALL = 1 &lt;&lt; 5, JSVM_REGEXP_LINEAR = 1 &lt;&lt; 6,<br/>JSVM_REGEXP_HAS_INDICES = 1 &lt;&lt; 7, JSVM_REGEXP_UNICODE_SETS = 1 &lt;&lt; 8<br/>} | 正则表达式标志位。它们可以用来启用一组标志。 | 
95e41f4b71Sopenharmony_ci| [JSVM_InitializedFlag](#jsvm_initializedflag) { JSVM_ZERO_INITIALIZED, JSVM_UNINITIALIZED } | 初始化方式的标志位 | 
96e41f4b71Sopenharmony_ci| [JSVM_WasmOptLevel](#jsvm_wasmoptlevel) { JSVM_WASM_OPT_BASELINE = 10, JSVM_WASM_OPT_HIGH = 20 } | WebAssembly 函数优化等级 | 
97e41f4b71Sopenharmony_ci| [JSVM_CacheType](#jsvm_cachetype) { JSVM_CACHE_TYPE_JS, JSVM_CACHE_TYPE_WASM } | 缓存类型 | 
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci### 函数
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci| 名称 | 描述 | 
103e41f4b71Sopenharmony_ci| -------- | -------- |
104e41f4b71Sopenharmony_ci| EXTERN_C_START JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_Init](#oh_jsvm_init) (const [JSVM_InitOptions](_j_s_v_m___init_options.md) \*options) | 初始化一个JavaScript虚拟机。 | 
105e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateVM](#oh_jsvm_createvm) (const [JSVM_CreateVMOptions](_j_s_v_m___create_v_m_options.md) \*options, [JSVM_VM](#jsvm_vm) \*result) | 创建一个虚拟机实例。 | 
106e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_DestroyVM](#oh_jsvm_destroyvm) ([JSVM_VM](#jsvm_vm) vm) | 销毁一个虚拟机实例。 | 
107e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_OpenVMScope](#oh_jsvm_openvmscope) ([JSVM_VM](#jsvm_vm) vm, [JSVM_VMScope](#jsvm_vmscope) \*result) | 为虚拟机实例打开一个新的虚拟机作用域。 | 
108e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CloseVMScope](#oh_jsvm_closevmscope) ([JSVM_VM](#jsvm_vm) vm, [JSVM_VMScope](#jsvm_vmscope) scope) | 关闭虚拟机实例的虚拟机作用域。 | 
109e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateEnv](#oh_jsvm_createenv) ([JSVM_VM](#jsvm_vm) vm, size_t propertyCount, const [JSVM_PropertyDescriptor](_j_s_v_m___property_descriptor.md) \*properties, [JSVM_Env](#jsvm_env) \*result) | 基于新环境上下文的可选属性,创建一个新环境。 | 
110e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateEnvFromSnapshot](#oh_jsvm_createenvfromsnapshot) ([JSVM_VM](#jsvm_vm) vm, size_t index, [JSVM_Env](#jsvm_env) \*result) | 基于虚拟机的起始快照,创建一个新的环境。 | 
111e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_DestroyEnv](#oh_jsvm_destroyenv) ([JSVM_Env](#jsvm_env) env) | 销毁环境。 | 
112e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_OpenEnvScope](#oh_jsvm_openenvscope) ([JSVM_Env](#jsvm_env) env, [JSVM_EnvScope](#jsvm_envscope) \*result) | 打开一个新的环境作用域。 | 
113e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CloseEnvScope](#oh_jsvm_closeenvscope) ([JSVM_Env](#jsvm_env) env, [JSVM_EnvScope](#jsvm_envscope) scope) | 关闭环境作用域。 | 
114e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetVM](#oh_jsvm_getvm) ([JSVM_Env](#jsvm_env) env, [JSVM_VM](#jsvm_vm) \*result) | 将检索给定环境的虚拟机实例。 | 
115e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CompileScript](#oh_jsvm_compilescript) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) script, const uint8_t \*cachedData, size_t cacheDataLength, bool eagerCompile, bool \*cacheRejected, [JSVM_Script](#jsvm_script) \*result) | 编译一串JavaScript代码,并返回编译后的脚本。 | 
116e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CompileScriptWithOrigin](#oh_jsvm_compilescriptwithorigin) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) script, const uint8_t \*cachedData, size_t cacheDataLength, bool eagerCompile, bool \*cacheRejected, [JSVM_ScriptOrigin](_j_s_v_m___script_origin.md) \*origin, [JSVM_Script](#jsvm_script) \*result) | 编译一串包含 sourcemap 信息的 JavaScript 代码,并返回编译后的脚本。 | 
117e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CompileScriptWithOptions](#oh_jsvm_compilescriptwithoptions) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) script, size_t optionCount, JSVM_CompileOptions options[], [JSVM_Value](#jsvm_value) \*result) | 编译一串JavaScript代码,并返回编译后的脚本。 | 
118e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateCodeCache](#oh_jsvm_createcodecache) ([JSVM_Env](#jsvm_env) env, [JSVM_Script](#jsvm_script) script, const uint8_t \*\*data, size_t \*length) | 为编译后的脚本创建代码缓存。 | 
119e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_RunScript](#oh_jsvm_runscript) ([JSVM_Env](#jsvm_env) env, [JSVM_Script](#jsvm_script) script, [JSVM_Value](#jsvm_value) \*result) | 执行一串JavaScript代码并返回其结果,其中包含以下注意事项: 与eval不同的是,该函数不允许脚本访问当前词法作用域,因此也不允许访问模块作用域, 这意味着require等伪全局变量将不可用。 脚本可以访问全局作用域。 脚本中的函数和var声明将被添加到全局对象。 使用let和const的变量声明将全局可见,但不会被添加到全局对象。 this的值在脚本内是global。 | 
120e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_SetInstanceData](#oh_jsvm_setinstancedata) ([JSVM_Env](#jsvm_env) env, void \*data, [JSVM_Finalize](#jsvm_finalize) finalizeCb, void \*finalizeHint) | 将data与当前运行的JSVM环境相关联。后续可以使用OH_JSVM_GetInstanceData()检索data。 通过先前调用OH_JSVM_SetInstanceData()设置的任何与当前运行的JSVM环境相关联的现有数据都将 被覆盖。如果先前提供了finalizeCb,则不会调用它。 | 
121e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetInstanceData](#oh_jsvm_getinstancedata) ([JSVM_Env](#jsvm_env) env, void \*\*data) | 检索通过OH_JSVM_SetInstanceData()与当前运行的JSVM环境相关联的数据。 如果未设置任何关联数据,该函数调用将成功,且data设置为NULL。 | 
122e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetLastErrorInfo](#oh_jsvm_getlasterrorinfo) ([JSVM_Env](#jsvm_env) env, const [JSVM_ExtendedErrorInfo](_j_s_v_m___extended_error_info.md) \*\*result) | 检索JSVM_ExtendedErrorInfo结构,其中包含有关发生的最后一个错误的信息。 返回的JSVM_ExtendedErrorInfo的内容仅在对同一env调用JSVM-API函数之前有效。 这包括对OH_JSVM_IsExceptionPending的调用,因此可能经常需要复制信息以便以后使用。 error_message中返回的指针指向一个静态定义的字符串,因此如果你在调用另一个JSVM-API 函数之前将它从error_message字段(将被覆盖)中复制出来,则可以安全地使用该指针。 | 
123e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_Throw](#oh_jsvm_throw) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) error) | 抛出提供的JavaScript值。 | 
124e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ThrowError](#oh_jsvm_throwerror) ([JSVM_Env](#jsvm_env) env, const char \*code, const char \*msg) | 会抛出带有所提供文本的JavaScript Error。 | 
125e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ThrowTypeError](#oh_jsvm_throwtypeerror) ([JSVM_Env](#jsvm_env) env, const char \*code, const char \*msg) | 会抛出带有所提供文本的JavaScript TypeError。 | 
126e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ThrowRangeError](#oh_jsvm_throwrangeerror) ([JSVM_Env](#jsvm_env) env, const char \*code, const char \*msg) | 会抛出带有所提供文本的JavaScript RangeError。 | 
127e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ThrowSyntaxError](#oh_jsvm_throwsyntaxerror) ([JSVM_Env](#jsvm_env) env, const char \*code, const char \*msg) | 会抛出带有所提供文本的JavaScript SyntaxError。 | 
128e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsError](#oh_jsvm_iserror) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*result) | 查询JSVM_Value以检查它是否表示错误对象。 | 
129e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateError](#oh_jsvm_createerror) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) code, [JSVM_Value](#jsvm_value) msg, [JSVM_Value](#jsvm_value) \*result) | 返回带有所提供文本的JavaScript Error。 | 
130e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateTypeError](#oh_jsvm_createtypeerror) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) code, [JSVM_Value](#jsvm_value) msg, [JSVM_Value](#jsvm_value) \*result) | 返回带有所提供文本的JavaScript TypeError。 | 
131e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateRangeError](#oh_jsvm_createrangeerror) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) code, [JSVM_Value](#jsvm_value) msg, [JSVM_Value](#jsvm_value) \*result) | 返回带有所提供文本的JavaScript RangeError。 | 
132e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateSyntaxError](#oh_jsvm_createsyntaxerror) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) code, [JSVM_Value](#jsvm_value) msg, [JSVM_Value](#jsvm_value) \*result) | 返回带有所提供文本的JavaScript SyntaxError。 | 
133e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetAndClearLastException](#oh_jsvm_getandclearlastexception) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) \*result) | 获取并清除上一次异常。如果出现挂起,则返回JavaScript异常,否则返回NULL。 | 
134e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsExceptionPending](#oh_jsvm_isexceptionpending) ([JSVM_Env](#jsvm_env) env, bool \*result) | 查询上一次异常是否由挂起导致的。如果由异常导致,则返回true,否则返回false。 | 
135e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_OpenHandleScope](#oh_jsvm_openhandlescope) ([JSVM_Env](#jsvm_env) env, [JSVM_HandleScope](#jsvm_handlescope) \*result) | 开辟了一个新的作用域。 | 
136e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CloseHandleScope](#oh_jsvm_closehandlescope) ([JSVM_Env](#jsvm_env) env, [JSVM_HandleScope](#jsvm_handlescope) scope) | 关闭传入的作用域。必须按照创建作用域的相反顺序关闭作用域。 | 
137e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_OpenEscapableHandleScope](#oh_jsvm_openescapablehandlescope) ([JSVM_Env](#jsvm_env) env, [JSVM_EscapableHandleScope](#jsvm_escapablehandlescope) \*result) | 会打开一个新作用域,从中可以将一个对象提升到外部作用域。 | 
138e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CloseEscapableHandleScope](#oh_jsvm_closeescapablehandlescope) ([JSVM_Env](#jsvm_env) env, [JSVM_EscapableHandleScope](#jsvm_escapablehandlescope) scope) | 关闭传入的作用域。必须按照创建作用域的相反顺序关闭作用域。 即使存在挂起的JavaScript异常,也可以调用此JSVM_API。 | 
139e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_EscapeHandle](#oh_jsvm_escapehandle) ([JSVM_Env](#jsvm_env) env, [JSVM_EscapableHandleScope](#jsvm_escapablehandlescope) scope, [JSVM_Value](#jsvm_value) escapee, [JSVM_Value](#jsvm_value) \*result) | 提升JavaScript对象的句柄,使其在外部作用域的生命周期内有效。 每个作用域只能调用一次。如果多次调用,将返回错误。 | 
140e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateReference](#oh_jsvm_createreference) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, uint32_t initialRefcount, [JSVM_Ref](#jsvm_ref) \*result) | 对传入的值创建一个具有指定引用计数的新引用。 | 
141e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_DeleteReference](#oh_jsvm_deletereference) ([JSVM_Env](#jsvm_env) env, [JSVM_Ref](#jsvm_ref) ref) | 删除传入的引用。 | 
142e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ReferenceRef](#oh_jsvm_referenceref) ([JSVM_Env](#jsvm_env) env, [JSVM_Ref](#jsvm_ref) ref, uint32_t \*result) | 增加传入引用的引用计数并返回生成的引用计数。 | 
143e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ReferenceUnref](#oh_jsvm_referenceunref) ([JSVM_Env](#jsvm_env) env, [JSVM_Ref](#jsvm_ref) ref, uint32_t \*result) | 递减传入引用的引用计数并返回生成的引用计数。 | 
144e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetReferenceValue](#oh_jsvm_getreferencevalue) ([JSVM_Env](#jsvm_env) env, [JSVM_Ref](#jsvm_ref) ref, [JSVM_Value](#jsvm_value) \*result) | 如果仍然有效,此JSVM-API将返回JSVM_Value, 表示与JSVM_Ref关联的JavaScript值。否则,结果将为NULL。 | 
145e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateArray](#oh_jsvm_createarray) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) \*result) | 返回对应于JavaScript Array类型的JSVM-API值。 | 
146e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateArrayWithLength](#oh_jsvm_createarraywithlength) ([JSVM_Env](#jsvm_env) env, size_t length, [JSVM_Value](#jsvm_value) \*result) | 返回对应于JavaScript Array类型的JSVM-API值。Array 的长度属性设置为传入的长度参数。但是,不保证底层缓冲区在创建 数组时由VM预先分配。该行为留给底层VM实现。 | 
147e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateArraybuffer](#oh_jsvm_createarraybuffer) ([JSVM_Env](#jsvm_env) env, size_t byteLength, void \*\*data, [JSVM_Value](#jsvm_value) \*result) | 返回JavaScript ArrayBuffer类型对应的JSVM-API值。ArrayBuffer用于 表示固定长度的二进制数据缓冲区。通常用作TypedArray对象的后备缓冲区。 分配的ArrayBuffer有一个底层字节缓冲区,其大小由传入的length参数决定。 底层缓冲区可选择返回给调用方,调用方可直接操作该缓冲区。 此缓冲区只能直接从native代码写入。如果想从JavaScript写入该缓冲区, 需创建TypedArray或DataView对象。 | 
148e41f4b71Sopenharmony_ci| [JSVM_Status](#jsvm_status) JSVM_CDECL [OH_JSVM_AllocateArrayBufferBackingStoreData](#oh_jsvm_allocatearraybufferbackingstoredata) (size_t byteLength, [JSVM_InitializedFlag](#jsvm_initializedflag) initialized, void \*\*data) | 申请一段给 array buffer 使用的 BackingStore 内存。 | 
149e41f4b71Sopenharmony_ci| [JSVM_Status](#jsvm_status) JSVM_CDECL [OH_JSVM_FreeArrayBufferBackingStoreData](#oh_jsvm_freearraybufferbackingstoredata) (void \*data) | 释放由 OH_JSVM_AllocateArrayBufferBackingStoreData 申请的 BackingStore 内存。 | 
150e41f4b71Sopenharmony_ci| [JSVM_Status](#jsvm_status) JSVM_CDECL [OH_JSVM_CreateArrayBufferFromBackingStoreData](#oh_jsvm_createarraybufferfrombackingstoredata) ([JSVM_Env](#jsvm_env) env, void \*data, size_t backingStoreSize, size_t offset, size_t arrayBufferSize, [JSVM_Value](#jsvm_value) \*result) | 在申请得到的 BackingStore 内存上创建 array buffer。 | 
151e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateDate](#oh_jsvm_createdate) ([JSVM_Env](#jsvm_env) env, double time, [JSVM_Value](#jsvm_value) \*result) | 分配一个JavaScript Date对象。此API不处理闰秒。 这是因为ECMAScript遵循POSIX时间规范,对闰秒进行忽略。 | 
152e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateExternal](#oh_jsvm_createexternal) ([JSVM_Env](#jsvm_env) env, void \*data, [JSVM_Finalize](#jsvm_finalize) finalizeCb, void \*finalizeHint, [JSVM_Value](#jsvm_value) \*result) | 分配一个带有外部数据的JavaScript值。这用于通过JavaScript代码传递外部数据。 后续可以使用OH_JSVM_GetValueExternal由native代码检索。 该API添加了一个JSVM_Finalize回调,当刚刚创建的JavaScript对象被垃圾回收时将调用该回调。 创建的值不是一个对象,因此不支持附加属性。它被认为是一个独特的值类型: 使用外部值调用OH_JSVM_Typeof()会生成JSVM_EXTERNAL。 | 
153e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateObject](#oh_jsvm_createobject) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) \*result) | 分配一个默认的JavaScript对象。该函数功能等同于在JavaScript中执行new Object()。 | 
154e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateSymbol](#oh_jsvm_createsymbol) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) description, [JSVM_Value](#jsvm_value) \*result) | 从UTF8 编码的C字符串创建JavaScript symbol值。 | 
155e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_SymbolFor](#oh_jsvm_symbolfor) ([JSVM_Env](#jsvm_env) env, const char \*utf8description, size_t length, [JSVM_Value](#jsvm_value) \*result) | 在全局注册表中搜索具有给定描述的现有符号。如果该 符号已经存在,它将被返回,否则将在注册表中创建一个新符号。 | 
156e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateTypedarray](#oh_jsvm_createtypedarray) ([JSVM_Env](#jsvm_env) env, [JSVM_TypedarrayType](#jsvm_typedarraytype) type, size_t length, [JSVM_Value](#jsvm_value) arraybuffer, size_t byteOffset, [JSVM_Value](#jsvm_value) \*result) | 基于已有的ArrayBuffer对象,创建一个JavaScript TypedArray对象。TypedArray 对象在底层数据缓冲区上提供了一个类似数组的视图,其中每个元素都具有 相同的底层二进制标量数据类型。要求:(length\* 元素大小)+ byteOffset 小于等于传入的数组的大小(以字节为单位)。否则,将抛出范围错误(RangeError)。 | 
157e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateDataview](#oh_jsvm_createdataview) ([JSVM_Env](#jsvm_env) env, size_t length, [JSVM_Value](#jsvm_value) arraybuffer, size_t byteOffset, [JSVM_Value](#jsvm_value) \*result) | 基于已有的ArrayBuffer对象,创建一个JavaScript DataView对象。DataView 对象在底层数据缓冲区上提供了一个类似数组的视图,其中的元素可以具有不同的大小和类型。 要求:二进制的length + byteOffset 小于或等于传入的数组的大小(以字节为单位)。否则,将抛出范围错误(RangeError)。 | 
158e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateInt32](#oh_jsvm_createint32) ([JSVM_Env](#jsvm_env) env, int32_t value, [JSVM_Value](#jsvm_value) \*result) | 将C int32_t类型的值转换为JavaScript number类型。 | 
159e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateUint32](#oh_jsvm_createuint32) ([JSVM_Env](#jsvm_env) env, uint32_t value, [JSVM_Value](#jsvm_value) \*result) | 将C uint32_t类型的值转换为JavaScript number类型。 | 
160e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateInt64](#oh_jsvm_createint64) ([JSVM_Env](#jsvm_env) env, int64_t value, [JSVM_Value](#jsvm_value) \*result) | 将C int64_t类型的值转换为JavaScript number类型。 | 
161e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateDouble](#oh_jsvm_createdouble) ([JSVM_Env](#jsvm_env) env, double value, [JSVM_Value](#jsvm_value) \*result) | 将C double类型的值转换为JavaScript number类型。 | 
162e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateBigintInt64](#oh_jsvm_createbigintint64) ([JSVM_Env](#jsvm_env) env, int64_t value, [JSVM_Value](#jsvm_value) \*result) | 将C int64_t类型的值转换为JavaScript BigInt类型。 | 
163e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateBigintUint64](#oh_jsvm_createbigintuint64) ([JSVM_Env](#jsvm_env) env, uint64_t value, [JSVM_Value](#jsvm_value) \*result) | 将C uint64_t类型的值转换为JavaScript BigInt类型。 | 
164e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateBigintWords](#oh_jsvm_createbigintwords) ([JSVM_Env](#jsvm_env) env, int signBit, size_t wordCount, const uint64_t \*words, [JSVM_Value](#jsvm_value) \*result) | 将一组无符号64位字转换为单个BigInt值。 | 
165e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateStringLatin1](#oh_jsvm_createstringlatin1) ([JSVM_Env](#jsvm_env) env, const char \*str, size_t length, [JSVM_Value](#jsvm_value) \*result) | 将采用ISO-8859-1编码的C字符串转换为JavaScript string值。 复制原生字符串。 | 
166e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateStringUtf16](#oh_jsvm_createstringutf16) ([JSVM_Env](#jsvm_env) env, const char16_t \*str, size_t length, [JSVM_Value](#jsvm_value) \*result) | 将采用UTF16-LE编码的C字符串转换为JavaScript字符串值。 复制原生字符串。 | 
167e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateStringUtf8](#oh_jsvm_createstringutf8) ([JSVM_Env](#jsvm_env) env, const char \*str, size_t length, [JSVM_Value](#jsvm_value) \*result) | 从UTF8编码的C字符串创建JavaScript string值。 复制原生字符串。 | 
168e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetArrayLength](#oh_jsvm_getarraylength) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, uint32_t \*result) | 返回数组的长度。 | 
169e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetArraybufferInfo](#oh_jsvm_getarraybufferinfo) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) arraybuffer, void \*\*data, size_t \*byteLength) | 用于检索ArrayBuffer的底层数据缓冲区及其长度。 | 
170e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetPrototype](#oh_jsvm_getprototype) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, [JSVM_Value](#jsvm_value) \*result) | 返回对象的原型。 | 
171e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetTypedarrayInfo](#oh_jsvm_gettypedarrayinfo) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) typedarray, [JSVM_TypedarrayType](#jsvm_typedarraytype) \*type, size_t \*length, void \*\*data, [JSVM_Value](#jsvm_value) \*arraybuffer, size_t \*byteOffset) | 返回类型化数组的各种属性。如果不需要该属性,则任何输出参数都可以是 NULL。 | 
172e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetDataviewInfo](#oh_jsvm_getdataviewinfo) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) dataview, size_t \*bytelength, void \*\*data, [JSVM_Value](#jsvm_value) \*arraybuffer, size_t \*byteOffset) | 返回DataView的各种属性。 如果不需要某一属性,则任何出参都可以设置为NULL。 | 
173e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetDateValue](#oh_jsvm_getdatevalue) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, double \*result) | 返回给定JavaScript Date的时间值的C双精度基础类型。如果调用成功,返回JSVM_OK。 如果传入一个非JavaScript Date类型的JSVM_Value,返回JSVM_DATA_EXPECTED。 | 
174e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueBool](#oh_jsvm_getvaluebool) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*result) | 返回给定JavaScript Boolean的C布尔基础类型等价值。 | 
175e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueDouble](#oh_jsvm_getvaluedouble) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, double \*result) | 返回给定JavaScript number的C双精度基础类型等价值。 | 
176e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueBigintInt64](#oh_jsvm_getvaluebigintint64) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, int64_t \*result, bool \*lossless) | 返回给定JavaScript BigInt的C int64_t基础类型等价值。 如果需要,它将截断该值,将lossless设置为false。 | 
177e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueBigintUint64](#oh_jsvm_getvaluebigintuint64) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, uint64_t \*result, bool \*lossless) | 返回给定JavaScript BigInt的C uint64_t基础类型等价值。 如果需要,它将截断该值,将lossless设置为false。 | 
178e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueBigintWords](#oh_jsvm_getvaluebigintwords) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, int \*signBit, size_t \*wordCount, uint64_t \*words) | 将单个BigInt值转换为符号位、64位小端数组和数组中的元素数。 signBit和words参数可以都设置为NULL。这种情况下,只获取wordCount。 | 
179e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueExternal](#oh_jsvm_getvalueexternal) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, void \*\*result) | 检索之前传递给OH_JSVM_CreateExternal()的外部数据指针。 | 
180e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueInt32](#oh_jsvm_getvalueint32) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, int32_t \*result) | 返回给定JavaScript number的C int32基础类型等价值。 | 
181e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueInt64](#oh_jsvm_getvalueint64) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, int64_t \*result) | 返回给定JavaScript number的C int64基础类型等价值。 | 
182e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueStringLatin1](#oh_jsvm_getvaluestringlatin1) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, char \*buf, size_t bufsize, size_t \*result) | 返回对应于传入值的ISO-8859-1编码字符串 | 
183e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueStringUtf8](#oh_jsvm_getvaluestringutf8) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, char \*buf, size_t bufsize, size_t \*result) | 返回对应于传入值的UTF8编码字符串。 | 
184e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueStringUtf16](#oh_jsvm_getvaluestringutf16) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, char16_t \*buf, size_t bufsize, size_t \*result) | 基于传入的值,查询对应的采用UTF16编码的字符串。 | 
185e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetValueUint32](#oh_jsvm_getvalueuint32) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, uint32_t \*result) | 返回给定JavaScript number的C uint_32基础类型等价值。 | 
186e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetBoolean](#oh_jsvm_getboolean) ([JSVM_Env](#jsvm_env) env, bool value, [JSVM_Value](#jsvm_value) \*result) | 返回用于表示给定布尔值的JavaScript单例对象。 | 
187e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetGlobal](#oh_jsvm_getglobal) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) \*result) | 返回global对象。 | 
188e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetNull](#oh_jsvm_getnull) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) \*result) | 返回null对象。 | 
189e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetUndefined](#oh_jsvm_getundefined) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) \*result) | 返回Undefined对象。 | 
190e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CoerceToBool](#oh_jsvm_coercetobool) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, [JSVM_Value](#jsvm_value) \*result) | 实现抽象操作ToBoolean()。 | 
191e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CoerceToNumber](#oh_jsvm_coercetonumber) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, [JSVM_Value](#jsvm_value) \*result) | 实现抽象操作ToNumber()。 如果传入的值是对象,则函数可能会运行JavaScript代码。 | 
192e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CoerceToObject](#oh_jsvm_coercetoobject) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, [JSVM_Value](#jsvm_value) \*result) | 实现抽象操作ToObject()。 | 
193e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CoerceToString](#oh_jsvm_coercetostring) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, [JSVM_Value](#jsvm_value) \*result) | 实现抽象操作ToString()。 如果传入的值是对象,则函数可能会运行JavaScript代码。 | 
194e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_Typeof](#oh_jsvm_typeof) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, [JSVM_ValueType](#jsvm_valuetype) \*result) | 提供类似于在定义的对象上调用typeof运算符的行为。 不同点在于,该函数支持检测外部值;它将null检测为单独的类型, 而ECMAScript typeof将用于检测object。如果value的类型无效,则返回错误。 | 
195e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_Instanceof](#oh_jsvm_instanceof) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, [JSVM_Value](#jsvm_value) constructor, bool \*result) | 提供类似于在对象上调用instanceof运算符的行为。 | 
196e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsArray](#oh_jsvm_isarray) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*result) | 提供类似于在对象上调用IsArray的行为。 | 
197e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsArraybuffer](#oh_jsvm_isarraybuffer) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*result) | 检查传入的对象是否为ArrayBuffer。 | 
198e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsDate](#oh_jsvm_isdate) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isDate) | 检查传入的Object是否为日期。 | 
199e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsTypedarray](#oh_jsvm_istypedarray) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*result) | 检查传入的Object是否为类型化数组。 | 
200e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsDataview](#oh_jsvm_isdataview) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*result) | 检查传入的对象是否是DataView。 | 
201e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_StrictEquals](#oh_jsvm_strictequals) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) lhs, [JSVM_Value](#jsvm_value) rhs, bool \*result) | 提供类似调用严格相等算法的行为。 | 
202e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_Equals](#oh_jsvm_equals) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) lhs, [JSVM_Value](#jsvm_value) rhs, bool \*result) | 提供类似调用宽松相等算法的行为。 无论JavaScript值类型如何,只要值相等,就返回true。 | 
203e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_DetachArraybuffer](#oh_jsvm_detacharraybuffer) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) arraybuffer) | 提供类似于调用ArrayBuffer detach操作的行为。 | 
204e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsDetachedArraybuffer](#oh_jsvm_isdetachedarraybuffer) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*result) | 提供类似调用ArrayBuffer IsDetachedBuffer操作的行为。 | 
205e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetPropertyNames](#oh_jsvm_getpropertynames) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, [JSVM_Value](#jsvm_value) \*result) | 以字符数数组的形式返回object的可枚举属性的名称。 key为符号的object的属性将不会被包含在内。 | 
206e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetAllPropertyNames](#oh_jsvm_getallpropertynames) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, [JSVM_KeyCollectionMode](#jsvm_keycollectionmode) keyMode, [JSVM_KeyFilter](#jsvm_keyfilter) keyFilter, [JSVM_KeyConversion](#jsvm_keyconversion) keyConversion, [JSVM_Value](#jsvm_value) \*result) | 返回一个数组,其中包含此对象的可用属性的名称。 | 
207e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_SetProperty](#oh_jsvm_setproperty) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, [JSVM_Value](#jsvm_value) key, [JSVM_Value](#jsvm_value) value) | 为传入的object设置一个属性。 | 
208e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetProperty](#oh_jsvm_getproperty) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, [JSVM_Value](#jsvm_value) key, [JSVM_Value](#jsvm_value) \*result) | 从传入的object中获取请求的属性。 | 
209e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_HasProperty](#oh_jsvm_hasproperty) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, [JSVM_Value](#jsvm_value) key, bool \*result) | 检查传入的Object是否具有指定命名的属性。 | 
210e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_DeleteProperty](#oh_jsvm_deleteproperty) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, [JSVM_Value](#jsvm_value) key, bool \*result) | 尝试从object中删除key自己的属性。 | 
211e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_HasOwnProperty](#oh_jsvm_hasownproperty) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, [JSVM_Value](#jsvm_value) key, bool \*result) | 检查传入的Object是否具有命名的自己的属性。key必须是string或symbol, 否则将抛出错误。JSVM-API不会执行任何数据类型之间的转换。 | 
212e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_SetNamedProperty](#oh_jsvm_setnamedproperty) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, const char \*utf8name, [JSVM_Value](#jsvm_value) value) | 此方法等效于调用OH_JSVM_SetProperty, 其中,通过utf8Name传入的字符串用于创建JSVM_Value。 | 
213e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetNamedProperty](#oh_jsvm_getnamedproperty) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, const char \*utf8name, [JSVM_Value](#jsvm_value) \*result) | 此方法等效于调用OH_JSVM_GetProperty, 其中,通过utf8Name传入的字符串用于创建JSVM_Value。 | 
214e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_HasNamedProperty](#oh_jsvm_hasnamedproperty) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, const char \*utf8name, bool \*result) | 此方法等效于使用从作为utf8Name传入的字符串创建的JSVM_Value 调用OH_JSVM_HasProperty。 | 
215e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_SetElement](#oh_jsvm_setelement) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, uint32_t index, [JSVM_Value](#jsvm_value) value) | 在传入的Object上设置一个元素。 | 
216e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetElement](#oh_jsvm_getelement) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, uint32_t index, [JSVM_Value](#jsvm_value) \*result) | 获取请求索引处的元素。 | 
217e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_HasElement](#oh_jsvm_haselement) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, uint32_t index, bool \*result) | 如果传入的Object在指定的索引处有一个元素,则此JSVM-API返回true。 | 
218e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_DeleteElement](#oh_jsvm_deleteelement) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, uint32_t index, bool \*result) | 尝试从object中删除指定index处的元素。 | 
219e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_DefineProperties](#oh_jsvm_defineproperties) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, size_t propertyCount, const [JSVM_PropertyDescriptor](_j_s_v_m___property_descriptor.md) \*properties) | 通过此方法可以在给定对象上高效定义多个属性, 这些属性使用属性描述符进行定义。通过一个属性描述符的数组, 此API将为对象依次设置数组中的属性。 | 
220e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ObjectFreeze](#oh_jsvm_objectfreeze) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object) | 冻结指定的对象。这样可以防止为其添加新的属性、删除现有属性、更改现有属性的 可枚举性、可配置性或可写性、或者更改现有属性的值。它还可以防止改变对象的原型。 | 
221e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ObjectSeal](#oh_jsvm_objectseal) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object) | 封装指定的对象。这样可以防止为其添加新的属性并且将所有现有属性标记为不可配置。 | 
222e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CallFunction](#oh_jsvm_callfunction) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) recv, [JSVM_Value](#jsvm_value) func, size_t argc, const [JSVM_Value](#jsvm_value) \*argv, [JSVM_Value](#jsvm_value) \*result) | 支持从native代码调用JavaScript函数对象, 这是从native代码回调到JavaScript的主要机制。 | 
223e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateFunction](#oh_jsvm_createfunction) ([JSVM_Env](#jsvm_env) env, const char \*utf8name, size_t length, [JSVM_Callback](#jsvm_callback) cb, [JSVM_Value](#jsvm_value) \*result) | 支持在native代码中创建函数对象,这是从JavaScript调用native代码的主要机制。 在此调用之后,新创建的函数在脚本中不再自动可见。相反,必须在JavaScript可见的任何对象上显示设置属性, 才能从脚本访问该函数。 | 
224e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetCbInfo](#oh_jsvm_getcbinfo) ([JSVM_Env](#jsvm_env) env, [JSVM_CallbackInfo](#jsvm_callbackinfo) cbinfo, size_t \*argc, [JSVM_Value](#jsvm_value) \*argv, [JSVM_Value](#jsvm_value) \*thisArg, void \*\*data) | 此方法在回调函数中用于检索有关调用的详细信息, 例如来自给定回调信息的参数和this指针。 | 
225e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetNewTarget](#oh_jsvm_getnewtarget) ([JSVM_Env](#jsvm_env) env, [JSVM_CallbackInfo](#jsvm_callbackinfo) cbinfo, [JSVM_Value](#jsvm_value) \*result) | 返回构造函数调用的new target。 如果当前回调不是构造函数调用,结果为NULL。 | 
226e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_NewInstance](#oh_jsvm_newinstance) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) constructor, size_t argc, const [JSVM_Value](#jsvm_value) \*argv, [JSVM_Value](#jsvm_value) \*result) | 使用给定的JSVM_Value表示的构造函数来实例化新的JavaScript值。 | 
227e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_DefineClass](#oh_jsvm_defineclass) ([JSVM_Env](#jsvm_env) env, const char \*utf8name, size_t length, [JSVM_Callback](#jsvm_callback) constructor, size_t propertyCount, const [JSVM_PropertyDescriptor](_j_s_v_m___property_descriptor.md) \*properties, [JSVM_Value](#jsvm_value) \*result) | 定义一个JavaScript类。 | 
228e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_Wrap](#oh_jsvm_wrap) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) jsObject, void \*nativeObject, [JSVM_Finalize](#jsvm_finalize) finalizeCb, void \*finalizeHint, [JSVM_Ref](#jsvm_ref) \*result) | 在JavaScript对象中封装native实例。native实例 后续可以通过OH_JSVM_Unwrap()进行检索。 | 
229e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_Unwrap](#oh_jsvm_unwrap) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) jsObject, void \*\*result) | 当JavaScript代码调用类的方法或属性访问器时,对应的JSVM_Callback将被调用。 如果回调是针对实例方法或访问器的,则回调的this参数是封装器对象;然后可以通过调用 封装器对象的OH_JSVM_Unwrap()获得作为调用目标的C++实例。 | 
230e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_RemoveWrap](#oh_jsvm_removewrap) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) jsObject, void \*\*result) | 使用OH_JSVM_Wrap()检索先前封装在JavaScript对象js_object中的native实例并移除封装。 如果finalize回调与封装相关联,则当JavaScript对象被垃圾回收时将不再调用它。 | 
231e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_TypeTagObject](#oh_jsvm_typetagobject) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, const [JSVM_TypeTag](_j_s_v_m___type_tag.md) \*typeTag) | 将typeTag指针的值与JavaScript对象或外部值相关联。可调用OH_JSVM_CheckObjectTypeTag() 判断附加在对象上的标记类型,以确保对象的类型正确。如果对象已经有关联的类型标记,则返回JSVM_INVALID_ARG。 | 
232e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CheckObjectTypeTag](#oh_jsvm_checkobjecttypetag) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, const [JSVM_TypeTag](_j_s_v_m___type_tag.md) \*typeTag, bool \*result) | 将类型标签typeTag与JavaScript对象或外部值上的标签作对比。如果找到相同标签, 设置result为true,否则为false。 | 
233e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_AddFinalizer](#oh_jsvm_addfinalizer) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) jsObject, void \*finalizeData, [JSVM_Finalize](#jsvm_finalize) finalizeCb, void \*finalizeHint, [JSVM_Ref](#jsvm_ref) \*result) | 为JavaScript对象添加JSVM_Finalize回调,当JavaScript对象被垃圾回收时调用该回调函数。 可以在单个JavaScript对象上多次调用OH_JSVM_AddFinalizer。 | 
234e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetVersion](#oh_jsvm_getversion) ([JSVM_Env](#jsvm_env) env, uint32_t \*result) | 返回JSVM运行时支持的最高JSVM-API版本。 后续将新增JSVM-API,以便支持更多的功能。引入该API的目的:在支持某功能的JSVM版本, 可以使用新的功能;在不支持某功能的JSVM版本,可以提供回调行为。 | 
235e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetVMInfo](#oh_jsvm_getvminfo) ([JSVM_VMInfo](_j_s_v_m___v_m_info.md) \*result) | 返回虚拟机的信息。 | 
236e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_AdjustExternalMemory](#oh_jsvm_adjustexternalmemory) ([JSVM_Env](#jsvm_env) env, int64_t changeInBytes, int64_t \*result) | 此函数将因JavaScript对象而保持活跃的外部分配的内存大小通知给底层虚拟机。 注册外部分配的内存将比其他方式更频繁地触发全局垃圾回收。 | 
237e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_MemoryPressureNotification](#oh_jsvm_memorypressurenotification) ([JSVM_Env](#jsvm_env) env, [JSVM_MemoryPressureLevel](#jsvm_memorypressurelevel) level) | 通知虚拟机系统内存不足并有选择地触发垃圾回收。 | 
238e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreatePromise](#oh_jsvm_createpromise) ([JSVM_Env](#jsvm_env) env, [JSVM_Deferred](#jsvm_deferred) \*deferred, [JSVM_Value](#jsvm_value) \*promise) | 创建一个延迟对象和一个JavaScript promise。 | 
239e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ResolveDeferred](#oh_jsvm_resolvedeferred) ([JSVM_Env](#jsvm_env) env, [JSVM_Deferred](#jsvm_deferred) deferred, [JSVM_Value](#jsvm_value) resolution) | 通过与之关联的延迟对象来解析JavaScript promise。 它只能用于解析对应的可用的延迟对象的JavaScript Promise。 这意味着Promise必须使用OH_JSVM_CreatePromise()创建,并且 从该调用返回的对象必须保留,才能将其传递给此API。 | 
240e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_RejectDeferred](#oh_jsvm_rejectdeferred) ([JSVM_Env](#jsvm_env) env, [JSVM_Deferred](#jsvm_deferred) deferred, [JSVM_Value](#jsvm_value) rejection) | 通过与之关联的延迟对象来拒绝JavaScript Promise。 它只能用于拒绝对应的可用延迟对象的JavaScript Promise。 这意味着Promise必须使用OH_JSVM_CreatePromise()创建,并且 从该调用返回的对象必须保留,才能将其传递给此API。 | 
241e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsPromise](#oh_jsvm_ispromise) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isPromise) | 查询Promise是否为原生Promise对象。 | 
242e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_JsonParse](#oh_jsvm_jsonparse) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) jsonString, [JSVM_Value](#jsvm_value) \*result) | 解析JSON字符串,并返回成功解析的值。 | 
243e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_JsonStringify](#oh_jsvm_jsonstringify) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) jsonObject, [JSVM_Value](#jsvm_value) \*result) | 将对象字符串化,并返回成功转换后的字符串。 | 
244e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateSnapshot](#oh_jsvm_createsnapshot) ([JSVM_VM](#jsvm_vm) vm, size_t contextCount, const [JSVM_Env](#jsvm_env) \*contexts, const char \*\*blobData, size_t \*blobSize) | 创建虚拟机的启动快照。 | 
245e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_GetHeapStatistics](#oh_jsvm_getheapstatistics) ([JSVM_VM](#jsvm_vm) vm, [JSVM_HeapStatistics](_j_s_v_m___heap_statistics.md) \*result) | 返回一组虚拟机堆的统计数据。 | 
246e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_StartCpuProfiler](#oh_jsvm_startcpuprofiler) ([JSVM_VM](#jsvm_vm) vm, [JSVM_CpuProfiler](#jsvm_cpuprofiler) \*result) | 创建并启动一个CPU profiler。 | 
247e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_StopCpuProfiler](#oh_jsvm_stopcpuprofiler) ([JSVM_VM](#jsvm_vm) vm, [JSVM_CpuProfiler](#jsvm_cpuprofiler) profiler, [JSVM_OutputStream](#jsvm_outputstream) stream, void \*streamData) | 停止CPU profiler并将结果输出到流。 | 
248e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_TakeHeapSnapshot](#oh_jsvm_takeheapsnapshot) ([JSVM_VM](#jsvm_vm) vm, [JSVM_OutputStream](#jsvm_outputstream) stream, void \*streamData) | 获取当前堆快照并将其输出到流。 | 
249e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_OpenInspector](#oh_jsvm_openinspector) ([JSVM_Env](#jsvm_env) env, const char \*host, uint16_t port) | 在指定的主机和端口上激活inspector,将用来调试JS代码。 | 
250e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CloseInspector](#oh_jsvm_closeinspector) ([JSVM_Env](#jsvm_env) env) | 尝试关闭剩余的所有inspector连接。 | 
251e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_WaitForDebugger](#oh_jsvm_waitfordebugger) ([JSVM_Env](#jsvm_env) env, bool breakNextLine) | 等待主机与inspector建立socket连接,连接建立后程序将继续运行。 发送Runtime.runIfWaitingForDebugger命令。 | 
252e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_DefineClassWithPropertyHandler](#oh_jsvm_defineclasswithpropertyhandler) ([JSVM_Env](#jsvm_env) env, const char \*utf8name, size_t length, [JSVM_Callback](#jsvm_callback) constructor, size_t propertyCount, const [JSVM_PropertyDescriptor](_j_s_v_m___property_descriptor.md) \*properties, [JSVM_PropertyHandlerCfg](#jsvm_propertyhandlercfg) propertyHandlerCfg, [JSVM_Callback](#jsvm_callback) callAsFunctionCallback, [JSVM_Value](#jsvm_value) \*result) | 定义一个具有给定类名、构造函数、属性和回调处理程序的JavaScript类属性操作包括getter、setter、deleter、enumerator等,并作为函数回调进行调用。 | 
253e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsUndefined](#oh_jsvm_isundefined) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isUndefined) | 此API检查传入的值是否为Undefined。 这相当于JS中的value === undefined。 | 
254e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsNull](#oh_jsvm_isnull) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isNull) | 此API检查传入的值是否为Null对象。 这相当于JS中的value === null。 | 
255e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsNullOrUndefined](#oh_jsvm_isnullorundefined) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isNullOrUndefined) | 此API检查传入的值是否为Null或Undefined。 这相当于JS中的value == null。 | 
256e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsBoolean](#oh_jsvm_isboolean) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isBoolean) | 此API检查传入的值是否为Boolean。 这相当于JS中的‘typeof value === 'boolean’`。 | 
257e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsNumber](#oh_jsvm_isnumber) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isNumber) | 此API检查传入的值是否为Number。 这相当于JS中的‘typeof value === 'number’`。 | 
258e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsString](#oh_jsvm_isstring) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isString) | 此API检查传入的值是否为String。 这相当于JS中的‘typeof value === 'string’`。 | 
259e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsSymbol](#oh_jsvm_issymbol) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isSymbol) | 此API检查传入的值是否为Symbol。 这相当于JS中的‘typeof value === 'symbol’`。 | 
260e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsFunction](#oh_jsvm_isfunction) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isFunction) | 此API检查传入的值是否为Function。 这相当于JS中的‘typeof value === 'function’`。 | 
261e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsObject](#oh_jsvm_isobject) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isObject) | 此API检查传入的值是否为Object。 | 
262e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsBigInt](#oh_jsvm_isbigint) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isBigInt) | 此API检查传入的值是否为BigInt。 这相当于JS中的‘typeof value === 'bigint’`。 | 
263e41f4b71Sopenharmony_ci| [JSVM_Status](#jsvm_status) JSVM_CDECL [OH_JSVM_CreateMap](#oh_jsvm_createmap) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) \*result) | 此API返回与JavaScript Map类型对应的JavaScript值。 | 
264e41f4b71Sopenharmony_ci| [JSVM_Status](#jsvm_status) JSVM_CDECL [OH_JSVM_IsMap](#oh_jsvm_ismap) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isMap) | 此API检查传入的值是否为Map。 | 
265e41f4b71Sopenharmony_ci| [JSVM_Status](#jsvm_status) JSVM_CDECL [OH_JSVM_IsConstructor](#oh_jsvm_isconstructor) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isConstructor) | 此API检查传入的值是否为构造函数。 | 
266e41f4b71Sopenharmony_ci| [JSVM_Status](#jsvm_status) JSVM_CDECL [OH_JSVM_CreateRegExp](#oh_jsvm_createregexp) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, [JSVM_RegExpFlags](#jsvm_regexpflags) flags, [JSVM_Value](#jsvm_value) \*result) | 此API返回与输入对应的正则表达式的JavaScript值。 接口可能会抛出异常。 | 
267e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ObjectGetPrototypeOf](#oh_jsvm_objectgetprototypeof) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, [JSVM_Value](#jsvm_value) \*result) | 获取JavaScript object的原型。 | 
268e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ObjectSetPrototypeOf](#oh_jsvm_objectsetprototypeof) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) object, [JSVM_Value](#jsvm_value) prototype) | 设置给定的JavaScript object的原型。 | 
269e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateSet](#oh_jsvm_createset) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) \*result) | 创建JavaScript Set对象。 | 
270e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsSet](#oh_jsvm_isset) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*isSet) | 判断给定的对象是否是Set类型。 | 
271e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CoerceToBigInt](#oh_jsvm_coercetobigint) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, [JSVM_Value](#jsvm_value) \*result) | 实现抽象操作ToBigInt()。 | 
272e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsRegExp](#oh_jsvm_isregexp) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*result) | 此API检查传入的值是否为JavaScript RegExp对象。 | 
273e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateFunctionWithScript](#oh_jsvm_createfunctionwithscript) ([JSVM_Env](#jsvm_env) env, const char \*funcName, size_t length, size_t argc, const [JSVM_Value](#jsvm_value) \*argv, [JSVM_Value](#jsvm_value) script, [JSVM_Value](#jsvm_value) \*result) | 创建一个以给定JavaScript为函数体的函数。 | 
274e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_PumpMessageLoop](#oh_jsvm_pumpmessageloop) ([JSVM_VM](#jsvm_vm) vm, bool \*result) | 启动虚拟机内任务队列的运行。这个任务队列可以通过外部事件循环来执行。 | 
275e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_PerformMicrotaskCheckpoint](#oh_jsvm_performmicrotaskcheckpoint) ([JSVM_VM](#jsvm_vm) vm) | 检查队列中是否有微任务等待,如果存在则执行它们。 | 
276e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_RetainScript](#oh_jsvm_retainscript) ([JSVM_Env](#jsvm_env) env, [JSVM_Script](#jsvm_script) script) | 持久保存一个JSVM_Script并将其生命周期延长到当前作用域之外. | 
277e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ReleaseScript](#oh_jsvm_releasescript) ([JSVM_Env](#jsvm_env) env, [JSVM_Script](#jsvm_script) script) | 此函数释放由OH_JSVM_RetainScript保留的脚本,释放后应避免对传入 script 的再次使用. | 
278e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_OpenInspectorWithName](#oh_jsvm_openinspectorwithname) ([JSVM_Env](#jsvm_env) env, int pid, const char \*name) | 此函数打开一个命名为传入 name 的 inspector,为其打开对应 pid 的 unix domain 端口. | 
279e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CompileWasmModule](#oh_jsvm_compilewasmmodule) ([JSVM_Env](#jsvm_env) env, const uint8_t \*wasmBytecode, size_t wasmBytecodeLength, const uint8_t \*cacheData, size_t cacheDataLength, bool \*cacheRejected, [JSVM_Value](#jsvm_value) \*wasmModule) | 将 WebAssembly 字节码编译得到一个 WebAssembly 模块。 如果提供了 WebAssembly 缓存,则会先尝试对缓存进行反序列化。 | 
280e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CompileWasmFunction](#oh_jsvm_compilewasmfunction) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) wasmModule, uint32_t functionIndex, [JSVM_WasmOptLevel](#jsvm_wasmoptlevel) optLevel) | 对当前 WebAssembly 模块中指定索引的函数进行指定优化等级的编译优化。 | 
281e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_IsWasmModuleObject](#oh_jsvm_iswasmmoduleobject) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) value, bool \*result) | 判断给定的 JSVM_Value 是否是一个 WebAssembly 模块。 | 
282e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_CreateWasmCache](#oh_jsvm_createwasmcache) ([JSVM_Env](#jsvm_env) env, [JSVM_Value](#jsvm_value) wasmModule, const uint8_t \*\*data, size_t \*length) | 为给定的 WebAssembly 模块生成缓存。 | 
283e41f4b71Sopenharmony_ci| JSVM_EXTERN [JSVM_Status](#jsvm_status) [OH_JSVM_ReleaseCache](#oh_jsvm_releasecache) ([JSVM_Env](#jsvm_env) env, const uint8_t \*cacheData, [JSVM_CacheType](#jsvm_cachetype) cacheType) | 释放给定类型的缓存数据。 | 
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci## 宏定义说明
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ci### JSVM_AUTO_LENGTH
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ci```
292e41f4b71Sopenharmony_ci#define JSVM_AUTO_LENGTH   SIZE_MAX
293e41f4b71Sopenharmony_ci```
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci**描述**
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci自动长度。
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci**起始版本:** 11
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci## 类型定义说明
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci### JSVM_Callback
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ci```
308e41f4b71Sopenharmony_citypedef JSVM_CallbackStruct* JSVM_Callback
309e41f4b71Sopenharmony_ci```
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ci**描述**
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_ci用户提供的native函数的函数指针类型,这些函数通过JSVM-API接口暴露给JavaScript。
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_ci**起始版本:** 11
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ci### JSVM_CallbackInfo
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci```
321e41f4b71Sopenharmony_citypedef struct JSVM_CallbackInfo__* JSVM_CallbackInfo
322e41f4b71Sopenharmony_ci```
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci**描述**
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci表示传递给回调函数的不透明数据类型。可用于获取调用该函数的上下文的附加信息。
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ci**起始版本:** 11
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci### JSVM_CpuProfiler
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci```
334e41f4b71Sopenharmony_citypedef struct JSVM_CpuProfiler__* JSVM_CpuProfiler
335e41f4b71Sopenharmony_ci```
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci**描述**
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci表示一个JavaScript CPU时间性能分析器。
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci**起始版本:** 12
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci
344e41f4b71Sopenharmony_ci### JSVM_Deferred
345e41f4b71Sopenharmony_ci
346e41f4b71Sopenharmony_ci```
347e41f4b71Sopenharmony_citypedef struct JSVM_Deferred__* JSVM_Deferred
348e41f4b71Sopenharmony_ci```
349e41f4b71Sopenharmony_ci
350e41f4b71Sopenharmony_ci**描述**
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_ci表示Promise延迟对象。
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci**起始版本:** 11
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci### JSVM_Env
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci```
360e41f4b71Sopenharmony_citypedef struct JSVM_Env__* JSVM_Env
361e41f4b71Sopenharmony_ci```
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_ci**描述**
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ci表示虚拟机特定状态的上下文环境,需要在调用native函数时作为参数传递, 并且传递给后续任何的JSVM-API嵌套调用。
366e41f4b71Sopenharmony_ci
367e41f4b71Sopenharmony_ci**起始版本:** 11
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci### JSVM_EnvScope
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci```
373e41f4b71Sopenharmony_citypedef struct JSVM_EnvScope__* JSVM_EnvScope
374e41f4b71Sopenharmony_ci```
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ci**描述**
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci表示用于控制附加到当前虚拟机实例的环境。只有当线程通过 OH_JSVM_OpenEnvScope进入该环境的JSVM_EnvScope后,该环境才 对线程的虚拟机实例可用。
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci**起始版本:** 11
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ci### JSVM_EscapableHandleScope
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci```
386e41f4b71Sopenharmony_citypedef struct JSVM_EscapableHandleScope__* JSVM_EscapableHandleScope
387e41f4b71Sopenharmony_ci```
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_ci**描述**
390e41f4b71Sopenharmony_ci
391e41f4b71Sopenharmony_ci表示一种特殊类型的handle scope,用于将在特定handle scope内创建的值返回到父作用域。
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ci**起始版本:** 11
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci### JSVM_Finalize
397e41f4b71Sopenharmony_ci
398e41f4b71Sopenharmony_ci```
399e41f4b71Sopenharmony_citypedef void(JSVM_CDECL* JSVM_Finalize) (JSVM_Env env, void *finalizeData, void *finalizeHint)
400e41f4b71Sopenharmony_ci```
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_ci**描述**
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_ci函数指针类型,当native类型对象或数据与JS对象被关联时,传入该指针。该函数将会 在关联的JS对象被GC回收时被调用,用以执行native的清理动作。
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci**起始版本:** 11
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ci### JSVM_HandleScope
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ci```
412e41f4b71Sopenharmony_citypedef struct JSVM_HandleScope__* JSVM_HandleScope
413e41f4b71Sopenharmony_ci```
414e41f4b71Sopenharmony_ci
415e41f4b71Sopenharmony_ci**描述**
416e41f4b71Sopenharmony_ci
417e41f4b71Sopenharmony_ci表示JavaScript值的作用域,用于控制和修改在特定范围内创建的对象的生命周期。 通常,JSVM-API值是在JSVM_HandleScope的上下文中创建的。当从JavaScript调用native方法时, 将存在默认JSVM_HandleScope。如果用户没有显式创建新的JSVM_HandleScope,将在默认 JSVM_HandleScope中创建JSVM-API值。对于native方法执行之外的任何代码调用(例如,在libuv回调调用期间), 模块需要在调用任何可能导致创建JavaScript值的函数之前创建一个作用域。JSVM_HandleScope是使用 OH_JSVM_OpenHandleScope创建的,并使用OH_JSVM_CloseHandleScope销毁的。 关闭作用域代表向GC指示在JSVM_HandleScope作用域的生命周期内创建的所有JSVM_Value将不再从当前堆的栈帧中引用。
418e41f4b71Sopenharmony_ci
419e41f4b71Sopenharmony_ci**起始版本:** 11
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci### JSVM_OutputStream
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ci```
425e41f4b71Sopenharmony_citypedef bool(JSVM_CDECL* JSVM_OutputStream) (const char *data, int size, void *streamData)
426e41f4b71Sopenharmony_ci```
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ci**描述**
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ciASCII输出流回调的函数指针类型。参数data是指输出的数据指针。参数size是指输出的数据大小。 空数据指针指示流的结尾。参数streamData是指与回调一起传递给API函数的指针,该API函数向输出流生成数据。回 调返回true表示流可以继续接受数据。否则,它将中止流。
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci**起始版本:** 12
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ci
435e41f4b71Sopenharmony_ci### JSVM_PropertyHandlerCfg
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci```
438e41f4b71Sopenharmony_citypedef JSVM_PropertyHandlerConfigurationStruct* JSVM_PropertyHandlerCfg
439e41f4b71Sopenharmony_ci```
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ci**描述**
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ci包含属性监听回调的结构的指针类型。
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_ci**起始版本:** 12
446e41f4b71Sopenharmony_ci
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ci### JSVM_Ref
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci```
451e41f4b71Sopenharmony_citypedef struct JSVM_Ref__* JSVM_Ref
452e41f4b71Sopenharmony_ci```
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci**描述**
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci表示JavaScript值的引用。
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci**起始版本:** 11
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci
461e41f4b71Sopenharmony_ci### JSVM_Script
462e41f4b71Sopenharmony_ci
463e41f4b71Sopenharmony_ci```
464e41f4b71Sopenharmony_citypedef struct JSVM_Script__* JSVM_Script
465e41f4b71Sopenharmony_ci```
466e41f4b71Sopenharmony_ci
467e41f4b71Sopenharmony_ci**描述**
468e41f4b71Sopenharmony_ci
469e41f4b71Sopenharmony_ci表示一段JavaScript代码。
470e41f4b71Sopenharmony_ci
471e41f4b71Sopenharmony_ci**起始版本:** 11
472e41f4b71Sopenharmony_ci
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci### JSVM_Value
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci```
477e41f4b71Sopenharmony_citypedef struct JSVM_Value__* JSVM_Value
478e41f4b71Sopenharmony_ci```
479e41f4b71Sopenharmony_ci
480e41f4b71Sopenharmony_ci**描述**
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci表示JavaScript值。
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci**起始版本:** 11
485e41f4b71Sopenharmony_ci
486e41f4b71Sopenharmony_ci
487e41f4b71Sopenharmony_ci### JSVM_VM
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_ci```
490e41f4b71Sopenharmony_citypedef struct JSVM_VM__* JSVM_VM
491e41f4b71Sopenharmony_ci```
492e41f4b71Sopenharmony_ci
493e41f4b71Sopenharmony_ci**描述**
494e41f4b71Sopenharmony_ci
495e41f4b71Sopenharmony_ci表示JavaScript虚拟机实例。
496e41f4b71Sopenharmony_ci
497e41f4b71Sopenharmony_ci**起始版本:** 11
498e41f4b71Sopenharmony_ci
499e41f4b71Sopenharmony_ci
500e41f4b71Sopenharmony_ci### JSVM_VMScope
501e41f4b71Sopenharmony_ci
502e41f4b71Sopenharmony_ci```
503e41f4b71Sopenharmony_citypedef struct JSVM_VMScope__* JSVM_VMScope
504e41f4b71Sopenharmony_ci```
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci**描述**
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ci表示JavaScript虚拟机作用域。
509e41f4b71Sopenharmony_ci
510e41f4b71Sopenharmony_ci**起始版本:** 11
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci
513e41f4b71Sopenharmony_ci## 枚举类型说明
514e41f4b71Sopenharmony_ci
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_ci### JSVM_CacheType
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_ci```
519e41f4b71Sopenharmony_cienum JSVM_CacheType
520e41f4b71Sopenharmony_ci```
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_ci**描述**
523e41f4b71Sopenharmony_ci
524e41f4b71Sopenharmony_ci缓存类型
525e41f4b71Sopenharmony_ci
526e41f4b71Sopenharmony_ci**起始版本:** 12
527e41f4b71Sopenharmony_ci
528e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
529e41f4b71Sopenharmony_ci| -------- | -------- |
530e41f4b71Sopenharmony_ci| JSVM_CACHE_TYPE_JS | JS 缓存, 由接口 OH_JSVM_CreateCodeCache 生成 | 
531e41f4b71Sopenharmony_ci| JSVM_CACHE_TYPE_WASM | WebAssembly 缓存, 由接口 OH_JSVM_CreateWasmCache 生成 | 
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ci
534e41f4b71Sopenharmony_ci### JSVM_InitializedFlag
535e41f4b71Sopenharmony_ci
536e41f4b71Sopenharmony_ci```
537e41f4b71Sopenharmony_cienum JSVM_InitializedFlag
538e41f4b71Sopenharmony_ci```
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_ci**描述**
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci初始化方式的标志位
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ci**起始版本:** 12
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
547e41f4b71Sopenharmony_ci| -------- | -------- |
548e41f4b71Sopenharmony_ci| JSVM_ZERO_INITIALIZED | 初始化为 0 | 
549e41f4b71Sopenharmony_ci| JSVM_UNINITIALIZED | 不做初始化 | 
550e41f4b71Sopenharmony_ci
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_ci### JSVM_KeyCollectionMode
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_ci```
555e41f4b71Sopenharmony_cienum JSVM_KeyCollectionMode
556e41f4b71Sopenharmony_ci```
557e41f4b71Sopenharmony_ci
558e41f4b71Sopenharmony_ci**描述**
559e41f4b71Sopenharmony_ci
560e41f4b71Sopenharmony_ci限制查找属性的范围。
561e41f4b71Sopenharmony_ci
562e41f4b71Sopenharmony_ci**起始版本:** 11
563e41f4b71Sopenharmony_ci
564e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
565e41f4b71Sopenharmony_ci| -------- | -------- |
566e41f4b71Sopenharmony_ci| JSVM_KEY_INCLUDE_PROTOTYPES | 也包含对象原型链上的属性。 | 
567e41f4b71Sopenharmony_ci| JSVM_KEY_OWN_ONLY | 仅包含对象自身属性。 | 
568e41f4b71Sopenharmony_ci
569e41f4b71Sopenharmony_ci
570e41f4b71Sopenharmony_ci### JSVM_KeyConversion
571e41f4b71Sopenharmony_ci
572e41f4b71Sopenharmony_ci```
573e41f4b71Sopenharmony_cienum JSVM_KeyConversion
574e41f4b71Sopenharmony_ci```
575e41f4b71Sopenharmony_ci
576e41f4b71Sopenharmony_ci**描述**
577e41f4b71Sopenharmony_ci
578e41f4b71Sopenharmony_ci键转换选项。
579e41f4b71Sopenharmony_ci
580e41f4b71Sopenharmony_ci**起始版本:** 11
581e41f4b71Sopenharmony_ci
582e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
583e41f4b71Sopenharmony_ci| -------- | -------- |
584e41f4b71Sopenharmony_ci| JSVM_KEY_KEEP_NUMBERS | 将返回整数索引的数字。 | 
585e41f4b71Sopenharmony_ci| JSVM_KEY_NUMBERS_TO_STRINGS | 将整数索引转换为字符串。 | 
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_ci
588e41f4b71Sopenharmony_ci### JSVM_KeyFilter
589e41f4b71Sopenharmony_ci
590e41f4b71Sopenharmony_ci```
591e41f4b71Sopenharmony_cienum JSVM_KeyFilter
592e41f4b71Sopenharmony_ci```
593e41f4b71Sopenharmony_ci
594e41f4b71Sopenharmony_ci**描述**
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ci属性过滤器,可以通过使用or来构造一个复合过滤器。
597e41f4b71Sopenharmony_ci
598e41f4b71Sopenharmony_ci**起始版本:** 11
599e41f4b71Sopenharmony_ci
600e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
601e41f4b71Sopenharmony_ci| -------- | -------- |
602e41f4b71Sopenharmony_ci| JSVM_KEY_ALL_PROPERTIES | 所有属性的键。 | 
603e41f4b71Sopenharmony_ci| JSVM_KEY_WRITABLE | 可写的键。 | 
604e41f4b71Sopenharmony_ci| JSVM_KEY_ENUMERABLE | 可枚举的键。 | 
605e41f4b71Sopenharmony_ci| JSVM_KEY_CONFIGURABLE | 可配置的键。 | 
606e41f4b71Sopenharmony_ci| JSVM_KEY_SKIP_STRINGS | 排除字符串类型的键。 | 
607e41f4b71Sopenharmony_ci| JSVM_KEY_SKIP_SYMBOLS | 排除符号类型的键。 | 
608e41f4b71Sopenharmony_ci
609e41f4b71Sopenharmony_ci
610e41f4b71Sopenharmony_ci### JSVM_MemoryPressureLevel
611e41f4b71Sopenharmony_ci
612e41f4b71Sopenharmony_ci```
613e41f4b71Sopenharmony_cienum JSVM_MemoryPressureLevel
614e41f4b71Sopenharmony_ci```
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_ci**描述**
617e41f4b71Sopenharmony_ci
618e41f4b71Sopenharmony_ci内存压力水平。
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_ci**起始版本:** 11
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
623e41f4b71Sopenharmony_ci| -------- | -------- |
624e41f4b71Sopenharmony_ci| JSVM_MEMORY_PRESSURE_LEVEL_NONE | 无压力。 | 
625e41f4b71Sopenharmony_ci| JSVM_MEMORY_PRESSURE_LEVEL_MODERATE | 中等压力。 | 
626e41f4b71Sopenharmony_ci| JSVM_MEMORY_PRESSURE_LEVEL_CRITICAL | 临界压力。 | 
627e41f4b71Sopenharmony_ci
628e41f4b71Sopenharmony_ci
629e41f4b71Sopenharmony_ci### JSVM_PropertyAttributes
630e41f4b71Sopenharmony_ci
631e41f4b71Sopenharmony_ci```
632e41f4b71Sopenharmony_cienum JSVM_PropertyAttributes
633e41f4b71Sopenharmony_ci```
634e41f4b71Sopenharmony_ci
635e41f4b71Sopenharmony_ci**描述**
636e41f4b71Sopenharmony_ci
637e41f4b71Sopenharmony_ci用于控制JavaScript对象属性的行为。
638e41f4b71Sopenharmony_ci
639e41f4b71Sopenharmony_ci**起始版本:** 11
640e41f4b71Sopenharmony_ci
641e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
642e41f4b71Sopenharmony_ci| -------- | -------- |
643e41f4b71Sopenharmony_ci| JSVM_DEFAULT | 没有在属性上设置显式属性。 | 
644e41f4b71Sopenharmony_ci| JSVM_WRITABLE | 该属性是可写的。 | 
645e41f4b71Sopenharmony_ci| JSVM_ENUMERABLE | 该属性是可枚举的。 | 
646e41f4b71Sopenharmony_ci| JSVM_CONFIGURABLE | 该属性是可配置的。 | 
647e41f4b71Sopenharmony_ci| JSVM_STATIC | 该属性将被定义为类的静态属性,而不是默认的实例属性。这仅由OH_JSVM_DefineClass使用。 | 
648e41f4b71Sopenharmony_ci| JSVM_DEFAULT_METHOD | 就像JS类中的方法一样,该属性是可配置和可写的,但不可枚举。 | 
649e41f4b71Sopenharmony_ci| JSVM_DEFAULT_JSPROPERTY | 就像JavaScript中通过赋值设置的属性一样,属性是可写、可枚举和可配置的。 | 
650e41f4b71Sopenharmony_ci
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_ci### JSVM_RegExpFlags
653e41f4b71Sopenharmony_ci
654e41f4b71Sopenharmony_ci```
655e41f4b71Sopenharmony_cienum JSVM_RegExpFlags
656e41f4b71Sopenharmony_ci```
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ci**描述**
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_ci正则表达式标志位。它们可以用来启用一组标志。
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ci**起始版本:** 12
663e41f4b71Sopenharmony_ci
664e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
665e41f4b71Sopenharmony_ci| -------- | -------- |
666e41f4b71Sopenharmony_ci| JSVM_REGEXP_NONE | None模式。 | 
667e41f4b71Sopenharmony_ci| JSVM_REGEXP_GLOBAL | Global模式。 | 
668e41f4b71Sopenharmony_ci| JSVM_REGEXP_IGNORE_CASE | Ignore Case模式。 | 
669e41f4b71Sopenharmony_ci| JSVM_REGEXP_MULTILINE | Multiline模式。 | 
670e41f4b71Sopenharmony_ci| JSVM_REGEXP_STICKY | Sticky模式。 | 
671e41f4b71Sopenharmony_ci| JSVM_REGEXP_UNICODE | Unicode模式。 | 
672e41f4b71Sopenharmony_ci| JSVM_REGEXP_DOT_ALL | dotAll模式。 | 
673e41f4b71Sopenharmony_ci| JSVM_REGEXP_LINEAR | Linear模式。 | 
674e41f4b71Sopenharmony_ci| JSVM_REGEXP_HAS_INDICES | Has Indices模式。 | 
675e41f4b71Sopenharmony_ci| JSVM_REGEXP_UNICODE_SETS | Unicode Sets模式。 | 
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ci
678e41f4b71Sopenharmony_ci### JSVM_Status
679e41f4b71Sopenharmony_ci
680e41f4b71Sopenharmony_ci```
681e41f4b71Sopenharmony_cienum JSVM_Status
682e41f4b71Sopenharmony_ci```
683e41f4b71Sopenharmony_ci
684e41f4b71Sopenharmony_ci**描述**
685e41f4b71Sopenharmony_ci
686e41f4b71Sopenharmony_ci表示JSVM-API调用成功或失败的完整状态码。
687e41f4b71Sopenharmony_ci
688e41f4b71Sopenharmony_ci**起始版本:** 11
689e41f4b71Sopenharmony_ci
690e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
691e41f4b71Sopenharmony_ci| -------- | -------- |
692e41f4b71Sopenharmony_ci| JSVM_OK | 成功状态。 | 
693e41f4b71Sopenharmony_ci| JSVM_INVALID_ARG | 无效的状态。 | 
694e41f4b71Sopenharmony_ci| JSVM_OBJECT_EXPECTED | 期待传入对象类型。 | 
695e41f4b71Sopenharmony_ci| JSVM_STRING_EXPECTED | 期望传入字符串类型。 | 
696e41f4b71Sopenharmony_ci| JSVM_NAME_EXPECTED | 期望传入名字类型。 | 
697e41f4b71Sopenharmony_ci| JSVM_FUNCTION_EXPECTED | 期待传入函数类型。 | 
698e41f4b71Sopenharmony_ci| JSVM_NUMBER_EXPECTED | 期待传入数字类型。 | 
699e41f4b71Sopenharmony_ci| JSVM_BOOLEAN_EXPECTED | 期待传入布尔类型。 | 
700e41f4b71Sopenharmony_ci| JSVM_ARRAY_EXPECTED | 期待传入数组类型。 | 
701e41f4b71Sopenharmony_ci| JSVM_GENERIC_FAILURE | 泛型失败状态。 | 
702e41f4b71Sopenharmony_ci| JSVM_PENDING_EXCEPTION | 挂起异常状态。 | 
703e41f4b71Sopenharmony_ci| JSVM_CANCELLED | 取消状态。 | 
704e41f4b71Sopenharmony_ci| JSVM_ESCAPE_CALLED_TWICE | 转义调用了两次。 | 
705e41f4b71Sopenharmony_ci| JSVM_HANDLE_SCOPE_MISMATCH | 句柄作用域不匹配。 | 
706e41f4b71Sopenharmony_ci| JSVM_CALLBACK_SCOPE_MISMATCH | 回调作用域不匹配。 | 
707e41f4b71Sopenharmony_ci| JSVM_QUEUE_FULL | 队列满。 | 
708e41f4b71Sopenharmony_ci| JSVM_CLOSING | 关闭中。 | 
709e41f4b71Sopenharmony_ci| JSVM_BIGINT_EXPECTED | 期望传入Bigint类型。 | 
710e41f4b71Sopenharmony_ci| JSVM_DATE_EXPECTED | 期望传入日期类型。 | 
711e41f4b71Sopenharmony_ci| JSVM_ARRAYBUFFER_EXPECTED | 期望传入ArrayBuffer类型。 | 
712e41f4b71Sopenharmony_ci| JSVM_DETACHABLE_ARRAYBUFFER_EXPECTED | 可分离的数组缓冲区预期状态。 | 
713e41f4b71Sopenharmony_ci| JSVM_WOULD_DEADLOCK | 将死锁状态。 | 
714e41f4b71Sopenharmony_ci| JSVM_NO_EXTERNAL_BUFFERS_ALLOWED | 不允许外部缓冲区。 | 
715e41f4b71Sopenharmony_ci| JSVM_CANNOT_RUN_JS | 不能执行JS。 | 
716e41f4b71Sopenharmony_ci
717e41f4b71Sopenharmony_ci
718e41f4b71Sopenharmony_ci### JSVM_TypedarrayType
719e41f4b71Sopenharmony_ci
720e41f4b71Sopenharmony_ci```
721e41f4b71Sopenharmony_cienum JSVM_TypedarrayType
722e41f4b71Sopenharmony_ci```
723e41f4b71Sopenharmony_ci
724e41f4b71Sopenharmony_ci**描述**
725e41f4b71Sopenharmony_ci
726e41f4b71Sopenharmony_ci描述TypedArray的类型。
727e41f4b71Sopenharmony_ci
728e41f4b71Sopenharmony_ci**起始版本:** 11
729e41f4b71Sopenharmony_ci
730e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
731e41f4b71Sopenharmony_ci| -------- | -------- |
732e41f4b71Sopenharmony_ci| JSVM_INT8_ARRAY | int8类型。 | 
733e41f4b71Sopenharmony_ci| JSVM_UINT8_ARRAY | uint8类型。 | 
734e41f4b71Sopenharmony_ci| JSVM_UINT8_CLAMPED_ARRAY | uint8固定类型。 | 
735e41f4b71Sopenharmony_ci| JSVM_INT16_ARRAY | int16类型。 | 
736e41f4b71Sopenharmony_ci| JSVM_UINT16_ARRAY | uint16类型。 | 
737e41f4b71Sopenharmony_ci| JSVM_INT32_ARRAY | int32类型。 | 
738e41f4b71Sopenharmony_ci| JSVM_UINT32_ARRAY | uint32类型。 | 
739e41f4b71Sopenharmony_ci| JSVM_FLOAT32_ARRAY | float32类型。 | 
740e41f4b71Sopenharmony_ci| JSVM_FLOAT64_ARRAY | float64类型。 | 
741e41f4b71Sopenharmony_ci| JSVM_BIGINT64_ARRAY | bigint64类型。 | 
742e41f4b71Sopenharmony_ci| JSVM_BIGUINT64_ARRAY | biguint64类型。 | 
743e41f4b71Sopenharmony_ci
744e41f4b71Sopenharmony_ci
745e41f4b71Sopenharmony_ci### JSVM_ValueType
746e41f4b71Sopenharmony_ci
747e41f4b71Sopenharmony_ci```
748e41f4b71Sopenharmony_cienum JSVM_ValueType
749e41f4b71Sopenharmony_ci```
750e41f4b71Sopenharmony_ci
751e41f4b71Sopenharmony_ci**描述**
752e41f4b71Sopenharmony_ci
753e41f4b71Sopenharmony_ci描述JSVM_Value的类型。
754e41f4b71Sopenharmony_ci
755e41f4b71Sopenharmony_ci**起始版本:** 11
756e41f4b71Sopenharmony_ci
757e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
758e41f4b71Sopenharmony_ci| -------- | -------- |
759e41f4b71Sopenharmony_ci| JSVM_UNDEFINED | 未定义类型。 | 
760e41f4b71Sopenharmony_ci| JSVM_NULL | Null类型。 | 
761e41f4b71Sopenharmony_ci| JSVM_BOOLEAN | 布尔类型。 | 
762e41f4b71Sopenharmony_ci| JSVM_NUMBER | 数字类型。 | 
763e41f4b71Sopenharmony_ci| JSVM_STRING | 字符串类型。 | 
764e41f4b71Sopenharmony_ci| JSVM_SYMBOL | 符号类型。 | 
765e41f4b71Sopenharmony_ci| JSVM_OBJECT | 对象类型。 | 
766e41f4b71Sopenharmony_ci| JSVM_FUNCTION | 函数类型。 | 
767e41f4b71Sopenharmony_ci| JSVM_EXTERNAL | 外部类型。 | 
768e41f4b71Sopenharmony_ci| JSVM_BIGINT | bigint类型。 | 
769e41f4b71Sopenharmony_ci
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ci### JSVM_WasmOptLevel
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ci```
774e41f4b71Sopenharmony_cienum JSVM_WasmOptLevel
775e41f4b71Sopenharmony_ci```
776e41f4b71Sopenharmony_ci
777e41f4b71Sopenharmony_ci**描述**
778e41f4b71Sopenharmony_ci
779e41f4b71Sopenharmony_ciWebAssembly 函数优化等级
780e41f4b71Sopenharmony_ci
781e41f4b71Sopenharmony_ci**起始版本:** 12
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ci| 枚举值 | 描述 | 
784e41f4b71Sopenharmony_ci| -------- | -------- |
785e41f4b71Sopenharmony_ci| JSVM_WASM_OPT_BASELINE | baseline 优化等级 | 
786e41f4b71Sopenharmony_ci| JSVM_WASM_OPT_HIGH | 高优化等级 | 
787e41f4b71Sopenharmony_ci
788e41f4b71Sopenharmony_ci
789e41f4b71Sopenharmony_ci## 函数说明
790e41f4b71Sopenharmony_ci
791e41f4b71Sopenharmony_ci
792e41f4b71Sopenharmony_ci### OH_JSVM_AddFinalizer()
793e41f4b71Sopenharmony_ci
794e41f4b71Sopenharmony_ci```
795e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_AddFinalizer (JSVM_Env env, JSVM_Value jsObject, void * finalizeData, JSVM_Finalize finalizeCb, void * finalizeHint, JSVM_Ref * result )
796e41f4b71Sopenharmony_ci```
797e41f4b71Sopenharmony_ci
798e41f4b71Sopenharmony_ci**描述**
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_ci为JavaScript对象添加JSVM_Finalize回调,当JavaScript对象被垃圾回收时调用该回调函数。 可以在单个JavaScript对象上多次调用OH_JSVM_AddFinalizer。
801e41f4b71Sopenharmony_ci
802e41f4b71Sopenharmony_ci**起始版本:** 11
803e41f4b71Sopenharmony_ci
804e41f4b71Sopenharmony_ci**参数:**
805e41f4b71Sopenharmony_ci
806e41f4b71Sopenharmony_ci| 名称 | 描述 | 
807e41f4b71Sopenharmony_ci| -------- | -------- |
808e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
809e41f4b71Sopenharmony_ci| jsObject | 关联native数据的JavaScript对象。 | 
810e41f4b71Sopenharmony_ci| finalizeData | 要传递给finalizeCb的可选数据。 | 
811e41f4b71Sopenharmony_ci| finalizeCb | 当JavaScript对象被垃圾回收时,将用于释放native 数据的原生回调。JSVM_Finalize提供了更多详细信息。 | 
812e41f4b71Sopenharmony_ci| finalizeHint | 传递给finalize回调的可选上下文提示。 | 
813e41f4b71Sopenharmony_ci| result | 可选的对JavaScript对象的引用。 | 
814e41f4b71Sopenharmony_ci
815e41f4b71Sopenharmony_ci**返回:**
816e41f4b71Sopenharmony_ci
817e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
818e41f4b71Sopenharmony_ci
819e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
820e41f4b71Sopenharmony_ci
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ci### OH_JSVM_AdjustExternalMemory()
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_ci```
825e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_AdjustExternalMemory (JSVM_Env env, int64_t changeInBytes, int64_t * result )
826e41f4b71Sopenharmony_ci```
827e41f4b71Sopenharmony_ci
828e41f4b71Sopenharmony_ci**描述**
829e41f4b71Sopenharmony_ci
830e41f4b71Sopenharmony_ci此函数将因JavaScript对象而保持活跃的外部分配的内存大小通知给底层虚拟机。 注册外部分配的内存将比其他方式更频繁地触发全局垃圾回收。
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_ci**起始版本:** 11
833e41f4b71Sopenharmony_ci
834e41f4b71Sopenharmony_ci**参数:**
835e41f4b71Sopenharmony_ci
836e41f4b71Sopenharmony_ci| 名称 | 描述 | 
837e41f4b71Sopenharmony_ci| -------- | -------- |
838e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
839e41f4b71Sopenharmony_ci| changeInBytes | 因JavaScript对象而保持活动状态的外部分配内存的变化。 | 
840e41f4b71Sopenharmony_ci| result | 调整值。 | 
841e41f4b71Sopenharmony_ci
842e41f4b71Sopenharmony_ci**返回:**
843e41f4b71Sopenharmony_ci
844e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
845e41f4b71Sopenharmony_ci
846e41f4b71Sopenharmony_ci
847e41f4b71Sopenharmony_ci### OH_JSVM_AllocateArrayBufferBackingStoreData()
848e41f4b71Sopenharmony_ci
849e41f4b71Sopenharmony_ci```
850e41f4b71Sopenharmony_ciJSVM_Status JSVM_CDECL OH_JSVM_AllocateArrayBufferBackingStoreData (size_t byteLength, JSVM_InitializedFlag initialized, void ** data )
851e41f4b71Sopenharmony_ci```
852e41f4b71Sopenharmony_ci
853e41f4b71Sopenharmony_ci**描述**
854e41f4b71Sopenharmony_ci
855e41f4b71Sopenharmony_ci申请一段给 array buffer 使用的 BackingStore 内存。
856e41f4b71Sopenharmony_ci
857e41f4b71Sopenharmony_ci**起始版本:** 12
858e41f4b71Sopenharmony_ci
859e41f4b71Sopenharmony_ci**参数:**
860e41f4b71Sopenharmony_ci
861e41f4b71Sopenharmony_ci| 名称 | 描述 | 
862e41f4b71Sopenharmony_ci| -------- | -------- |
863e41f4b71Sopenharmony_ci| byteLength | BackingStore 内存的大小。 | 
864e41f4b71Sopenharmony_ci| initialized | BackingStore 内存初始化的方式。 | 
865e41f4b71Sopenharmony_ci| data | 用于接受申请 BackingStore 内存地址的指针。 | 
866e41f4b71Sopenharmony_ci
867e41f4b71Sopenharmony_ci**返回:**
868e41f4b71Sopenharmony_ci
869e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
870e41f4b71Sopenharmony_ci
871e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的 data 是空指针。
872e41f4b71Sopenharmony_ci
873e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示内存申请失败。
874e41f4b71Sopenharmony_ci
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci### OH_JSVM_CallFunction()
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ci```
879e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CallFunction (JSVM_Env env, JSVM_Value recv, JSVM_Value func, size_t argc, const JSVM_Value * argv, JSVM_Value * result )
880e41f4b71Sopenharmony_ci```
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ci**描述**
883e41f4b71Sopenharmony_ci
884e41f4b71Sopenharmony_ci支持从native代码调用JavaScript函数对象, 这是从native代码回调到JavaScript的主要机制。
885e41f4b71Sopenharmony_ci
886e41f4b71Sopenharmony_ci**起始版本:** 11
887e41f4b71Sopenharmony_ci
888e41f4b71Sopenharmony_ci**参数:**
889e41f4b71Sopenharmony_ci
890e41f4b71Sopenharmony_ci| 名称 | 描述 | 
891e41f4b71Sopenharmony_ci| -------- | -------- |
892e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
893e41f4b71Sopenharmony_ci| recv | 传递给被调用函数的this值。 | 
894e41f4b71Sopenharmony_ci| func | 表示将调用的JavaScript函数。 | 
895e41f4b71Sopenharmony_ci| argc | argv数组中的元素个数。 | 
896e41f4b71Sopenharmony_ci| argv | JSVM_values数组,表示将作为参数传递给函数的JavaScript值。 | 
897e41f4b71Sopenharmony_ci| result | 表示返回的JavaScript对象。 | 
898e41f4b71Sopenharmony_ci
899e41f4b71Sopenharmony_ci**返回:**
900e41f4b71Sopenharmony_ci
901e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
902e41f4b71Sopenharmony_ci
903e41f4b71Sopenharmony_ciJSVM_PENDING_EXCEPTION 表示执行的过程中产生了JS异常。
904e41f4b71Sopenharmony_ci
905e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
906e41f4b71Sopenharmony_ci
907e41f4b71Sopenharmony_ci
908e41f4b71Sopenharmony_ci### OH_JSVM_CheckObjectTypeTag()
909e41f4b71Sopenharmony_ci
910e41f4b71Sopenharmony_ci```
911e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CheckObjectTypeTag (JSVM_Env env, JSVM_Value value, const JSVM_TypeTag * typeTag, bool * result )
912e41f4b71Sopenharmony_ci```
913e41f4b71Sopenharmony_ci
914e41f4b71Sopenharmony_ci**描述**
915e41f4b71Sopenharmony_ci
916e41f4b71Sopenharmony_ci将类型标签typeTag与JavaScript对象或外部值上的标签作对比。如果找到相同标签, 设置result为true,否则为false。
917e41f4b71Sopenharmony_ci
918e41f4b71Sopenharmony_ci**起始版本:** 11
919e41f4b71Sopenharmony_ci
920e41f4b71Sopenharmony_ci**参数:**
921e41f4b71Sopenharmony_ci
922e41f4b71Sopenharmony_ci| 名称 | 描述 | 
923e41f4b71Sopenharmony_ci| -------- | -------- |
924e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
925e41f4b71Sopenharmony_ci| value | 待检查类型标记的JavaScript对象或外部值。 | 
926e41f4b71Sopenharmony_ci| typeTag | 用于比较在对象上找到的任何标签的标签。 | 
927e41f4b71Sopenharmony_ci| result | 表示指定的类型标记是否与对象上的类型标记匹配。如果在对象上找不到该类型标记,也会返回false。 | 
928e41f4b71Sopenharmony_ci
929e41f4b71Sopenharmony_ci**返回:**
930e41f4b71Sopenharmony_ci
931e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
932e41f4b71Sopenharmony_ci
933e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
934e41f4b71Sopenharmony_ci
935e41f4b71Sopenharmony_ci
936e41f4b71Sopenharmony_ci### OH_JSVM_CloseEnvScope()
937e41f4b71Sopenharmony_ci
938e41f4b71Sopenharmony_ci```
939e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CloseEnvScope (JSVM_Env env, JSVM_EnvScope scope )
940e41f4b71Sopenharmony_ci```
941e41f4b71Sopenharmony_ci
942e41f4b71Sopenharmony_ci**描述**
943e41f4b71Sopenharmony_ci
944e41f4b71Sopenharmony_ci关闭环境作用域。
945e41f4b71Sopenharmony_ci
946e41f4b71Sopenharmony_ci**起始版本:** 11
947e41f4b71Sopenharmony_ci
948e41f4b71Sopenharmony_ci**参数:**
949e41f4b71Sopenharmony_ci
950e41f4b71Sopenharmony_ci| 名称 | 描述 | 
951e41f4b71Sopenharmony_ci| -------- | -------- |
952e41f4b71Sopenharmony_ci| env | 目标环境,JSVM-API接口将在该环境下调用。 | 
953e41f4b71Sopenharmony_ci| scope | 将要关闭的环境作用域。 | 
954e41f4b71Sopenharmony_ci
955e41f4b71Sopenharmony_ci**返回:**
956e41f4b71Sopenharmony_ci
957e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
958e41f4b71Sopenharmony_ci
959e41f4b71Sopenharmony_ci
960e41f4b71Sopenharmony_ci### OH_JSVM_CloseEscapableHandleScope()
961e41f4b71Sopenharmony_ci
962e41f4b71Sopenharmony_ci```
963e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CloseEscapableHandleScope (JSVM_Env env, JSVM_EscapableHandleScope scope )
964e41f4b71Sopenharmony_ci```
965e41f4b71Sopenharmony_ci
966e41f4b71Sopenharmony_ci**描述**
967e41f4b71Sopenharmony_ci
968e41f4b71Sopenharmony_ci关闭传入的作用域。必须按照创建作用域的相反顺序关闭作用域。 即使存在挂起的JavaScript异常,也可以调用此JSVM_API。
969e41f4b71Sopenharmony_ci
970e41f4b71Sopenharmony_ci**起始版本:** 11
971e41f4b71Sopenharmony_ci
972e41f4b71Sopenharmony_ci**参数:**
973e41f4b71Sopenharmony_ci
974e41f4b71Sopenharmony_ci| 名称 | 描述 | 
975e41f4b71Sopenharmony_ci| -------- | -------- |
976e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
977e41f4b71Sopenharmony_ci| scope | 表示要关闭的作用域。 | 
978e41f4b71Sopenharmony_ci
979e41f4b71Sopenharmony_ci**返回:**
980e41f4b71Sopenharmony_ci
981e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
982e41f4b71Sopenharmony_ci
983e41f4b71Sopenharmony_ciJSVM_HANDLE_SCOPE_MISMATCH 表示执行失败。
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_ci
986e41f4b71Sopenharmony_ci### OH_JSVM_CloseHandleScope()
987e41f4b71Sopenharmony_ci
988e41f4b71Sopenharmony_ci```
989e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CloseHandleScope (JSVM_Env env, JSVM_HandleScope scope )
990e41f4b71Sopenharmony_ci```
991e41f4b71Sopenharmony_ci
992e41f4b71Sopenharmony_ci**描述**
993e41f4b71Sopenharmony_ci
994e41f4b71Sopenharmony_ci关闭传入的作用域。必须按照创建作用域的相反顺序关闭作用域。
995e41f4b71Sopenharmony_ci
996e41f4b71Sopenharmony_ci**起始版本:** 11
997e41f4b71Sopenharmony_ci
998e41f4b71Sopenharmony_ci**参数:**
999e41f4b71Sopenharmony_ci
1000e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1001e41f4b71Sopenharmony_ci| -------- | -------- |
1002e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1003e41f4b71Sopenharmony_ci| scope | 表示要关闭的作用域。 | 
1004e41f4b71Sopenharmony_ci
1005e41f4b71Sopenharmony_ci**返回:**
1006e41f4b71Sopenharmony_ci
1007e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1008e41f4b71Sopenharmony_ci
1009e41f4b71Sopenharmony_ci
1010e41f4b71Sopenharmony_ci### OH_JSVM_CloseInspector()
1011e41f4b71Sopenharmony_ci
1012e41f4b71Sopenharmony_ci```
1013e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CloseInspector (JSVM_Env env)
1014e41f4b71Sopenharmony_ci```
1015e41f4b71Sopenharmony_ci
1016e41f4b71Sopenharmony_ci**描述**
1017e41f4b71Sopenharmony_ci
1018e41f4b71Sopenharmony_ci尝试关闭剩余的所有inspector连接。
1019e41f4b71Sopenharmony_ci
1020e41f4b71Sopenharmony_ci**起始版本:** 12
1021e41f4b71Sopenharmony_ci
1022e41f4b71Sopenharmony_ci**参数:**
1023e41f4b71Sopenharmony_ci
1024e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1025e41f4b71Sopenharmony_ci| -------- | -------- |
1026e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1027e41f4b71Sopenharmony_ci
1028e41f4b71Sopenharmony_ci**返回:**
1029e41f4b71Sopenharmony_ci
1030e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1031e41f4b71Sopenharmony_ci
1032e41f4b71Sopenharmony_ci
1033e41f4b71Sopenharmony_ci### OH_JSVM_CloseVMScope()
1034e41f4b71Sopenharmony_ci
1035e41f4b71Sopenharmony_ci```
1036e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CloseVMScope (JSVM_VM vm, JSVM_VMScope scope )
1037e41f4b71Sopenharmony_ci```
1038e41f4b71Sopenharmony_ci
1039e41f4b71Sopenharmony_ci**描述**
1040e41f4b71Sopenharmony_ci
1041e41f4b71Sopenharmony_ci关闭虚拟机实例的虚拟机作用域。
1042e41f4b71Sopenharmony_ci
1043e41f4b71Sopenharmony_ci**起始版本:** 11
1044e41f4b71Sopenharmony_ci
1045e41f4b71Sopenharmony_ci**参数:**
1046e41f4b71Sopenharmony_ci
1047e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1048e41f4b71Sopenharmony_ci| -------- | -------- |
1049e41f4b71Sopenharmony_ci| vm | 目标虚拟机实例。 | 
1050e41f4b71Sopenharmony_ci| scope | 将要关闭的虚拟机作用域。 | 
1051e41f4b71Sopenharmony_ci
1052e41f4b71Sopenharmony_ci**返回:**
1053e41f4b71Sopenharmony_ci
1054e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1055e41f4b71Sopenharmony_ci
1056e41f4b71Sopenharmony_ci
1057e41f4b71Sopenharmony_ci### OH_JSVM_CoerceToBigInt()
1058e41f4b71Sopenharmony_ci
1059e41f4b71Sopenharmony_ci```
1060e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CoerceToBigInt (JSVM_Env env, JSVM_Value value, JSVM_Value * result )
1061e41f4b71Sopenharmony_ci```
1062e41f4b71Sopenharmony_ci
1063e41f4b71Sopenharmony_ci**描述**
1064e41f4b71Sopenharmony_ci
1065e41f4b71Sopenharmony_ci实现抽象操作ToBigInt()。
1066e41f4b71Sopenharmony_ci
1067e41f4b71Sopenharmony_ci**起始版本:** 12
1068e41f4b71Sopenharmony_ci
1069e41f4b71Sopenharmony_ci**参数:**
1070e41f4b71Sopenharmony_ci
1071e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1072e41f4b71Sopenharmony_ci| -------- | -------- |
1073e41f4b71Sopenharmony_ci| env | 调用该JSVM-API的环境。 | 
1074e41f4b71Sopenharmony_ci| value | 要进行强制转换的JavaScript值。 | 
1075e41f4b71Sopenharmony_ci| result | 表示成功转换成BigInt后的JavaScript值。 | 
1076e41f4b71Sopenharmony_ci
1077e41f4b71Sopenharmony_ci**返回:**
1078e41f4b71Sopenharmony_ci
1079e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1080e41f4b71Sopenharmony_ci
1081e41f4b71Sopenharmony_ciJSVM_BIGINT_EXPECTED 如果传入的JavaScript值无法转换成BitInt。
1082e41f4b71Sopenharmony_ci
1083e41f4b71Sopenharmony_ci
1084e41f4b71Sopenharmony_ci### OH_JSVM_CoerceToBool()
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci```
1087e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CoerceToBool (JSVM_Env env, JSVM_Value value, JSVM_Value * result )
1088e41f4b71Sopenharmony_ci```
1089e41f4b71Sopenharmony_ci
1090e41f4b71Sopenharmony_ci**描述**
1091e41f4b71Sopenharmony_ci
1092e41f4b71Sopenharmony_ci实现抽象操作ToBoolean()。
1093e41f4b71Sopenharmony_ci
1094e41f4b71Sopenharmony_ci**起始版本:** 11
1095e41f4b71Sopenharmony_ci
1096e41f4b71Sopenharmony_ci**参数:**
1097e41f4b71Sopenharmony_ci
1098e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1099e41f4b71Sopenharmony_ci| -------- | -------- |
1100e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1101e41f4b71Sopenharmony_ci| value | 要强制转换的JavaScript值。 | 
1102e41f4b71Sopenharmony_ci| result | 代表强制的JavaScript Boolean。 | 
1103e41f4b71Sopenharmony_ci
1104e41f4b71Sopenharmony_ci**返回:**
1105e41f4b71Sopenharmony_ci
1106e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1107e41f4b71Sopenharmony_ci
1108e41f4b71Sopenharmony_ci
1109e41f4b71Sopenharmony_ci### OH_JSVM_CoerceToNumber()
1110e41f4b71Sopenharmony_ci
1111e41f4b71Sopenharmony_ci```
1112e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CoerceToNumber (JSVM_Env env, JSVM_Value value, JSVM_Value * result )
1113e41f4b71Sopenharmony_ci```
1114e41f4b71Sopenharmony_ci
1115e41f4b71Sopenharmony_ci**描述**
1116e41f4b71Sopenharmony_ci
1117e41f4b71Sopenharmony_ci实现抽象操作ToNumber()。 如果传入的值是对象,则函数可能会运行JavaScript代码。
1118e41f4b71Sopenharmony_ci
1119e41f4b71Sopenharmony_ci**起始版本:** 11
1120e41f4b71Sopenharmony_ci
1121e41f4b71Sopenharmony_ci**参数:**
1122e41f4b71Sopenharmony_ci
1123e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1124e41f4b71Sopenharmony_ci| -------- | -------- |
1125e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1126e41f4b71Sopenharmony_ci| value | 要强制转换的JavaScript值。 | 
1127e41f4b71Sopenharmony_ci| result | 代表强制的JavaScript number。 | 
1128e41f4b71Sopenharmony_ci
1129e41f4b71Sopenharmony_ci**返回:**
1130e41f4b71Sopenharmony_ci
1131e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1132e41f4b71Sopenharmony_ci
1133e41f4b71Sopenharmony_ci
1134e41f4b71Sopenharmony_ci### OH_JSVM_CoerceToObject()
1135e41f4b71Sopenharmony_ci
1136e41f4b71Sopenharmony_ci```
1137e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CoerceToObject (JSVM_Env env, JSVM_Value value, JSVM_Value * result )
1138e41f4b71Sopenharmony_ci```
1139e41f4b71Sopenharmony_ci
1140e41f4b71Sopenharmony_ci**描述**
1141e41f4b71Sopenharmony_ci
1142e41f4b71Sopenharmony_ci实现抽象操作ToObject()。
1143e41f4b71Sopenharmony_ci
1144e41f4b71Sopenharmony_ci**起始版本:** 11
1145e41f4b71Sopenharmony_ci
1146e41f4b71Sopenharmony_ci**参数:**
1147e41f4b71Sopenharmony_ci
1148e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1149e41f4b71Sopenharmony_ci| -------- | -------- |
1150e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1151e41f4b71Sopenharmony_ci| value | 要强制转换的JavaScript值。 | 
1152e41f4b71Sopenharmony_ci| result | 代表强制的JavaScript object。 | 
1153e41f4b71Sopenharmony_ci
1154e41f4b71Sopenharmony_ci**返回:**
1155e41f4b71Sopenharmony_ci
1156e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1157e41f4b71Sopenharmony_ci
1158e41f4b71Sopenharmony_ci
1159e41f4b71Sopenharmony_ci### OH_JSVM_CoerceToString()
1160e41f4b71Sopenharmony_ci
1161e41f4b71Sopenharmony_ci```
1162e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CoerceToString (JSVM_Env env, JSVM_Value value, JSVM_Value * result )
1163e41f4b71Sopenharmony_ci```
1164e41f4b71Sopenharmony_ci
1165e41f4b71Sopenharmony_ci**描述**
1166e41f4b71Sopenharmony_ci
1167e41f4b71Sopenharmony_ci实现抽象操作ToString()。 如果传入的值是对象,则函数可能会运行JavaScript代码。
1168e41f4b71Sopenharmony_ci
1169e41f4b71Sopenharmony_ci**起始版本:** 11
1170e41f4b71Sopenharmony_ci
1171e41f4b71Sopenharmony_ci**参数:**
1172e41f4b71Sopenharmony_ci
1173e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1174e41f4b71Sopenharmony_ci| -------- | -------- |
1175e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1176e41f4b71Sopenharmony_ci| value | 要强制转换的JavaScript值。 | 
1177e41f4b71Sopenharmony_ci| result | 代表强制的JavaScript string。 | 
1178e41f4b71Sopenharmony_ci
1179e41f4b71Sopenharmony_ci**返回:**
1180e41f4b71Sopenharmony_ci
1181e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1182e41f4b71Sopenharmony_ci
1183e41f4b71Sopenharmony_ci
1184e41f4b71Sopenharmony_ci### OH_JSVM_CompileScript()
1185e41f4b71Sopenharmony_ci
1186e41f4b71Sopenharmony_ci```
1187e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CompileScript (JSVM_Env env, JSVM_Value script, const uint8_t * cachedData, size_t cacheDataLength, bool eagerCompile, bool * cacheRejected, JSVM_Script * result )
1188e41f4b71Sopenharmony_ci```
1189e41f4b71Sopenharmony_ci
1190e41f4b71Sopenharmony_ci**描述**
1191e41f4b71Sopenharmony_ci
1192e41f4b71Sopenharmony_ci编译一串JavaScript代码,并返回编译后的脚本。
1193e41f4b71Sopenharmony_ci
1194e41f4b71Sopenharmony_ci**起始版本:** 11
1195e41f4b71Sopenharmony_ci
1196e41f4b71Sopenharmony_ci**参数:**
1197e41f4b71Sopenharmony_ci
1198e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1199e41f4b71Sopenharmony_ci| -------- | -------- |
1200e41f4b71Sopenharmony_ci| env | 目标环境,JSVM-API接口将在该环境下调用。 | 
1201e41f4b71Sopenharmony_ci| script | 包含要编译的脚本的JavaScript代码。 | 
1202e41f4b71Sopenharmony_ci| cachedData | 可选。脚本的代码缓存数据。 | 
1203e41f4b71Sopenharmony_ci| cacheDataLength | cachedData数组的长度。 | 
1204e41f4b71Sopenharmony_ci| eagerCompile | 是否立即编译脚本。 | 
1205e41f4b71Sopenharmony_ci| cacheRejected | 代码缓存是否被编译拒绝。 | 
1206e41f4b71Sopenharmony_ci| result | 编译后的脚本。 | 
1207e41f4b71Sopenharmony_ci
1208e41f4b71Sopenharmony_ci**返回:**
1209e41f4b71Sopenharmony_ci
1210e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1211e41f4b71Sopenharmony_ci
1212e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
1213e41f4b71Sopenharmony_ci
1214e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
1215e41f4b71Sopenharmony_ci
1216e41f4b71Sopenharmony_ci
1217e41f4b71Sopenharmony_ci### OH_JSVM_CompileScriptWithOptions()
1218e41f4b71Sopenharmony_ci
1219e41f4b71Sopenharmony_ci```
1220e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CompileScriptWithOptions (JSVM_Env env, JSVM_Value script, size_t optionCount, JSVM_CompileOptions options[], JSVM_Value * result )
1221e41f4b71Sopenharmony_ci```
1222e41f4b71Sopenharmony_ci
1223e41f4b71Sopenharmony_ci**描述**
1224e41f4b71Sopenharmony_ci
1225e41f4b71Sopenharmony_ci编译一串JavaScript代码,并返回编译后的脚本。
1226e41f4b71Sopenharmony_ci
1227e41f4b71Sopenharmony_ci**起始版本:** 12
1228e41f4b71Sopenharmony_ci
1229e41f4b71Sopenharmony_ci**参数:**
1230e41f4b71Sopenharmony_ci
1231e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1232e41f4b71Sopenharmony_ci| -------- | -------- |
1233e41f4b71Sopenharmony_ci| env | 目标环境,JSVM-API接口将在该环境下调用。 | 
1234e41f4b71Sopenharmony_ci| script | 包含要编译的脚本的JavaScript代码。 | 
1235e41f4b71Sopenharmony_ci| optionCount | 传入的 option 数组的长度. | 
1236e41f4b71Sopenharmony_ci| options | option 数组,存放所有的编译选项. | 
1237e41f4b71Sopenharmony_ci| result | 编译后的脚本。 | 
1238e41f4b71Sopenharmony_ci
1239e41f4b71Sopenharmony_ci**返回:**
1240e41f4b71Sopenharmony_ci
1241e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1242e41f4b71Sopenharmony_ci
1243e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
1244e41f4b71Sopenharmony_ci
1245e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
1246e41f4b71Sopenharmony_ci
1247e41f4b71Sopenharmony_ci
1248e41f4b71Sopenharmony_ci### OH_JSVM_CompileScriptWithOrigin()
1249e41f4b71Sopenharmony_ci
1250e41f4b71Sopenharmony_ci```
1251e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CompileScriptWithOrigin (JSVM_Env env, JSVM_Value script, const uint8_t * cachedData, size_t cacheDataLength, bool eagerCompile, bool * cacheRejected, JSVM_ScriptOrigin * origin, JSVM_Script * result )
1252e41f4b71Sopenharmony_ci```
1253e41f4b71Sopenharmony_ci
1254e41f4b71Sopenharmony_ci**描述**
1255e41f4b71Sopenharmony_ci
1256e41f4b71Sopenharmony_ci编译一串包含 sourcemap 信息的 JavaScript 代码,并返回编译后的脚本。
1257e41f4b71Sopenharmony_ci
1258e41f4b71Sopenharmony_ci**起始版本:** 12
1259e41f4b71Sopenharmony_ci
1260e41f4b71Sopenharmony_ci**参数:**
1261e41f4b71Sopenharmony_ci
1262e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1263e41f4b71Sopenharmony_ci| -------- | -------- |
1264e41f4b71Sopenharmony_ci| env | 目标环境,JSVM-API接口将在该环境下调用。 | 
1265e41f4b71Sopenharmony_ci| script | 包含要编译的脚本的JavaScript代码。 | 
1266e41f4b71Sopenharmony_ci| cachedData | 可选。脚本的代码缓存数据。 | 
1267e41f4b71Sopenharmony_ci| cacheDataLength | cachedData数组的长度。 | 
1268e41f4b71Sopenharmony_ci| eagerCompile | 是否立即编译脚本。 | 
1269e41f4b71Sopenharmony_ci| cacheRejected | 代码缓存是否被编译拒绝。 | 
1270e41f4b71Sopenharmony_ci| origin | 源代码信息,包括 source map 的位置和源代码文件名等信息 | 
1271e41f4b71Sopenharmony_ci| result | 编译后的脚本。 | 
1272e41f4b71Sopenharmony_ci
1273e41f4b71Sopenharmony_ci**返回:**
1274e41f4b71Sopenharmony_ci
1275e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1276e41f4b71Sopenharmony_ci
1277e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
1278e41f4b71Sopenharmony_ci
1279e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示执行失败。
1280e41f4b71Sopenharmony_ci
1281e41f4b71Sopenharmony_ci
1282e41f4b71Sopenharmony_ci### OH_JSVM_CompileWasmFunction()
1283e41f4b71Sopenharmony_ci
1284e41f4b71Sopenharmony_ci```
1285e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CompileWasmFunction (JSVM_Env env, JSVM_Value wasmModule, uint32_t functionIndex, JSVM_WasmOptLevel optLevel )
1286e41f4b71Sopenharmony_ci```
1287e41f4b71Sopenharmony_ci
1288e41f4b71Sopenharmony_ci**描述**
1289e41f4b71Sopenharmony_ci
1290e41f4b71Sopenharmony_ci对当前 WebAssembly 模块中指定索引的函数进行指定优化等级的编译优化。
1291e41f4b71Sopenharmony_ci
1292e41f4b71Sopenharmony_ci**起始版本:** 12
1293e41f4b71Sopenharmony_ci
1294e41f4b71Sopenharmony_ci**参数:**
1295e41f4b71Sopenharmony_ci
1296e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1297e41f4b71Sopenharmony_ci| -------- | -------- |
1298e41f4b71Sopenharmony_ci| env | 调用 JSVM-API 的环境。 | 
1299e41f4b71Sopenharmony_ci| wasmModule | 待编译函数所在的 WebAssembly 模块。 | 
1300e41f4b71Sopenharmony_ci| functionIndex | 待编译函数的索引,索引必须位于合法范围。 | 
1301e41f4b71Sopenharmony_ci| optLevel | 优化等级,当前只支持高优化等级。 | 
1302e41f4b71Sopenharmony_ci
1303e41f4b71Sopenharmony_ci**返回:**
1304e41f4b71Sopenharmony_ci
1305e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1306e41f4b71Sopenharmony_ci
1307e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示 env 或 wasmModule 参数为空,或 wasmModule 不是一个真正的 WebAssembly 模块。
1308e41f4b71Sopenharmony_ci
1309e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示函数索引越界,或编译失败。
1310e41f4b71Sopenharmony_ci
1311e41f4b71Sopenharmony_ciJSVM_PENDING_EXCEPTION 表示发生了异常。
1312e41f4b71Sopenharmony_ci
1313e41f4b71Sopenharmony_ci
1314e41f4b71Sopenharmony_ci### OH_JSVM_CompileWasmModule()
1315e41f4b71Sopenharmony_ci
1316e41f4b71Sopenharmony_ci```
1317e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CompileWasmModule (JSVM_Env env, const uint8_t * wasmBytecode, size_t wasmBytecodeLength, const uint8_t * cacheData, size_t cacheDataLength, bool * cacheRejected, JSVM_Value * wasmModule )
1318e41f4b71Sopenharmony_ci```
1319e41f4b71Sopenharmony_ci
1320e41f4b71Sopenharmony_ci**描述**
1321e41f4b71Sopenharmony_ci
1322e41f4b71Sopenharmony_ci将 WebAssembly 字节码编译得到一个 WebAssembly 模块。 如果提供了 WebAssembly 缓存,则会先尝试对缓存进行反序列化。
1323e41f4b71Sopenharmony_ci
1324e41f4b71Sopenharmony_ci**起始版本:** 12
1325e41f4b71Sopenharmony_ci
1326e41f4b71Sopenharmony_ci**参数:**
1327e41f4b71Sopenharmony_ci
1328e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1329e41f4b71Sopenharmony_ci| -------- | -------- |
1330e41f4b71Sopenharmony_ci| env | 调用 JSVM-API 的环境。 | 
1331e41f4b71Sopenharmony_ci| wasmBytecode | WebAssembly 字节码。 | 
1332e41f4b71Sopenharmony_ci| wasmBytecodeLength | WebAssembly 字节码的长度,单位:字节。 | 
1333e41f4b71Sopenharmony_ci| cacheData | 可选的 WebAssembly 缓存。 | 
1334e41f4b71Sopenharmony_ci| cacheDataLength | 可选的 WebAssembly 缓存长度,单位:字节。 | 
1335e41f4b71Sopenharmony_ci| cacheRejected | 输出参数,表示提供的 WebAssembly 缓存是否被引擎拒绝。 | 
1336e41f4b71Sopenharmony_ci| wasmModule | 输出参数,表示生成的 WebAssembly 模块。 | 
1337e41f4b71Sopenharmony_ci
1338e41f4b71Sopenharmony_ci**返回:**
1339e41f4b71Sopenharmony_ci
1340e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1341e41f4b71Sopenharmony_ci
1342e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示 env 或 wasmBytecode 参数为空,或传入的数据长度参数无效。
1343e41f4b71Sopenharmony_ci
1344e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示编译失败。
1345e41f4b71Sopenharmony_ci
1346e41f4b71Sopenharmony_ciJSVM_PENDING_EXCEPTION 表示发生了异常。
1347e41f4b71Sopenharmony_ci
1348e41f4b71Sopenharmony_ci
1349e41f4b71Sopenharmony_ci### OH_JSVM_CreateArray()
1350e41f4b71Sopenharmony_ci
1351e41f4b71Sopenharmony_ci```
1352e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateArray (JSVM_Env env, JSVM_Value * result )
1353e41f4b71Sopenharmony_ci```
1354e41f4b71Sopenharmony_ci
1355e41f4b71Sopenharmony_ci**描述**
1356e41f4b71Sopenharmony_ci
1357e41f4b71Sopenharmony_ci返回对应于JavaScript Array类型的JSVM-API值。
1358e41f4b71Sopenharmony_ci
1359e41f4b71Sopenharmony_ci**起始版本:** 11
1360e41f4b71Sopenharmony_ci
1361e41f4b71Sopenharmony_ci**参数:**
1362e41f4b71Sopenharmony_ci
1363e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1364e41f4b71Sopenharmony_ci| -------- | -------- |
1365e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1366e41f4b71Sopenharmony_ci| result | 代表JavaScript Array的JSVM_Value。 | 
1367e41f4b71Sopenharmony_ci
1368e41f4b71Sopenharmony_ci**返回:**
1369e41f4b71Sopenharmony_ci
1370e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1371e41f4b71Sopenharmony_ci
1372e41f4b71Sopenharmony_ci
1373e41f4b71Sopenharmony_ci### OH_JSVM_CreateArraybuffer()
1374e41f4b71Sopenharmony_ci
1375e41f4b71Sopenharmony_ci```
1376e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateArraybuffer (JSVM_Env env, size_t byteLength, void ** data, JSVM_Value * result )
1377e41f4b71Sopenharmony_ci```
1378e41f4b71Sopenharmony_ci
1379e41f4b71Sopenharmony_ci**描述**
1380e41f4b71Sopenharmony_ci
1381e41f4b71Sopenharmony_ci返回JavaScript ArrayBuffer类型对应的JSVM-API值。ArrayBuffer用于 表示固定长度的二进制数据缓冲区。通常用作TypedArray对象的后备缓冲区。 分配的ArrayBuffer有一个底层字节缓冲区,其大小由传入的length参数决定。 底层缓冲区可选择返回给调用方,调用方可直接操作该缓冲区。 此缓冲区只能直接从native代码写入。如果想从JavaScript写入该缓冲区, 需创建TypedArray或DataView对象。
1382e41f4b71Sopenharmony_ci
1383e41f4b71Sopenharmony_ci**起始版本:** 11
1384e41f4b71Sopenharmony_ci
1385e41f4b71Sopenharmony_ci**参数:**
1386e41f4b71Sopenharmony_ci
1387e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1388e41f4b71Sopenharmony_ci| -------- | -------- |
1389e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1390e41f4b71Sopenharmony_ci| byteLength | 要创建的数组缓冲区的字节长度。 | 
1391e41f4b71Sopenharmony_ci| data | 指向ArrayBuffer的底层字节缓冲区的指针。data可以选择性地通过传递NULL来忽略。 | 
1392e41f4b71Sopenharmony_ci| result | 代表JavaScript ArrayBuffer的JSVM_Value。 | 
1393e41f4b71Sopenharmony_ci
1394e41f4b71Sopenharmony_ci**返回:**
1395e41f4b71Sopenharmony_ci
1396e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1397e41f4b71Sopenharmony_ci
1398e41f4b71Sopenharmony_ci
1399e41f4b71Sopenharmony_ci### OH_JSVM_CreateArrayBufferFromBackingStoreData()
1400e41f4b71Sopenharmony_ci
1401e41f4b71Sopenharmony_ci```
1402e41f4b71Sopenharmony_ciJSVM_Status JSVM_CDECL OH_JSVM_CreateArrayBufferFromBackingStoreData (JSVM_Env env, void * data, size_t backingStoreSize, size_t offset, size_t arrayBufferSize, JSVM_Value * result )
1403e41f4b71Sopenharmony_ci```
1404e41f4b71Sopenharmony_ci
1405e41f4b71Sopenharmony_ci**描述**
1406e41f4b71Sopenharmony_ci
1407e41f4b71Sopenharmony_ci在申请得到的 BackingStore 内存上创建 array buffer。
1408e41f4b71Sopenharmony_ci
1409e41f4b71Sopenharmony_ci**起始版本:** 12
1410e41f4b71Sopenharmony_ci
1411e41f4b71Sopenharmony_ci**参数:**
1412e41f4b71Sopenharmony_ci
1413e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1414e41f4b71Sopenharmony_ci| -------- | -------- |
1415e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1416e41f4b71Sopenharmony_ci| data | 申请得到的 BackingStore 内存。 | 
1417e41f4b71Sopenharmony_ci| backingStoreSize | BackingStore 内存的大小。 | 
1418e41f4b71Sopenharmony_ci| offset | array buffer 在这段内存上的起始位置与内存头之间的相对偏移,单位是字节。 | 
1419e41f4b71Sopenharmony_ci| arrayBufferSize | array buffer 的大小,单位是字节。 | 
1420e41f4b71Sopenharmony_ci| result | 接收 array buffer 地址的指针。 | 
1421e41f4b71Sopenharmony_ci
1422e41f4b71Sopenharmony_ci**返回:**
1423e41f4b71Sopenharmony_ci
1424e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1425e41f4b71Sopenharmony_ci
1426e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示触发了下面描述的异常情况之一:
1427e41f4b71Sopenharmony_ci
1428e41f4b71Sopenharmony_ci1. offset + arrayBufferSize &gt; backingStoreSize
1429e41f4b71Sopenharmony_ci
1430e41f4b71Sopenharmony_ci2. backingStoreSize 或者 arrayBufferSize 为 0
1431e41f4b71Sopenharmony_ci
1432e41f4b71Sopenharmony_ci3. data 或者 result 为空
1433e41f4b71Sopenharmony_ci
1434e41f4b71Sopenharmony_ci
1435e41f4b71Sopenharmony_ci### OH_JSVM_CreateArrayWithLength()
1436e41f4b71Sopenharmony_ci
1437e41f4b71Sopenharmony_ci```
1438e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateArrayWithLength (JSVM_Env env, size_t length, JSVM_Value * result )
1439e41f4b71Sopenharmony_ci```
1440e41f4b71Sopenharmony_ci
1441e41f4b71Sopenharmony_ci**描述**
1442e41f4b71Sopenharmony_ci
1443e41f4b71Sopenharmony_ci返回对应于JavaScript Array类型的JSVM-API值。Array 的长度属性设置为传入的长度参数。但是,不保证底层缓冲区在创建 数组时由VM预先分配。该行为留给底层VM实现。
1444e41f4b71Sopenharmony_ci
1445e41f4b71Sopenharmony_ci**起始版本:** 11
1446e41f4b71Sopenharmony_ci
1447e41f4b71Sopenharmony_ci**参数:**
1448e41f4b71Sopenharmony_ci
1449e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1450e41f4b71Sopenharmony_ci| -------- | -------- |
1451e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1452e41f4b71Sopenharmony_ci| length | 数组的初始长度。 | 
1453e41f4b71Sopenharmony_ci| result | 代表JavaScript Array的JSVM_Value。 | 
1454e41f4b71Sopenharmony_ci
1455e41f4b71Sopenharmony_ci**返回:**
1456e41f4b71Sopenharmony_ci
1457e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1458e41f4b71Sopenharmony_ci
1459e41f4b71Sopenharmony_ci
1460e41f4b71Sopenharmony_ci### OH_JSVM_CreateBigintInt64()
1461e41f4b71Sopenharmony_ci
1462e41f4b71Sopenharmony_ci```
1463e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateBigintInt64 (JSVM_Env env, int64_t value, JSVM_Value * result )
1464e41f4b71Sopenharmony_ci```
1465e41f4b71Sopenharmony_ci
1466e41f4b71Sopenharmony_ci**描述**
1467e41f4b71Sopenharmony_ci
1468e41f4b71Sopenharmony_ci将C int64_t类型的值转换为JavaScript BigInt类型。
1469e41f4b71Sopenharmony_ci
1470e41f4b71Sopenharmony_ci**起始版本:** 11
1471e41f4b71Sopenharmony_ci
1472e41f4b71Sopenharmony_ci**参数:**
1473e41f4b71Sopenharmony_ci
1474e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1475e41f4b71Sopenharmony_ci| -------- | -------- |
1476e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1477e41f4b71Sopenharmony_ci| value | 要在JavaScript中表现的整数值。 | 
1478e41f4b71Sopenharmony_ci| result | 表示JavaScript BigInt类型的JSVM_Value。 | 
1479e41f4b71Sopenharmony_ci
1480e41f4b71Sopenharmony_ci**返回:**
1481e41f4b71Sopenharmony_ci
1482e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1483e41f4b71Sopenharmony_ci
1484e41f4b71Sopenharmony_ci
1485e41f4b71Sopenharmony_ci### OH_JSVM_CreateBigintUint64()
1486e41f4b71Sopenharmony_ci
1487e41f4b71Sopenharmony_ci```
1488e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateBigintUint64 (JSVM_Env env, uint64_t value, JSVM_Value * result )
1489e41f4b71Sopenharmony_ci```
1490e41f4b71Sopenharmony_ci
1491e41f4b71Sopenharmony_ci**描述**
1492e41f4b71Sopenharmony_ci
1493e41f4b71Sopenharmony_ci将C uint64_t类型的值转换为JavaScript BigInt类型。
1494e41f4b71Sopenharmony_ci
1495e41f4b71Sopenharmony_ci**起始版本:** 11
1496e41f4b71Sopenharmony_ci
1497e41f4b71Sopenharmony_ci**参数:**
1498e41f4b71Sopenharmony_ci
1499e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1500e41f4b71Sopenharmony_ci| -------- | -------- |
1501e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1502e41f4b71Sopenharmony_ci| value | 要在JavaScript中表示的无符号整数值。 | 
1503e41f4b71Sopenharmony_ci| result | 代表JavaScript BigInt类型的JSVM_Value。 | 
1504e41f4b71Sopenharmony_ci
1505e41f4b71Sopenharmony_ci**返回:**
1506e41f4b71Sopenharmony_ci
1507e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1508e41f4b71Sopenharmony_ci
1509e41f4b71Sopenharmony_ci
1510e41f4b71Sopenharmony_ci### OH_JSVM_CreateBigintWords()
1511e41f4b71Sopenharmony_ci
1512e41f4b71Sopenharmony_ci```
1513e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateBigintWords (JSVM_Env env, int signBit, size_t wordCount, const uint64_t * words, JSVM_Value * result )
1514e41f4b71Sopenharmony_ci```
1515e41f4b71Sopenharmony_ci
1516e41f4b71Sopenharmony_ci**描述**
1517e41f4b71Sopenharmony_ci
1518e41f4b71Sopenharmony_ci将一组无符号64位字转换为单个BigInt值。
1519e41f4b71Sopenharmony_ci
1520e41f4b71Sopenharmony_ci**起始版本:** 11
1521e41f4b71Sopenharmony_ci
1522e41f4b71Sopenharmony_ci**参数:**
1523e41f4b71Sopenharmony_ci
1524e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1525e41f4b71Sopenharmony_ci| -------- | -------- |
1526e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1527e41f4b71Sopenharmony_ci| signBit | 确定生成的BigInt是正数还是负数。 | 
1528e41f4b71Sopenharmony_ci| wordCount | words数组的长度。 | 
1529e41f4b71Sopenharmony_ci| words | uint64_t little-endian 64位字数组。 | 
1530e41f4b71Sopenharmony_ci| result | 代表JavaScript BigInt类型的JSVM_Value。 | 
1531e41f4b71Sopenharmony_ci
1532e41f4b71Sopenharmony_ci**返回:**
1533e41f4b71Sopenharmony_ci
1534e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1535e41f4b71Sopenharmony_ci
1536e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
1537e41f4b71Sopenharmony_ci
1538e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
1539e41f4b71Sopenharmony_ci
1540e41f4b71Sopenharmony_ci
1541e41f4b71Sopenharmony_ci### OH_JSVM_CreateCodeCache()
1542e41f4b71Sopenharmony_ci
1543e41f4b71Sopenharmony_ci```
1544e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateCodeCache (JSVM_Env env, JSVM_Script script, const uint8_t ** data, size_t * length )
1545e41f4b71Sopenharmony_ci```
1546e41f4b71Sopenharmony_ci
1547e41f4b71Sopenharmony_ci**描述**
1548e41f4b71Sopenharmony_ci
1549e41f4b71Sopenharmony_ci为编译后的脚本创建代码缓存。
1550e41f4b71Sopenharmony_ci
1551e41f4b71Sopenharmony_ci**起始版本:** 11
1552e41f4b71Sopenharmony_ci
1553e41f4b71Sopenharmony_ci**参数:**
1554e41f4b71Sopenharmony_ci
1555e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1556e41f4b71Sopenharmony_ci| -------- | -------- |
1557e41f4b71Sopenharmony_ci| env | 目标环境,JSVM-API接口将在该环境下调用。 | 
1558e41f4b71Sopenharmony_ci| script | 目标编译脚本。 | 
1559e41f4b71Sopenharmony_ci| data | 代码缓存的数据。 | 
1560e41f4b71Sopenharmony_ci| length | 代码缓存数据的长度。 | 
1561e41f4b71Sopenharmony_ci
1562e41f4b71Sopenharmony_ci**返回:**
1563e41f4b71Sopenharmony_ci
1564e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1565e41f4b71Sopenharmony_ci
1566e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示执行失败。
1567e41f4b71Sopenharmony_ci
1568e41f4b71Sopenharmony_ci
1569e41f4b71Sopenharmony_ci### OH_JSVM_CreateDataview()
1570e41f4b71Sopenharmony_ci
1571e41f4b71Sopenharmony_ci```
1572e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateDataview (JSVM_Env env, size_t length, JSVM_Value arraybuffer, size_t byteOffset, JSVM_Value * result )
1573e41f4b71Sopenharmony_ci```
1574e41f4b71Sopenharmony_ci
1575e41f4b71Sopenharmony_ci**描述**
1576e41f4b71Sopenharmony_ci
1577e41f4b71Sopenharmony_ci基于已有的ArrayBuffer对象,创建一个JavaScript DataView对象。DataView 对象在底层数据缓冲区上提供了一个类似数组的视图,其中的元素可以具有不同的大小和类型。 要求:二进制的length + byteOffset 小于或等于传入的数组的大小(以字节为单位)。否则,将抛出范围错误(RangeError)。
1578e41f4b71Sopenharmony_ci
1579e41f4b71Sopenharmony_ci**起始版本:** 11
1580e41f4b71Sopenharmony_ci
1581e41f4b71Sopenharmony_ci**参数:**
1582e41f4b71Sopenharmony_ci
1583e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1584e41f4b71Sopenharmony_ci| -------- | -------- |
1585e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1586e41f4b71Sopenharmony_ci| length | DataView中的元素个数。 | 
1587e41f4b71Sopenharmony_ci| arraybuffer | 位于DataView底层的ArrayBuffer。 | 
1588e41f4b71Sopenharmony_ci| byteOffset | ArrayBuffer中的字节偏移量,指示投影DataView的开始位置。 | 
1589e41f4b71Sopenharmony_ci| result | 表示JavaScript DataView对象的JSVM_Value。 | 
1590e41f4b71Sopenharmony_ci
1591e41f4b71Sopenharmony_ci**返回:**
1592e41f4b71Sopenharmony_ci
1593e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1594e41f4b71Sopenharmony_ci
1595e41f4b71Sopenharmony_ci
1596e41f4b71Sopenharmony_ci### OH_JSVM_CreateDate()
1597e41f4b71Sopenharmony_ci
1598e41f4b71Sopenharmony_ci```
1599e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateDate (JSVM_Env env, double time, JSVM_Value * result )
1600e41f4b71Sopenharmony_ci```
1601e41f4b71Sopenharmony_ci
1602e41f4b71Sopenharmony_ci**描述**
1603e41f4b71Sopenharmony_ci
1604e41f4b71Sopenharmony_ci分配一个JavaScript Date对象。此API不处理闰秒。 这是因为ECMAScript遵循POSIX时间规范,对闰秒进行忽略。
1605e41f4b71Sopenharmony_ci
1606e41f4b71Sopenharmony_ci**起始版本:** 11
1607e41f4b71Sopenharmony_ci
1608e41f4b71Sopenharmony_ci**参数:**
1609e41f4b71Sopenharmony_ci
1610e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1611e41f4b71Sopenharmony_ci| -------- | -------- |
1612e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1613e41f4b71Sopenharmony_ci| time | 自1970年1月1日UTC以来的ECMAScript时间值(以毫秒为单位)。 | 
1614e41f4b71Sopenharmony_ci| result | 表示JavaScript Date对象的JSVM_Value。 | 
1615e41f4b71Sopenharmony_ci
1616e41f4b71Sopenharmony_ci**返回:**
1617e41f4b71Sopenharmony_ci
1618e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1619e41f4b71Sopenharmony_ci
1620e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示执行失败。
1621e41f4b71Sopenharmony_ci
1622e41f4b71Sopenharmony_ci
1623e41f4b71Sopenharmony_ci### OH_JSVM_CreateDouble()
1624e41f4b71Sopenharmony_ci
1625e41f4b71Sopenharmony_ci```
1626e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateDouble (JSVM_Env env, double value, JSVM_Value * result )
1627e41f4b71Sopenharmony_ci```
1628e41f4b71Sopenharmony_ci
1629e41f4b71Sopenharmony_ci**描述**
1630e41f4b71Sopenharmony_ci
1631e41f4b71Sopenharmony_ci将C double类型的值转换为JavaScript number类型。
1632e41f4b71Sopenharmony_ci
1633e41f4b71Sopenharmony_ci**起始版本:** 11
1634e41f4b71Sopenharmony_ci
1635e41f4b71Sopenharmony_ci**参数:**
1636e41f4b71Sopenharmony_ci
1637e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1638e41f4b71Sopenharmony_ci| -------- | -------- |
1639e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1640e41f4b71Sopenharmony_ci| value | 要在JavaScript中表现的双精度值。 | 
1641e41f4b71Sopenharmony_ci| result | 代表JavaScript number类型的JSVM_Value。 | 
1642e41f4b71Sopenharmony_ci
1643e41f4b71Sopenharmony_ci**返回:**
1644e41f4b71Sopenharmony_ci
1645e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1646e41f4b71Sopenharmony_ci
1647e41f4b71Sopenharmony_ci
1648e41f4b71Sopenharmony_ci### OH_JSVM_CreateEnv()
1649e41f4b71Sopenharmony_ci
1650e41f4b71Sopenharmony_ci```
1651e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateEnv (JSVM_VM vm, size_t propertyCount, const JSVM_PropertyDescriptor * properties, JSVM_Env * result )
1652e41f4b71Sopenharmony_ci```
1653e41f4b71Sopenharmony_ci
1654e41f4b71Sopenharmony_ci**描述**
1655e41f4b71Sopenharmony_ci
1656e41f4b71Sopenharmony_ci基于新环境上下文的可选属性,创建一个新环境。
1657e41f4b71Sopenharmony_ci
1658e41f4b71Sopenharmony_ci**起始版本:** 11
1659e41f4b71Sopenharmony_ci
1660e41f4b71Sopenharmony_ci**参数:**
1661e41f4b71Sopenharmony_ci
1662e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1663e41f4b71Sopenharmony_ci| -------- | -------- |
1664e41f4b71Sopenharmony_ci| vm | 虚拟机实例,新环境将在该实例中创建。 | 
1665e41f4b71Sopenharmony_ci| propertyCount | 属性数组中元素的个数。 | 
1666e41f4b71Sopenharmony_ci| properties | 属性描述符的数组。 | 
1667e41f4b71Sopenharmony_ci| result | 创建的新环境。 | 
1668e41f4b71Sopenharmony_ci
1669e41f4b71Sopenharmony_ci**返回:**
1670e41f4b71Sopenharmony_ci
1671e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1672e41f4b71Sopenharmony_ci
1673e41f4b71Sopenharmony_ci
1674e41f4b71Sopenharmony_ci### OH_JSVM_CreateEnvFromSnapshot()
1675e41f4b71Sopenharmony_ci
1676e41f4b71Sopenharmony_ci```
1677e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateEnvFromSnapshot (JSVM_VM vm, size_t index, JSVM_Env * result )
1678e41f4b71Sopenharmony_ci```
1679e41f4b71Sopenharmony_ci
1680e41f4b71Sopenharmony_ci**描述**
1681e41f4b71Sopenharmony_ci
1682e41f4b71Sopenharmony_ci基于虚拟机的起始快照,创建一个新的环境。
1683e41f4b71Sopenharmony_ci
1684e41f4b71Sopenharmony_ci**起始版本:** 11
1685e41f4b71Sopenharmony_ci
1686e41f4b71Sopenharmony_ci**参数:**
1687e41f4b71Sopenharmony_ci
1688e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1689e41f4b71Sopenharmony_ci| -------- | -------- |
1690e41f4b71Sopenharmony_ci| vm | 虚拟机实例,新环境将在该实例中创建。 | 
1691e41f4b71Sopenharmony_ci| index | 环境在快照中的索引。 | 
1692e41f4b71Sopenharmony_ci| result | 创建的新环境。 | 
1693e41f4b71Sopenharmony_ci
1694e41f4b71Sopenharmony_ci**返回:**
1695e41f4b71Sopenharmony_ci
1696e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1697e41f4b71Sopenharmony_ci
1698e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
1699e41f4b71Sopenharmony_ci
1700e41f4b71Sopenharmony_ci
1701e41f4b71Sopenharmony_ci### OH_JSVM_CreateError()
1702e41f4b71Sopenharmony_ci
1703e41f4b71Sopenharmony_ci```
1704e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateError (JSVM_Env env, JSVM_Value code, JSVM_Value msg, JSVM_Value * result )
1705e41f4b71Sopenharmony_ci```
1706e41f4b71Sopenharmony_ci
1707e41f4b71Sopenharmony_ci**描述**
1708e41f4b71Sopenharmony_ci
1709e41f4b71Sopenharmony_ci返回带有所提供文本的JavaScript Error。
1710e41f4b71Sopenharmony_ci
1711e41f4b71Sopenharmony_ci**起始版本:** 11
1712e41f4b71Sopenharmony_ci
1713e41f4b71Sopenharmony_ci**参数:**
1714e41f4b71Sopenharmony_ci
1715e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1716e41f4b71Sopenharmony_ci| -------- | -------- |
1717e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1718e41f4b71Sopenharmony_ci| code | 可选的JSVM_Value,带有与错误关联的错误代码的字符串。 | 
1719e41f4b71Sopenharmony_ci| msg | 引用JavaScript string用作Error的消息。 | 
1720e41f4b71Sopenharmony_ci| result | 表示创建的错误。 | 
1721e41f4b71Sopenharmony_ci
1722e41f4b71Sopenharmony_ci**返回:**
1723e41f4b71Sopenharmony_ci
1724e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1725e41f4b71Sopenharmony_ci
1726e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
1727e41f4b71Sopenharmony_ci
1728e41f4b71Sopenharmony_ci
1729e41f4b71Sopenharmony_ci### OH_JSVM_CreateExternal()
1730e41f4b71Sopenharmony_ci
1731e41f4b71Sopenharmony_ci```
1732e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateExternal (JSVM_Env env, void * data, JSVM_Finalize finalizeCb, void * finalizeHint, JSVM_Value * result )
1733e41f4b71Sopenharmony_ci```
1734e41f4b71Sopenharmony_ci
1735e41f4b71Sopenharmony_ci**描述**
1736e41f4b71Sopenharmony_ci
1737e41f4b71Sopenharmony_ci分配一个带有外部数据的JavaScript值。这用于通过JavaScript代码传递外部数据。 后续可以使用OH_JSVM_GetValueExternal由native代码检索。 该API添加了一个JSVM_Finalize回调,当刚刚创建的JavaScript对象被垃圾回收时将调用该回调。 创建的值不是一个对象,因此不支持附加属性。它被认为是一个独特的值类型: 使用外部值调用OH_JSVM_Typeof()会生成JSVM_EXTERNAL。
1738e41f4b71Sopenharmony_ci
1739e41f4b71Sopenharmony_ci**起始版本:** 11
1740e41f4b71Sopenharmony_ci
1741e41f4b71Sopenharmony_ci**参数:**
1742e41f4b71Sopenharmony_ci
1743e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1744e41f4b71Sopenharmony_ci| -------- | -------- |
1745e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1746e41f4b71Sopenharmony_ci| data | 指向外部数据的原始指针。 | 
1747e41f4b71Sopenharmony_ci| finalizeCb | 收集外部值时调用的可选回调。JSVM_Finalize提供了更多详细信息。 | 
1748e41f4b71Sopenharmony_ci| finalizeHint | 在收集期间传递给最终回调的可选提示。 | 
1749e41f4b71Sopenharmony_ci| result | 表示外部值的JSVM_Value。 | 
1750e41f4b71Sopenharmony_ci
1751e41f4b71Sopenharmony_ci**返回:**
1752e41f4b71Sopenharmony_ci
1753e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1754e41f4b71Sopenharmony_ci
1755e41f4b71Sopenharmony_ci
1756e41f4b71Sopenharmony_ci### OH_JSVM_CreateFunction()
1757e41f4b71Sopenharmony_ci
1758e41f4b71Sopenharmony_ci```
1759e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateFunction (JSVM_Env env, const char * utf8name, size_t length, JSVM_Callback cb, JSVM_Value * result )
1760e41f4b71Sopenharmony_ci```
1761e41f4b71Sopenharmony_ci
1762e41f4b71Sopenharmony_ci**描述**
1763e41f4b71Sopenharmony_ci
1764e41f4b71Sopenharmony_ci支持在native代码中创建函数对象,这是从JavaScript调用native代码的主要机制。 在此调用之后,新创建的函数在脚本中不再自动可见。相反,必须在JavaScript可见的任何对象上显示设置属性, 才能从脚本访问该函数。
1765e41f4b71Sopenharmony_ci
1766e41f4b71Sopenharmony_ci**起始版本:** 11
1767e41f4b71Sopenharmony_ci
1768e41f4b71Sopenharmony_ci**参数:**
1769e41f4b71Sopenharmony_ci
1770e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1771e41f4b71Sopenharmony_ci| -------- | -------- |
1772e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1773e41f4b71Sopenharmony_ci| utf8Name | 编码为UTF8的函数的可选名称。这在JavaScript中是可见的, 作为新函数对象的name属性。 | 
1774e41f4b71Sopenharmony_ci| length | utf8name的长度(以字节为单位)或JSVM_AUTO_LENGTH(如果以 null 结尾)。 | 
1775e41f4b71Sopenharmony_ci| cb | 调用此函数对象时应调用的native函数。详情请参考JSVM_Callback。 | 
1776e41f4b71Sopenharmony_ci| result | 表示新创建函数的JavaScript函数对象。 | 
1777e41f4b71Sopenharmony_ci
1778e41f4b71Sopenharmony_ci**返回:**
1779e41f4b71Sopenharmony_ci
1780e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1781e41f4b71Sopenharmony_ci
1782e41f4b71Sopenharmony_ci
1783e41f4b71Sopenharmony_ci### OH_JSVM_CreateFunctionWithScript()
1784e41f4b71Sopenharmony_ci
1785e41f4b71Sopenharmony_ci```
1786e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateFunctionWithScript (JSVM_Env env, const char * funcName, size_t length, size_t argc, const JSVM_Value * argv, JSVM_Value script, JSVM_Value * result )
1787e41f4b71Sopenharmony_ci```
1788e41f4b71Sopenharmony_ci
1789e41f4b71Sopenharmony_ci**描述**
1790e41f4b71Sopenharmony_ci
1791e41f4b71Sopenharmony_ci创建一个以给定JavaScript为函数体的函数。
1792e41f4b71Sopenharmony_ci
1793e41f4b71Sopenharmony_ci**起始版本:** 12
1794e41f4b71Sopenharmony_ci
1795e41f4b71Sopenharmony_ci**参数:**
1796e41f4b71Sopenharmony_ci
1797e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1798e41f4b71Sopenharmony_ci| -------- | -------- |
1799e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1800e41f4b71Sopenharmony_ci| funcName | 包含函数名称的字符串。如果传入NULL,则创建一个匿名函数。 | 
1801e41f4b71Sopenharmony_ci| length | funcName的长度(以字节为单位)或JSVM_AUTO_LENGTH(如果以 null 结尾)。 | 
1802e41f4b71Sopenharmony_ci| argc | argv数组中的元素个数。 | 
1803e41f4b71Sopenharmony_ci| argv | JSVM_values数组,表示将作为参数传递给函数的JavaScript值。 | 
1804e41f4b71Sopenharmony_ci| script | 包含作为函数体的JavaScript字符串。 | 
1805e41f4b71Sopenharmony_ci| result | 表示新创建函数的JavaScript函数对象的JSVM_Value。 | 
1806e41f4b71Sopenharmony_ci
1807e41f4b71Sopenharmony_ci**返回:**
1808e41f4b71Sopenharmony_ci
1809e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1810e41f4b71Sopenharmony_ci
1811e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示输入的JavaScript无法编译成功。
1812e41f4b71Sopenharmony_ci
1813e41f4b71Sopenharmony_ci
1814e41f4b71Sopenharmony_ci### OH_JSVM_CreateInt32()
1815e41f4b71Sopenharmony_ci
1816e41f4b71Sopenharmony_ci```
1817e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateInt32 (JSVM_Env env, int32_t value, JSVM_Value * result )
1818e41f4b71Sopenharmony_ci```
1819e41f4b71Sopenharmony_ci
1820e41f4b71Sopenharmony_ci**描述**
1821e41f4b71Sopenharmony_ci
1822e41f4b71Sopenharmony_ci将C int32_t类型的值转换为JavaScript number类型。
1823e41f4b71Sopenharmony_ci
1824e41f4b71Sopenharmony_ci**起始版本:** 11
1825e41f4b71Sopenharmony_ci
1826e41f4b71Sopenharmony_ci**参数:**
1827e41f4b71Sopenharmony_ci
1828e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1829e41f4b71Sopenharmony_ci| -------- | -------- |
1830e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1831e41f4b71Sopenharmony_ci| value | 要在JavaScript中表示的整数值。 | 
1832e41f4b71Sopenharmony_ci| result | 表示JavaScript number类型的JSVM_Value。 | 
1833e41f4b71Sopenharmony_ci
1834e41f4b71Sopenharmony_ci**返回:**
1835e41f4b71Sopenharmony_ci
1836e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1837e41f4b71Sopenharmony_ci
1838e41f4b71Sopenharmony_ci
1839e41f4b71Sopenharmony_ci### OH_JSVM_CreateInt64()
1840e41f4b71Sopenharmony_ci
1841e41f4b71Sopenharmony_ci```
1842e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateInt64 (JSVM_Env env, int64_t value, JSVM_Value * result )
1843e41f4b71Sopenharmony_ci```
1844e41f4b71Sopenharmony_ci
1845e41f4b71Sopenharmony_ci**描述**
1846e41f4b71Sopenharmony_ci
1847e41f4b71Sopenharmony_ci将C int64_t类型的值转换为JavaScript number类型。
1848e41f4b71Sopenharmony_ci
1849e41f4b71Sopenharmony_ci**起始版本:** 11
1850e41f4b71Sopenharmony_ci
1851e41f4b71Sopenharmony_ci**参数:**
1852e41f4b71Sopenharmony_ci
1853e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1854e41f4b71Sopenharmony_ci| -------- | -------- |
1855e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1856e41f4b71Sopenharmony_ci| value | 要在JavaScript中表示的整数值。 | 
1857e41f4b71Sopenharmony_ci| result | 代表JavaScript number类型的JSVM_Value。 | 
1858e41f4b71Sopenharmony_ci
1859e41f4b71Sopenharmony_ci**返回:**
1860e41f4b71Sopenharmony_ci
1861e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1862e41f4b71Sopenharmony_ci
1863e41f4b71Sopenharmony_ci
1864e41f4b71Sopenharmony_ci### OH_JSVM_CreateMap()
1865e41f4b71Sopenharmony_ci
1866e41f4b71Sopenharmony_ci```
1867e41f4b71Sopenharmony_ciJSVM_Status JSVM_CDECL OH_JSVM_CreateMap (JSVM_Env env, JSVM_Value * result )
1868e41f4b71Sopenharmony_ci```
1869e41f4b71Sopenharmony_ci
1870e41f4b71Sopenharmony_ci**描述**
1871e41f4b71Sopenharmony_ci
1872e41f4b71Sopenharmony_ci此API返回与JavaScript Map类型对应的JavaScript值。
1873e41f4b71Sopenharmony_ci
1874e41f4b71Sopenharmony_ci**起始版本:** 12
1875e41f4b71Sopenharmony_ci
1876e41f4b71Sopenharmony_ci**参数:**
1877e41f4b71Sopenharmony_ci
1878e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1879e41f4b71Sopenharmony_ci| -------- | -------- |
1880e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1881e41f4b71Sopenharmony_ci| result | 代表JavaScript Map的JSVM_Value。 | 
1882e41f4b71Sopenharmony_ci
1883e41f4b71Sopenharmony_ci**返回:**
1884e41f4b71Sopenharmony_ci
1885e41f4b71Sopenharmony_ci返回执行状态码JSVM_Status。 JSVM_OK 表示执行成功。
1886e41f4b71Sopenharmony_ci
1887e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示输入参数不合法。
1888e41f4b71Sopenharmony_ci
1889e41f4b71Sopenharmony_ci
1890e41f4b71Sopenharmony_ci### OH_JSVM_CreateObject()
1891e41f4b71Sopenharmony_ci
1892e41f4b71Sopenharmony_ci```
1893e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateObject (JSVM_Env env, JSVM_Value * result )
1894e41f4b71Sopenharmony_ci```
1895e41f4b71Sopenharmony_ci
1896e41f4b71Sopenharmony_ci**描述**
1897e41f4b71Sopenharmony_ci
1898e41f4b71Sopenharmony_ci分配一个默认的JavaScript对象。该函数功能等同于在JavaScript中执行new Object()。
1899e41f4b71Sopenharmony_ci
1900e41f4b71Sopenharmony_ci**起始版本:** 11
1901e41f4b71Sopenharmony_ci
1902e41f4b71Sopenharmony_ci**参数:**
1903e41f4b71Sopenharmony_ci
1904e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1905e41f4b71Sopenharmony_ci| -------- | -------- |
1906e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1907e41f4b71Sopenharmony_ci| result | 表示JavaScript对象的JSVM_Value。 | 
1908e41f4b71Sopenharmony_ci
1909e41f4b71Sopenharmony_ci**返回:**
1910e41f4b71Sopenharmony_ci
1911e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1912e41f4b71Sopenharmony_ci
1913e41f4b71Sopenharmony_ci
1914e41f4b71Sopenharmony_ci### OH_JSVM_CreatePromise()
1915e41f4b71Sopenharmony_ci
1916e41f4b71Sopenharmony_ci```
1917e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreatePromise (JSVM_Env env, JSVM_Deferred * deferred, JSVM_Value * promise )
1918e41f4b71Sopenharmony_ci```
1919e41f4b71Sopenharmony_ci
1920e41f4b71Sopenharmony_ci**描述**
1921e41f4b71Sopenharmony_ci
1922e41f4b71Sopenharmony_ci创建一个延迟对象和一个JavaScript promise。
1923e41f4b71Sopenharmony_ci
1924e41f4b71Sopenharmony_ci**起始版本:** 11
1925e41f4b71Sopenharmony_ci
1926e41f4b71Sopenharmony_ci**参数:**
1927e41f4b71Sopenharmony_ci
1928e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1929e41f4b71Sopenharmony_ci| -------- | -------- |
1930e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1931e41f4b71Sopenharmony_ci| deferred | 一个新创建的延迟对象,后续可以传递给OH_JSVM_ResolveDeferred()或 [OH_JSVM_RejectDeferred()](#oh_jsvm_rejectdeferred)以解析resp。或拒绝相关的Promise。 | 
1932e41f4b71Sopenharmony_ci| promise | 与延迟对象关联的JavaScript Promise。 | 
1933e41f4b71Sopenharmony_ci
1934e41f4b71Sopenharmony_ci**返回:**
1935e41f4b71Sopenharmony_ci
1936e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1937e41f4b71Sopenharmony_ci
1938e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
1939e41f4b71Sopenharmony_ci
1940e41f4b71Sopenharmony_ci
1941e41f4b71Sopenharmony_ci### OH_JSVM_CreateRangeError()
1942e41f4b71Sopenharmony_ci
1943e41f4b71Sopenharmony_ci```
1944e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateRangeError (JSVM_Env env, JSVM_Value code, JSVM_Value msg, JSVM_Value * result )
1945e41f4b71Sopenharmony_ci```
1946e41f4b71Sopenharmony_ci
1947e41f4b71Sopenharmony_ci**描述**
1948e41f4b71Sopenharmony_ci
1949e41f4b71Sopenharmony_ci返回带有所提供文本的JavaScript RangeError。
1950e41f4b71Sopenharmony_ci
1951e41f4b71Sopenharmony_ci**起始版本:** 11
1952e41f4b71Sopenharmony_ci
1953e41f4b71Sopenharmony_ci**参数:**
1954e41f4b71Sopenharmony_ci
1955e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1956e41f4b71Sopenharmony_ci| -------- | -------- |
1957e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1958e41f4b71Sopenharmony_ci| code | 可选的JSVM_Value,带有与错误关联的错误代码的字符串。 | 
1959e41f4b71Sopenharmony_ci| msg | 引用JavaScript string用作Error的消息。 | 
1960e41f4b71Sopenharmony_ci| result | 表示创建的错误。 | 
1961e41f4b71Sopenharmony_ci
1962e41f4b71Sopenharmony_ci**返回:**
1963e41f4b71Sopenharmony_ci
1964e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1965e41f4b71Sopenharmony_ci
1966e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
1967e41f4b71Sopenharmony_ci
1968e41f4b71Sopenharmony_ci
1969e41f4b71Sopenharmony_ci### OH_JSVM_CreateReference()
1970e41f4b71Sopenharmony_ci
1971e41f4b71Sopenharmony_ci```
1972e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateReference (JSVM_Env env, JSVM_Value value, uint32_t initialRefcount, JSVM_Ref * result )
1973e41f4b71Sopenharmony_ci```
1974e41f4b71Sopenharmony_ci
1975e41f4b71Sopenharmony_ci**描述**
1976e41f4b71Sopenharmony_ci
1977e41f4b71Sopenharmony_ci对传入的值创建一个具有指定引用计数的新引用。
1978e41f4b71Sopenharmony_ci
1979e41f4b71Sopenharmony_ci**起始版本:** 11
1980e41f4b71Sopenharmony_ci
1981e41f4b71Sopenharmony_ci**参数:**
1982e41f4b71Sopenharmony_ci
1983e41f4b71Sopenharmony_ci| 名称 | 描述 | 
1984e41f4b71Sopenharmony_ci| -------- | -------- |
1985e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
1986e41f4b71Sopenharmony_ci| value | 正在为其创建引用的JSVM_Value。 | 
1987e41f4b71Sopenharmony_ci| initialRefcount | 新引用的初始引用计数。 | 
1988e41f4b71Sopenharmony_ci| result | 指向新的引用。 | 
1989e41f4b71Sopenharmony_ci
1990e41f4b71Sopenharmony_ci**返回:**
1991e41f4b71Sopenharmony_ci
1992e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
1993e41f4b71Sopenharmony_ci
1994e41f4b71Sopenharmony_ci
1995e41f4b71Sopenharmony_ci### OH_JSVM_CreateRegExp()
1996e41f4b71Sopenharmony_ci
1997e41f4b71Sopenharmony_ci```
1998e41f4b71Sopenharmony_ciJSVM_Status JSVM_CDECL OH_JSVM_CreateRegExp (JSVM_Env env, JSVM_Value value, JSVM_RegExpFlags flags, JSVM_Value * result )
1999e41f4b71Sopenharmony_ci```
2000e41f4b71Sopenharmony_ci
2001e41f4b71Sopenharmony_ci**描述**
2002e41f4b71Sopenharmony_ci
2003e41f4b71Sopenharmony_ci此API返回与输入对应的正则表达式的JavaScript值。 接口可能会抛出异常。
2004e41f4b71Sopenharmony_ci
2005e41f4b71Sopenharmony_ci**起始版本:** 12
2006e41f4b71Sopenharmony_ci
2007e41f4b71Sopenharmony_ci**参数:**
2008e41f4b71Sopenharmony_ci
2009e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2010e41f4b71Sopenharmony_ci| -------- | -------- |
2011e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2012e41f4b71Sopenharmony_ci| value | 要转换为正则表达式的JavaScript字符串。 | 
2013e41f4b71Sopenharmony_ci| flags | 正则表达式标志位。 | 
2014e41f4b71Sopenharmony_ci| result | 代表JavaScript RegExp的JSVM_Value。 | 
2015e41f4b71Sopenharmony_ci
2016e41f4b71Sopenharmony_ci**返回:**
2017e41f4b71Sopenharmony_ci
2018e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2019e41f4b71Sopenharmony_ci
2020e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示输入参数不合法。
2021e41f4b71Sopenharmony_ci
2022e41f4b71Sopenharmony_ci**JSVM_PENDING_EXCPTION** 表示API在运行时抛出异常。
2023e41f4b71Sopenharmony_ci
2024e41f4b71Sopenharmony_ci
2025e41f4b71Sopenharmony_ci### OH_JSVM_CreateSet()
2026e41f4b71Sopenharmony_ci
2027e41f4b71Sopenharmony_ci```
2028e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateSet (JSVM_Env env, JSVM_Value * result )
2029e41f4b71Sopenharmony_ci```
2030e41f4b71Sopenharmony_ci
2031e41f4b71Sopenharmony_ci**描述**
2032e41f4b71Sopenharmony_ci
2033e41f4b71Sopenharmony_ci创建JavaScript Set对象。
2034e41f4b71Sopenharmony_ci
2035e41f4b71Sopenharmony_ci**起始版本:** 12
2036e41f4b71Sopenharmony_ci
2037e41f4b71Sopenharmony_ci**参数:**
2038e41f4b71Sopenharmony_ci
2039e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2040e41f4b71Sopenharmony_ci| -------- | -------- |
2041e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2042e41f4b71Sopenharmony_ci| result | 表示已经创建的JavaScript Set对象。 | 
2043e41f4b71Sopenharmony_ci
2044e41f4b71Sopenharmony_ci**返回:**
2045e41f4b71Sopenharmony_ci
2046e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status JSVM_OK 表示执行成功。
2047e41f4b71Sopenharmony_ci
2048e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示输入参数不合法。
2049e41f4b71Sopenharmony_ci
2050e41f4b71Sopenharmony_ci
2051e41f4b71Sopenharmony_ci### OH_JSVM_CreateSnapshot()
2052e41f4b71Sopenharmony_ci
2053e41f4b71Sopenharmony_ci```
2054e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateSnapshot (JSVM_VM vm, size_t contextCount, const JSVM_Env * contexts, const char ** blobData, size_t * blobSize )
2055e41f4b71Sopenharmony_ci```
2056e41f4b71Sopenharmony_ci
2057e41f4b71Sopenharmony_ci**描述**
2058e41f4b71Sopenharmony_ci
2059e41f4b71Sopenharmony_ci创建虚拟机的启动快照。
2060e41f4b71Sopenharmony_ci
2061e41f4b71Sopenharmony_ci**起始版本:** 11
2062e41f4b71Sopenharmony_ci
2063e41f4b71Sopenharmony_ci**参数:**
2064e41f4b71Sopenharmony_ci
2065e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2066e41f4b71Sopenharmony_ci| -------- | -------- |
2067e41f4b71Sopenharmony_ci| vm | 目标环境,API接口将在该环境下调用。 | 
2068e41f4b71Sopenharmony_ci| contextCount | 上下文个数。 | 
2069e41f4b71Sopenharmony_ci| contexts | 要添加到快照的上下文数组。 | 
2070e41f4b71Sopenharmony_ci| blobData | 快照数据。 | 
2071e41f4b71Sopenharmony_ci| blobSize | 快照数据的大小。 | 
2072e41f4b71Sopenharmony_ci
2073e41f4b71Sopenharmony_ci**返回:**
2074e41f4b71Sopenharmony_ci
2075e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2076e41f4b71Sopenharmony_ci
2077e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
2078e41f4b71Sopenharmony_ci
2079e41f4b71Sopenharmony_ci
2080e41f4b71Sopenharmony_ci### OH_JSVM_CreateStringLatin1()
2081e41f4b71Sopenharmony_ci
2082e41f4b71Sopenharmony_ci```
2083e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateStringLatin1 (JSVM_Env env, const char * str, size_t length, JSVM_Value * result )
2084e41f4b71Sopenharmony_ci```
2085e41f4b71Sopenharmony_ci
2086e41f4b71Sopenharmony_ci**描述**
2087e41f4b71Sopenharmony_ci
2088e41f4b71Sopenharmony_ci将采用ISO-8859-1编码的C字符串转换为JavaScript string值。 复制原生字符串。
2089e41f4b71Sopenharmony_ci
2090e41f4b71Sopenharmony_ci**起始版本:** 11
2091e41f4b71Sopenharmony_ci
2092e41f4b71Sopenharmony_ci**参数:**
2093e41f4b71Sopenharmony_ci
2094e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2095e41f4b71Sopenharmony_ci| -------- | -------- |
2096e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2097e41f4b71Sopenharmony_ci| str | 表示ISO-8859-1编码的字符串的字符缓冲区。 | 
2098e41f4b71Sopenharmony_ci| length | 字符串的长度,以字节为单位。如果它以null结尾,则为JSVM_AUTO_LENGTH。 | 
2099e41f4b71Sopenharmony_ci| result | 表示JavaScript字符串的JSVM_Value。 | 
2100e41f4b71Sopenharmony_ci
2101e41f4b71Sopenharmony_ci**返回:**
2102e41f4b71Sopenharmony_ci
2103e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2104e41f4b71Sopenharmony_ci
2105e41f4b71Sopenharmony_ci
2106e41f4b71Sopenharmony_ci### OH_JSVM_CreateStringUtf16()
2107e41f4b71Sopenharmony_ci
2108e41f4b71Sopenharmony_ci```
2109e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateStringUtf16 (JSVM_Env env, const char16_t * str, size_t length, JSVM_Value * result )
2110e41f4b71Sopenharmony_ci```
2111e41f4b71Sopenharmony_ci
2112e41f4b71Sopenharmony_ci**描述**
2113e41f4b71Sopenharmony_ci
2114e41f4b71Sopenharmony_ci将采用UTF16-LE编码的C字符串转换为JavaScript字符串值。 复制原生字符串。
2115e41f4b71Sopenharmony_ci
2116e41f4b71Sopenharmony_ci**起始版本:** 11
2117e41f4b71Sopenharmony_ci
2118e41f4b71Sopenharmony_ci**参数:**
2119e41f4b71Sopenharmony_ci
2120e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2121e41f4b71Sopenharmony_ci| -------- | -------- |
2122e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2123e41f4b71Sopenharmony_ci| str | 表示UTF16-LE编码的字符串的字符缓冲区。 | 
2124e41f4b71Sopenharmony_ci| length | 以两字节代码单元表示的字符串长度,如果它以null终止,则为JSVM_AUTO_LENGTH。 | 
2125e41f4b71Sopenharmony_ci| result | 代表JavaScript string的JSVM_Value。 | 
2126e41f4b71Sopenharmony_ci
2127e41f4b71Sopenharmony_ci**返回:**
2128e41f4b71Sopenharmony_ci
2129e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2130e41f4b71Sopenharmony_ci
2131e41f4b71Sopenharmony_ci
2132e41f4b71Sopenharmony_ci### OH_JSVM_CreateStringUtf8()
2133e41f4b71Sopenharmony_ci
2134e41f4b71Sopenharmony_ci```
2135e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateStringUtf8 (JSVM_Env env, const char * str, size_t length, JSVM_Value * result )
2136e41f4b71Sopenharmony_ci```
2137e41f4b71Sopenharmony_ci
2138e41f4b71Sopenharmony_ci**描述**
2139e41f4b71Sopenharmony_ci
2140e41f4b71Sopenharmony_ci从UTF8编码的C字符串创建JavaScript string值。 复制原生字符串。
2141e41f4b71Sopenharmony_ci
2142e41f4b71Sopenharmony_ci**起始版本:** 11
2143e41f4b71Sopenharmony_ci
2144e41f4b71Sopenharmony_ci**参数:**
2145e41f4b71Sopenharmony_ci
2146e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2147e41f4b71Sopenharmony_ci| -------- | -------- |
2148e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2149e41f4b71Sopenharmony_ci| str | 表示UTF8编码字符串的字符缓冲区。 | 
2150e41f4b71Sopenharmony_ci| length | 字符串的长度,以字节为单位。如果字符串以null结尾,则为JSVM_AUTO_LENGTH。 | 
2151e41f4b71Sopenharmony_ci| result | 代表JavaScript字符串的JSVM_Value。 | 
2152e41f4b71Sopenharmony_ci
2153e41f4b71Sopenharmony_ci**返回:**
2154e41f4b71Sopenharmony_ci
2155e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2156e41f4b71Sopenharmony_ci
2157e41f4b71Sopenharmony_ci
2158e41f4b71Sopenharmony_ci### OH_JSVM_CreateSymbol()
2159e41f4b71Sopenharmony_ci
2160e41f4b71Sopenharmony_ci```
2161e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateSymbol (JSVM_Env env, JSVM_Value description, JSVM_Value * result )
2162e41f4b71Sopenharmony_ci```
2163e41f4b71Sopenharmony_ci
2164e41f4b71Sopenharmony_ci**描述**
2165e41f4b71Sopenharmony_ci
2166e41f4b71Sopenharmony_ci从UTF8 编码的C字符串创建JavaScript symbol值。
2167e41f4b71Sopenharmony_ci
2168e41f4b71Sopenharmony_ci**起始版本:** 11
2169e41f4b71Sopenharmony_ci
2170e41f4b71Sopenharmony_ci**参数:**
2171e41f4b71Sopenharmony_ci
2172e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2173e41f4b71Sopenharmony_ci| -------- | -------- |
2174e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2175e41f4b71Sopenharmony_ci| description | 可选的JSVM_Value,它指的是要设置为符号描述的JavaScript string。 | 
2176e41f4b71Sopenharmony_ci| result | 代表JavaScript symbol的JSVM_Value。 | 
2177e41f4b71Sopenharmony_ci
2178e41f4b71Sopenharmony_ci**返回:**
2179e41f4b71Sopenharmony_ci
2180e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2181e41f4b71Sopenharmony_ci
2182e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
2183e41f4b71Sopenharmony_ci
2184e41f4b71Sopenharmony_ci
2185e41f4b71Sopenharmony_ci### OH_JSVM_CreateSyntaxError()
2186e41f4b71Sopenharmony_ci
2187e41f4b71Sopenharmony_ci```
2188e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateSyntaxError (JSVM_Env env, JSVM_Value code, JSVM_Value msg, JSVM_Value * result )
2189e41f4b71Sopenharmony_ci```
2190e41f4b71Sopenharmony_ci
2191e41f4b71Sopenharmony_ci**描述**
2192e41f4b71Sopenharmony_ci
2193e41f4b71Sopenharmony_ci返回带有所提供文本的JavaScript SyntaxError。
2194e41f4b71Sopenharmony_ci
2195e41f4b71Sopenharmony_ci**起始版本:** 11
2196e41f4b71Sopenharmony_ci
2197e41f4b71Sopenharmony_ci**参数:**
2198e41f4b71Sopenharmony_ci
2199e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2200e41f4b71Sopenharmony_ci| -------- | -------- |
2201e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2202e41f4b71Sopenharmony_ci| code | 可选的JSVM_Value,带有与错误关联的错误代码的字符串。 | 
2203e41f4b71Sopenharmony_ci| msg | 引用JavaScript string用作Error的消息。 | 
2204e41f4b71Sopenharmony_ci| result | 表示创建的错误。 | 
2205e41f4b71Sopenharmony_ci
2206e41f4b71Sopenharmony_ci**返回:**
2207e41f4b71Sopenharmony_ci
2208e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2209e41f4b71Sopenharmony_ci
2210e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
2211e41f4b71Sopenharmony_ci
2212e41f4b71Sopenharmony_ci\*
2213e41f4b71Sopenharmony_ci
2214e41f4b71Sopenharmony_ci
2215e41f4b71Sopenharmony_ci### OH_JSVM_CreateTypedarray()
2216e41f4b71Sopenharmony_ci
2217e41f4b71Sopenharmony_ci```
2218e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateTypedarray (JSVM_Env env, JSVM_TypedarrayType type, size_t length, JSVM_Value arraybuffer, size_t byteOffset, JSVM_Value * result )
2219e41f4b71Sopenharmony_ci```
2220e41f4b71Sopenharmony_ci
2221e41f4b71Sopenharmony_ci**描述**
2222e41f4b71Sopenharmony_ci
2223e41f4b71Sopenharmony_ci基于已有的ArrayBuffer对象,创建一个JavaScript TypedArray对象。TypedArray 对象在底层数据缓冲区上提供了一个类似数组的视图,其中每个元素都具有 相同的底层二进制标量数据类型。要求:(length\* 元素大小)+ byteOffset 小于等于传入的数组的大小(以字节为单位)。否则,将抛出范围错误(RangeError)。
2224e41f4b71Sopenharmony_ci
2225e41f4b71Sopenharmony_ci**起始版本:** 11
2226e41f4b71Sopenharmony_ci
2227e41f4b71Sopenharmony_ci**参数:**
2228e41f4b71Sopenharmony_ci
2229e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2230e41f4b71Sopenharmony_ci| -------- | -------- |
2231e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2232e41f4b71Sopenharmony_ci| type | TypedArray中元素的标量数据类型。 | 
2233e41f4b71Sopenharmony_ci| length | TypedArray中的元素个数。 | 
2234e41f4b71Sopenharmony_ci| arraybuffer | ArrayBuffer是类型化数组的基础。 | 
2235e41f4b71Sopenharmony_ci| byteOffset | ArrayBuffer中开始投影TypedArray的字节偏移量。 | 
2236e41f4b71Sopenharmony_ci| result | 表示JavaScript TypedArray的JSVM_Value。 | 
2237e41f4b71Sopenharmony_ci
2238e41f4b71Sopenharmony_ci**返回:**
2239e41f4b71Sopenharmony_ci
2240e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2241e41f4b71Sopenharmony_ci
2242e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
2243e41f4b71Sopenharmony_ci
2244e41f4b71Sopenharmony_ci
2245e41f4b71Sopenharmony_ci### OH_JSVM_CreateTypeError()
2246e41f4b71Sopenharmony_ci
2247e41f4b71Sopenharmony_ci```
2248e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateTypeError (JSVM_Env env, JSVM_Value code, JSVM_Value msg, JSVM_Value * result )
2249e41f4b71Sopenharmony_ci```
2250e41f4b71Sopenharmony_ci
2251e41f4b71Sopenharmony_ci**描述**
2252e41f4b71Sopenharmony_ci
2253e41f4b71Sopenharmony_ci返回带有所提供文本的JavaScript TypeError。
2254e41f4b71Sopenharmony_ci
2255e41f4b71Sopenharmony_ci**起始版本:** 11
2256e41f4b71Sopenharmony_ci
2257e41f4b71Sopenharmony_ci**参数:**
2258e41f4b71Sopenharmony_ci
2259e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2260e41f4b71Sopenharmony_ci| -------- | -------- |
2261e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2262e41f4b71Sopenharmony_ci| code | 可选的JSVM_Value,带有与错误关联的错误代码的字符串。 | 
2263e41f4b71Sopenharmony_ci| msg | 引用JavaScript string用作Error的消息。 | 
2264e41f4b71Sopenharmony_ci| result | 表示创建的错误。 | 
2265e41f4b71Sopenharmony_ci
2266e41f4b71Sopenharmony_ci**返回:**
2267e41f4b71Sopenharmony_ci
2268e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2269e41f4b71Sopenharmony_ci
2270e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
2271e41f4b71Sopenharmony_ci
2272e41f4b71Sopenharmony_ci
2273e41f4b71Sopenharmony_ci### OH_JSVM_CreateUint32()
2274e41f4b71Sopenharmony_ci
2275e41f4b71Sopenharmony_ci```
2276e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateUint32 (JSVM_Env env, uint32_t value, JSVM_Value * result )
2277e41f4b71Sopenharmony_ci```
2278e41f4b71Sopenharmony_ci
2279e41f4b71Sopenharmony_ci**描述**
2280e41f4b71Sopenharmony_ci
2281e41f4b71Sopenharmony_ci将C uint32_t类型的值转换为JavaScript number类型。
2282e41f4b71Sopenharmony_ci
2283e41f4b71Sopenharmony_ci**起始版本:** 11
2284e41f4b71Sopenharmony_ci
2285e41f4b71Sopenharmony_ci**参数:**
2286e41f4b71Sopenharmony_ci
2287e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2288e41f4b71Sopenharmony_ci| -------- | -------- |
2289e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2290e41f4b71Sopenharmony_ci| value | 要在JavaScript中表示的无符号整数值。 | 
2291e41f4b71Sopenharmony_ci| result | 表示JavaScript number类型的JSVM_Value。 | 
2292e41f4b71Sopenharmony_ci
2293e41f4b71Sopenharmony_ci**返回:**
2294e41f4b71Sopenharmony_ci
2295e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2296e41f4b71Sopenharmony_ci
2297e41f4b71Sopenharmony_ci
2298e41f4b71Sopenharmony_ci### OH_JSVM_CreateVM()
2299e41f4b71Sopenharmony_ci
2300e41f4b71Sopenharmony_ci```
2301e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateVM (const JSVM_CreateVMOptions * options, JSVM_VM * result )
2302e41f4b71Sopenharmony_ci```
2303e41f4b71Sopenharmony_ci
2304e41f4b71Sopenharmony_ci**描述**
2305e41f4b71Sopenharmony_ci
2306e41f4b71Sopenharmony_ci创建一个虚拟机实例。
2307e41f4b71Sopenharmony_ci
2308e41f4b71Sopenharmony_ci**起始版本:** 11
2309e41f4b71Sopenharmony_ci
2310e41f4b71Sopenharmony_ci**参数:**
2311e41f4b71Sopenharmony_ci
2312e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2313e41f4b71Sopenharmony_ci| -------- | -------- |
2314e41f4b71Sopenharmony_ci| options | 用于创建虚拟机实例的选项。 | 
2315e41f4b71Sopenharmony_ci| result | 新的虚拟机实例。 | 
2316e41f4b71Sopenharmony_ci
2317e41f4b71Sopenharmony_ci**返回:**
2318e41f4b71Sopenharmony_ci
2319e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2320e41f4b71Sopenharmony_ci
2321e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
2322e41f4b71Sopenharmony_ci
2323e41f4b71Sopenharmony_ci
2324e41f4b71Sopenharmony_ci### OH_JSVM_CreateWasmCache()
2325e41f4b71Sopenharmony_ci
2326e41f4b71Sopenharmony_ci```
2327e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_CreateWasmCache (JSVM_Env env, JSVM_Value wasmModule, const uint8_t ** data, size_t * length )
2328e41f4b71Sopenharmony_ci```
2329e41f4b71Sopenharmony_ci
2330e41f4b71Sopenharmony_ci**描述**
2331e41f4b71Sopenharmony_ci
2332e41f4b71Sopenharmony_ci为给定的 WebAssembly 模块生成缓存。
2333e41f4b71Sopenharmony_ci
2334e41f4b71Sopenharmony_ci**起始版本:** 12
2335e41f4b71Sopenharmony_ci
2336e41f4b71Sopenharmony_ci**参数:**
2337e41f4b71Sopenharmony_ci
2338e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2339e41f4b71Sopenharmony_ci| -------- | -------- |
2340e41f4b71Sopenharmony_ci| env | 调用 JSVM-API 的环境。 | 
2341e41f4b71Sopenharmony_ci| wasmModule | 编译好的 WebAssembly 模块。 | 
2342e41f4b71Sopenharmony_ci| data | 输出参数,表示生成的 WebAssembly 缓存。 | 
2343e41f4b71Sopenharmony_ci| length | 输出参数,表示生成的 WebAssembly 缓存的长度,单位:字节。 | 
2344e41f4b71Sopenharmony_ci
2345e41f4b71Sopenharmony_ci**返回:**
2346e41f4b71Sopenharmony_ci
2347e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2348e41f4b71Sopenharmony_ci
2349e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入了空指针参数。
2350e41f4b71Sopenharmony_ci
2351e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示缓存生成失败。
2352e41f4b71Sopenharmony_ci
2353e41f4b71Sopenharmony_ci
2354e41f4b71Sopenharmony_ci### OH_JSVM_DefineClass()
2355e41f4b71Sopenharmony_ci
2356e41f4b71Sopenharmony_ci```
2357e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_DefineClass (JSVM_Env env, const char * utf8name, size_t length, JSVM_Callback constructor, size_t propertyCount, const JSVM_PropertyDescriptor * properties, JSVM_Value * result )
2358e41f4b71Sopenharmony_ci```
2359e41f4b71Sopenharmony_ci
2360e41f4b71Sopenharmony_ci**描述**
2361e41f4b71Sopenharmony_ci
2362e41f4b71Sopenharmony_ci定义一个JavaScript类。
2363e41f4b71Sopenharmony_ci
2364e41f4b71Sopenharmony_ci**起始版本:** 11
2365e41f4b71Sopenharmony_ci
2366e41f4b71Sopenharmony_ci**参数:**
2367e41f4b71Sopenharmony_ci
2368e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2369e41f4b71Sopenharmony_ci| -------- | -------- |
2370e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2371e41f4b71Sopenharmony_ci| utf8name | JavaScript构造函数的名称,建议在包装C++类时使用C++类名。 | 
2372e41f4b71Sopenharmony_ci| length | utf8name的长度(以字节为单位)或JSVM_AUTO_LENGTH(如果以 null 结尾)。 | 
2373e41f4b71Sopenharmony_ci| constructor | 用于创建类的构造函数的回调函数。包装C++类时,此方法必须是符合JSVM_Callback。 callback签名的静态成员。不能使用C++类构造函数。详情请参考JSVM_Callback。 | 
2374e41f4b71Sopenharmony_ci| propertyCount | properties数组参数中的项数。 | 
2375e41f4b71Sopenharmony_ci| properties | 类的属性描述符,用于定义类的属性和方法。 | 
2376e41f4b71Sopenharmony_ci| result | 表示类的构造函数的JSVM_Value。 | 
2377e41f4b71Sopenharmony_ci
2378e41f4b71Sopenharmony_ci**返回:**
2379e41f4b71Sopenharmony_ci
2380e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2381e41f4b71Sopenharmony_ci
2382e41f4b71Sopenharmony_ci
2383e41f4b71Sopenharmony_ci### OH_JSVM_DefineClassWithPropertyHandler()
2384e41f4b71Sopenharmony_ci
2385e41f4b71Sopenharmony_ci```
2386e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_DefineClassWithPropertyHandler (JSVM_Env env, const char * utf8name, size_t length, JSVM_Callback constructor, size_t propertyCount, const JSVM_PropertyDescriptor * properties, JSVM_PropertyHandlerCfg propertyHandlerCfg, JSVM_Callback callAsFunctionCallback, JSVM_Value * result )
2387e41f4b71Sopenharmony_ci```
2388e41f4b71Sopenharmony_ci
2389e41f4b71Sopenharmony_ci**描述**
2390e41f4b71Sopenharmony_ci
2391e41f4b71Sopenharmony_ci定义一个具有给定类名、构造函数、属性和回调处理程序的JavaScript类属性操作包括getter、setter、deleter、enumerator等,并作为函数回调进行调用。
2392e41f4b71Sopenharmony_ci
2393e41f4b71Sopenharmony_ci**起始版本:** 12
2394e41f4b71Sopenharmony_ci
2395e41f4b71Sopenharmony_ci**参数:**
2396e41f4b71Sopenharmony_ci
2397e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2398e41f4b71Sopenharmony_ci| -------- | -------- |
2399e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2400e41f4b71Sopenharmony_ci| utf8name | JavaScript类构造函数的名称。 | 
2401e41f4b71Sopenharmony_ci| length | utf8name的长度(以字节为单位)或JSVM_AUTO_LENGTH(如果以 null 结尾)。 | 
2402e41f4b71Sopenharmony_ci| constructor | 用于创建类的构造函数的回调函数。此方法必须是JSVM_Callback类型。 constructor中callback回调需为静态成员。不能使用C++类构造函数。详情请参考JSVM_Callback。 | 
2403e41f4b71Sopenharmony_ci| propertyCount | properties数组参数中的项数。 | 
2404e41f4b71Sopenharmony_ci| properties | 描述静态数据和实例数据的属性描述符数组类上的属性、访问器和方法请参考JSVM_PropertyDescriptor。 | 
2405e41f4b71Sopenharmony_ci| propertyHandlerCfg | 访问实例对象属性触发相应的回调函数。 | 
2406e41f4b71Sopenharmony_ci| callAsFunctionCallback | 将实例对象作为函数调用将触发此回调。 | 
2407e41f4b71Sopenharmony_ci| result | 表示JavaScript类的构造函数的JSVM_Value。 | 
2408e41f4b71Sopenharmony_ci
2409e41f4b71Sopenharmony_ci**返回:**
2410e41f4b71Sopenharmony_ci
2411e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2412e41f4b71Sopenharmony_ci
2413e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
2414e41f4b71Sopenharmony_ci
2415e41f4b71Sopenharmony_ci
2416e41f4b71Sopenharmony_ci### OH_JSVM_DefineProperties()
2417e41f4b71Sopenharmony_ci
2418e41f4b71Sopenharmony_ci```
2419e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_DefineProperties (JSVM_Env env, JSVM_Value object, size_t propertyCount, const JSVM_PropertyDescriptor * properties )
2420e41f4b71Sopenharmony_ci```
2421e41f4b71Sopenharmony_ci
2422e41f4b71Sopenharmony_ci**描述**
2423e41f4b71Sopenharmony_ci
2424e41f4b71Sopenharmony_ci通过此方法可以在给定对象上高效定义多个属性, 这些属性使用属性描述符进行定义。通过一个属性描述符的数组, 此API将为对象依次设置数组中的属性。
2425e41f4b71Sopenharmony_ci
2426e41f4b71Sopenharmony_ci**起始版本:** 11
2427e41f4b71Sopenharmony_ci
2428e41f4b71Sopenharmony_ci**参数:**
2429e41f4b71Sopenharmony_ci
2430e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2431e41f4b71Sopenharmony_ci| -------- | -------- |
2432e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2433e41f4b71Sopenharmony_ci| object | 待进行属性检索的对象。 | 
2434e41f4b71Sopenharmony_ci| propertyCount | properties数组中的元素数。 | 
2435e41f4b71Sopenharmony_ci| properties | 属性描述符的数组。 | 
2436e41f4b71Sopenharmony_ci
2437e41f4b71Sopenharmony_ci**返回:**
2438e41f4b71Sopenharmony_ci
2439e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2440e41f4b71Sopenharmony_ci
2441e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
2442e41f4b71Sopenharmony_ci
2443e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
2444e41f4b71Sopenharmony_ci
2445e41f4b71Sopenharmony_ci
2446e41f4b71Sopenharmony_ci### OH_JSVM_DeleteElement()
2447e41f4b71Sopenharmony_ci
2448e41f4b71Sopenharmony_ci```
2449e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_DeleteElement (JSVM_Env env, JSVM_Value object, uint32_t index, bool * result )
2450e41f4b71Sopenharmony_ci```
2451e41f4b71Sopenharmony_ci
2452e41f4b71Sopenharmony_ci**描述**
2453e41f4b71Sopenharmony_ci
2454e41f4b71Sopenharmony_ci尝试从object中删除指定index处的元素。
2455e41f4b71Sopenharmony_ci
2456e41f4b71Sopenharmony_ci**起始版本:** 11
2457e41f4b71Sopenharmony_ci
2458e41f4b71Sopenharmony_ci**参数:**
2459e41f4b71Sopenharmony_ci
2460e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2461e41f4b71Sopenharmony_ci| -------- | -------- |
2462e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2463e41f4b71Sopenharmony_ci| object | 待查询的对象。 | 
2464e41f4b71Sopenharmony_ci| index | 要删除的属性的索引。 | 
2465e41f4b71Sopenharmony_ci| result | 表示元素删除是否成功。 | 
2466e41f4b71Sopenharmony_ci
2467e41f4b71Sopenharmony_ci**返回:**
2468e41f4b71Sopenharmony_ci
2469e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2470e41f4b71Sopenharmony_ci
2471e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
2472e41f4b71Sopenharmony_ci
2473e41f4b71Sopenharmony_ci
2474e41f4b71Sopenharmony_ci### OH_JSVM_DeleteProperty()
2475e41f4b71Sopenharmony_ci
2476e41f4b71Sopenharmony_ci```
2477e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_DeleteProperty (JSVM_Env env, JSVM_Value object, JSVM_Value key, bool * result )
2478e41f4b71Sopenharmony_ci```
2479e41f4b71Sopenharmony_ci
2480e41f4b71Sopenharmony_ci**描述**
2481e41f4b71Sopenharmony_ci
2482e41f4b71Sopenharmony_ci尝试从object中删除key自己的属性。
2483e41f4b71Sopenharmony_ci
2484e41f4b71Sopenharmony_ci**起始版本:** 11
2485e41f4b71Sopenharmony_ci
2486e41f4b71Sopenharmony_ci**参数:**
2487e41f4b71Sopenharmony_ci
2488e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2489e41f4b71Sopenharmony_ci| -------- | -------- |
2490e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2491e41f4b71Sopenharmony_ci| object | 待查询的对象。 | 
2492e41f4b71Sopenharmony_ci| key | 待删除的属性名。 | 
2493e41f4b71Sopenharmony_ci| result | 表示属性删除是否成功。result可以选择性地通过传递NULL来忽略。 | 
2494e41f4b71Sopenharmony_ci
2495e41f4b71Sopenharmony_ci**返回:**
2496e41f4b71Sopenharmony_ci
2497e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2498e41f4b71Sopenharmony_ci
2499e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
2500e41f4b71Sopenharmony_ci
2501e41f4b71Sopenharmony_ci
2502e41f4b71Sopenharmony_ci### OH_JSVM_DeleteReference()
2503e41f4b71Sopenharmony_ci
2504e41f4b71Sopenharmony_ci```
2505e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_DeleteReference (JSVM_Env env, JSVM_Ref ref )
2506e41f4b71Sopenharmony_ci```
2507e41f4b71Sopenharmony_ci
2508e41f4b71Sopenharmony_ci**描述**
2509e41f4b71Sopenharmony_ci
2510e41f4b71Sopenharmony_ci删除传入的引用。
2511e41f4b71Sopenharmony_ci
2512e41f4b71Sopenharmony_ci**起始版本:** 11
2513e41f4b71Sopenharmony_ci
2514e41f4b71Sopenharmony_ci**参数:**
2515e41f4b71Sopenharmony_ci
2516e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2517e41f4b71Sopenharmony_ci| -------- | -------- |
2518e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2519e41f4b71Sopenharmony_ci| ref | 需删除的JSVM_Ref。 | 
2520e41f4b71Sopenharmony_ci
2521e41f4b71Sopenharmony_ci**返回:**
2522e41f4b71Sopenharmony_ci
2523e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2524e41f4b71Sopenharmony_ci
2525e41f4b71Sopenharmony_ci
2526e41f4b71Sopenharmony_ci### OH_JSVM_DestroyEnv()
2527e41f4b71Sopenharmony_ci
2528e41f4b71Sopenharmony_ci```
2529e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_DestroyEnv (JSVM_Env env)
2530e41f4b71Sopenharmony_ci```
2531e41f4b71Sopenharmony_ci
2532e41f4b71Sopenharmony_ci**描述**
2533e41f4b71Sopenharmony_ci
2534e41f4b71Sopenharmony_ci销毁环境。
2535e41f4b71Sopenharmony_ci
2536e41f4b71Sopenharmony_ci**起始版本:** 11
2537e41f4b71Sopenharmony_ci
2538e41f4b71Sopenharmony_ci**参数:**
2539e41f4b71Sopenharmony_ci
2540e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2541e41f4b71Sopenharmony_ci| -------- | -------- |
2542e41f4b71Sopenharmony_ci| env | 待销毁的环境。 | 
2543e41f4b71Sopenharmony_ci
2544e41f4b71Sopenharmony_ci**返回:**
2545e41f4b71Sopenharmony_ci
2546e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2547e41f4b71Sopenharmony_ci
2548e41f4b71Sopenharmony_ci
2549e41f4b71Sopenharmony_ci### OH_JSVM_DestroyVM()
2550e41f4b71Sopenharmony_ci
2551e41f4b71Sopenharmony_ci```
2552e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_DestroyVM (JSVM_VM vm)
2553e41f4b71Sopenharmony_ci```
2554e41f4b71Sopenharmony_ci
2555e41f4b71Sopenharmony_ci**描述**
2556e41f4b71Sopenharmony_ci
2557e41f4b71Sopenharmony_ci销毁一个虚拟机实例。
2558e41f4b71Sopenharmony_ci
2559e41f4b71Sopenharmony_ci**起始版本:** 11
2560e41f4b71Sopenharmony_ci
2561e41f4b71Sopenharmony_ci**参数:**
2562e41f4b71Sopenharmony_ci
2563e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2564e41f4b71Sopenharmony_ci| -------- | -------- |
2565e41f4b71Sopenharmony_ci| vm | 待销毁的虚拟机实例。 | 
2566e41f4b71Sopenharmony_ci
2567e41f4b71Sopenharmony_ci**返回:**
2568e41f4b71Sopenharmony_ci
2569e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2570e41f4b71Sopenharmony_ci
2571e41f4b71Sopenharmony_ci
2572e41f4b71Sopenharmony_ci### OH_JSVM_DetachArraybuffer()
2573e41f4b71Sopenharmony_ci
2574e41f4b71Sopenharmony_ci```
2575e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_DetachArraybuffer (JSVM_Env env, JSVM_Value arraybuffer )
2576e41f4b71Sopenharmony_ci```
2577e41f4b71Sopenharmony_ci
2578e41f4b71Sopenharmony_ci**描述**
2579e41f4b71Sopenharmony_ci
2580e41f4b71Sopenharmony_ci提供类似于调用ArrayBuffer detach操作的行为。
2581e41f4b71Sopenharmony_ci
2582e41f4b71Sopenharmony_ci**起始版本:** 11
2583e41f4b71Sopenharmony_ci
2584e41f4b71Sopenharmony_ci**参数:**
2585e41f4b71Sopenharmony_ci
2586e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2587e41f4b71Sopenharmony_ci| -------- | -------- |
2588e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2589e41f4b71Sopenharmony_ci| arraybuffer | 待分离的JavaScript ArrayBuffer。 | 
2590e41f4b71Sopenharmony_ci
2591e41f4b71Sopenharmony_ci**返回:**
2592e41f4b71Sopenharmony_ci
2593e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 如果JSVM_OK 表示执行成功。
2594e41f4b71Sopenharmony_ci
2595e41f4b71Sopenharmony_ciJSVM_DETACHABLE_ARRAYBUFFER_EXPECTED 表示传入的参数不是可分析的ArrayBuffer。
2596e41f4b71Sopenharmony_ci
2597e41f4b71Sopenharmony_ci
2598e41f4b71Sopenharmony_ci### OH_JSVM_Equals()
2599e41f4b71Sopenharmony_ci
2600e41f4b71Sopenharmony_ci```
2601e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_Equals (JSVM_Env env, JSVM_Value lhs, JSVM_Value rhs, bool * result )
2602e41f4b71Sopenharmony_ci```
2603e41f4b71Sopenharmony_ci
2604e41f4b71Sopenharmony_ci**描述**
2605e41f4b71Sopenharmony_ci
2606e41f4b71Sopenharmony_ci提供类似调用宽松相等算法的行为。 无论JavaScript值类型如何,只要值相等,就返回true。
2607e41f4b71Sopenharmony_ci
2608e41f4b71Sopenharmony_ci**起始版本:** 12
2609e41f4b71Sopenharmony_ci
2610e41f4b71Sopenharmony_ci**参数:**
2611e41f4b71Sopenharmony_ci
2612e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2613e41f4b71Sopenharmony_ci| -------- | -------- |
2614e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2615e41f4b71Sopenharmony_ci| lhs | 待检查的JavaScript值。 | 
2616e41f4b71Sopenharmony_ci| rhs | 要检查的JavaScript值。 | 
2617e41f4b71Sopenharmony_ci| result | 表示两个JSVM_Value对象是否相等。 | 
2618e41f4b71Sopenharmony_ci
2619e41f4b71Sopenharmony_ci**返回:**
2620e41f4b71Sopenharmony_ci
2621e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2622e41f4b71Sopenharmony_ci
2623e41f4b71Sopenharmony_ci
2624e41f4b71Sopenharmony_ci### OH_JSVM_EscapeHandle()
2625e41f4b71Sopenharmony_ci
2626e41f4b71Sopenharmony_ci```
2627e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_EscapeHandle (JSVM_Env env, JSVM_EscapableHandleScope scope, JSVM_Value escapee, JSVM_Value * result )
2628e41f4b71Sopenharmony_ci```
2629e41f4b71Sopenharmony_ci
2630e41f4b71Sopenharmony_ci**描述**
2631e41f4b71Sopenharmony_ci
2632e41f4b71Sopenharmony_ci提升JavaScript对象的句柄,使其在外部作用域的生命周期内有效。 每个作用域只能调用一次。如果多次调用,将返回错误。
2633e41f4b71Sopenharmony_ci
2634e41f4b71Sopenharmony_ci**起始版本:** 11
2635e41f4b71Sopenharmony_ci
2636e41f4b71Sopenharmony_ci**参数:**
2637e41f4b71Sopenharmony_ci
2638e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2639e41f4b71Sopenharmony_ci| -------- | -------- |
2640e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2641e41f4b71Sopenharmony_ci| scope | 表示当前的作用域。 | 
2642e41f4b71Sopenharmony_ci| escapee | 表示要提升的JavaScript Object。 | 
2643e41f4b71Sopenharmony_ci| result | 被提升的Object在外部作用域中的句柄。 | 
2644e41f4b71Sopenharmony_ci
2645e41f4b71Sopenharmony_ci**返回:**
2646e41f4b71Sopenharmony_ci
2647e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2648e41f4b71Sopenharmony_ci
2649e41f4b71Sopenharmony_ciJSVM_ESCAPE_CALLED_TWICE 表示scope对象已被关闭。
2650e41f4b71Sopenharmony_ci
2651e41f4b71Sopenharmony_ci
2652e41f4b71Sopenharmony_ci### OH_JSVM_FreeArrayBufferBackingStoreData()
2653e41f4b71Sopenharmony_ci
2654e41f4b71Sopenharmony_ci```
2655e41f4b71Sopenharmony_ciJSVM_Status JSVM_CDECL OH_JSVM_FreeArrayBufferBackingStoreData (void * data)
2656e41f4b71Sopenharmony_ci```
2657e41f4b71Sopenharmony_ci
2658e41f4b71Sopenharmony_ci**描述**
2659e41f4b71Sopenharmony_ci
2660e41f4b71Sopenharmony_ci释放由 OH_JSVM_AllocateArrayBufferBackingStoreData 申请的 BackingStore 内存。
2661e41f4b71Sopenharmony_ci
2662e41f4b71Sopenharmony_ci**起始版本:** 12
2663e41f4b71Sopenharmony_ci
2664e41f4b71Sopenharmony_ci**参数:**
2665e41f4b71Sopenharmony_ci
2666e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2667e41f4b71Sopenharmony_ci| -------- | -------- |
2668e41f4b71Sopenharmony_ci| data | 申请得到的 BackingStore 内存。 | 
2669e41f4b71Sopenharmony_ci
2670e41f4b71Sopenharmony_ci**返回:**
2671e41f4b71Sopenharmony_ci
2672e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2673e41f4b71Sopenharmony_ci
2674e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的 data 是空指针。
2675e41f4b71Sopenharmony_ci
2676e41f4b71Sopenharmony_ci
2677e41f4b71Sopenharmony_ci### OH_JSVM_GetAllPropertyNames()
2678e41f4b71Sopenharmony_ci
2679e41f4b71Sopenharmony_ci```
2680e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetAllPropertyNames (JSVM_Env env, JSVM_Value object, JSVM_KeyCollectionMode keyMode, JSVM_KeyFilter keyFilter, JSVM_KeyConversion keyConversion, JSVM_Value * result )
2681e41f4b71Sopenharmony_ci```
2682e41f4b71Sopenharmony_ci
2683e41f4b71Sopenharmony_ci**描述**
2684e41f4b71Sopenharmony_ci
2685e41f4b71Sopenharmony_ci返回一个数组,其中包含此对象的可用属性的名称。
2686e41f4b71Sopenharmony_ci
2687e41f4b71Sopenharmony_ci**起始版本:** 11
2688e41f4b71Sopenharmony_ci
2689e41f4b71Sopenharmony_ci**参数:**
2690e41f4b71Sopenharmony_ci
2691e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2692e41f4b71Sopenharmony_ci| -------- | -------- |
2693e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2694e41f4b71Sopenharmony_ci| object | 从中检索属性的对象。 | 
2695e41f4b71Sopenharmony_ci| keyMode | 是否也检索原型属性。 | 
2696e41f4b71Sopenharmony_ci| keyFilter | 要检索哪些属性(可枚举/可读/可写)。 | 
2697e41f4b71Sopenharmony_ci| keyConversion | 表示是否将编号的属性键转换为字符串。 | 
2698e41f4b71Sopenharmony_ci| result | 表示JavaScript值的数组,这些值表示对象的属性名称。 可以使用OH_JSVM_GetArrayLength和OH_JSVM_GetElement对结果进行迭代。 | 
2699e41f4b71Sopenharmony_ci
2700e41f4b71Sopenharmony_ci**返回:**
2701e41f4b71Sopenharmony_ci
2702e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2703e41f4b71Sopenharmony_ci
2704e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
2705e41f4b71Sopenharmony_ci
2706e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
2707e41f4b71Sopenharmony_ci
2708e41f4b71Sopenharmony_ci
2709e41f4b71Sopenharmony_ci### OH_JSVM_GetAndClearLastException()
2710e41f4b71Sopenharmony_ci
2711e41f4b71Sopenharmony_ci```
2712e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetAndClearLastException (JSVM_Env env, JSVM_Value * result )
2713e41f4b71Sopenharmony_ci```
2714e41f4b71Sopenharmony_ci
2715e41f4b71Sopenharmony_ci**描述**
2716e41f4b71Sopenharmony_ci
2717e41f4b71Sopenharmony_ci获取并清除上一次异常。如果出现挂起,则返回JavaScript异常,否则返回NULL。
2718e41f4b71Sopenharmony_ci
2719e41f4b71Sopenharmony_ci**起始版本:** 11
2720e41f4b71Sopenharmony_ci
2721e41f4b71Sopenharmony_ci**参数:**
2722e41f4b71Sopenharmony_ci
2723e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2724e41f4b71Sopenharmony_ci| -------- | -------- |
2725e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2726e41f4b71Sopenharmony_ci| result | 如果出现挂起则返回异常,否则为NULL。 | 
2727e41f4b71Sopenharmony_ci
2728e41f4b71Sopenharmony_ci**返回:**
2729e41f4b71Sopenharmony_ci
2730e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2731e41f4b71Sopenharmony_ci
2732e41f4b71Sopenharmony_ci
2733e41f4b71Sopenharmony_ci### OH_JSVM_GetArraybufferInfo()
2734e41f4b71Sopenharmony_ci
2735e41f4b71Sopenharmony_ci```
2736e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetArraybufferInfo (JSVM_Env env, JSVM_Value arraybuffer, void ** data, size_t * byteLength )
2737e41f4b71Sopenharmony_ci```
2738e41f4b71Sopenharmony_ci
2739e41f4b71Sopenharmony_ci**描述**
2740e41f4b71Sopenharmony_ci
2741e41f4b71Sopenharmony_ci用于检索ArrayBuffer的底层数据缓冲区及其长度。
2742e41f4b71Sopenharmony_ci
2743e41f4b71Sopenharmony_ci**起始版本:** 11
2744e41f4b71Sopenharmony_ci
2745e41f4b71Sopenharmony_ci**参数:**
2746e41f4b71Sopenharmony_ci
2747e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2748e41f4b71Sopenharmony_ci| -------- | -------- |
2749e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2750e41f4b71Sopenharmony_ci| arraybuffer | 代表被查询的ArrayBuffer。 | 
2751e41f4b71Sopenharmony_ci| data | ArrayBuffer的底层数据缓冲区。如果byte_length为0,则该值可能为NULL 或任何其他指针值。 | 
2752e41f4b71Sopenharmony_ci| byteLength | 底层数据缓冲区的字节长度。 | 
2753e41f4b71Sopenharmony_ci
2754e41f4b71Sopenharmony_ci**返回:**
2755e41f4b71Sopenharmony_ci
2756e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2757e41f4b71Sopenharmony_ci
2758e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
2759e41f4b71Sopenharmony_ci
2760e41f4b71Sopenharmony_ci
2761e41f4b71Sopenharmony_ci### OH_JSVM_GetArrayLength()
2762e41f4b71Sopenharmony_ci
2763e41f4b71Sopenharmony_ci```
2764e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetArrayLength (JSVM_Env env, JSVM_Value value, uint32_t * result )
2765e41f4b71Sopenharmony_ci```
2766e41f4b71Sopenharmony_ci
2767e41f4b71Sopenharmony_ci**描述**
2768e41f4b71Sopenharmony_ci
2769e41f4b71Sopenharmony_ci返回数组的长度。
2770e41f4b71Sopenharmony_ci
2771e41f4b71Sopenharmony_ci**起始版本:** 11
2772e41f4b71Sopenharmony_ci
2773e41f4b71Sopenharmony_ci**参数:**
2774e41f4b71Sopenharmony_ci
2775e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2776e41f4b71Sopenharmony_ci| -------- | -------- |
2777e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2778e41f4b71Sopenharmony_ci| value | 代表查询长度的JavaScript Array。 | 
2779e41f4b71Sopenharmony_ci| result | uint32代表数组的长度。 | 
2780e41f4b71Sopenharmony_ci
2781e41f4b71Sopenharmony_ci**返回:**
2782e41f4b71Sopenharmony_ci
2783e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2784e41f4b71Sopenharmony_ci
2785e41f4b71Sopenharmony_ciJSVM_ARRAY_EXPECTED 表示传入的参数不是Array类型。
2786e41f4b71Sopenharmony_ci
2787e41f4b71Sopenharmony_ci
2788e41f4b71Sopenharmony_ci### OH_JSVM_GetBoolean()
2789e41f4b71Sopenharmony_ci
2790e41f4b71Sopenharmony_ci```
2791e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetBoolean (JSVM_Env env, bool value, JSVM_Value * result )
2792e41f4b71Sopenharmony_ci```
2793e41f4b71Sopenharmony_ci
2794e41f4b71Sopenharmony_ci**描述**
2795e41f4b71Sopenharmony_ci
2796e41f4b71Sopenharmony_ci返回用于表示给定布尔值的JavaScript单例对象。
2797e41f4b71Sopenharmony_ci
2798e41f4b71Sopenharmony_ci**起始版本:** 11
2799e41f4b71Sopenharmony_ci
2800e41f4b71Sopenharmony_ci**参数:**
2801e41f4b71Sopenharmony_ci
2802e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2803e41f4b71Sopenharmony_ci| -------- | -------- |
2804e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2805e41f4b71Sopenharmony_ci| value | 要检索的布尔值。 | 
2806e41f4b71Sopenharmony_ci| result | 表示待检索的JavaScript Boolean单例。 | 
2807e41f4b71Sopenharmony_ci
2808e41f4b71Sopenharmony_ci**返回:**
2809e41f4b71Sopenharmony_ci
2810e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2811e41f4b71Sopenharmony_ci
2812e41f4b71Sopenharmony_ci
2813e41f4b71Sopenharmony_ci### OH_JSVM_GetCbInfo()
2814e41f4b71Sopenharmony_ci
2815e41f4b71Sopenharmony_ci```
2816e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetCbInfo (JSVM_Env env, JSVM_CallbackInfo cbinfo, size_t * argc, JSVM_Value * argv, JSVM_Value * thisArg, void ** data )
2817e41f4b71Sopenharmony_ci```
2818e41f4b71Sopenharmony_ci
2819e41f4b71Sopenharmony_ci**描述**
2820e41f4b71Sopenharmony_ci
2821e41f4b71Sopenharmony_ci此方法在回调函数中用于检索有关调用的详细信息, 例如来自给定回调信息的参数和this指针。
2822e41f4b71Sopenharmony_ci
2823e41f4b71Sopenharmony_ci**起始版本:** 11
2824e41f4b71Sopenharmony_ci
2825e41f4b71Sopenharmony_ci**参数:**
2826e41f4b71Sopenharmony_ci
2827e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2828e41f4b71Sopenharmony_ci| -------- | -------- |
2829e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2830e41f4b71Sopenharmony_ci| cbinfo | 传入回调函数的回调信息。 | 
2831e41f4b71Sopenharmony_ci| argc | 指定所提供的argv数组的长度并接收参数的实际数量, 可以通过传递NULL来选择性地忽略。 | 
2832e41f4b71Sopenharmony_ci| argv | JSVM_Value的C数组,用于存储复制的参数。如果参数数量超过提供的数量, 则只复制请求数量的参数。如果提供的参数比声明的少,则argv的其余部分将由代表undefined 的JSVM_Value值填充。可以通过传递NULL来忽略argv。 | 
2833e41f4b71Sopenharmony_ci| thisArg | 接收调用的JavaScript this参数。thisArg可以通过传递NULL来进行忽略。 | 
2834e41f4b71Sopenharmony_ci| data | 接收回调的数据指针。data可以通过传递NULL来进行忽略。 | 
2835e41f4b71Sopenharmony_ci
2836e41f4b71Sopenharmony_ci**返回:**
2837e41f4b71Sopenharmony_ci
2838e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2839e41f4b71Sopenharmony_ci
2840e41f4b71Sopenharmony_ci
2841e41f4b71Sopenharmony_ci### OH_JSVM_GetDataviewInfo()
2842e41f4b71Sopenharmony_ci
2843e41f4b71Sopenharmony_ci```
2844e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetDataviewInfo (JSVM_Env env, JSVM_Value dataview, size_t * bytelength, void ** data, JSVM_Value * arraybuffer, size_t * byteOffset )
2845e41f4b71Sopenharmony_ci```
2846e41f4b71Sopenharmony_ci
2847e41f4b71Sopenharmony_ci**描述**
2848e41f4b71Sopenharmony_ci
2849e41f4b71Sopenharmony_ci返回DataView的各种属性。 如果不需要某一属性,则任何出参都可以设置为NULL。
2850e41f4b71Sopenharmony_ci
2851e41f4b71Sopenharmony_ci**起始版本:** 11
2852e41f4b71Sopenharmony_ci
2853e41f4b71Sopenharmony_ci**参数:**
2854e41f4b71Sopenharmony_ci
2855e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2856e41f4b71Sopenharmony_ci| -------- | -------- |
2857e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2858e41f4b71Sopenharmony_ci| dataview | 表示要查询其属性的DataView。 | 
2859e41f4b71Sopenharmony_ci| bytelength | DataView中的字节个数。 | 
2860e41f4b71Sopenharmony_ci| data | DataView下的数据缓冲区。如果bytelength是0, 则这可能是NULL或任何其他指针值。 | 
2861e41f4b71Sopenharmony_ci| arraybuffer | ArrayBuffer是DataView的基础。 | 
2862e41f4b71Sopenharmony_ci| byteOffset | 开始投影DataView的数据缓冲区中的字节偏移量。 | 
2863e41f4b71Sopenharmony_ci
2864e41f4b71Sopenharmony_ci**返回:**
2865e41f4b71Sopenharmony_ci
2866e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2867e41f4b71Sopenharmony_ci
2868e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
2869e41f4b71Sopenharmony_ci
2870e41f4b71Sopenharmony_ci
2871e41f4b71Sopenharmony_ci### OH_JSVM_GetDateValue()
2872e41f4b71Sopenharmony_ci
2873e41f4b71Sopenharmony_ci```
2874e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetDateValue (JSVM_Env env, JSVM_Value value, double * result )
2875e41f4b71Sopenharmony_ci```
2876e41f4b71Sopenharmony_ci
2877e41f4b71Sopenharmony_ci**描述**
2878e41f4b71Sopenharmony_ci
2879e41f4b71Sopenharmony_ci返回给定JavaScript Date的时间值的C双精度基础类型。如果调用成功,返回JSVM_OK。 如果传入一个非JavaScript Date类型的JSVM_Value,返回JSVM_DATA_EXPECTED。
2880e41f4b71Sopenharmony_ci
2881e41f4b71Sopenharmony_ci**起始版本:** 11
2882e41f4b71Sopenharmony_ci
2883e41f4b71Sopenharmony_ci**参数:**
2884e41f4b71Sopenharmony_ci
2885e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2886e41f4b71Sopenharmony_ci| -------- | -------- |
2887e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2888e41f4b71Sopenharmony_ci| value | 代表一个JavaScript Date。 | 
2889e41f4b71Sopenharmony_ci| result | 作为double的时间值表示为自1970年1月1日UTC午夜以来的毫秒数。 | 
2890e41f4b71Sopenharmony_ci
2891e41f4b71Sopenharmony_ci**返回:**
2892e41f4b71Sopenharmony_ci
2893e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2894e41f4b71Sopenharmony_ci
2895e41f4b71Sopenharmony_ciJSVM_DATE_EXPECTED 表示传入参数不是Date类型。
2896e41f4b71Sopenharmony_ci
2897e41f4b71Sopenharmony_ci
2898e41f4b71Sopenharmony_ci### OH_JSVM_GetElement()
2899e41f4b71Sopenharmony_ci
2900e41f4b71Sopenharmony_ci```
2901e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetElement (JSVM_Env env, JSVM_Value object, uint32_t index, JSVM_Value * result )
2902e41f4b71Sopenharmony_ci```
2903e41f4b71Sopenharmony_ci
2904e41f4b71Sopenharmony_ci**描述**
2905e41f4b71Sopenharmony_ci
2906e41f4b71Sopenharmony_ci获取请求索引处的元素。
2907e41f4b71Sopenharmony_ci
2908e41f4b71Sopenharmony_ci**起始版本:** 11
2909e41f4b71Sopenharmony_ci
2910e41f4b71Sopenharmony_ci**参数:**
2911e41f4b71Sopenharmony_ci
2912e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2913e41f4b71Sopenharmony_ci| -------- | -------- |
2914e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2915e41f4b71Sopenharmony_ci| object | 待进行属性检索的对象。 | 
2916e41f4b71Sopenharmony_ci| index | 要获取的属性的索引。 | 
2917e41f4b71Sopenharmony_ci| result | 属性值。 | 
2918e41f4b71Sopenharmony_ci
2919e41f4b71Sopenharmony_ci**返回:**
2920e41f4b71Sopenharmony_ci
2921e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2922e41f4b71Sopenharmony_ci
2923e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
2924e41f4b71Sopenharmony_ci
2925e41f4b71Sopenharmony_ci
2926e41f4b71Sopenharmony_ci### OH_JSVM_GetGlobal()
2927e41f4b71Sopenharmony_ci
2928e41f4b71Sopenharmony_ci```
2929e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetGlobal (JSVM_Env env, JSVM_Value * result )
2930e41f4b71Sopenharmony_ci```
2931e41f4b71Sopenharmony_ci
2932e41f4b71Sopenharmony_ci**描述**
2933e41f4b71Sopenharmony_ci
2934e41f4b71Sopenharmony_ci返回global对象。
2935e41f4b71Sopenharmony_ci
2936e41f4b71Sopenharmony_ci**起始版本:** 11
2937e41f4b71Sopenharmony_ci
2938e41f4b71Sopenharmony_ci**参数:**
2939e41f4b71Sopenharmony_ci
2940e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2941e41f4b71Sopenharmony_ci| -------- | -------- |
2942e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2943e41f4b71Sopenharmony_ci| result | 代表JavaScript global对象。 | 
2944e41f4b71Sopenharmony_ci
2945e41f4b71Sopenharmony_ci**返回:**
2946e41f4b71Sopenharmony_ci
2947e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2948e41f4b71Sopenharmony_ci
2949e41f4b71Sopenharmony_ci
2950e41f4b71Sopenharmony_ci### OH_JSVM_GetHeapStatistics()
2951e41f4b71Sopenharmony_ci
2952e41f4b71Sopenharmony_ci```
2953e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetHeapStatistics (JSVM_VM vm, JSVM_HeapStatistics * result )
2954e41f4b71Sopenharmony_ci```
2955e41f4b71Sopenharmony_ci
2956e41f4b71Sopenharmony_ci**描述**
2957e41f4b71Sopenharmony_ci
2958e41f4b71Sopenharmony_ci返回一组虚拟机堆的统计数据。
2959e41f4b71Sopenharmony_ci
2960e41f4b71Sopenharmony_ci**起始版本:** 12
2961e41f4b71Sopenharmony_ci
2962e41f4b71Sopenharmony_ci**参数:**
2963e41f4b71Sopenharmony_ci
2964e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2965e41f4b71Sopenharmony_ci| -------- | -------- |
2966e41f4b71Sopenharmony_ci| vm | 返回堆统计信息的虚拟机。 | 
2967e41f4b71Sopenharmony_ci| result | 堆统计数据。 | 
2968e41f4b71Sopenharmony_ci
2969e41f4b71Sopenharmony_ci**返回:**
2970e41f4b71Sopenharmony_ci
2971e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2972e41f4b71Sopenharmony_ci
2973e41f4b71Sopenharmony_ci
2974e41f4b71Sopenharmony_ci### OH_JSVM_GetInstanceData()
2975e41f4b71Sopenharmony_ci
2976e41f4b71Sopenharmony_ci```
2977e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetInstanceData (JSVM_Env env, void ** data )
2978e41f4b71Sopenharmony_ci```
2979e41f4b71Sopenharmony_ci
2980e41f4b71Sopenharmony_ci**描述**
2981e41f4b71Sopenharmony_ci
2982e41f4b71Sopenharmony_ci检索通过OH_JSVM_SetInstanceData()与当前运行的JSVM环境相关联的数据。 如果未设置任何关联数据,该函数调用将成功,且data设置为NULL。
2983e41f4b71Sopenharmony_ci
2984e41f4b71Sopenharmony_ci**起始版本:** 11
2985e41f4b71Sopenharmony_ci
2986e41f4b71Sopenharmony_ci**参数:**
2987e41f4b71Sopenharmony_ci
2988e41f4b71Sopenharmony_ci| 名称 | 描述 | 
2989e41f4b71Sopenharmony_ci| -------- | -------- |
2990e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
2991e41f4b71Sopenharmony_ci| data | 之前通过调用OH_JSVM_SetInstanceData()与当前运行的JSVM环境关联的数据项。 | 
2992e41f4b71Sopenharmony_ci
2993e41f4b71Sopenharmony_ci**返回:**
2994e41f4b71Sopenharmony_ci
2995e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
2996e41f4b71Sopenharmony_ci
2997e41f4b71Sopenharmony_ci
2998e41f4b71Sopenharmony_ci### OH_JSVM_GetLastErrorInfo()
2999e41f4b71Sopenharmony_ci
3000e41f4b71Sopenharmony_ci```
3001e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetLastErrorInfo (JSVM_Env env, const JSVM_ExtendedErrorInfo ** result )
3002e41f4b71Sopenharmony_ci```
3003e41f4b71Sopenharmony_ci
3004e41f4b71Sopenharmony_ci**描述**
3005e41f4b71Sopenharmony_ci
3006e41f4b71Sopenharmony_ci检索JSVM_ExtendedErrorInfo结构,其中包含有关发生的最后一个错误的信息。 返回的JSVM_ExtendedErrorInfo的内容仅在对同一env调用JSVM-API函数之前有效。 这包括对OH_JSVM_IsExceptionPending的调用,因此可能经常需要复制信息以便以后使用。 error_message中返回的指针指向一个静态定义的字符串,因此如果你在调用另一个JSVM-API 函数之前将它从error_message字段(将被覆盖)中复制出来,则可以安全地使用该指针。
3007e41f4b71Sopenharmony_ci
3008e41f4b71Sopenharmony_ci**起始版本:** 11
3009e41f4b71Sopenharmony_ci
3010e41f4b71Sopenharmony_ci**参数:**
3011e41f4b71Sopenharmony_ci
3012e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3013e41f4b71Sopenharmony_ci| -------- | -------- |
3014e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3015e41f4b71Sopenharmony_ci| result | 包含有关错误的更多信息的JSVM_ExtendedErrorInfo结构。 | 
3016e41f4b71Sopenharmony_ci
3017e41f4b71Sopenharmony_ci**返回:**
3018e41f4b71Sopenharmony_ci
3019e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3020e41f4b71Sopenharmony_ci
3021e41f4b71Sopenharmony_ci
3022e41f4b71Sopenharmony_ci### OH_JSVM_GetNamedProperty()
3023e41f4b71Sopenharmony_ci
3024e41f4b71Sopenharmony_ci```
3025e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetNamedProperty (JSVM_Env env, JSVM_Value object, const char * utf8name, JSVM_Value * result )
3026e41f4b71Sopenharmony_ci```
3027e41f4b71Sopenharmony_ci
3028e41f4b71Sopenharmony_ci**描述**
3029e41f4b71Sopenharmony_ci
3030e41f4b71Sopenharmony_ci此方法等效于调用OH_JSVM_GetProperty, 其中,通过utf8Name传入的字符串用于创建JSVM_Value。
3031e41f4b71Sopenharmony_ci
3032e41f4b71Sopenharmony_ci**起始版本:** 11
3033e41f4b71Sopenharmony_ci
3034e41f4b71Sopenharmony_ci**参数:**
3035e41f4b71Sopenharmony_ci
3036e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3037e41f4b71Sopenharmony_ci| -------- | -------- |
3038e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3039e41f4b71Sopenharmony_ci| object | 从中检索属性的对象。 | 
3040e41f4b71Sopenharmony_ci| utf8Name | 要获取的属性名。 | 
3041e41f4b71Sopenharmony_ci| result | 属性值。 | 
3042e41f4b71Sopenharmony_ci
3043e41f4b71Sopenharmony_ci**返回:**
3044e41f4b71Sopenharmony_ci
3045e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3046e41f4b71Sopenharmony_ci
3047e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
3048e41f4b71Sopenharmony_ci
3049e41f4b71Sopenharmony_ci
3050e41f4b71Sopenharmony_ci### OH_JSVM_GetNewTarget()
3051e41f4b71Sopenharmony_ci
3052e41f4b71Sopenharmony_ci```
3053e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetNewTarget (JSVM_Env env, JSVM_CallbackInfo cbinfo, JSVM_Value * result )
3054e41f4b71Sopenharmony_ci```
3055e41f4b71Sopenharmony_ci
3056e41f4b71Sopenharmony_ci**描述**
3057e41f4b71Sopenharmony_ci
3058e41f4b71Sopenharmony_ci返回构造函数调用的new target。 如果当前回调不是构造函数调用,结果为NULL。
3059e41f4b71Sopenharmony_ci
3060e41f4b71Sopenharmony_ci**起始版本:** 11
3061e41f4b71Sopenharmony_ci
3062e41f4b71Sopenharmony_ci**参数:**
3063e41f4b71Sopenharmony_ci
3064e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3065e41f4b71Sopenharmony_ci| -------- | -------- |
3066e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3067e41f4b71Sopenharmony_ci| cbinfo | 传递给回调函数的回调信息。 | 
3068e41f4b71Sopenharmony_ci| result | 构造函数调用的new target。 | 
3069e41f4b71Sopenharmony_ci
3070e41f4b71Sopenharmony_ci**返回:**
3071e41f4b71Sopenharmony_ci
3072e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3073e41f4b71Sopenharmony_ci
3074e41f4b71Sopenharmony_ci
3075e41f4b71Sopenharmony_ci### OH_JSVM_GetNull()
3076e41f4b71Sopenharmony_ci
3077e41f4b71Sopenharmony_ci```
3078e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetNull (JSVM_Env env, JSVM_Value * result )
3079e41f4b71Sopenharmony_ci```
3080e41f4b71Sopenharmony_ci
3081e41f4b71Sopenharmony_ci**描述**
3082e41f4b71Sopenharmony_ci
3083e41f4b71Sopenharmony_ci返回null对象。
3084e41f4b71Sopenharmony_ci
3085e41f4b71Sopenharmony_ci**起始版本:** 11
3086e41f4b71Sopenharmony_ci
3087e41f4b71Sopenharmony_ci**参数:**
3088e41f4b71Sopenharmony_ci
3089e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3090e41f4b71Sopenharmony_ci| -------- | -------- |
3091e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3092e41f4b71Sopenharmony_ci| result | 代表JavaScript null对象。 | 
3093e41f4b71Sopenharmony_ci
3094e41f4b71Sopenharmony_ci**返回:**
3095e41f4b71Sopenharmony_ci
3096e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3097e41f4b71Sopenharmony_ci
3098e41f4b71Sopenharmony_ci
3099e41f4b71Sopenharmony_ci### OH_JSVM_GetProperty()
3100e41f4b71Sopenharmony_ci
3101e41f4b71Sopenharmony_ci```
3102e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetProperty (JSVM_Env env, JSVM_Value object, JSVM_Value key, JSVM_Value * result )
3103e41f4b71Sopenharmony_ci```
3104e41f4b71Sopenharmony_ci
3105e41f4b71Sopenharmony_ci**描述**
3106e41f4b71Sopenharmony_ci
3107e41f4b71Sopenharmony_ci从传入的object中获取请求的属性。
3108e41f4b71Sopenharmony_ci
3109e41f4b71Sopenharmony_ci**起始版本:** 11
3110e41f4b71Sopenharmony_ci
3111e41f4b71Sopenharmony_ci**参数:**
3112e41f4b71Sopenharmony_ci
3113e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3114e41f4b71Sopenharmony_ci| -------- | -------- |
3115e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3116e41f4b71Sopenharmony_ci| object | 从中检索属性的对象。 | 
3117e41f4b71Sopenharmony_ci| key | 要检索的属性的名称。 | 
3118e41f4b71Sopenharmony_ci| result | 属性值。 | 
3119e41f4b71Sopenharmony_ci
3120e41f4b71Sopenharmony_ci**返回:**
3121e41f4b71Sopenharmony_ci
3122e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3123e41f4b71Sopenharmony_ci
3124e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
3125e41f4b71Sopenharmony_ci
3126e41f4b71Sopenharmony_ci
3127e41f4b71Sopenharmony_ci### OH_JSVM_GetPropertyNames()
3128e41f4b71Sopenharmony_ci
3129e41f4b71Sopenharmony_ci```
3130e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetPropertyNames (JSVM_Env env, JSVM_Value object, JSVM_Value * result )
3131e41f4b71Sopenharmony_ci```
3132e41f4b71Sopenharmony_ci
3133e41f4b71Sopenharmony_ci**描述**
3134e41f4b71Sopenharmony_ci
3135e41f4b71Sopenharmony_ci以字符数数组的形式返回object的可枚举属性的名称。 key为符号的object的属性将不会被包含在内。
3136e41f4b71Sopenharmony_ci
3137e41f4b71Sopenharmony_ci**起始版本:** 11
3138e41f4b71Sopenharmony_ci
3139e41f4b71Sopenharmony_ci**参数:**
3140e41f4b71Sopenharmony_ci
3141e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3142e41f4b71Sopenharmony_ci| -------- | -------- |
3143e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3144e41f4b71Sopenharmony_ci| object | 待进行属性检索的对象。 | 
3145e41f4b71Sopenharmony_ci| result | 表示一个JavaScript值的数组,这些值表示对象的属性名称。 可以使用OH_JSVM_GetArrayLength以及OH_JSVM_GetElement对结果进行迭代。 | 
3146e41f4b71Sopenharmony_ci
3147e41f4b71Sopenharmony_ci**返回:**
3148e41f4b71Sopenharmony_ci
3149e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3150e41f4b71Sopenharmony_ci
3151e41f4b71Sopenharmony_ci
3152e41f4b71Sopenharmony_ci### OH_JSVM_GetPrototype()
3153e41f4b71Sopenharmony_ci
3154e41f4b71Sopenharmony_ci```
3155e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetPrototype (JSVM_Env env, JSVM_Value object, JSVM_Value * result )
3156e41f4b71Sopenharmony_ci```
3157e41f4b71Sopenharmony_ci
3158e41f4b71Sopenharmony_ci**描述**
3159e41f4b71Sopenharmony_ci
3160e41f4b71Sopenharmony_ci返回对象的原型。
3161e41f4b71Sopenharmony_ci
3162e41f4b71Sopenharmony_ci**起始版本:** 11
3163e41f4b71Sopenharmony_ci
3164e41f4b71Sopenharmony_ci**参数:**
3165e41f4b71Sopenharmony_ci
3166e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3167e41f4b71Sopenharmony_ci| -------- | -------- |
3168e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3169e41f4b71Sopenharmony_ci| object | 表示待返回其原型的JavaScript object。 这将返回Object.getPrototypeOf的等价值(与函数的prototype属性不同)。 | 
3170e41f4b71Sopenharmony_ci| result | 表示给定对象的原型。 | 
3171e41f4b71Sopenharmony_ci
3172e41f4b71Sopenharmony_ci**返回:**
3173e41f4b71Sopenharmony_ci
3174e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3175e41f4b71Sopenharmony_ci
3176e41f4b71Sopenharmony_ci
3177e41f4b71Sopenharmony_ci### OH_JSVM_GetReferenceValue()
3178e41f4b71Sopenharmony_ci
3179e41f4b71Sopenharmony_ci```
3180e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetReferenceValue (JSVM_Env env, JSVM_Ref ref, JSVM_Value * result )
3181e41f4b71Sopenharmony_ci```
3182e41f4b71Sopenharmony_ci
3183e41f4b71Sopenharmony_ci**描述**
3184e41f4b71Sopenharmony_ci
3185e41f4b71Sopenharmony_ci如果仍然有效,此JSVM-API将返回JSVM_Value, 表示与JSVM_Ref关联的JavaScript值。否则,结果将为NULL。
3186e41f4b71Sopenharmony_ci
3187e41f4b71Sopenharmony_ci**起始版本:** 11
3188e41f4b71Sopenharmony_ci
3189e41f4b71Sopenharmony_ci**参数:**
3190e41f4b71Sopenharmony_ci
3191e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3192e41f4b71Sopenharmony_ci| -------- | -------- |
3193e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3194e41f4b71Sopenharmony_ci| ref | 请求相应值的JSVM_Ref。 | 
3195e41f4b71Sopenharmony_ci| result | JSVM_Ref引用的JSVM_Value。 | 
3196e41f4b71Sopenharmony_ci
3197e41f4b71Sopenharmony_ci**返回:**
3198e41f4b71Sopenharmony_ci
3199e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3200e41f4b71Sopenharmony_ci
3201e41f4b71Sopenharmony_ci
3202e41f4b71Sopenharmony_ci### OH_JSVM_GetTypedarrayInfo()
3203e41f4b71Sopenharmony_ci
3204e41f4b71Sopenharmony_ci```
3205e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetTypedarrayInfo (JSVM_Env env, JSVM_Value typedarray, JSVM_TypedarrayType * type, size_t * length, void ** data, JSVM_Value * arraybuffer, size_t * byteOffset )
3206e41f4b71Sopenharmony_ci```
3207e41f4b71Sopenharmony_ci
3208e41f4b71Sopenharmony_ci**描述**
3209e41f4b71Sopenharmony_ci
3210e41f4b71Sopenharmony_ci返回类型化数组的各种属性。如果不需要该属性,则任何输出参数都可以是 NULL。
3211e41f4b71Sopenharmony_ci
3212e41f4b71Sopenharmony_ci**起始版本:** 11
3213e41f4b71Sopenharmony_ci
3214e41f4b71Sopenharmony_ci**参数:**
3215e41f4b71Sopenharmony_ci
3216e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3217e41f4b71Sopenharmony_ci| -------- | -------- |
3218e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3219e41f4b71Sopenharmony_ci| typedarray | 表示要查询其属性的TypedArray。 | 
3220e41f4b71Sopenharmony_ci| type | TypedArray中元素的标量数据类型。 | 
3221e41f4b71Sopenharmony_ci| length | TypedArray中的元素数。 | 
3222e41f4b71Sopenharmony_ci| data | TypedArray底层的数据缓冲区由byte_offset值调整,使其指向TypedArray 中的第一个元素。如果数组的长度是0,这可能是NULL或任何其他指针值。 | 
3223e41f4b71Sopenharmony_ci| arraybuffer | 位于TypedArray下的ArrayBuffer。 | 
3224e41f4b71Sopenharmony_ci| byteOffset | 数组的第一个元素所在的基础原生数组中的字节偏移量。 data 参数的值已经过调整,因此data指向数组中的第一个元素。因此, 原生数组的第一个字节将位于data - byte_offset。 | 
3225e41f4b71Sopenharmony_ci
3226e41f4b71Sopenharmony_ci**返回:**
3227e41f4b71Sopenharmony_ci
3228e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3229e41f4b71Sopenharmony_ci
3230e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
3231e41f4b71Sopenharmony_ci
3232e41f4b71Sopenharmony_ci
3233e41f4b71Sopenharmony_ci### OH_JSVM_GetUndefined()
3234e41f4b71Sopenharmony_ci
3235e41f4b71Sopenharmony_ci```
3236e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetUndefined (JSVM_Env env, JSVM_Value * result )
3237e41f4b71Sopenharmony_ci```
3238e41f4b71Sopenharmony_ci
3239e41f4b71Sopenharmony_ci**描述**
3240e41f4b71Sopenharmony_ci
3241e41f4b71Sopenharmony_ci返回Undefined对象。
3242e41f4b71Sopenharmony_ci
3243e41f4b71Sopenharmony_ci**起始版本:** 11
3244e41f4b71Sopenharmony_ci
3245e41f4b71Sopenharmony_ci**参数:**
3246e41f4b71Sopenharmony_ci
3247e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3248e41f4b71Sopenharmony_ci| -------- | -------- |
3249e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3250e41f4b71Sopenharmony_ci| value | 代表JavaScript undefined值。 | 
3251e41f4b71Sopenharmony_ci
3252e41f4b71Sopenharmony_ci**返回:**
3253e41f4b71Sopenharmony_ci
3254e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3255e41f4b71Sopenharmony_ci
3256e41f4b71Sopenharmony_ci
3257e41f4b71Sopenharmony_ci### OH_JSVM_GetValueBigintInt64()
3258e41f4b71Sopenharmony_ci
3259e41f4b71Sopenharmony_ci```
3260e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueBigintInt64 (JSVM_Env env, JSVM_Value value, int64_t * result, bool * lossless )
3261e41f4b71Sopenharmony_ci```
3262e41f4b71Sopenharmony_ci
3263e41f4b71Sopenharmony_ci**描述**
3264e41f4b71Sopenharmony_ci
3265e41f4b71Sopenharmony_ci返回给定JavaScript BigInt的C int64_t基础类型等价值。 如果需要,它将截断该值,将lossless设置为false。
3266e41f4b71Sopenharmony_ci
3267e41f4b71Sopenharmony_ci**起始版本:** 11
3268e41f4b71Sopenharmony_ci
3269e41f4b71Sopenharmony_ci**参数:**
3270e41f4b71Sopenharmony_ci
3271e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3272e41f4b71Sopenharmony_ci| -------- | -------- |
3273e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3274e41f4b71Sopenharmony_ci| value | 代表JavaScript BigInt。 | 
3275e41f4b71Sopenharmony_ci| result | 给定的JavaScript BigInt的C int64_t基础类型等价值。 | 
3276e41f4b71Sopenharmony_ci| lossless | 指示BigInt值是否已无损转换。 | 
3277e41f4b71Sopenharmony_ci
3278e41f4b71Sopenharmony_ci**返回:**
3279e41f4b71Sopenharmony_ci
3280e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3281e41f4b71Sopenharmony_ci
3282e41f4b71Sopenharmony_ciJSVM_BIGINT_EXPECTED 表示传入的参数不是BitInt类型。
3283e41f4b71Sopenharmony_ci
3284e41f4b71Sopenharmony_ci
3285e41f4b71Sopenharmony_ci### OH_JSVM_GetValueBigintUint64()
3286e41f4b71Sopenharmony_ci
3287e41f4b71Sopenharmony_ci```
3288e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueBigintUint64 (JSVM_Env env, JSVM_Value value, uint64_t * result, bool * lossless )
3289e41f4b71Sopenharmony_ci```
3290e41f4b71Sopenharmony_ci
3291e41f4b71Sopenharmony_ci**描述**
3292e41f4b71Sopenharmony_ci
3293e41f4b71Sopenharmony_ci返回给定JavaScript BigInt的C uint64_t基础类型等价值。 如果需要,它将截断该值,将lossless设置为false。
3294e41f4b71Sopenharmony_ci
3295e41f4b71Sopenharmony_ci**起始版本:** 11
3296e41f4b71Sopenharmony_ci
3297e41f4b71Sopenharmony_ci**参数:**
3298e41f4b71Sopenharmony_ci
3299e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3300e41f4b71Sopenharmony_ci| -------- | -------- |
3301e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3302e41f4b71Sopenharmony_ci| value | 代表JavaScript BigInt。 | 
3303e41f4b71Sopenharmony_ci| result | 给定的JavaScript BigInt的C uint64_t基础类型等价值。 | 
3304e41f4b71Sopenharmony_ci| lossless | 指示BigInt值是否已无损转换。 | 
3305e41f4b71Sopenharmony_ci
3306e41f4b71Sopenharmony_ci**返回:**
3307e41f4b71Sopenharmony_ci
3308e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3309e41f4b71Sopenharmony_ci
3310e41f4b71Sopenharmony_ciJSVM_BIGINT_EXPECTED 表示传入的参数不是BitInt类型。
3311e41f4b71Sopenharmony_ci
3312e41f4b71Sopenharmony_ci
3313e41f4b71Sopenharmony_ci### OH_JSVM_GetValueBigintWords()
3314e41f4b71Sopenharmony_ci
3315e41f4b71Sopenharmony_ci```
3316e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueBigintWords (JSVM_Env env, JSVM_Value value, int * signBit, size_t * wordCount, uint64_t * words )
3317e41f4b71Sopenharmony_ci```
3318e41f4b71Sopenharmony_ci
3319e41f4b71Sopenharmony_ci**描述**
3320e41f4b71Sopenharmony_ci
3321e41f4b71Sopenharmony_ci将单个BigInt值转换为符号位、64位小端数组和数组中的元素数。 signBit和words参数可以都设置为NULL。这种情况下,只获取wordCount。
3322e41f4b71Sopenharmony_ci
3323e41f4b71Sopenharmony_ci**起始版本:** 11
3324e41f4b71Sopenharmony_ci
3325e41f4b71Sopenharmony_ci**参数:**
3326e41f4b71Sopenharmony_ci
3327e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3328e41f4b71Sopenharmony_ci| -------- | -------- |
3329e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3330e41f4b71Sopenharmony_ci| value | 代表JavaScript BigInt。 | 
3331e41f4b71Sopenharmony_ci| signBit | 表示JavaScript BigInt是正数还是负数的整数。 | 
3332e41f4b71Sopenharmony_ci| wordCount | 必须初始化为words数组的长度。返回后,将被设置为存储此BigInt所需的实际字数。 | 
3333e41f4b71Sopenharmony_ci| words | 指向预分配的64位字数组的指针。 | 
3334e41f4b71Sopenharmony_ci
3335e41f4b71Sopenharmony_ci**返回:**
3336e41f4b71Sopenharmony_ci
3337e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3338e41f4b71Sopenharmony_ci
3339e41f4b71Sopenharmony_ciJSVM_BIGINT_EXPECTED 表示传入的参数不是BitInt类型。
3340e41f4b71Sopenharmony_ci
3341e41f4b71Sopenharmony_ci
3342e41f4b71Sopenharmony_ci### OH_JSVM_GetValueBool()
3343e41f4b71Sopenharmony_ci
3344e41f4b71Sopenharmony_ci```
3345e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueBool (JSVM_Env env, JSVM_Value value, bool * result )
3346e41f4b71Sopenharmony_ci```
3347e41f4b71Sopenharmony_ci
3348e41f4b71Sopenharmony_ci**描述**
3349e41f4b71Sopenharmony_ci
3350e41f4b71Sopenharmony_ci返回给定JavaScript Boolean的C布尔基础类型等价值。
3351e41f4b71Sopenharmony_ci
3352e41f4b71Sopenharmony_ci**起始版本:** 11
3353e41f4b71Sopenharmony_ci
3354e41f4b71Sopenharmony_ci**参数:**
3355e41f4b71Sopenharmony_ci
3356e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3357e41f4b71Sopenharmony_ci| -------- | -------- |
3358e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3359e41f4b71Sopenharmony_ci| value | 代表JavaScript Boolean。 | 
3360e41f4b71Sopenharmony_ci| result | 给定JavaScript Boolean的C布尔基础类型等价值。 | 
3361e41f4b71Sopenharmony_ci
3362e41f4b71Sopenharmony_ci**返回:**
3363e41f4b71Sopenharmony_ci
3364e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3365e41f4b71Sopenharmony_ci
3366e41f4b71Sopenharmony_ciJSVM_BOOLEAN_EXPECTED 表示传入的参数不是boolean类型。
3367e41f4b71Sopenharmony_ci
3368e41f4b71Sopenharmony_ci
3369e41f4b71Sopenharmony_ci### OH_JSVM_GetValueDouble()
3370e41f4b71Sopenharmony_ci
3371e41f4b71Sopenharmony_ci```
3372e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueDouble (JSVM_Env env, JSVM_Value value, double * result )
3373e41f4b71Sopenharmony_ci```
3374e41f4b71Sopenharmony_ci
3375e41f4b71Sopenharmony_ci**描述**
3376e41f4b71Sopenharmony_ci
3377e41f4b71Sopenharmony_ci返回给定JavaScript number的C双精度基础类型等价值。
3378e41f4b71Sopenharmony_ci
3379e41f4b71Sopenharmony_ci**起始版本:** 11
3380e41f4b71Sopenharmony_ci
3381e41f4b71Sopenharmony_ci**参数:**
3382e41f4b71Sopenharmony_ci
3383e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3384e41f4b71Sopenharmony_ci| -------- | -------- |
3385e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3386e41f4b71Sopenharmony_ci| value | 代表JavaScript number。 | 
3387e41f4b71Sopenharmony_ci| result | 给定的JavaScript number的C双精度基础类型等价值。 | 
3388e41f4b71Sopenharmony_ci
3389e41f4b71Sopenharmony_ci**返回:**
3390e41f4b71Sopenharmony_ci
3391e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3392e41f4b71Sopenharmony_ci
3393e41f4b71Sopenharmony_ciJSVM_NUMBER_EXPECTED 表示传入的参数不是number类型。
3394e41f4b71Sopenharmony_ci
3395e41f4b71Sopenharmony_ci
3396e41f4b71Sopenharmony_ci### OH_JSVM_GetValueExternal()
3397e41f4b71Sopenharmony_ci
3398e41f4b71Sopenharmony_ci```
3399e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueExternal (JSVM_Env env, JSVM_Value value, void ** result )
3400e41f4b71Sopenharmony_ci```
3401e41f4b71Sopenharmony_ci
3402e41f4b71Sopenharmony_ci**描述**
3403e41f4b71Sopenharmony_ci
3404e41f4b71Sopenharmony_ci检索之前传递给OH_JSVM_CreateExternal()的外部数据指针。
3405e41f4b71Sopenharmony_ci
3406e41f4b71Sopenharmony_ci**起始版本:** 11
3407e41f4b71Sopenharmony_ci
3408e41f4b71Sopenharmony_ci**参数:**
3409e41f4b71Sopenharmony_ci
3410e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3411e41f4b71Sopenharmony_ci| -------- | -------- |
3412e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3413e41f4b71Sopenharmony_ci| value | 代表JavaScript外部值。 | 
3414e41f4b71Sopenharmony_ci| result | 指向被JavaScript外部值封装的数据的指针。 | 
3415e41f4b71Sopenharmony_ci
3416e41f4b71Sopenharmony_ci**返回:**
3417e41f4b71Sopenharmony_ci
3418e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3419e41f4b71Sopenharmony_ci
3420e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入参数非外部的JSVM_Value。
3421e41f4b71Sopenharmony_ci
3422e41f4b71Sopenharmony_ci
3423e41f4b71Sopenharmony_ci### OH_JSVM_GetValueInt32()
3424e41f4b71Sopenharmony_ci
3425e41f4b71Sopenharmony_ci```
3426e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueInt32 (JSVM_Env env, JSVM_Value value, int32_t * result )
3427e41f4b71Sopenharmony_ci```
3428e41f4b71Sopenharmony_ci
3429e41f4b71Sopenharmony_ci**描述**
3430e41f4b71Sopenharmony_ci
3431e41f4b71Sopenharmony_ci返回给定JavaScript number的C int32基础类型等价值。
3432e41f4b71Sopenharmony_ci
3433e41f4b71Sopenharmony_ci**起始版本:** 11
3434e41f4b71Sopenharmony_ci
3435e41f4b71Sopenharmony_ci**参数:**
3436e41f4b71Sopenharmony_ci
3437e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3438e41f4b71Sopenharmony_ci| -------- | -------- |
3439e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3440e41f4b71Sopenharmony_ci| value | 代表JavaScript number。 | 
3441e41f4b71Sopenharmony_ci| result | 给定的JavaScript number的C int32基础类型等价值。 | 
3442e41f4b71Sopenharmony_ci
3443e41f4b71Sopenharmony_ci**返回:**
3444e41f4b71Sopenharmony_ci
3445e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3446e41f4b71Sopenharmony_ci
3447e41f4b71Sopenharmony_ciJSVM_NUMBER_EXPECTED 表示传入的参数不是number类型。
3448e41f4b71Sopenharmony_ci
3449e41f4b71Sopenharmony_ci
3450e41f4b71Sopenharmony_ci### OH_JSVM_GetValueInt64()
3451e41f4b71Sopenharmony_ci
3452e41f4b71Sopenharmony_ci```
3453e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueInt64 (JSVM_Env env, JSVM_Value value, int64_t * result )
3454e41f4b71Sopenharmony_ci```
3455e41f4b71Sopenharmony_ci
3456e41f4b71Sopenharmony_ci**描述**
3457e41f4b71Sopenharmony_ci
3458e41f4b71Sopenharmony_ci返回给定JavaScript number的C int64基础类型等价值。
3459e41f4b71Sopenharmony_ci
3460e41f4b71Sopenharmony_ci**起始版本:** 11
3461e41f4b71Sopenharmony_ci
3462e41f4b71Sopenharmony_ci**参数:**
3463e41f4b71Sopenharmony_ci
3464e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3465e41f4b71Sopenharmony_ci| -------- | -------- |
3466e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3467e41f4b71Sopenharmony_ci| value | 代表JavaScript number。 | 
3468e41f4b71Sopenharmony_ci| result | 给定的JavaScript number的C int64基础类型等价值。 | 
3469e41f4b71Sopenharmony_ci
3470e41f4b71Sopenharmony_ci**返回:**
3471e41f4b71Sopenharmony_ci
3472e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3473e41f4b71Sopenharmony_ci
3474e41f4b71Sopenharmony_ciJSVM_NUMBER_EXPECTED 表示传入的参数不是number类型。
3475e41f4b71Sopenharmony_ci
3476e41f4b71Sopenharmony_ci
3477e41f4b71Sopenharmony_ci### OH_JSVM_GetValueStringLatin1()
3478e41f4b71Sopenharmony_ci
3479e41f4b71Sopenharmony_ci```
3480e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueStringLatin1 (JSVM_Env env, JSVM_Value value, char * buf, size_t bufsize, size_t * result )
3481e41f4b71Sopenharmony_ci```
3482e41f4b71Sopenharmony_ci
3483e41f4b71Sopenharmony_ci**描述**
3484e41f4b71Sopenharmony_ci
3485e41f4b71Sopenharmony_ci返回对应于传入值的ISO-8859-1编码字符串
3486e41f4b71Sopenharmony_ci
3487e41f4b71Sopenharmony_ci**起始版本:** 11
3488e41f4b71Sopenharmony_ci
3489e41f4b71Sopenharmony_ci**参数:**
3490e41f4b71Sopenharmony_ci
3491e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3492e41f4b71Sopenharmony_ci| -------- | -------- |
3493e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3494e41f4b71Sopenharmony_ci| value | 代表JavaScript number。 | 
3495e41f4b71Sopenharmony_ci| buf | 写入ISO-8859-1编码字符串的缓冲区。如果传入NULL,则将在result中返回 字符串的长度(以字节为单位,不包括null结束符)。 | 
3496e41f4b71Sopenharmony_ci| bufsize | 目的缓冲区大小。当大小不够时,返回的字符串将被截断并以null结尾。 | 
3497e41f4b71Sopenharmony_ci| result | 复制到缓冲区中的字节数,不包括空终止符。 | 
3498e41f4b71Sopenharmony_ci
3499e41f4b71Sopenharmony_ci**返回:**
3500e41f4b71Sopenharmony_ci
3501e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3502e41f4b71Sopenharmony_ci
3503e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
3504e41f4b71Sopenharmony_ci
3505e41f4b71Sopenharmony_ci
3506e41f4b71Sopenharmony_ci### OH_JSVM_GetValueStringUtf16()
3507e41f4b71Sopenharmony_ci
3508e41f4b71Sopenharmony_ci```
3509e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueStringUtf16 (JSVM_Env env, JSVM_Value value, char16_t * buf, size_t bufsize, size_t * result )
3510e41f4b71Sopenharmony_ci```
3511e41f4b71Sopenharmony_ci
3512e41f4b71Sopenharmony_ci**描述**
3513e41f4b71Sopenharmony_ci
3514e41f4b71Sopenharmony_ci基于传入的值,查询对应的采用UTF16编码的字符串。
3515e41f4b71Sopenharmony_ci
3516e41f4b71Sopenharmony_ci**起始版本:** 11
3517e41f4b71Sopenharmony_ci
3518e41f4b71Sopenharmony_ci**参数:**
3519e41f4b71Sopenharmony_ci
3520e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3521e41f4b71Sopenharmony_ci| -------- | -------- |
3522e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3523e41f4b71Sopenharmony_ci| value | 代表JavaScript字符串。 | 
3524e41f4b71Sopenharmony_ci| buf | 将UTF16-LE编码字符串写入的缓冲区。如果传入NULL,则返回字符串的 2字节代码单元长度,不包括空终止符。 | 
3525e41f4b71Sopenharmony_ci| bufsize | 目标缓冲区的大小。当此值不足时,返回的字符串将被截断并以null终止。 | 
3526e41f4b71Sopenharmony_ci| result | 复制到缓冲区中的2字节代码单元数,不包括空终止符。 | 
3527e41f4b71Sopenharmony_ci
3528e41f4b71Sopenharmony_ci**返回:**
3529e41f4b71Sopenharmony_ci
3530e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3531e41f4b71Sopenharmony_ci
3532e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
3533e41f4b71Sopenharmony_ci
3534e41f4b71Sopenharmony_ci
3535e41f4b71Sopenharmony_ci### OH_JSVM_GetValueStringUtf8()
3536e41f4b71Sopenharmony_ci
3537e41f4b71Sopenharmony_ci```
3538e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueStringUtf8 (JSVM_Env env, JSVM_Value value, char * buf, size_t bufsize, size_t * result )
3539e41f4b71Sopenharmony_ci```
3540e41f4b71Sopenharmony_ci
3541e41f4b71Sopenharmony_ci**描述**
3542e41f4b71Sopenharmony_ci
3543e41f4b71Sopenharmony_ci返回对应于传入值的UTF8编码字符串。
3544e41f4b71Sopenharmony_ci
3545e41f4b71Sopenharmony_ci**起始版本:** 11
3546e41f4b71Sopenharmony_ci
3547e41f4b71Sopenharmony_ci**参数:**
3548e41f4b71Sopenharmony_ci
3549e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3550e41f4b71Sopenharmony_ci| -------- | -------- |
3551e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3552e41f4b71Sopenharmony_ci| value | 代表JavaScript字符串。 | 
3553e41f4b71Sopenharmony_ci| buf | 将UTF8编码的字符串写入的缓冲区。如果传入NULL,则在result中 返回以字节为单位的字符串长度,不包括空终止符。 | 
3554e41f4b71Sopenharmony_ci| bufsize | 目标缓冲区的大小。当此值不足时,返回的字符串将被截断并以null终止。 | 
3555e41f4b71Sopenharmony_ci| result | 复制到缓冲区的字节数,不包括null结束符。 | 
3556e41f4b71Sopenharmony_ci
3557e41f4b71Sopenharmony_ci**返回:**
3558e41f4b71Sopenharmony_ci
3559e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3560e41f4b71Sopenharmony_ci
3561e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
3562e41f4b71Sopenharmony_ci
3563e41f4b71Sopenharmony_ci
3564e41f4b71Sopenharmony_ci### OH_JSVM_GetValueUint32()
3565e41f4b71Sopenharmony_ci
3566e41f4b71Sopenharmony_ci```
3567e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetValueUint32 (JSVM_Env env, JSVM_Value value, uint32_t * result )
3568e41f4b71Sopenharmony_ci```
3569e41f4b71Sopenharmony_ci
3570e41f4b71Sopenharmony_ci**描述**
3571e41f4b71Sopenharmony_ci
3572e41f4b71Sopenharmony_ci返回给定JavaScript number的C uint_32基础类型等价值。
3573e41f4b71Sopenharmony_ci
3574e41f4b71Sopenharmony_ci**起始版本:** 11
3575e41f4b71Sopenharmony_ci
3576e41f4b71Sopenharmony_ci**参数:**
3577e41f4b71Sopenharmony_ci
3578e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3579e41f4b71Sopenharmony_ci| -------- | -------- |
3580e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3581e41f4b71Sopenharmony_ci| value | 代表JavaScript number。 | 
3582e41f4b71Sopenharmony_ci| result | 将给定的JSVM_Value等效为uint32_t 的C基础类型。 | 
3583e41f4b71Sopenharmony_ci
3584e41f4b71Sopenharmony_ci**返回:**
3585e41f4b71Sopenharmony_ci
3586e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3587e41f4b71Sopenharmony_ci
3588e41f4b71Sopenharmony_ciJSVM_NUMBER_EXPECTED 表示传入的参数不是number类型。
3589e41f4b71Sopenharmony_ci
3590e41f4b71Sopenharmony_ci
3591e41f4b71Sopenharmony_ci### OH_JSVM_GetVersion()
3592e41f4b71Sopenharmony_ci
3593e41f4b71Sopenharmony_ci```
3594e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetVersion (JSVM_Env env, uint32_t * result )
3595e41f4b71Sopenharmony_ci```
3596e41f4b71Sopenharmony_ci
3597e41f4b71Sopenharmony_ci**描述**
3598e41f4b71Sopenharmony_ci
3599e41f4b71Sopenharmony_ci返回JSVM运行时支持的最高JSVM-API版本。 后续将新增JSVM-API,以便支持更多的功能。引入该API的目的:在支持某功能的JSVM版本, 可以使用新的功能;在不支持某功能的JSVM版本,可以提供回调行为。
3600e41f4b71Sopenharmony_ci
3601e41f4b71Sopenharmony_ci**起始版本:** 11
3602e41f4b71Sopenharmony_ci
3603e41f4b71Sopenharmony_ci**参数:**
3604e41f4b71Sopenharmony_ci
3605e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3606e41f4b71Sopenharmony_ci| -------- | -------- |
3607e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3608e41f4b71Sopenharmony_ci| result | 支持的最高版本的JSVM-API。 | 
3609e41f4b71Sopenharmony_ci
3610e41f4b71Sopenharmony_ci**返回:**
3611e41f4b71Sopenharmony_ci
3612e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3613e41f4b71Sopenharmony_ci
3614e41f4b71Sopenharmony_ci
3615e41f4b71Sopenharmony_ci### OH_JSVM_GetVM()
3616e41f4b71Sopenharmony_ci
3617e41f4b71Sopenharmony_ci```
3618e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetVM (JSVM_Env env, JSVM_VM * result )
3619e41f4b71Sopenharmony_ci```
3620e41f4b71Sopenharmony_ci
3621e41f4b71Sopenharmony_ci**描述**
3622e41f4b71Sopenharmony_ci
3623e41f4b71Sopenharmony_ci将检索给定环境的虚拟机实例。
3624e41f4b71Sopenharmony_ci
3625e41f4b71Sopenharmony_ci**起始版本:** 12
3626e41f4b71Sopenharmony_ci
3627e41f4b71Sopenharmony_ci**参数:**
3628e41f4b71Sopenharmony_ci
3629e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3630e41f4b71Sopenharmony_ci| -------- | -------- |
3631e41f4b71Sopenharmony_ci| env | 目标环境,JSVM-API接口将在该环境下调用。 | 
3632e41f4b71Sopenharmony_ci| result | 给定环境的虚拟机实例。 | 
3633e41f4b71Sopenharmony_ci
3634e41f4b71Sopenharmony_ci**返回:**
3635e41f4b71Sopenharmony_ci
3636e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3637e41f4b71Sopenharmony_ci
3638e41f4b71Sopenharmony_ci
3639e41f4b71Sopenharmony_ci### OH_JSVM_GetVMInfo()
3640e41f4b71Sopenharmony_ci
3641e41f4b71Sopenharmony_ci```
3642e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_GetVMInfo (JSVM_VMInfo * result)
3643e41f4b71Sopenharmony_ci```
3644e41f4b71Sopenharmony_ci
3645e41f4b71Sopenharmony_ci**描述**
3646e41f4b71Sopenharmony_ci
3647e41f4b71Sopenharmony_ci返回虚拟机的信息。
3648e41f4b71Sopenharmony_ci
3649e41f4b71Sopenharmony_ci**起始版本:** 11
3650e41f4b71Sopenharmony_ci
3651e41f4b71Sopenharmony_ci**参数:**
3652e41f4b71Sopenharmony_ci
3653e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3654e41f4b71Sopenharmony_ci| -------- | -------- |
3655e41f4b71Sopenharmony_ci| result | 虚拟机的信息。 | 
3656e41f4b71Sopenharmony_ci
3657e41f4b71Sopenharmony_ci**返回:**
3658e41f4b71Sopenharmony_ci
3659e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3660e41f4b71Sopenharmony_ci
3661e41f4b71Sopenharmony_ci
3662e41f4b71Sopenharmony_ci### OH_JSVM_HasElement()
3663e41f4b71Sopenharmony_ci
3664e41f4b71Sopenharmony_ci```
3665e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_HasElement (JSVM_Env env, JSVM_Value object, uint32_t index, bool * result )
3666e41f4b71Sopenharmony_ci```
3667e41f4b71Sopenharmony_ci
3668e41f4b71Sopenharmony_ci**描述**
3669e41f4b71Sopenharmony_ci
3670e41f4b71Sopenharmony_ci如果传入的Object在指定的索引处有一个元素,则此JSVM-API返回true。
3671e41f4b71Sopenharmony_ci
3672e41f4b71Sopenharmony_ci**起始版本:** 11
3673e41f4b71Sopenharmony_ci
3674e41f4b71Sopenharmony_ci**参数:**
3675e41f4b71Sopenharmony_ci
3676e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3677e41f4b71Sopenharmony_ci| -------- | -------- |
3678e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3679e41f4b71Sopenharmony_ci| object | 待查询的对象。 | 
3680e41f4b71Sopenharmony_ci| index | 待确定是否存在元素的索引位置。 | 
3681e41f4b71Sopenharmony_ci| result | 该属性是否存在于对象上。 | 
3682e41f4b71Sopenharmony_ci
3683e41f4b71Sopenharmony_ci**返回:**
3684e41f4b71Sopenharmony_ci
3685e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3686e41f4b71Sopenharmony_ci
3687e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
3688e41f4b71Sopenharmony_ci
3689e41f4b71Sopenharmony_ci
3690e41f4b71Sopenharmony_ci### OH_JSVM_HasNamedProperty()
3691e41f4b71Sopenharmony_ci
3692e41f4b71Sopenharmony_ci```
3693e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_HasNamedProperty (JSVM_Env env, JSVM_Value object, const char * utf8name, bool * result )
3694e41f4b71Sopenharmony_ci```
3695e41f4b71Sopenharmony_ci
3696e41f4b71Sopenharmony_ci**描述**
3697e41f4b71Sopenharmony_ci
3698e41f4b71Sopenharmony_ci此方法等效于使用从作为utf8Name传入的字符串创建的JSVM_Value 调用OH_JSVM_HasProperty。
3699e41f4b71Sopenharmony_ci
3700e41f4b71Sopenharmony_ci**起始版本:** 11
3701e41f4b71Sopenharmony_ci
3702e41f4b71Sopenharmony_ci**参数:**
3703e41f4b71Sopenharmony_ci
3704e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3705e41f4b71Sopenharmony_ci| -------- | -------- |
3706e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3707e41f4b71Sopenharmony_ci| object | 待查询的对象。 | 
3708e41f4b71Sopenharmony_ci| utf8Name | 待检查的属性名。 | 
3709e41f4b71Sopenharmony_ci| result | 该属性是否存在于对象上。 | 
3710e41f4b71Sopenharmony_ci
3711e41f4b71Sopenharmony_ci**返回:**
3712e41f4b71Sopenharmony_ci
3713e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3714e41f4b71Sopenharmony_ci
3715e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
3716e41f4b71Sopenharmony_ci
3717e41f4b71Sopenharmony_ci
3718e41f4b71Sopenharmony_ci### OH_JSVM_HasOwnProperty()
3719e41f4b71Sopenharmony_ci
3720e41f4b71Sopenharmony_ci```
3721e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_HasOwnProperty (JSVM_Env env, JSVM_Value object, JSVM_Value key, bool * result )
3722e41f4b71Sopenharmony_ci```
3723e41f4b71Sopenharmony_ci
3724e41f4b71Sopenharmony_ci**描述**
3725e41f4b71Sopenharmony_ci
3726e41f4b71Sopenharmony_ci检查传入的Object是否具有命名的自己的属性。key必须是string或symbol, 否则将抛出错误。JSVM-API不会执行任何数据类型之间的转换。
3727e41f4b71Sopenharmony_ci
3728e41f4b71Sopenharmony_ci**起始版本:** 11
3729e41f4b71Sopenharmony_ci
3730e41f4b71Sopenharmony_ci**参数:**
3731e41f4b71Sopenharmony_ci
3732e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3733e41f4b71Sopenharmony_ci| -------- | -------- |
3734e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3735e41f4b71Sopenharmony_ci| object | 待查询的对象。 | 
3736e41f4b71Sopenharmony_ci| key | 要检查其存在的自有属性的名称。 | 
3737e41f4b71Sopenharmony_ci| result | 表示对象上是否存在该自身属性。 | 
3738e41f4b71Sopenharmony_ci
3739e41f4b71Sopenharmony_ci**返回:**
3740e41f4b71Sopenharmony_ci
3741e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3742e41f4b71Sopenharmony_ci
3743e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
3744e41f4b71Sopenharmony_ci
3745e41f4b71Sopenharmony_ci
3746e41f4b71Sopenharmony_ci### OH_JSVM_HasProperty()
3747e41f4b71Sopenharmony_ci
3748e41f4b71Sopenharmony_ci```
3749e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_HasProperty (JSVM_Env env, JSVM_Value object, JSVM_Value key, bool * result )
3750e41f4b71Sopenharmony_ci```
3751e41f4b71Sopenharmony_ci
3752e41f4b71Sopenharmony_ci**描述**
3753e41f4b71Sopenharmony_ci
3754e41f4b71Sopenharmony_ci检查传入的Object是否具有指定命名的属性。
3755e41f4b71Sopenharmony_ci
3756e41f4b71Sopenharmony_ci**起始版本:** 11
3757e41f4b71Sopenharmony_ci
3758e41f4b71Sopenharmony_ci**参数:**
3759e41f4b71Sopenharmony_ci
3760e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3761e41f4b71Sopenharmony_ci| -------- | -------- |
3762e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3763e41f4b71Sopenharmony_ci| object | 待查询的对象。 | 
3764e41f4b71Sopenharmony_ci| key | 要检查其存在的属性的名称。 | 
3765e41f4b71Sopenharmony_ci| result | 该属性是否存在于对象上。 | 
3766e41f4b71Sopenharmony_ci
3767e41f4b71Sopenharmony_ci**返回:**
3768e41f4b71Sopenharmony_ci
3769e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3770e41f4b71Sopenharmony_ci
3771e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
3772e41f4b71Sopenharmony_ci
3773e41f4b71Sopenharmony_ci
3774e41f4b71Sopenharmony_ci### OH_JSVM_Init()
3775e41f4b71Sopenharmony_ci
3776e41f4b71Sopenharmony_ci```
3777e41f4b71Sopenharmony_ciEXTERN_C_START JSVM_EXTERN JSVM_Status OH_JSVM_Init (const JSVM_InitOptions * options)
3778e41f4b71Sopenharmony_ci```
3779e41f4b71Sopenharmony_ci
3780e41f4b71Sopenharmony_ci**描述**
3781e41f4b71Sopenharmony_ci
3782e41f4b71Sopenharmony_ci初始化一个JavaScript虚拟机。
3783e41f4b71Sopenharmony_ci
3784e41f4b71Sopenharmony_ci**起始版本:** 11
3785e41f4b71Sopenharmony_ci
3786e41f4b71Sopenharmony_ci**参数:**
3787e41f4b71Sopenharmony_ci
3788e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3789e41f4b71Sopenharmony_ci| -------- | -------- |
3790e41f4b71Sopenharmony_ci| options | 用于初始化JavaScript虚拟机的选项。 | 
3791e41f4b71Sopenharmony_ci
3792e41f4b71Sopenharmony_ci**返回:**
3793e41f4b71Sopenharmony_ci
3794e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3795e41f4b71Sopenharmony_ci
3796e41f4b71Sopenharmony_ci
3797e41f4b71Sopenharmony_ci### OH_JSVM_Instanceof()
3798e41f4b71Sopenharmony_ci
3799e41f4b71Sopenharmony_ci```
3800e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_Instanceof (JSVM_Env env, JSVM_Value object, JSVM_Value constructor, bool * result )
3801e41f4b71Sopenharmony_ci```
3802e41f4b71Sopenharmony_ci
3803e41f4b71Sopenharmony_ci**描述**
3804e41f4b71Sopenharmony_ci
3805e41f4b71Sopenharmony_ci提供类似于在对象上调用instanceof运算符的行为。
3806e41f4b71Sopenharmony_ci
3807e41f4b71Sopenharmony_ci**起始版本:** 11
3808e41f4b71Sopenharmony_ci
3809e41f4b71Sopenharmony_ci**参数:**
3810e41f4b71Sopenharmony_ci
3811e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3812e41f4b71Sopenharmony_ci| -------- | -------- |
3813e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3814e41f4b71Sopenharmony_ci| value | 要检查的JavaScript值。 | 
3815e41f4b71Sopenharmony_ci| constructor | 要检查的构造函数的JavaScript函数对象 | 
3816e41f4b71Sopenharmony_ci| result | 如果object instanceof constructor为true,则设置为true的布尔值。 | 
3817e41f4b71Sopenharmony_ci
3818e41f4b71Sopenharmony_ci**返回:**
3819e41f4b71Sopenharmony_ci
3820e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3821e41f4b71Sopenharmony_ci
3822e41f4b71Sopenharmony_ciJSVM_FUNCTION_EXPECTED 表示传入的参数不是Function类型。
3823e41f4b71Sopenharmony_ci
3824e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
3825e41f4b71Sopenharmony_ci
3826e41f4b71Sopenharmony_ci
3827e41f4b71Sopenharmony_ci### OH_JSVM_IsArray()
3828e41f4b71Sopenharmony_ci
3829e41f4b71Sopenharmony_ci```
3830e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsArray (JSVM_Env env, JSVM_Value value, bool * result )
3831e41f4b71Sopenharmony_ci```
3832e41f4b71Sopenharmony_ci
3833e41f4b71Sopenharmony_ci**描述**
3834e41f4b71Sopenharmony_ci
3835e41f4b71Sopenharmony_ci提供类似于在对象上调用IsArray的行为。
3836e41f4b71Sopenharmony_ci
3837e41f4b71Sopenharmony_ci**起始版本:** 11
3838e41f4b71Sopenharmony_ci
3839e41f4b71Sopenharmony_ci**参数:**
3840e41f4b71Sopenharmony_ci
3841e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3842e41f4b71Sopenharmony_ci| -------- | -------- |
3843e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3844e41f4b71Sopenharmony_ci| value | 待检查的JavaScript值。 | 
3845e41f4b71Sopenharmony_ci| result | 表示给定的对象是否为数组。 | 
3846e41f4b71Sopenharmony_ci
3847e41f4b71Sopenharmony_ci**返回:**
3848e41f4b71Sopenharmony_ci
3849e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3850e41f4b71Sopenharmony_ci
3851e41f4b71Sopenharmony_ci
3852e41f4b71Sopenharmony_ci### OH_JSVM_IsArraybuffer()
3853e41f4b71Sopenharmony_ci
3854e41f4b71Sopenharmony_ci```
3855e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsArraybuffer (JSVM_Env env, JSVM_Value value, bool * result )
3856e41f4b71Sopenharmony_ci```
3857e41f4b71Sopenharmony_ci
3858e41f4b71Sopenharmony_ci**描述**
3859e41f4b71Sopenharmony_ci
3860e41f4b71Sopenharmony_ci检查传入的对象是否为ArrayBuffer。
3861e41f4b71Sopenharmony_ci
3862e41f4b71Sopenharmony_ci**起始版本:** 11
3863e41f4b71Sopenharmony_ci
3864e41f4b71Sopenharmony_ci**参数:**
3865e41f4b71Sopenharmony_ci
3866e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3867e41f4b71Sopenharmony_ci| -------- | -------- |
3868e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3869e41f4b71Sopenharmony_ci| value | 待检查的JavaScript值。 | 
3870e41f4b71Sopenharmony_ci| result | 表示指定的对象是否为ArrayBuffer。 | 
3871e41f4b71Sopenharmony_ci
3872e41f4b71Sopenharmony_ci**返回:**
3873e41f4b71Sopenharmony_ci
3874e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3875e41f4b71Sopenharmony_ci
3876e41f4b71Sopenharmony_ci
3877e41f4b71Sopenharmony_ci### OH_JSVM_IsBigInt()
3878e41f4b71Sopenharmony_ci
3879e41f4b71Sopenharmony_ci```
3880e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsBigInt (JSVM_Env env, JSVM_Value value, bool * isBigInt )
3881e41f4b71Sopenharmony_ci```
3882e41f4b71Sopenharmony_ci
3883e41f4b71Sopenharmony_ci**描述**
3884e41f4b71Sopenharmony_ci
3885e41f4b71Sopenharmony_ci此API检查传入的值是否为BigInt。 这相当于JS中的‘typeof value === 'bigint’`。
3886e41f4b71Sopenharmony_ci
3887e41f4b71Sopenharmony_ci**起始版本:** 12
3888e41f4b71Sopenharmony_ci
3889e41f4b71Sopenharmony_ci**参数:**
3890e41f4b71Sopenharmony_ci
3891e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3892e41f4b71Sopenharmony_ci| -------- | -------- |
3893e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3894e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
3895e41f4b71Sopenharmony_ci| isBigInt | 表示给定的JSVM_Value是否为BigInt。 | 
3896e41f4b71Sopenharmony_ci
3897e41f4b71Sopenharmony_ci**返回:**
3898e41f4b71Sopenharmony_ci
3899e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功,这个API不会触发任何异常。
3900e41f4b71Sopenharmony_ci
3901e41f4b71Sopenharmony_ci
3902e41f4b71Sopenharmony_ci### OH_JSVM_IsBoolean()
3903e41f4b71Sopenharmony_ci
3904e41f4b71Sopenharmony_ci```
3905e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsBoolean (JSVM_Env env, JSVM_Value value, bool * isBoolean )
3906e41f4b71Sopenharmony_ci```
3907e41f4b71Sopenharmony_ci
3908e41f4b71Sopenharmony_ci**描述**
3909e41f4b71Sopenharmony_ci
3910e41f4b71Sopenharmony_ci此API检查传入的值是否为Boolean。 这相当于JS中的‘typeof value === 'boolean’`。
3911e41f4b71Sopenharmony_ci
3912e41f4b71Sopenharmony_ci**起始版本:** 12
3913e41f4b71Sopenharmony_ci
3914e41f4b71Sopenharmony_ci**参数:**
3915e41f4b71Sopenharmony_ci
3916e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3917e41f4b71Sopenharmony_ci| -------- | -------- |
3918e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3919e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
3920e41f4b71Sopenharmony_ci| isBoolean | 表示给定的JSVM_Value是否为Boolean。 | 
3921e41f4b71Sopenharmony_ci
3922e41f4b71Sopenharmony_ci**返回:**
3923e41f4b71Sopenharmony_ci
3924e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功,这个API不会触发任何异常。
3925e41f4b71Sopenharmony_ci
3926e41f4b71Sopenharmony_ci
3927e41f4b71Sopenharmony_ci### OH_JSVM_IsConstructor()
3928e41f4b71Sopenharmony_ci
3929e41f4b71Sopenharmony_ci```
3930e41f4b71Sopenharmony_ciJSVM_Status JSVM_CDECL OH_JSVM_IsConstructor (JSVM_Env env, JSVM_Value value, bool * isConstructor )
3931e41f4b71Sopenharmony_ci```
3932e41f4b71Sopenharmony_ci
3933e41f4b71Sopenharmony_ci**描述**
3934e41f4b71Sopenharmony_ci
3935e41f4b71Sopenharmony_ci此API检查传入的值是否为构造函数。
3936e41f4b71Sopenharmony_ci
3937e41f4b71Sopenharmony_ci**起始版本:** 12
3938e41f4b71Sopenharmony_ci
3939e41f4b71Sopenharmony_ci**参数:**
3940e41f4b71Sopenharmony_ci
3941e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3942e41f4b71Sopenharmony_ci| -------- | -------- |
3943e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3944e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
3945e41f4b71Sopenharmony_ci| isConstructor | 给定的值是否为构造函数。 | 
3946e41f4b71Sopenharmony_ci
3947e41f4b71Sopenharmony_ci**返回:**
3948e41f4b71Sopenharmony_ci
3949e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3950e41f4b71Sopenharmony_ci
3951e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示输入参数不合法。
3952e41f4b71Sopenharmony_ci
3953e41f4b71Sopenharmony_ci
3954e41f4b71Sopenharmony_ci### OH_JSVM_IsDataview()
3955e41f4b71Sopenharmony_ci
3956e41f4b71Sopenharmony_ci```
3957e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsDataview (JSVM_Env env, JSVM_Value value, bool * result )
3958e41f4b71Sopenharmony_ci```
3959e41f4b71Sopenharmony_ci
3960e41f4b71Sopenharmony_ci**描述**
3961e41f4b71Sopenharmony_ci
3962e41f4b71Sopenharmony_ci检查传入的对象是否是DataView。
3963e41f4b71Sopenharmony_ci
3964e41f4b71Sopenharmony_ci**起始版本:** 11
3965e41f4b71Sopenharmony_ci
3966e41f4b71Sopenharmony_ci**参数:**
3967e41f4b71Sopenharmony_ci
3968e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3969e41f4b71Sopenharmony_ci| -------- | -------- |
3970e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3971e41f4b71Sopenharmony_ci| value | 待检查的JavaScript值。 | 
3972e41f4b71Sopenharmony_ci| result | 给定的JSVM_Value是否代表DataView。 | 
3973e41f4b71Sopenharmony_ci
3974e41f4b71Sopenharmony_ci**返回:**
3975e41f4b71Sopenharmony_ci
3976e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
3977e41f4b71Sopenharmony_ci
3978e41f4b71Sopenharmony_ci
3979e41f4b71Sopenharmony_ci### OH_JSVM_IsDate()
3980e41f4b71Sopenharmony_ci
3981e41f4b71Sopenharmony_ci```
3982e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsDate (JSVM_Env env, JSVM_Value value, bool * isDate )
3983e41f4b71Sopenharmony_ci```
3984e41f4b71Sopenharmony_ci
3985e41f4b71Sopenharmony_ci**描述**
3986e41f4b71Sopenharmony_ci
3987e41f4b71Sopenharmony_ci检查传入的Object是否为日期。
3988e41f4b71Sopenharmony_ci
3989e41f4b71Sopenharmony_ci**起始版本:** 11
3990e41f4b71Sopenharmony_ci
3991e41f4b71Sopenharmony_ci**参数:**
3992e41f4b71Sopenharmony_ci
3993e41f4b71Sopenharmony_ci| 名称 | 描述 | 
3994e41f4b71Sopenharmony_ci| -------- | -------- |
3995e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
3996e41f4b71Sopenharmony_ci| value | 待检查的JavaScript值。 | 
3997e41f4b71Sopenharmony_ci| isDate | 给定的JSVM_Value是否表示JavaScript Date对象。 | 
3998e41f4b71Sopenharmony_ci
3999e41f4b71Sopenharmony_ci**返回:**
4000e41f4b71Sopenharmony_ci
4001e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4002e41f4b71Sopenharmony_ci
4003e41f4b71Sopenharmony_ci
4004e41f4b71Sopenharmony_ci### OH_JSVM_IsDetachedArraybuffer()
4005e41f4b71Sopenharmony_ci
4006e41f4b71Sopenharmony_ci```
4007e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsDetachedArraybuffer (JSVM_Env env, JSVM_Value value, bool * result )
4008e41f4b71Sopenharmony_ci```
4009e41f4b71Sopenharmony_ci
4010e41f4b71Sopenharmony_ci**描述**
4011e41f4b71Sopenharmony_ci
4012e41f4b71Sopenharmony_ci提供类似调用ArrayBuffer IsDetachedBuffer操作的行为。
4013e41f4b71Sopenharmony_ci
4014e41f4b71Sopenharmony_ci**起始版本:** 11
4015e41f4b71Sopenharmony_ci
4016e41f4b71Sopenharmony_ci**参数:**
4017e41f4b71Sopenharmony_ci
4018e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4019e41f4b71Sopenharmony_ci| -------- | -------- |
4020e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4021e41f4b71Sopenharmony_ci| value | 待检查的JavaScript ArrayBuffer。 | 
4022e41f4b71Sopenharmony_ci| result | 表示ArrayBuffer是否被分离。 | 
4023e41f4b71Sopenharmony_ci
4024e41f4b71Sopenharmony_ci**返回:**
4025e41f4b71Sopenharmony_ci
4026e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4027e41f4b71Sopenharmony_ci
4028e41f4b71Sopenharmony_ci
4029e41f4b71Sopenharmony_ci### OH_JSVM_IsError()
4030e41f4b71Sopenharmony_ci
4031e41f4b71Sopenharmony_ci```
4032e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsError (JSVM_Env env, JSVM_Value value, bool * result )
4033e41f4b71Sopenharmony_ci```
4034e41f4b71Sopenharmony_ci
4035e41f4b71Sopenharmony_ci**描述**
4036e41f4b71Sopenharmony_ci
4037e41f4b71Sopenharmony_ci查询JSVM_Value以检查它是否表示错误对象。
4038e41f4b71Sopenharmony_ci
4039e41f4b71Sopenharmony_ci**起始版本:** 11
4040e41f4b71Sopenharmony_ci
4041e41f4b71Sopenharmony_ci**参数:**
4042e41f4b71Sopenharmony_ci
4043e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4044e41f4b71Sopenharmony_ci| -------- | -------- |
4045e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4046e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
4047e41f4b71Sopenharmony_ci| result | 如果JSVM_Value表示错误,则设置为true的布尔值,否则设置为false。 | 
4048e41f4b71Sopenharmony_ci
4049e41f4b71Sopenharmony_ci**返回:**
4050e41f4b71Sopenharmony_ci
4051e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4052e41f4b71Sopenharmony_ci
4053e41f4b71Sopenharmony_ci
4054e41f4b71Sopenharmony_ci### OH_JSVM_IsExceptionPending()
4055e41f4b71Sopenharmony_ci
4056e41f4b71Sopenharmony_ci```
4057e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsExceptionPending (JSVM_Env env, bool * result )
4058e41f4b71Sopenharmony_ci```
4059e41f4b71Sopenharmony_ci
4060e41f4b71Sopenharmony_ci**描述**
4061e41f4b71Sopenharmony_ci
4062e41f4b71Sopenharmony_ci查询上一次异常是否由挂起导致的。如果由异常导致,则返回true,否则返回false。
4063e41f4b71Sopenharmony_ci
4064e41f4b71Sopenharmony_ci**起始版本:** 11
4065e41f4b71Sopenharmony_ci
4066e41f4b71Sopenharmony_ci**参数:**
4067e41f4b71Sopenharmony_ci
4068e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4069e41f4b71Sopenharmony_ci| -------- | -------- |
4070e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4071e41f4b71Sopenharmony_ci| result | 如果异常挂起,则设置为true的布尔值。 | 
4072e41f4b71Sopenharmony_ci
4073e41f4b71Sopenharmony_ci**返回:**
4074e41f4b71Sopenharmony_ci
4075e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4076e41f4b71Sopenharmony_ci
4077e41f4b71Sopenharmony_ci
4078e41f4b71Sopenharmony_ci### OH_JSVM_IsFunction()
4079e41f4b71Sopenharmony_ci
4080e41f4b71Sopenharmony_ci```
4081e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsFunction (JSVM_Env env, JSVM_Value value, bool * isFunction )
4082e41f4b71Sopenharmony_ci```
4083e41f4b71Sopenharmony_ci
4084e41f4b71Sopenharmony_ci**描述**
4085e41f4b71Sopenharmony_ci
4086e41f4b71Sopenharmony_ci此API检查传入的值是否为Function。 这相当于JS中的‘typeof value === 'function’`。
4087e41f4b71Sopenharmony_ci
4088e41f4b71Sopenharmony_ci**起始版本:** 12
4089e41f4b71Sopenharmony_ci
4090e41f4b71Sopenharmony_ci**参数:**
4091e41f4b71Sopenharmony_ci
4092e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4093e41f4b71Sopenharmony_ci| -------- | -------- |
4094e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4095e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
4096e41f4b71Sopenharmony_ci| isFunction | 表示给定的JSVM_Value是否为Function。 | 
4097e41f4b71Sopenharmony_ci
4098e41f4b71Sopenharmony_ci**返回:**
4099e41f4b71Sopenharmony_ci
4100e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功,这个API不会触发任何异常。
4101e41f4b71Sopenharmony_ci
4102e41f4b71Sopenharmony_ci
4103e41f4b71Sopenharmony_ci### OH_JSVM_IsMap()
4104e41f4b71Sopenharmony_ci
4105e41f4b71Sopenharmony_ci```
4106e41f4b71Sopenharmony_ciJSVM_Status JSVM_CDECL OH_JSVM_IsMap (JSVM_Env env, JSVM_Value value, bool * isMap )
4107e41f4b71Sopenharmony_ci```
4108e41f4b71Sopenharmony_ci
4109e41f4b71Sopenharmony_ci**描述**
4110e41f4b71Sopenharmony_ci
4111e41f4b71Sopenharmony_ci此API检查传入的值是否为Map。
4112e41f4b71Sopenharmony_ci
4113e41f4b71Sopenharmony_ci**起始版本:** 12
4114e41f4b71Sopenharmony_ci
4115e41f4b71Sopenharmony_ci**参数:**
4116e41f4b71Sopenharmony_ci
4117e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4118e41f4b71Sopenharmony_ci| -------- | -------- |
4119e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4120e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
4121e41f4b71Sopenharmony_ci| isMap | 给定的值是否为Map。 | 
4122e41f4b71Sopenharmony_ci
4123e41f4b71Sopenharmony_ci**返回:**
4124e41f4b71Sopenharmony_ci
4125e41f4b71Sopenharmony_ci返回执行状态码JSVM_Status。 JSVM_OK 表示执行成功。
4126e41f4b71Sopenharmony_ci
4127e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示输入参数不合法。
4128e41f4b71Sopenharmony_ci
4129e41f4b71Sopenharmony_ci
4130e41f4b71Sopenharmony_ci### OH_JSVM_IsNull()
4131e41f4b71Sopenharmony_ci
4132e41f4b71Sopenharmony_ci```
4133e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsNull (JSVM_Env env, JSVM_Value value, bool * isNull )
4134e41f4b71Sopenharmony_ci```
4135e41f4b71Sopenharmony_ci
4136e41f4b71Sopenharmony_ci**描述**
4137e41f4b71Sopenharmony_ci
4138e41f4b71Sopenharmony_ci此API检查传入的值是否为Null对象。 这相当于JS中的value === null。
4139e41f4b71Sopenharmony_ci
4140e41f4b71Sopenharmony_ci**起始版本:** 12
4141e41f4b71Sopenharmony_ci
4142e41f4b71Sopenharmony_ci**参数:**
4143e41f4b71Sopenharmony_ci
4144e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4145e41f4b71Sopenharmony_ci| -------- | -------- |
4146e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4147e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
4148e41f4b71Sopenharmony_ci| isNull | 表示给定的JSVM_Value是否为Null。 | 
4149e41f4b71Sopenharmony_ci
4150e41f4b71Sopenharmony_ci**返回:**
4151e41f4b71Sopenharmony_ci
4152e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功,这个API不会触发任何异常。
4153e41f4b71Sopenharmony_ci
4154e41f4b71Sopenharmony_ci
4155e41f4b71Sopenharmony_ci### OH_JSVM_IsNullOrUndefined()
4156e41f4b71Sopenharmony_ci
4157e41f4b71Sopenharmony_ci```
4158e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsNullOrUndefined (JSVM_Env env, JSVM_Value value, bool * isNullOrUndefined )
4159e41f4b71Sopenharmony_ci```
4160e41f4b71Sopenharmony_ci
4161e41f4b71Sopenharmony_ci**描述**
4162e41f4b71Sopenharmony_ci
4163e41f4b71Sopenharmony_ci此API检查传入的值是否为Null或Undefined。 这相当于JS中的value == null。
4164e41f4b71Sopenharmony_ci
4165e41f4b71Sopenharmony_ci**起始版本:** 12
4166e41f4b71Sopenharmony_ci
4167e41f4b71Sopenharmony_ci**参数:**
4168e41f4b71Sopenharmony_ci
4169e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4170e41f4b71Sopenharmony_ci| -------- | -------- |
4171e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4172e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
4173e41f4b71Sopenharmony_ci| isNullOrUndefined | 表示给定的JSVM_Value是否为Null或Undefined。 | 
4174e41f4b71Sopenharmony_ci
4175e41f4b71Sopenharmony_ci**返回:**
4176e41f4b71Sopenharmony_ci
4177e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功,这个API不会触发任何异常。
4178e41f4b71Sopenharmony_ci
4179e41f4b71Sopenharmony_ci
4180e41f4b71Sopenharmony_ci### OH_JSVM_IsNumber()
4181e41f4b71Sopenharmony_ci
4182e41f4b71Sopenharmony_ci```
4183e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsNumber (JSVM_Env env, JSVM_Value value, bool * isNumber )
4184e41f4b71Sopenharmony_ci```
4185e41f4b71Sopenharmony_ci
4186e41f4b71Sopenharmony_ci**描述**
4187e41f4b71Sopenharmony_ci
4188e41f4b71Sopenharmony_ci此API检查传入的值是否为Number。 这相当于JS中的‘typeof value === 'number’`。
4189e41f4b71Sopenharmony_ci
4190e41f4b71Sopenharmony_ci**起始版本:** 12
4191e41f4b71Sopenharmony_ci
4192e41f4b71Sopenharmony_ci**参数:**
4193e41f4b71Sopenharmony_ci
4194e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4195e41f4b71Sopenharmony_ci| -------- | -------- |
4196e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4197e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
4198e41f4b71Sopenharmony_ci| isNumber | 表示给定的JSVM_Value是否为Number。 | 
4199e41f4b71Sopenharmony_ci
4200e41f4b71Sopenharmony_ci**返回:**
4201e41f4b71Sopenharmony_ci
4202e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功,这个API不会触发任何异常。
4203e41f4b71Sopenharmony_ci
4204e41f4b71Sopenharmony_ci
4205e41f4b71Sopenharmony_ci### OH_JSVM_IsObject()
4206e41f4b71Sopenharmony_ci
4207e41f4b71Sopenharmony_ci```
4208e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsObject (JSVM_Env env, JSVM_Value value, bool * isObject )
4209e41f4b71Sopenharmony_ci```
4210e41f4b71Sopenharmony_ci
4211e41f4b71Sopenharmony_ci**描述**
4212e41f4b71Sopenharmony_ci
4213e41f4b71Sopenharmony_ci此API检查传入的值是否为Object。
4214e41f4b71Sopenharmony_ci
4215e41f4b71Sopenharmony_ci**起始版本:** 12
4216e41f4b71Sopenharmony_ci
4217e41f4b71Sopenharmony_ci**参数:**
4218e41f4b71Sopenharmony_ci
4219e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4220e41f4b71Sopenharmony_ci| -------- | -------- |
4221e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4222e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
4223e41f4b71Sopenharmony_ci| isObject | 表示给定的JSVM_Value是否为Object。 | 
4224e41f4b71Sopenharmony_ci
4225e41f4b71Sopenharmony_ci**返回:**
4226e41f4b71Sopenharmony_ci
4227e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功,这个API不会触发任何异常。
4228e41f4b71Sopenharmony_ci
4229e41f4b71Sopenharmony_ci
4230e41f4b71Sopenharmony_ci### OH_JSVM_IsPromise()
4231e41f4b71Sopenharmony_ci
4232e41f4b71Sopenharmony_ci```
4233e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsPromise (JSVM_Env env, JSVM_Value value, bool * isPromise )
4234e41f4b71Sopenharmony_ci```
4235e41f4b71Sopenharmony_ci
4236e41f4b71Sopenharmony_ci**描述**
4237e41f4b71Sopenharmony_ci
4238e41f4b71Sopenharmony_ci查询Promise是否为原生Promise对象。
4239e41f4b71Sopenharmony_ci
4240e41f4b71Sopenharmony_ci**起始版本:** 11
4241e41f4b71Sopenharmony_ci
4242e41f4b71Sopenharmony_ci**参数:**
4243e41f4b71Sopenharmony_ci
4244e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4245e41f4b71Sopenharmony_ci| -------- | -------- |
4246e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4247e41f4b71Sopenharmony_ci| value | 待检查的值。 | 
4248e41f4b71Sopenharmony_ci| isPromise | 表示是否为原生Promise对象(即底层引擎创建的promise对象)的标志。 | 
4249e41f4b71Sopenharmony_ci
4250e41f4b71Sopenharmony_ci**返回:**
4251e41f4b71Sopenharmony_ci
4252e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4253e41f4b71Sopenharmony_ci
4254e41f4b71Sopenharmony_ci
4255e41f4b71Sopenharmony_ci### OH_JSVM_IsRegExp()
4256e41f4b71Sopenharmony_ci
4257e41f4b71Sopenharmony_ci```
4258e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsRegExp (JSVM_Env env, JSVM_Value value, bool * result )
4259e41f4b71Sopenharmony_ci```
4260e41f4b71Sopenharmony_ci
4261e41f4b71Sopenharmony_ci**描述**
4262e41f4b71Sopenharmony_ci
4263e41f4b71Sopenharmony_ci此API检查传入的值是否为JavaScript RegExp对象。
4264e41f4b71Sopenharmony_ci
4265e41f4b71Sopenharmony_ci**起始版本:** 12
4266e41f4b71Sopenharmony_ci
4267e41f4b71Sopenharmony_ci**参数:**
4268e41f4b71Sopenharmony_ci
4269e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4270e41f4b71Sopenharmony_ci| -------- | -------- |
4271e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4272e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
4273e41f4b71Sopenharmony_ci| result | 表示给定的JSVM_Value是否为JavaScript RegExp对象。 | 
4274e41f4b71Sopenharmony_ci
4275e41f4b71Sopenharmony_ci**返回:**
4276e41f4b71Sopenharmony_ci
4277e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4278e41f4b71Sopenharmony_ci
4279e41f4b71Sopenharmony_ci
4280e41f4b71Sopenharmony_ci### OH_JSVM_IsSet()
4281e41f4b71Sopenharmony_ci
4282e41f4b71Sopenharmony_ci```
4283e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsSet (JSVM_Env env, JSVM_Value value, bool * isSet )
4284e41f4b71Sopenharmony_ci```
4285e41f4b71Sopenharmony_ci
4286e41f4b71Sopenharmony_ci**描述**
4287e41f4b71Sopenharmony_ci
4288e41f4b71Sopenharmony_ci判断给定的对象是否是Set类型。
4289e41f4b71Sopenharmony_ci
4290e41f4b71Sopenharmony_ci**起始版本:** 12
4291e41f4b71Sopenharmony_ci
4292e41f4b71Sopenharmony_ci**参数:**
4293e41f4b71Sopenharmony_ci
4294e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4295e41f4b71Sopenharmony_ci| -------- | -------- |
4296e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4297e41f4b71Sopenharmony_ci| value | 待检查的对象。 | 
4298e41f4b71Sopenharmony_ci| isSet | 给定的对象是否是Set类型。 | 
4299e41f4b71Sopenharmony_ci
4300e41f4b71Sopenharmony_ci**返回:**
4301e41f4b71Sopenharmony_ci
4302e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status JSVM_OK 表示执行成功。
4303e41f4b71Sopenharmony_ci
4304e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示输入参数不合法。
4305e41f4b71Sopenharmony_ci
4306e41f4b71Sopenharmony_ci
4307e41f4b71Sopenharmony_ci### OH_JSVM_IsString()
4308e41f4b71Sopenharmony_ci
4309e41f4b71Sopenharmony_ci```
4310e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsString (JSVM_Env env, JSVM_Value value, bool * isString )
4311e41f4b71Sopenharmony_ci```
4312e41f4b71Sopenharmony_ci
4313e41f4b71Sopenharmony_ci**描述**
4314e41f4b71Sopenharmony_ci
4315e41f4b71Sopenharmony_ci此API检查传入的值是否为String。 这相当于JS中的‘typeof value === 'string’`。
4316e41f4b71Sopenharmony_ci
4317e41f4b71Sopenharmony_ci**起始版本:** 12
4318e41f4b71Sopenharmony_ci
4319e41f4b71Sopenharmony_ci**参数:**
4320e41f4b71Sopenharmony_ci
4321e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4322e41f4b71Sopenharmony_ci| -------- | -------- |
4323e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4324e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
4325e41f4b71Sopenharmony_ci| isString | 表示给定的JSVM_Value是否为String。 | 
4326e41f4b71Sopenharmony_ci
4327e41f4b71Sopenharmony_ci**返回:**
4328e41f4b71Sopenharmony_ci
4329e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功,这个API不会触发任何异常。
4330e41f4b71Sopenharmony_ci
4331e41f4b71Sopenharmony_ci
4332e41f4b71Sopenharmony_ci### OH_JSVM_IsSymbol()
4333e41f4b71Sopenharmony_ci
4334e41f4b71Sopenharmony_ci```
4335e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsSymbol (JSVM_Env env, JSVM_Value value, bool * isSymbol )
4336e41f4b71Sopenharmony_ci```
4337e41f4b71Sopenharmony_ci
4338e41f4b71Sopenharmony_ci**描述**
4339e41f4b71Sopenharmony_ci
4340e41f4b71Sopenharmony_ci此API检查传入的值是否为Symbol。 这相当于JS中的‘typeof value === 'symbol’`。
4341e41f4b71Sopenharmony_ci
4342e41f4b71Sopenharmony_ci**起始版本:** 12
4343e41f4b71Sopenharmony_ci
4344e41f4b71Sopenharmony_ci**参数:**
4345e41f4b71Sopenharmony_ci
4346e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4347e41f4b71Sopenharmony_ci| -------- | -------- |
4348e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4349e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
4350e41f4b71Sopenharmony_ci| isSymbol | 表示给定的JSVM_Value是否为Symbol。 | 
4351e41f4b71Sopenharmony_ci
4352e41f4b71Sopenharmony_ci**返回:**
4353e41f4b71Sopenharmony_ci
4354e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功,这个API不会触发任何异常。
4355e41f4b71Sopenharmony_ci
4356e41f4b71Sopenharmony_ci
4357e41f4b71Sopenharmony_ci### OH_JSVM_IsTypedarray()
4358e41f4b71Sopenharmony_ci
4359e41f4b71Sopenharmony_ci```
4360e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsTypedarray (JSVM_Env env, JSVM_Value value, bool * result )
4361e41f4b71Sopenharmony_ci```
4362e41f4b71Sopenharmony_ci
4363e41f4b71Sopenharmony_ci**描述**
4364e41f4b71Sopenharmony_ci
4365e41f4b71Sopenharmony_ci检查传入的Object是否为类型化数组。
4366e41f4b71Sopenharmony_ci
4367e41f4b71Sopenharmony_ci**起始版本:** 11
4368e41f4b71Sopenharmony_ci
4369e41f4b71Sopenharmony_ci**参数:**
4370e41f4b71Sopenharmony_ci
4371e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4372e41f4b71Sopenharmony_ci| -------- | -------- |
4373e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4374e41f4b71Sopenharmony_ci| value | 待检查的JavaScript值。 | 
4375e41f4b71Sopenharmony_ci| result | 给定的JSVM_Value是否代表TypedArray。 | 
4376e41f4b71Sopenharmony_ci
4377e41f4b71Sopenharmony_ci**返回:**
4378e41f4b71Sopenharmony_ci
4379e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4380e41f4b71Sopenharmony_ci
4381e41f4b71Sopenharmony_ci
4382e41f4b71Sopenharmony_ci### OH_JSVM_IsUndefined()
4383e41f4b71Sopenharmony_ci
4384e41f4b71Sopenharmony_ci```
4385e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsUndefined (JSVM_Env env, JSVM_Value value, bool * isUndefined )
4386e41f4b71Sopenharmony_ci```
4387e41f4b71Sopenharmony_ci
4388e41f4b71Sopenharmony_ci**描述**
4389e41f4b71Sopenharmony_ci
4390e41f4b71Sopenharmony_ci此API检查传入的值是否为Undefined。 这相当于JS中的value === undefined。
4391e41f4b71Sopenharmony_ci
4392e41f4b71Sopenharmony_ci**起始版本:** 12
4393e41f4b71Sopenharmony_ci
4394e41f4b71Sopenharmony_ci**参数:**
4395e41f4b71Sopenharmony_ci
4396e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4397e41f4b71Sopenharmony_ci| -------- | -------- |
4398e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4399e41f4b71Sopenharmony_ci| value | 待检查的JSVM_Value。 | 
4400e41f4b71Sopenharmony_ci| isUndefined | 表示给定的JSVM_Value是否为Undefined。 | 
4401e41f4b71Sopenharmony_ci
4402e41f4b71Sopenharmony_ci**返回:**
4403e41f4b71Sopenharmony_ci
4404e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功,这个API不会触发任何异常。
4405e41f4b71Sopenharmony_ci
4406e41f4b71Sopenharmony_ci
4407e41f4b71Sopenharmony_ci### OH_JSVM_IsWasmModuleObject()
4408e41f4b71Sopenharmony_ci
4409e41f4b71Sopenharmony_ci```
4410e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_IsWasmModuleObject (JSVM_Env env, JSVM_Value value, bool * result )
4411e41f4b71Sopenharmony_ci```
4412e41f4b71Sopenharmony_ci
4413e41f4b71Sopenharmony_ci**描述**
4414e41f4b71Sopenharmony_ci
4415e41f4b71Sopenharmony_ci判断给定的 JSVM_Value 是否是一个 WebAssembly 模块。
4416e41f4b71Sopenharmony_ci
4417e41f4b71Sopenharmony_ci**起始版本:** 12
4418e41f4b71Sopenharmony_ci
4419e41f4b71Sopenharmony_ci**参数:**
4420e41f4b71Sopenharmony_ci
4421e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4422e41f4b71Sopenharmony_ci| -------- | -------- |
4423e41f4b71Sopenharmony_ci| env | 调用 JSVM-API 的环境。 | 
4424e41f4b71Sopenharmony_ci| value | 待检查的 JavaScript 值。 | 
4425e41f4b71Sopenharmony_ci| result | 输出参数,表示给定的值是否是一个 WebAssembly 模块。 | 
4426e41f4b71Sopenharmony_ci
4427e41f4b71Sopenharmony_ci**返回:**
4428e41f4b71Sopenharmony_ci
4429e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4430e41f4b71Sopenharmony_ci
4431e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入了空指针参数。
4432e41f4b71Sopenharmony_ci
4433e41f4b71Sopenharmony_ci
4434e41f4b71Sopenharmony_ci### OH_JSVM_JsonParse()
4435e41f4b71Sopenharmony_ci
4436e41f4b71Sopenharmony_ci```
4437e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_JsonParse (JSVM_Env env, JSVM_Value jsonString, JSVM_Value * result )
4438e41f4b71Sopenharmony_ci```
4439e41f4b71Sopenharmony_ci
4440e41f4b71Sopenharmony_ci**描述**
4441e41f4b71Sopenharmony_ci
4442e41f4b71Sopenharmony_ci解析JSON字符串,并返回成功解析的值。
4443e41f4b71Sopenharmony_ci
4444e41f4b71Sopenharmony_ci**起始版本:** 11
4445e41f4b71Sopenharmony_ci
4446e41f4b71Sopenharmony_ci**参数:**
4447e41f4b71Sopenharmony_ci
4448e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4449e41f4b71Sopenharmony_ci| -------- | -------- |
4450e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4451e41f4b71Sopenharmony_ci| jsonString | 待解析的字符串。 | 
4452e41f4b71Sopenharmony_ci| result | 成功解析的值。 | 
4453e41f4b71Sopenharmony_ci
4454e41f4b71Sopenharmony_ci**返回:**
4455e41f4b71Sopenharmony_ci
4456e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4457e41f4b71Sopenharmony_ci
4458e41f4b71Sopenharmony_ciJSVM_STRING_EXPECTED 表示传入的参数不是string类型。
4459e41f4b71Sopenharmony_ci
4460e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
4461e41f4b71Sopenharmony_ci
4462e41f4b71Sopenharmony_ci
4463e41f4b71Sopenharmony_ci### OH_JSVM_JsonStringify()
4464e41f4b71Sopenharmony_ci
4465e41f4b71Sopenharmony_ci```
4466e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_JsonStringify (JSVM_Env env, JSVM_Value jsonObject, JSVM_Value * result )
4467e41f4b71Sopenharmony_ci```
4468e41f4b71Sopenharmony_ci
4469e41f4b71Sopenharmony_ci**描述**
4470e41f4b71Sopenharmony_ci
4471e41f4b71Sopenharmony_ci将对象字符串化,并返回成功转换后的字符串。
4472e41f4b71Sopenharmony_ci
4473e41f4b71Sopenharmony_ci**起始版本:** 11
4474e41f4b71Sopenharmony_ci
4475e41f4b71Sopenharmony_ci**参数:**
4476e41f4b71Sopenharmony_ci
4477e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4478e41f4b71Sopenharmony_ci| -------- | -------- |
4479e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4480e41f4b71Sopenharmony_ci| jsonObject | 待字符串化的对象。 | 
4481e41f4b71Sopenharmony_ci| result | 成功转换后返回的字符串。 | 
4482e41f4b71Sopenharmony_ci
4483e41f4b71Sopenharmony_ci**返回:**
4484e41f4b71Sopenharmony_ci
4485e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4486e41f4b71Sopenharmony_ci
4487e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
4488e41f4b71Sopenharmony_ci
4489e41f4b71Sopenharmony_ci
4490e41f4b71Sopenharmony_ci### OH_JSVM_MemoryPressureNotification()
4491e41f4b71Sopenharmony_ci
4492e41f4b71Sopenharmony_ci```
4493e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_MemoryPressureNotification (JSVM_Env env, JSVM_MemoryPressureLevel level )
4494e41f4b71Sopenharmony_ci```
4495e41f4b71Sopenharmony_ci
4496e41f4b71Sopenharmony_ci**描述**
4497e41f4b71Sopenharmony_ci
4498e41f4b71Sopenharmony_ci通知虚拟机系统内存不足并有选择地触发垃圾回收。
4499e41f4b71Sopenharmony_ci
4500e41f4b71Sopenharmony_ci**起始版本:** 11
4501e41f4b71Sopenharmony_ci
4502e41f4b71Sopenharmony_ci**参数:**
4503e41f4b71Sopenharmony_ci
4504e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4505e41f4b71Sopenharmony_ci| -------- | -------- |
4506e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4507e41f4b71Sopenharmony_ci| level | 要为当前虚拟机设置的内存压力等级。 | 
4508e41f4b71Sopenharmony_ci
4509e41f4b71Sopenharmony_ci**返回:**
4510e41f4b71Sopenharmony_ci
4511e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4512e41f4b71Sopenharmony_ci
4513e41f4b71Sopenharmony_ci
4514e41f4b71Sopenharmony_ci### OH_JSVM_NewInstance()
4515e41f4b71Sopenharmony_ci
4516e41f4b71Sopenharmony_ci```
4517e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_NewInstance (JSVM_Env env, JSVM_Value constructor, size_t argc, const JSVM_Value * argv, JSVM_Value * result )
4518e41f4b71Sopenharmony_ci```
4519e41f4b71Sopenharmony_ci
4520e41f4b71Sopenharmony_ci**描述**
4521e41f4b71Sopenharmony_ci
4522e41f4b71Sopenharmony_ci使用给定的JSVM_Value表示的构造函数来实例化新的JavaScript值。
4523e41f4b71Sopenharmony_ci
4524e41f4b71Sopenharmony_ci**起始版本:** 11
4525e41f4b71Sopenharmony_ci
4526e41f4b71Sopenharmony_ci**参数:**
4527e41f4b71Sopenharmony_ci
4528e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4529e41f4b71Sopenharmony_ci| -------- | -------- |
4530e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4531e41f4b71Sopenharmony_ci| constructor | 表示将作为构造函数调用的JavaScript函数。 | 
4532e41f4b71Sopenharmony_ci| argc | argv数组中的元素个数。 | 
4533e41f4b71Sopenharmony_ci| argv | JavaScript值数组。其中JSVM_Value表示构造函数的参数。 如果argc为零,则可以通过传入NULL来忽略此参数。 | 
4534e41f4b71Sopenharmony_ci| result | 表示返回的JavaScript对象, 在本例中是构造的对象。 | 
4535e41f4b71Sopenharmony_ci
4536e41f4b71Sopenharmony_ci**返回:**
4537e41f4b71Sopenharmony_ci
4538e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4539e41f4b71Sopenharmony_ci
4540e41f4b71Sopenharmony_ciJSVM_PENDING_EXCEPTION 表示执行的过程中产生了JS异常。
4541e41f4b71Sopenharmony_ci
4542e41f4b71Sopenharmony_ci
4543e41f4b71Sopenharmony_ci### OH_JSVM_ObjectFreeze()
4544e41f4b71Sopenharmony_ci
4545e41f4b71Sopenharmony_ci```
4546e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ObjectFreeze (JSVM_Env env, JSVM_Value object )
4547e41f4b71Sopenharmony_ci```
4548e41f4b71Sopenharmony_ci
4549e41f4b71Sopenharmony_ci**描述**
4550e41f4b71Sopenharmony_ci
4551e41f4b71Sopenharmony_ci冻结指定的对象。这样可以防止为其添加新的属性、删除现有属性、更改现有属性的 可枚举性、可配置性或可写性、或者更改现有属性的值。它还可以防止改变对象的原型。
4552e41f4b71Sopenharmony_ci
4553e41f4b71Sopenharmony_ci**起始版本:** 11
4554e41f4b71Sopenharmony_ci
4555e41f4b71Sopenharmony_ci**参数:**
4556e41f4b71Sopenharmony_ci
4557e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4558e41f4b71Sopenharmony_ci| -------- | -------- |
4559e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4560e41f4b71Sopenharmony_ci| object | 待冻结的对象。 | 
4561e41f4b71Sopenharmony_ci
4562e41f4b71Sopenharmony_ci**返回:**
4563e41f4b71Sopenharmony_ci
4564e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4565e41f4b71Sopenharmony_ci
4566e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
4567e41f4b71Sopenharmony_ci
4568e41f4b71Sopenharmony_ci
4569e41f4b71Sopenharmony_ci### OH_JSVM_ObjectGetPrototypeOf()
4570e41f4b71Sopenharmony_ci
4571e41f4b71Sopenharmony_ci```
4572e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ObjectGetPrototypeOf (JSVM_Env env, JSVM_Value object, JSVM_Value * result )
4573e41f4b71Sopenharmony_ci```
4574e41f4b71Sopenharmony_ci
4575e41f4b71Sopenharmony_ci**描述**
4576e41f4b71Sopenharmony_ci
4577e41f4b71Sopenharmony_ci获取JavaScript object的原型。
4578e41f4b71Sopenharmony_ci
4579e41f4b71Sopenharmony_ci**起始版本:** 12
4580e41f4b71Sopenharmony_ci
4581e41f4b71Sopenharmony_ci**参数:**
4582e41f4b71Sopenharmony_ci
4583e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4584e41f4b71Sopenharmony_ci| -------- | -------- |
4585e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4586e41f4b71Sopenharmony_ci| object | 表示待返回其原型的JavaScript object。 | 
4587e41f4b71Sopenharmony_ci| result | 表示给定对象的原型。 | 
4588e41f4b71Sopenharmony_ci
4589e41f4b71Sopenharmony_ci**返回:**
4590e41f4b71Sopenharmony_ci
4591e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status JSVM_OK 表示执行成功。
4592e41f4b71Sopenharmony_ci
4593e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示输入参数不合法。
4594e41f4b71Sopenharmony_ci
4595e41f4b71Sopenharmony_ci**JSVM_PENDING_EXCPTION** 表示API在运行时抛出异常。
4596e41f4b71Sopenharmony_ci
4597e41f4b71Sopenharmony_ci
4598e41f4b71Sopenharmony_ci### OH_JSVM_ObjectSeal()
4599e41f4b71Sopenharmony_ci
4600e41f4b71Sopenharmony_ci```
4601e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ObjectSeal (JSVM_Env env, JSVM_Value object )
4602e41f4b71Sopenharmony_ci```
4603e41f4b71Sopenharmony_ci
4604e41f4b71Sopenharmony_ci**描述**
4605e41f4b71Sopenharmony_ci
4606e41f4b71Sopenharmony_ci封装指定的对象。这样可以防止为其添加新的属性并且将所有现有属性标记为不可配置。
4607e41f4b71Sopenharmony_ci
4608e41f4b71Sopenharmony_ci**起始版本:** 11
4609e41f4b71Sopenharmony_ci
4610e41f4b71Sopenharmony_ci**参数:**
4611e41f4b71Sopenharmony_ci
4612e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4613e41f4b71Sopenharmony_ci| -------- | -------- |
4614e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4615e41f4b71Sopenharmony_ci| object | 待封装的对象。 | 
4616e41f4b71Sopenharmony_ci
4617e41f4b71Sopenharmony_ci**返回:**
4618e41f4b71Sopenharmony_ci
4619e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4620e41f4b71Sopenharmony_ci
4621e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
4622e41f4b71Sopenharmony_ci
4623e41f4b71Sopenharmony_ci
4624e41f4b71Sopenharmony_ci### OH_JSVM_ObjectSetPrototypeOf()
4625e41f4b71Sopenharmony_ci
4626e41f4b71Sopenharmony_ci```
4627e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ObjectSetPrototypeOf (JSVM_Env env, JSVM_Value object, JSVM_Value prototype )
4628e41f4b71Sopenharmony_ci```
4629e41f4b71Sopenharmony_ci
4630e41f4b71Sopenharmony_ci**描述**
4631e41f4b71Sopenharmony_ci
4632e41f4b71Sopenharmony_ci设置给定的JavaScript object的原型。
4633e41f4b71Sopenharmony_ci
4634e41f4b71Sopenharmony_ci**起始版本:** 12
4635e41f4b71Sopenharmony_ci
4636e41f4b71Sopenharmony_ci**参数:**
4637e41f4b71Sopenharmony_ci
4638e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4639e41f4b71Sopenharmony_ci| -------- | -------- |
4640e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4641e41f4b71Sopenharmony_ci| object | 表示需要设置原型的JavaScript object。 | 
4642e41f4b71Sopenharmony_ci| prototype | 对象原型。 | 
4643e41f4b71Sopenharmony_ci
4644e41f4b71Sopenharmony_ci**返回:**
4645e41f4b71Sopenharmony_ci
4646e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status JSVM_OK 表示执行成功。
4647e41f4b71Sopenharmony_ci
4648e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示输入参数不合法。
4649e41f4b71Sopenharmony_ci
4650e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示设置原型失败。如循环设置原型时,会触发该失败。
4651e41f4b71Sopenharmony_ci
4652e41f4b71Sopenharmony_ci**JSVM_PENDING_EXCPTION** 表示API在运行时抛出异常。
4653e41f4b71Sopenharmony_ci
4654e41f4b71Sopenharmony_ci
4655e41f4b71Sopenharmony_ci### OH_JSVM_OpenEnvScope()
4656e41f4b71Sopenharmony_ci
4657e41f4b71Sopenharmony_ci```
4658e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_OpenEnvScope (JSVM_Env env, JSVM_EnvScope * result )
4659e41f4b71Sopenharmony_ci```
4660e41f4b71Sopenharmony_ci
4661e41f4b71Sopenharmony_ci**描述**
4662e41f4b71Sopenharmony_ci
4663e41f4b71Sopenharmony_ci打开一个新的环境作用域。
4664e41f4b71Sopenharmony_ci
4665e41f4b71Sopenharmony_ci**起始版本:** 11
4666e41f4b71Sopenharmony_ci
4667e41f4b71Sopenharmony_ci**参数:**
4668e41f4b71Sopenharmony_ci
4669e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4670e41f4b71Sopenharmony_ci| -------- | -------- |
4671e41f4b71Sopenharmony_ci| env | 目标环境,JSVM-API接口将在该环境下调用。 | 
4672e41f4b71Sopenharmony_ci| result | 新的环境作用域。 | 
4673e41f4b71Sopenharmony_ci
4674e41f4b71Sopenharmony_ci**返回:**
4675e41f4b71Sopenharmony_ci
4676e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4677e41f4b71Sopenharmony_ci
4678e41f4b71Sopenharmony_ci
4679e41f4b71Sopenharmony_ci### OH_JSVM_OpenEscapableHandleScope()
4680e41f4b71Sopenharmony_ci
4681e41f4b71Sopenharmony_ci```
4682e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_OpenEscapableHandleScope (JSVM_Env env, JSVM_EscapableHandleScope * result )
4683e41f4b71Sopenharmony_ci```
4684e41f4b71Sopenharmony_ci
4685e41f4b71Sopenharmony_ci**描述**
4686e41f4b71Sopenharmony_ci
4687e41f4b71Sopenharmony_ci会打开一个新作用域,从中可以将一个对象提升到外部作用域。
4688e41f4b71Sopenharmony_ci
4689e41f4b71Sopenharmony_ci**起始版本:** 11
4690e41f4b71Sopenharmony_ci
4691e41f4b71Sopenharmony_ci**参数:**
4692e41f4b71Sopenharmony_ci
4693e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4694e41f4b71Sopenharmony_ci| -------- | -------- |
4695e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4696e41f4b71Sopenharmony_ci| result | 代表新作用域。 | 
4697e41f4b71Sopenharmony_ci
4698e41f4b71Sopenharmony_ci**返回:**
4699e41f4b71Sopenharmony_ci
4700e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4701e41f4b71Sopenharmony_ci
4702e41f4b71Sopenharmony_ci
4703e41f4b71Sopenharmony_ci### OH_JSVM_OpenHandleScope()
4704e41f4b71Sopenharmony_ci
4705e41f4b71Sopenharmony_ci```
4706e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_OpenHandleScope (JSVM_Env env, JSVM_HandleScope * result )
4707e41f4b71Sopenharmony_ci```
4708e41f4b71Sopenharmony_ci
4709e41f4b71Sopenharmony_ci**描述**
4710e41f4b71Sopenharmony_ci
4711e41f4b71Sopenharmony_ci开辟了一个新的作用域。
4712e41f4b71Sopenharmony_ci
4713e41f4b71Sopenharmony_ci**起始版本:** 11
4714e41f4b71Sopenharmony_ci
4715e41f4b71Sopenharmony_ci**参数:**
4716e41f4b71Sopenharmony_ci
4717e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4718e41f4b71Sopenharmony_ci| -------- | -------- |
4719e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4720e41f4b71Sopenharmony_ci| result | 代表新作用域。 | 
4721e41f4b71Sopenharmony_ci
4722e41f4b71Sopenharmony_ci**返回:**
4723e41f4b71Sopenharmony_ci
4724e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4725e41f4b71Sopenharmony_ci
4726e41f4b71Sopenharmony_ci
4727e41f4b71Sopenharmony_ci### OH_JSVM_OpenInspector()
4728e41f4b71Sopenharmony_ci
4729e41f4b71Sopenharmony_ci```
4730e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_OpenInspector (JSVM_Env env, const char * host, uint16_t port )
4731e41f4b71Sopenharmony_ci```
4732e41f4b71Sopenharmony_ci
4733e41f4b71Sopenharmony_ci**描述**
4734e41f4b71Sopenharmony_ci
4735e41f4b71Sopenharmony_ci在指定的主机和端口上激活inspector,将用来调试JS代码。
4736e41f4b71Sopenharmony_ci
4737e41f4b71Sopenharmony_ci**起始版本:** 12
4738e41f4b71Sopenharmony_ci
4739e41f4b71Sopenharmony_ci**参数:**
4740e41f4b71Sopenharmony_ci
4741e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4742e41f4b71Sopenharmony_ci| -------- | -------- |
4743e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4744e41f4b71Sopenharmony_ci| host | 要监听inspector连接的主机IP地址。 | 
4745e41f4b71Sopenharmony_ci| port | 要监听inspector连接的端口。 | 
4746e41f4b71Sopenharmony_ci
4747e41f4b71Sopenharmony_ci**返回:**
4748e41f4b71Sopenharmony_ci
4749e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4750e41f4b71Sopenharmony_ci
4751e41f4b71Sopenharmony_ciJSVM_PENDING_EXCEPTION 表示执行的过程中产生了JS异常。
4752e41f4b71Sopenharmony_ci
4753e41f4b71Sopenharmony_ci
4754e41f4b71Sopenharmony_ci### OH_JSVM_OpenInspectorWithName()
4755e41f4b71Sopenharmony_ci
4756e41f4b71Sopenharmony_ci```
4757e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_OpenInspectorWithName (JSVM_Env env, int pid, const char * name )
4758e41f4b71Sopenharmony_ci```
4759e41f4b71Sopenharmony_ci
4760e41f4b71Sopenharmony_ci**描述**
4761e41f4b71Sopenharmony_ci
4762e41f4b71Sopenharmony_ci此函数打开一个命名为传入 name 的 inspector,为其打开对应 pid 的 unix domain 端口.
4763e41f4b71Sopenharmony_ci
4764e41f4b71Sopenharmony_ci**起始版本:** 12
4765e41f4b71Sopenharmony_ci
4766e41f4b71Sopenharmony_ci**参数:**
4767e41f4b71Sopenharmony_ci
4768e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4769e41f4b71Sopenharmony_ci| -------- | -------- |
4770e41f4b71Sopenharmony_ci| env | 调用该API的环境. | 
4771e41f4b71Sopenharmony_ci| pid | 用于标识 inspector 连接的进程ID. | 
4772e41f4b71Sopenharmony_ci| name | inspector 的名字. 如果传入nullptr, 则默认名称为jsvm. | 
4773e41f4b71Sopenharmony_ci
4774e41f4b71Sopenharmony_ci**返回:**
4775e41f4b71Sopenharmony_ci
4776e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status JSVM_OK 表示执行成功。
4777e41f4b71Sopenharmony_ci
4778e41f4b71Sopenharmony_ciJSVM_PENDING_EXCEPTION 表示发生了异常.
4779e41f4b71Sopenharmony_ci
4780e41f4b71Sopenharmony_ci
4781e41f4b71Sopenharmony_ci### OH_JSVM_OpenVMScope()
4782e41f4b71Sopenharmony_ci
4783e41f4b71Sopenharmony_ci```
4784e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_OpenVMScope (JSVM_VM vm, JSVM_VMScope * result )
4785e41f4b71Sopenharmony_ci```
4786e41f4b71Sopenharmony_ci
4787e41f4b71Sopenharmony_ci**描述**
4788e41f4b71Sopenharmony_ci
4789e41f4b71Sopenharmony_ci为虚拟机实例打开一个新的虚拟机作用域。
4790e41f4b71Sopenharmony_ci
4791e41f4b71Sopenharmony_ci**起始版本:** 11
4792e41f4b71Sopenharmony_ci
4793e41f4b71Sopenharmony_ci**参数:**
4794e41f4b71Sopenharmony_ci
4795e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4796e41f4b71Sopenharmony_ci| -------- | -------- |
4797e41f4b71Sopenharmony_ci| vm | 目标虚拟机实例。 | 
4798e41f4b71Sopenharmony_ci| result | 新的虚拟机作用域。 | 
4799e41f4b71Sopenharmony_ci
4800e41f4b71Sopenharmony_ci**返回:**
4801e41f4b71Sopenharmony_ci
4802e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4803e41f4b71Sopenharmony_ci
4804e41f4b71Sopenharmony_ci
4805e41f4b71Sopenharmony_ci### OH_JSVM_PerformMicrotaskCheckpoint()
4806e41f4b71Sopenharmony_ci
4807e41f4b71Sopenharmony_ci```
4808e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_PerformMicrotaskCheckpoint (JSVM_VM vm)
4809e41f4b71Sopenharmony_ci```
4810e41f4b71Sopenharmony_ci
4811e41f4b71Sopenharmony_ci**描述**
4812e41f4b71Sopenharmony_ci
4813e41f4b71Sopenharmony_ci检查队列中是否有微任务等待,如果存在则执行它们。
4814e41f4b71Sopenharmony_ci
4815e41f4b71Sopenharmony_ci**起始版本:** 12
4816e41f4b71Sopenharmony_ci
4817e41f4b71Sopenharmony_ci**参数:**
4818e41f4b71Sopenharmony_ci
4819e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4820e41f4b71Sopenharmony_ci| -------- | -------- |
4821e41f4b71Sopenharmony_ci| env | 要检查微任务的虚拟机实例。 | 
4822e41f4b71Sopenharmony_ci
4823e41f4b71Sopenharmony_ci**返回:**
4824e41f4b71Sopenharmony_ci
4825e41f4b71Sopenharmony_ci返回JSVM函数结果代码。 JSVM_OK 表示执行成功。
4826e41f4b71Sopenharmony_ci
4827e41f4b71Sopenharmony_ci
4828e41f4b71Sopenharmony_ci### OH_JSVM_PumpMessageLoop()
4829e41f4b71Sopenharmony_ci
4830e41f4b71Sopenharmony_ci```
4831e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_PumpMessageLoop (JSVM_VM vm, bool * result )
4832e41f4b71Sopenharmony_ci```
4833e41f4b71Sopenharmony_ci
4834e41f4b71Sopenharmony_ci**描述**
4835e41f4b71Sopenharmony_ci
4836e41f4b71Sopenharmony_ci启动虚拟机内任务队列的运行。这个任务队列可以通过外部事件循环来执行。
4837e41f4b71Sopenharmony_ci
4838e41f4b71Sopenharmony_ci**起始版本:** 12
4839e41f4b71Sopenharmony_ci
4840e41f4b71Sopenharmony_ci**参数:**
4841e41f4b71Sopenharmony_ci
4842e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4843e41f4b71Sopenharmony_ci| -------- | -------- |
4844e41f4b71Sopenharmony_ci| env | 启动任务队列的虚拟机实例。 | 
4845e41f4b71Sopenharmony_ci| result | 表示任务队列是否成功启动。 | 
4846e41f4b71Sopenharmony_ci
4847e41f4b71Sopenharmony_ci**返回:**
4848e41f4b71Sopenharmony_ci
4849e41f4b71Sopenharmony_ci返回JSVM函数结果代码。 JSVM_OK 表示执行成功。
4850e41f4b71Sopenharmony_ci
4851e41f4b71Sopenharmony_ci
4852e41f4b71Sopenharmony_ci### OH_JSVM_ReferenceRef()
4853e41f4b71Sopenharmony_ci
4854e41f4b71Sopenharmony_ci```
4855e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ReferenceRef (JSVM_Env env, JSVM_Ref ref, uint32_t * result )
4856e41f4b71Sopenharmony_ci```
4857e41f4b71Sopenharmony_ci
4858e41f4b71Sopenharmony_ci**描述**
4859e41f4b71Sopenharmony_ci
4860e41f4b71Sopenharmony_ci增加传入引用的引用计数并返回生成的引用计数。
4861e41f4b71Sopenharmony_ci
4862e41f4b71Sopenharmony_ci**起始版本:** 11
4863e41f4b71Sopenharmony_ci
4864e41f4b71Sopenharmony_ci**参数:**
4865e41f4b71Sopenharmony_ci
4866e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4867e41f4b71Sopenharmony_ci| -------- | -------- |
4868e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4869e41f4b71Sopenharmony_ci| ref | 传入的引用,其引用计数将增加。 | 
4870e41f4b71Sopenharmony_ci| result | 新的引用计数。 | 
4871e41f4b71Sopenharmony_ci
4872e41f4b71Sopenharmony_ci**返回:**
4873e41f4b71Sopenharmony_ci
4874e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4875e41f4b71Sopenharmony_ci
4876e41f4b71Sopenharmony_ci
4877e41f4b71Sopenharmony_ci### OH_JSVM_ReferenceUnref()
4878e41f4b71Sopenharmony_ci
4879e41f4b71Sopenharmony_ci```
4880e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ReferenceUnref (JSVM_Env env, JSVM_Ref ref, uint32_t * result )
4881e41f4b71Sopenharmony_ci```
4882e41f4b71Sopenharmony_ci
4883e41f4b71Sopenharmony_ci**描述**
4884e41f4b71Sopenharmony_ci
4885e41f4b71Sopenharmony_ci递减传入引用的引用计数并返回生成的引用计数。
4886e41f4b71Sopenharmony_ci
4887e41f4b71Sopenharmony_ci**起始版本:** 11
4888e41f4b71Sopenharmony_ci
4889e41f4b71Sopenharmony_ci**参数:**
4890e41f4b71Sopenharmony_ci
4891e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4892e41f4b71Sopenharmony_ci| -------- | -------- |
4893e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4894e41f4b71Sopenharmony_ci| ref | 将减少其引用计数的JSVM_Ref。 | 
4895e41f4b71Sopenharmony_ci| result | 新的引用计数。 | 
4896e41f4b71Sopenharmony_ci
4897e41f4b71Sopenharmony_ci**返回:**
4898e41f4b71Sopenharmony_ci
4899e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4900e41f4b71Sopenharmony_ci
4901e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示执行失败。
4902e41f4b71Sopenharmony_ci
4903e41f4b71Sopenharmony_ci
4904e41f4b71Sopenharmony_ci### OH_JSVM_RejectDeferred()
4905e41f4b71Sopenharmony_ci
4906e41f4b71Sopenharmony_ci```
4907e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_RejectDeferred (JSVM_Env env, JSVM_Deferred deferred, JSVM_Value rejection )
4908e41f4b71Sopenharmony_ci```
4909e41f4b71Sopenharmony_ci
4910e41f4b71Sopenharmony_ci**描述**
4911e41f4b71Sopenharmony_ci
4912e41f4b71Sopenharmony_ci通过与之关联的延迟对象来拒绝JavaScript Promise。 它只能用于拒绝对应的可用延迟对象的JavaScript Promise。 这意味着Promise必须使用OH_JSVM_CreatePromise()创建,并且 从该调用返回的对象必须保留,才能将其传递给此API。
4913e41f4b71Sopenharmony_ci
4914e41f4b71Sopenharmony_ci**起始版本:** 11
4915e41f4b71Sopenharmony_ci
4916e41f4b71Sopenharmony_ci**参数:**
4917e41f4b71Sopenharmony_ci
4918e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4919e41f4b71Sopenharmony_ci| -------- | -------- |
4920e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4921e41f4b71Sopenharmony_ci| deferred | 要解析其关联promise的延迟对象。 | 
4922e41f4b71Sopenharmony_ci| rejection | 用来拒绝Promise的值。 | 
4923e41f4b71Sopenharmony_ci
4924e41f4b71Sopenharmony_ci**返回:**
4925e41f4b71Sopenharmony_ci
4926e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4927e41f4b71Sopenharmony_ci
4928e41f4b71Sopenharmony_ci
4929e41f4b71Sopenharmony_ci### OH_JSVM_ReleaseCache()
4930e41f4b71Sopenharmony_ci
4931e41f4b71Sopenharmony_ci```
4932e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ReleaseCache (JSVM_Env env, const uint8_t * cacheData, JSVM_CacheType cacheType )
4933e41f4b71Sopenharmony_ci```
4934e41f4b71Sopenharmony_ci
4935e41f4b71Sopenharmony_ci**描述**
4936e41f4b71Sopenharmony_ci
4937e41f4b71Sopenharmony_ci释放给定类型的缓存数据。
4938e41f4b71Sopenharmony_ci
4939e41f4b71Sopenharmony_ci**起始版本:** 12
4940e41f4b71Sopenharmony_ci
4941e41f4b71Sopenharmony_ci**参数:**
4942e41f4b71Sopenharmony_ci
4943e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4944e41f4b71Sopenharmony_ci| -------- | -------- |
4945e41f4b71Sopenharmony_ci| env | 调用 JSVM-API 的环境。 | 
4946e41f4b71Sopenharmony_ci| cacheData | 待释放的缓存数据,重复释放是未定义行为。 | 
4947e41f4b71Sopenharmony_ci| cacheType | 缓存的类型,缓存的生成和释放必须一一对应。 | 
4948e41f4b71Sopenharmony_ci
4949e41f4b71Sopenharmony_ci**返回:**
4950e41f4b71Sopenharmony_ci
4951e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
4952e41f4b71Sopenharmony_ci
4953e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入了空指针参数,或 cacheType 参数不合法。
4954e41f4b71Sopenharmony_ci
4955e41f4b71Sopenharmony_ci
4956e41f4b71Sopenharmony_ci### OH_JSVM_ReleaseScript()
4957e41f4b71Sopenharmony_ci
4958e41f4b71Sopenharmony_ci```
4959e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ReleaseScript (JSVM_Env env, JSVM_Script script )
4960e41f4b71Sopenharmony_ci```
4961e41f4b71Sopenharmony_ci
4962e41f4b71Sopenharmony_ci**描述**
4963e41f4b71Sopenharmony_ci
4964e41f4b71Sopenharmony_ci此函数释放由OH_JSVM_RetainScript保留的脚本,释放后应避免对传入 script 的再次使用.
4965e41f4b71Sopenharmony_ci
4966e41f4b71Sopenharmony_ci**起始版本:** 12
4967e41f4b71Sopenharmony_ci
4968e41f4b71Sopenharmony_ci**参数:**
4969e41f4b71Sopenharmony_ci
4970e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4971e41f4b71Sopenharmony_ci| -------- | -------- |
4972e41f4b71Sopenharmony_ci| env | 调用该API的环境. | 
4973e41f4b71Sopenharmony_ci| script | 包含要释放的脚本的JavaScript字符串. | 
4974e41f4b71Sopenharmony_ci
4975e41f4b71Sopenharmony_ci**返回:**
4976e41f4b71Sopenharmony_ci
4977e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status JSVM_OK 表示执行成功。
4978e41f4b71Sopenharmony_ci
4979e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示脚本为空或未被保存过.
4980e41f4b71Sopenharmony_ci
4981e41f4b71Sopenharmony_ci
4982e41f4b71Sopenharmony_ci### OH_JSVM_RemoveWrap()
4983e41f4b71Sopenharmony_ci
4984e41f4b71Sopenharmony_ci```
4985e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_RemoveWrap (JSVM_Env env, JSVM_Value jsObject, void ** result )
4986e41f4b71Sopenharmony_ci```
4987e41f4b71Sopenharmony_ci
4988e41f4b71Sopenharmony_ci**描述**
4989e41f4b71Sopenharmony_ci
4990e41f4b71Sopenharmony_ci使用OH_JSVM_Wrap()检索先前封装在JavaScript对象js_object中的native实例并移除封装。 如果finalize回调与封装相关联,则当JavaScript对象被垃圾回收时将不再调用它。
4991e41f4b71Sopenharmony_ci
4992e41f4b71Sopenharmony_ci**起始版本:** 11
4993e41f4b71Sopenharmony_ci
4994e41f4b71Sopenharmony_ci**参数:**
4995e41f4b71Sopenharmony_ci
4996e41f4b71Sopenharmony_ci| 名称 | 描述 | 
4997e41f4b71Sopenharmony_ci| -------- | -------- |
4998e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
4999e41f4b71Sopenharmony_ci| jsObject | 与native实例关联的对象。 | 
5000e41f4b71Sopenharmony_ci| result | 指向封装的native实例的指针。 | 
5001e41f4b71Sopenharmony_ci
5002e41f4b71Sopenharmony_ci**返回:**
5003e41f4b71Sopenharmony_ci
5004e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5005e41f4b71Sopenharmony_ci
5006e41f4b71Sopenharmony_ci
5007e41f4b71Sopenharmony_ci### OH_JSVM_ResolveDeferred()
5008e41f4b71Sopenharmony_ci
5009e41f4b71Sopenharmony_ci```
5010e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ResolveDeferred (JSVM_Env env, JSVM_Deferred deferred, JSVM_Value resolution )
5011e41f4b71Sopenharmony_ci```
5012e41f4b71Sopenharmony_ci
5013e41f4b71Sopenharmony_ci**描述**
5014e41f4b71Sopenharmony_ci
5015e41f4b71Sopenharmony_ci通过与之关联的延迟对象来解析JavaScript promise。 它只能用于解析对应的可用的延迟对象的JavaScript Promise。 这意味着Promise必须使用OH_JSVM_CreatePromise()创建,并且 从该调用返回的对象必须保留,才能将其传递给此API。
5016e41f4b71Sopenharmony_ci
5017e41f4b71Sopenharmony_ci**起始版本:** 11
5018e41f4b71Sopenharmony_ci
5019e41f4b71Sopenharmony_ci**参数:**
5020e41f4b71Sopenharmony_ci
5021e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5022e41f4b71Sopenharmony_ci| -------- | -------- |
5023e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5024e41f4b71Sopenharmony_ci| deferred | 要解析其关联promise的延迟对象。 | 
5025e41f4b71Sopenharmony_ci| resolution | 用来解决Promise的值。 | 
5026e41f4b71Sopenharmony_ci
5027e41f4b71Sopenharmony_ci**返回:**
5028e41f4b71Sopenharmony_ci
5029e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5030e41f4b71Sopenharmony_ci
5031e41f4b71Sopenharmony_ci
5032e41f4b71Sopenharmony_ci### OH_JSVM_RetainScript()
5033e41f4b71Sopenharmony_ci
5034e41f4b71Sopenharmony_ci```
5035e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_RetainScript (JSVM_Env env, JSVM_Script script )
5036e41f4b71Sopenharmony_ci```
5037e41f4b71Sopenharmony_ci
5038e41f4b71Sopenharmony_ci**描述**
5039e41f4b71Sopenharmony_ci
5040e41f4b71Sopenharmony_ci持久保存一个JSVM_Script并将其生命周期延长到当前作用域之外.
5041e41f4b71Sopenharmony_ci
5042e41f4b71Sopenharmony_ci**起始版本:** 12
5043e41f4b71Sopenharmony_ci
5044e41f4b71Sopenharmony_ci**参数:**
5045e41f4b71Sopenharmony_ci
5046e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5047e41f4b71Sopenharmony_ci| -------- | -------- |
5048e41f4b71Sopenharmony_ci| env | 调用该API的环境. | 
5049e41f4b71Sopenharmony_ci| script | 包含要持久化保存脚本的JavaScript字符串. | 
5050e41f4b71Sopenharmony_ci
5051e41f4b71Sopenharmony_ci**返回:**
5052e41f4b71Sopenharmony_ci
5053e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status JSVM_OK 表示执行成功。
5054e41f4b71Sopenharmony_ci
5055e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示脚本为空或已被保存过.
5056e41f4b71Sopenharmony_ci
5057e41f4b71Sopenharmony_ci
5058e41f4b71Sopenharmony_ci### OH_JSVM_RunScript()
5059e41f4b71Sopenharmony_ci
5060e41f4b71Sopenharmony_ci```
5061e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_RunScript (JSVM_Env env, JSVM_Script script, JSVM_Value * result )
5062e41f4b71Sopenharmony_ci```
5063e41f4b71Sopenharmony_ci
5064e41f4b71Sopenharmony_ci**描述**
5065e41f4b71Sopenharmony_ci
5066e41f4b71Sopenharmony_ci执行一串JavaScript代码并返回其结果,其中包含以下注意事项: 与eval不同的是,该函数不允许脚本访问当前词法作用域,因此也不允许访问模块作用域, 这意味着require等伪全局变量将不可用。 脚本可以访问全局作用域。 脚本中的函数和var声明将被添加到全局对象。 使用let和const的变量声明将全局可见,但不会被添加到全局对象。 this的值在脚本内是global。
5067e41f4b71Sopenharmony_ci
5068e41f4b71Sopenharmony_ci**起始版本:** 11
5069e41f4b71Sopenharmony_ci
5070e41f4b71Sopenharmony_ci**参数:**
5071e41f4b71Sopenharmony_ci
5072e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5073e41f4b71Sopenharmony_ci| -------- | -------- |
5074e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5075e41f4b71Sopenharmony_ci| script | 包含要执行的脚本的JavaScript字符串。 | 
5076e41f4b71Sopenharmony_ci| result | 执行脚本产生的值。 | 
5077e41f4b71Sopenharmony_ci
5078e41f4b71Sopenharmony_ci**返回:**
5079e41f4b71Sopenharmony_ci
5080e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5081e41f4b71Sopenharmony_ci
5082e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示执行失败。
5083e41f4b71Sopenharmony_ci
5084e41f4b71Sopenharmony_ci
5085e41f4b71Sopenharmony_ci### OH_JSVM_SetElement()
5086e41f4b71Sopenharmony_ci
5087e41f4b71Sopenharmony_ci```
5088e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_SetElement (JSVM_Env env, JSVM_Value object, uint32_t index, JSVM_Value value )
5089e41f4b71Sopenharmony_ci```
5090e41f4b71Sopenharmony_ci
5091e41f4b71Sopenharmony_ci**描述**
5092e41f4b71Sopenharmony_ci
5093e41f4b71Sopenharmony_ci在传入的Object上设置一个元素。
5094e41f4b71Sopenharmony_ci
5095e41f4b71Sopenharmony_ci**起始版本:** 11
5096e41f4b71Sopenharmony_ci
5097e41f4b71Sopenharmony_ci**参数:**
5098e41f4b71Sopenharmony_ci
5099e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5100e41f4b71Sopenharmony_ci| -------- | -------- |
5101e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5102e41f4b71Sopenharmony_ci| object | 待进行属性设置的对象。 | 
5103e41f4b71Sopenharmony_ci| index | 要设置的属性的索引。 | 
5104e41f4b71Sopenharmony_ci| value | 属性值。 | 
5105e41f4b71Sopenharmony_ci
5106e41f4b71Sopenharmony_ci**返回:**
5107e41f4b71Sopenharmony_ci
5108e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5109e41f4b71Sopenharmony_ci
5110e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
5111e41f4b71Sopenharmony_ci
5112e41f4b71Sopenharmony_ci
5113e41f4b71Sopenharmony_ci### OH_JSVM_SetInstanceData()
5114e41f4b71Sopenharmony_ci
5115e41f4b71Sopenharmony_ci```
5116e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_SetInstanceData (JSVM_Env env, void * data, JSVM_Finalize finalizeCb, void * finalizeHint )
5117e41f4b71Sopenharmony_ci```
5118e41f4b71Sopenharmony_ci
5119e41f4b71Sopenharmony_ci**描述**
5120e41f4b71Sopenharmony_ci
5121e41f4b71Sopenharmony_ci将data与当前运行的JSVM环境相关联。后续可以使用OH_JSVM_GetInstanceData()检索data。 通过先前调用OH_JSVM_SetInstanceData()设置的任何与当前运行的JSVM环境相关联的现有数据都将 被覆盖。如果先前提供了finalizeCb,则不会调用它。
5122e41f4b71Sopenharmony_ci
5123e41f4b71Sopenharmony_ci**起始版本:** 11
5124e41f4b71Sopenharmony_ci
5125e41f4b71Sopenharmony_ci**参数:**
5126e41f4b71Sopenharmony_ci
5127e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5128e41f4b71Sopenharmony_ci| -------- | -------- |
5129e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5130e41f4b71Sopenharmony_ci| data | 可用于此实例的绑定的数据项。 | 
5131e41f4b71Sopenharmony_ci| finalizeCb | 销毁环境时调用的函数,该函数接收data以便释放它。 | 
5132e41f4b71Sopenharmony_ci| finalizeHint | 在收集期间传递给最终回调的可选提示。 | 
5133e41f4b71Sopenharmony_ci
5134e41f4b71Sopenharmony_ci**返回:**
5135e41f4b71Sopenharmony_ci
5136e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5137e41f4b71Sopenharmony_ci
5138e41f4b71Sopenharmony_ci
5139e41f4b71Sopenharmony_ci### OH_JSVM_SetNamedProperty()
5140e41f4b71Sopenharmony_ci
5141e41f4b71Sopenharmony_ci```
5142e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_SetNamedProperty (JSVM_Env env, JSVM_Value object, const char * utf8name, JSVM_Value value )
5143e41f4b71Sopenharmony_ci```
5144e41f4b71Sopenharmony_ci
5145e41f4b71Sopenharmony_ci**描述**
5146e41f4b71Sopenharmony_ci
5147e41f4b71Sopenharmony_ci此方法等效于调用OH_JSVM_SetProperty, 其中,通过utf8Name传入的字符串用于创建JSVM_Value。
5148e41f4b71Sopenharmony_ci
5149e41f4b71Sopenharmony_ci**起始版本:** 11
5150e41f4b71Sopenharmony_ci
5151e41f4b71Sopenharmony_ci**参数:**
5152e41f4b71Sopenharmony_ci
5153e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5154e41f4b71Sopenharmony_ci| -------- | -------- |
5155e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5156e41f4b71Sopenharmony_ci| object | 要对其设置属性的对象。 | 
5157e41f4b71Sopenharmony_ci| utf8Name | 要设置的属性的名称。 | 
5158e41f4b71Sopenharmony_ci| value | 属性值。 | 
5159e41f4b71Sopenharmony_ci
5160e41f4b71Sopenharmony_ci**返回:**
5161e41f4b71Sopenharmony_ci
5162e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5163e41f4b71Sopenharmony_ci
5164e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
5165e41f4b71Sopenharmony_ci
5166e41f4b71Sopenharmony_ci
5167e41f4b71Sopenharmony_ci### OH_JSVM_SetProperty()
5168e41f4b71Sopenharmony_ci
5169e41f4b71Sopenharmony_ci```
5170e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_SetProperty (JSVM_Env env, JSVM_Value object, JSVM_Value key, JSVM_Value value )
5171e41f4b71Sopenharmony_ci```
5172e41f4b71Sopenharmony_ci
5173e41f4b71Sopenharmony_ci**描述**
5174e41f4b71Sopenharmony_ci
5175e41f4b71Sopenharmony_ci为传入的object设置一个属性。
5176e41f4b71Sopenharmony_ci
5177e41f4b71Sopenharmony_ci**起始版本:** 11
5178e41f4b71Sopenharmony_ci
5179e41f4b71Sopenharmony_ci**参数:**
5180e41f4b71Sopenharmony_ci
5181e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5182e41f4b71Sopenharmony_ci| -------- | -------- |
5183e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5184e41f4b71Sopenharmony_ci| object | 将进行属性设置的对象。 | 
5185e41f4b71Sopenharmony_ci| key | 待设置的属性名。 | 
5186e41f4b71Sopenharmony_ci| value | 属性值。 | 
5187e41f4b71Sopenharmony_ci
5188e41f4b71Sopenharmony_ci**返回:**
5189e41f4b71Sopenharmony_ci
5190e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5191e41f4b71Sopenharmony_ci
5192e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
5193e41f4b71Sopenharmony_ci
5194e41f4b71Sopenharmony_ci
5195e41f4b71Sopenharmony_ci### OH_JSVM_StartCpuProfiler()
5196e41f4b71Sopenharmony_ci
5197e41f4b71Sopenharmony_ci```
5198e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_StartCpuProfiler (JSVM_VM vm, JSVM_CpuProfiler * result )
5199e41f4b71Sopenharmony_ci```
5200e41f4b71Sopenharmony_ci
5201e41f4b71Sopenharmony_ci**描述**
5202e41f4b71Sopenharmony_ci
5203e41f4b71Sopenharmony_ci创建并启动一个CPU profiler。
5204e41f4b71Sopenharmony_ci
5205e41f4b71Sopenharmony_ci**起始版本:** 12
5206e41f4b71Sopenharmony_ci
5207e41f4b71Sopenharmony_ci**参数:**
5208e41f4b71Sopenharmony_ci
5209e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5210e41f4b71Sopenharmony_ci| -------- | -------- |
5211e41f4b71Sopenharmony_ci| vm | 启动CPU profiler的虚拟机。 | 
5212e41f4b71Sopenharmony_ci| result | 指向CPU profiler的指针。 | 
5213e41f4b71Sopenharmony_ci
5214e41f4b71Sopenharmony_ci**返回:**
5215e41f4b71Sopenharmony_ci
5216e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5217e41f4b71Sopenharmony_ci
5218e41f4b71Sopenharmony_ci
5219e41f4b71Sopenharmony_ci### OH_JSVM_StopCpuProfiler()
5220e41f4b71Sopenharmony_ci
5221e41f4b71Sopenharmony_ci```
5222e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_StopCpuProfiler (JSVM_VM vm, JSVM_CpuProfiler profiler, JSVM_OutputStream stream, void * streamData )
5223e41f4b71Sopenharmony_ci```
5224e41f4b71Sopenharmony_ci
5225e41f4b71Sopenharmony_ci**描述**
5226e41f4b71Sopenharmony_ci
5227e41f4b71Sopenharmony_ci停止CPU profiler并将结果输出到流。
5228e41f4b71Sopenharmony_ci
5229e41f4b71Sopenharmony_ci**起始版本:** 12
5230e41f4b71Sopenharmony_ci
5231e41f4b71Sopenharmony_ci**参数:**
5232e41f4b71Sopenharmony_ci
5233e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5234e41f4b71Sopenharmony_ci| -------- | -------- |
5235e41f4b71Sopenharmony_ci| vm | 启动CPU profiler的虚拟机。 | 
5236e41f4b71Sopenharmony_ci| profiler | 要停止的CPU profiler。 | 
5237e41f4b71Sopenharmony_ci| stream | 接收数据的输出流回调。 | 
5238e41f4b71Sopenharmony_ci| streamData | 传递给输出流回调的可选数据。例如,可以是一个文件流,用来将输出流回调中传递的采样数据写入文件。 | 
5239e41f4b71Sopenharmony_ci
5240e41f4b71Sopenharmony_ci**返回:**
5241e41f4b71Sopenharmony_ci
5242e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5243e41f4b71Sopenharmony_ci
5244e41f4b71Sopenharmony_ci
5245e41f4b71Sopenharmony_ci### OH_JSVM_StrictEquals()
5246e41f4b71Sopenharmony_ci
5247e41f4b71Sopenharmony_ci```
5248e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_StrictEquals (JSVM_Env env, JSVM_Value lhs, JSVM_Value rhs, bool * result )
5249e41f4b71Sopenharmony_ci```
5250e41f4b71Sopenharmony_ci
5251e41f4b71Sopenharmony_ci**描述**
5252e41f4b71Sopenharmony_ci
5253e41f4b71Sopenharmony_ci提供类似调用严格相等算法的行为。
5254e41f4b71Sopenharmony_ci
5255e41f4b71Sopenharmony_ci**起始版本:** 11
5256e41f4b71Sopenharmony_ci
5257e41f4b71Sopenharmony_ci**参数:**
5258e41f4b71Sopenharmony_ci
5259e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5260e41f4b71Sopenharmony_ci| -------- | -------- |
5261e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5262e41f4b71Sopenharmony_ci| lhs | 待检查的JavaScript值。 | 
5263e41f4b71Sopenharmony_ci| rhs | 要检查的JavaScript值。 | 
5264e41f4b71Sopenharmony_ci| result | 表示两个JSVM_Value对象是否相等。 | 
5265e41f4b71Sopenharmony_ci
5266e41f4b71Sopenharmony_ci**返回:**
5267e41f4b71Sopenharmony_ci
5268e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5269e41f4b71Sopenharmony_ci
5270e41f4b71Sopenharmony_ci
5271e41f4b71Sopenharmony_ci### OH_JSVM_SymbolFor()
5272e41f4b71Sopenharmony_ci
5273e41f4b71Sopenharmony_ci```
5274e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_SymbolFor (JSVM_Env env, const char * utf8description, size_t length, JSVM_Value * result )
5275e41f4b71Sopenharmony_ci```
5276e41f4b71Sopenharmony_ci
5277e41f4b71Sopenharmony_ci**描述**
5278e41f4b71Sopenharmony_ci
5279e41f4b71Sopenharmony_ci在全局注册表中搜索具有给定描述的现有符号。如果该 符号已经存在,它将被返回,否则将在注册表中创建一个新符号。
5280e41f4b71Sopenharmony_ci
5281e41f4b71Sopenharmony_ci**起始版本:** 11
5282e41f4b71Sopenharmony_ci
5283e41f4b71Sopenharmony_ci**参数:**
5284e41f4b71Sopenharmony_ci
5285e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5286e41f4b71Sopenharmony_ci| -------- | -------- |
5287e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5288e41f4b71Sopenharmony_ci| utf8description | UTF-8 C 字符串,表示用作符号描述的文本。 | 
5289e41f4b71Sopenharmony_ci| length | 描述字符串的长度,以字节为单位。如果字符串以null结尾,则为JSVM_AUTO_LENGTH。 | 
5290e41f4b71Sopenharmony_ci| result | 表示JavaScript 符号的JSVM_Value。 | 
5291e41f4b71Sopenharmony_ci
5292e41f4b71Sopenharmony_ci**返回:**
5293e41f4b71Sopenharmony_ci
5294e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5295e41f4b71Sopenharmony_ci
5296e41f4b71Sopenharmony_ci
5297e41f4b71Sopenharmony_ci### OH_JSVM_TakeHeapSnapshot()
5298e41f4b71Sopenharmony_ci
5299e41f4b71Sopenharmony_ci```
5300e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_TakeHeapSnapshot (JSVM_VM vm, JSVM_OutputStream stream, void * streamData )
5301e41f4b71Sopenharmony_ci```
5302e41f4b71Sopenharmony_ci
5303e41f4b71Sopenharmony_ci**描述**
5304e41f4b71Sopenharmony_ci
5305e41f4b71Sopenharmony_ci获取当前堆快照并将其输出到流。
5306e41f4b71Sopenharmony_ci
5307e41f4b71Sopenharmony_ci**起始版本:** 12
5308e41f4b71Sopenharmony_ci
5309e41f4b71Sopenharmony_ci**参数:**
5310e41f4b71Sopenharmony_ci
5311e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5312e41f4b71Sopenharmony_ci| -------- | -------- |
5313e41f4b71Sopenharmony_ci| vm | 将被获取堆快照的虚拟机。 | 
5314e41f4b71Sopenharmony_ci| stream | 接收数据的输出流回调。 | 
5315e41f4b71Sopenharmony_ci| streamData | 传递给输出流回调的可选数据。例如,可以是一个文件流,用来将输出流回调中传递的采样数据写入文件。 | 
5316e41f4b71Sopenharmony_ci
5317e41f4b71Sopenharmony_ci**返回:**
5318e41f4b71Sopenharmony_ci
5319e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5320e41f4b71Sopenharmony_ci
5321e41f4b71Sopenharmony_ci
5322e41f4b71Sopenharmony_ci### OH_JSVM_Throw()
5323e41f4b71Sopenharmony_ci
5324e41f4b71Sopenharmony_ci```
5325e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_Throw (JSVM_Env env, JSVM_Value error )
5326e41f4b71Sopenharmony_ci```
5327e41f4b71Sopenharmony_ci
5328e41f4b71Sopenharmony_ci**描述**
5329e41f4b71Sopenharmony_ci
5330e41f4b71Sopenharmony_ci抛出提供的JavaScript值。
5331e41f4b71Sopenharmony_ci
5332e41f4b71Sopenharmony_ci**起始版本:** 11
5333e41f4b71Sopenharmony_ci
5334e41f4b71Sopenharmony_ci**参数:**
5335e41f4b71Sopenharmony_ci
5336e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5337e41f4b71Sopenharmony_ci| -------- | -------- |
5338e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5339e41f4b71Sopenharmony_ci| error | 要抛出的JavaScript值。 | 
5340e41f4b71Sopenharmony_ci
5341e41f4b71Sopenharmony_ci**返回:**
5342e41f4b71Sopenharmony_ci
5343e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5344e41f4b71Sopenharmony_ci
5345e41f4b71Sopenharmony_ci
5346e41f4b71Sopenharmony_ci### OH_JSVM_ThrowError()
5347e41f4b71Sopenharmony_ci
5348e41f4b71Sopenharmony_ci```
5349e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ThrowError (JSVM_Env env, const char * code, const char * msg )
5350e41f4b71Sopenharmony_ci```
5351e41f4b71Sopenharmony_ci
5352e41f4b71Sopenharmony_ci**描述**
5353e41f4b71Sopenharmony_ci
5354e41f4b71Sopenharmony_ci会抛出带有所提供文本的JavaScript Error。
5355e41f4b71Sopenharmony_ci
5356e41f4b71Sopenharmony_ci**起始版本:** 11
5357e41f4b71Sopenharmony_ci
5358e41f4b71Sopenharmony_ci**参数:**
5359e41f4b71Sopenharmony_ci
5360e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5361e41f4b71Sopenharmony_ci| -------- | -------- |
5362e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5363e41f4b71Sopenharmony_ci| code | 要在错误上设置的可选错误代码。 | 
5364e41f4b71Sopenharmony_ci| msg | 表示与错误关联的文本的C字符串。 | 
5365e41f4b71Sopenharmony_ci
5366e41f4b71Sopenharmony_ci**返回:**
5367e41f4b71Sopenharmony_ci
5368e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5369e41f4b71Sopenharmony_ci
5370e41f4b71Sopenharmony_ci
5371e41f4b71Sopenharmony_ci### OH_JSVM_ThrowRangeError()
5372e41f4b71Sopenharmony_ci
5373e41f4b71Sopenharmony_ci```
5374e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ThrowRangeError (JSVM_Env env, const char * code, const char * msg )
5375e41f4b71Sopenharmony_ci```
5376e41f4b71Sopenharmony_ci
5377e41f4b71Sopenharmony_ci**描述**
5378e41f4b71Sopenharmony_ci
5379e41f4b71Sopenharmony_ci会抛出带有所提供文本的JavaScript RangeError。
5380e41f4b71Sopenharmony_ci
5381e41f4b71Sopenharmony_ci**起始版本:** 11
5382e41f4b71Sopenharmony_ci
5383e41f4b71Sopenharmony_ci**参数:**
5384e41f4b71Sopenharmony_ci
5385e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5386e41f4b71Sopenharmony_ci| -------- | -------- |
5387e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5388e41f4b71Sopenharmony_ci| code | 要在错误上设置的可选错误代码。 | 
5389e41f4b71Sopenharmony_ci| msg | 表示与错误关联的文本的C字符串。 | 
5390e41f4b71Sopenharmony_ci
5391e41f4b71Sopenharmony_ci**返回:**
5392e41f4b71Sopenharmony_ci
5393e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5394e41f4b71Sopenharmony_ci
5395e41f4b71Sopenharmony_ci
5396e41f4b71Sopenharmony_ci### OH_JSVM_ThrowSyntaxError()
5397e41f4b71Sopenharmony_ci
5398e41f4b71Sopenharmony_ci```
5399e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ThrowSyntaxError (JSVM_Env env, const char * code, const char * msg )
5400e41f4b71Sopenharmony_ci```
5401e41f4b71Sopenharmony_ci
5402e41f4b71Sopenharmony_ci**描述**
5403e41f4b71Sopenharmony_ci
5404e41f4b71Sopenharmony_ci会抛出带有所提供文本的JavaScript SyntaxError。
5405e41f4b71Sopenharmony_ci
5406e41f4b71Sopenharmony_ci**起始版本:** 11
5407e41f4b71Sopenharmony_ci
5408e41f4b71Sopenharmony_ci**参数:**
5409e41f4b71Sopenharmony_ci
5410e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5411e41f4b71Sopenharmony_ci| -------- | -------- |
5412e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5413e41f4b71Sopenharmony_ci| code | 要在错误上设置的可选错误代码。 | 
5414e41f4b71Sopenharmony_ci| msg | 表示与错误关联的文本的C字符串。 | 
5415e41f4b71Sopenharmony_ci
5416e41f4b71Sopenharmony_ci**返回:**
5417e41f4b71Sopenharmony_ci
5418e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5419e41f4b71Sopenharmony_ci
5420e41f4b71Sopenharmony_ci
5421e41f4b71Sopenharmony_ci### OH_JSVM_ThrowTypeError()
5422e41f4b71Sopenharmony_ci
5423e41f4b71Sopenharmony_ci```
5424e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_ThrowTypeError (JSVM_Env env, const char * code, const char * msg )
5425e41f4b71Sopenharmony_ci```
5426e41f4b71Sopenharmony_ci
5427e41f4b71Sopenharmony_ci**描述**
5428e41f4b71Sopenharmony_ci
5429e41f4b71Sopenharmony_ci会抛出带有所提供文本的JavaScript TypeError。
5430e41f4b71Sopenharmony_ci
5431e41f4b71Sopenharmony_ci**起始版本:** 11
5432e41f4b71Sopenharmony_ci
5433e41f4b71Sopenharmony_ci**参数:**
5434e41f4b71Sopenharmony_ci
5435e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5436e41f4b71Sopenharmony_ci| -------- | -------- |
5437e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5438e41f4b71Sopenharmony_ci| code | 要在错误上设置的可选错误代码。 | 
5439e41f4b71Sopenharmony_ci| msg | 表示与错误关联的文本的C字符串。 | 
5440e41f4b71Sopenharmony_ci
5441e41f4b71Sopenharmony_ci**返回:**
5442e41f4b71Sopenharmony_ci
5443e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5444e41f4b71Sopenharmony_ci
5445e41f4b71Sopenharmony_ci
5446e41f4b71Sopenharmony_ci### OH_JSVM_Typeof()
5447e41f4b71Sopenharmony_ci
5448e41f4b71Sopenharmony_ci```
5449e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_Typeof (JSVM_Env env, JSVM_Value value, JSVM_ValueType * result )
5450e41f4b71Sopenharmony_ci```
5451e41f4b71Sopenharmony_ci
5452e41f4b71Sopenharmony_ci**描述**
5453e41f4b71Sopenharmony_ci
5454e41f4b71Sopenharmony_ci提供类似于在定义的对象上调用typeof运算符的行为。 不同点在于,该函数支持检测外部值;它将null检测为单独的类型, 而ECMAScript typeof将用于检测object。如果value的类型无效,则返回错误。
5455e41f4b71Sopenharmony_ci
5456e41f4b71Sopenharmony_ci**起始版本:** 11
5457e41f4b71Sopenharmony_ci
5458e41f4b71Sopenharmony_ci**参数:**
5459e41f4b71Sopenharmony_ci
5460e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5461e41f4b71Sopenharmony_ci| -------- | -------- |
5462e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5463e41f4b71Sopenharmony_ci| value | 要查询其类型的JavaScript值。 | 
5464e41f4b71Sopenharmony_ci| result | JavaScript值的类型。 | 
5465e41f4b71Sopenharmony_ci
5466e41f4b71Sopenharmony_ci**返回:**
5467e41f4b71Sopenharmony_ci
5468e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5469e41f4b71Sopenharmony_ci
5470e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
5471e41f4b71Sopenharmony_ci
5472e41f4b71Sopenharmony_ci
5473e41f4b71Sopenharmony_ci### OH_JSVM_TypeTagObject()
5474e41f4b71Sopenharmony_ci
5475e41f4b71Sopenharmony_ci```
5476e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_TypeTagObject (JSVM_Env env, JSVM_Value value, const JSVM_TypeTag * typeTag )
5477e41f4b71Sopenharmony_ci```
5478e41f4b71Sopenharmony_ci
5479e41f4b71Sopenharmony_ci**描述**
5480e41f4b71Sopenharmony_ci
5481e41f4b71Sopenharmony_ci将typeTag指针的值与JavaScript对象或外部值相关联。可调用OH_JSVM_CheckObjectTypeTag() 判断附加在对象上的标记类型,以确保对象的类型正确。如果对象已经有关联的类型标记,则返回JSVM_INVALID_ARG。
5482e41f4b71Sopenharmony_ci
5483e41f4b71Sopenharmony_ci**起始版本:** 11
5484e41f4b71Sopenharmony_ci
5485e41f4b71Sopenharmony_ci**参数:**
5486e41f4b71Sopenharmony_ci
5487e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5488e41f4b71Sopenharmony_ci| -------- | -------- |
5489e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5490e41f4b71Sopenharmony_ci| value | 要标记的JavaScript对象或外部值。 | 
5491e41f4b71Sopenharmony_ci| typeTag | 要标记对象的标签。 | 
5492e41f4b71Sopenharmony_ci
5493e41f4b71Sopenharmony_ci**返回:**
5494e41f4b71Sopenharmony_ci
5495e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5496e41f4b71Sopenharmony_ci
5497e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
5498e41f4b71Sopenharmony_ci
5499e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
5500e41f4b71Sopenharmony_ci
5501e41f4b71Sopenharmony_ci
5502e41f4b71Sopenharmony_ci### OH_JSVM_Unwrap()
5503e41f4b71Sopenharmony_ci
5504e41f4b71Sopenharmony_ci```
5505e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_Unwrap (JSVM_Env env, JSVM_Value jsObject, void ** result )
5506e41f4b71Sopenharmony_ci```
5507e41f4b71Sopenharmony_ci
5508e41f4b71Sopenharmony_ci**描述**
5509e41f4b71Sopenharmony_ci
5510e41f4b71Sopenharmony_ci当JavaScript代码调用类的方法或属性访问器时,对应的JSVM_Callback将被调用。 如果回调是针对实例方法或访问器的,则回调的this参数是封装器对象;然后可以通过调用 封装器对象的OH_JSVM_Unwrap()获得作为调用目标的C++实例。
5511e41f4b71Sopenharmony_ci
5512e41f4b71Sopenharmony_ci**起始版本:** 11
5513e41f4b71Sopenharmony_ci
5514e41f4b71Sopenharmony_ci**参数:**
5515e41f4b71Sopenharmony_ci
5516e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5517e41f4b71Sopenharmony_ci| -------- | -------- |
5518e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5519e41f4b71Sopenharmony_ci| jsObject | 与native实例关联的对象。 | 
5520e41f4b71Sopenharmony_ci| result | 指向封装的native实例的指针。 | 
5521e41f4b71Sopenharmony_ci
5522e41f4b71Sopenharmony_ci**返回:**
5523e41f4b71Sopenharmony_ci
5524e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5525e41f4b71Sopenharmony_ci
5526e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
5527e41f4b71Sopenharmony_ci
5528e41f4b71Sopenharmony_ci
5529e41f4b71Sopenharmony_ci### OH_JSVM_WaitForDebugger()
5530e41f4b71Sopenharmony_ci
5531e41f4b71Sopenharmony_ci```
5532e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_WaitForDebugger (JSVM_Env env, bool breakNextLine )
5533e41f4b71Sopenharmony_ci```
5534e41f4b71Sopenharmony_ci
5535e41f4b71Sopenharmony_ci**描述**
5536e41f4b71Sopenharmony_ci
5537e41f4b71Sopenharmony_ci等待主机与inspector建立socket连接,连接建立后程序将继续运行。 发送Runtime.runIfWaitingForDebugger命令。
5538e41f4b71Sopenharmony_ci
5539e41f4b71Sopenharmony_ci**起始版本:** 12
5540e41f4b71Sopenharmony_ci
5541e41f4b71Sopenharmony_ci**参数:**
5542e41f4b71Sopenharmony_ci
5543e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5544e41f4b71Sopenharmony_ci| -------- | -------- |
5545e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5546e41f4b71Sopenharmony_ci| breakNextLine | 是否在下一行JavaScript代码中中断。传递“是”,后续将暂停在运行下一行JS代码时,继续运行需要开发者通过调试器的调试按钮控制JS的执行。 | 
5547e41f4b71Sopenharmony_ci
5548e41f4b71Sopenharmony_ci**返回:**
5549e41f4b71Sopenharmony_ci
5550e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5551e41f4b71Sopenharmony_ci
5552e41f4b71Sopenharmony_ciJSVM_GENERIC_FAILURE 表示有未知的原因导致执行失败。
5553e41f4b71Sopenharmony_ci
5554e41f4b71Sopenharmony_ci
5555e41f4b71Sopenharmony_ci### OH_JSVM_Wrap()
5556e41f4b71Sopenharmony_ci
5557e41f4b71Sopenharmony_ci```
5558e41f4b71Sopenharmony_ciJSVM_EXTERN JSVM_Status OH_JSVM_Wrap (JSVM_Env env, JSVM_Value jsObject, void * nativeObject, JSVM_Finalize finalizeCb, void * finalizeHint, JSVM_Ref * result )
5559e41f4b71Sopenharmony_ci```
5560e41f4b71Sopenharmony_ci
5561e41f4b71Sopenharmony_ci**描述**
5562e41f4b71Sopenharmony_ci
5563e41f4b71Sopenharmony_ci在JavaScript对象中封装native实例。native实例 后续可以通过OH_JSVM_Unwrap()进行检索。
5564e41f4b71Sopenharmony_ci
5565e41f4b71Sopenharmony_ci**起始版本:** 11
5566e41f4b71Sopenharmony_ci
5567e41f4b71Sopenharmony_ci**参数:**
5568e41f4b71Sopenharmony_ci
5569e41f4b71Sopenharmony_ci| 名称 | 描述 | 
5570e41f4b71Sopenharmony_ci| -------- | -------- |
5571e41f4b71Sopenharmony_ci| env | 调用JSVM-API的环境。 | 
5572e41f4b71Sopenharmony_ci| jsObject | 将成为原生对象封装器的JavaScript对象。 | 
5573e41f4b71Sopenharmony_ci| nativeObject | 将封装在JavaScript对象中的native实例。 | 
5574e41f4b71Sopenharmony_ci| finalizeCb | 可选的原生回调,可用于在 JavaScript 对象被垃圾回收时释放native实例。 | 
5575e41f4b71Sopenharmony_ci| finalizeHint | 传递给完成回调的可选上下文提示。 | 
5576e41f4b71Sopenharmony_ci| result | 对封装对象的可选引用。 | 
5577e41f4b71Sopenharmony_ci
5578e41f4b71Sopenharmony_ci**返回:**
5579e41f4b71Sopenharmony_ci
5580e41f4b71Sopenharmony_ci返回执行状态码 JSVM_Status。 JSVM_OK 表示执行成功。
5581e41f4b71Sopenharmony_ci
5582e41f4b71Sopenharmony_ciJSVM_INVALID_ARG 表示传入的参数不合法。
5583