napi_new_instance

Function napi_new_instance 

Source
pub unsafe extern "C" fn napi_new_instance(
    env: napi_env,
    constructor: napi_value,
    argc: usize,
    argv: *const napi_value,
    result: *mut napi_value,
) -> napi_status
Available on crate feature napi only.
Expand description

Instantiate a new ArkTS value using a given napi_value that represents the constructor for the object.

§Arguments

  • env - Current running virtual machine context.

  • constructor - The ArkTS function to be invoked as a constructor.

  • argc - The count of elements in the argv array.

  • argv - Array of ArkTS values representing the arguments to the constructor. If argc is 0 this parameter may be omitted by passing in nullptr.

  • result - The ArkTS object returned, which in this case is the constructed object.

§Returns

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

[napi_invalid_arg] If the param env and(or) func is nullptr. If argv is nullptr but argc greater

than 0.

[napi_function_expected] If the param func is not an ArkTS Function.

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

Available since API-level: 10