napi_wrap

Function napi_wrap 

Source
pub unsafe extern "C" fn napi_wrap(
    env: napi_env,
    js_object: napi_value,
    native_object: *mut c_void,
    finalize_cb: napi_finalize,
    finalize_hint: *mut c_void,
    result: *mut napi_ref,
) -> napi_status
Available on crate feature napi only.
Expand description

Wraps a native instance in a ArkTS object. The native instance can be retrieved later using napi_unwrap.

§Arguments

  • env - Current running virtual machine context.

  • js_object - The ArkTS object that will be the wrapper for the native object.

  • native_object - The native instance that will be wrapped in the ArkTS object.

  • finalize_cb - Native callback that can be used to free the native instance when the JavaScript object has been garbage-collected.

  • finalize_hint - Optional contextual hint that is passed to the finalize callback.

  • result - Optional reference to the wrapped object.

§Returns

  • Returns the function execution status. [napi_ok] If the function executed successfully.

[napi_invalid_arg] If the param env, js_object, native_object and(or) finalize_cb is nullptr.

[napi_object_expected] If the param js_object is not an ArkTS Object.

[napi_pending_exception] If have uncaught exception, or exception occurred in execution.

Available since API-level: 10