From 137254784707cd0ef86ebc4afa66f122435cd916 Mon Sep 17 00:00:00 2001 From: huanghan Date: Thu, 21 Nov 2024 22:17:12 +0800 Subject: [PATCH 1/3] =?UTF-8?q?API=20Lint=E7=9A=84=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huanghan --- src/jsvm.h | 1908 +++++++++++++++++++++++++--------------------- src/jsvm_types.h | 84 +- 2 files changed, 1095 insertions(+), 897 deletions(-) diff --git a/src/jsvm.h b/src/jsvm.h index 41a7f81f3..89ce7ffbd 100644 --- a/src/jsvm.h +++ b/src/jsvm.h @@ -12,10 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#ifndef ARK_RUNTIME_JSVM_JSVM_H -#define ARK_RUNTIME_JSVM_JSVM_H - /** * @addtogroup JSVM * @{ @@ -38,13 +34,20 @@ * including managing the engine lifecycle, compiling and running JS code, implementing JS/C++ cross language calls, * and taking snapshots. * @library libjsvm.so + * @kit ArkTS * @syscap SystemCapability.ArkCompiler.JSVM * @since 11 */ + +#ifndef ARK_RUNTIME_JSVM_JSVM_H +#define ARK_RUNTIME_JSVM_JSVM_H + + // This file needs to be compatible with C compilers. #include // NOLINT(modernize-deprecated-headers) #include // NOLINT(modernize-deprecated-headers) +#include "jsvm_types.h" // Use INT_MAX, this should only be consumed by the pre-processor anyway. #define JSVM_VERSION_EXPERIMENTAL 2147483647 @@ -62,8 +65,6 @@ #endif #endif -#include "jsvm_types.h" - #ifndef JSVM_EXTERN #ifdef _WIN32 /** @@ -102,7 +103,8 @@ EXTERN_C_START * @brief Init a JavaScript vm. * * @param options: The options for initialize the JavaScript VM. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } in all cases.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_Init(const JSVM_InitOptions* options); @@ -110,9 +112,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_Init(const JSVM_InitOptions* options); /** * @brief This API create a new VM instance. * - * @param options: The options for create the VM instance. - * @param result: The new VM instance. - * @return Returns JSVM_OK if the API succeeded. + * @param options The options for create the VM instance. + * @param result The new VM instance. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateVM(const JSVM_CreateVMOptions* options, @@ -121,8 +124,9 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateVM(const JSVM_CreateVMOptions* options, /** * @brief Destroys VM instance. * - * @param vm: The VM instance to be Destroyed. - * @return Returns JSVM_OK if the API succeeded. + * @param vm The VM instance to be Destroyed. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_DestroyVM(JSVM_VM vm); @@ -130,9 +134,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_DestroyVM(JSVM_VM vm); /** * @brief This API open a new VM scope for the VM instance. * - * @param vm: The VM instance to open scope for. - * @param result: The new VM scope. - * @return Returns JSVM_OK if the API succeeded. + * @param vm The VM instance to open scope for. + * @param result The new VM scope. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_OpenVMScope(JSVM_VM vm, @@ -141,9 +146,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_OpenVMScope(JSVM_VM vm, /** * @brief This function close the VM scope for the VM instance. * - * @param vm: The VM instance to close scope for. - * @param scope: The VM scope to be closed. - * @return Returns JSVM_OK if the API succeeded. + * @param vm The VM instance to close scope for. + * @param scope The VM scope to be closed. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CloseVMScope(JSVM_VM vm, @@ -152,11 +158,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CloseVMScope(JSVM_VM vm, /** * @brief This function create a new environment with optional properties for the context of the new environment. * - * @param vm: The VM instance that the env will be created in. - * @param propertyCount: The number of elements in the properties array. - * @param properties: The array of property descriptor. - * @param result: The new environment created. - * @return Returns JSVM_OK if the API succeeded. + * @param vm The VM instance that the env will be created in. + * @param propertyCount The number of elements in the properties array. + * @param properties The array of property descriptor. + * @param result The new environment created. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateEnv(JSVM_VM vm, @@ -167,10 +174,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateEnv(JSVM_VM vm, /** * @brief This function create a new environment from the start snapshot of the vm. * - * @param vm: The VM instance that the env will be created in. - * @param index: The index of the environment in the snapshot. - * @param result: The new environment created. - * @return Returns JSVM_OK if the API succeeded. + * @param vm The VM instance that the env will be created in. + * @param index The index of the environment in the snapshot. + * @param result The new environment created. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateEnvFromSnapshot(JSVM_VM vm, @@ -180,8 +188,9 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateEnvFromSnapshot(JSVM_VM vm, /** * @brief This function destroys the environment. * - * @param env: The environment to be destroyed. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment to be destroyed. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_DestroyEnv(JSVM_Env env); @@ -189,9 +198,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_DestroyEnv(JSVM_Env env); /** * @brief This function open a new environment scope. * - * @param env: The environment that the JSVM-API call is invoked under. - * @param result: The new environment scope. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the JSVM-API call is invoked under. + * @param result The new environment scope. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_OpenEnvScope(JSVM_Env env, @@ -200,9 +210,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_OpenEnvScope(JSVM_Env env, /** * @brief This function closes the environment scope of the environment. * - * @param env: The environment that the JSVM-API call is invoked under. - * @param scope: The environment scope to be closed. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the JSVM-API call is invoked under. + * @param scope The environment scope to be closed. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CloseEnvScope(JSVM_Env env, @@ -211,9 +222,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CloseEnvScope(JSVM_Env env, /** * @brief This function retrieves the VM instance of the given environment. * - * @param env: The environment that the JSVM-API call is invoked under. - * @param result: The VM instance of the environment. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the JSVM-API call is invoked under. + * @param result The VM instance of the environment. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } in all cases.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetVM(JSVM_Env env, @@ -222,14 +234,15 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetVM(JSVM_Env env, /** * @brief This function compiles a string of JavaScript code and returns the compiled script. * - * @param env: The environment that the JSVM-API call is invoked under. - * @param script: A JavaScript string containing the script yo be compiled. - * @param cachedData: Optional code cache data for the script. - * @param cacheDataLength: The length of cachedData array. - * @param eagerCompile: Whether to compile the script eagerly. - * @param cacheRejected: Whether the code cache rejected by compilation. - * @param result: The compiled script. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the JSVM-API call is invoked under. + * @param script A JavaScript string containing the script yo be compiled. + * @param cachedData Optional code cache data for the script. + * @param cacheDataLength The length of cachedData array. + * @param eagerCompile Whether to compile the script eagerly. + * @param cacheRejected Whether the code cache rejected by compilation. + * @param result The compiled script. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CompileScript(JSVM_Env env, @@ -244,15 +257,16 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CompileScript(JSVM_Env env, * @brief This function compiles a string of JavaScript code with the source code information * and returns the compiled script. * - * @param env: The environment that the JSVM-API call is invoked under. - * @param script: A JavaScript string containing the script to be compiled. - * @param cachedData: Optional code cache data for the script. - * @param cacheDataLength: The length of cachedData array. - * @param eagerCompile: Whether to compile the script eagerly. - * @param cacheRejected: Whether the code cache rejected by compilation. - * @param origin: The information of source code. - * @param result: The compiled script. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the JSVM-API call is invoked under. + * @param script A JavaScript string containing the script to be compiled. + * @param cachedData Optional code cache data for the script. + * @param cacheDataLength The length of cachedData array. + * @param eagerCompile Whether to compile the script eagerly. + * @param cacheRejected Whether the code cache rejected by compilation. + * @param origin The information of source code. + * @param result The compiled script. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_CompileScriptWithOrigin(JSVM_Env env, @@ -264,32 +278,15 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CompileScriptWithOrigin(JSVM_Env env, JSVM_ScriptOrigin* origin, JSVM_Script* result); -/** - * @brief This function compiles a string of JavaScript code with the source code information - * and returns the compiled script. - * - * @param env: The environment that the JSVM-API call is invoked under. - * @param script: A JavaScript string containing the script to be compiled. - * @param optionCount: length of option array. - * @param options: Compile options to be passed. - * @param result: The compiled script. - * @return Returns JSVM_OK if the API succeeded. - * @since 12 - */ -JSVM_EXTERN JSVM_Status OH_JSVM_CompileScriptWithOptions(JSVM_Env env, - JSVM_Value script, - size_t optionCount, - JSVM_CompileOptions options[], - JSVM_Script* result); - /** * @brief This function creates code cache for the compiled script. * - * @param env: The environment that the JSVM-API call is invoked under. - * @param script: A compiled script to create code cache for. - * @param data: The data of the code cache. - * @param length: The length of the code cache data. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the JSVM-API call is invoked under. + * @param script A compiled script to create code cache for. + * @param data The data of the code cache. + * @param length The length of the code cache data. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateCodeCache(JSVM_Env env, @@ -305,9 +302,9 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateCodeCache(JSVM_Env env, * global object. Variable declarations made using let and const will be visible globally, but will not be added * to the global object.The value of this is global within the script. * - * @param env: The environment that the API is invoked under. - * @param script: A JavaScript string containing the script to execute. - * @param result: The value resulting from having executed the script. + * @param env The environment that the API is invoked under. + * @param script A JavaScript string containing the script to execute. + * @param result The value resulting from having executed the script. * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_RunScript(JSVM_Env env, @@ -318,12 +315,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_RunScript(JSVM_Env env, * @brief This API associates data with the currently running JSVM environment. data can later be retrieved * using OH_JSVM_GetInstanceData(). * - * @param env: The environment that the JSVM-API call is invoked under. - * @param data: The data item to make available to bindings of this instance. - * @param finalizeCb: The function to call when the environment is being torn down. The function receives + * @param env The environment that the JSVM-API call is invoked under. + * @param data The data item to make available to bindings of this instance. + * @param finalizeCb The function to call when the environment is being torn down. The function receives * data so that it might free it. JSVM_Finalize provides more details. - * @param finalizeHint: Optional hint to pass to the finalize callback during collection. - * @return Returns JSVM_OK if the API succeeded. + * @param finalizeHint Optional hint to pass to the finalize callback during collection. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_SetInstanceData(JSVM_Env env, @@ -335,10 +333,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_SetInstanceData(JSVM_Env env, * @brief This API retrieves data that was previously associated with the currently running JSVM environment * via OH_JSVM_SetInstanceData(). If no data is set, the call will succeed and data will be set to NULL. * - * @param env: The environment that the JSVM-API call is invoked under. - * @param data: The data item that was previously associated with the currently running JSVM environment by + * @param env The environment that the JSVM-API call is invoked under. + * @param data The data item that was previously associated with the currently running JSVM environment by * a call to OH_JSVM_SetInstanceData(). - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetInstanceData(JSVM_Env env, @@ -348,9 +347,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetInstanceData(JSVM_Env env, * @brief This API retrieves a JSVM_ExtendedErrorInfo structure with information about the last error that * occurred. * - * @param env: The environment that the JSVM-API call is invoked under. - * @param result: The JSVM_ExtendedErrorInfo structure with more information about the error. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the JSVM-API call is invoked under. + * @param result The JSVM_ExtendedErrorInfo structure with more information about the error. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetLastErrorInfo(JSVM_Env env, @@ -359,9 +359,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetLastErrorInfo(JSVM_Env env, /** * @brief This API throws the JavaScript value provided. * - * @param env: The environment that the API is invoked under. - * @param error: The JavaScript value to be thrown. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param error The JavaScript value to be thrown. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_Throw(JSVM_Env env, @@ -370,10 +371,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_Throw(JSVM_Env env, /** * @brief This API throws a JavaScript Error with the text provided. * - * @param env: The environment that the API is invoked under. - * @param code: Optional error code to be set on the error. - * @param msg: C string representing the text to be associated with the error. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param code Optional error code to be set on the error. + * @param msg C string representing the text to be associated with the error. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_ThrowError(JSVM_Env env, @@ -383,10 +385,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ThrowError(JSVM_Env env, /** * @brief This API throws a JavaScript TypeError with the text provided. * - * @param env: The environment that the API is invoked under. - * @param code: Optional error code to be set on the error. - * @param msg: C string representing the text to be associated with the error. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param code Optional error code to be set on the error. + * @param msg C string representing the text to be associated with the error. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_ThrowTypeError(JSVM_Env env, @@ -396,10 +399,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ThrowTypeError(JSVM_Env env, /** * @brief This API throws a JavaScript RangeError with the text provided. * - * @param env: The environment that the API is invoked under. - * @param code: Optional error code to be set on the error. - * @param msg: C string representing the text to be associated with the error. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param code Optional error code to be set on the error. + * @param msg C string representing the text to be associated with the error. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_ThrowRangeError(JSVM_Env env, @@ -409,10 +413,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ThrowRangeError(JSVM_Env env, /** * @brief This API throws a JavaScript SyntaxError with the text provided. * - * @param env: The environment that the API is invoked under. - * @param code: Optional error code to be set on the error. - * @param msg: C string representing the text to be associated with the error. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param code Optional error code to be set on the error. + * @param msg C string representing the text to be associated with the error. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_ThrowSyntaxError(JSVM_Env env, @@ -422,11 +427,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ThrowSyntaxError(JSVM_Env env, /** * @brief This API queries a JSVM_Value to check if it represents an error object. * - * @param env: The environment that the API is invoked under. - * @param value: The JSVM_Value to be checked. - * @param result: Boolean value that is set to true if JSVM_Value represents an error, + * @param env The environment that the API is invoked under. + * @param value The JSVM_Value to be checked. + * @param result Boolean value that is set to true if JSVM_Value represents an error, * false otherwise. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsError(JSVM_Env env, @@ -436,11 +442,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsError(JSVM_Env env, /** * @brief This API returns a JavaScript Error with the text provided. * - * @param env: The environment that the API is invoked under. - * @param code: Optional JSVM_Value with the string for the error code to be associated with the error. - * @param msg: JSVM_Value that references a JavaScript string to be used as the message for the Error. - * @param result: JSVM_Value representing the error created. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param code Optional JSVM_Value with the string for the error code to be associated with the error. + * @param msg JSVM_Value that references a JavaScript string to be used as the message for the Error. + * @param result JSVM_Value representing the error created. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateError(JSVM_Env env, @@ -451,11 +458,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateError(JSVM_Env env, /** * @brief This API returns a JavaScript TypeError with the text provided. * - * @param env: The environment that the API is invoked under. - * @param code: Optional JSVM_Value with the string for the error code to be associated with the error. - * @param msg: JSVM_Value that references a JavaScript string to be used as the message for the Error. - * @param result: JSVM_Value representing the error created. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param code Optional JSVM_Value with the string for the error code to be associated with the error. + * @param msg JSVM_Value that references a JavaScript string to be used as the message for the Error. + * @param result JSVM_Value representing the error created. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateTypeError(JSVM_Env env, @@ -466,11 +474,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateTypeError(JSVM_Env env, /** * @brief This API returns a JavaScript RangeError with the text provided. * - * @param env: The environment that the API is invoked under. - * @param code: Optional JSVM_Value with the string for the error code to be associated with the error. - * @param msg: JSVM_Value that references a JavaScript string to be used as the message for the Error. - * @param result: JSVM_Value representing the error created. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param code Optional JSVM_Value with the string for the error code to be associated with the error. + * @param msg JSVM_Value that references a JavaScript string to be used as the message for the Error. + * @param result JSVM_Value representing the error created. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateRangeError(JSVM_Env env, @@ -481,11 +490,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateRangeError(JSVM_Env env, /** * @brief This API returns a JavaScript SyntaxError with the text provided. * - * @param env: The environment that the API is invoked under. - * @param code: Optional JSVM_Value with the string for the error code to be associated with the error. - * @param msg: JSVM_Value that references a JavaScript string to be used as the message for the Error. - * @param result: JSVM_Value representing the error created. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param code Optional JSVM_Value with the string for the error code to be associated with the error. + * @param msg JSVM_Value that references a JavaScript string to be used as the message for the Error. + * @param result JSVM_Value representing the error created. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateSyntaxError(JSVM_Env env, @@ -496,9 +506,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateSyntaxError(JSVM_Env env, /** * @brief This API returns a JavaScript exception if one is pending, NULL otherwise. * - * @param env: The environment that the API is invoked under. - * @param result: The exception if one is pending, NULL otherwise. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param result The exception if one is pending, NULL otherwise. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetAndClearLastException(JSVM_Env env, @@ -507,9 +518,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetAndClearLastException(JSVM_Env env, /** * @brief This API returns true if an exception is pending, false otherwise. * - * @param env: The environment that the API is invoked under. - * @param result: Boolean value that is set to true if an exception is pending. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param result Boolean value that is set to true if an exception is pending. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsExceptionPending(JSVM_Env env, @@ -518,9 +530,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsExceptionPending(JSVM_Env env, /** * @brief This API opens a new scope. * - * @param env: The environment that the API is invoked under. - * @param result: JSVM_Value representing the new scope. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param result JSVM_Value representing the new scope. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_OpenHandleScope(JSVM_Env env, @@ -530,9 +543,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_OpenHandleScope(JSVM_Env env, * @brief This API closes the scope passed in. Scopes must be closed in the reverse * order from which they were created. * - * @param env: The environment that the API is invoked under. - * @param scope: JSVM_Value representing the scope to be closed. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param scope JSVM_Value representing the scope to be closed. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CloseHandleScope(JSVM_Env env, @@ -541,9 +555,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CloseHandleScope(JSVM_Env env, /** * @brief This API opens a new scope from which one object can be promoted to the outer scope. * - * @param env: The environment that the API is invoked under. - * @param result: JSVM_Value representing the new scope. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param result JSVM_Value representing the new scope. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_OpenEscapableHandleScope(JSVM_Env env, @@ -553,9 +568,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_OpenEscapableHandleScope(JSVM_Env env, * @brief This API closes the scope passed in. Scopes must be closed in the reverse order * from which they were created. * - * @param env: The environment that the API is invoked under. - * @param scope: JSVM_Value representing the scope to be closed. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param scope JSVM_Value representing the scope to be closed. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CloseEscapableHandleScope(JSVM_Env env, @@ -566,11 +582,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CloseEscapableHandleScope(JSVM_Env env, * of the outer scope. It can only be called once per scope. If it is called more than once an error * will be returned. * - * @param env: The environment that the API is invoked under. - * @param scope: JSVM_Value representing the current scope. - * @param escapee: JSVM_Value representing the JavaScript Object to be escaped. - * @param result: JSVM_Value representing the handle to the escaped Object in the outer scope. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param scope JSVM_Value representing the current scope. + * @param escapee JSVM_Value representing the JavaScript Object to be escaped. + * @param result JSVM_Value representing the handle to the escaped Object in the outer scope. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_EscapeHandle(JSVM_Env env, @@ -581,11 +598,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_EscapeHandle(JSVM_Env env, /** * @brief This API creates a new reference with the specified reference count to the value passed in. * - * @param env: The environment that the API is invoked under. - * @param value: The JSVM_Value for which a reference is being created. - * @param initialRefcount: Initial reference count for the new reference. - * @param result: JSVM_Ref pointing to the new reference. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JSVM_Value for which a reference is being created. + * @param initialRefcount Initial reference count for the new reference. + * @param result JSVM_Ref pointing to the new reference. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateReference(JSVM_Env env, @@ -596,9 +614,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateReference(JSVM_Env env, /** * @brief his API deletes the reference passed in. * - * @param env: The environment that the API is invoked under. - * @param ref: JSVM_Ref to be deleted. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param ref JSVM_Ref to be deleted. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_DeleteReference(JSVM_Env env, @@ -608,10 +627,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_DeleteReference(JSVM_Env env, * @brief his API increments the reference count for the reference passed in and * returns the resulting reference count. * - * @param env: The environment that the API is invoked under. - * @param ref: JSVM_Ref for which the reference count will be incremented. - * @param result: The new reference count. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param ref JSVM_Ref for which the reference count will be incremented. + * @param result The new reference count. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_ReferenceRef(JSVM_Env env, @@ -622,10 +642,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ReferenceRef(JSVM_Env env, * @brief This API decrements the reference count for the reference passed in and * returns the resulting reference count. * - * @param env: The environment that the API is invoked under. - * @param ref: JSVM_Ref for which the reference count will be decremented. - * @param result: The new reference count. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param ref JSVM_Ref for which the reference count will be decremented. + * @param result The new reference count. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_ReferenceUnref(JSVM_Env env, @@ -636,10 +657,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ReferenceUnref(JSVM_Env env, * @brief If still valid, this API returns the JSVM_Value representing the * JavaScript value associated with the JSVM_Ref. Otherwise, result will be NULL. * - * @param env: The environment that the API is invoked under. - * @param ref: The JSVM_Ref for which the corresponding value is being requested. - * @param result: The JSVM_Value referenced by the JSVM_Ref. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param ref The JSVM_Ref for which the corresponding value is being requested. + * @param result The JSVM_Value referenced by the JSVM_Ref. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetReferenceValue(JSVM_Env env, @@ -649,9 +671,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetReferenceValue(JSVM_Env env, /** * @brief This API returns a JSVM-API value corresponding to a JavaScript Array type. * - * @param env: The environment that the API is invoked under. - * @param result: A JSVM_Value representing a JavaScript Array. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param result A JSVM_Value representing a JavaScript Array. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateArray(JSVM_Env env, @@ -663,10 +686,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateArray(JSVM_Env env, * is set to the passed-in length parameter. However, the underlying buffer is not guaranteed to be pre-allocated * by the VM when the array is created. That behavior is left to the underlying VM implementation. * - * @param env: The environment that the API is invoked under. - * @param length: The initial length of the Array. - * @param result: A JSVM_Value representing a JavaScript Array. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param length The initial length of the Array. + * @param result A JSVM_Value representing a JavaScript Array. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateArrayWithLength(JSVM_Env env, @@ -681,11 +705,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateArrayWithLength(JSVM_Env env, * directly manipulate the buffer. This buffer can only be written to directly from native code. To write to this * buffer from JavaScript, a typed array or DataView object would need to be created. * - * @param env: The environment that the API is invoked under. - * @param byteLength: The length in bytes of the array buffer to create. - * @param data: Pointer to the underlying byte buffer of the ArrayBuffer.data can optionally be ignored by passing NULL. - * @param result: A JSVM_Value representing a JavaScript Array. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param byteLength The length in bytes of the array buffer to create. + * @param data Pointer to the underlying byte buffer of the ArrayBuffer.data can optionally be ignored by passing NULL. + * @param result A JSVM_Value representing a JavaScript Array. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateArraybuffer(JSVM_Env env, @@ -696,9 +721,9 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateArraybuffer(JSVM_Env env, /** * @brief This API allocate the memory of array buffer backing store. * - * @param byteLength: size of backing store memory. - * @param initialized: initialization status of the backing store memory. - * @param data: pointer that recieve the backing store memory pointer. + * @param byteLength size of backing store memory. + * @param initialized initialization status of the backing store memory. + * @param data pointer that recieve the backing store memory pointer. * @return Returns JSVM funtions result code. * Returns {@link JSVM_OK } if allocation succeed.\n * Returns {@link JSVM_INVALID_ARG } if data is null pointer.\n @@ -712,7 +737,7 @@ JSVM_Status JSVM_CDECL OH_JSVM_AllocateArrayBufferBackingStoreData(size_t byteLe /** * @brief This API release the memory of an array buffer backing store. * - * @param data: pointer to the backing store memory. + * @param data pointer to the backing store memory. * @return Returns JSVM funtions result code. * Returns {@link JSVM_OK } if run succeed.\n * Returns {@link JSVM_INVALID_ARG } if data is null pointer.\n @@ -723,12 +748,12 @@ JSVM_Status JSVM_CDECL OH_JSVM_FreeArrayBufferBackingStoreData(void *data); /** * @brief This API create an array buffer using the backing store data. * - * @param env: The environment that the API is invoked under. - * @param data: pointer to the backing store memory. - * @param backingStoreSize: size of backing store memory. - * @param offset: start position of the array buffer in the backing store memory. - * @param arrayBufferSize: size of the array buffer. - * @param result: pointer that recieve the array buffer. + * @param env The environment that the API is invoked under. + * @param data pointer to the backing store memory. + * @param backingStoreSize size of backing store memory. + * @param offset start position of the array buffer in the backing store memory. + * @param arrayBufferSize size of the array buffer. + * @param result pointer that recieve the array buffer. * @return Returns JSVM funtions result code. * Returns {@link JSVM_OK } if creation succeed.\n * Returns {@link JSVM_INVALID_ARG } if any of the following condition reached:\n @@ -748,10 +773,11 @@ JSVM_Status JSVM_CDECL OH_JSVM_CreateArrayBufferFromBackingStoreData(JSVM_Env en * @brief This API does not observe leap seconds; they are ignored, as ECMAScript aligns with POSIX time specification. * This API allocates a JavaScript Date object. * - * @param env: The environment that the API is invoked under. - * @param time: ECMAScript time value in milliseconds since 01 January, 1970 UTC. - * @param result: A JSVM_Value representing a JavaScript Date. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param time ECMAScript time value in milliseconds since 01 January, 1970 UTC. + * @param result A JSVM_Value representing a JavaScript Date. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateDate(JSVM_Env env, @@ -763,15 +789,16 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateDate(JSVM_Env env, * data through JavaScript code, so it can be retrieved later by native code using OH_JSVM_GetValueExternal. * The API adds a JSVM_Finalize callback which will be called when the JavaScript object just created has been garbage * collected.The created value is not an object, and therefore does not support additional properties. It is considered - * a distinct value type: calling OH_JSVM_Typeof() with an external value yields JSVM_EXTERNAL. + * a distinct value type calling OH_JSVM_Typeof() with an external value yields JSVM_EXTERNAL. * - * @param env: The environment that the API is invoked under. - * @param data: Raw pointer to the external data. - * @param finalizeCb: Optional callback to call when the external value is being collected. JSVM_Finalize provides + * @param env The environment that the API is invoked under. + * @param data Raw pointer to the external data. + * @param finalizeCb Optional callback to call when the external value is being collected. JSVM_Finalize provides * more details. - * @param finalizeHint: Optional hint to pass to the finalize callback during collection. - * @param result: A JSVM_Value representing an external value. - * @return Returns JSVM_OK if the API succeeded. + * @param finalizeHint Optional hint to pass to the finalize callback during collection. + * @param result A JSVM_Value representing an external value. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateExternal(JSVM_Env env, @@ -783,9 +810,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateExternal(JSVM_Env env, /** * @brief This API allocates a default JavaScript Object. It is the equivalent of doing new Object() in JavaScript. * - * @param env: The environment that the API is invoked under. - * @param result: A JSVM_Value representing a JavaScript Object. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param result A JSVM_Value representing a JavaScript Object. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateObject(JSVM_Env env, @@ -794,11 +822,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateObject(JSVM_Env env, /** * @brief This API creates a JavaScript symbol value from a UTF8-encoded C string. * - * @param env: The environment that the API is invoked under. - * @param description: Optional JSVM_Value which refers to a JavaScript string to be set as the description + * @param env The environment that the API is invoked under. + * @param description Optional JSVM_Value which refers to a JavaScript string to be set as the description * for the symbol. - * @param result: A JSVM_Value representing a JavaScript symbol. - * @return Returns JSVM_OK if the API succeeded. + * @param result A JSVM_Value representing a JavaScript symbol. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateSymbol(JSVM_Env env, @@ -809,11 +838,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateSymbol(JSVM_Env env, * @brief This API searches in the global registry for an existing symbol with the given description. * If the symbol already exists it will be returned, otherwise a new symbol will be created in the registry. * - * @param env: The environment that the API is invoked under. - * @param utf8description: UTF-8 C string representing the text to be used as the description for the symbol. - * @param length: The length of the description string in bytes, or JSVM_AUTO_LENGTH if it is null-terminated. - * @param result: A JSVM_Value representing a JavaScript symbol. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param utf8description UTF-8 C string representing the text to be used as the description for the symbol. + * @param length The length of the description string in bytes, or JSVM_AUTO_LENGTH if it is null-terminated. + * @param result A JSVM_Value representing a JavaScript symbol. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_SymbolFor(JSVM_Env env, @@ -827,13 +857,14 @@ JSVM_EXTERN JSVM_Status OH_JSVM_SymbolFor(JSVM_Env env, * same underlying binary scalar datatype.It's required that (length * size_of_element) + byte_offset should * be <= the size in bytes of the array passed in. If not, a RangeError exception is raised. * - * @param env: The environment that the API is invoked under. - * @param type: Scalar datatype of the elements within the TypedArray. - * @param length: Number of elements in the TypedArray. - * @param arraybuffer: ArrayBuffer underlying the typed array. - * @param byteOffset: The byte offset within the ArrayBuffer from which to start projecting the TypedArray. - * @param result: A JSVM_Value representing a JavaScript TypedArray - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param type Scalar datatype of the elements within the TypedArray. + * @param length Number of elements in the TypedArray. + * @param arraybuffer ArrayBuffer underlying the typed array. + * @param byteOffset The byte offset within the ArrayBuffer from which to start projecting the TypedArray. + * @param result A JSVM_Value representing a JavaScript TypedArray + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateTypedarray(JSVM_Env env, @@ -850,12 +881,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateTypedarray(JSVM_Env env, * less than or equal to the size in bytes of the array passed in. If not, a RangeError exception * is raised. * - * @param env: The environment that the API is invoked under. - * @param length: Number of elements in the DataView. - * @param arraybuffer: ArrayBuffer underlying the DataView. - * @param byteOffset: The byte offset within the ArrayBuffer from which to start projecting the DataView. - * @param result:A JSVM_Value representing a JavaScript DataView. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param length Number of elements in the DataView. + * @param arraybuffer ArrayBuffer underlying the DataView. + * @param byteOffset The byte offset within the ArrayBuffer from which to start projecting the DataView. + * @param result A JSVM_Value representing a JavaScript DataView. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateDataview(JSVM_Env env, @@ -867,10 +899,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateDataview(JSVM_Env env, /** * @brief This API is used to convert from the C int32_t type to the JavaScript number type. * - * @param env: The environment that the API is invoked under. - * @param value: Integer value to be represented in JavaScript. - * @param result: A JSVM_Value representing a JavaScript number. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value Integer value to be represented in JavaScript. + * @param result A JSVM_Value representing a JavaScript number. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateInt32(JSVM_Env env, @@ -880,10 +913,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateInt32(JSVM_Env env, /** * @brief This API is used to convert from the C uint32_t type to the JavaScript number type. * - * @param env: The environment that the API is invoked under. - * @param value: Unsigned integer value to be represented in JavaScript. - * @param result: A JSVM_Value representing a JavaScript number. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value Unsigned integer value to be represented in JavaScript. + * @param result A JSVM_Value representing a JavaScript number. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateUint32(JSVM_Env env, @@ -893,10 +927,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateUint32(JSVM_Env env, /** * @brief This API is used to convert from the C int64_t type to the JavaScript number type. * - * @param env: The environment that the API is invoked under. - * @param value: Integer value to be represented in JavaScript. - * @param result: A JSVM_Value representing a JavaScript number. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value Integer value to be represented in JavaScript. + * @param result A JSVM_Value representing a JavaScript number. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateInt64(JSVM_Env env, @@ -906,10 +941,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateInt64(JSVM_Env env, /** * @brief This API is used to convert from the C double type to the JavaScript number type. * - * @param env: The environment that the API is invoked under. - * @param value: Double-precision value to be represented in JavaScript. - * @param result: A JSVM_Value representing a JavaScript number. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value Double-precision value to be represented in JavaScript. + * @param result A JSVM_Value representing a JavaScript number. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateDouble(JSVM_Env env, @@ -919,10 +955,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateDouble(JSVM_Env env, /** * @brief This API converts the C int64_t type to the JavaScript BigInt type. * - * @param env: The environment that the API is invoked under. - * @param value: Integer value to be represented in JavaScript. - * @param result: A JSVM_Value representing a JavaScript BigInt. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value Integer value to be represented in JavaScript. + * @param result A JSVM_Value representing a JavaScript BigInt. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateBigintInt64(JSVM_Env env, @@ -932,10 +969,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateBigintInt64(JSVM_Env env, /** * @brief This API converts the C uint64_t type to the JavaScript BigInt type. * - * @param env: The environment that the API is invoked under. - * @param value: Unsigned integer value to be represented in JavaScript. - * @param result: A JSVM_Value representing a JavaScript BigInt. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value Unsigned integer value to be represented in JavaScript. + * @param result A JSVM_Value representing a JavaScript BigInt. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateBigintUint64(JSVM_Env env, @@ -944,14 +982,15 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateBigintUint64(JSVM_Env env, /** * @brief This API converts an array of unsigned 64-bit words into a single BigInt value. - * The resulting BigInt is calculated as: (–1)sign_bit (words[0] × (264)0 + words[1] × (264)1 + …) + * The resulting BigInt is calculated as (–1)sign_bit (words[0] × (264)0 + words[1] × (264)1 + …) * - * @param env: The environment that the API is invoked under. - * @param signBit: Determines if the resulting BigInt will be positive or negative. - * @param wordCount: The length of the words array. - * @param words: An array of uint64_t little-endian 64-bit words. - * @param result: A JSVM_Value representing a JavaScript BigInt. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param signBit Determines if the resulting BigInt will be positive or negative. + * @param wordCount The length of the words array. + * @param words An array of uint64_t little-endian 64-bit words. + * @param result A JSVM_Value representing a JavaScript BigInt. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateBigintWords(JSVM_Env env, @@ -964,11 +1003,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateBigintWords(JSVM_Env env, * @brief This API creates a JavaScript string value from an ISO-8859-1-encoded C * string. The native string is copied. * - * @param env: The environment that the API is invoked under. - * @param str: Character buffer representing an ISO-8859-1-encoded string. - * @param length: The length of the string in bytes, or JSVM_AUTO_LENGTH if it is null-terminated. - * @param result: A JSVM_Value representing a JavaScript string. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param str Character buffer representing an ISO-8859-1-encoded string. + * @param length The length of the string in bytes, or JSVM_AUTO_LENGTH if it is null-terminated. + * @param result A JSVM_Value representing a JavaScript string. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateStringLatin1(JSVM_Env env, @@ -980,12 +1020,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateStringLatin1(JSVM_Env env, * @brief This API creates a JavaScript string value from a UTF16-LE-encoded C * string. The native string is copied. * - * @param env: The environment that the API is invoked under. - * @param str: Character buffer representing a UTF16-LE-encoded string. - * @param length: The length of the string in two-byte code units, or JSVM_AUTO_LENGTH + * @param env The environment that the API is invoked under. + * @param str Character buffer representing a UTF16-LE-encoded string. + * @param length The length of the string in two-byte code units, or JSVM_AUTO_LENGTH * if it is null-terminated. - * @param result: A JSVM_Value representing a JavaScript string. - * @return Returns JSVM_OK if the API succeeded. + * @param result A JSVM_Value representing a JavaScript string. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateStringUtf16(JSVM_Env env, @@ -997,11 +1038,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateStringUtf16(JSVM_Env env, * @brief This API creates a JavaScript string value from a UTF8-encoded C * string. The native string is copied. * - * @param env: The environment that the API is invoked under. - * @param str: Character buffer representing a UTF8-encoded string. - * @param length: The length of the string in bytes, or JSVM_AUTO_LENGTH if it is null-terminated. - * @param result: A JSVM_Value representing a JavaScript string. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param str Character buffer representing a UTF8-encoded string. + * @param length The length of the string in bytes, or JSVM_AUTO_LENGTH if it is null-terminated. + * @param result A JSVM_Value representing a JavaScript string. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateStringUtf8(JSVM_Env env, @@ -1012,10 +1054,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateStringUtf8(JSVM_Env env, /** * @brief This API returns the length of an array. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing the JavaScript Array whose length is being queried. - * @param result: uint32 representing length of the array. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing the JavaScript Array whose length is being queried. + * @param result uint32 representing length of the array. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetArrayLength(JSVM_Env env, @@ -1025,12 +1068,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetArrayLength(JSVM_Env env, /** * @brief This API is used to retrieve the underlying data buffer of an ArrayBuffer and its length. * - * @param env: The environment that the API is invoked under. - * @param arraybuffer: JSVM_Value representing the ArrayBuffer being queried. - * @param data: The underlying data buffer of the ArrayBuffer. If byte_length is 0, this may be NULL + * @param env The environment that the API is invoked under. + * @param arraybuffer JSVM_Value representing the ArrayBuffer being queried. + * @param data The underlying data buffer of the ArrayBuffer. If byte_length is 0, this may be NULL * or any other pointer value. - * @param byteLength: Length in bytes of the underlying data buffer. - * @return Returns JSVM_OK if the API succeeded. + * @param byteLength Length in bytes of the underlying data buffer. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetArraybufferInfo(JSVM_Env env, @@ -1041,11 +1085,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetArraybufferInfo(JSVM_Env env, /** * @brief This API returns the length of an array. * - * @param env: The environment that the API is invoked under. - * @param object: JSVM_Value representing JavaScript Object whose prototype to return. This returns + * @param env The environment that the API is invoked under. + * @param object JSVM_Value representing JavaScript Object whose prototype to return. This returns * the equivalent of Object.getPrototypeOf (which is not the same as the function's prototype property). - * @param result: JSVM_Value representing prototype of the given object. - * @return Returns JSVM_OK if the API succeeded. + * @param result JSVM_Value representing prototype of the given object. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetPrototype(JSVM_Env env, @@ -1055,18 +1100,19 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetPrototype(JSVM_Env env, /** * @brief This API returns various properties of a typed array. * - * @param env: The environment that the API is invoked under. - * @param typedarray: JSVM_Value representing the TypedArray whose properties to query. - * @param type: Scalar datatype of the elements within the TypedArray. - * @param length: The number of elements in the TypedArray. - * @param data: The data buffer underlying the TypedArray adjusted by the byte_offset value so that it + * @param env The environment that the API is invoked under. + * @param typedarray JSVM_Value representing the TypedArray whose properties to query. + * @param type Scalar datatype of the elements within the TypedArray. + * @param length The number of elements in the TypedArray. + * @param data The data buffer underlying the TypedArray adjusted by the byte_offset value so that it * points to the first element in the TypedArray. If the length of the array is 0, this may be NULL or * any other pointer value. - * @param arraybuffer: The ArrayBuffer underlying the TypedArray. - * @param byteOffset: The byte offset within the underlying native array at which the first element of + * @param arraybuffer The ArrayBuffer underlying the TypedArray. + * @param byteOffset The byte offset within the underlying native array at which the first element of * the arrays is located. The value for the data parameter has already been adjusted so that data points * to the first element in the array. Therefore, the first byte of the native array would be at data - byte_offset. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetTypedarrayInfo(JSVM_Env env, @@ -1081,14 +1127,15 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetTypedarrayInfo(JSVM_Env env, * @brief Any of the out parameters may be NULL if that property is unneeded. * This API returns various properties of a DataView. * - * @param env: The environment that the API is invoked under. - * @param dataview: JSVM_Value representing the DataView whose properties to query. - * @param bytelength: Number of bytes in the DataView. - * @param data: The data buffer underlying the DataView. + * @param env The environment that the API is invoked under. + * @param dataview JSVM_Value representing the DataView whose properties to query. + * @param bytelength Number of bytes in the DataView. + * @param data The data buffer underlying the DataView. * If byte_length is 0, this may be NULL or any other pointer value. - * @param arraybuffer: ArrayBuffer underlying the DataView. - * @param byteOffset: The byte offset within the data buffer from which to start projecting the DataView. - * @return Returns JSVM_OK if the API succeeded. + * @param arraybuffer ArrayBuffer underlying the DataView. + * @param byteOffset The byte offset within the data buffer from which to start projecting the DataView. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetDataviewInfo(JSVM_Env env, @@ -1099,15 +1146,17 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetDataviewInfo(JSVM_Env env, size_t* byteOffset); /** - * @brief Returns JSVM_OK if the API succeeded. If a non-date JSVM_Value is + * @brief Returns JSVM_OK if the function executed successfully. If a non-date JSVM_Value is * passed in it returns JSVM_date_expected.This API returns the C double * primitive of time value for the given JavaScript Date. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing a JavaScript Date. - * @param result: Time value as a double represented as milliseconds + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing a JavaScript Date. + * @param result Time value as a double represented as milliseconds * since midnight at the beginning of 01 January, 1970 UTC. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_DATE_EXPECTED } If a non-date JSVM_Value is passed in it.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetDateValue(JSVM_Env env, @@ -1117,11 +1166,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetDateValue(JSVM_Env env, /** * @brief This API returns the C boolean primitive equivalent of the given JavaScript Boolean. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript Boolean. - * @param result: C boolean primitive equivalent of the given JavaScript Boolean. - * @return Returns JSVM_OK if the API succeeded. - * If a non-boolean JSVM_Value is passed in it returns JSVM_BOOLEAN_EXPECTED. + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript Boolean. + * @param result C boolean primitive equivalent of the given JavaScript Boolean. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_BOOLEAN_EXPECTED }If a non-boolean JSVM_Value is passed in it.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueBool(JSVM_Env env, @@ -1131,11 +1181,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueBool(JSVM_Env env, /** * @brief This API returns the C double primitive equivalent of the given JavaScript number. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript number. - * @param result: C double primitive equivalent of the given JavaScript number. - * @return Returns JSVM_OK if the API succeeded. - * If a non-number JSVM_Value is passed in it returns JSVM_NUMBER_EXPECTED. + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript number. + * @param result C double primitive equivalent of the given JavaScript number. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_NUMBER_EXPECTED } If a non-number JSVM_Value is passed in.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueDouble(JSVM_Env env, @@ -1146,11 +1197,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueDouble(JSVM_Env env, * @brief This API returns the C int64_t primitive equivalent of the given JavaScript BigInt. * If needed it will truncate the value, setting lossless to false. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript BigInt. - * @param result: C int64_t primitive equivalent of the given JavaScript BigInt. - * @param lossless: Indicates whether the BigInt value was converted losslessly. - * @return Returns JSVM_OK if the API succeeded. If a non-BigInt is passed in it returns JSVM_BIGINT_EXPECTED. + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript BigInt. + * @param result C int64_t primitive equivalent of the given JavaScript BigInt. + * @param lossless Indicates whether the BigInt value was converted losslessly. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_BIGINT_EXPECTED } If a non-BigInt is passed in it.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueBigintInt64(JSVM_Env env, @@ -1162,11 +1215,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueBigintInt64(JSVM_Env env, * @brief This API returns the C uint64_t primitive equivalent of the given JavaScript BigInt. * If needed it will truncate the value, setting lossless to false. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript BigInt. - * @param result: C uint64_t primitive equivalent of the given JavaScript BigInt. - * @param lossless: Indicates whether the BigInt value was converted losslessly. - * @return Returns JSVM_OK if the API succeeded. If a non-BigInt is passed in it returns JSVM_BIGINT_EXPECTED. + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript BigInt. + * @param result C uint64_t primitive equivalent of the given JavaScript BigInt. + * @param lossless Indicates whether the BigInt value was converted losslessly. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_BIGINT_EXPECTED } If a non-BigInt is passed in it.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueBigintUint64(JSVM_Env env, @@ -1178,13 +1233,14 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueBigintUint64(JSVM_Env env, * @brief This API converts a single BigInt value into a sign bit, 64-bit little-endian array, and the number * of elements in the array. signBit and words may be both set to NULL, in order to get only wordCount. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript BigInt. - * @param signBit: Integer representing if the JavaScript BigInt is positive or negative. - * @param wordCount: Must be initialized to the length of the words array. Upon return, it will be set to + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript BigInt. + * @param signBit Integer representing if the JavaScript BigInt is positive or negative. + * @param wordCount Must be initialized to the length of the words array. Upon return, it will be set to * the actual number of words that would be needed to store this BigInt. - * @param words: Pointer to a pre-allocated 64-bit word array. - * @return Returns JSVM_OK if the API succeeded. + * @param words Pointer to a pre-allocated 64-bit word array. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueBigintWords(JSVM_Env env, @@ -1196,10 +1252,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueBigintWords(JSVM_Env env, /** * @brief This API retrieves the external data pointer that was previously passed to OH_JSVM_CreateExternal(). * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript external value. - * @param result: Pointer to the data wrapped by the JavaScript external value. - * @return Returns JSVM_OK if the API succeeded. If a non-external JSVM_Value is passed in it returns JSVM_INVALID_ARG. + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript external value. + * @param result Pointer to the data wrapped by the JavaScript external value. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_INVALID_ARG } If a non-external JSVM_Value is passed in it.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueExternal(JSVM_Env env, @@ -1209,10 +1267,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueExternal(JSVM_Env env, /** * @brief This API returns the C int32 primitive equivalent of the given JavaScript number. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript number. - * @param result: C int32 primitive equivalent of the given JavaScript number. - * @return Returns JSVM_OK if the API succeeded. If a non-number JSVM_Value is passed in JSVM_NUMBER_EXPECTED. + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript number. + * @param result C int32 primitive equivalent of the given JavaScript number. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_NUMBER_EXPECTED } If a non-number JSVM_Value is passed in.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueInt32(JSVM_Env env, @@ -1222,10 +1282,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueInt32(JSVM_Env env, /** * @brief This API returns the C int64 primitive equivalent of the given JavaScript number. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript number. - * @param result: C int64 primitive equivalent of the given JavaScript number. - * @return Returns JSVM_OK if the API succeeded. If a non-number JSVM_Value is passed in JSVM_NUMBER_EXPECTED. + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript number. + * @param result C int64 primitive equivalent of the given JavaScript number. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_NUMBER_EXPECTED } If a non-number JSVM_Value is passed in.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueInt64(JSVM_Env env, @@ -1235,14 +1297,16 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueInt64(JSVM_Env env, /** * @brief This API returns the ISO-8859-1-encoded string corresponding the value passed in. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript string. - * @param buf: Buffer to write the ISO-8859-1-encoded string into. If NULL is passed in, the + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript string. + * @param buf Buffer to write the ISO-8859-1-encoded string into. If NULL is passed in, the * length of the string in bytes and excluding the null terminator is returned in result. - * @param bufsize: Size of the destination buffer. When this value is insufficient, the returned string + * @param bufsize Size of the destination buffer. When this value is insufficient, the returned string * is truncated and null-terminated. - * @param result: Number of bytes copied into the buffer, excluding the null terminator. - * @return Returns JSVM_OK if the API succeeded. If a non-number JSVM_Value is passed in JSVM_NUMBER_EXPECTED. + * @param result Number of bytes copied into the buffer, excluding the null terminator. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_NUMBER_EXPECTED } If a non-number JSVM_Value is passed in.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueStringLatin1(JSVM_Env env, @@ -1254,14 +1318,16 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueStringLatin1(JSVM_Env env, /** * @brief This API returns the UTF8-encoded string corresponding the value passed in. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript string. - * @param buf: Buffer to write the UTF8-encoded string into. If NULL is passed in, the length + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript string. + * @param buf Buffer to write the UTF8-encoded string into. If NULL is passed in, the length * of the string in bytes and excluding the null terminator is returned in result. - * @param bufsize: Size of the destination buffer. When this value is insufficient, the returned + * @param bufsize Size of the destination buffer. When this value is insufficient, the returned * string is truncated and null-terminated. - * @param result: Number of bytes copied into the buffer, excluding the null terminator. - * @return Returns JSVM_OK if the API succeeded. If a non-number JSVM_Value is passed in JSVM_NUMBER_EXPECTED. + * @param result Number of bytes copied into the buffer, excluding the null terminator. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_NUMBER_EXPECTED } If a non-number JSVM_Value is passed in.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueStringUtf8(JSVM_Env env, @@ -1273,14 +1339,16 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueStringUtf8(JSVM_Env env, /** * @brief This API returns the UTF16-encoded string corresponding the value passed in. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript string. - * @param buf: Buffer to write the UTF16-LE-encoded string into. If NULL is passed in, + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript string. + * @param buf Buffer to write the UTF16-LE-encoded string into. If NULL is passed in, * the length of the string in 2-byte code units and excluding the null terminator is returned. - * @param bufsize: Size of the destination buffer. When this value is insufficient, + * @param bufsize Size of the destination buffer. When this value is insufficient, * the returned string is truncated and null-terminated. - * @param result: Number of 2-byte code units copied into the buffer, excluding the null terminator. - * @return Returns JSVM_OK if the API succeeded. If a non-number JSVM_Value is passed in JSVM_NUMBER_EXPECTED. + * @param result Number of 2-byte code units copied into the buffer, excluding the null terminator. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_NUMBER_EXPECTED } If a non-number JSVM_Value is passed in.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueStringUtf16(JSVM_Env env, @@ -1292,11 +1360,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueStringUtf16(JSVM_Env env, /** * @brief This API returns the C primitive equivalent of the given JSVM_Value as a uint32_t. * - * @param env: The environment that the API is invoked under. - * @param value: JSVM_Value representing JavaScript number. - * @param result: C primitive equivalent of the given JSVM_Value as a uint32_t. - * @return Returns JSVM_OK if the API succeeded. - * If a non-number JSVM_Value is passed in it returns JSVM_NUMBER_EXPECTED. + * @param env The environment that the API is invoked under. + * @param value JSVM_Value representing JavaScript number. + * @param result C primitive equivalent of the given JSVM_Value as a uint32_t. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_NUMBER_EXPECTED } If a non-number JSVM_Value is passed in it.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueUint32(JSVM_Env env, @@ -1306,10 +1375,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetValueUint32(JSVM_Env env, /** * @brief This API is used to return the JavaScript singleton object that is used to represent the given boolean value. * - * @param env: The environment that the API is invoked under. - * @param value: The value of the boolean to retrieve. - * @param result: JSVM_Value representing JavaScript Boolean singleton to retrieve. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The value of the boolean to retrieve. + * @param result JSVM_Value representing JavaScript Boolean singleton to retrieve. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetBoolean(JSVM_Env env, @@ -1319,9 +1389,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetBoolean(JSVM_Env env, /** * @brief This API returns the global object. * - * @param env: The environment that the API is invoked under. - * @param result: JSVM_Value representing JavaScript global object. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param result JSVM_Value representing JavaScript global object. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetGlobal(JSVM_Env env, @@ -1330,9 +1401,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetGlobal(JSVM_Env env, /** * @brief This API returns the null object. * - * @param env: The environment that the API is invoked under. - * @param result: JSVM_Value representing JavaScript null object. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param result JSVM_Value representing JavaScript null object. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetNull(JSVM_Env env, @@ -1341,9 +1413,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetNull(JSVM_Env env, /** * @brief This API returns the Undefined object. * - * @param env: The environment that the API is invoked under. - * @param result: JSVM_Value representing JavaScript Undefined value. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param result JSVM_Value representing JavaScript Undefined value. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetUndefined(JSVM_Env env, @@ -1352,10 +1425,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetUndefined(JSVM_Env env, /** * @brief This API implements the abstract operation ToBoolean() * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to coerce. - * @param result: JSVM_Value representing the coerced JavaScript Boolean. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to coerce. + * @param result JSVM_Value representing the coerced JavaScript Boolean. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CoerceToBool(JSVM_Env env, @@ -1366,10 +1440,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CoerceToBool(JSVM_Env env, * @brief This API implements the abstract operation ToNumber() as defined. This * function potentially runs JS code if the passed-in value is an object. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to coerce. - * @param result: JSVM_Value representing the coerced JavaScript number. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to coerce. + * @param result JSVM_Value representing the coerced JavaScript number. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CoerceToNumber(JSVM_Env env, @@ -1379,10 +1454,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CoerceToNumber(JSVM_Env env, /** * @brief This API implements the abstract operation ToObject(). * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to coerce. - * @param result: JSVM_Value representing the coerced JavaScript Object. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to coerce. + * @param result JSVM_Value representing the coerced JavaScript Object. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CoerceToObject(JSVM_Env env, @@ -1393,10 +1469,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CoerceToObject(JSVM_Env env, * @brief This API implements the abstract operation ToString().This * function potentially runs JS code if the passed-in value is an object. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to coerce. - * @param result: JSVM_Value representing the coerced JavaScript string. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to coerce. + * @param result JSVM_Value representing the coerced JavaScript string. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CoerceToString(JSVM_Env env, @@ -1410,10 +1487,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CoerceToString(JSVM_Env env, * ECMAScript typeof would detect object.If value has a type that is invalid, * an error is returned. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value whose type to query. - * @param result: The type of the JavaScript value. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value whose type to query. + * @param result The type of the JavaScript value. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_Typeof(JSVM_Env env, @@ -1423,12 +1501,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_Typeof(JSVM_Env env, /** * @brief This API represents invoking the instanceof Operator on the object. * - * @param env: The environment that the API is invoked under. - * @param object: The JavaScript value to check. - * @param constructor: The JavaScript function object of the constructor function + * @param env The environment that the API is invoked under. + * @param object The JavaScript value to check. + * @param constructor The JavaScript function object of the constructor function * to check against. - * @param result: Boolean that is set to true if object instanceof constructor is true. - * @return Returns JSVM_OK if the API succeeded. + * @param result Boolean that is set to true if object instanceof constructor is true. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_Instanceof(JSVM_Env env, @@ -1439,10 +1518,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_Instanceof(JSVM_Env env, /** * @brief This API represents invoking the IsArray operation on the object * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to check. - * @param result: Whether the given object is an array. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to check. + * @param result Whether the given object is an array. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsArray(JSVM_Env env, @@ -1452,10 +1532,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsArray(JSVM_Env env, /** * @brief This API checks if the Object passed in is an array buffer. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to check. - * @param result: Whether the given object is an ArrayBuffer. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to check. + * @param result Whether the given object is an ArrayBuffer. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsArraybuffer(JSVM_Env env, @@ -1468,7 +1549,8 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsArraybuffer(JSVM_Env env, * @param env: The environment that the API is invoked under. * @param value: The JavaScript value to check. * @param result: Whether the given JSVM_Value represents a JavaScript Date object. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsDate(JSVM_Env env, @@ -1478,10 +1560,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsDate(JSVM_Env env, /** * @brief This API checks if the Object passed in is a typed array. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to check. - * @param result: Whether the given JSVM_Value represents a TypedArray. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to check. + * @param result Whether the given JSVM_Value represents a TypedArray. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsTypedarray(JSVM_Env env, @@ -1491,10 +1574,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsTypedarray(JSVM_Env env, /** * @brief This API checks if the Object passed in is a DataView. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to check. - * @param result: Whether the given JSVM_Value represents a DataView. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to check. + * @param result Whether the given JSVM_Value represents a DataView. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsDataview(JSVM_Env env, @@ -1503,13 +1587,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsDataview(JSVM_Env env, /** * @brief This API represents the invocation of the Strict Equality algorithm. - * Returns true only when both the type and value are equal. * - * @param env: The environment that the API is invoked under. - * @param lhs: The JavaScript value to check. - * @param rhs: The JavaScript value to check against. - * @param result: Whether the two JSVM_Value objects are equal. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param lhs The JavaScript value to check. + * @param rhs The JavaScript value to check against. + * @param result Whether the two JSVM_Value objects are equal. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_StrictEquals(JSVM_Env env, @@ -1521,11 +1605,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_StrictEquals(JSVM_Env env, * @brief This API represents the invocation of the Relaxed Equality algorithm. * Returns true as long as the values are equal, regardless of type. * - * @param env: The environment that the API is invoked under. - * @param lhs: The JavaScript value to check. - * @param rhs: The JavaScript value to check against. - * @param result: Whether the two JSVM_Value objects are relaxed equal. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param lhs The JavaScript value to check. + * @param rhs The JavaScript value to check against. + * @param result Whether the two JSVM_Value objects are relaxed equal. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_Equals(JSVM_Env env, @@ -1536,10 +1621,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_Equals(JSVM_Env env, /** * @brief This API represents the invocation of the ArrayBuffer detach operation. * - * @param env: The environment that the API is invoked under. - * @param arraybuffer: The JavaScript ArrayBuffer to be detached. - * @return Returns JSVM_OK if the API succeeded.If a non-detachable ArrayBuffer - * is passed in it returns JSVM_DETACHABLE_ARRAYBUFFER_EXPECTED. + * @param env The environment that the API is invoked under. + * @param arraybuffer The JavaScript ArrayBuffer to be detached. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_DETACHABLE_ARRAYBUFFER_EXPECTED } If a non-detachable ArrayBuffer is passed in it.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_DetachArraybuffer(JSVM_Env env, @@ -1548,10 +1634,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_DetachArraybuffer(JSVM_Env env, /** * @brief This API represents the invocation of the ArrayBuffer IsDetachedBuffer operation. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript ArrayBuffer to be checked. - * @param result: Whether the arraybuffer is detached. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript ArrayBuffer to be checked. + * @param result Whether the arraybuffer is detached. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsDetachedArraybuffer(JSVM_Env env, @@ -1562,12 +1649,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsDetachedArraybuffer(JSVM_Env env, * @brief This API returns the names of the enumerable properties of object as an array of * strings. The properties of object whose key is a symbol will not be included. * - * @param env: The environment that the API is invoked under. - * @param object: The object from which to retrieve the properties. - * @param result: A JSVM_Value representing an array of JavaScript values that represent + * @param env The environment that the API is invoked under. + * @param object The object from which to retrieve the properties. + * @param result A JSVM_Value representing an array of JavaScript values that represent * the property names of the object. The API can be used to iterate over result using * OH_JSVM_GetArrayLength and OH_JSVM_GetElement. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetPropertyNames(JSVM_Env env, @@ -1578,15 +1666,16 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetPropertyNames(JSVM_Env env, * @brief This API returns an array containing the names of the available properties * of this object. * - * @param env: The environment that the API is invoked under. - * @param object: The object from which to retrieve the properties. - * @param keyMode: Whether to retrieve prototype properties as well. - * @param keyFilter: Which properties to retrieve (enumerable/readable/writable). - * @param keyConversion: Whether to convert numbered property keys to strings. - * @param result: result: A JSVM_Value representing an array of JavaScript values + * @param env The environment that the API is invoked under. + * @param object The object from which to retrieve the properties. + * @param keyMode Whether to retrieve prototype properties as well. + * @param keyFilter Which properties to retrieve (enumerable/readable/writable). + * @param keyConversion Whether to convert numbered property keys to strings. + * @param result A JSVM_Value representing an array of JavaScript values * that represent the property names of the object. OH_JSVM_GetArrayLength and * OH_JSVM_GetElement can be used to iterate over result. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetAllPropertyNames(JSVM_Env env, @@ -1599,11 +1688,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetAllPropertyNames(JSVM_Env env, /** * @brief This API set a property on the Object passed in. * - * @param env: The environment that the API is invoked under. - * @param object: The object on which to set the property. - * @param key: The name of the property to set. - * @param value: The property value. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object on which to set the property. + * @param key The name of the property to set. + * @param value The property value. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_SetProperty(JSVM_Env env, @@ -1614,11 +1704,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_SetProperty(JSVM_Env env, /** * @brief This API gets the requested property from the Object passed in. * - * @param env: The environment that the API is invoked under. - * @param object: The object from which to retrieve the property. - * @param key: The name of the property to retrieve. - * @param result: The value of the property. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object from which to retrieve the property. + * @param key The name of the property to retrieve. + * @param result The value of the property. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetProperty(JSVM_Env env, @@ -1629,11 +1720,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetProperty(JSVM_Env env, /** * @brief This API checks if the Object passed in has the named property. * - * @param env: The environment that the API is invoked under. - * @param object: The object to query. - * @param key: The name of the property whose existence to check. - * @param result: Whether the property exists on the object or not. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object to query. + * @param key The name of the property whose existence to check. + * @param result Whether the property exists on the object or not. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_HasProperty(JSVM_Env env, @@ -1644,12 +1736,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_HasProperty(JSVM_Env env, /** * @brief This API attempts to delete the key own property from object. * - * @param env: The environment that the API is invoked under. - * @param object: The object to query. - * @param key: The name of the property to delete. - * @param result: Whether the property deletion succeeded or not. result + * @param env The environment that the API is invoked under. + * @param object The object to query. + * @param key The name of the property to delete. + * @param result Whether the property deletion succeeded or not. result * can optionally be ignored by passing NULL. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_DeleteProperty(JSVM_Env env, @@ -1662,11 +1755,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_DeleteProperty(JSVM_Env env, * key must be a string or a symbol, or an error will be thrown. JSVM-API will * not perform any conversion between data types. * - * @param env: The environment that the API is invoked under. - * @param object: The object to query. - * @param key: The name of the own property whose existence to check. - * @param result: Whether the own property exists on the object or not. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object to query. + * @param key The name of the own property whose existence to check. + * @param result Whether the own property exists on the object or not. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_HasOwnProperty(JSVM_Env env, @@ -1676,13 +1770,14 @@ JSVM_EXTERN JSVM_Status OH_JSVM_HasOwnProperty(JSVM_Env env, /** * @brief This method is equivalent to calling OH_JSVM_SetProperty with - * a JSVM_Value created from the string passed in as utf8Name. + * a JSVM_Value created from the string passed in as utf8name. * - * @param env: The environment that the API is invoked under. - * @param object: The object on which to set the property. - * @param utf8Name: The name of the property to set. - * @param value: The property value. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object on which to set the property. + * @param utf8name The name of the property to set. + * @param value The property value. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_SetNamedProperty(JSVM_Env env, @@ -1692,13 +1787,14 @@ JSVM_EXTERN JSVM_Status OH_JSVM_SetNamedProperty(JSVM_Env env, /** * @brief This method is equivalent to calling OH_JSVM_SetProperty with - * a JSVM_Value created from the string passed in as utf8Name. + * a JSVM_Value created from the string passed in as utf8name. * - * @param env: The environment that the API is invoked under. - * @param object: The object from which to retrieve the property. - * @param utf8Name: The name of the property to get. - * @param result: The value of the property. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object from which to retrieve the property. + * @param utf8name The name of the property to get. + * @param result The value of the property. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetNamedProperty(JSVM_Env env, @@ -1708,13 +1804,14 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetNamedProperty(JSVM_Env env, /** * @brief This method is equivalent to calling OH_JSVM_SetProperty with - * a JSVM_Value created from the string passed in as utf8Name. + * a JSVM_Value created from the string passed in as utf8name. * - * @param env: The environment that the API is invoked under. - * @param object: The object to query. - * @param utf8Name: The name of the property whose existence to check. - * @param result: Whether the property exists on the object or not. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object to query. + * @param utf8name The name of the property whose existence to check. + * @param result Whether the property exists on the object or not. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_HasNamedProperty(JSVM_Env env, @@ -1725,11 +1822,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_HasNamedProperty(JSVM_Env env, /** * @brief This API sets an element on the Object passed in. * - * @param env: The environment that the API is invoked under. - * @param object: The object from which to set the properties. - * @param index: The index of the property to set. - * @param value: The property value. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object from which to set the properties. + * @param index The index of the property to set. + * @param value The property value. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_SetElement(JSVM_Env env, @@ -1740,11 +1838,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_SetElement(JSVM_Env env, /** * @brief This API gets the element at the requested index. * - * @param env: The environment that the API is invoked under. - * @param object: The object from which to retrieve the property. - * @param index: The index of the property to get. - * @param result: The value of the property. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object from which to retrieve the property. + * @param index The index of the property to get. + * @param result The value of the property. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetElement(JSVM_Env env, @@ -1756,11 +1855,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetElement(JSVM_Env env, * @brief This API returns if the Object passed in has an element * at the requested index. * - * @param env: The environment that the API is invoked under. - * @param object: The object to query. - * @param index: The index of the property whose existence to check. - * @param result: Whether the property exists on the object or not. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object to query. + * @param index The index of the property whose existence to check. + * @param result Whether the property exists on the object or not. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_HasElement(JSVM_Env env, @@ -1771,12 +1871,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_HasElement(JSVM_Env env, /** * @brief This API attempts to delete the specified index from object. * - * @param env: The environment that the API is invoked under. - * @param object: The object to query. - * @param index: The index of the property to delete. - * @param result: Whether the element deletion succeeded or not. result + * @param env The environment that the API is invoked under. + * @param object The object to query. + * @param index The index of the property to delete. + * @param result Whether the element deletion succeeded or not. result * can optionally be ignored by passing NULL. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_DeleteElement(JSVM_Env env, @@ -1790,11 +1891,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_DeleteElement(JSVM_Env env, * Given an array of such property descriptors, this API will set the properties * on the object one at a time, as defined by DefineOwnProperty(). * - * @param env: The environment that the API is invoked under. - * @param object: The object from which to retrieve the properties. - * @param propertyCount: The number of elements in the properties array. - * @param properties: The array of property descriptors. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object from which to retrieve the properties. + * @param propertyCount The number of elements in the properties array. + * @param properties The array of property descriptors. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_DefineProperties(JSVM_Env env, @@ -1809,9 +1911,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_DefineProperties(JSVM_Env env, * properties, and prevents the values of existing properties from being changed. * It also prevents the object's prototype from being changed. * - * @param env: The environment that the API is invoked under. - * @param object: The object to freeze. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object to freeze. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_ObjectFreeze(JSVM_Env env, @@ -1821,9 +1924,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ObjectFreeze(JSVM_Env env, * @brief This method seals a given object. This prevents new properties * from being added to it, as well as marking all existing properties as non-configurable. * - * @param env: The environment that the API is invoked under. - * @param object: The object to seal. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param object The object to seal. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_ObjectSeal(JSVM_Env env, @@ -1834,13 +1938,14 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ObjectSeal(JSVM_Env env, * a native add-on. This is the primary mechanism of calling back from the * add-on's native code into JavaScript. * - * @param env: The environment that the API is invoked under. - * @param recv: The this value passed to the called function. - * @param func: JSVM_Value representing the JavaScript function to be invoked. - * @param argc: The count of elements in the argv array. - * @param argv: Array of JSVM_values representing JavaScript values passed in as arguments to the function. - * @param result: JSVM_Value representing the JavaScript object returned. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param recv The this value passed to the called function. + * @param func JSVM_Value representing the JavaScript function to be invoked. + * @param argc The count of elements in the argv array. + * @param argv Array of JSVM_values representing JavaScript values passed in as arguments to the function. + * @param result JSVM_Value representing the JavaScript object returned. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CallFunction(JSVM_Env env, @@ -1858,16 +1963,17 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CallFunction(JSVM_Env env, * object that is visible to JavaScript, in order for the function to be accessible * from script. * - * @param env: The environment that the API is invoked under. - * @param utf8Name: Optional name of the function encoded as UTF8. This is visible + * @param env The environment that the API is invoked under. + * @param utf8name Optional name of the function encoded as UTF8. This is visible * within JavaScript as the new function object's name property. - * @param length: The length of the utf8name in bytes, or JSVM_AUTO_LENGTH if it + * @param length The length of the utf8name in bytes, or JSVM_AUTO_LENGTH if it * is null-terminated. - * @param cb: The native function which should be called when this function + * @param cb The native function which should be called when this function * object is invoked and data. JSVM_Callback provides more details. - * @param result: JSVM_Value representing the JavaScript function object for the newly + * @param result JSVM_Value representing the JavaScript function object for the newly * created function. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateFunction(JSVM_Env env, @@ -1880,20 +1986,21 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateFunction(JSVM_Env env, * @brief This method is used within a callback function to retrieve details about * the call like the arguments and the this pointer from a given callback info. * - * @param env: The environment that the API is invoked under. - * @param cbinfo: The callback info passed into the callback function. - * @param argc: Specifies the length of the provided argv array and receives the + * @param env The environment that the API is invoked under. + * @param cbinfo The callback info passed into the callback function. + * @param argc Specifies the length of the provided argv array and receives the * actual count of arguments. argc can optionally be ignored by passing NULL. - * @param argv: C array of JSVM_values to which the arguments will be copied. If + * @param argv C array of JSVM_values to which the arguments will be copied. If * there are more arguments than the provided count, only the requested number of * arguments are copied. If there are fewer arguments provided than claimed, the * rest of argv is filled with JSVM_Value values that represent undefined. argv * can optionally be ignored by passing NULL. - * @param thisArg: Receives the JavaScript this argument for the call. thisArg + * @param thisArg Receives the JavaScript this argument for the call. thisArg * can optionally be ignored by passing NULL. - * @param data: Receives the data pointer for the callback. data can optionally + * @param data Receives the data pointer for the callback. data can optionally * be ignored by passing NULL. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetCbInfo(JSVM_Env env, @@ -1907,10 +2014,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetCbInfo(JSVM_Env env, * @brief This API returns the new.target of the constructor call. If the * current callback is not a constructor call, the result is NULL. * - * @param env: The environment that the API is invoked under. - * @param cbinfo: The callback info passed into the callback function. - * @param result: The new.target of the constructor call. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param cbinfo The callback info passed into the callback function. + * @param result The new.target of the constructor call. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetNewTarget(JSVM_Env env, @@ -1921,14 +2029,15 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetNewTarget(JSVM_Env env, * @brief his method is used to instantiate a new JavaScript value using * a given JSVM_Value that represents the constructor for the object. * - * @param env: The environment that the API is invoked under. - * @param constructor: JSVM_Value representing the JavaScript function to be invoked as a constructor. - * @param argc: The count of elements in the argv array. - * @param argv: Array of JavaScript values as JSVM_Value representing the arguments to + * @param env The environment that the API is invoked under. + * @param constructor JSVM_Value representing the JavaScript function to be invoked as a constructor. + * @param argc The count of elements in the argv array. + * @param argv Array of JavaScript values as JSVM_Value representing the arguments to * the constructor. If argc is zero this parameter may be omitted by passing in NULL. - * @param result: JSVM_Value representing the JavaScript object returned, which + * @param result JSVM_Value representing the JavaScript object returned, which * in this case is the constructed object. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_NewInstance(JSVM_Env env, @@ -1942,21 +2051,22 @@ JSVM_EXTERN JSVM_Status OH_JSVM_NewInstance(JSVM_Env env, * should be a static method on the class that calls the actual class constructor, then * wraps the new C++ instance in a JavaScript object, and returns the wrapper object. * - * @param env: The environment that the API is invoked under. - * @param utf8name: Name of the JavaScript constructor function. For clarity, it is + * @param env The environment that the API is invoked under. + * @param utf8name Name of the JavaScript constructor function. For clarity, it is * recommended to use the C++ class name when wrapping a C++ class. - * @param length: The length of the utf8name in bytes, or JSVM_AUTO_LENGTH if it + * @param length The length of the utf8name in bytes, or JSVM_AUTO_LENGTH if it * is null-terminated. - * @param constructor: Struct include callback function that handles constructing instances of the class. + * @param constructor Struct include callback function that handles constructing instances of the class. * When wrapping a C++ class, this method must be a static member with the JSVM_Callback.callback * signature. A C++ class constructor cannot be used. * Include Optional data to be passed to the constructor callback as the data * property of the callback info. JSVM_Callback provides more details. - * @param propertyCount: Number of items in the properties array argument. - * @param properties: Array of property descriptors describing static and instance data + * @param propertyCount Number of items in the properties array argument. + * @param properties Array of property descriptors describing static and instance data * properties, accessors, and methods on the class See JSVM_PropertyDescriptor. - * @param result: A JSVM_Value representing the constructor function for the class. - * @return Returns JSVM_OK if the API succeeded. + * @param result A JSVM_Value representing the constructor function for the class. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_DefineClass(JSVM_Env env, @@ -1971,15 +2081,16 @@ JSVM_EXTERN JSVM_Status OH_JSVM_DefineClass(JSVM_Env env, * @brief Wraps a native instance in a JavaScript object. The native instance can * be retrieved later using OH_JSVM_Unwrap(). * - * @param env: The environment that the API is invoked under. - * @param jsObject: The JavaScript object that will be the wrapper for the native object. - * @param nativeObject: The native instance that will be wrapped in the JavaScript object. - * @param finalizeCb: Optional native callback that can be used to free the native instance + * @param env The environment that the API is invoked under. + * @param jsObject The JavaScript object that will be the wrapper for the native object. + * @param nativeObject The native instance that will be wrapped in the JavaScript object. + * @param finalizeCb Optional native callback that can be used to free the native instance * when the JavaScript object has been garbage-collected. - * @param finalizeHint: Optional contextual hint that is passed to the finalize callback. + * @param finalizeHint Optional contextual hint that is passed to the finalize callback. * properties, accessors, and methods on the class See JSVM_PropertyDescriptor. - * @param result: Optional reference to the wrapped object. - * @return Returns JSVM_OK if the API succeeded. + * @param result Optional reference to the wrapped object. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_Wrap(JSVM_Env env, @@ -1995,10 +2106,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_Wrap(JSVM_Env env, * argument to the callback is the wrapper object; the wrapped C++ instance that is the target of * the call can be obtained then by calling OH_JSVM_Unwrap() on the wrapper object. * - * @param env: The environment that the API is invoked under. - * @param jsObject: The object associated with the native instance. - * @param result: Pointer to the wrapped native instance. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param jsObject The object associated with the native instance. + * @param result Pointer to the wrapped native instance. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_Unwrap(JSVM_Env env, @@ -2010,10 +2122,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_Unwrap(JSVM_Env env, * using OH_JSVM_Wrap() and removes the wrapping. If a finalize callback was associated with the wrapping, * it will no longer be called when the JavaScript object becomes garbage-collected. * - * @param env: The environment that the API is invoked under. - * @param jsObject: The object associated with the native instance. - * @param result: Pointer to the wrapped native instance. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param jsObject The object associated with the native instance. + * @param result Pointer to the wrapped native instance. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_RemoveWrap(JSVM_Env env, @@ -2026,10 +2139,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_RemoveWrap(JSVM_Env env, * object with one owned by the addon to ensure that the object has the right type. * If the object already has an associated type tag, this API will return JSVM_INVALID_ARG. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript object or external to be marked. - * @param typeTag: The tag with which the object is to be marked. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript object or external to be marked. + * @param typeTag The tag with which the object is to be marked. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n + * {@link JSVM_INVALID_ARG } If the object already has an associated type tag.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_TypeTagObject(JSVM_Env env, @@ -2041,12 +2156,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_TypeTagObject(JSVM_Env env, * If no tag is found on js object or, if a tag is found but it does not match typeTag, * then result is set to false. If a tag is found and it matches typeTag, then result is set to true. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript object or external whose type tag to examine. - * @param typeTag: The tag with which to compare any tag found on the object. - * @param result: Whether the type tag given matched the type tag on the object. false is also returned + * @param env The environment that the API is invoked under. + * @param value The JavaScript object or external whose type tag to examine. + * @param typeTag The tag with which to compare any tag found on the object. + * @param result Whether the type tag given matched the type tag on the object. false is also returned * if no type tag was found on the object. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CheckObjectTypeTag(JSVM_Env env, @@ -2057,14 +2173,15 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CheckObjectTypeTag(JSVM_Env env, /** * @brief This API can be called multiple times on a single JavaScript object. * - * @param env: The environment that the API is invoked under. - * @param jsObject: The JavaScript object to which the native data will be attached. - * @param finalizeData: Optional data to be passed to finalizeCb. - * @param finalizeCb: Native callback that will be used to free the native data when the + * @param env The environment that the API is invoked under. + * @param jsObject The JavaScript object to which the native data will be attached. + * @param finalizeData Optional data to be passed to finalizeCb. + * @param finalizeCb Native callback that will be used to free the native data when the * JavaScript object has been garbage-collected. JSVM_Finalize provides more details. - * @param finalizeHint: Optional contextual hint that is passed to the finalize callback. - * @param result: Optional reference to the JavaScript object. - * @return Returns JSVM_OK if the API succeeded. + * @param finalizeHint Optional contextual hint that is passed to the finalize callback. + * @param result Optional reference to the JavaScript object. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_AddFinalizer(JSVM_Env env, @@ -2081,9 +2198,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_AddFinalizer(JSVM_Env env, * API functions. In order to allow an addon to use a newer function when running with versions * of JSVM that support it, while providing fallback behavior when running with JSVM * versions that don't support it. - * @param env: The environment that the API is invoked under. - * @param result: The highest version of JSVM-API supported. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param result The highest version of JSVM-API supported. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetVersion(JSVM_Env env, @@ -2092,8 +2210,9 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetVersion(JSVM_Env env, /** * @brief Return information of the VM. * - * @param result: The information of the VM. - * @return Returns JSVM_OK if the API succeeded. + * @param result The information of the VM. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetVMInfo(JSVM_VMInfo* result); @@ -2105,11 +2224,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetVMInfo(JSVM_VMInfo* result); * externally allocated memory will trigger global garbage collections more often * than it would otherwise. * - * @param env: The environment that the API is invoked under. - * @param changeInBytes: The change in externally allocated memory that is kept + * @param env The environment that the API is invoked under. + * @param changeInBytes The change in externally allocated memory that is kept * alive by JavaScript objects. - * @param result: The adjusted value - * @return Returns JSVM_OK if the API succeeded. + * @param result The adjusted value + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_AdjustExternalMemory(JSVM_Env env, @@ -2120,9 +2240,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_AdjustExternalMemory(JSVM_Env env, * @brief This function notifies the VM that the system is running low on memory * and optionally triggers a garbage collection. * - * @param env: The environment that the API is invoked under. - * @param level: The memory pressure level set to the current VM. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param level The memory pressure level set to the current VM. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_MemoryPressureNotification(JSVM_Env env, @@ -2131,12 +2252,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_MemoryPressureNotification(JSVM_Env env, /** * @brief This API creates a deferred object and a JavaScript promise. * - * @param env: The environment that the API is invoked under. - * @param deferred: A newly created deferred object which can later be + * @param env The environment that the API is invoked under. + * @param deferred A newly created deferred object which can later be * passed to OH_JSVM_ResolveDeferred() or OH_JSVM_RejectDeferred() to resolve * resp. reject the associated promise. - * @param promise: The JavaScript promise associated with the deferred object. - * @return Returns JSVM_OK if the API succeeded. + * @param promise The JavaScript promise associated with the deferred object. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreatePromise(JSVM_Env env, @@ -2150,10 +2272,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreatePromise(JSVM_Env env, * that the promise must have been created using OH_JSVM_CreatePromise() and the deferred * object returned from that call must have been retained in order to be passed to this API. * - * @param env: The environment that the API is invoked under. - * @param deferred: The deferred object whose associated promise to resolve. - * @param resolution: The value with which to resolve the promise. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param deferred The deferred object whose associated promise to resolve. + * @param resolution The value with which to resolve the promise. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_ResolveDeferred(JSVM_Env env, @@ -2167,10 +2290,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ResolveDeferred(JSVM_Env env, * that the promise must have been created using OH_JSVM_CreatePromise() and the deferred * object returned from that call must have been retained in order to be passed to this API. * - * @param env: The environment that the API is invoked under. - * @param deferred: The deferred object whose associated promise to resolve. - * @param rejection: The value with which to reject the promise. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param deferred The deferred object whose associated promise to resolve. + * @param rejection The value with which to reject the promise. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_RejectDeferred(JSVM_Env env, @@ -2179,10 +2303,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_RejectDeferred(JSVM_Env env, /** * @brief This API return indicating whether promise is a native promise object. - * @param env: The environment that the API is invoked under. - * @param value: The value to examine - * @param isPromise: Flag indicating whether promise is a native promise object - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The value to examine + * @param isPromise Flag indicating whether promise is a native promise object + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsPromise(JSVM_Env env, @@ -2191,10 +2316,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsPromise(JSVM_Env env, /** * @brief This API parses a JSON string and returns it as value if successful. - * @param env: The environment that the API is invoked under. - * @param jsonString: The string to parse. - * @param result: The parse value if successful. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param jsonString The string to parse. + * @param result The parse value if successful. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_JsonParse(JSVM_Env env, @@ -2203,10 +2329,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_JsonParse(JSVM_Env env, /** * @brief This API stringifies the object and returns it as string if successful. - * @param env: The environment that the API is invoked under. - * @param jsonObject: The object to stringify. - * @param result: The string if successfully stringified. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param jsonObject The object to stringify. + * @param result The string if successfully stringified. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_JsonStringify(JSVM_Env env, @@ -2215,12 +2342,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_JsonStringify(JSVM_Env env, /** * @brief This API create the startup snapshot of the VM. - * @param vm: The environment that the API is invoked under. - * @param contextCount: The object to stringify. - * @param contexts: The array of contexts to add to the snapshot. - * @param blobData: The snapshot data. - * @param blobSize: The size of snapshot data. - * @return Returns JSVM_OK if the API succeeded. + * @param vm The environment that the API is invoked under. + * @param contextCount The object to stringify. + * @param contexts The array of contexts to add to the snapshot. + * @param blobData The snapshot data. + * @param blobSize The size of snapshot data. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 11 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateSnapshot(JSVM_VM vm, @@ -2232,9 +2360,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateSnapshot(JSVM_VM vm, /** * @brief This function returns a set of statistics data of the heap of the VM. * - * @param vm: The VM whose heap statistics are returned. - * @param result: The heap statistics data. - * @return Returns JSVM_OK if the API succeeded. + * @param vm The VM whose heap statistics are returned. + * @param result The heap statistics data. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } in all cases.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_GetHeapStatistics(JSVM_VM vm, @@ -2243,9 +2372,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_GetHeapStatistics(JSVM_VM vm, /** * @brief This function creates and starts a CPU profiler. * - * @param vm: The VM to start CPU profiler for. - * @param result: The pointer to the CPU profiler. - * @return Returns JSVM_OK if the API succeeded. + * @param vm The VM to start CPU profiler for. + * @param result The pointer to the CPU profiler. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } in all cases.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_StartCpuProfiler(JSVM_VM vm, @@ -2254,11 +2384,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_StartCpuProfiler(JSVM_VM vm, /** * @brief This function stops the CPU profiler and output to the stream. * - * @param vm: THe VM to start CPU profiler for. - * @param profiler: The CPU profiler to stop. - * @param stream: The output stream callback for receiving the data. - * @param streamData: Optional data to be passed to the stream callback. - * @return Returns JSVM_OK if the API succeeded. + * @param vm THe VM to start CPU profiler for. + * @param profiler The CPU profiler to stop. + * @param stream The output stream callback for receiving the data. + * @param streamData Optional data to be passed to the stream callback. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } in all cases.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_StopCpuProfiler(JSVM_VM vm, @@ -2269,10 +2400,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_StopCpuProfiler(JSVM_VM vm, /** * @brief This funciton takes the current heap snapshot and output to the stream. * - * @param vm: The VM whose heap snapshot is taken. - * @param stream: The output stream callback for receiving the data. - * @param streamData: Optional data to be passed to the stream callback. - * @return Returns JSVM_OK if the API succeeded. + * @param vm The VM whose heap snapshot is taken. + * @param stream The output stream callback for receiving the data. + * @param streamData Optional data to be passed to the stream callback. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } in all cases.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_TakeHeapSnapshot(JSVM_VM vm, @@ -2282,10 +2414,12 @@ JSVM_EXTERN JSVM_Status OH_JSVM_TakeHeapSnapshot(JSVM_VM vm, /** * @brief This functiong activates insepctor on host and port. * - * @param env: The environment that the API is invoked under. - * @param host: The host to listen to for inspector connections. - * @param port: The port to listen to for inspector connections. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param host The host to listen to for inspector connections. + * @param port The port to listen to for inspector connections. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } if the function executed successfully.\n + * Returns {@link JSVM_PENDING_EXCEPTION } if an exception occurs.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_OpenInspector(JSVM_Env env, @@ -2295,8 +2429,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_OpenInspector(JSVM_Env env, /** * @brief This function attempts to close all remaining inspector connections. * - * @param env: The environment that the API is invoked under. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } if the function executed successfully.\n + * Returns {@link JSVM_PENDING_EXCEPTION } if an exception occurs.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_CloseInspector(JSVM_Env env); @@ -2305,37 +2441,38 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CloseInspector(JSVM_Env env); * @brief This function will block until a client (existing or connected later) * has sent Runtime.runIfWaitingForDebugger command. * - * @param env: The environment that the API is invoked under. - * @param breakNextLine: Whether break on the next line of JavaScript code. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param breakNextLine Whether break on the next line of JavaScript code. + * @return Returns JSVM funtions result code. + * Returns {@link JSVM_OK } if the function executed successfully.\n + * Returns {@link JSVM_PENDING_EXCEPTION } if an exception occurs.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_WaitForDebugger(JSVM_Env env, bool breakNextLine); /** - * @brief When packaging C++classes, the C++constructor callback passed through the constructor - * triggers the corresponding callback function when getter, setter, call, and other - * behaviors occur on the instance object, handles the user's custom behavior, and then wraps - * the new C++instance in a JavaScript object and returns the wrapper object. + * @brief Define a JavaScript class with given class name, constructor, properties, callback handlers for + * property operations including get, set, delete, enum etc., and call as function callback. * - * @param env: The environment that the API is invoked under. - * @param utf8name: Name of the JavaScript constructor function. For clarity, it is + * @param env The environment that the API is invoked under. + * @param utf8name Name of the JavaScript constructor function. For clarity, it is * recommended to use the C++ class name when wrapping a C++ class. - * @param length: The length of the utf8name in bytes, or JSVM_AUTO_LENGTH if it + * @param length The length of the utf8name in bytes, or JSVM_AUTO_LENGTH if it * is null-terminated. - * @param constructor: Struct include callback function that handles constructing instances of the class. + * @param constructor Struct include callback function that handles constructing instances of the class. * When wrapping a C++ class, this method must be a static member with the JSVM_Callback.callback * signature. A C++ class constructor cannot be used. * Include Optional data to be passed to the constructor callback as the data * property of the callback info. JSVM_Callback provides more details. - * @param propertyCount: Number of items in the properties array argument. - * @param properties: Array of property descriptors describing static and instance data + * @param propertyCount Number of items in the properties array argument. + * @param properties Array of property descriptors describing static and instance data * properties, accessors, and methods on the class See JSVM_PropertyDescriptor. - * @param propertyHandlerCfg: The instance object triggers the corresponding callback function. - * @param callAsFunctionCallback: Calling an instance object as a function will trigger this callback. - * @param result: A JSVM_Value representing the constructor function for the class. - * @return Returns JSVM_OK if the API succeeded. + * @param propertyHandlerCfg The instance object triggers the corresponding callback function. + * @param callAsFunctionCallback Calling an instance object as a function will trigger this callback. + * @param result A JSVM_Value representing the constructor function for the class. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_DefineClassWithPropertyHandler(JSVM_Env env, @@ -2352,9 +2489,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_DefineClassWithPropertyHandler(JSVM_Env env, * @brief Determines whether the current thread holds the lock for the specified environment. * Only threads that hold locks can use the environment. * - * @param env: The environment that the API is invoked under. - * @param isLocked: Flag indicating whether the current thread holds the lock for the specified environment. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param isLocked Flag indicating whether the current thread holds the lock for the specified environment. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsLocked(JSVM_Env env, @@ -2363,8 +2501,9 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsLocked(JSVM_Env env, /** * @brief Acquire the lock for the specified environment. Only threads that hold locks can use the environment. * - * @param env: The environment that the API is invoked under. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_AcquireLock(JSVM_Env env); @@ -2372,8 +2511,9 @@ JSVM_EXTERN JSVM_Status OH_JSVM_AcquireLock(JSVM_Env env); /** * @brief Release the lock for the specified environment. Only threads that hold locks can use the environment. * - * @param env: The environment that the API is invoked under. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_ReleaseLock(JSVM_Env env); @@ -2384,7 +2524,8 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ReleaseLock(JSVM_Env env); * * @param env: The VM instance on which to start the task queue. * @param result: Whether the task queue was successfully started. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_PumpMessageLoop(JSVM_VM vm, @@ -2394,7 +2535,8 @@ JSVM_EXTERN JSVM_Status OH_JSVM_PumpMessageLoop(JSVM_VM vm, * @brief Check to see if there are any microtasks waiting in the queue, and if there are, execute them. * * @param env: The VM instance on which to check microtasks. - * @return Returns JSVM_OK if the API succeeded. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_PerformMicrotaskCheckpoint(JSVM_VM vm); @@ -2402,10 +2544,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_PerformMicrotaskCheckpoint(JSVM_VM vm); /** * @brief This API checks if the value passed in is callable. * - * @param env: The VM instance on which to check microtasks. - * @param value: The JavaScript value to check. - * @param isCallable: Whether the given value is callable. - * @return Returns JSVM_OK if the API succeeded. + * @param env The VM instance on which to check microtasks. + * @param value The JavaScript value to check. + * @param isCallable Whether the given value is callable. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } If the function executed successfully.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsCallable(JSVM_Env env, @@ -2416,10 +2559,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsCallable(JSVM_Env env, * @brief This API checks if the value passed in is undefined. * This equals to `value === undefined` in JS. * - * @param env: The VM instance on which to check microtasks. - * @param value: The JavaScript value to check. - * @param isUndefined: Whether the given value is Undefined. - * @return Only returns JSVM_OK, because this API will not trigger any exception. + * @param env The VM instance on which to check microtasks. + * @param value The JavaScript value to check. + * @param isUndefined Whether the given value is Undefined. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } This API will not trigger any exception.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsUndefined(JSVM_Env env, @@ -2430,10 +2574,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsUndefined(JSVM_Env env, * @brief This API checks if the value passed in is a null object. * This equals to `value === null` in JS. * - * @param env: The VM instance on which to check microtasks. - * @param value: The JavaScript value to check. - * @param isNull: Whether the given value is Null. - * @return Only returns JSVM_OK, because this API will not trigger any exception. + * @param env The VM instance on which to check microtasks. + * @param value The JavaScript value to check. + * @param isNull Whether the given value is Null. + * @return Only returns JSVM funtions result code. + * {@link JSVM_OK } This API will not trigger any exception.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsNull(JSVM_Env env, @@ -2444,10 +2589,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsNull(JSVM_Env env, * @brief This API checks if the value passed in is either a null or an undefined object. * This is equivalent to `value == null` in JS. * - * @param env: The VM instance on which to check microtasks. - * @param value: The JavaScript value to check. - * @param isNullOrUndefined: Whether the given value is Null or Undefined. - * @return Only returns JSVM_OK, because this API will not trigger any exception. + * @param env The VM instance on which to check microtasks. + * @param value The JavaScript value to check. + * @param isNullOrUndefined Whether the given value is Null or Undefined. + * @return Only returns JSVM funtions result code. + * {@link JSVM_OK } This API will not trigger any exception.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsNullOrUndefined(JSVM_Env env, @@ -2458,10 +2604,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsNullOrUndefined(JSVM_Env env, * @brief This API checks if the value passed in is a boolean. * This equals to `typeof value === 'boolean'` in JS. * - * @param env: The VM instance on which to check microtasks. - * @param value: The JavaScript value to check. - * @param isBoolean: Whether the given value is Boolean. - * @return Only returns JSVM_OK, because this API will not trigger any exception. + * @param env The VM instance on which to check microtasks. + * @param value The JavaScript value to check. + * @param isBoolean Whether the given value is Boolean. + * @return Only returns JSVM funtions result code. + * {@link JSVM_OK } This API will not trigger any exception.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsBoolean(JSVM_Env env, @@ -2472,10 +2619,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsBoolean(JSVM_Env env, * @brief This API checks if the value passed in is a number. * This equals to `typeof value === 'number'` in JS. * - * @param env: The VM instance on which to check microtasks. - * @param value: The JavaScript value to check. - * @param isNumber: Whether the given value is Number. - * @return Only returns JSVM_OK, because this API will not trigger any exception. + * @param env The VM instance on which to check microtasks. + * @param value The JavaScript value to check. + * @param isNumber Whether the given value is Number. + * @return Only returns JSVM funtions result code. + * {@link JSVM_OK } This API will not trigger any exception.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsNumber(JSVM_Env env, @@ -2486,10 +2634,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsNumber(JSVM_Env env, * @brief This API checks if the value passed in is a string. * This equals to `typeof value === 'string'` in JS. * - * @param env: The VM instance on which to check microtasks. - * @param value: The JavaScript value to check. - * @param isString: Whether the given value is String. - * @return Only returns JSVM_OK, because this API will not trigger any exception. + * @param env The VM instance on which to check microtasks. + * @param value The JavaScript value to check. + * @param isString Whether the given value is String. + * @return Only returns JSVM funtions result code. + * {@link JSVM_OK } This API will not trigger any exception.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsString(JSVM_Env env, @@ -2500,10 +2649,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsString(JSVM_Env env, * @brief This API checks if the value passed in is a symbol. * This equals to `typeof value === 'symbol'` in JS. * - * @param env: The VM instance on which to check microtasks. - * @param value: The JavaScript value to check. - * @param isSymbol: Whether the given value is Symbol. - * @return Only returns JSVM_OK, because this API will not trigger any exception. + * @param env The VM instance on which to check microtasks. + * @param value The JavaScript value to check. + * @param isSymbol Whether the given value is Symbol. + * @return Only returns JSVM funtions result code. + * {@link JSVM_OK } This API will not trigger any exception.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsSymbol(JSVM_Env env, @@ -2514,10 +2664,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsSymbol(JSVM_Env env, * @brief This API checks if the value passed in is a function. * This equals to `typeof value === 'function'` in JS. * - * @param env: The VM instance on which to check microtasks. - * @param value: The JavaScript value to check. - * @param isFunction: Whether the given value is Function. - * @return Only returns JSVM_OK, because this API will not trigger any exception. + * @param env The VM instance on which to check microtasks. + * @param value The JavaScript value to check. + * @param isFunction Whether the given value is Function. + * @return Only returns JSVM funtions result code. + * {@link JSVM_OK } This API will not trigger any exception.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsFunction(JSVM_Env env, @@ -2527,10 +2678,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsFunction(JSVM_Env env, /** * @brief This API checks if the value passed in is an object. * - * @param env: The VM instance on which to check microtasks. - * @param value: The JavaScript value to check. - * @param isObject: Whether the given value is Object. - * @return Only returns JSVM_OK, because this API will not trigger any exception. + * @param env The VM instance on which to check microtasks. + * @param value The JavaScript value to check. + * @param isObject Whether the given value is Object. + * @return Only returns JSVM funtions result code. + * {@link JSVM_OK } This API will not trigger any exception.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsObject(JSVM_Env env, @@ -2541,10 +2693,11 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsObject(JSVM_Env env, * @brief This API checks if the value passed in is a bigInt. * This equals to `typeof value === 'bigint'` in JS. * - * @param env: The VM instance on which to check microtasks. - * @param value: The JavaScript value to check. - * @param isBigInt: Whether the given value is BigInt. - * @return Only returns JSVM_OK, because this API will not trigger any exception. + * @param env The VM instance on which to check microtasks. + * @param value The JavaScript value to check. + * @param isBigInt Whether the given value is BigInt. + * @return Only returns JSVM funtions result code. + * {@link JSVM_OK } This API will not trigger any exception.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsBigInt(JSVM_Env env, @@ -2552,46 +2705,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsBigInt(JSVM_Env env, bool* isBigInt); /** - * @brief This API checks if the value passed in is a constructor. - * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to check. - * @param isConstructor: Whether the given value is Constructor. - * @return Returns JSVM_OK if the API succeeded. Returns JSVM_INVALID_ARG if the API failed. - * @since 12 - */ -JSVM_Status JSVM_CDECL OH_JSVM_IsConstructor(JSVM_Env env, - JSVM_Value value, - bool* isConstructor); - -/** - * @brief This API returns the JavaScript value of the regular expression - * corresponding to the input. - * The interface may throw an exception. + * @brief This API returns a JSVM-API value corresponding to a JavaScript Map type. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript string to convert to a regular expression. - * @param flags: Regular expression flag bits. - * @param result: A JSVM_Value representing a JavaScript RegExp. + * @param env The environment that the API is invoked under. + * @param result A JSVM_Value representing a JavaScript Map. * @return Only returns JSVM function's result code. * {@link JSVM_OK } If the API succeeded.\n * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n - * {@link JSVM_STRING_EXPECTED } If the value of 'value' is not a string.\n - * {@link JSVM_GENERIC_FAILURE } If create RegExp failed.\n - * {@link JSVM_PENDING_EXCEPTION } If the API throws an exception during runtime.\n - * @since 12 - */ -JSVM_Status JSVM_CDECL OH_JSVM_CreateRegExp(JSVM_Env env, - JSVM_Value value, - JSVM_RegExpFlags flags, - JSVM_Value* result); - -/** - * @brief This API returns a JSVM-API value corresponding to a JavaScript Map type. - * - * @param env: The environment that the API is invoked under. - * @param result: A JSVM_Value representing a JavaScript Map. - * @return Returns JSVM_OK if the API succeeded. Returns JSVM_INVALID_ARG if the API failed. * @since 12 */ JSVM_Status JSVM_CDECL OH_JSVM_CreateMap(JSVM_Env env, JSVM_Value* result); @@ -2599,10 +2719,12 @@ JSVM_Status JSVM_CDECL OH_JSVM_CreateMap(JSVM_Env env, JSVM_Value* result); /** * @brief This API checks if the value passed in is a Map. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to check. - * @param isMap: Whether the given value is Map. - * @return Returns JSVM_OK if the API succeeded. Returns JSVM_INVALID_ARG if the API failed. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to check. + * @param isMap Whether the given value is Map. + * @return Only returns JSVM function's result code. + * {@link JSVM_OK } If the API succeeded.\n + * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n * @since 12 */ JSVM_Status JSVM_CDECL OH_JSVM_IsMap(JSVM_Env env, @@ -2612,9 +2734,11 @@ JSVM_Status JSVM_CDECL OH_JSVM_IsMap(JSVM_Env env, /** * @brief This API returns a JSVM-API value corresponding to a JavaScript Set type. * - * @param env: The environment that the API is invoked under. - * @param result: A JSVM_Value representing a JavaScript Set. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param result A JSVM_Value representing a JavaScript Set. + * @return Returns JSVM function's result code. + * {@link JSVM_OK } If the API succeeded.\n + * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateSet(JSVM_Env env, @@ -2623,50 +2747,48 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateSet(JSVM_Env env, /** * @brief This API checks if the value passed in is a Set. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to check. - * @param isSet: Whether the given value is Set. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to check. + * @param isSet Whether the given value is Set. + * @return Returns JSVM function's result code. + * {@link JSVM_OK } If the API succeeded.\n + * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsSet(JSVM_Env env, - JSVM_Value value, - bool* isSet); + JSVM_Value value, + bool* isSet); /** - * @brief This API returns the Object prototype. - * - * @param env: The environment that the API is invoked under. - * @param object: JSVM_Value representing JavaScript Object whose prototype to return. - * @param result: JSVM_Value representing prototype of the given object. - * @return Returns JSVM_OK if the API succeeded. - * @since 12 - */ -JSVM_EXTERN JSVM_Status OH_JSVM_ObjectGetPrototypeOf(JSVM_Env env, - JSVM_Value object, - JSVM_Value* result); - -/** - * @brief This API set the prototype on the Object passed in. + * @brief This function compiles a string of JavaScript code with the compile options + * and returns the compiled script. * - * @param env: The environment that the API is invoked under. - * @param object: The object on which to set the prototype. - * @param prototype: The prototype value. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the JSVM-API call is invoked under. + * @param script A JavaScript string containing the script to be compiled. + * @param optionCount length of option array. + * @param options Compile options to be passed. + * @param result The compiled script. + * @return Returns JSVM functions result code + * {@link JSVM_OK } if the API succeeded. \n + * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n * @since 12 */ -JSVM_EXTERN JSVM_Status OH_JSVM_ObjectSetPrototypeOf(JSVM_Env env, - JSVM_Value object, - JSVM_Value prototype); +JSVM_EXTERN JSVM_Status OH_JSVM_CompileScriptWithOptions(JSVM_Env env, + JSVM_Value script, + size_t optionCount, + JSVM_CompileOptions options[], + JSVM_Script* result); /** - * @brief This API implements the abstract operation `ToBigInt()`. + * @brief This API implements the abstract operation ToBigInt(). * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to coerce. - * @param result: JSVM_Value representing the coerced JavaScript BigInt. - * @return Returns JSVM_OK if the API succeeded. Returns JSVM_BIGINT_EXPECTED if the - * JavaScript value fails to coerce. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to coerce. + * @param result JSVM_Value representing the coerced JavaScript BigInt. + * @return Returns JSVM function's result code. + * {@link JSVM_OK } If the API succeeded. + * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n + * {@link JSVM_BIGINT_EXPECTED} If the JavaScript value fails to coerce.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_CoerceToBigInt(JSVM_Env env, @@ -2674,32 +2796,106 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CoerceToBigInt(JSVM_Env env, JSVM_Value* result); /** - * @brief This API checks if the value passed in is a JavaScript RegExp object. + * @brief This API checks if the value passed in is a regExp. + * This equals to `value instanceof RegExp` in JS. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to check. - * @param result: Whether the given value is RegExp. - * @return Returns JSVM_OK if the API succeeded. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to check. + * @param result Whether the given value is RegExp. + * @return Returns JSVM function's result code. + * {@link JSVM_OK } If the API succeeded.\n + * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_IsRegExp(JSVM_Env env, JSVM_Value value, bool* result); + +/** + * @brief This API checks if the value passed in is a constructor. + * + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to check. + * @param isConstructor Whether the given value is Constructor. + * @return Only returns JSVM function's result code. + * {@link JSVM_OK } If the API succeeded.\n + * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n + * @since 12 + */ +JSVM_Status JSVM_CDECL OH_JSVM_IsConstructor(JSVM_Env env, + JSVM_Value value, + bool* isConstructor); + +/** + * @brief This API returns the JavaScript value of the regular expression + * corresponding to the input. + * The interface may throw an exception. + * + * @param env The environment that the API is invoked under. + * @param value The JavaScript string to convert to a regular expression. + * @param flags Regular expression flag bits. + * @param result A JSVM_Value representing a JavaScript RegExp. + * @return Only returns JSVM function's result code. + * {@link JSVM_OK } If the API succeeded.\n + * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n + * {@link JSVM_STRING_EXPECTED } If the value of 'value' is not a string.\n + * {@link JSVM_GENERIC_FAILURE } If create RegExp failed.\n + * {@link JSVM_PENDING_EXCEPTION } If the API throws an exception during runtime.\n + * @since 12 + */ +JSVM_Status JSVM_CDECL OH_JSVM_CreateRegExp(JSVM_Env env, + JSVM_Value value, + JSVM_RegExpFlags flags, + JSVM_Value* result); + +/** + * @brief This API returns the Object prototype. + * + * @param env The environment that the API is invoked under. + * @param object JSVM_Value representing JavaScript Object whose prototype to return. This returns + * the equivalent of Object.getPrototypeOf (which is not the same as the function's prototype property). + * @param result JSVM_Value representing prototype of the given object. + * @return Returns JSVM function's result code. + * {@link JSVM_OK } If the API succeeded.\n + * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n + * @since 12 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_ObjectGetPrototypeOf(JSVM_Env env, + JSVM_Value object, + JSVM_Value* result); + +/** + * @brief This API set the prototype on the Object passed in. + * + * @param env The environment that the API is invoked under. + * @param object The object on which to set the prototype. + * @param prototype The prototype value. + * @return Returns JSVM function's result code. + * {@link JSVM_OK } If the API succeeded.\n + * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n + * @since 12 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_ObjectSetPrototypeOf(JSVM_Env env, + JSVM_Value object, + JSVM_Value prototype); + /** * @brief Creates a function with a given script as its body. * - * @param env: The environment that the API is invoked under. - * @param funcName: A string containing the function's name. Pass NULL to create an anonymous function. - * @param length: The length of the funcName in bytes, or JSVM_AUTO_LENGTH if it + * @param env The environment that the API is invoked under. + * @param funcName A string containing the function's name. Pass NULL to create an anonymous function. + * @param length The length of the funcName in bytes, or JSVM_AUTO_LENGTH if it * is null-terminated. - * @param argc: The count of elements in the argv array. - * @param argv: Array of JSVM_Values representing JavaScript strings passed in as arguments to the function. - * @param script: A JavaScript string containing the script to use as the function's body. - * @param result: JSVM_Value representing the JavaScript function object for the newly + * @param argc The count of elements in the argv array. + * @param argv Array of JSVM_Values representing JavaScript strings passed in as arguments to the function. + * @param script A JavaScript string containing the script to use as the function's body. + * @param result JSVM_Value representing the JavaScript function object for the newly * created function. - * @return Returns JSVM_OK if the API succeeded. Returns JSVM_GENERIC_FAILURE if the input script fails to - * be compiled. + * @return Returns JSVM function's result code. + * {@link JSVM_OK } If the API succeeded. + * {@link JSVM_INVALID_ARG } If the input parameter is invalid.\n + * {@link JSVM_GENERIC_FAILURE} If the input script fails to be compiled.\n * @since 12 */ JSVM_EXTERN JSVM_Status OH_JSVM_CreateFunctionWithScript(JSVM_Env env, @@ -2714,8 +2910,8 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateFunctionWithScript(JSVM_Env env, * @brief This function keep persistently save a JSVM_Script and extend its lifecycle * beyond the current scope. * - * @param env: The environment that the API is invoked under. - * @param script: A JavaScript string containing the script to be retained. + * @param env The environment that the API is invoked under. + * @param script A JavaScript string containing the script to be retained. * @return Returns JSVM functions result code * {@link JSVM_OK } if the API succeeded. \n * {@link JSVM_INVALID_ARG } if the script is empty or already retained. \n @@ -2726,8 +2922,8 @@ JSVM_EXTERN JSVM_Status OH_JSVM_RetainScript(JSVM_Env env, JSVM_Script script); /** * @brief This function release the script retained by OH_JSVM_RetainScript * - * @param env: The environment that the API is invoked under. - * @param script: A JavaScript string containing the script to be retained. + * @param env The environment that the API is invoked under. + * @param script A JavaScript string containing the script to be retained. * @return Returns JSVM functions result code * {@link JSVM_OK } if the API succeeded. \n * {@link JSVM_INVALID_ARG } if the script is empty or not retained. \n @@ -2738,9 +2934,9 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ReleaseScript(JSVM_Env env, JSVM_Script script); /** * @brief This function activates insepctor with pid and alias it. * - * @param env: The environment that the API is invoked under. - * @param pid: A process id to identify the inspector connection. - * @param name: An alias for the inspector that under a specific pid. + * @param env The environment that the API is invoked under. + * @param pid A process id to identify the inspector connection. + * @param name An alias for the inspector that under a specific pid. * default name is jsvm if a nullptr is passed in. * @return Returns JSVM funtions result code. * Returns {@link JSVM_OK } if the function executed successfully.\n @@ -2755,13 +2951,13 @@ JSVM_EXTERN JSVM_Status OH_JSVM_OpenInspectorWithName(JSVM_Env env, * @brief Compile WebAssembly bytecode into a WebAssembly module. * If WebAssembly cache provided, deserialization will be performed. * - * @param env: The environment that the API is invoked under. - * @param wasmBytecode: WebAssembly bytecode. - * @param wasmBytecodeLength: WebAssembly bytecode length in byte. - * @param cacheData: Optional WebAssembly cache. - * @param cacheDataLength: Optional WebAssembly cache length in byte. - * @param cacheRejected: Output parameter representing whether the provided cacheData is rejected. - * @param wasmModule: Output parameter representing compiled WebAssembly module. + * @param env The environment that the API is invoked under. + * @param wasmBytecode WebAssembly bytecode. + * @param wasmBytecodeLength WebAssembly bytecode length in byte. + * @param cacheData Optional WebAssembly cache. + * @param cacheDataLength Optional WebAssembly cache length in byte. + * @param cacheRejected Output parameter representing whether the provided cacheData is rejected. + * @param wasmModule Output parameter representing compiled WebAssembly module. * @return Returns JSVM funtions result code. * Returns {@link JSVM_OK } if the function executed successfully.\n * Returns {@link JSVM_INVALID_ARG } if any of env, wasmBytecode is NULL, or data length is invalid.\n @@ -2782,10 +2978,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CompileWasmModule(JSVM_Env env, * @brief Compile the function with the specified index in the WebAssembly module * into the specified optimization level. * - * @param env: The environment that the API is invoked under. - * @param wasmModule: The WebAssembly module to which the function to compiled belongs. - * @param functionIndex: The index of the function to be compiled, should never be out of range. - * @param optLevel: Optimization level the function will be compiled with. + * @param env The environment that the API is invoked under. + * @param wasmModule The WebAssembly module to which the function to compiled belongs. + * @param functionIndex The index of the function to be compiled, should never be out of range. + * @param optLevel Optimization level the function will be compiled with. * @return Returns JSVM funtions result code. * Returns {@link JSVM_OK } if the function executed successfully.\n * Returns {@link JSVM_INVALID_ARG } if env is NULL, or wasmModule is NULL or is not a WebAssembly module.\n @@ -2802,9 +2998,9 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CompileWasmFunction(JSVM_Env env, /** * @brief Check whether the given JSVM_Value is a WebAssembly module. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to check. - * @param result: Whether the given value is a WebAssembly module. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to check. + * @param result Whether the given value is a WebAssembly module. * @return Returns JSVM funtions result code. * Returns {@link JSVM_OK } if the function executed successfully.\n * Returns {@link JSVM_INVALID_ARG } if any of the input arguments is NULL.\n @@ -2818,10 +3014,10 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsWasmModuleObject(JSVM_Env env, /** * @brief Create cache for compiled WebAssembly module. * - * @param env: The environment that the API is invoked under. - * @param wasmModule: The compiled WebAssembly module. - * @param data: Output parameter representing generated WebAssembly module cache. - * @param length: Output parameter representing byte length of generated WebAssembly module cache. + * @param env The environment that the API is invoked under. + * @param wasmModule The compiled WebAssembly module. + * @param data Output parameter representing generated WebAssembly module cache. + * @param length Output parameter representing byte length of generated WebAssembly module cache. * @return Returns JSVM funtions result code. * Returns {@link JSVM_OK } if the function executed successfully.\n * Returns {@link JSVM_INVALID_ARG } if any of the input arguments is NULL.\n @@ -2837,9 +3033,9 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateWasmCache(JSVM_Env env, /** * @brief Release cache data with specified cache type. * - * @param env: The environment that the API is invoked under. - * @param cacheData: The cache data to be released, double free is undefined behaviors. - * @param cacheType: The type of cache data. + * @param env The environment that the API is invoked under. + * @param cacheData The cache data to be released, double free is undefined behaviors. + * @param cacheType The type of cache data. * @return Returns JSVM funtions result code. * Returns {@link JSVM_OK } if the function executed successfully.\n * Returns {@link JSVM_INVALID_ARG } if any of the pointer arguments is NULL or cacheType is illegal.\n @@ -2849,9 +3045,7 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateWasmCache(JSVM_Env env, JSVM_EXTERN JSVM_Status OH_JSVM_ReleaseCache(JSVM_Env env, const uint8_t* cacheData, JSVM_CacheType cacheType); - EXTERN_C_END - /** @} */ #endif /* ARK_RUNTIME_JSVM_JSVM_H */ diff --git a/src/jsvm_types.h b/src/jsvm_types.h index 139fec1b6..4ee1793b3 100644 --- a/src/jsvm_types.h +++ b/src/jsvm_types.h @@ -12,10 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#ifndef ARK_RUNTIME_JSVM_JSVM_TYPE_H -#define ARK_RUNTIME_JSVM_JSVM_TYPE_H - /** * @addtogroup JSVM * @{ @@ -38,10 +34,15 @@ * including managing the engine lifecycle, compiling and running JS code, implementing JS/C++ cross language calls, * and taking snapshots. * @library libjsvm.so + * @kit ArkTS * @syscap SystemCapability.ArkCompiler.JSVM * @since 11 */ +#ifndef ARK_RUNTIME_JSVM_JSVM_TYPE_H +#define ARK_RUNTIME_JSVM_JSVM_TYPE_H + + #include // NOLINT(modernize-deprecated-headers) #include // NOLINT(modernize-deprecated-headers) #include // NOLINT(modernize-deprecated-headers) @@ -171,7 +172,11 @@ typedef void(JSVM_CDECL* JSVM_Finalize)(JSVM_Env env, void* finalizeHint); /** - * @brief Function pointer type for callback of ASCII output stream. + * @brief Function pointer type for callback of ASCII output stream. The first parameter data is the data pointer. + * And the second parameter size is the data size to output. A null data pointer indicates the end of the stream. + * The third parameter streamData is the pointer passed in together with the callback to the API functions that + * generate data to the output stream. The callback returns true to indicate the stream can continue to accept + * data. Otherwise, it will abort the stream. * * @since 12 */ @@ -575,8 +580,8 @@ typedef struct { } JSVM_TypeTag; /** - * @brief When the getter, setter, call, etc. behavior occurs on the object, the corresponding - * the corresponding callback will be triggered. + * @brief When the object's getter, setter, deleter, and enumerator operations are performed, the corresponding + * callback will be triggered. * * @since 12 */ @@ -637,15 +642,13 @@ typedef struct { } JSVM_PropertyHandlerConfigurationStruct; /** - * @brief The function pointer type of the callback provided by the instance object, which triggers the - * corresponding callback when getter, setter, call, and other behaviors occur on the object. + * @brief The pointer type of the structure which contains the property handlers. * * @since 12 */ typedef JSVM_PropertyHandlerConfigurationStruct* JSVM_PropertyHandlerCfg; /** - * * @brief Source code information. * * @since 12 @@ -671,12 +674,12 @@ typedef struct { JSVM_CompileOptionId id; /** option content. */ union { - /** ptr type. */ - void *ptr; - /** int type. */ - int num; - /** bool type. */ - bool boolean; + /** ptr type. */ + void *ptr; + /** int type. */ + int num; + /** bool type. */ + bool boolean; } content; } JSVM_CompileOptions; @@ -692,30 +695,6 @@ typedef struct { size_t length; } JSVM_CodeCache; -/** - * @brief WebAssembly function optimization level - * - * @since 12 - */ -typedef enum { - /** baseline optimization level. */ - JSVM_WASM_OPT_BASELINE = 10, - /** high optimization level. */ - JSVM_WASM_OPT_HIGH = 20, -} JSVM_WasmOptLevel; - -/** - * @brief Cache data type - * - * @since 12 - */ -typedef enum { - /** js code cache, generated by OH_JSVM_CreateCodeCache */ - JSVM_CACHE_TYPE_JS, - /** WebAssembly cache, generated by OH_JSVM_CreateWasmCache */ - JSVM_CACHE_TYPE_WASM, -} JSVM_CacheType; - /** * @brief compile profile passed with JSVM_COMPILE_COMPILE_PROFILE * @@ -767,5 +746,30 @@ typedef enum { /** leave uninitialized. */ JSVM_UNINITIALIZED, } JSVM_InitializedFlag; + +/** + * @brief WebAssembly function optimization level + * + * @since 12 + */ +typedef enum { + /** baseline optimization level. */ + JSVM_WASM_OPT_BASELINE = 10, + /** high optimization level. */ + JSVM_WASM_OPT_HIGH = 20, +} JSVM_WasmOptLevel; + +/** + * @brief Cache data type + * + * @since 12 + */ +typedef enum { + /** js code cache, generated by OH_JSVM_CreateCodeCache */ + JSVM_CACHE_TYPE_JS, + /** WebAssembly cache, generated by OH_JSVM_CreateWasmCache */ + JSVM_CACHE_TYPE_WASM, +} JSVM_CacheType; /** @} */ #endif /* ARK_RUNTIME_JSVM_JSVM_TYPE_H */ + -- Gitee From 925d42c7ef91d3909f06679eca966ebe8c3ee969 Mon Sep 17 00:00:00 2001 From: huanghan Date: Mon, 25 Nov 2024 10:20:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?API=20Lint=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huanghan --- src/jsvm.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/jsvm.h b/src/jsvm.h index 89ce7ffbd..b5771f107 100644 --- a/src/jsvm.h +++ b/src/jsvm.h @@ -102,7 +102,7 @@ EXTERN_C_START /** * @brief Init a JavaScript vm. * - * @param options: The options for initialize the JavaScript VM. + * @param options The options for initialize the JavaScript VM. * @return Returns JSVM funtions result code. * Returns {@link JSVM_OK } in all cases.\n * @since 11 @@ -1546,9 +1546,9 @@ JSVM_EXTERN JSVM_Status OH_JSVM_IsArraybuffer(JSVM_Env env, /** * @brief This API checks if the Object passed in is a date. * - * @param env: The environment that the API is invoked under. - * @param value: The JavaScript value to check. - * @param result: Whether the given JSVM_Value represents a JavaScript Date object. + * @param env The environment that the API is invoked under. + * @param value The JavaScript value to check. + * @param isDate Whether the given JSVM_Value represents a JavaScript Date object. * @return Returns JSVM funtions result code. * {@link JSVM_OK } If the function executed successfully.\n * @since 11 @@ -2522,8 +2522,8 @@ JSVM_EXTERN JSVM_Status OH_JSVM_ReleaseLock(JSVM_Env env); * @brief Starts the running of the task queue inside the VM. * This task queue can be executed by an external event loop. * - * @param env: The VM instance on which to start the task queue. - * @param result: Whether the task queue was successfully started. + * @param vm The VM instance on which to start the task queue. + * @param result Whether the task queue was successfully started. * @return Returns JSVM funtions result code. * {@link JSVM_OK } If the function executed successfully.\n * @since 12 @@ -2534,7 +2534,7 @@ JSVM_EXTERN JSVM_Status OH_JSVM_PumpMessageLoop(JSVM_VM vm, /** * @brief Check to see if there are any microtasks waiting in the queue, and if there are, execute them. * - * @param env: The VM instance on which to check microtasks. + * @param vm The VM instance on which to check microtasks. * @return Returns JSVM funtions result code. * {@link JSVM_OK } If the function executed successfully.\n * @since 12 -- Gitee From 41b278f75d2ea2f7f833af702f333f547821f72f Mon Sep 17 00:00:00 2001 From: chenraozhong Date: Thu, 28 Nov 2024 17:28:57 +0800 Subject: [PATCH 3/3] Set Handler for OOM | Fatal | PromiseReject Signed-off-by: chenraozhong --- src/js_native_api_v8.cc | 138 ++++++++++++++++++++++++++++++++++++++++ src/jsvm.h | 45 +++++++++++++ src/jsvm_types.h | 78 +++++++++++++++++++++++ 3 files changed, 261 insertions(+) diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index a61038398..fedad1bf5 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -143,12 +143,41 @@ namespace { enum IsolateDataSlot { kIsolateData = 0, kIsolateSnapshotCreatorSlot = 1, + kIsolateHandlerPoolSlot = 2, }; +// Always compare the final element of IsolateDataSlot with v8 limit. +static_assert(kIsolateHandlerPoolSlot < v8::internal::Internals::kNumIsolateDataSlots); + +struct IsolateHandlerPool { + JSVM_HandlerForOOMError handlerForOOMError = nullptr; + JSVM_HandlerForFatalError handlerForFatalError = nullptr; + JSVM_HandlerForPromiseReject handlerForPromiseReject = nullptr; +}; + +static IsolateHandlerPool* GetIsolateHandlerPool(v8::Isolate* isolate) { + auto pool = isolate->GetData(v8impl::kIsolateHandlerPoolSlot); + return reinterpret_cast(pool); +} + +static IsolateHandlerPool* GetOrCreateIsolateHandlerPool(v8::Isolate* isolate) { + auto *pool = isolate->GetData(v8impl::kIsolateHandlerPoolSlot); + if (pool != nullptr) { + return reinterpret_cast(pool); + } + auto *createdPool = new v8impl::IsolateHandlerPool(); + isolate->SetData(v8impl::kIsolateHandlerPoolSlot, createdPool); + return createdPool; +} enum ContextEmbedderIndex { kContextEnvIndex = 1, }; +static JSVM_Env GetEnvByContext(v8::Local context) { + auto env = context->GetAlignedPointerFromEmbedderData(v8impl::kContextEnvIndex); + return reinterpret_cast(env); +} + struct IsolateData { IsolateData(v8::StartupData* blob) : blob(blob) {} @@ -1480,6 +1509,8 @@ OH_JSVM_CreateVM(const JSVM_CreateVMOptions* options, JSVM_VM* result) { } v8impl::CreateIsolateData(isolate, snapshotBlob); *result = reinterpret_cast(isolate); + // Create nullptr placeholder + isolate->SetData(v8impl::kIsolateHandlerPoolSlot, nullptr); return JSVM_OK; } @@ -1493,6 +1524,7 @@ OH_JSVM_DestroyVM(JSVM_VM vm) { auto creator = v8impl::GetIsolateSnapshotCreator(isolate); auto data = v8impl::GetIsolateData(isolate); + auto *handlerPool = v8impl::GetIsolateHandlerPool(isolate); if (creator != nullptr) { delete creator; } else { @@ -1502,6 +1534,9 @@ OH_JSVM_DestroyVM(JSVM_VM vm) { delete data; } + if (handlerPool != nullptr) { + delete handlerPool; + } return JSVM_OK; } @@ -2791,6 +2826,109 @@ JSVM_Status JSVM_CDECL OH_JSVM_ObjectSeal(JSVM_Env env, JSVM_Value object) { return GET_RETURN_STATUS(env); } +static void OnOOMError(const char* location, const v8::OOMDetails& details) { + auto* isolate = v8::Isolate::GetCurrent(); + auto* pool = v8impl::GetIsolateHandlerPool(isolate); + if (pool == nullptr) { + return; + } + auto* handler = pool->handlerForOOMError; + if (handler == nullptr) { + return; + } + (*handler)(location, details.detail, details.is_heap_oom); +} + +static void OnFatalError(const char* location, const char* message) { + auto* isolate = v8::Isolate::GetCurrent(); + auto* pool = v8impl::GetIsolateHandlerPool(isolate); + if (pool == nullptr) { + return; + } + auto* handler = pool->handlerForFatalError; + if (handler == nullptr) { + return; + } + (*handler)(location, message); +} + +JSVM_Status JSVM_CDECL OH_JSVM_SetHandlerForOOMError(JSVM_VM vm, JSVM_HandlerForOOMError handler) { + if (vm == nullptr) { + return JSVM_INVALID_ARG; + } + auto* isolate = reinterpret_cast(vm); + auto* pool = v8impl::GetOrCreateIsolateHandlerPool(isolate); + pool->handlerForOOMError = handler; + isolate->SetOOMErrorHandler(OnOOMError); + return JSVM_OK; +} + +static void OnPromiseReject(v8::PromiseRejectMessage rejectMessage) { + auto* isolate = v8::Isolate::GetCurrent(); + auto* pool = v8impl::GetIsolateHandlerPool(isolate); + if (pool == nullptr) { + return; + } + auto* handler = pool->handlerForPromiseReject; + if (handler == nullptr) { + return; + } + auto context = isolate->GetCurrentContext(); + auto env = v8impl::GetEnvByContext(context); + v8::HandleScope scope(isolate); + v8::Local rejectInfo = v8::Object::New(isolate); + auto strPromise = + v8::String::NewFromUtf8(isolate, "promise").ToLocalChecked(); + (void)rejectInfo->Set(context, strPromise, rejectMessage.GetPromise()); + auto strValue = v8::String::NewFromUtf8(isolate, "value").ToLocalChecked(); + (void)rejectInfo->Set(context, strValue, rejectMessage.GetValue()); + JSVM_Value jsvmRejectInfo = v8impl::JsValueFromV8LocalValue(rejectInfo); + JSVM_PromiseRejectEvent rejectEvent = JSVM_PROMISE_REJECT_OTHER_REASONS; + switch (rejectMessage.GetEvent()) { + case v8::kPromiseRejectWithNoHandler: { + rejectEvent = JSVM_PROMISE_REJECT_WITH_NO_HANDLER; + break; + } + case v8::kPromiseHandlerAddedAfterReject: { + rejectEvent = JSVM_PROMISE_ADD_HANDLER_AFTER_REJECTED; + break; + } + case v8::kPromiseRejectAfterResolved: { + rejectEvent = JSVM_PROMISE_REJECT_AFTER_RESOLVED; + break; + } + case v8::kPromiseResolveAfterResolved: { + rejectEvent = JSVM_PROMISE_RESOLVE_AFTER_RESOLVED; + break; + } + } + (*handler)(env, rejectEvent, jsvmRejectInfo); +} + +JSVM_Status JSVM_CDECL OH_JSVM_SetHandlerForFatalError(JSVM_VM vm, + JSVM_HandlerForFatalError handler) { + if (vm == nullptr) { + return JSVM_INVALID_ARG; + } + auto* isolate = reinterpret_cast(vm); + auto* pool = v8impl::GetOrCreateIsolateHandlerPool(isolate); + pool->handlerForFatalError = handler; + isolate->SetFatalErrorHandler(OnFatalError); + return JSVM_OK; +} + +JSVM_Status JSVM_CDECL OH_JSVM_SetHandlerForPromiseReject( + JSVM_VM vm, JSVM_HandlerForPromiseReject handler) { + if (vm == nullptr) { + return JSVM_INVALID_ARG; + } + auto* isolate = reinterpret_cast(vm); + auto* pool = v8impl::GetOrCreateIsolateHandlerPool(isolate); + pool->handlerForPromiseReject = handler; + isolate->SetPromiseRejectCallback(OnPromiseReject); + return JSVM_OK; +} + JSVM_Status JSVM_CDECL OH_JSVM_IsArray(JSVM_Env env, JSVM_Value value, bool* result) { diff --git a/src/jsvm.h b/src/jsvm.h index b5771f107..f0ce3cb87 100644 --- a/src/jsvm.h +++ b/src/jsvm.h @@ -1515,6 +1515,51 @@ JSVM_EXTERN JSVM_Status OH_JSVM_Instanceof(JSVM_Env env, JSVM_Value constructor, bool* result); +/** + * @brief Set Handler For OOM Error. If this function is invoked repeatedly, + * only the last time takes effect. When handler is null, the previous setting is canceled. + * + * @param vm The environment that the API is invoked under. + * @param handler The handler for OOM Error. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } if the function executed successfully.\n + * {@link JSVM_INVALID_ARG } if vm is NULL.\n + * + * @since 16 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_SetHandlerForOOMError(JSVM_VM vm, + JSVM_HandlerForOOMError handler); + +/** + * @brief Set Handler For Fatal Error. If this function is invoked repeatedly, + * only the last time takes effect. When handler is null, the previous setting is canceled. + * + * @param vm The environment that the API is invoked under. + * @param handler The handler for Fatal Error. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } if the function executed successfully.\n + * {@link JSVM_INVALID_ARG } if vm is NULL.\n + * + * @since 16 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_SetHandlerForFatalError(JSVM_VM vm, + JSVM_HandlerForFatalError handler); + +/** + * @brief Set Handler For Promise Reject. If this function is invoked repeatedly, + * only the last time takes effect. When handler is null, the previous setting is canceled. + * + * @param vm The environment that the API is invoked under. + * @param handler The handler for Promise Reject. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } if the function executed successfully.\n + * {@link JSVM_INVALID_ARG } if vm is NULL.\n + * + * @since 16 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_SetHandlerForPromiseReject(JSVM_VM vm, + JSVM_HandlerForPromiseReject handler); + /** * @brief This API represents invoking the IsArray operation on the object * diff --git a/src/jsvm_types.h b/src/jsvm_types.h index 4ee1793b3..7b27df393 100644 --- a/src/jsvm_types.h +++ b/src/jsvm_types.h @@ -770,6 +770,84 @@ typedef enum { /** WebAssembly cache, generated by OH_JSVM_CreateWasmCache */ JSVM_CACHE_TYPE_WASM, } JSVM_CacheType; + +/** + * @brief The promise-reject event. + * + * @since 16 + */ +typedef enum { + /** Promise is rejected for other reasons. */ + JSVM_PROMISE_REJECT_OTHER_REASONS = 0, + /** Promise rejected with no handler. */ + JSVM_PROMISE_REJECT_WITH_NO_HANDLER = 1, + /** Add the handler after Promise has been rejected. */ + JSVM_PROMISE_ADD_HANDLER_AFTER_REJECTED = 2, + /** After the Promise has been resolved, try to reject the Promise again. */ + JSVM_PROMISE_REJECT_AFTER_RESOLVED = 3, + /** After the Promise has been resolved, try resolving the Promise again. */ + JSVM_PROMISE_RESOLVE_AFTER_RESOLVED = 4, +} JSVM_PromiseRejectEvent; + +/** + * @brief The level of message error. + * + * @since 16 + */ +typedef enum { + /** Log level message. */ + JSVM_MESSAGE_LOG = (1 << 0), + /** Debug level message. */ + JSVM_MESSAGE_DEBUG = (1 << 1), + /** Info level message. */ + JSVM_MESSAGE_INFO = (1 << 2), + /** Error level message. */ + JSVM_MESSAGE_ERROR = (1 << 3), + /** Warning level message. */ + JSVM_MESSAGE_WARNING = (1 << 4), + /** All level message. */ + JSVM_MESSAGE_ALL = JSVM_MESSAGE_LOG | JSVM_MESSAGE_DEBUG | JSVM_MESSAGE_INFO | JSVM_MESSAGE_ERROR | + JSVM_MESSAGE_WARNING, +} JSVM_MessageErrorLevel; + +/** + * @brief Function pointer type of OOM-Error callback. + * + * @param location The location information of the OOM error. + * @param detail The detail of the OOM error. + * @param isHeapOOM Determine whether the OOM type is Heap OOM. + * + * @since 16 + */ +typedef void(JSVM_CDECL* JSVM_HandlerForOOMError)(const char* location, + const char* detail, + bool isHeapOOM); + +/** + * @brief Function pointer type of Fatal-Error callback. + * + * @param location The location information of the Fatal error. + * @param message The message of the Fatal error. + * + * @since 16 + */ +typedef void(JSVM_CDECL* JSVM_HandlerForFatalError)(const char* location, + const char* message); + +/** + * @brief Function pointer type of Promise-Reject callback. + * + * @param env The environment that the function is invoked under. + * @param rejectEvent The promise-reject event. + * @param rejectInfo An JS-object containing two properties: 'promise' and 'value'. + * The 'promise' represents a reference to the Promise object that was rejected. + * The 'value' represents the rejection reason associated with that promise. + * + * @since 16 + */ +typedef void(JSVM_CDECL* JSVM_HandlerForPromiseReject)(JSVM_Env env, + JSVM_PromiseRejectEvent rejectEvent, + JSVM_Value rejectInfo); /** @} */ #endif /* ARK_RUNTIME_JSVM_JSVM_TYPE_H */ -- Gitee