1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4#![allow(dead_code)]
5
6use std::os::raw::{c_char, c_int, c_uint, c_void};
7
8#[repr(C)]
9#[derive(Copy, Clone)]
10pub struct napi_env__ {
11 _unused: [u8; 0],
12}
13
14/// Env ptr
15pub type napi_env = *mut napi_env__;
16#[repr(C)]
17#[derive(Copy, Clone)]
18pub struct napi_value__ {
19 _unused: [u8; 0],
20}
21
22/// JsValue ptr
23pub type napi_value = *mut napi_value__;
24#[repr(C)]
25#[derive(Copy, Clone)]
26pub struct napi_ref__ {
27 _unused: [u8; 0],
28}
29pub type napi_ref = *mut napi_ref__;
30#[repr(C)]
31#[derive(Copy, Clone)]
32pub struct napi_handle_scope__ {
33 _unused: [u8; 0],
34}
35pub type napi_handle_scope = *mut napi_handle_scope__;
36#[repr(C)]
37#[derive(Copy, Clone)]
38pub struct napi_escapable_handle_scope__ {
39 _unused: [u8; 0],
40}
41pub type napi_escapable_handle_scope = *mut napi_escapable_handle_scope__;
42#[repr(C)]
43#[derive(Copy, Clone)]
44pub struct napi_callback_info__ {
45 _unused: [u8; 0],
46}
47pub type napi_callback_info = *mut napi_callback_info__;
48#[repr(C)]
49#[derive(Copy, Clone)]
50pub struct napi_deferred__ {
51 _unused: [u8; 0],
52}
53#[repr(C)]
54#[derive(Copy, Clone)]
55pub struct uv_loop_s {
56 _unused: [u8; 0],
57}
58#[repr(C)]
59#[derive(Copy, Clone)]
60pub enum uv_run_mode {
61 UV_RUN_DEFAULT = 0,
62 UV_RUN_ONCE = 1,
63 UV_RUN_NOWAIT = 2,
64}
65pub type napi_deferred = *mut napi_deferred__;
66
67pub type napi_property_attributes = i32;
68
69pub mod PropertyAttributes {
70 use super::napi_property_attributes;
71
72 pub const default: napi_property_attributes = 0;
73 pub const writable: napi_property_attributes = 1 << 0;
74 pub const enumerable: napi_property_attributes = 1 << 1;
75 pub const configurable: napi_property_attributes = 1 << 2;
76
77 // Used with napi_define_class to distinguish static properties
78 // from instance properties. Ignored by napi_define_properties.
79 pub const static_: napi_property_attributes = 1 << 10;
80}
81
82pub type napi_valuetype = i32;
83
84pub mod ValueType {
85 pub const napi_undefined: i32 = 0;
86 pub const napi_null: i32 = 1;
87 pub const napi_boolean: i32 = 2;
88 pub const napi_number: i32 = 3;
89 pub const napi_string: i32 = 4;
90 pub const napi_symbol: i32 = 5;
91 pub const napi_object: i32 = 6;
92 pub const napi_function: i32 = 7;
93 pub const napi_external: i32 = 8;
94 #[cfg(feature = "napi6")]
95 pub const napi_bigint: i32 = 9;
96}
97
98pub type napi_typedarray_type = i32;
99
100pub mod TypedarrayType {
101 pub const int8_array: i32 = 0;
102 pub const uint8_array: i32 = 1;
103 pub const uint8_clamped_array: i32 = 2;
104 pub const int16_array: i32 = 3;
105 pub const uint16_array: i32 = 4;
106 pub const int32_array: i32 = 5;
107 pub const uint32_array: i32 = 6;
108 pub const float32_array: i32 = 7;
109 pub const float64_array: i32 = 8;
110 #[cfg(feature = "napi6")]
111 pub const bigint64_array: i32 = 9;
112 #[cfg(feature = "napi6")]
113 pub const biguint64_array: i32 = 10;
114}
115
116pub type napi_status = i32;
117
118pub mod Status {
119 pub const napi_ok: i32 = 0;
120 pub const napi_invalid_arg: i32 = 1;
121 pub const napi_object_expected: i32 = 2;
122 pub const napi_string_expected: i32 = 3;
123 pub const napi_name_expected: i32 = 4;
124 pub const napi_function_expected: i32 = 5;
125 pub const napi_number_expected: i32 = 6;
126 pub const napi_boolean_expected: i32 = 7;
127 pub const napi_array_expected: i32 = 8;
128 pub const napi_generic_failure: i32 = 9;
129 pub const napi_pending_exception: i32 = 10;
130 pub const napi_cancelled: i32 = 11;
131 pub const napi_escape_called_twice: i32 = 12;
132 pub const napi_handle_scope_mismatch: i32 = 13;
133 pub const napi_callback_scope_mismatch: i32 = 14;
134 pub const napi_queue_full: i32 = 15;
135 pub const napi_closing: i32 = 16;
136 pub const napi_bigint_expected: i32 = 17;
137 pub const napi_date_expected: i32 = 18;
138 pub const napi_arraybuffer_expected: i32 = 19;
139 pub const napi_detachable_arraybuffer_expected: i32 = 20;
140 pub const napi_would_deadlock: i32 = 21; // unused
141 pub const napi_no_external_buffers_allowed: i32 = 22;
142}
143
144pub type napi_callback =
145 Option<unsafe extern "C" fn(env: napi_env, info: napi_callback_info) -> napi_value>;
146pub type napi_finalize = Option<
147 unsafe extern "C" fn(env: napi_env, finalize_data: *mut c_void, finalize_hint: *mut c_void),
148>;
149#[repr(C)]
150#[derive(Copy, Clone, Debug)]
151pub struct napi_property_descriptor {
152 pub utf8name: *const c_char,
153 pub name: napi_value,
154 pub method: napi_callback,
155 pub getter: napi_callback,
156 pub setter: napi_callback,
157 pub value: napi_value,
158 pub attributes: napi_property_attributes,
159 pub data: *mut c_void,
160}
161
162#[repr(C)]
163#[derive(Copy, Clone)]
164pub struct napi_extended_error_info {
165 pub error_message: *const c_char,
166 pub engine_reserved: *mut c_void,
167 pub engine_error_code: u32,
168 pub error_code: napi_status,
169}
170
171#[cfg(feature = "napi6")]
172pub type napi_key_collection_mode = i32;
173
174#[cfg(feature = "napi6")]
175pub mod KeyCollectionMode {
176 pub use super::napi_key_collection_mode;
177 pub const include_prototypes: napi_key_collection_mode = 0;
178 pub const own_only: napi_key_collection_mode = 1;
179}
180
181#[cfg(feature = "napi6")]
182pub type napi_key_filter = i32;
183
184#[cfg(feature = "napi6")]
185pub mod KeyFilter {
186 use super::napi_key_filter;
187
188 pub const all_properties: napi_key_filter = 0;
189 pub const writable: napi_key_filter = 1;
190 pub const enumerable: napi_key_filter = 1 << 1;
191 pub const configurable: napi_key_filter = 1 << 2;
192 pub const skip_strings: napi_key_filter = 1 << 3;
193 pub const skip_symbols: napi_key_filter = 1 << 4;
194}
195
196#[cfg(feature = "napi6")]
197pub type napi_key_conversion = i32;
198
199#[cfg(feature = "napi6")]
200pub mod KeyConversion {
201 use super::napi_key_conversion;
202
203 pub const keep_numbers: napi_key_conversion = 0;
204 pub const numbers_to_strings: napi_key_conversion = 1;
205}
206#[cfg(feature = "napi8")]
207#[repr(C)]
208#[derive(Debug, Copy, Clone)]
209pub struct napi_async_cleanup_hook_handle__ {
210 _unused: [u8; 0],
211}
212#[cfg(feature = "napi8")]
213pub type napi_async_cleanup_hook_handle = *mut napi_async_cleanup_hook_handle__;
214#[cfg(feature = "napi8")]
215pub type napi_async_cleanup_hook =
216 Option<unsafe extern "C" fn(handle: napi_async_cleanup_hook_handle, data: *mut c_void)>;
217
218#[repr(C)]
219#[derive(Copy, Clone)]
220pub struct napi_callback_scope__ {
221 _unused: [u8; 0],
222}
223pub type napi_callback_scope = *mut napi_callback_scope__;
224#[repr(C)]
225#[derive(Copy, Clone)]
226pub struct napi_async_context__ {
227 _unused: [u8; 0],
228}
229pub type napi_async_context = *mut napi_async_context__;
230#[repr(C)]
231#[derive(Copy, Clone)]
232pub struct napi_async_work__ {
233 _unused: [u8; 0],
234}
235pub type napi_async_work = *mut napi_async_work__;
236
237#[cfg(feature = "napi4")]
238#[repr(C)]
239#[derive(Copy, Clone)]
240pub struct napi_threadsafe_function__ {
241 _unused: [u8; 0],
242}
243
244#[cfg(feature = "napi4")]
245pub type napi_threadsafe_function = *mut napi_threadsafe_function__;
246
247#[cfg(feature = "napi4")]
248pub type napi_threadsafe_function_release_mode = i32;
249
250#[cfg(feature = "napi4")]
251pub mod ThreadsafeFunctionReleaseMode {
252 use super::napi_threadsafe_function_release_mode;
253 pub const release: napi_threadsafe_function_release_mode = 0;
254 pub const abort: napi_threadsafe_function_release_mode = 1;
255}
256
257#[cfg(feature = "napi4")]
258pub type napi_threadsafe_function_call_mode = i32;
259
260#[cfg(feature = "napi4")]
261pub mod ThreadsafeFunctionCallMode {
262 use super::napi_threadsafe_function_call_mode;
263
264 pub const nonblocking: napi_threadsafe_function_call_mode = 0;
265 pub const blocking: napi_threadsafe_function_call_mode = 1;
266}
267
268pub type napi_async_execute_callback =
269 Option<unsafe extern "C" fn(env: napi_env, data: *mut c_void)>;
270pub type napi_async_complete_callback =
271 Option<unsafe extern "C" fn(env: napi_env, status: napi_status, data: *mut c_void)>;
272
273#[cfg(feature = "napi4")]
274pub type napi_threadsafe_function_call_js = Option<
275 unsafe extern "C" fn(
276 env: napi_env,
277 js_callback: napi_value,
278 context: *mut c_void,
279 data: *mut c_void,
280 ),
281>;
282#[repr(C)]
283#[derive(Copy, Clone)]
284pub struct napi_node_version {
285 pub major: u32,
286 pub minor: u32,
287 pub patch: u32,
288 pub release: *const c_char,
289}
290
291pub type napi_addon_register_func =
292 Option<unsafe extern "C" fn(env: napi_env, exports: napi_value) -> napi_value>;
293#[repr(C)]
294#[derive(Copy, Clone)]
295pub struct napi_module {
296 pub nm_version: c_int,
297 pub nm_flags: c_uint,
298 pub nm_filename: *const c_char,
299 pub nm_register_func: napi_addon_register_func,
300 pub nm_modname: *const c_char,
301 pub nm_priv: *mut c_void,
302 pub reserved: [*mut c_void; 4usize],
303}
304