From 4b43aca8ba7e12be1a393149318e2f2b63a6aacd Mon Sep 17 00:00:00 2001 From: chenraozhong Date: Tue, 2 Jul 2024 09:38:43 +0800 Subject: [PATCH] Add OH_JSVM_CreateFunctionWithScript Signed-off-by: chenraozhong --- src/jsvm.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/jsvm.h b/src/jsvm.h index feae51abb..155b35fc0 100644 --- a/src/jsvm.h +++ b/src/jsvm.h @@ -1806,6 +1806,25 @@ JSVM_EXTERN JSVM_Status OH_JSVM_CreateFunction(JSVM_Env env, JSVM_Callback cb, JSVM_Value* result); +/** + * @brief Creates a function with a given script as its body. + * @param env: The environment that the API is invoked under. + * @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 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. + * @param funcName: A string containing the function's name. Pass NULL to create an anonymous function. + * @return Returns JSVM_OK if the API succeeded. + * @since 11 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_CreateFunctionWithScript(JSVM_Env env, + size_t argc, + const char* argv, + JSVM_Value script, + JSVM_Value* result, + const char* funcName = nullptr); + /** * @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. -- Gitee