pub unsafe extern "C" fn napi_define_class(
env: napi_env,
utf8name: *const c_char,
length: usize,
constructor: napi_callback,
data: *mut c_void,
property_count: usize,
properties: *const napi_property_descriptor,
result: *mut napi_value,
) -> napi_statusnapi only.Expand description
Defines an ArkTS class, including constructor function and properties.
§Arguments
-
env- Current running virtual machine context. -
utf8name- Name of the ArkTS constructor function. -
length- The length of the utf8name in bytes, or NAPI_AUTO_LENGTH if it is null-terminated. -
constructor- Callback function that handles constructing instances of the class. -
data- Optional data to be passed to the constructor callback as the data property of the callback info. -
property_count- Number of items in the properties array argument. -
properties- Array of property descriptors. -
result- A napi_value representing the constructor function for the class.
§Returns
- Returns the function execution status.
[
napi_ok] If the function executed successfully. execution.
[napi_invalid_arg] If the param env, utf8name and(or) result is nullptr. If napi_property_descriptor
is nullptr but property_count greater than 0.
[napi_function_expected] If the param func is not an ArkTS Function.
[napi_pending_exception] If have uncaught exception, or exception occurs in execution.
Available since API-level: 10