From 57fae1328c224bdec9b8c7db39cec3b9571858fd Mon Sep 17 00:00:00 2001 From: milkpotatoes Date: Tue, 13 Aug 2024 20:30:08 +0800 Subject: [PATCH] Add description for napi_coerce_to_native_binding_object Issue: https://gitee.com/openharmony/interface_sdk_c/issues/IAJT2E Signed-off-by: milkpotatoes Change-Id: Ieb0e4680e79308e92ab289ce95405dfa96883ed4 --- arkui/napi/native_api.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arkui/napi/native_api.h b/arkui/napi/native_api.h index 7cbab661d..a45ce8476 100644 --- a/arkui/napi/native_api.h +++ b/arkui/napi/native_api.h @@ -72,7 +72,19 @@ NAPI_INNER_EXTERN napi_status napi_adjust_external_memory(napi_env env, extern "C" { #endif +/** + * @brief Native detach callback of napi_coerce_to_native_binding_object that can be used to + * detach the js object and the native object. + * + * @since 11 + */ typedef void* (*napi_native_binding_detach_callback)(napi_env env, void* native_object, void* hint); +/** + * @brief Native attach callback of napi_coerce_to_native_binding_object that can be used to + * bind the js object and the native object. + * + * @since 11 + */ typedef napi_value (*napi_native_binding_attach_callback)(napi_env env, void* native_object, void* hint); NAPI_EXTERN napi_status napi_run_script_path(napi_env env, const char* path, napi_value* result); @@ -130,6 +142,18 @@ NAPI_EXTERN napi_status napi_create_object_with_named_properties(napi_env env, size_t property_count, const char** keys, const napi_value* values); +/** + * @brief This API sets native properties to a object and converts this js object to native binding object. + * + * @param[in] env Current running virtual machine context. + * @param[in] js_object The JavaScript value to coerce. + * @param[in] detach_cb Native callback that can be used to detach the js object and the native object. + * @param[in] attach_cb Native callback that can be used to bind the js object and the native object. + * @param[in] native_object User-provided native instance to pass to thr detach callback and attach callback. + * @param[in] hint Optional hint to pass to the detach callback and attach callback. + * @return Return the function execution status. + * @since 11 + */ NAPI_EXTERN napi_status napi_coerce_to_native_binding_object(napi_env env, napi_value js_object, napi_native_binding_detach_callback detach_cb,