ohos_sys/napi/napi_ffi.rs
1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6pub use ohos_sys_opaque_types::{napi_env, napi_value};
7
8pub const NAPI_VERSION: u32 = 8;
9pub const NAPI_VERSION_EXPERIMENTAL: u32 = 2147483647;
10pub const NAPI_AUTO_LENGTH: i32 = -1;
11pub const NAPI_MODULE_VERSION: u32 = 1;
12impl napi_qos_t {
13 pub const napi_qos_background: napi_qos_t = napi_qos_t(0);
14 pub const napi_qos_utility: napi_qos_t = napi_qos_t(1);
15 pub const napi_qos_default: napi_qos_t = napi_qos_t(2);
16 pub const napi_qos_user_initiated: napi_qos_t = napi_qos_t(3);
17}
18#[repr(transparent)]
19#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
20pub struct napi_qos_t(pub ::core::ffi::c_uint);
21#[cfg(feature = "api-12")]
22#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
23impl napi_event_mode {
24 /// In this mode, the current asynchronous thread will be blocked and events of native event loop will
25 /// be processed.
26 pub const napi_event_mode_default: napi_event_mode = napi_event_mode(0);
27 /// In this mode, the current asynchronous thread will not be blocked. If there are events in the event loop,
28 /// only one event will be processed and then the event loop will stop. If there are no events in the loop,
29 /// the event loop will stop immediately.
30 pub const napi_event_mode_nowait: napi_event_mode = napi_event_mode(1);
31}
32#[repr(transparent)]
33/// Indicates the running mode of the native event loop in an asynchronous native thread.
34///
35///
36/// Available since API-level: 12
37#[cfg(feature = "api-12")]
38#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
39#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
40pub struct napi_event_mode(pub ::core::ffi::c_uint);
41#[cfg(feature = "api-12")]
42#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
43impl napi_task_priority {
44 /// The immediate priority tasks should be promptly processed whenever feasible.
45 pub const napi_priority_immediate: napi_task_priority = napi_task_priority(0);
46 /// The high priority tasks, as sorted by their handle time, should be prioritized over tasks with low priority.
47 pub const napi_priority_high: napi_task_priority = napi_task_priority(1);
48 /// The low priority tasks, as sorted by their handle time, should be processed before idle priority tasks.
49 pub const napi_priority_low: napi_task_priority = napi_task_priority(2);
50 /// The idle priority tasks should be processed immediately only if there are no other priority tasks.
51 pub const napi_priority_idle: napi_task_priority = napi_task_priority(3);
52}
53#[repr(transparent)]
54/// Indicates the priority of a task dispatched from native thread to ArkTS thread.
55///
56///
57/// Available since API-level: 12
58#[cfg(feature = "api-12")]
59#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
60#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
61pub struct napi_task_priority(pub ::core::ffi::c_uint);
62pub type char16_t = u16;
63#[repr(C)]
64pub struct napi_ref__ {
65 _unused: [u8; 0],
66}
67pub type napi_ref = *mut napi_ref__;
68#[repr(C)]
69pub struct napi_handle_scope__ {
70 _unused: [u8; 0],
71}
72pub type napi_handle_scope = *mut napi_handle_scope__;
73#[repr(C)]
74pub struct napi_escapable_handle_scope__ {
75 _unused: [u8; 0],
76}
77pub type napi_escapable_handle_scope = *mut napi_escapable_handle_scope__;
78#[repr(C)]
79pub struct napi_callback_info__ {
80 _unused: [u8; 0],
81}
82pub type napi_callback_info = *mut napi_callback_info__;
83#[repr(C)]
84pub struct napi_deferred__ {
85 _unused: [u8; 0],
86}
87pub type napi_deferred = *mut napi_deferred__;
88impl napi_property_attributes {
89 pub const napi_default: napi_property_attributes = napi_property_attributes(0);
90 pub const napi_writable: napi_property_attributes = napi_property_attributes(1);
91 pub const napi_enumerable: napi_property_attributes = napi_property_attributes(2);
92 pub const napi_configurable: napi_property_attributes = napi_property_attributes(4);
93 pub const napi_static: napi_property_attributes = napi_property_attributes(1024);
94 pub const napi_default_method: napi_property_attributes = napi_property_attributes(5);
95 pub const napi_default_jsproperty: napi_property_attributes = napi_property_attributes(7);
96}
97#[repr(transparent)]
98#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
99pub struct napi_property_attributes(pub ::core::ffi::c_uint);
100impl napi_valuetype {
101 pub const napi_undefined: napi_valuetype = napi_valuetype(0);
102 pub const napi_null: napi_valuetype = napi_valuetype(1);
103 pub const napi_boolean: napi_valuetype = napi_valuetype(2);
104 pub const napi_number: napi_valuetype = napi_valuetype(3);
105 pub const napi_string: napi_valuetype = napi_valuetype(4);
106 pub const napi_symbol: napi_valuetype = napi_valuetype(5);
107 pub const napi_object: napi_valuetype = napi_valuetype(6);
108 pub const napi_function: napi_valuetype = napi_valuetype(7);
109 pub const napi_external: napi_valuetype = napi_valuetype(8);
110 pub const napi_bigint: napi_valuetype = napi_valuetype(9);
111}
112#[repr(transparent)]
113#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
114pub struct napi_valuetype(pub ::core::ffi::c_uint);
115impl napi_typedarray_type {
116 pub const napi_int8_array: napi_typedarray_type = napi_typedarray_type(0);
117 pub const napi_uint8_array: napi_typedarray_type = napi_typedarray_type(1);
118 pub const napi_uint8_clamped_array: napi_typedarray_type = napi_typedarray_type(2);
119 pub const napi_int16_array: napi_typedarray_type = napi_typedarray_type(3);
120 pub const napi_uint16_array: napi_typedarray_type = napi_typedarray_type(4);
121 pub const napi_int32_array: napi_typedarray_type = napi_typedarray_type(5);
122 pub const napi_uint32_array: napi_typedarray_type = napi_typedarray_type(6);
123 pub const napi_float32_array: napi_typedarray_type = napi_typedarray_type(7);
124 pub const napi_float64_array: napi_typedarray_type = napi_typedarray_type(8);
125 pub const napi_bigint64_array: napi_typedarray_type = napi_typedarray_type(9);
126 pub const napi_biguint64_array: napi_typedarray_type = napi_typedarray_type(10);
127}
128#[repr(transparent)]
129#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
130pub struct napi_typedarray_type(pub ::core::ffi::c_uint);
131impl napi_status {
132 pub const napi_ok: napi_status = napi_status(0);
133 pub const napi_invalid_arg: napi_status = napi_status(1);
134 pub const napi_object_expected: napi_status = napi_status(2);
135 pub const napi_string_expected: napi_status = napi_status(3);
136 pub const napi_name_expected: napi_status = napi_status(4);
137 pub const napi_function_expected: napi_status = napi_status(5);
138 pub const napi_number_expected: napi_status = napi_status(6);
139 pub const napi_boolean_expected: napi_status = napi_status(7);
140 pub const napi_array_expected: napi_status = napi_status(8);
141 pub const napi_generic_failure: napi_status = napi_status(9);
142 pub const napi_pending_exception: napi_status = napi_status(10);
143 pub const napi_cancelled: napi_status = napi_status(11);
144 pub const napi_escape_called_twice: napi_status = napi_status(12);
145 pub const napi_handle_scope_mismatch: napi_status = napi_status(13);
146 pub const napi_callback_scope_mismatch: napi_status = napi_status(14);
147 pub const napi_queue_full: napi_status = napi_status(15);
148 pub const napi_closing: napi_status = napi_status(16);
149 pub const napi_bigint_expected: napi_status = napi_status(17);
150 pub const napi_date_expected: napi_status = napi_status(18);
151 pub const napi_arraybuffer_expected: napi_status = napi_status(19);
152 pub const napi_detachable_arraybuffer_expected: napi_status = napi_status(20);
153 pub const napi_would_deadlock: napi_status = napi_status(21);
154 pub const napi_create_ark_runtime_too_many_envs: napi_status = napi_status(22);
155 pub const napi_create_ark_runtime_only_one_env_per_thread: napi_status = napi_status(23);
156 pub const napi_destroy_ark_runtime_env_not_exist: napi_status = napi_status(24);
157}
158#[repr(transparent)]
159#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
160pub struct napi_status(pub ::core::ffi::c_uint);
161pub type napi_callback = ::core::option::Option<
162 unsafe extern "C" fn(env: napi_env, info: napi_callback_info) -> napi_value,
163>;
164pub type napi_finalize = ::core::option::Option<
165 unsafe extern "C" fn(
166 env: napi_env,
167 finalize_data: *mut ::core::ffi::c_void,
168 finalize_hint: *mut ::core::ffi::c_void,
169 ),
170>;
171#[repr(C)]
172pub struct napi_property_descriptor {
173 pub utf8name: *const ::core::ffi::c_char,
174 pub name: napi_value,
175 pub method: napi_callback,
176 pub getter: napi_callback,
177 pub setter: napi_callback,
178 pub value: napi_value,
179 pub attributes: napi_property_attributes,
180 pub data: *mut ::core::ffi::c_void,
181}
182#[repr(C)]
183#[derive(Debug)]
184pub struct napi_extended_error_info {
185 pub error_message: *const ::core::ffi::c_char,
186 pub engine_reserved: *mut ::core::ffi::c_void,
187 pub engine_error_code: u32,
188 pub error_code: napi_status,
189}
190impl napi_key_collection_mode {
191 pub const napi_key_include_prototypes: napi_key_collection_mode = napi_key_collection_mode(0);
192 pub const napi_key_own_only: napi_key_collection_mode = napi_key_collection_mode(1);
193}
194#[repr(transparent)]
195#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
196pub struct napi_key_collection_mode(pub ::core::ffi::c_uint);
197impl napi_key_filter {
198 pub const napi_key_all_properties: napi_key_filter = napi_key_filter(0);
199 pub const napi_key_writable: napi_key_filter = napi_key_filter(1);
200 pub const napi_key_enumerable: napi_key_filter = napi_key_filter(2);
201 pub const napi_key_configurable: napi_key_filter = napi_key_filter(4);
202 pub const napi_key_skip_strings: napi_key_filter = napi_key_filter(8);
203 pub const napi_key_skip_symbols: napi_key_filter = napi_key_filter(16);
204}
205#[repr(transparent)]
206#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
207pub struct napi_key_filter(pub ::core::ffi::c_uint);
208impl napi_key_conversion {
209 pub const napi_key_keep_numbers: napi_key_conversion = napi_key_conversion(0);
210 pub const napi_key_numbers_to_strings: napi_key_conversion = napi_key_conversion(1);
211}
212#[repr(transparent)]
213#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
214pub struct napi_key_conversion(pub ::core::ffi::c_uint);
215#[repr(C)]
216#[derive(Debug, Copy, Clone)]
217pub struct napi_type_tag {
218 pub lower: u64,
219 pub upper: u64,
220}
221#[repr(C)]
222pub struct napi_callback_scope__ {
223 _unused: [u8; 0],
224}
225pub type napi_callback_scope = *mut napi_callback_scope__;
226#[repr(C)]
227pub struct napi_async_context__ {
228 _unused: [u8; 0],
229}
230pub type napi_async_context = *mut napi_async_context__;
231#[repr(C)]
232pub struct napi_async_work__ {
233 _unused: [u8; 0],
234}
235pub type napi_async_work = *mut napi_async_work__;
236#[repr(C)]
237pub struct napi_threadsafe_function__ {
238 _unused: [u8; 0],
239}
240pub type napi_threadsafe_function = *mut napi_threadsafe_function__;
241impl napi_threadsafe_function_release_mode {
242 pub const napi_tsfn_release: napi_threadsafe_function_release_mode =
243 napi_threadsafe_function_release_mode(0);
244 pub const napi_tsfn_abort: napi_threadsafe_function_release_mode =
245 napi_threadsafe_function_release_mode(1);
246}
247#[repr(transparent)]
248#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
249pub struct napi_threadsafe_function_release_mode(pub ::core::ffi::c_uint);
250impl napi_threadsafe_function_call_mode {
251 pub const napi_tsfn_nonblocking: napi_threadsafe_function_call_mode =
252 napi_threadsafe_function_call_mode(0);
253 pub const napi_tsfn_blocking: napi_threadsafe_function_call_mode =
254 napi_threadsafe_function_call_mode(1);
255}
256#[repr(transparent)]
257#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
258pub struct napi_threadsafe_function_call_mode(pub ::core::ffi::c_uint);
259pub type napi_async_execute_callback =
260 ::core::option::Option<unsafe extern "C" fn(env: napi_env, data: *mut ::core::ffi::c_void)>;
261pub type napi_async_complete_callback = ::core::option::Option<
262 unsafe extern "C" fn(env: napi_env, status: napi_status, data: *mut ::core::ffi::c_void),
263>;
264pub type napi_threadsafe_function_call_js = ::core::option::Option<
265 unsafe extern "C" fn(
266 env: napi_env,
267 js_callback: napi_value,
268 context: *mut ::core::ffi::c_void,
269 data: *mut ::core::ffi::c_void,
270 ),
271>;
272#[repr(C)]
273#[derive(Debug)]
274pub struct napi_node_version {
275 pub major: u32,
276 pub minor: u32,
277 pub patch: u32,
278 pub release: *const ::core::ffi::c_char,
279}
280#[repr(C)]
281pub struct napi_async_cleanup_hook_handle__ {
282 _unused: [u8; 0],
283}
284pub type napi_async_cleanup_hook_handle = *mut napi_async_cleanup_hook_handle__;
285pub type napi_async_cleanup_hook = ::core::option::Option<
286 unsafe extern "C" fn(handle: napi_async_cleanup_hook_handle, data: *mut ::core::ffi::c_void),
287>;
288#[repr(C)]
289pub struct uv_loop_s {
290 _unused: [u8; 0],
291}
292pub type napi_addon_register_func =
293 ::core::option::Option<unsafe extern "C" fn(env: napi_env, exports: napi_value) -> napi_value>;
294#[repr(C)]
295#[derive(Debug)]
296pub struct napi_module {
297 pub nm_version: ::core::ffi::c_int,
298 pub nm_flags: ::core::ffi::c_uint,
299 pub nm_filename: *const ::core::ffi::c_char,
300 pub nm_register_func: napi_addon_register_func,
301 pub nm_modname: *const ::core::ffi::c_char,
302 pub nm_priv: *mut ::core::ffi::c_void,
303 pub reserved: [*mut ::core::ffi::c_void; 4usize],
304}
305/// Native detach callback of napi_coerce_to_native_binding_object that can be used to
306/// detach the ArkTS object and the native object.
307///
308///
309/// Available since API-level: 11
310#[cfg(feature = "api-11")]
311#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
312pub type napi_native_binding_detach_callback = ::core::option::Option<
313 unsafe extern "C" fn(
314 env: napi_env,
315 native_object: *mut ::core::ffi::c_void,
316 hint: *mut ::core::ffi::c_void,
317 ) -> *mut ::core::ffi::c_void,
318>;
319/// Native attach callback of napi_coerce_to_native_binding_object that can be used to
320/// bind the ArkTS object and the native object.
321///
322///
323/// Available since API-level: 11
324#[cfg(feature = "api-11")]
325#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
326pub type napi_native_binding_attach_callback = ::core::option::Option<
327 unsafe extern "C" fn(
328 env: napi_env,
329 native_object: *mut ::core::ffi::c_void,
330 hint: *mut ::core::ffi::c_void,
331 ) -> napi_value,
332>;
333#[repr(C)]
334pub struct napi_critical_scope__ {
335 _unused: [u8; 0],
336}
337/// Native critical scope provides a scope within that an ArkTS string buffer cache can be obtained.
338///
339/// Available since API-level: 21
340#[cfg(feature = "api-21")]
341#[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
342pub type napi_critical_scope = *mut napi_critical_scope__;
343#[repr(C)]
344pub struct napi_strong_ref__ {
345 _unused: [u8; 0],
346}
347/// Native strong reference of an ArkTS object.
348///
349/// Available since API-level: 21
350#[cfg(feature = "api-21")]
351#[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
352pub type napi_strong_ref = *mut napi_strong_ref__;
353extern "C" {
354 /// Obtains the napi_extended_error_info struct, which contains the latest error information.
355 ///
356 /// # Arguments
357 ///
358 /// * `env` - Current running virtual machine context.
359 ///
360 /// * `result` - The error info about the error.
361 ///
362 ///
363 /// # Returns
364 ///
365 /// * Returns the function execution status.
366 /// [`napi_ok`] If the function executed successfully.
367 ///
368 /// [`napi_invalid_arg`] If env or result is nullptr.
369 ///
370 ///
371 /// Available since API-level: 10
372 pub fn napi_get_last_error_info(
373 env: napi_env,
374 result: *mut *const napi_extended_error_info,
375 ) -> napi_status;
376 /// Obtains the ArkTS undefined value.
377 /// # Arguments
378 ///
379 /// * `env` - Current running virtual machine context.
380 ///
381 /// * `result` - The ArkTS undefined value.
382 ///
383 ///
384 /// # Returns
385 ///
386 /// * Returns the function execution status.
387 /// [`napi_ok`] If the function executed successfully.
388 ///
389 /// [`napi_invalid_arg`] If the parameter env and(or) result is nullptr.
390 ///
391 ///
392 /// Available since API-level: 10
393 pub fn napi_get_undefined(env: napi_env, result: *mut napi_value) -> napi_status;
394 /// Obtains the ArkTS null value.
395 /// # Arguments
396 ///
397 /// * `env` - Current running virtual machine context.
398 ///
399 /// * `result` - The ArkTS null value.
400 ///
401 ///
402 /// # Returns
403 ///
404 /// * Returns the function execution status.
405 /// [`napi_ok`] If the function executed successfully.
406 ///
407 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
408 ///
409 ///
410 /// Available since API-level: 10
411 pub fn napi_get_null(env: napi_env, result: *mut napi_value) -> napi_status;
412 /// Obtains the ArkTS global object.
413 /// # Arguments
414 ///
415 /// * `env` - Current running virtual machine context.
416 ///
417 /// * `result` - The ArkTS global Object.
418 ///
419 ///
420 /// # Returns
421 ///
422 /// * Returns the function execution status.
423 /// [`napi_ok`] If the function executed successfully.
424 ///
425 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
426 ///
427 ///
428 /// Available since API-level: 10
429 pub fn napi_get_global(env: napi_env, result: *mut napi_value) -> napi_status;
430 /// Obtains the ArkTS singleton value corresponding to given C primitive boolean value.
431 /// # Arguments
432 ///
433 /// * `env` - Current running virtual machine context.
434 ///
435 /// * `value` - C primitive boolean value.
436 ///
437 /// * `result` - The ArkTS singleton value equivalent of C primitive boolean value.
438 ///
439 ///
440 /// # Returns
441 ///
442 /// * Returns the function execution status.
443 /// [`napi_ok`] If the function executed successfully.
444 ///
445 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
446 ///
447 ///
448 /// Available since API-level: 10
449 pub fn napi_get_boolean(env: napi_env, value: bool, result: *mut napi_value) -> napi_status;
450 /// Creates a default ArkTS object.
451 /// # Arguments
452 ///
453 /// * `env` - Current running virtual machine context.
454 ///
455 /// * `result` - napi_value representing an ArkTS object.
456 ///
457 ///
458 /// # Returns
459 ///
460 /// * Returns the function execution status.
461 /// [`napi_ok`] If the function executed successfully.
462 ///
463 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
464 ///
465 ///
466 /// Available since API-level: 10
467 pub fn napi_create_object(env: napi_env, result: *mut napi_value) -> napi_status;
468 /// Creates an ArkTS array.
469 /// # Arguments
470 ///
471 /// * `env` - Current running virtual machine context.
472 ///
473 /// * `result` - napi_value representing an ArkTS Array.
474 ///
475 ///
476 /// # Returns
477 ///
478 /// * Returns the function execution status.
479 /// [`napi_ok`] If the function executed successfully.
480 ///
481 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
482 ///
483 ///
484 /// Available since API-level: 10
485 pub fn napi_create_array(env: napi_env, result: *mut napi_value) -> napi_status;
486 /// Creates an ArkTS array of the specified length.
487 /// # Arguments
488 ///
489 /// * `env` - Current running virtual machine context.
490 ///
491 /// * `length` - The length of the Array.
492 ///
493 /// * `result` - napi_value representing an ArkTS Array.
494 ///
495 ///
496 /// # Returns
497 ///
498 /// * Returns the function execution status.
499 /// [`napi_ok`] If the function executed successfully.
500 ///
501 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
502 ///
503 ///
504 /// Available since API-level: 10
505 pub fn napi_create_array_with_length(
506 env: napi_env,
507 length: usize,
508 result: *mut napi_value,
509 ) -> napi_status;
510 /// Creates an ArkTS number from C double data.
511 /// # Arguments
512 ///
513 /// * `env` - Current running virtual machine context.
514 ///
515 /// * `value` - The double value to be represented in ArkTS.
516 ///
517 /// * `result` - A napi_value representing an ArkTS number.
518 ///
519 ///
520 /// # Returns
521 ///
522 /// * Returns the function execution status.
523 /// [`napi_ok`] If the function executed successfully.
524 ///
525 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
526 ///
527 ///
528 /// Available since API-level: 10
529 pub fn napi_create_double(env: napi_env, value: f64, result: *mut napi_value) -> napi_status;
530 /// Creates an ArkTS number from C int32_t data.
531 /// # Arguments
532 ///
533 /// * `env` - Current running virtual machine context.
534 ///
535 /// * `value` - The int32 value to be represented in ArkTS.
536 ///
537 /// * `result` - A napi_value representing an ArkTS number.
538 ///
539 ///
540 /// # Returns
541 ///
542 /// * Returns the function execution status.
543 /// [`napi_ok`] If the function executed successfully.
544 ///
545 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
546 ///
547 ///
548 /// Available since API-level: 10
549 pub fn napi_create_int32(env: napi_env, value: i32, result: *mut napi_value) -> napi_status;
550 /// Creates an ArkTS number from C uint32_t data.
551 /// # Arguments
552 ///
553 /// * `env` - Current running virtual machine context.
554 ///
555 /// * `value` - The uint32 value to be represented in ArkTS.
556 ///
557 /// * `result` - A napi_value representing an ArkTS number.
558 ///
559 ///
560 /// # Returns
561 ///
562 /// * Returns the function execution status.
563 /// [`napi_ok`] If the function executed successfully.
564 ///
565 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
566 ///
567 ///
568 /// Available since API-level: 10
569 pub fn napi_create_uint32(env: napi_env, value: u32, result: *mut napi_value) -> napi_status;
570 /// Creates an ArkTS number from C int64_t data.
571 /// # Arguments
572 ///
573 /// * `env` - Current running virtual machine context.
574 ///
575 /// * `value` - The int64 value to be represented in ArkTS.
576 ///
577 /// * `result` - A napi_value representing an ArkTS number.
578 ///
579 ///
580 /// # Returns
581 ///
582 /// * Returns the function execution status.
583 /// [`napi_ok`] If the function executed successfully.
584 ///
585 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr.
586 ///
587 ///
588 /// Available since API-level: 10
589 pub fn napi_create_int64(env: napi_env, value: i64, result: *mut napi_value) -> napi_status;
590 /// Creates an ArkTS string from an ISO-8859-1-encoded C string.
591 /// # Arguments
592 ///
593 /// * `env` - Current running virtual machine context.
594 ///
595 /// * `str` - C string encoded in ISO-8859-1-encoded format.
596 ///
597 /// * `length` - The length of the C string 'str'.
598 ///
599 /// * `result` - Result of the ArkTS string from the ISO-8859-1-encoded C string.
600 ///
601 ///
602 /// # Returns
603 ///
604 /// * Returns the function execution status.
605 /// [`napi_ok`] If the function executed successfully.
606 ///
607 /// [`napi_invalid_arg`] If the param env, str and(or) result is nullptr.
608 ///
609 ///
610 /// Available since API-level: 10
611 pub fn napi_create_string_latin1(
612 env: napi_env,
613 str_: *const ::core::ffi::c_char,
614 length: usize,
615 result: *mut napi_value,
616 ) -> napi_status;
617 /// Creates an ArkTS string from a UTF8-encoded C string.
618 /// # Arguments
619 ///
620 /// * `env` - Current running virtual machine context.
621 ///
622 /// * `str` - C string encoded in UTF8 format.
623 ///
624 /// * `length` - The length of the C string 'str'.
625 ///
626 /// * `result` - Result of the ArkTS string from the UTF8-encoded C string.
627 ///
628 ///
629 /// # Returns
630 ///
631 /// * Returns the function execution status.
632 /// [`napi_ok`] If the function executed successfully.
633 ///
634 /// [`napi_invalid_arg`] If the param env, str and(or) result is nullptr.
635 ///
636 ///
637 /// Available since API-level: 10
638 pub fn napi_create_string_utf8(
639 env: napi_env,
640 str_: *const ::core::ffi::c_char,
641 length: usize,
642 result: *mut napi_value,
643 ) -> napi_status;
644 pub fn napi_create_string_utf16(
645 env: napi_env,
646 str_: *const char16_t,
647 length: usize,
648 result: *mut napi_value,
649 ) -> napi_status;
650 /// Creates an ArkTS symbol.
651 /// # Arguments
652 ///
653 /// * `env` - Current running virtual machine context.
654 ///
655 /// * `description` - Optional napi_value representing an ArkTS string to describe the symbol.
656 ///
657 /// * `result` - A napi_value representing an ArkTS symbol.
658 ///
659 ///
660 /// # Returns
661 ///
662 /// * Returns the function execution status.
663 /// [`napi_ok`] If the function executed successfully.
664 ///
665 /// [`napi_invalid_arg`] If the param env and(or) result is nullptr;
666 ///
667 /// If the param description is not nullptr and is not an ArkTS String.
668 ///
669 ///
670 /// Available since API-level: 10
671 pub fn napi_create_symbol(
672 env: napi_env,
673 description: napi_value,
674 result: *mut napi_value,
675 ) -> napi_status;
676 /// Create an ArkTS function. This is the primary mechanism to call back into native code from ArkTS.
677 /// # Arguments
678 ///
679 /// * `env` - Current running virtual machine context.
680 ///
681 /// * `utf8name` - The visible within ArkTS as the new function's name property.
682 ///
683 /// * `length` - The length oh the utf8name, or NAPI_AUTO_LENGTH if it is null-terminated.
684 ///
685 /// * `cb` - The native function which should be called when this function object is called.
686 ///
687 /// * `data` - User-provided data context. This will be passed back into the function when invoked.
688 ///
689 /// * `result` - The newly created ArkTS function.
690 ///
691 ///
692 /// # Returns
693 ///
694 /// * Returns the function execution status.
695 /// [`napi_ok`] If the function executed successfully.
696 ///
697 /// [`napi_invalid_arg`] If the param env, cb and(or) result is nullptr.
698 ///
699 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
700 ///
701 ///
702 /// Available since API-level: 10
703 pub fn napi_create_function(
704 env: napi_env,
705 utf8name: *const ::core::ffi::c_char,
706 length: usize,
707 cb: napi_callback,
708 data: *mut ::core::ffi::c_void,
709 result: *mut napi_value,
710 ) -> napi_status;
711 /// Creates an ArkTS Error with text information.
712 /// # Arguments
713 ///
714 /// * `env` - Current running virtual machine context.
715 ///
716 /// * `code` - Optional error code to set on the error.
717 ///
718 /// * `msg` - napi_value representing the EcmaScript string to be associated with the error.
719 ///
720 /// * `result` - napi_value representing the error created.
721 ///
722 ///
723 /// # Returns
724 ///
725 /// * Returns the function execution status.
726 /// [`napi_ok`] If the function executed successfully.
727 ///
728 /// [`napi_invalid_arg`] If env, msg or result is nullptr, code is not string and number type or msg is
729 ///
730 /// not a string type.
731 ///
732 ///
733 /// Available since API-level: 10
734 pub fn napi_create_error(
735 env: napi_env,
736 code: napi_value,
737 msg: napi_value,
738 result: *mut napi_value,
739 ) -> napi_status;
740 /// Creates an ArkTS TypeError with text information.
741 /// # Arguments
742 ///
743 /// * `env` - Current running virtual machine context.
744 ///
745 /// * `code` - Optional error code to set on the error.
746 ///
747 /// * `msg` - napi_value representing the EcmaScript string to be associated with the error.
748 ///
749 /// * `result` - napi_value representing the error created.
750 ///
751 ///
752 /// # Returns
753 ///
754 /// * Returns the function execution status.
755 /// [`napi_ok`] If the function executed successfully.
756 ///
757 /// [`napi_invalid_arg`] If env, msg or result is nullptr, code is not string and number type or msg is
758 ///
759 /// not a string type.
760 ///
761 ///
762 /// Available since API-level: 10
763 pub fn napi_create_type_error(
764 env: napi_env,
765 code: napi_value,
766 msg: napi_value,
767 result: *mut napi_value,
768 ) -> napi_status;
769 /// Creates an ArkTS RangeError with text information.
770 /// # Arguments
771 ///
772 /// * `env` - Current running virtual machine context.
773 ///
774 /// * `code` - Optional error code to set on the error.
775 ///
776 /// * `msg` - napi_value representing the EcmaScript string to be associated with the error.
777 ///
778 /// * `result` - napi_value representing the error created.
779 ///
780 ///
781 /// # Returns
782 ///
783 /// * Returns the function execution status.
784 /// [`napi_ok`] If the function executed successfully.
785 ///
786 /// [`napi_invalid_arg`] If env, msg or result is nullptr, code is not string and number type or msg is
787 ///
788 /// not a string type.
789 ///
790 ///
791 /// Available since API-level: 10
792 pub fn napi_create_range_error(
793 env: napi_env,
794 code: napi_value,
795 msg: napi_value,
796 result: *mut napi_value,
797 ) -> napi_status;
798 /// Similar to typeof operation, support external value, detects null as a separate type.
799 /// # Arguments
800 ///
801 /// * `env` - Current running virtual machine context.
802 ///
803 /// * `value` - The ArkTS value whose type expects to query.
804 ///
805 /// * `result` - The type of ArkTS value.
806 ///
807 ///
808 /// # Returns
809 ///
810 /// * Returns the function execution status.
811 /// [`napi_ok`] If the function executed successfully.
812 ///
813 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
814 ///
815 ///
816 /// Available since API-level: 10
817 pub fn napi_typeof(
818 env: napi_env,
819 value: napi_value,
820 result: *mut napi_valuetype,
821 ) -> napi_status;
822 /// Obtains the double value corresponding to the given ArkTS value.
823 /// # Arguments
824 ///
825 /// * `env` - Current running virtual machine context.
826 ///
827 /// * `value` - ArkTS number.
828 ///
829 /// * `result` - The C primitive equivalent of ArkTS value as double.
830 ///
831 ///
832 /// # Returns
833 ///
834 /// * Returns the function execution status.
835 /// [`napi_ok`] If the function executed successfully.
836 ///
837 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
838 ///
839 /// [`napi_number_expected`] If a non-number ArkTS value passed in it.
840 ///
841 ///
842 /// Available since API-level: 10
843 pub fn napi_get_value_double(env: napi_env, value: napi_value, result: *mut f64)
844 -> napi_status;
845 /// Obtains the int32_t value corresponding to the given ArkTS value.
846 /// # Arguments
847 ///
848 /// * `env` - Current running virtual machine context.
849 ///
850 /// * `value` - ArkTS number.
851 ///
852 /// * `result` - The C primitive equivalent of ArkTS value as int32_t.
853 ///
854 ///
855 /// # Returns
856 ///
857 /// * Returns the function execution status.
858 /// [`napi_ok`] If the function executed successfully.
859 ///
860 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
861 ///
862 /// [`napi_number_expected`] If a non-number ArkTS value passed in it.
863 ///
864 ///
865 /// Available since API-level: 10
866 pub fn napi_get_value_int32(env: napi_env, value: napi_value, result: *mut i32) -> napi_status;
867 /// Obtains the uint32_t value corresponding to the given ArkTS value.
868 /// # Arguments
869 ///
870 /// * `env` - Current running virtual machine context.
871 ///
872 /// * `value` - ArkTS number.
873 ///
874 /// * `result` - The C primitive equivalent of ArkTS value as uint32_t.
875 ///
876 ///
877 /// # Returns
878 ///
879 /// * Returns the function execution status.
880 /// [`napi_ok`] If the function executed successfully.
881 ///
882 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
883 ///
884 /// [`napi_number_expected`] If a non-number ArkTS value passed in it.
885 ///
886 ///
887 /// Available since API-level: 10
888 pub fn napi_get_value_uint32(env: napi_env, value: napi_value, result: *mut u32)
889 -> napi_status;
890 /// Obtains the int64_t value corresponding to the given ArkTS value.
891 /// # Arguments
892 ///
893 /// * `env` - Current running virtual machine context.
894 ///
895 /// * `value` - ArkTS number.
896 ///
897 /// * `result` - The C primitive equivalent of ArkTS value as int64_t.
898 ///
899 ///
900 /// # Returns
901 ///
902 /// * Returns the function execution status.
903 /// [`napi_ok`] If the function executed successfully.
904 ///
905 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
906 ///
907 /// [`napi_number_expected`] If a non-number ArkTS value passed in it.
908 ///
909 ///
910 /// Available since API-level: 10
911 pub fn napi_get_value_int64(env: napi_env, value: napi_value, result: *mut i64) -> napi_status;
912 /// Obtains the C Boolean equivalent of an ArkTS Boolean value.
913 /// # Arguments
914 ///
915 /// * `env` - Current running virtual machine context.
916 ///
917 /// * `value` - A napi_value representing ArkTS Boolean.
918 ///
919 /// * `result` - The C boolean equivalent of the ArkTS Boolean.
920 ///
921 ///
922 /// # Returns
923 ///
924 /// * Returns the function execution status.
925 /// [`napi_ok`] If the function executed successfully.
926 ///
927 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
928 ///
929 /// [`napi_boolean_expected`] If a non-boolean ArkTS value passed in it.
930 ///
931 ///
932 /// Available since API-level: 10
933 pub fn napi_get_value_bool(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
934 /// Obtains the ISO-8859-1-encoded string corresponding to the given ArkTS value.
935 /// # Arguments
936 ///
937 /// * `env` - Current running virtual machine context.
938 ///
939 /// * `value` - ArkTS string.
940 ///
941 /// * `buf` - Destination buffer that will be filled with the provided ISO-8859-1-encoded string.
942 ///
943 /// * `bufsize` - The size of the buffer 'buf'.
944 ///
945 /// * `result` - The length of the string in ISO-8859-1-encoded format.
946 ///
947 ///
948 /// # Returns
949 ///
950 /// * Returns the function execution status.
951 /// [`napi_ok`] If the function executed successfully.
952 ///
953 /// [`napi_invalid_arg`] If the param env and(or) value is nullptr;
954 ///
955 /// If the param buf and result both are nullptr.
956 ///
957 /// [`napi_string_expected`] If a non-string ArkTS value passed in it.
958 ///
959 ///
960 /// Available since API-level: 10
961 pub fn napi_get_value_string_latin1(
962 env: napi_env,
963 value: napi_value,
964 buf: *mut ::core::ffi::c_char,
965 bufsize: usize,
966 result: *mut usize,
967 ) -> napi_status;
968 /// Obtains the UTF8-encoded string corresponding to the given ArkTS value.
969 /// # Arguments
970 ///
971 /// * `env` - Current running virtual machine context.
972 ///
973 /// * `value` - ArkTS string.
974 ///
975 /// * `buf` - Destination buffer that will be filled with the provided UTF8-encoded string.
976 ///
977 /// * `bufsize` - The size of the buffer 'buf'.
978 ///
979 /// * `result` - The length of the string in UTF8-encoded format.
980 ///
981 ///
982 /// # Returns
983 ///
984 /// * Returns the function execution status.
985 /// [`napi_ok`] If the function executed successfully.
986 ///
987 /// [`napi_invalid_arg`] If the param env and(or) value is nullptr;
988 ///
989 /// If the param buf and result both are nullptr.
990 ///
991 /// [`napi_string_expected`] If a non-string ArkTS value passed in it.
992 ///
993 ///
994 /// Available since API-level: 10
995 pub fn napi_get_value_string_utf8(
996 env: napi_env,
997 value: napi_value,
998 buf: *mut ::core::ffi::c_char,
999 bufsize: usize,
1000 result: *mut usize,
1001 ) -> napi_status;
1002 pub fn napi_get_value_string_utf16(
1003 env: napi_env,
1004 value: napi_value,
1005 buf: *mut char16_t,
1006 bufsize: usize,
1007 result: *mut usize,
1008 ) -> napi_status;
1009 /// Coerce the given ArkTS value to an ArkTS boolean value.
1010 /// # Arguments
1011 ///
1012 /// * `env` - Current running virtual machine context.
1013 ///
1014 /// * `value` - The ArkTS value to coerce.
1015 ///
1016 /// * `result` - The coerced ArkTS boolean value.
1017 ///
1018 ///
1019 /// # Returns
1020 ///
1021 /// * Returns the function execution status.
1022 /// [`napi_ok`] If the function executed successfully.
1023 ///
1024 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1025 ///
1026 ///
1027 /// Available since API-level: 10
1028 pub fn napi_coerce_to_bool(
1029 env: napi_env,
1030 value: napi_value,
1031 result: *mut napi_value,
1032 ) -> napi_status;
1033 /// Coerce the given ArkTS value to an ArkTS number value.
1034 /// # Arguments
1035 ///
1036 /// * `env` - Current running virtual machine context.
1037 ///
1038 /// * `value` - The ArkTS value to coerce.
1039 ///
1040 /// * `result` - The coerced ArkTS number value.
1041 ///
1042 ///
1043 /// # Returns
1044 ///
1045 /// * Returns the function execution status.
1046 /// [`napi_ok`] If the function executed successfully.
1047 ///
1048 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1049 ///
1050 ///
1051 /// Available since API-level: 10
1052 pub fn napi_coerce_to_number(
1053 env: napi_env,
1054 value: napi_value,
1055 result: *mut napi_value,
1056 ) -> napi_status;
1057 /// Coerce the given ArkTS value to an ArkTS object value.
1058 /// # Arguments
1059 ///
1060 /// * `env` - Current running virtual machine context.
1061 ///
1062 /// * `value` - The ArkTS value to coerce.
1063 ///
1064 /// * `result` - The coerced ArkTS object value.
1065 ///
1066 ///
1067 /// # Returns
1068 ///
1069 /// * Returns the function execution status.
1070 /// [`napi_ok`] If the function executed successfully.
1071 ///
1072 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1073 ///
1074 ///
1075 /// Available since API-level: 10
1076 pub fn napi_coerce_to_object(
1077 env: napi_env,
1078 value: napi_value,
1079 result: *mut napi_value,
1080 ) -> napi_status;
1081 /// Coerce the given ArkTS value to an ArkTS string value.
1082 /// # Arguments
1083 ///
1084 /// * `env` - Current running virtual machine context.
1085 ///
1086 /// * `value` - The ArkTS value to coerce.
1087 ///
1088 /// * `result` - The coerced ArkTS string value.
1089 ///
1090 ///
1091 /// # Returns
1092 ///
1093 /// * Returns the function execution status.
1094 /// [`napi_ok`] If the function executed successfully.
1095 ///
1096 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1097 ///
1098 ///
1099 /// Available since API-level: 10
1100 pub fn napi_coerce_to_string(
1101 env: napi_env,
1102 value: napi_value,
1103 result: *mut napi_value,
1104 ) -> napi_status;
1105 /// Obtains the prototype of an ArkTS object.
1106 /// # Arguments
1107 ///
1108 /// * `env` - Current running virtual machine context.
1109 ///
1110 /// * `object` - The napi_value representing an ArkTS Object whose prototype to return.
1111 ///
1112 /// * `result` - A napi_value representing prototype of the object.
1113 ///
1114 ///
1115 /// # Returns
1116 ///
1117 /// * Returns the function execution status.
1118 /// [`napi_ok`] If the function executed successfully.
1119 ///
1120 /// [`napi_invalid_arg`] If the param env, object or result is nullptr;
1121 ///
1122 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
1123 ///
1124 ///
1125 /// Available since API-level: 10
1126 pub fn napi_get_prototype(
1127 env: napi_env,
1128 object: napi_value,
1129 result: *mut napi_value,
1130 ) -> napi_status;
1131 /// Obtains the names of the enumerable properties of object as an Array of Strings. The keys that are symbols
1132 /// will not be included.
1133 /// # Arguments
1134 ///
1135 /// * `env` - Current running virtual machine context.
1136 ///
1137 /// * `object` - The ArkTS object from which the property is retrieved.
1138 ///
1139 /// * `result` - An ArkTS Array that contains the attribute names of the object.
1140 ///
1141 ///
1142 /// # Returns
1143 ///
1144 /// * Returns the function execution status.
1145 /// [`napi_ok`] If the function executed successfully.
1146 ///
1147 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1148 ///
1149 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1150 ///
1151 ///
1152 /// Available since API-level: 10
1153 pub fn napi_get_property_names(
1154 env: napi_env,
1155 object: napi_value,
1156 result: *mut napi_value,
1157 ) -> napi_status;
1158 /// Set a property on the given ArkTS Object.
1159 /// # Arguments
1160 ///
1161 /// * `env` - Current running virtual machine context.
1162 ///
1163 /// * `object` - The ArkTS object.
1164 ///
1165 /// * `key` - The name of the property to set.
1166 ///
1167 /// * `value` - The property value.
1168 ///
1169 ///
1170 /// # Returns
1171 ///
1172 /// * Returns the function execution status.
1173 /// [`napi_ok`] If the function executed successfully.
1174 ///
1175 /// [`napi_invalid_arg`] If the param env, object, key and(or) value is nullptr.
1176 ///
1177 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1178 ///
1179 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1180 ///
1181 ///
1182 /// Available since API-level: 10
1183 pub fn napi_set_property(
1184 env: napi_env,
1185 object: napi_value,
1186 key: napi_value,
1187 value: napi_value,
1188 ) -> napi_status;
1189 /// Check if the given ArkTS Object has the named property or not.
1190 /// # Arguments
1191 ///
1192 /// * `env` - Current running virtual machine context.
1193 ///
1194 /// * `object` - The ArkTS object.
1195 ///
1196 /// * `key` - The name of the property to check.
1197 ///
1198 /// * `result` - Whether the property exists on the object or not.
1199 ///
1200 ///
1201 /// # Returns
1202 ///
1203 /// * Returns the function execution status.
1204 /// [`napi_ok`] If the function executed successfully.
1205 ///
1206 /// [`napi_invalid_arg`] If the param env, object, key and(or) result is nullptr.
1207 ///
1208 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1209 ///
1210 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1211 ///
1212 ///
1213 /// Available since API-level: 10
1214 pub fn napi_has_property(
1215 env: napi_env,
1216 object: napi_value,
1217 key: napi_value,
1218 result: *mut bool,
1219 ) -> napi_status;
1220 /// Get the requests property of the given ArkTS Object.
1221 /// # Arguments
1222 ///
1223 /// * `env` - Current running virtual machine context.
1224 ///
1225 /// * `object` - The ArkTS object.
1226 ///
1227 /// * `key` - The name of the property to get.
1228 ///
1229 /// * `result` - The value of the property.
1230 ///
1231 ///
1232 /// # Returns
1233 ///
1234 /// * Returns the function execution status.
1235 /// [`napi_ok`] If the function executed successfully.
1236 ///
1237 /// [`napi_invalid_arg`] If the param env, object, key and(or) result is nullptr.
1238 ///
1239 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1240 ///
1241 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1242 ///
1243 ///
1244 /// Available since API-level: 10
1245 pub fn napi_get_property(
1246 env: napi_env,
1247 object: napi_value,
1248 key: napi_value,
1249 result: *mut napi_value,
1250 ) -> napi_status;
1251 /// Delete the named property of the given ArkTS Object.
1252 /// # Arguments
1253 ///
1254 /// * `env` - Current running virtual machine context.
1255 ///
1256 /// * `object` - The ArkTS object.
1257 ///
1258 /// * `key` - The name of the property to delete.
1259 ///
1260 /// * `result` - Whether the execution is succeed or not. Can optionally be ignored by passing nullptr.
1261 ///
1262 ///
1263 /// # Returns
1264 ///
1265 /// * Returns the function execution status.
1266 /// [`napi_ok`] If the function executed successfully.
1267 ///
1268 /// [`napi_invalid_arg`] If the param env, object and(or) key is nullptr.
1269 ///
1270 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1271 ///
1272 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1273 ///
1274 ///
1275 /// Available since API-level: 10
1276 pub fn napi_delete_property(
1277 env: napi_env,
1278 object: napi_value,
1279 key: napi_value,
1280 result: *mut bool,
1281 ) -> napi_status;
1282 /// Check if the given ArkTS Object has the named own property or not.
1283 /// # Arguments
1284 ///
1285 /// * `env` - Current running virtual machine context.
1286 ///
1287 /// * `object` - The ArkTS object.
1288 ///
1289 /// * `key` - The name of the property to check.
1290 ///
1291 /// * `result` - Whether the own property exists on the object or not.
1292 ///
1293 ///
1294 /// # Returns
1295 ///
1296 /// * Returns the function execution status.
1297 /// [`napi_ok`] If the function executed successfully.
1298 ///
1299 /// [`napi_invalid_arg`] If the param env, object, key and(or) result is nullptr.
1300 ///
1301 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1302 ///
1303 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
1304 ///
1305 ///
1306 /// Available since API-level: 10
1307 pub fn napi_has_own_property(
1308 env: napi_env,
1309 object: napi_value,
1310 key: napi_value,
1311 result: *mut bool,
1312 ) -> napi_status;
1313 /// Set a property on the given ArkTS Object.
1314 /// # Arguments
1315 ///
1316 /// * `env` - Current running virtual machine context.
1317 ///
1318 /// * `object` - The ArkTS object.
1319 ///
1320 /// * `utf8name` - The name of the property to set.
1321 ///
1322 /// * `value` - The property value.
1323 ///
1324 ///
1325 /// # Returns
1326 ///
1327 /// * Returns the function execution status.
1328 /// [`napi_ok`] If the function executed successfully.
1329 ///
1330 /// [`napi_invalid_arg`] If the param env, object, utf8name and(or) value is nullptr.
1331 ///
1332 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1333 ///
1334 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1335 ///
1336 ///
1337 /// Available since API-level: 10
1338 pub fn napi_set_named_property(
1339 env: napi_env,
1340 object: napi_value,
1341 utf8name: *const ::core::ffi::c_char,
1342 value: napi_value,
1343 ) -> napi_status;
1344 /// Check if the given ArkTS Object has the named property or not.
1345 /// # Arguments
1346 ///
1347 /// * `env` - Current running virtual machine context.
1348 ///
1349 /// * `object` - The ArkTS object.
1350 ///
1351 /// * `utf8name` - The name of the property to check.
1352 ///
1353 /// * `result` - Whether the property exists on the object or not.
1354 ///
1355 ///
1356 /// # Returns
1357 ///
1358 /// * Returns the function execution status.
1359 /// [`napi_ok`] If the function executed successfully.
1360 ///
1361 /// [`napi_invalid_arg`] If the param env, object, utf8name and(or) result is nullptr.
1362 ///
1363 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1364 ///
1365 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1366 ///
1367 ///
1368 /// Available since API-level: 10
1369 pub fn napi_has_named_property(
1370 env: napi_env,
1371 object: napi_value,
1372 utf8name: *const ::core::ffi::c_char,
1373 result: *mut bool,
1374 ) -> napi_status;
1375 /// Get the requests property of the given ArkTS Object.
1376 /// # Arguments
1377 ///
1378 /// * `env` - Current running virtual machine context.
1379 ///
1380 /// * `object` - The ArkTS object.
1381 ///
1382 /// * `utf8name` - The name of the property to get.
1383 ///
1384 /// * `result` - The value of the property.
1385 ///
1386 ///
1387 /// # Returns
1388 ///
1389 /// * Returns the function execution status.
1390 /// [`napi_ok`] If the function executed successfully.
1391 ///
1392 /// [`napi_invalid_arg`] If the param env, object, utf8name and(or) result is nullptr.
1393 ///
1394 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1395 ///
1396 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1397 ///
1398 ///
1399 /// Available since API-level: 10
1400 pub fn napi_get_named_property(
1401 env: napi_env,
1402 object: napi_value,
1403 utf8name: *const ::core::ffi::c_char,
1404 result: *mut napi_value,
1405 ) -> napi_status;
1406 /// Set a element on the given ArkTS Array.
1407 /// # Arguments
1408 ///
1409 /// * `env` - Current running virtual machine context.
1410 ///
1411 /// * `object` - The ArkTS Array.
1412 ///
1413 /// * `index` - The index of the element to set.
1414 ///
1415 /// * `value` - The element value.
1416 ///
1417 ///
1418 /// # Returns
1419 ///
1420 /// * Returns the function execution status.
1421 /// [`napi_ok`] If the function executed successfully.
1422 ///
1423 /// [`napi_invalid_arg`] If the param env, object and(or) value is nullptr.
1424 ///
1425 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1426 ///
1427 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1428 ///
1429 ///
1430 /// Available since API-level: 10
1431 pub fn napi_set_element(
1432 env: napi_env,
1433 object: napi_value,
1434 index: u32,
1435 value: napi_value,
1436 ) -> napi_status;
1437 /// Check if the given ArkTS Array has an element at the requested index.
1438 /// # Arguments
1439 ///
1440 /// * `env` - Current running virtual machine context.
1441 ///
1442 /// * `object` - The ArkTS Array.
1443 ///
1444 /// * `index` - The name of the property to check.
1445 ///
1446 /// * `result` - Whether the property exists on the Array or not.
1447 ///
1448 ///
1449 /// # Returns
1450 ///
1451 /// * Returns the function execution status.
1452 /// [`napi_ok`] If the function executed successfully.
1453 ///
1454 /// [`napi_invalid_arg`] If the param env, object and(or) result is nullptr.
1455 ///
1456 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1457 ///
1458 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1459 ///
1460 ///
1461 /// Available since API-level: 10
1462 pub fn napi_has_element(
1463 env: napi_env,
1464 object: napi_value,
1465 index: u32,
1466 result: *mut bool,
1467 ) -> napi_status;
1468 /// Get the requests element of the given ArkTS Array.
1469 /// # Arguments
1470 ///
1471 /// * `env` - Current running virtual machine context.
1472 ///
1473 /// * `object` - The ArkTS Array.
1474 ///
1475 /// * `index` - The index of the element to get.
1476 ///
1477 /// * `result` - The value of the element.
1478 ///
1479 ///
1480 /// # Returns
1481 ///
1482 /// * Returns the function execution status.
1483 /// [`napi_ok`] If the function executed successfully.
1484 ///
1485 /// [`napi_invalid_arg`] If the param env, object and(or) result is nullptr.
1486 ///
1487 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1488 ///
1489 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1490 ///
1491 ///
1492 /// Available since API-level: 10
1493 pub fn napi_get_element(
1494 env: napi_env,
1495 object: napi_value,
1496 index: u32,
1497 result: *mut napi_value,
1498 ) -> napi_status;
1499 /// Delete the special index from the given ArkTS Array.
1500 /// # Arguments
1501 ///
1502 /// * `env` - Current running virtual machine context.
1503 ///
1504 /// * `object` - The ArkTS Array.
1505 ///
1506 /// * `index` - The index of the element to delete.
1507 ///
1508 /// * `result` - Whether the execution is succeed or not. Can optionally be ignored by passing nullptr.
1509 ///
1510 ///
1511 /// # Returns
1512 ///
1513 /// * Returns the function execution status.
1514 /// [`napi_ok`] If the function executed successfully.
1515 ///
1516 /// [`napi_invalid_arg`] If the param env, object and(or) key is nullptr.
1517 ///
1518 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1519 ///
1520 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1521 ///
1522 ///
1523 /// Available since API-level: 10
1524 pub fn napi_delete_element(
1525 env: napi_env,
1526 object: napi_value,
1527 index: u32,
1528 result: *mut bool,
1529 ) -> napi_status;
1530 /// Efficient define multiple properties on the given ArkTS Object by napi_property_descriptor.
1531 /// # Arguments
1532 ///
1533 /// * `env` - Current running virtual machine context.
1534 ///
1535 /// * `object` - The ArkTS Object.
1536 ///
1537 /// * `property_count` - The count of elements in the properties array.
1538 ///
1539 /// * `properties` - The properties array.
1540 ///
1541 ///
1542 /// # Returns
1543 ///
1544 /// * Returns the function execution status.
1545 /// [`napi_ok`] If the function executed successfully.
1546 ///
1547 /// [`napi_invalid_arg`] If the param env, object and(or) properties is nullptr.
1548 ///
1549 /// [`napi_object_expected`] If the param object is not an ArkTS Object.
1550 ///
1551 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1552 ///
1553 ///
1554 /// Available since API-level: 10
1555 pub fn napi_define_properties(
1556 env: napi_env,
1557 object: napi_value,
1558 property_count: usize,
1559 properties: *const napi_property_descriptor,
1560 ) -> napi_status;
1561 /// Checks if the ArkTS value is an ArkTS Array.
1562 /// # Arguments
1563 ///
1564 /// * `env` - Current running virtual machine context.
1565 ///
1566 /// * `value` - The ArkTS value to check.
1567 ///
1568 /// * `result` - Whether the given ArkTS value is an ArkTS Array.
1569 ///
1570 ///
1571 /// # Returns
1572 ///
1573 /// * Returns the function execution status.
1574 /// [`napi_ok`] If the function executed successfully.
1575 ///
1576 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1577 ///
1578 ///
1579 /// Available since API-level: 10
1580 pub fn napi_is_array(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
1581 /// Obtains the array length.
1582 /// # Arguments
1583 ///
1584 /// * `env` - Current running virtual machine context.
1585 ///
1586 /// * `value` - The napi_value representing the ArkTS Array being queried.
1587 ///
1588 /// * `result` - The length of the array.
1589 ///
1590 ///
1591 /// # Returns
1592 ///
1593 /// * Returns the function execution status.
1594 /// [`napi_ok`] If the function executed successfully.
1595 ///
1596 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr;
1597 ///
1598 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
1599 ///
1600 ///
1601 /// Available since API-level: 10
1602 pub fn napi_get_array_length(env: napi_env, value: napi_value, result: *mut u32)
1603 -> napi_status;
1604 /// Checks if the two ArkTS values are equal.
1605 /// # Arguments
1606 ///
1607 /// * `env` - Current running virtual machine context.
1608 ///
1609 /// * `lhs` - The ArkTS value to check.
1610 ///
1611 /// * `rhs` - The ArkTS value to check against.
1612 ///
1613 /// * `result` - Whether the two given ArkTS values are equal.
1614 ///
1615 ///
1616 /// # Returns
1617 ///
1618 /// * Returns the function execution status.
1619 /// [`napi_ok`] If the function executed successfully.
1620 ///
1621 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
1622 ///
1623 ///
1624 /// Available since API-level: 10
1625 pub fn napi_strict_equals(
1626 env: napi_env,
1627 lhs: napi_value,
1628 rhs: napi_value,
1629 result: *mut bool,
1630 ) -> napi_status;
1631 /// Invoke an ArkTS function. This is the primary mechanism to call back into JavaScript.
1632 /// # Arguments
1633 ///
1634 /// * `env` - Current running virtual machine context.
1635 ///
1636 /// * `recv` - The this value passed to the called function
1637 ///
1638 /// * `func` - The ArkTS function to be invoked.
1639 ///
1640 /// * `argc` - The count of elements in the argv array.
1641 ///
1642 /// * `argv` - ArkTS values passed in as arguments to the function.
1643 ///
1644 /// * `result` - Whether the provided 'type_tag' is matched with the tag on the ArkTS object 'value'.
1645 ///
1646 ///
1647 /// # Returns
1648 ///
1649 /// * Returns the function execution status.
1650 /// [`napi_ok`] If the function executed successfully.
1651 ///
1652 /// [`napi_invalid_arg`] If the param env and(or) func is nullptr. If argv is nullptr but argc greater
1653 ///
1654 /// than 0.
1655 ///
1656 /// [`napi_function_expected`] If the param func is not an ArkTS Function.
1657 ///
1658 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1659 ///
1660 ///
1661 /// Available since API-level: 10
1662 pub fn napi_call_function(
1663 env: napi_env,
1664 recv: napi_value,
1665 func: napi_value,
1666 argc: usize,
1667 argv: *const napi_value,
1668 result: *mut napi_value,
1669 ) -> napi_status;
1670 /// Instantiate a new ArkTS value using a given napi_value that represents the constructor for the object.
1671 /// # Arguments
1672 ///
1673 /// * `env` - Current running virtual machine context.
1674 ///
1675 /// * `constructor` - The ArkTS function to be invoked as a constructor.
1676 ///
1677 /// * `argc` - The count of elements in the argv array.
1678 ///
1679 /// * `argv` - Array of ArkTS values representing the arguments to the constructor. If argc is 0 this parameter may
1680 /// be omitted by passing in nullptr.
1681 ///
1682 /// * `result` - The ArkTS object returned, which in this case is the constructed object.
1683 ///
1684 ///
1685 /// # Returns
1686 ///
1687 /// * Returns the function execution status.
1688 /// [`napi_ok`] If the function executed successfully.
1689 ///
1690 /// [`napi_invalid_arg`] If the param env and(or) func is nullptr. If argv is nullptr but argc greater
1691 ///
1692 /// than 0.
1693 ///
1694 /// [`napi_function_expected`] If the param func is not an ArkTS Function.
1695 ///
1696 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1697 ///
1698 ///
1699 /// Available since API-level: 10
1700 pub fn napi_new_instance(
1701 env: napi_env,
1702 constructor: napi_value,
1703 argc: usize,
1704 argv: *const napi_value,
1705 result: *mut napi_value,
1706 ) -> napi_status;
1707 /// Invoke instanceof operation on the object.
1708 /// # Arguments
1709 ///
1710 /// * `env` - Current running virtual machine context.
1711 ///
1712 /// * `object` - The ArkTS object to check.
1713 ///
1714 /// * `constructor` - The ArkTS constructor function to check against.
1715 ///
1716 /// * `result` - Set to true if the given ArkTS object instanceof constructor.
1717 ///
1718 ///
1719 /// # Returns
1720 ///
1721 /// * Returns the function execution status.
1722 /// [`napi_ok`] If the function executed successfully.
1723 ///
1724 /// [`napi_invalid_arg`] If the param env, object, constructor and(or) result is nullptr.
1725 ///
1726 /// [`napi_object_expected`] If the param object is not an ArkTS object value.
1727 ///
1728 /// [`napi_function_expected`] If the param constructor is not an ArkTS function value.
1729 ///
1730 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1731 ///
1732 ///
1733 /// Available since API-level: 10
1734 pub fn napi_instanceof(
1735 env: napi_env,
1736 object: napi_value,
1737 constructor: napi_value,
1738 result: *mut bool,
1739 ) -> napi_status;
1740 /// Obtains callback details about the call like arguments, this from given callback info.
1741 /// # Arguments
1742 ///
1743 /// * `env` - Current running virtual machine context.
1744 ///
1745 /// * `cbinfo` - The callback info.
1746 ///
1747 /// * `argc` - Size of the argv array.
1748 ///
1749 /// * `argv` - The Array which arguments will be copied to. If there are more arguments than the provided count, only
1750 /// the requested number of arguments are copied. If there are fewer arguments provided, the rest argv is
1751 /// filled with undefined. Can optionally be ignored by passing nullptr.
1752 ///
1753 /// * `this_arg` - Receives the ArkTS this argument for the call. Can optionally be ignored by passing nullptr.
1754 ///
1755 /// * `data` - Receives the data pointer for the callback. Can optionally be ignored by passing nullptr.
1756 ///
1757 ///
1758 /// # Returns
1759 ///
1760 /// * Returns the function execution status.
1761 /// [`napi_ok`] If the function executed successfully.
1762 ///
1763 /// [`napi_invalid_arg`] If the param env and(or) cbinfo is nullptr.
1764 ///
1765 ///
1766 /// Available since API-level: 10
1767 pub fn napi_get_cb_info(
1768 env: napi_env,
1769 cbinfo: napi_callback_info,
1770 argc: *mut usize,
1771 argv: *mut napi_value,
1772 this_arg: *mut napi_value,
1773 data: *mut *mut ::core::ffi::c_void,
1774 ) -> napi_status;
1775 /// Obtains callback details about the call like arguments, this from given callback info.
1776 /// # Arguments
1777 ///
1778 /// * `env` - Current running virtual machine context.
1779 ///
1780 /// * `cbinfo` - The callback info.
1781 ///
1782 /// * `result` - The new.target of the constructor call.
1783 ///
1784 ///
1785 /// # Returns
1786 ///
1787 /// * Returns the function execution status.
1788 /// [`napi_ok`] If the function executed successfully.
1789 ///
1790 /// [`napi_invalid_arg`] If the param env, cbinfo and(or) result is nullptr.
1791 ///
1792 ///
1793 /// Available since API-level: 10
1794 pub fn napi_get_new_target(
1795 env: napi_env,
1796 cbinfo: napi_callback_info,
1797 result: *mut napi_value,
1798 ) -> napi_status;
1799 /// Defines an ArkTS class, including constructor function and properties.
1800 /// # Arguments
1801 ///
1802 /// * `env` - Current running virtual machine context.
1803 ///
1804 /// * `utf8name` - Name of the ArkTS constructor function.
1805 ///
1806 /// * `length` - The length of the utf8name in bytes, or NAPI_AUTO_LENGTH if it is null-terminated.
1807 ///
1808 /// * `constructor` - Callback function that handles constructing instances of the class.
1809 ///
1810 /// * `data` - Optional data to be passed to the constructor callback as the data property of the callback info.
1811 ///
1812 /// * `property_count` - Number of items in the properties array argument.
1813 ///
1814 /// * `properties` - Array of property descriptors.
1815 ///
1816 /// * `result` - A napi_value representing the constructor function for the class.
1817 ///
1818 ///
1819 /// # Returns
1820 ///
1821 /// * Returns the function execution status.
1822 /// [`napi_ok`] If the function executed successfully.
1823 /// execution.
1824 ///
1825 /// [`napi_invalid_arg`] If the param env, utf8name and(or) result is nullptr. If napi_property_descriptor
1826 /// is nullptr but property_count greater than 0.
1827 ///
1828 /// [`napi_function_expected`] If the param func is not an ArkTS Function.
1829 ///
1830 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
1831 ///
1832 ///
1833 /// Available since API-level: 10
1834 pub fn napi_define_class(
1835 env: napi_env,
1836 utf8name: *const ::core::ffi::c_char,
1837 length: usize,
1838 constructor: napi_callback,
1839 data: *mut ::core::ffi::c_void,
1840 property_count: usize,
1841 properties: *const napi_property_descriptor,
1842 result: *mut napi_value,
1843 ) -> napi_status;
1844 /// Wraps a native instance in a ArkTS object. The native instance can be retrieved later using napi_unwrap.
1845 /// # Arguments
1846 ///
1847 /// * `env` - Current running virtual machine context.
1848 ///
1849 /// * `js_object` - The ArkTS object that will be the wrapper for the native object.
1850 ///
1851 /// * `native_object` - The native instance that will be wrapped in the ArkTS object.
1852 ///
1853 /// * `finalize_cb` - Native callback that can be used to free the native instance when the JavaScript object has
1854 /// been garbage-collected.
1855 ///
1856 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
1857 ///
1858 /// * `result` - Optional reference to the wrapped object.
1859 ///
1860 ///
1861 /// # Returns
1862 ///
1863 /// * Returns the function execution status.
1864 /// [`napi_ok`] If the function executed successfully.
1865 ///
1866 /// [`napi_invalid_arg`] If the param env, js_object, native_object and(or) finalize_cb is nullptr.
1867 ///
1868 /// [`napi_object_expected`] If the param js_object is not an ArkTS Object.
1869 ///
1870 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1871 ///
1872 ///
1873 /// Available since API-level: 10
1874 pub fn napi_wrap(
1875 env: napi_env,
1876 js_object: napi_value,
1877 native_object: *mut ::core::ffi::c_void,
1878 finalize_cb: napi_finalize,
1879 finalize_hint: *mut ::core::ffi::c_void,
1880 result: *mut napi_ref,
1881 ) -> napi_status;
1882 /// Retrieves a native instance that was previously wrapped in an ArkTS object using napi_wrap.
1883 /// # Arguments
1884 ///
1885 /// * `env` - Current running virtual machine context.
1886 ///
1887 /// * `js_object` - The ArkTS object.
1888 ///
1889 /// * `result` - Pointer to the wrapped native instance.
1890 ///
1891 ///
1892 /// # Returns
1893 ///
1894 /// * Returns the function execution status.
1895 /// [`napi_ok`] If the function executed successfully.
1896 ///
1897 /// [`napi_invalid_arg`] If the param env, js_object and(or) result is nullptr.
1898 ///
1899 /// [`napi_object_expected`] If the param js_object is not an ArkTS Object.
1900 ///
1901 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1902 ///
1903 ///
1904 /// Available since API-level: 10
1905 pub fn napi_unwrap(
1906 env: napi_env,
1907 js_object: napi_value,
1908 result: *mut *mut ::core::ffi::c_void,
1909 ) -> napi_status;
1910 /// Retrieves a native instance that was previously wrapped in the ArkTS object js_object using napi_wrap
1911 /// and removes the wrapping.
1912 /// # Arguments
1913 ///
1914 /// * `env` - Current running virtual machine context.
1915 ///
1916 /// * `js_object` - The ArkTS object.
1917 ///
1918 /// * `result` - Pointer to the wrapped native instance.
1919 ///
1920 ///
1921 /// # Returns
1922 ///
1923 /// * Returns the function execution status.
1924 /// [`napi_ok`] If the function executed successfully.
1925 ///
1926 /// [`napi_invalid_arg`] If the param env, js_object and(or) result is nullptr.
1927 ///
1928 /// [`napi_object_expected`] If the param js_object is not an ArkTS Object.
1929 ///
1930 /// [`napi_pending_exception`] If have uncaught exception, or exception occurred in execution.
1931 ///
1932 ///
1933 /// Available since API-level: 10
1934 pub fn napi_remove_wrap(
1935 env: napi_env,
1936 js_object: napi_value,
1937 result: *mut *mut ::core::ffi::c_void,
1938 ) -> napi_status;
1939 /// Allocates a JS value with external data.
1940 /// # Arguments
1941 ///
1942 /// * `env` - Current running virtual machine context.
1943 ///
1944 /// * `data` - Allocates a JS value that references external data.
1945 ///
1946 /// * `finalize_cb` - Optional callback to call when the external value is being collected.
1947 ///
1948 /// * `finalize_hint` - Optional hint that can be passed to the finalize callback function during the garbage
1949 /// collection process.
1950 ///
1951 /// * `result` - A napi_value representing an external value.
1952 ///
1953 ///
1954 /// # Returns
1955 ///
1956 /// * Returns the function execution status.
1957 /// [`napi_ok`] If the function executed successfully.
1958 ///
1959 /// [`napi_invalid_arg`] If the param env or result is nullptr.
1960 ///
1961 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
1962 ///
1963 ///
1964 /// Available since API-level: 10
1965 pub fn napi_create_external(
1966 env: napi_env,
1967 data: *mut ::core::ffi::c_void,
1968 finalize_cb: napi_finalize,
1969 finalize_hint: *mut ::core::ffi::c_void,
1970 result: *mut napi_value,
1971 ) -> napi_status;
1972 /// Obtains the external data pointer previously passed through napi_create_external().
1973 /// # Arguments
1974 ///
1975 /// * `env` - Current running virtual machine context.
1976 ///
1977 /// * `value` - JavaScript external value.
1978 ///
1979 /// * `result` - The data wrapped by the JavaScript external value.
1980 ///
1981 ///
1982 /// # Returns
1983 ///
1984 /// * Returns the function execution status.
1985 /// [`napi_ok`] If the function executed successfully.
1986 ///
1987 /// [`napi_invalid_arg`] If the param env, value or result is nullptr;
1988 ///
1989 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
1990 ///
1991 ///
1992 /// Available since API-level: 10
1993 pub fn napi_get_value_external(
1994 env: napi_env,
1995 value: napi_value,
1996 result: *mut *mut ::core::ffi::c_void,
1997 ) -> napi_status;
1998 /// Creates a reference for an object to extend its lifespan. The caller needs to manage the reference lifespan.
1999 /// # Arguments
2000 ///
2001 /// * `env` - Current running virtual machine context.
2002 ///
2003 /// * `value` - The napi_value that is being referenced.
2004 ///
2005 /// * `initial_refcount` - The initial count for the new reference.
2006 ///
2007 /// * `result` - napi_ref pointing to the new reference.
2008 ///
2009 ///
2010 /// # Returns
2011 ///
2012 /// * Returns the function execution status.
2013 /// [`napi_ok`] If the function executed successfully.
2014 ///
2015 /// [`napi_invalid_arg`] If env, value or result is nullptr.
2016 ///
2017 ///
2018 /// Available since API-level: 10
2019 pub fn napi_create_reference(
2020 env: napi_env,
2021 value: napi_value,
2022 initial_refcount: u32,
2023 result: *mut napi_ref,
2024 ) -> napi_status;
2025 /// Deletes the reference passed in.
2026 /// # Arguments
2027 ///
2028 /// * `env` - Current running virtual machine context.
2029 ///
2030 /// * `ref` - The napi_ref to be deleted.
2031 ///
2032 ///
2033 /// # Returns
2034 ///
2035 /// * Returns the function execution status.
2036 /// [`napi_ok`] If the function executed successfully.
2037 ///
2038 /// [`napi_invalid_arg`] If env or ref is nullptr.
2039 ///
2040 ///
2041 /// Available since API-level: 10
2042 pub fn napi_delete_reference(env: napi_env, ref_: napi_ref) -> napi_status;
2043 /// Increments the reference count for the reference passed in and returns the count.
2044 /// # Arguments
2045 ///
2046 /// * `env` - Current running virtual machine context.
2047 ///
2048 /// * `ref` - The napi_ref whose reference count will be incremented.
2049 ///
2050 /// * `result` - The new reference count.
2051 ///
2052 ///
2053 /// # Returns
2054 ///
2055 /// * Returns the function execution status.
2056 /// [`napi_ok`] If the function executed successfully.
2057 ///
2058 /// [`napi_invalid_arg`] If env or ref is nullptr.
2059 ///
2060 ///
2061 /// Available since API-level: 10
2062 pub fn napi_reference_ref(env: napi_env, ref_: napi_ref, result: *mut u32) -> napi_status;
2063 /// Decrements the reference count for the reference passed in and returns the count.
2064 /// # Arguments
2065 ///
2066 /// * `env` - Current running virtual machine context.
2067 ///
2068 /// * `ref` - The napi_ref whose reference count will be decremented.
2069 ///
2070 /// * `result` - The new reference count.
2071 ///
2072 ///
2073 /// # Returns
2074 ///
2075 /// * Returns the function execution status.
2076 /// [`napi_ok`] If the function executed successfully.
2077 ///
2078 /// [`napi_invalid_arg`] If env or ref is nullptr.
2079 ///
2080 ///
2081 /// Available since API-level: 10
2082 pub fn napi_reference_unref(env: napi_env, ref_: napi_ref, result: *mut u32) -> napi_status;
2083 /// Obtains the ArkTS Object associated with the reference.
2084 /// # Arguments
2085 ///
2086 /// * `env` - Current running virtual machine context.
2087 ///
2088 /// * `ref` - The napi_ref of the value being requested.
2089 ///
2090 /// * `result` - The napi_value referenced by the napi_ref.
2091 ///
2092 ///
2093 /// # Returns
2094 ///
2095 /// * Returns the function execution status.
2096 /// [`napi_ok`] If the function executed successfully.
2097 ///
2098 /// [`napi_invalid_arg`] If env, ref or result is nullptr.
2099 ///
2100 ///
2101 /// Available since API-level: 10
2102 pub fn napi_get_reference_value(
2103 env: napi_env,
2104 ref_: napi_ref,
2105 result: *mut napi_value,
2106 ) -> napi_status;
2107 /// Opens a scope.
2108 /// # Arguments
2109 ///
2110 /// * `env` - Current running virtual machine context.
2111 ///
2112 /// * `result` - napi_value representing the new scope.
2113 ///
2114 ///
2115 /// # Returns
2116 ///
2117 /// * Returns the function execution status.
2118 /// [`napi_ok`] If the function executed successfully.
2119 ///
2120 /// [`napi_invalid_arg`] If env or result is nullptr.
2121 ///
2122 ///
2123 /// Available since API-level: 10
2124 pub fn napi_open_handle_scope(env: napi_env, result: *mut napi_handle_scope) -> napi_status;
2125 /// Closes the scope passed in. After the scope is closed, all references declared in it are closed.
2126 /// # Arguments
2127 ///
2128 /// * `env` - Current running virtual machine context.
2129 ///
2130 /// * `scope` - The scope to close.
2131 ///
2132 ///
2133 /// # Returns
2134 ///
2135 /// * Returns the function execution status.
2136 /// [`napi_ok`] If the function executed successfully.
2137 ///
2138 /// [`napi_invalid_arg`] If env or scope is nullptr.
2139 ///
2140 /// [`napi_handle_scope_mismatch`] If there is no scope still existed.
2141 ///
2142 ///
2143 /// Available since API-level: 10
2144 pub fn napi_close_handle_scope(env: napi_env, scope: napi_handle_scope) -> napi_status;
2145 /// Opens an escapable handle scope from which the declared values can be returned to the outer scope.
2146 /// # Arguments
2147 ///
2148 /// * `env` - Current running virtual machine context.
2149 ///
2150 /// * `result` - The new scope.
2151 ///
2152 ///
2153 /// # Returns
2154 ///
2155 /// * Returns the function execution status.
2156 /// [`napi_ok`] If the function executed successfully.
2157 ///
2158 /// [`napi_invalid_arg`] If env or result is nullptr.
2159 ///
2160 ///
2161 /// Available since API-level: 10
2162 pub fn napi_open_escapable_handle_scope(
2163 env: napi_env,
2164 result: *mut napi_escapable_handle_scope,
2165 ) -> napi_status;
2166 /// Closes the escapable handle scope passed in.
2167 /// # Arguments
2168 ///
2169 /// * `env` - Current running virtual machine context.
2170 ///
2171 /// * `scope` - The scope to close.
2172 ///
2173 ///
2174 /// # Returns
2175 ///
2176 /// * Returns the function execution status.
2177 /// [`napi_ok`] If the function executed successfully.
2178 ///
2179 /// [`napi_invalid_arg`] If env or scope is nullptr.
2180 ///
2181 /// [`napi_handle_scope_mismatch`] If there is no scope still existed.
2182 ///
2183 ///
2184 /// Available since API-level: 10
2185 pub fn napi_close_escapable_handle_scope(
2186 env: napi_env,
2187 scope: napi_escapable_handle_scope,
2188 ) -> napi_status;
2189 /// Promotes the handle to the input ArkTS object so that it is valid for the lifespan of its outer scope.
2190 /// # Arguments
2191 ///
2192 /// * `env` - Current running virtual machine context.
2193 ///
2194 /// * `scope` - Current scope.
2195 ///
2196 /// * `escapee` - The ArkTS object to be escaped.
2197 ///
2198 /// * `result` - The handle to the escaped object in the outer scope.
2199 ///
2200 ///
2201 /// # Returns
2202 ///
2203 /// * Returns the function execution status.
2204 /// [`napi_ok`] If the function executed successfully.
2205 ///
2206 /// [`napi_invalid_arg`] If env, scope, escapee or result is nullptr.
2207 ///
2208 ///
2209 /// Available since API-level: 10
2210 pub fn napi_escape_handle(
2211 env: napi_env,
2212 scope: napi_escapable_handle_scope,
2213 escapee: napi_value,
2214 result: *mut napi_value,
2215 ) -> napi_status;
2216 /// Throws an ArkTS error.
2217 /// # Arguments
2218 ///
2219 /// * `env` - Current running virtual machine context.
2220 ///
2221 /// * `error` - The ArkTS error to be thrown.
2222 ///
2223 ///
2224 /// # Returns
2225 ///
2226 /// * Returns the function execution status.
2227 /// [`napi_ok`] If the function executed successfully.
2228 ///
2229 /// [`napi_invalid_arg`] If env or error is nullptr, or error is not an error object.
2230 ///
2231 ///
2232 /// Available since API-level: 10
2233 pub fn napi_throw(env: napi_env, error: napi_value) -> napi_status;
2234 /// Throws an ArkTS Error with text information.
2235 /// # Arguments
2236 ///
2237 /// * `env` - Current running virtual machine context.
2238 ///
2239 /// * `code` - Optional error code to set on the error.
2240 ///
2241 /// * `msg` - C string representing the text to be associated with the error.
2242 ///
2243 ///
2244 /// # Returns
2245 ///
2246 /// * Returns the function execution status.
2247 /// [`napi_ok`] If the function executed successfully.
2248 ///
2249 /// [`napi_invalid_arg`] If env or msg is nullptr.
2250 ///
2251 ///
2252 /// Available since API-level: 10
2253 pub fn napi_throw_error(
2254 env: napi_env,
2255 code: *const ::core::ffi::c_char,
2256 msg: *const ::core::ffi::c_char,
2257 ) -> napi_status;
2258 /// Throws an ArkTS TypeError with text information.
2259 /// # Arguments
2260 ///
2261 /// * `env` - Current running virtual machine context.
2262 ///
2263 /// * `code` - Optional error code to set on the error.
2264 ///
2265 /// * `msg` - C string representing the text to be associated with the error.
2266 ///
2267 ///
2268 /// # Returns
2269 ///
2270 /// * Returns the function execution status.
2271 /// [`napi_ok`] If the function executed successfully.
2272 ///
2273 /// [`napi_invalid_arg`] If env or msg is nullptr.
2274 ///
2275 ///
2276 /// Available since API-level: 10
2277 pub fn napi_throw_type_error(
2278 env: napi_env,
2279 code: *const ::core::ffi::c_char,
2280 msg: *const ::core::ffi::c_char,
2281 ) -> napi_status;
2282 /// Throws an ArkTS RangeError with text information.
2283 /// # Arguments
2284 ///
2285 /// * `env` - Current running virtual machine context.
2286 ///
2287 /// * `code` - Optional error code to set on the error.
2288 ///
2289 /// * `msg` - C string representing the text to be associated with the error.
2290 ///
2291 ///
2292 /// # Returns
2293 ///
2294 /// * Returns the function execution status.
2295 /// [`napi_ok`] If the function executed successfully.
2296 ///
2297 /// [`napi_invalid_arg`] If env or msg is nullptr.
2298 ///
2299 ///
2300 /// Available since API-level: 10
2301 pub fn napi_throw_range_error(
2302 env: napi_env,
2303 code: *const ::core::ffi::c_char,
2304 msg: *const ::core::ffi::c_char,
2305 ) -> napi_status;
2306 /// Checks whether a 'napi_value' is an error object.
2307 /// # Arguments
2308 ///
2309 /// * `env` - Current running virtual machine context.
2310 ///
2311 /// * `value` - The value to check
2312 ///
2313 /// * `result` - Boolean value that is set to true if the value represents an error object, false otherwise.
2314 ///
2315 ///
2316 /// # Returns
2317 ///
2318 /// * Returns the function execution status.
2319 /// [`napi_ok`] If the function executed successfully.
2320 ///
2321 /// [`napi_invalid_arg`] If env, value or result is nullptr.
2322 ///
2323 ///
2324 /// Available since API-level: 10
2325 pub fn napi_is_error(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
2326 /// Checks whether an exception occurs.
2327 /// # Arguments
2328 ///
2329 /// * `env` - Current running virtual machine context.
2330 ///
2331 /// * `result` - Boolean value that is true if there is a pending exception.
2332 ///
2333 ///
2334 /// # Returns
2335 ///
2336 /// * Returns the function execution status.
2337 /// [`napi_ok`] If the function executed successfully.
2338 ///
2339 /// [`napi_invalid_arg`] If env or result is nullptr.
2340 ///
2341 ///
2342 /// Available since API-level: 10
2343 pub fn napi_is_exception_pending(env: napi_env, result: *mut bool) -> napi_status;
2344 /// Obtains and clears the latest exception.
2345 /// # Arguments
2346 ///
2347 /// * `env` - Current running virtual machine context.
2348 ///
2349 /// * `result` - The exception if there is a pending exception; otherwise return a null value.
2350 ///
2351 ///
2352 /// # Returns
2353 ///
2354 /// * Returns the function execution status.
2355 /// [`napi_ok`] If the function executed successfully.
2356 ///
2357 /// [`napi_invalid_arg`] If env or result is nullptr.
2358 ///
2359 ///
2360 /// Available since API-level: 10
2361 pub fn napi_get_and_clear_last_exception(env: napi_env, result: *mut napi_value)
2362 -> napi_status;
2363 /// Checks if the ArkTS value is an ArkTS ArrayBuffer.
2364 /// # Arguments
2365 ///
2366 /// * `env` - Current running virtual machine context.
2367 ///
2368 /// * `value` - The ArkTS value to check.
2369 ///
2370 /// * `result` - Whether the given ArkTS value is an ArkTS ArrayBuffer.
2371 ///
2372 ///
2373 /// # Returns
2374 ///
2375 /// * Returns the function execution status.
2376 /// [`napi_ok`] If the function executed successfully.
2377 ///
2378 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
2379 ///
2380 ///
2381 /// Available since API-level: 10
2382 pub fn napi_is_arraybuffer(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
2383 /// Creates an ArkTS ArrayBuffer of the specified size.
2384 /// # Arguments
2385 ///
2386 /// * `env` - Current running virtual machine context.
2387 ///
2388 /// * `byte_length` - The length in bytes of the array buffer.
2389 ///
2390 /// * `data` - The byte buffer of the ArrayBuffer.
2391 ///
2392 /// * `result` - A napi_value representing an ArkTS ArrayBuffer.
2393 ///
2394 ///
2395 /// # Returns
2396 ///
2397 /// * Returns the function execution status.
2398 /// [`napi_ok`] If the function executed successfully.
2399 ///
2400 /// [`napi_invalid_arg`] If the param env, data and(or) result is nullptr.
2401 ///
2402 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
2403 ///
2404 ///
2405 /// Available since API-level: 10
2406 pub fn napi_create_arraybuffer(
2407 env: napi_env,
2408 byte_length: usize,
2409 data: *mut *mut ::core::ffi::c_void,
2410 result: *mut napi_value,
2411 ) -> napi_status;
2412 /// The underlying data that ArrayBuffer point to.
2413 /// # Arguments
2414 ///
2415 /// * `env` - Current running virtual machine context.
2416 ///
2417 /// * `external_data` - Allocates an ArkTS value that references external data.
2418 ///
2419 /// * `byte_length` - The length in bytes of the underlying buffer.
2420 ///
2421 /// * `finalize_cb` - Optional callback to call when the ArrayBuffer is being collected.
2422 ///
2423 /// * `finalize_hint` - Optional hint that can be passed to the finalize callback function during the garbage
2424 /// collection process.
2425 ///
2426 /// * `result` - A napi_value representing an ArkTS ArrayBuffer.
2427 ///
2428 ///
2429 /// # Returns
2430 ///
2431 /// * Returns the function execution status.
2432 /// [`napi_ok`] If the function executed successfully.
2433 ///
2434 /// [`napi_invalid_arg`] If the param env, external_data, finalize_cb and(or) result is nullptr.
2435 ///
2436 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
2437 ///
2438 ///
2439 /// Available since API-level: 10
2440 pub fn napi_create_external_arraybuffer(
2441 env: napi_env,
2442 external_data: *mut ::core::ffi::c_void,
2443 byte_length: usize,
2444 finalize_cb: napi_finalize,
2445 finalize_hint: *mut ::core::ffi::c_void,
2446 result: *mut napi_value,
2447 ) -> napi_status;
2448 /// Obtains the underlying data buffer of ArrayBuffer and its length.
2449 /// # Arguments
2450 ///
2451 /// * `env` - Current running virtual machine context.
2452 ///
2453 /// * `arraybuffer` - The napi_value representing the ArrayBuffer being queried.
2454 ///
2455 /// * `data` - The underlying data buffer of the ArrayBuffer.
2456 ///
2457 /// * `byte_length` - Length in bytes of the underlying data buffer.
2458 ///
2459 ///
2460 /// # Returns
2461 ///
2462 /// * Returns the function execution status.
2463 /// [`napi_ok`] If the function executed successfully.
2464 ///
2465 /// [`napi_invalid_arg`] If the param env, arraybuffer and(or) byte_length is nullptr.
2466 ///
2467 /// [`napi_arraybuffer_expected`] If the param is neither ArkTS TypedArray nor SendableArrayBuffer.
2468 ///
2469 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
2470 ///
2471 ///
2472 /// Available since API-level: 10
2473 pub fn napi_get_arraybuffer_info(
2474 env: napi_env,
2475 arraybuffer: napi_value,
2476 data: *mut *mut ::core::ffi::c_void,
2477 byte_length: *mut usize,
2478 ) -> napi_status;
2479 /// Checks if the ArkTS value is an ArkTS TypedArray.
2480 /// # Arguments
2481 ///
2482 /// * `env` - Current running virtual machine context.
2483 ///
2484 /// * `value` - The ArkTS value to check.
2485 ///
2486 /// * `result` - Whether the given ArkTS value is an ArkTS TypedArray.
2487 ///
2488 ///
2489 /// # Returns
2490 ///
2491 /// * Returns the function execution status.
2492 /// [`napi_ok`] If the function executed successfully.
2493 ///
2494 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
2495 ///
2496 ///
2497 /// Available since API-level: 10
2498 pub fn napi_is_typedarray(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
2499 /// Creates an ArkTS TypeArray from an existing ArrayBuffer.
2500 /// # Arguments
2501 ///
2502 /// * `env` - Current running virtual machine context.
2503 ///
2504 /// * `type` - The element datatype of the TypedArray.
2505 ///
2506 /// * `length` - Number of elements in the TypedArray.
2507 ///
2508 /// * `arraybuffer` - The underlying ArrayBuffer that supports the TypedArray.
2509 ///
2510 /// * `byte_offset` - The byte offset within the ArrayBuffer from which to start projecting the TypedArray.
2511 ///
2512 /// * `result` - A napi_value representing an ArkTS TypedArray.
2513 ///
2514 ///
2515 /// # Returns
2516 ///
2517 /// * Returns the function execution status.
2518 /// [`napi_ok`] If the function executed successfully.
2519 ///
2520 /// [`napi_invalid_arg`] If the param env, arraybuffer and(or) result is nullptr;
2521 ///
2522 /// If param type is not a valid napi_typedarray_type.
2523 ///
2524 /// [`napi_arraybuffer_expected`] If a non-arraybuffer ArkTS value passed in it.
2525 ///
2526 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
2527 ///
2528 ///
2529 /// Available since API-level: 10
2530 pub fn napi_create_typedarray(
2531 env: napi_env,
2532 type_: napi_typedarray_type,
2533 length: usize,
2534 arraybuffer: napi_value,
2535 byte_offset: usize,
2536 result: *mut napi_value,
2537 ) -> napi_status;
2538 /// Obtains properties of a TypedArray.
2539 /// # Arguments
2540 ///
2541 /// * `env` - Current running virtual machine context.
2542 ///
2543 /// * `typedarray` - The napi_value for the TypedArray whose properties are being checked.
2544 ///
2545 /// * `type` - The datatype of elements in the TypedArray.
2546 ///
2547 /// * `length` - The number of elements in the TypedArray.
2548 ///
2549 /// * `data` - The data buffer underlying the TypedArray adjusted by the byte_offset.
2550 ///
2551 /// * `arraybuffer` - The ArrayBuffer underlying the TypedArray.
2552 ///
2553 /// * `byte_offset` - The byte offset within the underlying arraybuffer
2554 ///
2555 ///
2556 /// # Returns
2557 ///
2558 /// * Returns the function execution status.
2559 /// [`napi_ok`] If the function executed successfully.
2560 ///
2561 /// [`napi_invalid_arg`] If the param env and(or) typedarray is nullptr;
2562 ///
2563 /// If the param typedarray is neither ArkTS TypedArray nor SendableTypedArray.
2564 ///
2565 ///
2566 /// Available since API-level: 10
2567 pub fn napi_get_typedarray_info(
2568 env: napi_env,
2569 typedarray: napi_value,
2570 type_: *mut napi_typedarray_type,
2571 length: *mut usize,
2572 data: *mut *mut ::core::ffi::c_void,
2573 arraybuffer: *mut napi_value,
2574 byte_offset: *mut usize,
2575 ) -> napi_status;
2576 /// Creates an ArkTS DataView from an existing ArrayBuffer.
2577 /// # Arguments
2578 ///
2579 /// * `env` - Current running virtual machine context.
2580 ///
2581 /// * `length` - Number of elements in the DataView.
2582 ///
2583 /// * `arraybuffer` - The underlying ArrayBuffer that supports the DataView.
2584 ///
2585 /// * `byte_offset` - The byte offset within the ArrayBuffer from which to start projecting the DataView.
2586 ///
2587 /// * `result` - A napi_value representing an ArkTS DataView.
2588 ///
2589 ///
2590 /// # Returns
2591 ///
2592 /// * Returns the function execution status.
2593 /// [`napi_ok`] If the function executed successfully.
2594 ///
2595 /// [`napi_invalid_arg`] If the param env, arraybuffer and(or) result is nullptr.
2596 ///
2597 /// [`napi_arraybuffer_expected`] If a non-arraybuffer ArkTS value passed in it.
2598 ///
2599 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
2600 ///
2601 /// If the sum of byte_length and length is greater than the byte length of
2602 ///
2603 /// the arraybuffer.
2604 ///
2605 ///
2606 /// Available since API-level: 10
2607 pub fn napi_create_dataview(
2608 env: napi_env,
2609 length: usize,
2610 arraybuffer: napi_value,
2611 byte_offset: usize,
2612 result: *mut napi_value,
2613 ) -> napi_status;
2614 /// Checks if the ArkTS value is an ArkTS DataView.
2615 /// # Arguments
2616 ///
2617 /// * `env` - Current running virtual machine context.
2618 ///
2619 /// * `value` - The ArkTS value to check.
2620 ///
2621 /// * `result` - Whether the given ArkTS value is an ArkTS DataView.
2622 ///
2623 ///
2624 /// # Returns
2625 ///
2626 /// * Returns the function execution status.
2627 /// [`napi_ok`] If the function executed successfully.
2628 ///
2629 /// [`napi_invalid_arg`] If the param env, value and(or) result is nullptr.
2630 ///
2631 ///
2632 /// Available since API-level: 10
2633 pub fn napi_is_dataview(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
2634 /// Obtains properties of a DataView.
2635 /// # Arguments
2636 ///
2637 /// * `env` - Current running virtual machine context.
2638 ///
2639 /// * `dataview` - The napi_value for the DataView whose properties are being checked.
2640 ///
2641 /// * `bytelength` - The number of elements in the DataView.
2642 ///
2643 /// * `data` - The data buffer underlying the DataView.
2644 ///
2645 /// * `arraybuffer` - The ArrayBuffer underlying the DataView.
2646 ///
2647 /// * `byte_offset` - The byte offset within the underlying arraybuffer
2648 ///
2649 ///
2650 /// # Returns
2651 ///
2652 /// * Returns the function execution status.
2653 /// [`napi_ok`] If the function executed successfully.
2654 ///
2655 /// [`napi_invalid_arg`] If the param env and(or) dataview is nullptr;
2656 ///
2657 /// If non-dataview ArkTS value passed in.
2658 ///
2659 ///
2660 /// Available since API-level: 10
2661 pub fn napi_get_dataview_info(
2662 env: napi_env,
2663 dataview: napi_value,
2664 bytelength: *mut usize,
2665 data: *mut *mut ::core::ffi::c_void,
2666 arraybuffer: *mut napi_value,
2667 byte_offset: *mut usize,
2668 ) -> napi_status;
2669 pub fn napi_get_version(env: napi_env, result: *mut u32) -> napi_status;
2670 /// Creates a deferred object and an ArkTS promise.
2671 /// # Arguments
2672 ///
2673 /// * `env` - Current running virtual machine context.
2674 ///
2675 /// * `deferred` - The created deferred object which will be passed to 'napi_resolve_deferred()' or
2676 /// 'napi_reject_deferred()' to resolve or reject the promise.
2677 ///
2678 /// * `promise` - The ArkTS promise which is associated with the deferred object.
2679 ///
2680 /// # Returns
2681 ///
2682 /// * Returns the function execution status.
2683 /// [`napi_ok`] If the function executed successfully.
2684 ///
2685 /// [`napi_invalid_arg`] If env, deferred or resolution is nullptr.
2686 ///
2687 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2688 ///
2689 /// [`napi_generic_failure`] If create promise failed.
2690 ///
2691 ///
2692 /// Available since API-level: 10
2693 pub fn napi_create_promise(
2694 env: napi_env,
2695 deferred: *mut napi_deferred,
2696 promise: *mut napi_value,
2697 ) -> napi_status;
2698 /// Resolves a promise by way of the deferred object associated.
2699 /// # Arguments
2700 ///
2701 /// * `env` - Current running virtual machine context.
2702 ///
2703 /// * `deferred` - The deferred object which is utilized to resolve the promise.
2704 ///
2705 /// * `resolution` - The resolution value used to resolve the promise.
2706 ///
2707 /// # Returns
2708 ///
2709 /// * Returns the function execution status.
2710 /// [`napi_ok`] If the function executed successfully.
2711 ///
2712 /// [`napi_invalid_arg`] If env, deferred or resolution is nullptr.
2713 ///
2714 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2715 ///
2716 ///
2717 /// Available since API-level: 10
2718 pub fn napi_resolve_deferred(
2719 env: napi_env,
2720 deferred: napi_deferred,
2721 resolution: napi_value,
2722 ) -> napi_status;
2723 /// Rejects a promise by way of the deferred object associated.
2724 /// # Arguments
2725 ///
2726 /// * `env` - Current running virtual machine context.
2727 ///
2728 /// * `deferred` - The deferred object which is utilized to reject the promise.
2729 ///
2730 /// * `rejection` - The rejection value used to reject the promise.
2731 ///
2732 /// # Returns
2733 ///
2734 /// * Returns the function execution status.
2735 /// [`napi_ok`] If the function executed successfully.
2736 ///
2737 /// [`napi_invalid_arg`] If env, deferred or rejection is nullptr.
2738 ///
2739 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2740 ///
2741 ///
2742 /// Available since API-level: 10
2743 pub fn napi_reject_deferred(
2744 env: napi_env,
2745 deferred: napi_deferred,
2746 rejection: napi_value,
2747 ) -> napi_status;
2748 /// Checks whether the given 'napi_value' is a promise object.
2749 /// # Arguments
2750 ///
2751 /// * `env` - Current running virtual machine context.
2752 ///
2753 /// * `value` - The 'napi_value' to be checked.
2754 ///
2755 /// * `is_promise` - Boolean value that is set to true if the 'value' is a promise object, false otherwise.
2756 ///
2757 /// # Returns
2758 ///
2759 /// * Returns the function execution status.
2760 /// [`napi_ok`] If the function executed successfully.
2761 ///
2762 /// [`napi_invalid_arg`] If env, value or is_promise is nullptr.
2763 ///
2764 ///
2765 /// Available since API-level: 10
2766 pub fn napi_is_promise(env: napi_env, value: napi_value, is_promise: *mut bool) -> napi_status;
2767 pub fn napi_run_script(
2768 env: napi_env,
2769 script: napi_value,
2770 result: *mut napi_value,
2771 ) -> napi_status;
2772 pub fn napi_adjust_external_memory(
2773 env: napi_env,
2774 change_in_bytes: i64,
2775 adjusted_value: *mut i64,
2776 ) -> napi_status;
2777 /// Creates an ArkTS 'Date' object from C double data
2778 /// # Arguments
2779 ///
2780 /// * `env` - Current running virtual machine context.
2781 ///
2782 /// * `time` - ArkTS time value in milliseconds format since 01 January, 1970 UTC.
2783 ///
2784 /// * `result` - Created ArkTS data object.
2785 ///
2786 /// # Returns
2787 ///
2788 /// * Returns the function execution status.
2789 /// [`napi_ok`] If the function executed successfully.
2790 ///
2791 /// [`napi_invalid_arg`] If env or result is nullptr.
2792 ///
2793 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2794 ///
2795 ///
2796 /// Available since API-level: 10
2797 pub fn napi_create_date(env: napi_env, time: f64, result: *mut napi_value) -> napi_status;
2798 /// Checks whether the given ArkTS value is a 'Date' object. You can use this API to check the type
2799 /// of the parameter passed from ArkTS.
2800 /// # Arguments
2801 ///
2802 /// * `env` - Current running virtual machine context.
2803 ///
2804 /// * `value` - ArkTS data object.
2805 ///
2806 /// * `is_date` - Boolean value that is set to true if the 'value' is a 'Date' object, false otherwise.
2807 ///
2808 /// # Returns
2809 ///
2810 /// * Returns the function execution status.
2811 /// [`napi_ok`] If the function executed successfully.
2812 ///
2813 /// [`napi_invalid_arg`] If env, value or is_date is nullptr.
2814 ///
2815 ///
2816 /// Available since API-level: 10
2817 pub fn napi_is_date(env: napi_env, value: napi_value, is_date: *mut bool) -> napi_status;
2818 /// Obtains the C equivalent of the given ArkTS 'Date' object.
2819 ///
2820 /// # Arguments
2821 ///
2822 /// * `env` - Current running virtual machine context.
2823 ///
2824 /// * `value` - ArkTS data object.
2825 ///
2826 /// * `result` - C time value in milliseconds format since 01 January, 1970 UTC.
2827 ///
2828 /// # Returns
2829 ///
2830 /// * Returns the function execution status.
2831 /// [`napi_ok`] If the function executed successfully.
2832 ///
2833 /// [`napi_invalid_arg`] If env, value or result is nullptr.
2834 ///
2835 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2836 ///
2837 /// [`napi_date_expected`] If the 'value' is not a 'Date' object.
2838 ///
2839 ///
2840 /// Available since API-level: 10
2841 pub fn napi_get_date_value(env: napi_env, value: napi_value, result: *mut f64) -> napi_status;
2842 /// Adds a 'napi_finalize' callback, which will be called when the ArkTS object is garbage-collected.
2843 ///
2844 /// # Arguments
2845 ///
2846 /// * `env` - Current running virtual machine context.
2847 ///
2848 /// * `js_object` - The ArkTS object value.
2849 ///
2850 /// * `native_object` - Native object to bind with the ArkTS object.
2851 ///
2852 /// * `finalize_cb` - Native callback that can be used to free the native object
2853 /// when the ArkTS object is garbage-collected.
2854 ///
2855 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
2856 ///
2857 /// * `result` - Optional reference of the ArkTS object.
2858 ///
2859 ///
2860 /// # Returns
2861 ///
2862 /// * Return the function execution status.
2863 ///
2864 /// Available since API-level: 11
2865 #[cfg(feature = "api-11")]
2866 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
2867 pub fn napi_add_finalizer(
2868 env: napi_env,
2869 js_object: napi_value,
2870 native_object: *mut ::core::ffi::c_void,
2871 finalize_cb: napi_finalize,
2872 finalize_hint: *mut ::core::ffi::c_void,
2873 result: *mut napi_ref,
2874 ) -> napi_status;
2875 /// Creates an ArkTS BigInt from C int64 data.
2876 ///
2877 /// # Arguments
2878 ///
2879 /// * `env` - Current running virtual machine context.
2880 ///
2881 /// * `value` - C int64 data.
2882 ///
2883 /// * `result` - Created ArkTS BigInt object from C int64 data.
2884 ///
2885 /// # Returns
2886 ///
2887 /// * Returns the function execution status.
2888 /// [`napi_ok`] If the function executed successfully.
2889 ///
2890 /// [`napi_invalid_arg`] If env or result is nullptr.
2891 ///
2892 ///
2893 /// Available since API-level: 10
2894 pub fn napi_create_bigint_int64(
2895 env: napi_env,
2896 value: i64,
2897 result: *mut napi_value,
2898 ) -> napi_status;
2899 /// Creates an ArkTS BigInt from C int64 data.
2900 ///
2901 /// # Arguments
2902 ///
2903 /// * `env` - Current running virtual machine context.
2904 ///
2905 /// * `value` - C int64 data.
2906 ///
2907 /// * `result` - Created ArkTS BigInt object from C int64 data.
2908 ///
2909 /// # Returns
2910 ///
2911 /// * Returns the function execution status.
2912 /// [`napi_ok`] If the function executed successfully.
2913 ///
2914 /// [`napi_invalid_arg`] If env or result is nullptr.
2915 ///
2916 ///
2917 /// Available since API-level: 10
2918 pub fn napi_create_bigint_uint64(
2919 env: napi_env,
2920 value: u64,
2921 result: *mut napi_value,
2922 ) -> napi_status;
2923 /// Creates a single ArkTS BigInt from a C uint64 array.
2924 ///
2925 /// # Arguments
2926 ///
2927 /// * `env` - Current running virtual machine context.
2928 ///
2929 /// * `sign_bit` - Sign bit of the BigInt. If sign_bit is 0, the BigInt is positive, otherwise it is negative.
2930 ///
2931 /// * `word_count` - The size of the words array.
2932 ///
2933 /// * `words` - C uint64 array in little-endian 64-bit format.
2934 ///
2935 /// * `result` - Created ArkTS BigInt object from C int64 array.
2936 ///
2937 /// # Returns
2938 ///
2939 /// * Returns the function execution status.
2940 /// [`napi_ok`] If the function executed successfully.
2941 ///
2942 /// [`napi_invalid_arg`] If env, words or result is nullptr or word_count is larger than 2147483647.
2943 ///
2944 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
2945 ///
2946 ///
2947 /// Available since API-level: 10
2948 pub fn napi_create_bigint_words(
2949 env: napi_env,
2950 sign_bit: ::core::ffi::c_int,
2951 word_count: usize,
2952 words: *const u64,
2953 result: *mut napi_value,
2954 ) -> napi_status;
2955 /// Obtains a signed 64-bit integer from an ArkTS BigInt object.
2956 ///
2957 /// # Arguments
2958 ///
2959 /// * `env` - Current running virtual machine context.
2960 ///
2961 /// * `value` - ArkTS BigInt object.
2962 ///
2963 /// * `result` - Pointer points to the location where store the C signed 64-bit integer value.
2964 ///
2965 /// * `lossless` - Indicates whether the conversion is lossless. If lossless is true, the conversion is lossless,
2966 /// false otherwise.
2967 ///
2968 /// # Returns
2969 ///
2970 /// * Returns the function execution status.
2971 /// [`napi_ok`] If the function executed successfully.
2972 ///
2973 /// [`napi_invalid_arg`] If env, value, result or lossless is nullptr or word_count is larger than
2974 ///
2975 /// 2147483647.
2976 ///
2977 /// [`napi_bigint_expected`] If the 'value' is not an ArkTS bigint object.
2978 ///
2979 ///
2980 /// Available since API-level: 10
2981 pub fn napi_get_value_bigint_int64(
2982 env: napi_env,
2983 value: napi_value,
2984 result: *mut i64,
2985 lossless: *mut bool,
2986 ) -> napi_status;
2987 /// Obtains an unsigned 64-bit integer from an ArkTS BigInt object.
2988 ///
2989 /// # Arguments
2990 ///
2991 /// * `env` - Current running virtual machine context.
2992 ///
2993 /// * `value` - ArkTS BigInt object.
2994 ///
2995 /// * `result` - Pointer points to the location where store the C unsigned 64-bit integer value.
2996 ///
2997 /// * `lossless` - Indicates whether the conversion is lossless. If lossless is true, the conversion is lossless,
2998 /// false otherwise.
2999 ///
3000 /// # Returns
3001 ///
3002 /// * Returns the function execution status.
3003 /// [`napi_ok`] If the function executed successfully.
3004 ///
3005 /// [`napi_invalid_arg`] If env, value, result or lossless is nullptr or word_count is larger than
3006 ///
3007 /// 2147483647.
3008 ///
3009 /// [`napi_bigint_expected`] If the 'value' is not an ArkTS bigint object.
3010 ///
3011 ///
3012 /// Available since API-level: 10
3013 pub fn napi_get_value_bigint_uint64(
3014 env: napi_env,
3015 value: napi_value,
3016 result: *mut u64,
3017 lossless: *mut bool,
3018 ) -> napi_status;
3019 /// Obtains the underlying 64-bit unsigned (uint64) byte data from an ArkTS BigInt object.
3020 ///
3021 /// # Arguments
3022 ///
3023 /// * `env` - Current running virtual machine context.
3024 ///
3025 /// * `value` - ArkTS BigInt object.
3026 ///
3027 /// * `sign_bit` - Sign bit of the BigInt. If sign_bit is 0, the BigInt is positive, otherwise it is negative.
3028 ///
3029 /// * `word_count` - The size of the words array.
3030 ///
3031 /// * `words` - C uint64 array in little-endian 64-bit format.
3032 ///
3033 /// # Returns
3034 ///
3035 /// * Returns the function execution status.
3036 /// [`napi_ok`] If the function executed successfully.
3037 ///
3038 /// [`napi_invalid_arg`] If env, value or word_count is nullptr or word_count is larger than 2147483647.
3039 ///
3040 /// [`napi_bigint_expected`] If the 'value' is not an ArkTS bigint object.
3041 ///
3042 ///
3043 /// Available since API-level: 10
3044 pub fn napi_get_value_bigint_words(
3045 env: napi_env,
3046 value: napi_value,
3047 sign_bit: *mut ::core::ffi::c_int,
3048 word_count: *mut usize,
3049 words: *mut u64,
3050 ) -> napi_status;
3051 /// Obtains the names of all properties of an ArkTS object.
3052 ///
3053 /// # Arguments
3054 ///
3055 /// * `env` - Current running virtual machine context.
3056 ///
3057 /// * `object` - ArkTS object.
3058 ///
3059 /// * `key_mode` - Key collection mode. If key_mode is napi_key_include_prototypes, the result includes properties on
3060 /// prototypes. If key_mode is napi_key_own_only, the result includes only properties directly on own
3061 /// object.
3062 ///
3063 /// * `key_filter` - Which properties to be collected.
3064 ///
3065 /// * `key_conversion` - Key conversion mode. If key_conversion is napi_key_keep_numbers, the numbered property keys
3066 /// will keep number type. If key_conversion is napi_key_numbers_to_strings, the numbered property
3067 /// keys will be convert to string type.
3068 ///
3069 /// * `result` - An array of ArkTS object that represent the property names of the object.
3070 ///
3071 /// # Returns
3072 ///
3073 /// * Returns the function execution status.
3074 /// [`napi_ok`] If the function executed successfully.
3075 ///
3076 /// [`napi_invalid_arg`] If env, object or result is nullptr;
3077 ///
3078 /// key_mode is not enumeration value of napi_key_collection_mode;
3079 ///
3080 /// key_conversion is not enumeration value of napi_key_conversion.
3081 ///
3082 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
3083 ///
3084 /// [`napi_object_expected`] If object is not object type and function type.
3085 ///
3086 ///
3087 /// Available since API-level: 10
3088 pub fn napi_get_all_property_names(
3089 env: napi_env,
3090 object: napi_value,
3091 key_mode: napi_key_collection_mode,
3092 key_filter: napi_key_filter,
3093 key_conversion: napi_key_conversion,
3094 result: *mut napi_value,
3095 ) -> napi_status;
3096 /// Associates data with the currently running environment.
3097 ///
3098 /// # Arguments
3099 ///
3100 /// * `env` - Current running virtual machine context.
3101 ///
3102 /// * `data` - Data item to bind with the 'env'.
3103 ///
3104 /// * `finalize_cb` - Optional native callback that will be triggered when 'env' is destroyed or this interface
3105 /// repeatedly calls.
3106 ///
3107 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
3108 ///
3109 ///
3110 /// # Returns
3111 ///
3112 /// * Returns the function execution status.
3113 ///
3114 /// Available since API-level: 11
3115 #[cfg(feature = "api-11")]
3116 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3117 pub fn napi_set_instance_data(
3118 env: napi_env,
3119 data: *mut ::core::ffi::c_void,
3120 finalize_cb: napi_finalize,
3121 finalize_hint: *mut ::core::ffi::c_void,
3122 ) -> napi_status;
3123 /// Retrieves the data that was previously associated with the currently running environment.
3124 ///
3125 /// # Arguments
3126 ///
3127 /// * `env` - Current running virtual machine context.
3128 ///
3129 /// * `data` - Data item is bound with the 'env'.
3130 ///
3131 ///
3132 /// # Returns
3133 ///
3134 /// * Returns the function execution status.
3135 ///
3136 /// Available since API-level: 11
3137 #[cfg(feature = "api-11")]
3138 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3139 pub fn napi_get_instance_data(
3140 env: napi_env,
3141 data: *mut *mut ::core::ffi::c_void,
3142 ) -> napi_status;
3143 /// Detaches the underlying data from an 'ArrayBuffer' object. After the data is detached, you
3144 /// can operate the data in C/C++.
3145 ///
3146 /// # Arguments
3147 ///
3148 /// * `env` - Current running virtual machine context.
3149 ///
3150 /// * `arraybuffer` - ArkTS ArrayBuffer object.
3151 ///
3152 /// # Returns
3153 ///
3154 /// * Returns the function execution status.
3155 /// [`napi_ok`] If the function executed successfully.
3156 ///
3157 /// [`napi_invalid_arg`] If env or arraybuffer is nullptr, if 'arraybuffer' is not an ArrayBuffer object.
3158 ///
3159 /// [`napi_object_expected`] If the 'arraybuffer' is not an ArkTS object.
3160 ///
3161 ///
3162 /// Available since API-level: 10
3163 pub fn napi_detach_arraybuffer(env: napi_env, arraybuffer: napi_value) -> napi_status;
3164 /// Checks whether the given 'ArrayBuffer' has been detached.
3165 ///
3166 /// # Arguments
3167 ///
3168 /// * `env` - Current running virtual machine context.
3169 ///
3170 /// * `value` - ArkTS ArrayBuffer object.
3171 ///
3172 /// * `result` - Boolean value that is set to true if the 'value' has been detached, false otherwise.
3173 ///
3174 /// # Returns
3175 ///
3176 /// * Returns the function execution status.
3177 /// [`napi_ok`] If the function executed successfully.
3178 ///
3179 /// [`napi_invalid_arg`] If env, value or result is nullptr.
3180 ///
3181 ///
3182 /// Available since API-level: 10
3183 pub fn napi_is_detached_arraybuffer(
3184 env: napi_env,
3185 value: napi_value,
3186 result: *mut bool,
3187 ) -> napi_status;
3188 pub fn napi_type_tag_object(
3189 env: napi_env,
3190 value: napi_value,
3191 type_tag: *const napi_type_tag,
3192 ) -> napi_status;
3193 pub fn napi_check_object_type_tag(
3194 env: napi_env,
3195 value: napi_value,
3196 type_tag: *const napi_type_tag,
3197 result: *mut bool,
3198 ) -> napi_status;
3199 /// Freezes an ArkTS object. Once an object is frozen, its properties are immutable.
3200 ///
3201 /// # Arguments
3202 ///
3203 /// * `env` - Current running virtual machine context.
3204 ///
3205 /// * `object` - The given ArkTS object.
3206 ///
3207 /// # Returns
3208 ///
3209 /// * Returns the function execution status.
3210 /// [`napi_ok`] If the function executed successfully.
3211 ///
3212 /// [`napi_invalid_arg`] If env or object is nullptr.
3213 ///
3214 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
3215 ///
3216 ///
3217 /// Available since API-level: 10
3218 pub fn napi_object_freeze(env: napi_env, object: napi_value) -> napi_status;
3219 /// Seals an ArkTS object. Once an object is sealed, its properties cannot be added or deleted, but property
3220 /// values can be modified.
3221 ///
3222 /// # Arguments
3223 ///
3224 /// * `env` - Current running virtual machine context.
3225 ///
3226 /// * `object` - The given ArkTS object.
3227 ///
3228 /// # Returns
3229 ///
3230 /// * Returns the function execution status.
3231 /// [`napi_ok`] If the function executed successfully.
3232 ///
3233 /// [`napi_invalid_arg`] If env or object is nullptr.
3234 ///
3235 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
3236 ///
3237 ///
3238 /// Available since API-level: 10
3239 pub fn napi_object_seal(env: napi_env, object: napi_value) -> napi_status;
3240 /// Registers a native module.
3241 ///
3242 /// # Arguments
3243 ///
3244 /// * `mod` - Native module of type 'napi_module' to be registered.
3245 ///
3246 /// Available since API-level: 10
3247 pub fn napi_module_register(mod_: *mut napi_module);
3248 /// Raises a fatal error to terminate the process immediately.
3249 /// # Arguments
3250 ///
3251 /// * `location` - Optional location for the error occurrence.
3252 ///
3253 /// * `location_len` - The byte length of the location, or NAPI_AUTO_LENGTH if it is terminated by a null character.
3254 ///
3255 /// * `message` - The message associated with the error.
3256 ///
3257 /// * `message_len` - The byte length of the message, or NAPI_AUTO_LENGTH if it is terminated by a null character.
3258 ///
3259 ///
3260 /// Available since API-level: 10
3261 pub fn napi_fatal_error(
3262 location: *const ::core::ffi::c_char,
3263 location_len: usize,
3264 message: *const ::core::ffi::c_char,
3265 message_len: usize,
3266 ) -> !;
3267 /// Creates an asynchronous context. The capabilities related to 'async_hook' are not supported currently.
3268 ///
3269 /// # Arguments
3270 ///
3271 /// * `env` - Current running virtual machine context.
3272 ///
3273 /// * `async_resource` - Object associated with the async work that will be passed to possible 'async_hook'.
3274 ///
3275 /// * `async_resource_name` - Identifier for the kind of resource that is being provided for diagnostic information
3276 /// exposed by the async_hooks API.
3277 ///
3278 /// * `result` - The initialized async context.
3279 ///
3280 ///
3281 /// # Returns
3282 ///
3283 /// * Returns the function execution status.
3284 ///
3285 /// Available since API-level: 11
3286 #[cfg(feature = "api-11")]
3287 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3288 pub fn napi_async_init(
3289 env: napi_env,
3290 async_resource: napi_value,
3291 async_resource_name: napi_value,
3292 result: *mut napi_async_context,
3293 ) -> napi_status;
3294 /// Destroys the previously created asynchronous context. The capabilities related to 'async_hook' are not
3295 /// supported currently.
3296 ///
3297 /// # Arguments
3298 ///
3299 /// * `env` - Current running virtual machine context.
3300 ///
3301 /// * `async_context` - The async context to be destroyed.
3302 ///
3303 ///
3304 /// # Returns
3305 ///
3306 /// * Returns the function execution status.
3307 ///
3308 /// Available since API-level: 11
3309 #[cfg(feature = "api-11")]
3310 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3311 pub fn napi_async_destroy(env: napi_env, async_context: napi_async_context) -> napi_status;
3312 /// Allows an ArkTS function to be called in the asynchronous context. The capabilities related to 'async_hook'
3313 /// are not supported currently.
3314 /// # Arguments
3315 ///
3316 /// * `env` - Current running virtual machine context.
3317 ///
3318 /// * `async_context` - The context environment for the async operation.
3319 ///
3320 /// * `recv` - The 'this' pointer of the function.
3321 ///
3322 /// * `func` - ArkTS function to be called.
3323 ///
3324 /// * `argc` - Size of the argument array which is passed to 'func'.
3325 ///
3326 /// * `argv` - Argument array.
3327 ///
3328 /// * `result` - Result returned by the ArkTS function.
3329 ///
3330 ///
3331 /// # Returns
3332 ///
3333 /// * Returns the function execution status.
3334 /// [`napi_ok`] If the function executed successfully.
3335 ///
3336 /// [`napi_invalid_arg`] If the param env, func and(or) recv is nullptr;
3337 ///
3338 /// If the param argc is greater than 0 but argv is nullptr.
3339 ///
3340 /// [`napi_object_expected`] If the param recv is not an ArkTS Object.
3341 ///
3342 /// [`napi_function_expected`] If the param func is not an ArkTS Function.
3343 ///
3344 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
3345 ///
3346 ///
3347 /// Available since API-level: 11
3348 #[cfg(feature = "api-11")]
3349 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3350 pub fn napi_make_callback(
3351 env: napi_env,
3352 async_context: napi_async_context,
3353 recv: napi_value,
3354 func: napi_value,
3355 argc: usize,
3356 argv: *const napi_value,
3357 result: *mut napi_value,
3358 ) -> napi_status;
3359 /// Creates an ArkTS ArrayBuffer object of the specified size.
3360 ///
3361 /// # Arguments
3362 ///
3363 /// * `env` - Current running virtual machine context.
3364 ///
3365 /// * `length` - Bytes size of the underlying arraybuffer.
3366 ///
3367 /// * `data` - Raw pointer to the underlying arraybuffer.
3368 ///
3369 /// * `result` - Created ArkTS ArrayBuffer object.
3370 ///
3371 /// # Returns
3372 ///
3373 /// * Returns the function execution status.
3374 /// [`napi_ok`] If the function executed successfully.
3375 ///
3376 /// [`napi_invalid_arg`] If env, data or result is nullptr, or length is larger than 2097152,
3377 /// or length is less than zero.
3378 ///
3379 ///
3380 /// Available since API-level: 10
3381 pub fn napi_create_buffer(
3382 env: napi_env,
3383 length: usize,
3384 data: *mut *mut ::core::ffi::c_void,
3385 result: *mut napi_value,
3386 ) -> napi_status;
3387 /// Creates an ArkTS ArrayBuffer object of the specified size and initializes it with the given data.
3388 ///
3389 /// # Arguments
3390 ///
3391 /// * `env` - Current running virtual machine context.n
3392 ///
3393 /// * `length` - Bytes size of the given data.
3394 ///
3395 /// * `data` - Given data.
3396 ///
3397 /// * `finalize_cb` - Optional native callback that can be used to free the given data when the ArkTS ArrayBuffer
3398 /// object has been garbage-collected.
3399 ///
3400 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
3401 ///
3402 /// * `result` - Created ArkTS ArrayBuffer object.
3403 ///
3404 /// # Returns
3405 ///
3406 /// * Returns the function execution status.
3407 /// [`napi_ok`] If the function executed successfully.
3408 ///
3409 /// [`napi_invalid_arg`] If env, data or result is nullptr, or length is larger than 2097152,
3410 /// or length is less than or equal to zero.
3411 ///
3412 /// [`napi_pending_exception`] If an ArkTS exception existed when the function was called.
3413 ///
3414 ///
3415 /// Available since API-level: 10
3416 pub fn napi_create_external_buffer(
3417 env: napi_env,
3418 length: usize,
3419 data: *mut ::core::ffi::c_void,
3420 finalize_cb: napi_finalize,
3421 finalize_hint: *mut ::core::ffi::c_void,
3422 result: *mut napi_value,
3423 ) -> napi_status;
3424 /// Creates an ArkTS ArrayBuffer object of the specified size and initializes it with the given data.
3425 ///
3426 /// # Arguments
3427 ///
3428 /// * `env` - Current running virtual machine context.
3429 ///
3430 /// * `length` - Bytes size of the given data.
3431 ///
3432 /// * `data` - Given data.
3433 ///
3434 /// * `result_data` - Raw pointer to the underlying arraybuffer.
3435 ///
3436 /// * `result` - Created ArkTS ArrayBuffer object.
3437 ///
3438 /// # Returns
3439 ///
3440 /// * Returns the function execution status.
3441 /// [`napi_ok`] If the function executed successfully.
3442 ///
3443 /// [`napi_invalid_arg`] If env, data or result is nullptr, or length is larger than 2097152,
3444 /// or length is less than or equal to zero.
3445 ///
3446 ///
3447 /// Available since API-level: 10
3448 pub fn napi_create_buffer_copy(
3449 env: napi_env,
3450 length: usize,
3451 data: *const ::core::ffi::c_void,
3452 result_data: *mut *mut ::core::ffi::c_void,
3453 result: *mut napi_value,
3454 ) -> napi_status;
3455 /// Checks whether the given ArkTS value is a 'ArrayBuffer' object.
3456 ///
3457 /// # Arguments
3458 ///
3459 /// * `env` - Current running virtual machine context.
3460 ///
3461 /// * `value` - ArkTS ArrayBuffer object.
3462 ///
3463 /// * `result` - Boolean value that is set to true if the 'value' is a 'ArrayBuffer' object, false otherwise.
3464 ///
3465 /// # Returns
3466 ///
3467 /// * Returns the function execution status.
3468 /// [`napi_ok`] If the function executed successfully.
3469 ///
3470 /// [`napi_invalid_arg`] If env, value or result is nullptr.
3471 ///
3472 ///
3473 /// Available since API-level: 10
3474 pub fn napi_is_buffer(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
3475 /// Obtains the underlying data of 'ArrayBuffer' and its length.
3476 ///
3477 /// # Arguments
3478 ///
3479 /// * `env` - Current running virtual machine context.
3480 ///
3481 /// * `value` - ArkTS ArrayBuffer object.
3482 ///
3483 /// * `data` - Raw pointer to the underlying arraybuffer.
3484 ///
3485 /// * `length` - Bytes size of the underlying arraybuffer.
3486 ///
3487 /// # Returns
3488 ///
3489 /// * Returns the function execution status.
3490 /// [`napi_ok`] If the function executed successfully.
3491 ///
3492 /// [`napi_invalid_arg`] If env, value or result is nullptr.
3493 ///
3494 /// [`napi_arraybuffer_expected`] If the 'value' is not an ArkTS array buffer object.
3495 ///
3496 ///
3497 /// Available since API-level: 10
3498 pub fn napi_get_buffer_info(
3499 env: napi_env,
3500 value: napi_value,
3501 data: *mut *mut ::core::ffi::c_void,
3502 length: *mut usize,
3503 ) -> napi_status;
3504 /// Allocate a work object that is used to execute logic asynchronously.
3505 /// # Arguments
3506 ///
3507 /// * `env` - Current running virtual machine context.
3508 ///
3509 /// * `async_resource` - Not supported, can be ignored by passing nullptr.
3510 ///
3511 /// * `async_resource_name` - Identifier for the kind of resource that is being provided for diagnostic information
3512 /// exposed by the HiTrace.
3513 ///
3514 /// * `execute` - The native function which should be called to execute the logic asynchronously. The given function
3515 /// is called from a worker pool thread and can execute in parallel with the main event loop thread.
3516 ///
3517 /// * `complete` - The native function which will be called when the asynchronous logic is completed or is cancelled.
3518 /// The given function is called from the main event loop thread.
3519 ///
3520 /// * `data` - User-provided data context. This will be passed back into the execute and complete functions.
3521 ///
3522 /// * `result` - The handle to the newly created async work.
3523 ///
3524 ///
3525 /// # Returns
3526 ///
3527 /// * Returns the function execution status.
3528 /// [`napi_ok`] If the function executed successfully.
3529 ///
3530 /// [`napi_invalid_arg`] If the param env, async_resource_name, execute, complete and(or) result is
3531 ///
3532 /// nullptr.
3533 ///
3534 ///
3535 /// Available since API-level: 10
3536 pub fn napi_create_async_work(
3537 env: napi_env,
3538 async_resource: napi_value,
3539 async_resource_name: napi_value,
3540 execute: napi_async_execute_callback,
3541 complete: napi_async_complete_callback,
3542 data: *mut ::core::ffi::c_void,
3543 result: *mut napi_async_work,
3544 ) -> napi_status;
3545 /// Free a previously allocated work object.
3546 /// # Arguments
3547 ///
3548 /// * `env` - Current running virtual machine context.
3549 ///
3550 /// * `work` - The handle returned by the call to napi_create_async_work.
3551 ///
3552 ///
3553 /// # Returns
3554 ///
3555 /// * Returns the function execution status.
3556 /// [`napi_ok`] If the function executed successfully.
3557 ///
3558 /// [`napi_invalid_arg`] If the param env and(or) work is nullptr.
3559 ///
3560 ///
3561 /// Available since API-level: 10
3562 pub fn napi_delete_async_work(env: napi_env, work: napi_async_work) -> napi_status;
3563 /// Requests that the previously allocated work be scheduled for execution. Once it returns successfully,
3564 /// this API must not be called again with the same napi_async_work item or the result will be undefined.
3565 /// # Arguments
3566 ///
3567 /// * `env` - Current running virtual machine context.
3568 ///
3569 /// * `work` - The handle returned by the call to napi_create_async_work.
3570 ///
3571 ///
3572 /// # Returns
3573 ///
3574 /// * Returns the function execution status.
3575 /// [`napi_ok`] If the function executed successfully.
3576 ///
3577 /// [`napi_invalid_arg`] If the param env and(or) work is nullptr.
3578 ///
3579 ///
3580 /// Available since API-level: 10
3581 pub fn napi_queue_async_work(env: napi_env, work: napi_async_work) -> napi_status;
3582 /// Cancels queued work if it has not yet been started. If it has already started executing, it cannot be
3583 /// cancelled. If successful, the complete callback will be invoked with a status value of napi_cancelled.
3584 /// The work should not be deleted before the complete callback invocation, even if it has been successfully
3585 /// cancelled.
3586 /// # Arguments
3587 ///
3588 /// * `env` - Current running virtual machine context.
3589 ///
3590 /// * `work` - The handle returned by the call to napi_create_async_work.
3591 ///
3592 ///
3593 /// # Returns
3594 ///
3595 /// * Returns the function execution status.
3596 /// [`napi_ok`] If the function executed successfully.
3597 ///
3598 /// [`napi_invalid_arg`] If the param env and(or) work is nullptr.
3599 ///
3600 ///
3601 /// Available since API-level: 10
3602 pub fn napi_cancel_async_work(env: napi_env, work: napi_async_work) -> napi_status;
3603 pub fn napi_get_node_version(
3604 env: napi_env,
3605 version: *mut *const napi_node_version,
3606 ) -> napi_status;
3607 /// Obtains the current libuv loop instance.
3608 /// # Arguments
3609 ///
3610 /// * `env` - Current running virtual machine context.
3611 ///
3612 /// * `loop` - Libuv event loop.
3613 ///
3614 /// # Returns
3615 ///
3616 /// * Returns the function execution status.
3617 /// [`napi_ok`] If the function executed successfully.
3618 ///
3619 /// [`napi_invalid_arg`] If env or loop is nullptr.
3620 ///
3621 /// [`napi_generic_failure`] If env is invalid.
3622 ///
3623 ///
3624 /// Available since API-level: 10
3625 pub fn napi_get_uv_event_loop(env: napi_env, loop_: *mut *mut uv_loop_s) -> napi_status;
3626 /// Throws UncaughtException to ArkTS.
3627 /// # Arguments
3628 ///
3629 /// * `env` - Current running virtual machine context.
3630 ///
3631 /// * `err` - Error object which is passed to 'UncaughtException'.
3632 ///
3633 ///
3634 /// # Returns
3635 ///
3636 /// * Returns the function execution status.
3637 /// [`napi_ok`] If the function executed successfully.
3638 ///
3639 /// [`napi_invalid_arg`] If the param env and(or) err is nullptr;
3640 ///
3641 /// If the param err is not an ArkTS Error value.
3642 ///
3643 /// [`napi_pending_exception`] There is an uncaught exception occurred before execution.
3644 ///
3645 ///
3646 /// Available since API-level: 12
3647 #[cfg(feature = "api-12")]
3648 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
3649 pub fn napi_fatal_exception(env: napi_env, err: napi_value) -> napi_status;
3650 /// Registers a clean-up hook for releasing resources when the environment exits.
3651 ///
3652 /// # Arguments
3653 ///
3654 /// * `env` - Current running virtual machine context.
3655 ///
3656 /// * `fun` - Function pointer which will be triggered when environment is destroy.
3657 ///
3658 /// * `arg` - The argument is passed to the function pointer 'fun'.
3659 ///
3660 ///
3661 /// # Returns
3662 ///
3663 /// * Returns the function execution status.
3664 ///
3665 /// Available since API-level: 11
3666 #[cfg(feature = "api-11")]
3667 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3668 pub fn napi_add_env_cleanup_hook(
3669 env: napi_env,
3670 fun: ::core::option::Option<unsafe extern "C" fn(arg: *mut ::core::ffi::c_void)>,
3671 arg: *mut ::core::ffi::c_void,
3672 ) -> napi_status;
3673 /// Unregisters the clean-up hook.
3674 ///
3675 /// # Arguments
3676 ///
3677 /// * `env` - Current running virtual machine context.
3678 ///
3679 /// * `fun` - Function pointer which will be triggered when environment is destroy.
3680 ///
3681 /// * `arg` - The argument is passed to the function pointer 'fun'.
3682 ///
3683 ///
3684 /// # Returns
3685 ///
3686 /// * Returns the function execution status.
3687 ///
3688 /// Available since API-level: 11
3689 #[cfg(feature = "api-11")]
3690 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3691 pub fn napi_remove_env_cleanup_hook(
3692 env: napi_env,
3693 fun: ::core::option::Option<unsafe extern "C" fn(arg: *mut ::core::ffi::c_void)>,
3694 arg: *mut ::core::ffi::c_void,
3695 ) -> napi_status;
3696 /// Opens a callback scope. The capabilities related to 'async_hook' are not supported currently.
3697 /// # Arguments
3698 ///
3699 /// * `env` - Current running virtual machine context.
3700 ///
3701 /// * `resource_object` - The resource object to be passed to possible 'async_hook'.
3702 ///
3703 /// * `context` - The context environment for the async operation.
3704 ///
3705 /// * `result` - The generated callback scope.
3706 ///
3707 ///
3708 /// # Returns
3709 ///
3710 /// * Returns the function execution status.
3711 ///
3712 /// Available since API-level: 11
3713 #[cfg(feature = "api-11")]
3714 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3715 pub fn napi_open_callback_scope(
3716 env: napi_env,
3717 resource_object: napi_value,
3718 context: napi_async_context,
3719 result: *mut napi_callback_scope,
3720 ) -> napi_status;
3721 /// Closes the callback scope. The capabilities related to 'async_hook' are not supported currently.
3722 ///
3723 /// # Arguments
3724 ///
3725 /// * `env` - Current running virtual machine context.
3726 ///
3727 /// * `scope` - The callback scope to be closed.
3728 ///
3729 ///
3730 /// # Returns
3731 ///
3732 /// * Returns the function execution status.
3733 ///
3734 /// Available since API-level: 11
3735 #[cfg(feature = "api-11")]
3736 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3737 pub fn napi_close_callback_scope(env: napi_env, scope: napi_callback_scope) -> napi_status;
3738 /// Creates a thread-safe function.
3739 /// # Arguments
3740 ///
3741 /// * `env` - Current running virtual machine context.
3742 ///
3743 /// * `func` - ArkTS function to be called.
3744 ///
3745 /// * `async_resource` - An optional Object associated with the async work that will be passed to possible
3746 /// 'async_hooks'.
3747 ///
3748 /// * `async_resource_name` - An ArkTS string to provide an identifier for the kind of resource that is being
3749 /// provided for diagnostic information exposed by the `async_hooks` interface.
3750 ///
3751 /// * `max_queue_size` - Maximum size of the event queue in the thread-safe function.
3752 ///
3753 /// * `initial_thread_count` - Initial thread count of the thread-safe function.
3754 ///
3755 /// * `thread_finalize_data` - Data passed to the finalize callback.
3756 ///
3757 /// * `thread_finalize_cb` - Finalize callback function which will be triggered when the thread-safe function is
3758 /// released.
3759 ///
3760 /// * `context` - Optional data is passed to 'call_js_cb'.
3761 ///
3762 /// * `call_js_cb` - Callback function which will be triggered after 'napi_call_threadsafe_function()' is called.
3763 ///
3764 /// * `result` - The created thread-safe function.
3765 ///
3766 /// # Returns
3767 ///
3768 /// * Returns the function execution status.
3769 /// [`napi_ok`] If the function executed successfully.
3770 ///
3771 /// [`napi_invalid_arg`] If env, async_resource_name or result is nullptr; max_queue_size is less than 0;
3772 ///
3773 /// initial_thread_count is greater than 128 or less than 0; func and call_js_cb are
3774 ///
3775 /// nullptr at same time.
3776 ///
3777 /// [`napi_generic_failure`] If create thread-safe function failed.
3778 ///
3779 ///
3780 /// Available since API-level: 10
3781 pub fn napi_create_threadsafe_function(
3782 env: napi_env,
3783 func: napi_value,
3784 async_resource: napi_value,
3785 async_resource_name: napi_value,
3786 max_queue_size: usize,
3787 initial_thread_count: usize,
3788 thread_finalize_data: *mut ::core::ffi::c_void,
3789 thread_finalize_cb: napi_finalize,
3790 context: *mut ::core::ffi::c_void,
3791 call_js_cb: napi_threadsafe_function_call_js,
3792 result: *mut napi_threadsafe_function,
3793 ) -> napi_status;
3794 /// Obtains the context of a thread-safe function.
3795 /// # Arguments
3796 ///
3797 /// * `func` - The created thread-safe function.
3798 ///
3799 /// * `result` - Pointer pointer to the context of the thread-safe function.
3800 ///
3801 /// # Returns
3802 ///
3803 /// * Returns the function execution status.
3804 /// [`napi_ok`] If the function executed successfully.
3805 ///
3806 /// [`napi_invalid_arg`] If func or result is nullptr.
3807 ///
3808 ///
3809 /// Available since API-level: 10
3810 pub fn napi_get_threadsafe_function_context(
3811 func: napi_threadsafe_function,
3812 result: *mut *mut ::core::ffi::c_void,
3813 ) -> napi_status;
3814 /// Calls a thread-safe function.
3815 /// # Arguments
3816 ///
3817 /// * `func` - The created thread-safe function.
3818 ///
3819 /// * `data` - Data passed to the callback function 'call_js_cb' which is registered by calling
3820 /// 'napi_create_threadsafe_function()'.
3821 ///
3822 /// * `is_blocking` - If true, this function blocks until the event queue is not full. If false, return directly.
3823 ///
3824 /// # Returns
3825 ///
3826 /// * Returns the function execution status.
3827 /// [`napi_ok`] If the function executed successfully.
3828 ///
3829 /// [`napi_invalid_arg`] If func is nullptr.
3830 ///
3831 /// [`napi_queue_full`] If event queue is full.
3832 ///
3833 /// [`napi_closing`] If the thread-safe function is closing.
3834 ///
3835 /// [`napi_generic_failure`] If call thread-safe function failed.
3836 ///
3837 ///
3838 /// Available since API-level: 10
3839 pub fn napi_call_threadsafe_function(
3840 func: napi_threadsafe_function,
3841 data: *mut ::core::ffi::c_void,
3842 is_blocking: napi_threadsafe_function_call_mode,
3843 ) -> napi_status;
3844 /// Acquires a thread-safe function.
3845 /// # Arguments
3846 ///
3847 /// * `func` - The created thread-safe function.
3848 ///
3849 /// # Returns
3850 ///
3851 /// * Returns the function execution status.
3852 /// [`napi_ok`] If the function executed successfully.
3853 ///
3854 /// [`napi_invalid_arg`] If func is nullptr.
3855 ///
3856 /// [`napi_generic_failure`] If acquire thread-safe function failed.
3857 ///
3858 ///
3859 /// Available since API-level: 10
3860 pub fn napi_acquire_threadsafe_function(func: napi_threadsafe_function) -> napi_status;
3861 /// Releases a thread-safe function.
3862 /// # Arguments
3863 ///
3864 /// * `func` - The created thread-safe function.
3865 ///
3866 /// * `mode` - Value of mode can be either 'napi_tsfn_release' to indicate that no more calls should be made
3867 /// to the thread-safe function from current thread or 'napi_tsfn_abort' to indicate that the queue
3868 /// of the thread-safe function will be closed and 'napi_closing' will be return when calling
3869 /// 'napi_call_threadsafe_function()' under the circumstance.
3870 ///
3871 /// # Returns
3872 ///
3873 /// * Returns the function execution status.
3874 /// [`napi_ok`] If the function executed successfully.
3875 ///
3876 /// [`napi_invalid_arg`] If func is nullptr.
3877 ///
3878 /// [`napi_generic_failure`] If release thread-safe function failed.
3879 ///
3880 ///
3881 /// Available since API-level: 10
3882 pub fn napi_release_threadsafe_function(
3883 func: napi_threadsafe_function,
3884 mode: napi_threadsafe_function_release_mode,
3885 ) -> napi_status;
3886 /// Indicates that the event loop running on the main thread may exit before the thread-safe function
3887 /// is destroyed.
3888 /// # Arguments
3889 ///
3890 /// * `env` - Current running virtual machine context.
3891 ///
3892 /// * `func` - The created thread-safe function.
3893 ///
3894 /// # Returns
3895 ///
3896 /// * Returns the function execution status.
3897 /// [`napi_ok`] If the function executed successfully.
3898 ///
3899 /// [`napi_invalid_arg`] If env or func is nullptr.
3900 ///
3901 /// [`napi_generic_failure`] If unref thread-safe function failed.
3902 ///
3903 ///
3904 /// Available since API-level: 10
3905 pub fn napi_unref_threadsafe_function(
3906 env: napi_env,
3907 func: napi_threadsafe_function,
3908 ) -> napi_status;
3909 /// Indicates that the event loop running on the main thread should not exit until the thread-safe
3910 /// function is destroyed.
3911 /// # Arguments
3912 ///
3913 /// * `env` - Current running virtual machine context.
3914 ///
3915 /// * `func` - The created thread-safe function.
3916 ///
3917 /// # Returns
3918 ///
3919 /// * Returns the function execution status.
3920 /// [`napi_ok`] If the function executed successfully.
3921 ///
3922 /// [`napi_invalid_arg`] If env or func is nullptr.
3923 ///
3924 /// [`napi_generic_failure`] If ref thread-safe function failed.
3925 ///
3926 ///
3927 /// Available since API-level: 10
3928 pub fn napi_ref_threadsafe_function(
3929 env: napi_env,
3930 func: napi_threadsafe_function,
3931 ) -> napi_status;
3932 /// Registers an asynchronous clean-up hook for releasing resources when the environment exits.
3933 ///
3934 /// # Arguments
3935 ///
3936 /// * `env` - Current running virtual machine context.
3937 ///
3938 /// * `hook` - The function pointer to call at environment teardown.
3939 ///
3940 /// * `arg` - The pointer to pass to `hook` when it gets called.
3941 ///
3942 /// * `remove_handle` - Optional handle that refers to the asynchronous cleanup.
3943 ///
3944 ///
3945 /// # Returns
3946 ///
3947 /// * Returns the function execution status.
3948 ///
3949 /// Available since API-level: 11
3950 #[cfg(feature = "api-11")]
3951 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3952 pub fn napi_add_async_cleanup_hook(
3953 env: napi_env,
3954 hook: napi_async_cleanup_hook,
3955 arg: *mut ::core::ffi::c_void,
3956 remove_handle: *mut napi_async_cleanup_hook_handle,
3957 ) -> napi_status;
3958 /// Unregisters the asynchronous clean-up hook.
3959 ///
3960 /// # Arguments
3961 ///
3962 /// * `remove_handle` - Optional handle that refers to the asynchronous cleanup.
3963 ///
3964 ///
3965 /// # Returns
3966 ///
3967 /// * Returns the function execution status.
3968 ///
3969 /// Available since API-level: 11
3970 #[cfg(feature = "api-11")]
3971 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3972 pub fn napi_remove_async_cleanup_hook(
3973 remove_handle: napi_async_cleanup_hook_handle,
3974 ) -> napi_status;
3975 /// Obtains the absolute path of the location, from which the addon is loaded.
3976 ///
3977 /// # Arguments
3978 ///
3979 /// * `env` - Current running virtual machine context.
3980 ///
3981 /// * `result` - The absolute path of the location of the loaded addon.
3982 ///
3983 ///
3984 /// # Returns
3985 ///
3986 /// * Returns the function execution status.
3987 ///
3988 /// Available since API-level: 11
3989 #[cfg(feature = "api-11")]
3990 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
3991 pub fn node_api_get_module_file_name(
3992 env: napi_env,
3993 result: *mut *const ::core::ffi::c_char,
3994 ) -> napi_status;
3995 pub fn napi_run_script_path(
3996 env: napi_env,
3997 path: *const ::core::ffi::c_char,
3998 result: *mut napi_value,
3999 ) -> napi_status;
4000 pub fn napi_queue_async_work_with_qos(
4001 env: napi_env,
4002 work: napi_async_work,
4003 qos: napi_qos_t,
4004 ) -> napi_status;
4005 /// Loads an .abc file as a module. This API returns the namespace of the module.
4006 /// # Arguments
4007 ///
4008 /// * `env` - Current running virtual machine context.
4009 ///
4010 /// * `path` - Path of the .abc file or name of the module to load.
4011 ///
4012 /// * `result` - Result of the module object.
4013 ///
4014 ///
4015 /// # Returns
4016 ///
4017 /// * Returns the function execution status.
4018 ///
4019 /// Available since API-level: 11
4020 #[cfg(feature = "api-11")]
4021 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
4022 pub fn napi_load_module(
4023 env: napi_env,
4024 path: *const ::core::ffi::c_char,
4025 result: *mut napi_value,
4026 ) -> napi_status;
4027 /// Create ArkTS Object with initial properties given by descriptors, note that property key must be String, and
4028 /// must can not convert to element_index, also all keys must not duplicate.
4029 ///
4030 /// # Arguments
4031 ///
4032 /// * `env` - Current running virtual machine context.
4033 ///
4034 /// * `result` - The created ArkTS object.
4035 ///
4036 /// * `property_count` - Number of the property descriptors.
4037 ///
4038 /// * `properties` - Array of property descriptors which are expected to be applied to the ArkTS object.
4039 ///
4040 ///
4041 /// # Returns
4042 ///
4043 /// * Returns the function execution status.
4044 ///
4045 /// Available since API-level: 11
4046 #[cfg(feature = "api-11")]
4047 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
4048 pub fn napi_create_object_with_properties(
4049 env: napi_env,
4050 result: *mut napi_value,
4051 property_count: usize,
4052 properties: *const napi_property_descriptor,
4053 ) -> napi_status;
4054 /// Create ArkTS Object with initial properties given by keys and values, note that property key must be String,
4055 /// and must can not convert to element_index, also all keys must not duplicate.
4056 ///
4057 /// # Arguments
4058 ///
4059 /// * `env` - Current running virtual machine context.
4060 ///
4061 /// * `result` - The absolute path of the location of the loaded addon.
4062 ///
4063 /// * `property_count` - Number of the propertied which needs to be applied on the ArkTS object.
4064 ///
4065 /// * `keys` - Array of the keys of the properties.
4066 ///
4067 /// * `values` - Array of the values of the properties.
4068 ///
4069 ///
4070 /// # Returns
4071 ///
4072 /// * Returns the function execution status.
4073 ///
4074 /// Available since API-level: 11
4075 #[cfg(feature = "api-11")]
4076 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
4077 pub fn napi_create_object_with_named_properties(
4078 env: napi_env,
4079 result: *mut napi_value,
4080 property_count: usize,
4081 keys: *mut *const ::core::ffi::c_char,
4082 values: *const napi_value,
4083 ) -> napi_status;
4084 /// This API sets native properties to a object and converts this ArkTS object to native binding object.
4085 ///
4086 /// # Arguments
4087 ///
4088 /// * `env` - Current running virtual machine context.
4089 ///
4090 /// * `js_object` - The ArkTS value to coerce.
4091 ///
4092 /// * `detach_cb` - Native callback that can be used to detach the ArkTS object and the native object.
4093 ///
4094 /// * `attach_cb` - Native callback that can be used to bind the ArkTS object and the native object.
4095 ///
4096 /// * `native_object` - User-provided native instance to pass to thr detach callback and attach callback.
4097 ///
4098 /// * `hint` - Optional hint to pass to the detach callback and attach callback.
4099 ///
4100 ///
4101 /// # Returns
4102 ///
4103 /// * Return the function execution status.
4104 ///
4105 /// Available since API-level: 11
4106 #[cfg(feature = "api-11")]
4107 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
4108 pub fn napi_coerce_to_native_binding_object(
4109 env: napi_env,
4110 js_object: napi_value,
4111 detach_cb: napi_native_binding_detach_callback,
4112 attach_cb: napi_native_binding_attach_callback,
4113 native_object: *mut ::core::ffi::c_void,
4114 hint: *mut ::core::ffi::c_void,
4115 ) -> napi_status;
4116 /// The module is loaded through the NAPI. By default, the default object is exported from the module.
4117 ///
4118 /// # Arguments
4119 ///
4120 /// * `env` - Current running virtual machine context.
4121 ///
4122 /// * `path` - Path name of the module to be loaded, like
4123 /// * `module_info` - Path names of bundle and module, like com.example.application/entry.
4124 ///
4125 /// * `result` - Result of loading a module, which is an exported object of the module.
4126 ///
4127 ///
4128 /// # Returns
4129 ///
4130 /// * Returns the function execution status.
4131 ///
4132 /// Available since API-level: 12
4133 #[cfg(feature = "api-12")]
4134 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4135 pub fn napi_load_module_with_info(
4136 env: napi_env,
4137 path: *const ::core::ffi::c_char,
4138 module_info: *const ::core::ffi::c_char,
4139 result: *mut napi_value,
4140 ) -> napi_status;
4141 /// Create the ark runtime.
4142 ///
4143 /// # Arguments
4144 ///
4145 /// * `env` - Indicates the ark runtime environment.
4146 ///
4147 ///
4148 /// # Returns
4149 ///
4150 /// * Return the function execution status.
4151 ///
4152 /// Available since API-level: 12
4153 #[cfg(feature = "api-12")]
4154 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4155 pub fn napi_create_ark_runtime(env: *mut napi_env) -> napi_status;
4156 /// Destroy the ark runtime.
4157 ///
4158 /// # Arguments
4159 ///
4160 /// * `env` - Indicates the ark runtime environment.
4161 ///
4162 ///
4163 /// # Returns
4164 ///
4165 /// * Return the function execution status.
4166 ///
4167 /// Available since API-level: 12
4168 #[cfg(feature = "api-12")]
4169 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4170 pub fn napi_destroy_ark_runtime(env: *mut napi_env) -> napi_status;
4171 /// Defines a sendable class.
4172 ///
4173 /// # Arguments
4174 ///
4175 /// * `env` - The environment that the API is invoked under.
4176 ///
4177 /// * `utf8name` - Name of the ArkTS constructor function.
4178 ///
4179 /// * `length` - The length of the utf8name in bytes, or NAPI_AUTO_LENGTH if it is null-terminated.
4180 ///
4181 /// * `constructor` - Callback function that handles constructing instances of the class.
4182 ///
4183 /// * `data` - Optional data to be passed to the constructor callback as the data property of the callback info.
4184 ///
4185 /// * `property_count` - Number of items in the properties array argument.
4186 ///
4187 /// * `properties` - Array of property descriptors describing static and instance data properties, accessors, and
4188 /// methods on the class. See napi_property_descriptor.
4189 ///
4190 /// * `parent` - A napi_value representing the Superclass.
4191 ///
4192 /// * `result` - A napi_value representing the constructor function for the class.
4193 ///
4194 ///
4195 /// # Returns
4196 ///
4197 /// * Return the function execution status.
4198 ///
4199 /// Available since API-level: 12
4200 #[cfg(feature = "api-12")]
4201 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4202 pub fn napi_define_sendable_class(
4203 env: napi_env,
4204 utf8name: *const ::core::ffi::c_char,
4205 length: usize,
4206 constructor: napi_callback,
4207 data: *mut ::core::ffi::c_void,
4208 property_count: usize,
4209 properties: *const napi_property_descriptor,
4210 parent: napi_value,
4211 result: *mut napi_value,
4212 ) -> napi_status;
4213 /// Queries a napi_value to check if it is sendable.
4214 ///
4215 /// # Arguments
4216 ///
4217 /// * `env` - The environment that the API is invoked under.
4218 ///
4219 /// * `value` - The napi_value to be checked.
4220 ///
4221 /// * `result` - Boolean value that is set to true if napi_value is sendable, false otherwise.
4222 ///
4223 ///
4224 /// # Returns
4225 ///
4226 /// * Return the function execution status.
4227 ///
4228 /// Available since API-level: 12
4229 #[cfg(feature = "api-12")]
4230 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4231 pub fn napi_is_sendable(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
4232 /// Defines a sendable object.
4233 ///
4234 /// # Arguments
4235 ///
4236 /// * `env` - The environment that the API is invoked under.
4237 ///
4238 /// * `property_count` - The count of object properties.
4239 ///
4240 /// * `properties` - Object properties.
4241 ///
4242 /// * `result` - The created sendable object.
4243 ///
4244 ///
4245 /// # Returns
4246 ///
4247 /// * Return the function execution status.
4248 ///
4249 /// Available since API-level: 12
4250 #[cfg(feature = "api-12")]
4251 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4252 pub fn napi_create_sendable_object_with_properties(
4253 env: napi_env,
4254 property_count: usize,
4255 properties: *const napi_property_descriptor,
4256 result: *mut napi_value,
4257 ) -> napi_status;
4258 /// Wraps a native instance in an ArkTS object.
4259 ///
4260 /// # Arguments
4261 ///
4262 /// * `env` - The environment that the API is invoked under.
4263 ///
4264 /// * `js_object` - The ArkTS object that will be the wrapper for the native object.
4265 ///
4266 /// * `native_object` - The native instance that will be wrapped in the ArkTS object.
4267 ///
4268 /// * `finalize_cb` - Optional native callback that can be used to free the native instance when the ArkTS object
4269 /// has been garbage-collected.
4270 ///
4271 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
4272 ///
4273 ///
4274 /// # Returns
4275 ///
4276 /// * Return the function execution status.
4277 ///
4278 /// Available since API-level: 12
4279 #[cfg(feature = "api-12")]
4280 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4281 pub fn napi_wrap_sendable(
4282 env: napi_env,
4283 js_object: napi_value,
4284 native_object: *mut ::core::ffi::c_void,
4285 finalize_cb: napi_finalize,
4286 finalize_hint: *mut ::core::ffi::c_void,
4287 ) -> napi_status;
4288 /// Wraps a native instance in an ArkTS object.
4289 ///
4290 /// # Arguments
4291 ///
4292 /// * `env` - The environment that the API is invoked under.
4293 ///
4294 /// * `js_object` - The ArkTS object that will be the wrapper for the native object.
4295 ///
4296 /// * `native_object` - The native instance that will be wrapped in the ArkTS object.
4297 ///
4298 /// * `finalize_cb` - Optional native callback that can be used to free the native instance when the ArkTS object
4299 /// has been garbage-collected.
4300 ///
4301 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
4302 ///
4303 /// * `native_binding_size` - The size of native binding.
4304 ///
4305 ///
4306 /// # Returns
4307 ///
4308 /// * Return the function execution status.
4309 ///
4310 /// Available since API-level: 12
4311 #[cfg(feature = "api-12")]
4312 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4313 pub fn napi_wrap_sendable_with_size(
4314 env: napi_env,
4315 js_object: napi_value,
4316 native_object: *mut ::core::ffi::c_void,
4317 finalize_cb: napi_finalize,
4318 finalize_hint: *mut ::core::ffi::c_void,
4319 native_binding_size: usize,
4320 ) -> napi_status;
4321 /// Retrieves a native instance that was previously wrapped in an ArkTS object.
4322 ///
4323 /// # Arguments
4324 ///
4325 /// * `env` - The environment that the API is invoked under.
4326 ///
4327 /// * `js_object` - The object associated with the native instance.
4328 ///
4329 /// * `result` - Pointer to the wrapped native instance.
4330 ///
4331 ///
4332 /// # Returns
4333 ///
4334 /// * Return the function execution status.
4335 ///
4336 /// Available since API-level: 12
4337 #[cfg(feature = "api-12")]
4338 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4339 pub fn napi_unwrap_sendable(
4340 env: napi_env,
4341 js_object: napi_value,
4342 result: *mut *mut ::core::ffi::c_void,
4343 ) -> napi_status;
4344 /// Retrieves a native instance that was previously wrapped in an ArkTS object and removes the wrapping.
4345 ///
4346 /// # Arguments
4347 ///
4348 /// * `env` - The environment that the API is invoked under.
4349 ///
4350 /// * `js_object` - The object associated with the native instance.
4351 ///
4352 /// * `result` - Pointer to the wrapped native instance.
4353 ///
4354 ///
4355 /// # Returns
4356 ///
4357 /// * Return the function execution status.
4358 ///
4359 /// Available since API-level: 12
4360 #[cfg(feature = "api-12")]
4361 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4362 pub fn napi_remove_wrap_sendable(
4363 env: napi_env,
4364 js_object: napi_value,
4365 result: *mut *mut ::core::ffi::c_void,
4366 ) -> napi_status;
4367 /// Create a sendable array.
4368 ///
4369 /// # Arguments
4370 ///
4371 /// * `env` - The environment that the API is invoked under.
4372 ///
4373 /// * `result` - A napi_value representing a sendable array.
4374 ///
4375 ///
4376 /// # Returns
4377 ///
4378 /// * Return the function execution status.
4379 ///
4380 /// Available since API-level: 12
4381 #[cfg(feature = "api-12")]
4382 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4383 pub fn napi_create_sendable_array(env: napi_env, result: *mut napi_value) -> napi_status;
4384 /// Create a sendable array with length.
4385 ///
4386 /// # Arguments
4387 ///
4388 /// * `env` - The environment that the API is invoked under.
4389 ///
4390 /// * `length` - The initial length of the sendable array.
4391 ///
4392 /// * `result` - A napi_value representing a sendable array.
4393 ///
4394 ///
4395 /// # Returns
4396 ///
4397 /// * Return the function execution status.
4398 ///
4399 /// Available since API-level: 12
4400 #[cfg(feature = "api-12")]
4401 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4402 pub fn napi_create_sendable_array_with_length(
4403 env: napi_env,
4404 length: usize,
4405 result: *mut napi_value,
4406 ) -> napi_status;
4407 /// Create a sendable arraybuffer.
4408 ///
4409 /// # Arguments
4410 ///
4411 /// * `env` - The environment that the API is invoked under.
4412 ///
4413 /// * `byte_length` - The length in bytes of the sendable arraybuffer to create.
4414 ///
4415 /// * `data` - Pointer to the underlying byte buffer of the sendable arraybuffer.
4416 ///
4417 /// * `result` - A napi_value representing a sendable arraybuffer.
4418 ///
4419 ///
4420 /// # Returns
4421 ///
4422 /// * Return the function execution status.
4423 ///
4424 /// Available since API-level: 12
4425 #[cfg(feature = "api-12")]
4426 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4427 pub fn napi_create_sendable_arraybuffer(
4428 env: napi_env,
4429 byte_length: usize,
4430 data: *mut *mut ::core::ffi::c_void,
4431 result: *mut napi_value,
4432 ) -> napi_status;
4433 /// Create a sendable typedarray.
4434 ///
4435 /// # Arguments
4436 ///
4437 /// * `env` - The environment that the API is invoked under.
4438 ///
4439 /// * `type` - Scalar datatype of the elements within the sendable typedarray.
4440 ///
4441 /// * `length` - Number of elements in the typedarray.
4442 ///
4443 /// * `arraybuffer` - Sendable arraybuffer underlying the sendable typedarray.
4444 ///
4445 /// * `byte_offset` - The byte offset within the sendable arraybuffer from which to start projecting the
4446 /// sendable typedarray.
4447 ///
4448 /// * `result` - A napi_value representing a sendable typedarray.
4449 ///
4450 ///
4451 /// # Returns
4452 ///
4453 /// * Return the function execution status.
4454 ///
4455 /// Available since API-level: 12
4456 #[cfg(feature = "api-12")]
4457 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4458 pub fn napi_create_sendable_typedarray(
4459 env: napi_env,
4460 type_: napi_typedarray_type,
4461 length: usize,
4462 arraybuffer: napi_value,
4463 byte_offset: usize,
4464 result: *mut napi_value,
4465 ) -> napi_status;
4466 /// Run the event loop by the given env and running mode in current thread.
4467 ///
4468 /// Support to run the native event loop in an asynchronous native thread with the specified running mode.
4469 ///
4470 /// # Arguments
4471 ///
4472 /// * `env` - Current running virtual machine context.
4473 ///
4474 /// * `mode` - Indicates the running mode of the native event loop.
4475 ///
4476 ///
4477 /// # Returns
4478 ///
4479 /// * Return the function execution status.
4480 ///
4481 /// Available since API-level: 12
4482 #[cfg(feature = "api-12")]
4483 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4484 pub fn napi_run_event_loop(env: napi_env, mode: napi_event_mode) -> napi_status;
4485 /// Stop the event loop in current thread.
4486 ///
4487 /// Support to stop the running event loop in current native thread.
4488 ///
4489 /// # Arguments
4490 ///
4491 /// * `env` - Current running virtual machine context.
4492 ///
4493 ///
4494 /// # Returns
4495 ///
4496 /// * Return the function execution status.
4497 ///
4498 /// Available since API-level: 12
4499 #[cfg(feature = "api-12")]
4500 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4501 pub fn napi_stop_event_loop(env: napi_env) -> napi_status;
4502 /// Serialize an ArkTS object.
4503 ///
4504 /// # Arguments
4505 ///
4506 /// * `env` - Current running virtual machine context.
4507 ///
4508 /// * `object` - The ArkTS object to serialize.
4509 ///
4510 /// * `transfer_list` - List of data to transfer in transfer mode.
4511 ///
4512 /// * `clone_list` - List of Sendable data to transfer in clone mode.
4513 ///
4514 /// * `result` - Serialization result of the ArkTS object.
4515 ///
4516 ///
4517 /// # Returns
4518 ///
4519 /// * Returns the function execution status.
4520 ///
4521 /// Available since API-level: 12
4522 #[cfg(feature = "api-12")]
4523 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4524 pub fn napi_serialize(
4525 env: napi_env,
4526 object: napi_value,
4527 transfer_list: napi_value,
4528 clone_list: napi_value,
4529 result: *mut *mut ::core::ffi::c_void,
4530 ) -> napi_status;
4531 /// Restore serialization data to an ArkTS object.
4532 ///
4533 /// # Arguments
4534 ///
4535 /// * `env` - Current running virtual machine context.
4536 ///
4537 /// * `buffer` - Data to deserialize.
4538 ///
4539 /// * `object` - ArkTS object obtained by deserialization.
4540 ///
4541 ///
4542 /// # Returns
4543 ///
4544 /// * Returns the function execution status.
4545 ///
4546 /// Available since API-level: 12
4547 #[cfg(feature = "api-12")]
4548 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4549 pub fn napi_deserialize(
4550 env: napi_env,
4551 buffer: *mut ::core::ffi::c_void,
4552 object: *mut napi_value,
4553 ) -> napi_status;
4554 /// Delete serialization data.
4555 ///
4556 /// # Arguments
4557 ///
4558 /// * `env` - Current running virtual machine context.
4559 ///
4560 /// * `buffer` - Data to delete.
4561 ///
4562 ///
4563 /// # Returns
4564 ///
4565 /// * Returns the function execution status.
4566 ///
4567 /// Available since API-level: 12
4568 #[cfg(feature = "api-12")]
4569 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4570 pub fn napi_delete_serialization_data(
4571 env: napi_env,
4572 buffer: *mut ::core::ffi::c_void,
4573 ) -> napi_status;
4574 /// Dispatch a task with specified priority from a native thread to an ArkTS thread, the task will execute
4575 /// the given thread safe function.
4576 ///
4577 /// # Arguments
4578 ///
4579 /// * `func` - Indicates the thread safe function.
4580 ///
4581 /// * `data` - Indicates the data anticipated to be transferred to the ArkTS thread.
4582 ///
4583 /// * `priority` - Indicates the priority of the task dispatched.
4584 ///
4585 /// * `isTail` - Indicates the way of the task dispatched into the native event queue. When "isTail" is true,
4586 /// the task will be dispatched to the tail of the native event queue. Conversely, when "isTail" is
4587 /// false, the tasks will be dispatched to the head of the native event queue.
4588 ///
4589 ///
4590 /// # Returns
4591 ///
4592 /// * Return the function execution status.
4593 ///
4594 /// Available since API-level: 12
4595 #[cfg(feature = "api-12")]
4596 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
4597 pub fn napi_call_threadsafe_function_with_priority(
4598 func: napi_threadsafe_function,
4599 data: *mut ::core::ffi::c_void,
4600 priority: napi_task_priority,
4601 isTail: bool,
4602 ) -> napi_status;
4603 /// Wraps a native instance in an ArkTS object.
4604 /// # Arguments
4605 ///
4606 /// * `env` - The environment that the API is invoked under.
4607 ///
4608 /// * `js_object` - The ArkTS object that will be the wrapper for the native object.
4609 ///
4610 /// * `native_object` - The native instance that will be wrapped in the ArkTS object.
4611 ///
4612 /// * `finalize_cb` - Optional native callback that can be used to free the native instance when the ArkTS object
4613 /// has been garbage-collected.
4614 ///
4615 /// * `async_finalizer` - A boolean value to determine that finalize_cb execute async or not.
4616 ///
4617 /// * `finalize_hint` - Optional contextual hint that is passed to the finalize callback.
4618 ///
4619 /// * `native_binding_size` - The size of native binding.
4620 ///
4621 /// * `result` - Optional reference to the wrapped object.
4622 ///
4623 ///
4624 /// # Returns
4625 ///
4626 /// * Returns the function execution status.
4627 /// [`napi_ok`] If the function executed successfully.
4628 ///
4629 /// [`napi_invalid_arg`] If the param env, js_object or native_object is nullptr.
4630 ///
4631 /// [`napi_object_expected`] If the param js_object is not an ArkTS Object or Function.
4632 ///
4633 /// [`napi_pending_exception`] There is an uncaught exception occurred before(in) execution.
4634 ///
4635 ///
4636 /// Available since API-level: 18
4637 #[cfg(feature = "api-18")]
4638 #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
4639 pub fn napi_wrap_enhance(
4640 env: napi_env,
4641 js_object: napi_value,
4642 native_object: *mut ::core::ffi::c_void,
4643 finalize_cb: napi_finalize,
4644 async_finalizer: bool,
4645 finalize_hint: *mut ::core::ffi::c_void,
4646 native_binding_size: usize,
4647 result: *mut napi_ref,
4648 ) -> napi_status;
4649 /// To create a new virtual machine context.
4650 /// # Arguments
4651 ///
4652 /// * `env` - Current running virtual machine context.
4653 ///
4654 /// * `newEnv` - New generated virtual machine context which is expected to be used later.
4655 ///
4656 ///
4657 /// # Returns
4658 ///
4659 /// * Returns the function execution status.
4660 /// [`napi_ok`] If the function executed successfully.
4661 ///
4662 /// [`napi_invalid_arg`] If the param env is nullptr.
4663 ///
4664 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
4665 ///
4666 ///
4667 /// Available since API-level: 20
4668 #[cfg(feature = "api-20")]
4669 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
4670 pub fn napi_create_ark_context(env: napi_env, newEnv: *mut napi_env) -> napi_status;
4671 /// To switch a virtual machine context which is expected to be used later.
4672 /// # Arguments
4673 ///
4674 /// * `env` - Designated Virtual machine context which is expected to be used as the current virtual machine context.
4675 ///
4676 ///
4677 /// # Returns
4678 ///
4679 /// * Returns the function execution status.
4680 /// [`napi_ok`] If the function executed successfully.
4681 ///
4682 /// [`napi_invalid_arg`] If the param env is nullptr.
4683 ///
4684 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
4685 ///
4686 ///
4687 /// Available since API-level: 20
4688 #[cfg(feature = "api-20")]
4689 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
4690 pub fn napi_switch_ark_context(env: napi_env) -> napi_status;
4691 /// To destroy a virtual machine context which will not be used again.
4692 /// # Arguments
4693 ///
4694 /// * `env` - Virtual machine context expected to be destroyed.
4695 ///
4696 ///
4697 /// # Returns
4698 ///
4699 /// * Returns the function execution status.
4700 /// [`napi_ok`] If the function executed successfully.
4701 ///
4702 /// [`napi_invalid_arg`] If the param env is nullptr.
4703 ///
4704 /// [`napi_pending_exception`] If have uncaught exception, or exception occurs in execution.
4705 ///
4706 ///
4707 /// Available since API-level: 20
4708 #[cfg(feature = "api-20")]
4709 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
4710 pub fn napi_destroy_ark_context(env: napi_env) -> napi_status;
4711 /// To open a critical scope.
4712 /// # Arguments
4713 ///
4714 /// * `env` - Current running virtual machine context.
4715 ///
4716 /// * `scope` - A critical scope of type of napi_critical_scope is generated.
4717 ///
4718 ///
4719 /// # Returns
4720 ///
4721 /// * Returns the function execution status.
4722 /// [`napi_ok`] If the function executed successfully.
4723 ///
4724 /// [`napi_invalid_arg`] If the param scope is nullptr.
4725 ///
4726 ///
4727 /// Available since API-level: 21
4728 #[cfg(feature = "api-21")]
4729 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4730 pub fn napi_open_critical_scope(env: napi_env, scope: *mut napi_critical_scope) -> napi_status;
4731 /// To close a critical scope.
4732 /// # Arguments
4733 ///
4734 /// * `env` - Current running virtual machine context.
4735 ///
4736 /// * `scope` - A critical scope to be closed.
4737 ///
4738 ///
4739 /// # Returns
4740 ///
4741 /// * Returns the function execution status.
4742 /// [`napi_ok`] If the function executed successfully.
4743 ///
4744 /// [`napi_invalid_arg`] If the param scope is nullptr.
4745 ///
4746 ///
4747 /// Available since API-level: 21
4748 #[cfg(feature = "api-21")]
4749 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4750 pub fn napi_close_critical_scope(env: napi_env, scope: napi_critical_scope) -> napi_status;
4751 /// To obtain a ArkTS string buffer cache within the critical scope.
4752 /// # Arguments
4753 ///
4754 /// * `env` - Current running virtual machine context.
4755 ///
4756 /// * `value` - An ArkTS string object which need be encoded with UTF16 format.
4757 ///
4758 /// * `buffer` - String buffer cache of the ArkTS string object value.
4759 ///
4760 /// * `length` - Length size of the string buffer cache which needs to be obtained.
4761 ///
4762 ///
4763 /// # Returns
4764 ///
4765 /// * Returns the function execution status.
4766 /// [`napi_ok`] If the function executed successfully.
4767 ///
4768 /// [`napi_invalid_arg`] If the param env, value, buffer and length is nullptr.
4769 ///
4770 ///
4771 /// Available since API-level: 21
4772 #[cfg(feature = "api-21")]
4773 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4774 pub fn napi_get_buffer_string_utf16_in_critical_scope(
4775 env: napi_env,
4776 value: napi_value,
4777 buffer: *mut *const char16_t,
4778 length: *mut usize,
4779 ) -> napi_status;
4780 /// Creates a strong reference for an ArkTS object to extend its lifespan. The caller needs to manage the
4781 /// reference lifespan.
4782 /// # Arguments
4783 ///
4784 /// * `env` - Current running virtual machine context.
4785 ///
4786 /// * `value` - The napi_value that is being referenced.
4787 ///
4788 /// * `result` - napi_strong_ref pointing to the new strong reference.
4789 ///
4790 ///
4791 /// # Returns
4792 ///
4793 /// * Returns the function execution status.
4794 /// [`napi_ok`] If the function executed successfully.
4795 ///
4796 /// [`napi_invalid_arg`] If env, value or result is nullptr.
4797 ///
4798 ///
4799 /// Available since API-level: 21
4800 #[cfg(feature = "api-21")]
4801 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4802 pub fn napi_create_strong_reference(
4803 env: napi_env,
4804 value: napi_value,
4805 result: *mut napi_strong_ref,
4806 ) -> napi_status;
4807 /// Deletes the strong reference passed in.
4808 /// # Arguments
4809 ///
4810 /// * `env` - Current running virtual machine context.
4811 ///
4812 /// * `ref` - The napi_strong_ref to be deleted.
4813 ///
4814 ///
4815 /// # Returns
4816 ///
4817 /// * Returns the function execution status.
4818 /// [`napi_ok`] If the function executed successfully.
4819 ///
4820 /// [`napi_invalid_arg`] If env or ref is nullptr.
4821 ///
4822 ///
4823 /// Available since API-level: 21
4824 #[cfg(feature = "api-21")]
4825 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4826 pub fn napi_delete_strong_reference(env: napi_env, ref_: napi_strong_ref) -> napi_status;
4827 /// Obtains the ArkTS Object associated with the strong reference.
4828 /// # Arguments
4829 ///
4830 /// * `env` - Current running virtual machine context.
4831 ///
4832 /// * `ref` - The napi_strong_ref of the value being requested.
4833 ///
4834 /// * `result` - The napi_value referenced by the napi_strong_ref.
4835 ///
4836 ///
4837 /// # Returns
4838 ///
4839 /// * Returns the function execution status.
4840 /// [`napi_ok`] If the function executed successfully.
4841 ///
4842 /// [`napi_invalid_arg`] If env, ref or result is nullptr.
4843 ///
4844 ///
4845 /// Available since API-level: 21
4846 #[cfg(feature = "api-21")]
4847 #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
4848 pub fn napi_get_strong_reference_value(
4849 env: napi_env,
4850 ref_: napi_strong_ref,
4851 result: *mut napi_value,
4852 ) -> napi_status;
4853}