• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup ArkTS_Napi_NativeModule
18  * @{
19  *
20  *
21  * @brief Provides native api of ArkTS native module.
22  *
23  * @since 10
24  */
25 
26 /**
27  * @file native_api.h
28  *
29  * @brief Defines native api of ArkTS native module.
30  *
31  * @kit ArkTS
32  * @library libace_napi.z.so
33  * @syscap SystemCapability.ArkUI.ArkUI.Napi
34  * @since 10
35  * @version 1.0
36  */
37 
38 #ifndef FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H
39 #define FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H
40 
41 #ifndef NAPI_VERSION
42 #define NAPI_VERSION 8
43 #endif // NAPI_VERSION
44 
45 #ifndef NAPI_EXPERIMENTAL
46 #define NAPI_EXPERIMENTAL
47 #endif // NAPI_EXPERIMENTAL
48 
49 #include "common.h"
50 #include "node_api.h"
51 
52 #ifdef NAPI_TEST
53 #ifdef _WIN32 // WIN32
54 #define NAPI_INNER_EXTERN __declspec(dllexport)
55 #else // NON-WIN32
56 #define NAPI_INNER_EXTERN __attribute__((visibility("default")))
57 #endif // _WIN32
58 
59 #else // NAPI_TEST
60 #ifdef _WIN32
61 #define NAPI_INNER_EXTERN __declspec(deprecated)
62 #else
63 #define NAPI_INNER_EXTERN __attribute__((__deprecated__))
64 #endif // __WIN32
65 #endif
66 
67 NAPI_EXTERN napi_status napi_create_string_utf16(napi_env env,
68                                                  const char16_t* str,
69                                                  size_t length,
70                                                  napi_value* result);
71 
72 NAPI_EXTERN napi_status napi_get_value_string_utf16(napi_env env,
73                                                     napi_value value,
74                                                     char16_t* buf,
75                                                     size_t bufsize,
76                                                     size_t* result);
77 
78 NAPI_EXTERN napi_status napi_type_tag_object(napi_env env,
79                                              napi_value value,
80                                              const napi_type_tag* type_tag);
81 
82 NAPI_EXTERN napi_status napi_check_object_type_tag(napi_env env,
83                                                    napi_value value,
84                                                    const napi_type_tag* type_tag,
85                                                    bool* result);
86 
87 NAPI_INNER_EXTERN napi_status napi_adjust_external_memory(napi_env env,
88                                                           int64_t change_in_bytes,
89                                                           int64_t* adjusted_value);
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 
95 /**
96  * @brief Native detach callback of napi_coerce_to_native_binding_object that can be used to
97  *        detach the js object and the native object.
98  *
99  * @since 11
100  */
101 typedef void* (*napi_native_binding_detach_callback)(napi_env env, void* native_object, void* hint);
102 
103 /**
104  * @brief Native attach callback of napi_coerce_to_native_binding_object that can be used to
105  *        bind the js object and the native object.
106  *
107  * @since 11
108  */
109 typedef napi_value (*napi_native_binding_attach_callback)(napi_env env, void* native_object, void* hint);
110 
111 NAPI_EXTERN napi_status napi_run_script_path(napi_env env, const char* path, napi_value* result);
112 NAPI_EXTERN napi_status napi_queue_async_work_with_qos(napi_env env, napi_async_work work, napi_qos_t qos);
113 
114 /**
115  * @brief Loads an .abc file as a module. This API returns the namespace of the module.
116  * @param env Current running virtual machine context.
117  * @param path Path of the .abc file or name of the module to load.
118  * @param result Result of the module object.
119  *
120  * @return Returns the function execution status.
121  * @since 11
122  */
123 NAPI_EXTERN napi_status napi_load_module(napi_env env,
124                                          const char* path,
125                                          napi_value* result);
126 
127 /**
128  * @brief Associates data with the currently running environment.
129  *
130  * @param env Current running virtual machine context.
131  * @param data Data item to bind with the 'env'.
132  * @param finalize_cb Optional native callback that will be triggered when 'env' is destroyed or this interface
133  *                    repeatedly calls.
134  * @param finalize_hint Optional contextual hint that is passed to the finalize callback.
135  *
136  * @return Returns the function execution status.
137  * @since 11
138  */
139 NAPI_EXTERN napi_status napi_set_instance_data(napi_env env,
140                                                void* data,
141                                                napi_finalize finalize_cb,
142                                                void* finalize_hint);
143 
144 /**
145  * @brief Retrieves the data that was previously associated with the currently running environment.
146  *
147  * @param env Current running virtual machine context.
148  * @param data Data item is bound with the 'env'.
149  *
150  * @return Returns the function execution status.
151  * @since 11
152  */
153 NAPI_EXTERN napi_status napi_get_instance_data(napi_env env,
154                                                void** data);
155 
156 /**
157  * @brief Registers a clean-up hook for releasing resources when the environment exits.
158  *
159  * @param env Current running virtual machine context.
160  * @param fun Function pointer which will be triggered when environment is destroy.
161  * @param arg The argument is passed to the function pointer 'fun'.
162  *
163  * @return Returns the function execution status.
164  * @since 11
165  */
166 NAPI_EXTERN napi_status napi_add_env_cleanup_hook(napi_env env,
167                                                   void (*fun)(void* arg),
168                                                   void* arg);
169 
170 /**
171  * @brief Unregisters the clean-up hook.
172  *
173  * @param env Current running virtual machine context.
174  * @param fun Function pointer which will be triggered when environment is destroy.
175  * @param arg The argument is passed to the function pointer 'fun'.
176  *
177  * @return Returns the function execution status.
178  * @since 11
179  */
180 NAPI_EXTERN napi_status napi_remove_env_cleanup_hook(napi_env env,
181                                                      void (*fun)(void* arg),
182                                                      void* arg);
183 
184 /**
185  * @brief Registers an asynchronous clean-up hook for releasing resources when the environment exits.
186  *
187  * @param env Current running virtual machine context.
188  * @param hook The function pointer to call at environment teardown.
189  * @param arg The pointer to pass to `hook` when it gets called.
190  * @param remove_handle Optional handle that refers to the asynchronous cleanup.
191  *
192  * @return Returns the function execution status.
193  * @since 11
194  */
195 NAPI_EXTERN napi_status napi_add_async_cleanup_hook(napi_env env,
196                                                     napi_async_cleanup_hook hook,
197                                                     void* arg,
198                                                     napi_async_cleanup_hook_handle* remove_handle);
199 
200 /**
201  * @brief Unregisters the asynchronous clean-up hook.
202  *
203  * @param remove_handle Optional handle that refers to the asynchronous cleanup.
204  *
205  * @return Returns the function execution status.
206  * @since 11
207  */
208 NAPI_EXTERN napi_status napi_remove_async_cleanup_hook(napi_async_cleanup_hook_handle remove_handle);
209 
210 /**
211  * @brief Creates an asynchronous context. The capabilities related to 'async_hook' are not supported currently.
212  *
213  * @param env Current running virtual machine context.
214  * @param async_resource Object associated with the async work that will be passed to possible 'async_hook'.
215  * @param async_resource_name Identifier for the kind of resource that is being provided for diagnostic information
216  *                            exposed by the async_hooks API.
217  * @param result The initialized async context.
218  *
219  * @return Returns the function execution status.
220  * @since 11
221  */
222 NAPI_EXTERN napi_status napi_async_init(napi_env env,
223                                         napi_value async_resource,
224                                         napi_value async_resource_name,
225                                         napi_async_context* result);
226 
227 /**
228  * @brief Destroys the previously created asynchronous context. The capabilities related to 'async_hook' are not
229  *        supported currently.
230  *
231  * @param env Current running virtual machine context.
232  * @param async_context The async context to be destroyed.
233  *
234  * @return Returns the function execution status.
235  * @since 11
236  */
237 NAPI_EXTERN napi_status napi_async_destroy(napi_env env,
238                                            napi_async_context async_context);
239 
240 /**
241  * @brief Opens a callback scope. The capabilities related to 'async_hook' are not supported currently.
242  * @param env Current running virtual machine context.
243  * @param resource_object The resource object to be passed to possible 'async_hook'.
244  * @param context The context environment for the async operation.
245  * @param result The generated callback scope.
246  *
247  * @return Returns the function execution status.
248  * @since 11
249  */
250 NAPI_EXTERN napi_status napi_open_callback_scope(napi_env env,
251                                                  napi_value resource_object,
252                                                  napi_async_context context,
253                                                  napi_callback_scope* result);
254 
255 /**
256  * @brief Closes the callback scope. The capabilities related to 'async_hook' are not supported currently.
257  *
258  * @param env Current running virtual machine context.
259  * @param scope The callback scope to be closed.
260  *
261  * @return Returns the function execution status.
262  * @since 11
263  */
264 NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env,
265                                                   napi_callback_scope scope);
266 
267 /**
268  * @brief Obtains the absolute path of the location, from which the addon is loaded.
269  *
270  * @param env Current running virtual machine context.
271  * @param result The absolute path of the location of the loaded addon.
272  *
273  * @return Returns the function execution status.
274  * @since 11
275  */
276 NAPI_EXTERN napi_status node_api_get_module_file_name(napi_env env,
277                                                       const char** result);
278 
279 /**
280  * @brief Create JSObject with initial properties given by descriptors, note that property key must be String, and
281  *        must can not convert to element_index, also all keys must not duplicate.
282  *
283  * @param env Current running virtual machine context.
284  * @param result The created ArkTS object.
285  * @param property_count Number of the property descriptors.
286  * @param properties Array of property descriptors which are expected to be applied to the ArkTS object.
287  *
288  * @return Returns the function execution status.
289  * @since 11
290  */
291 NAPI_EXTERN napi_status napi_create_object_with_properties(napi_env env,
292                                                            napi_value* result,
293                                                            size_t property_count,
294                                                            const napi_property_descriptor* properties);
295 
296 /**
297  * @brief Create JSObject with initial properties given by keys and values, note that property key must be String, and
298  *        must can not convert to element_index, also all keys must not duplicate.
299  *
300  * @param env Current running virtual machine context.
301  * @param result The absolute path of the location of the loaded addon.
302  * @param property_count Number of the propertied which needs to be applied on the ArkTS object.
303  * @param keys Array of the keys of the properties.
304  * @param values Array of the values of the properties.
305  *
306  * @return Returns the function execution status.
307  * @since 11
308  */
309 NAPI_EXTERN napi_status napi_create_object_with_named_properties(napi_env env,
310                                                                  napi_value* result,
311                                                                  size_t property_count,
312                                                                  const char** keys,
313                                                                  const napi_value* values);
314 
315 /**
316  * @brief This API sets native properties to a object and converts this js object to native binding object.
317  *
318  * @param env Current running virtual machine context.
319  * @param js_object The JavaScript value to coerce.
320  * @param detach_cb Native callback that can be used to detach the js object and the native object.
321  * @param attach_cb Native callback that can be used to bind the js object and the native object.
322  * @param native_object User-provided native instance to pass to thr detach callback and attach callback.
323  * @param hint Optional hint to pass to the detach callback and attach callback.
324  *
325  * @return Return the function execution status.
326  * @since 11
327  */
328 NAPI_EXTERN napi_status napi_coerce_to_native_binding_object(napi_env env,
329                                                              napi_value js_object,
330                                                              napi_native_binding_detach_callback detach_cb,
331                                                              napi_native_binding_attach_callback attach_cb,
332                                                              void* native_object,
333                                                              void* hint);
334 
335 /**
336  * @brief Adds a 'napi_finalize' callback, which will be called when the ArkTS object is garbage-collected.
337  *
338  * @param env Current running virtual machine context.
339  * @param js_object The ArkTS object value.
340  * @param native_object Native object to bind with the ArkTS object.
341  * @param finalize_cb Native callback that can be used to free the native object when the ArkTS object is
342  garbage-collected.
343  * @param finalize_hint Optional contextual hint that is passed to the finalize callback.
344  * @param result Optional reference of the ArkTS object.
345  *
346  * @return Return the function execution status.
347  * @since 11
348  */
349 NAPI_EXTERN napi_status napi_add_finalizer(napi_env env,
350                                            napi_value js_object,
351                                            void* native_object,
352                                            napi_finalize finalize_cb,
353                                            void* finalize_hint,
354                                            napi_ref* result);
355 
356 /**
357  * @brief The module is loaded through the NAPI. By default, the default object is exported from the module.
358  *
359  * @param env Current running virtual machine context.
360  * @param path Path name of the module to be loaded, like @ohos.hilog.
361  * @param module_info Path names of bundle and module, like com.example.application/entry.
362  * @param result Result of loading a module, which is an exported object of the module.
363  *
364  * @return Returns the function execution status.
365  * @since 12
366  */
367 NAPI_EXTERN napi_status napi_load_module_with_info(napi_env env,
368                                                    const char* path,
369                                                    const char* module_info,
370                                                    napi_value* result);
371 
372 /**
373  * @brief Create the ark runtime.
374  *
375  * @param env Indicates the ark runtime environment.
376  *
377  * @return Return the function execution status.
378  * @since 12
379  */
380 NAPI_EXTERN napi_status napi_create_ark_runtime(napi_env* env);
381 
382 /**
383  * @brief Destroy the ark runtime.
384  *
385  * @param env Indicates the ark runtime environment.
386  *
387  * @return Return the function execution status.
388  * @since 12
389  */
390 NAPI_EXTERN napi_status napi_destroy_ark_runtime(napi_env* env);
391 
392 /**
393  * @brief Defines a sendable class.
394  *
395  * @param env The environment that the API is invoked under.
396  * @param utf8name Name of the ArkTS constructor function.
397  * @param length The length of the utf8name in bytes, or NAPI_AUTO_LENGTH if it is null-terminated.
398  * @param constructor Callback function that handles constructing instances of the class.
399  * @param data Optional data to be passed to the constructor callback as the data property of the callback info.
400  * @param property_count Number of items in the properties array argument.
401  * @param properties Array of property descriptors describing static and instance data properties, accessors, and
402  *                    methods on the class. See napi_property_descriptor.
403  * @param parent A napi_value representing the Superclass.
404  * @param result A napi_value representing the constructor function for the class.
405  *
406  * @return Return the function execution status.
407  * @since 12
408  */
409 NAPI_EXTERN napi_status napi_define_sendable_class(napi_env env,
410                                                    const char* utf8name,
411                                                    size_t length,
412                                                    napi_callback constructor,
413                                                    void* data,
414                                                    size_t property_count,
415                                                    const napi_property_descriptor* properties,
416                                                    napi_value parent,
417                                                    napi_value* result);
418 
419 /**
420  * @brief Queries a napi_value to check if it is sendable.
421  *
422  * @param env The environment that the API is invoked under.
423  * @param value The napi_value to be checked.
424  * @param result Boolean value that is set to true if napi_value is sendable, false otherwise.
425  *
426  * @return Return the function execution status.
427  * @since 12
428  */
429 NAPI_EXTERN napi_status napi_is_sendable(napi_env env,
430                                          napi_value value,
431                                          bool* result);
432 
433 /**
434  * @brief Defines a sendable object.
435  *
436  * @param env The environment that the API is invoked under.
437  * @param property_count The count of object properties.
438  * @param properties Object properties.
439  * @param result The created sendable object.
440  *
441  * @return Return the function execution status.
442  * @since 12
443  */
444 NAPI_EXTERN napi_status napi_create_sendable_object_with_properties(napi_env env,
445                                                                     size_t property_count,
446                                                                     const napi_property_descriptor* properties,
447                                                                     napi_value* result);
448 
449 /**
450  * @brief Wraps a native instance in a ArkTS object.
451  *
452  * @param env The environment that the API is invoked under.
453  * @param js_object The ArkTS object that will be the wrapper for the native object.
454  * @param native_object The native instance that will be wrapped in the ArkTS object.
455  * @param finalize_cb Optional native callback that can be used to free the native instance when the ArkTS object
456  * has been garbage-collected.
457  * @param finalize_hint Optional contextual hint that is passed to the finalize callback.
458  *
459  * @return Return the function execution status.
460  * @since 12
461  */
462 NAPI_EXTERN napi_status napi_wrap_sendable(napi_env env,
463                                            napi_value js_object,
464                                            void* native_object,
465                                            napi_finalize finalize_cb,
466                                            void* finalize_hint);
467 
468 /**
469  * @brief Wraps a native instance in a ArkTS object.
470  *
471  * @param env The environment that the API is invoked under.
472  * @param js_object The ArkTS object that will be the wrapper for the native object.
473  * @param native_object The native instance that will be wrapped in the ArkTS object.
474  * @param finalize_cb Optional native callback that can be used to free the native instance when the ArkTS object
475  *                    has been garbage-collected.
476  * @param finalize_hint Optional contextual hint that is passed to the finalize callback.
477  * @param native_binding_size The size of native binding.
478  *
479  * @return Return the function execution status.
480  * @since 12
481  */
482 NAPI_EXTERN napi_status napi_wrap_sendable_with_size(napi_env env,
483                                                      napi_value js_object,
484                                                      void* native_object,
485                                                      napi_finalize finalize_cb,
486                                                      void* finalize_hint,
487                                                      size_t native_binding_size);
488 
489 /**
490  * @brief Retrieves a native instance that was previously wrapped in a ArkTS object.
491  *
492  * @param env The environment that the API is invoked under.
493  * @param js_object The object associated with the native instance.
494  * @param result Pointer to the wrapped native instance.
495  *
496  * @return Return the function execution status.
497  * @since 12
498  */
499 NAPI_EXTERN napi_status napi_unwrap_sendable(napi_env env,
500                                              napi_value js_object,
501                                              void** result);
502 
503 /**
504  * @brief Retrieves a native instance that was previously wrapped in a ArkTS object and removes the wrapping.
505  *
506  * @param env The environment that the API is invoked under.
507  * @param js_object The object associated with the native instance.
508  * @param result Pointer to the wrapped native instance.
509  *
510  * @return Return the function execution status.
511  * @since 12
512  */
513 NAPI_EXTERN napi_status napi_remove_wrap_sendable(napi_env env,
514                                                   napi_value js_object,
515                                                   void** result);
516 
517 /**
518  * @brief Create a sendable array.
519  *
520  * @param env The environment that the API is invoked under.
521  * @param result A napi_value representing a sendable array.
522  *
523  * @return Return the function execution status.
524  * @since 12
525  */
526 NAPI_EXTERN napi_status napi_create_sendable_array(napi_env env,
527                                                    napi_value* result);
528 
529 /**
530  * @brief Create a sendable array with length.
531  *
532  * @param env The environment that the API is invoked under.
533  * @param length The initial length of the sendable array.
534  * @param result A napi_value representing a sendable array.
535  *
536  * @return Return the function execution status.
537  * @since 12
538  */
539 NAPI_EXTERN napi_status napi_create_sendable_array_with_length(napi_env env,
540                                                                size_t length,
541                                                                napi_value* result);
542 
543 /**
544  * @brief Create a sendable arraybuffer.
545  *
546  * @param env The environment that the API is invoked under.
547  * @param byte_length The length in bytes of the sendable arraybuffer to create.
548  * @param data Pointer to the underlying byte buffer of the sendable arraybuffer.
549  * @param result A napi_value representing a sendable arraybuffer.
550  *
551  * @return Return the function execution status.
552  * @since 12
553  */
554 NAPI_EXTERN napi_status napi_create_sendable_arraybuffer(napi_env env,
555                                                          size_t byte_length,
556                                                          void** data,
557                                                          napi_value* result);
558 
559 /**
560  * @brief Create a sendable typedarray.
561  *
562  * @param env The environment that the API is invoked under.
563  * @param type Scalar datatype of the elements within the sendable typedarray.
564  * @param length Number of elements in the typedarray.
565  * @param arraybuffer Sendable arraybuffer underlying the sendable typedarray.
566  * @param byte_offset The byte offset within the sendable arraybuffer from which to start projecting the
567  *                     sendable typedarray.
568  * @param result A napi_value representing a sendable typedarray.
569  *
570  * @return Return the function execution status.
571  * @since 12
572  */
573 NAPI_EXTERN napi_status napi_create_sendable_typedarray(napi_env env,
574                                                         napi_typedarray_type type,
575                                                         size_t length,
576                                                         napi_value arraybuffer,
577                                                         size_t byte_offset,
578                                                         napi_value* result);
579 
580 /**
581  * @brief Run the event loop by the given env and running mode in current thread.
582  *
583  * Support to run the native event loop in an asynchronous native thread with the specified running mode.
584  *
585  * @param env Current running virtual machine context.
586  * @param mode Indicates the running mode of the native event loop.
587  *
588  * @return Return the function execution status.
589  * @since 12
590  */
591 NAPI_EXTERN napi_status napi_run_event_loop(napi_env env,
592                                             napi_event_mode mode);
593 
594 /**
595  * @brief Stop the event loop in current thread.
596  *
597  * Support to stop the running event loop in current native thread.
598  *
599  * @param env Current running virtual machine context.
600  *
601  * @return Return the function execution status.
602  * @since 12
603  */
604 NAPI_EXTERN napi_status napi_stop_event_loop(napi_env env);
605 
606 /**
607  * @brief Serialize a JS object.
608  *
609  * @param env Current running virtual machine context.
610  * @param object The JavaScript value to serialize.
611  * @param transfer_list List of data to transfer in transfer mode.
612  * @param clone_list List of Sendable data to transfer in clone mode.
613  * @param result Serialization result of the JS object.
614  *
615  * @return Returns the function execution status.
616  * @since 12
617  */
618 NAPI_EXTERN napi_status napi_serialize(napi_env env,
619                                        napi_value object,
620                                        napi_value transfer_list,
621                                        napi_value clone_list,
622                                        void** result);
623 
624 /**
625  * @brief Restore serialization data to a ArkTS object.
626  *
627  * @param env Current running virtual machine context.
628  * @param buffer Data to deserialize.
629  * @param object ArkTS object obtained by deserialization.
630  *
631  * @return Returns the function execution status.
632  * @since 12
633  */
634 NAPI_EXTERN napi_status napi_deserialize(napi_env env,
635                                          void* buffer,
636                                          napi_value* object);
637 
638 /**
639  * @brief Delete serialization data.
640  *
641  * @param env Current running virtual machine context.
642  * @param buffer Data to delete.
643  *
644  * @return Returns the function execution status.
645  * @since 12
646  */
647 NAPI_EXTERN napi_status napi_delete_serialization_data(napi_env env,
648                                                        void* buffer);
649 
650 /**
651  * @brief Dispatch a task with specified priority from a native thread to an ArkTS thread, the task will execute
652  *        the given thread safe function.
653  *
654  * @param func Indicates the thread safe function.
655  * @param data Indicates the data anticipated to be transferred to the ArkTS thread.
656  * @param priority Indicates the priority of the task dispatched.
657  * @param isTail Indicates the way of the task dispatched into the native event queue. When "isTail" is true,
658  *        the task will be dispatched to the tail of the native event queue. Conversely, when "isTail" is false, the
659  *        tasks will be dispatched to the head of the native event queue.
660  *
661  * @return Return the function execution status.
662  * @since 12
663  */
664 NAPI_EXTERN napi_status napi_call_threadsafe_function_with_priority(napi_threadsafe_function func,
665                                                                     void *data,
666                                                                     napi_task_priority priority,
667                                                                     bool isTail);
668 
669 /**
670  * @brief Throws UncaughtException to ArkTS.
671  * @param env Current running virtual machine context.
672  * @param err Error object which is passed to 'UncaughtException'.
673  *
674  * @return Returns the function execution status.
675  * @since 12
676  */
677 NAPI_EXTERN napi_status napi_fatal_exception(napi_env env,
678                                              napi_value err);
679 
680 /**
681  * @brief Allows a JS function to be called in the asynchronous context. The capabilities related to **async_hook** are
682  *        not supported currently.
683  * @param env Current running virtual machine context.
684  * @param async_context The context environment for the async operation.
685  * @param recv The 'this' pointer of the function.
686  * @param func ArkTS function to be called.
687  * @param argc Size of the argument array which is passed to 'func'.
688  * @param argv Argument array.
689  * @param result Result returned by the ArkTS function.
690  *
691  * @return Returns the function execution status.
692  * @since 11
693  */
694 NAPI_EXTERN napi_status napi_make_callback(napi_env env,
695                                            napi_async_context async_context,
696                                            napi_value recv,
697                                            napi_value func,
698                                            size_t argc,
699                                            const napi_value* argv,
700                                            napi_value* result);
701 
702 /**
703  * @brief Creates a ArkTS buffer of the specified size.
704  * @param env Current running virtual machine context.
705  * @param length The size of the buffer to be created.
706  * @param data Raw pointer of the ArkTS buffer.
707  * @param result Result returned by the ArkTS function.
708  *
709  * @return Returns the function execution status.
710  * @since 10
711  */
712 NAPI_EXTERN napi_status napi_create_buffer(napi_env env,
713                                            size_t length,
714                                            void** data,
715                                            napi_value* result);
716 
717 #ifdef __cplusplus
718 }
719 #endif
720 
721 #endif /* FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H */
722 /** @} */