• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #ifndef FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H
17 #define FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H
18 
19 #ifndef NAPI_VERSION
20 #define NAPI_VERSION 8
21 #endif
22 
23 #ifndef NAPI_EXPERIMENTAL
24 #define NAPI_EXPERIMENTAL
25 #endif
26 
27 #include "common.h"
28 #include "node_api.h"
29 
30 #ifdef NAPI_TEST
31 #ifdef _WIN32
32 #define NAPI_INNER_EXTERN __declspec(dllexport)
33 #else
34 #define NAPI_INNER_EXTERN __attribute__((visibility("default")))
35 #endif
36 #else
37 #ifdef _WIN32
38 #define NAPI_INNER_EXTERN __declspec(deprecated)
39 #else
40 #define NAPI_INNER_EXTERN __attribute__((__deprecated__))
41 #endif
42 #endif
43 
44 NAPI_INNER_EXTERN napi_status napi_set_instance_data(napi_env env,
45                                                      void* data,
46                                                      napi_finalize finalize_cb,
47                                                      void* finalize_hint);
48 
49 NAPI_INNER_EXTERN napi_status napi_get_instance_data(napi_env env,
50                                                      void** data);
51 
52 NAPI_INNER_EXTERN napi_status napi_fatal_exception(napi_env env, napi_value err);
53 
54 NAPI_INNER_EXTERN napi_status napi_add_env_cleanup_hook(napi_env env,
55                                                         void (*fun)(void* arg),
56                                                         void* arg);
57 
58 NAPI_INNER_EXTERN napi_status napi_remove_env_cleanup_hook(napi_env env,
59                                                            void (*fun)(void* arg),
60                                                            void* arg);
61 
62 NAPI_INNER_EXTERN napi_status napi_add_async_cleanup_hook(
63     napi_env env,
64     napi_async_cleanup_hook hook,
65     void* arg,
66     napi_async_cleanup_hook_handle* remove_handle);
67 
68 NAPI_INNER_EXTERN napi_status napi_remove_async_cleanup_hook(
69     napi_async_cleanup_hook_handle remove_handle);
70 
71 NAPI_EXTERN napi_status napi_create_string_utf16(napi_env env,
72                                                  const char16_t* str,
73                                                  size_t length,
74                                                  napi_value* result);
75 
76 NAPI_EXTERN napi_status napi_get_value_string_utf16(napi_env env,
77                                                     napi_value value,
78                                                     char16_t* buf,
79                                                     size_t bufsize,
80                                                     size_t* result);
81 
82 NAPI_EXTERN napi_status napi_type_tag_object(napi_env env,
83                                              napi_value value,
84                                              const napi_type_tag* type_tag);
85 
86 NAPI_EXTERN napi_status napi_check_object_type_tag(napi_env env,
87                                                    napi_value value,
88                                                    const napi_type_tag* type_tag,
89                                                    bool* result);
90 
91 NAPI_INNER_EXTERN napi_status napi_add_finalizer(napi_env env,
92                                                  napi_value js_object,
93                                                  void* native_object,
94                                                  napi_finalize finalize_cb,
95                                                  void* finalize_hint,
96                                                  napi_ref* result);
97 
98 NAPI_INNER_EXTERN napi_status napi_async_init(napi_env env,
99                                               napi_value async_resource,
100                                               napi_value async_resource_name,
101                                               napi_async_context* result);
102 
103 NAPI_INNER_EXTERN napi_status napi_async_destroy(napi_env env,
104                                                  napi_async_context async_context);
105 
106 NAPI_INNER_EXTERN napi_status napi_open_callback_scope(napi_env env,
107                                                        napi_value resource_object,
108                                                        napi_async_context context,
109                                                        napi_callback_scope* result);
110 
111 NAPI_INNER_EXTERN napi_status napi_close_callback_scope(napi_env env,
112                                                         napi_callback_scope scope);
113 
114 NAPI_INNER_EXTERN napi_status napi_adjust_external_memory(napi_env env,
115                                                           int64_t change_in_bytes,
116                                                           int64_t* adjusted_value);
117 
118 NAPI_INNER_EXTERN napi_status node_api_get_module_file_name(napi_env env, const char** result);
119 
120 #ifdef __cplusplus
121 extern "C" {
122 #endif
123 
124 NAPI_EXTERN napi_status napi_run_script_path(napi_env env, const char* path, napi_value* result);
125 NAPI_EXTERN napi_status napi_queue_async_work_with_qos(napi_env env, napi_async_work work, napi_qos_t qos);
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 #endif /* FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H */
131