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