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