emnapi 0.36.3 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +1 -3
- package/README.md +51 -31
- package/dist/library_napi.js +72 -29
- package/include/emnapi_common.h +2 -4
- package/include/js_native_api.h +402 -383
- package/include/js_native_api_types.h +14 -6
- package/include/node_api.h +145 -104
- package/include/node_api_types.h +8 -12
- package/lib/wasm32-emscripten/libemnapi-basic.a +0 -0
- package/lib/wasm32-emscripten/libemnapi-mt.a +0 -0
- package/lib/wasm32-emscripten/libemnapi.a +0 -0
- package/lib/wasm32-emscripten.txt +2 -2
- package/package.json +9 -1
- package/include/napi-inl.deprecated.h +0 -186
- package/include/napi-inl.h +0 -6299
- package/include/napi.h +0 -3127
|
@@ -8,7 +8,15 @@
|
|
|
8
8
|
#include <stdint.h> // NOLINT(modernize-deprecated-headers)
|
|
9
9
|
|
|
10
10
|
#if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900)
|
|
11
|
-
|
|
11
|
+
typedef uint16_t char16_t;
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
#ifndef NAPI_CDECL
|
|
15
|
+
#ifdef _WIN32
|
|
16
|
+
#define NAPI_CDECL __cdecl
|
|
17
|
+
#else
|
|
18
|
+
#define NAPI_CDECL
|
|
19
|
+
#endif
|
|
12
20
|
#endif
|
|
13
21
|
|
|
14
22
|
// JSVM API types are all opaque pointers for ABI stability
|
|
@@ -101,11 +109,11 @@ typedef enum {
|
|
|
101
109
|
// * the definition of `napi_status` in doc/api/n-api.md to reflect the newly
|
|
102
110
|
// added value(s).
|
|
103
111
|
|
|
104
|
-
typedef napi_value
|
|
105
|
-
|
|
106
|
-
typedef void
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
typedef napi_value(NAPI_CDECL* napi_callback)(napi_env env,
|
|
113
|
+
napi_callback_info info);
|
|
114
|
+
typedef void(NAPI_CDECL* napi_finalize)(napi_env env,
|
|
115
|
+
void* finalize_data,
|
|
116
|
+
void* finalize_hint);
|
|
109
117
|
|
|
110
118
|
typedef struct {
|
|
111
119
|
// One of utf8name or name should be NULL.
|
package/include/node_api.h
CHANGED
|
@@ -1,90 +1,121 @@
|
|
|
1
1
|
#ifndef SRC_NODE_API_H_
|
|
2
2
|
#define SRC_NODE_API_H_
|
|
3
3
|
|
|
4
|
-
#
|
|
5
|
-
#
|
|
4
|
+
#ifdef EMNAPI_UNMODIFIED_UPSTREAM
|
|
5
|
+
#ifdef BUILDING_NODE_EXTENSION
|
|
6
|
+
#ifdef _WIN32
|
|
7
|
+
// Building native addon against node
|
|
8
|
+
#define NAPI_EXTERN __declspec(dllimport)
|
|
9
|
+
#elif defined(__wasm32__)
|
|
10
|
+
#define NAPI_EXTERN __attribute__((__import_module__("napi")))
|
|
11
|
+
#endif
|
|
12
|
+
#endif
|
|
6
13
|
#endif
|
|
7
14
|
#include "js_native_api.h"
|
|
8
15
|
#include "node_api_types.h"
|
|
9
16
|
|
|
10
|
-
struct uv_loop_s;
|
|
17
|
+
struct uv_loop_s; // Forward declaration.
|
|
11
18
|
|
|
19
|
+
#ifdef _WIN32
|
|
20
|
+
#define NAPI_MODULE_EXPORT __declspec(dllexport)
|
|
21
|
+
#else
|
|
22
|
+
#ifdef EMNAPI_UNMODIFIED_UPSTREAM
|
|
23
|
+
#define NAPI_MODULE_EXPORT __attribute__((visibility("default")))
|
|
24
|
+
#else
|
|
12
25
|
#ifdef __EMSCRIPTEN__
|
|
13
|
-
#define NAPI_MODULE_EXPORT __attribute__((used))
|
|
26
|
+
#define NAPI_MODULE_EXPORT __attribute__((visibility("default"))) __attribute__((used))
|
|
14
27
|
#else
|
|
15
28
|
#define NAPI_MODULE_EXPORT __attribute__((visibility("default")))
|
|
16
29
|
#endif
|
|
30
|
+
#endif
|
|
31
|
+
#endif
|
|
17
32
|
|
|
18
|
-
#
|
|
33
|
+
#if defined(__GNUC__)
|
|
34
|
+
#define NAPI_NO_RETURN __attribute__((noreturn))
|
|
35
|
+
#elif defined(_WIN32)
|
|
36
|
+
#define NAPI_NO_RETURN __declspec(noreturn)
|
|
37
|
+
#else
|
|
38
|
+
#define NAPI_NO_RETURN
|
|
39
|
+
#endif
|
|
19
40
|
|
|
20
|
-
typedef napi_value
|
|
21
|
-
|
|
41
|
+
typedef napi_value(NAPI_CDECL* napi_addon_register_func)(napi_env env,
|
|
42
|
+
napi_value exports);
|
|
22
43
|
|
|
23
|
-
|
|
44
|
+
// Used by deprecated registration method napi_module_register.
|
|
45
|
+
typedef struct napi_module {
|
|
46
|
+
int nm_version;
|
|
47
|
+
unsigned int nm_flags;
|
|
48
|
+
const char* nm_filename;
|
|
49
|
+
napi_addon_register_func nm_register_func;
|
|
50
|
+
const char* nm_modname;
|
|
51
|
+
void* nm_priv;
|
|
52
|
+
void* reserved[4];
|
|
53
|
+
} napi_module;
|
|
54
|
+
|
|
55
|
+
#define NAPI_MODULE_VERSION 1
|
|
24
56
|
|
|
25
57
|
#define NAPI_MODULE_INITIALIZER_X(base, version) \
|
|
26
58
|
NAPI_MODULE_INITIALIZER_X_HELPER(base, version)
|
|
27
59
|
#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version
|
|
28
60
|
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
#define
|
|
32
|
-
|
|
33
|
-
NAPI_MODULE_EXPORT napi_value NAPI_WASM_INITIALIZER(napi_env env, \
|
|
34
|
-
napi_value exports) { \
|
|
35
|
-
return regfunc(env, exports); \
|
|
36
|
-
} \
|
|
37
|
-
EXTERN_C_END
|
|
38
|
-
|
|
61
|
+
#ifdef EMNAPI_UNMODIFIED_UPSTREAM
|
|
62
|
+
#ifdef __wasm32__
|
|
63
|
+
#define NAPI_MODULE_INITIALIZER_BASE napi_register_wasm_v
|
|
64
|
+
#else
|
|
39
65
|
#define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v
|
|
66
|
+
#endif
|
|
67
|
+
#else
|
|
68
|
+
#ifdef __wasm__
|
|
69
|
+
#define NAPI_MODULE_INITIALIZER_BASE napi_register_wasm_v
|
|
70
|
+
#else
|
|
71
|
+
#define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v
|
|
72
|
+
#endif
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
#define NAPI_MODULE_INITIALIZER \
|
|
76
|
+
NAPI_MODULE_INITIALIZER_X(NAPI_MODULE_INITIALIZER_BASE, NAPI_MODULE_VERSION)
|
|
40
77
|
|
|
41
|
-
#define
|
|
42
|
-
|
|
43
|
-
|
|
78
|
+
#define NAPI_MODULE_INIT() \
|
|
79
|
+
EXTERN_C_START \
|
|
80
|
+
NAPI_MODULE_EXPORT napi_value NAPI_MODULE_INITIALIZER(napi_env env, \
|
|
81
|
+
napi_value exports); \
|
|
82
|
+
EXTERN_C_END \
|
|
83
|
+
napi_value NAPI_MODULE_INITIALIZER(napi_env env, napi_value exports)
|
|
44
84
|
|
|
45
|
-
#define
|
|
46
|
-
|
|
47
|
-
NAPI_MODULE_EXPORT napi_value \
|
|
48
|
-
NAPI_MODULE_INITIALIZER(napi_env env, napi_value exports); \
|
|
49
|
-
EXTERN_C_END \
|
|
50
|
-
NAPI_MODULE(NODE_GYP_MODULE_NAME, NAPI_MODULE_INITIALIZER) \
|
|
51
|
-
napi_value NAPI_MODULE_INITIALIZER(napi_env env, \
|
|
52
|
-
napi_value exports)
|
|
85
|
+
#define NAPI_MODULE(modname, regfunc) \
|
|
86
|
+
NAPI_MODULE_INIT() { return regfunc(env, exports); }
|
|
53
87
|
|
|
88
|
+
// Deprecated. Use NAPI_MODULE.
|
|
89
|
+
#define NAPI_MODULE_X(modname, regfunc, priv, flags) \
|
|
90
|
+
NAPI_MODULE(modname, regfunc)
|
|
54
91
|
|
|
55
92
|
EXTERN_C_START
|
|
56
93
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
NAPI_EXTERN
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
napi_async_work work);
|
|
71
|
-
|
|
72
|
-
NAPI_EXTERN NAPI_NO_RETURN void napi_fatal_error(const char* location,
|
|
73
|
-
size_t location_len,
|
|
74
|
-
const char* message,
|
|
75
|
-
size_t message_len);
|
|
94
|
+
// Deprecated. Replaced by symbol-based registration defined by NAPI_MODULE
|
|
95
|
+
// and NAPI_MODULE_INIT macros.
|
|
96
|
+
#if defined(__cplusplus) && __cplusplus >= 201402L
|
|
97
|
+
[[deprecated]]
|
|
98
|
+
#endif
|
|
99
|
+
NAPI_EXTERN void NAPI_CDECL
|
|
100
|
+
napi_module_register(napi_module* mod);
|
|
101
|
+
|
|
102
|
+
NAPI_EXTERN NAPI_NO_RETURN void NAPI_CDECL
|
|
103
|
+
napi_fatal_error(const char* location,
|
|
104
|
+
size_t location_len,
|
|
105
|
+
const char* message,
|
|
106
|
+
size_t message_len);
|
|
76
107
|
|
|
77
108
|
// Methods for custom handling of async operations
|
|
78
|
-
NAPI_EXTERN napi_status
|
|
109
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
79
110
|
napi_async_init(napi_env env,
|
|
80
111
|
napi_value async_resource,
|
|
81
112
|
napi_value async_resource_name,
|
|
82
113
|
napi_async_context* result);
|
|
83
114
|
|
|
84
|
-
NAPI_EXTERN napi_status
|
|
115
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
85
116
|
napi_async_destroy(napi_env env, napi_async_context async_context);
|
|
86
117
|
|
|
87
|
-
NAPI_EXTERN napi_status
|
|
118
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
88
119
|
napi_make_callback(napi_env env,
|
|
89
120
|
napi_async_context async_context,
|
|
90
121
|
napi_value recv,
|
|
@@ -94,14 +125,12 @@ napi_make_callback(napi_env env,
|
|
|
94
125
|
napi_value* result);
|
|
95
126
|
|
|
96
127
|
// Methods to provide node::Buffer functionality with napi types
|
|
97
|
-
NAPI_EXTERN napi_status
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
napi_value* result);
|
|
102
|
-
|
|
128
|
+
NAPI_EXTERN napi_status NAPI_CDECL napi_create_buffer(napi_env env,
|
|
129
|
+
size_t length,
|
|
130
|
+
void** data,
|
|
131
|
+
napi_value* result);
|
|
103
132
|
#ifndef NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED
|
|
104
|
-
NAPI_EXTERN napi_status
|
|
133
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
105
134
|
napi_create_external_buffer(napi_env env,
|
|
106
135
|
size_t length,
|
|
107
136
|
void* data,
|
|
@@ -109,62 +138,75 @@ napi_create_external_buffer(napi_env env,
|
|
|
109
138
|
void* finalize_hint,
|
|
110
139
|
napi_value* result);
|
|
111
140
|
#endif // NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
NAPI_EXTERN napi_status
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
NAPI_EXTERN napi_status NAPI_CDECL napi_create_buffer_copy(napi_env env,
|
|
142
|
+
size_t length,
|
|
143
|
+
const void* data,
|
|
144
|
+
void** result_data,
|
|
145
|
+
napi_value* result);
|
|
146
|
+
NAPI_EXTERN napi_status NAPI_CDECL napi_is_buffer(napi_env env,
|
|
147
|
+
napi_value value,
|
|
148
|
+
bool* result);
|
|
149
|
+
NAPI_EXTERN napi_status NAPI_CDECL napi_get_buffer_info(napi_env env,
|
|
150
|
+
napi_value value,
|
|
151
|
+
void** data,
|
|
152
|
+
size_t* length);
|
|
153
|
+
#if !defined(EMNAPI_UNMODIFIED_UPSTREAM) || (defined(EMNAPI_UNMODIFIED_UPSTREAM) && !defined(__wasm32__))
|
|
154
|
+
// Methods to manage simple async operations
|
|
155
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
156
|
+
napi_create_async_work(napi_env env,
|
|
157
|
+
napi_value async_resource,
|
|
158
|
+
napi_value async_resource_name,
|
|
159
|
+
napi_async_execute_callback execute,
|
|
160
|
+
napi_async_complete_callback complete,
|
|
161
|
+
void* data,
|
|
162
|
+
napi_async_work* result);
|
|
163
|
+
NAPI_EXTERN napi_status NAPI_CDECL napi_delete_async_work(napi_env env,
|
|
164
|
+
napi_async_work work);
|
|
165
|
+
NAPI_EXTERN napi_status NAPI_CDECL napi_queue_async_work(napi_env env,
|
|
166
|
+
napi_async_work work);
|
|
167
|
+
NAPI_EXTERN napi_status NAPI_CDECL napi_cancel_async_work(napi_env env,
|
|
168
|
+
napi_async_work work);
|
|
169
|
+
#endif // __wasm32__
|
|
170
|
+
|
|
171
|
+
// version management
|
|
172
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
173
|
+
napi_get_node_version(napi_env env, const napi_node_version** version);
|
|
134
174
|
|
|
135
175
|
#if NAPI_VERSION >= 2
|
|
136
176
|
|
|
137
|
-
|
|
138
|
-
|
|
177
|
+
// Return the current libuv event loop for a given environment
|
|
178
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
179
|
+
napi_get_uv_event_loop(napi_env env, struct uv_loop_s** loop);
|
|
139
180
|
|
|
140
181
|
#endif // NAPI_VERSION >= 2
|
|
141
182
|
|
|
142
183
|
#if NAPI_VERSION >= 3
|
|
143
184
|
|
|
144
|
-
NAPI_EXTERN napi_status napi_fatal_exception(napi_env env,
|
|
145
|
-
|
|
185
|
+
NAPI_EXTERN napi_status NAPI_CDECL napi_fatal_exception(napi_env env,
|
|
186
|
+
napi_value err);
|
|
146
187
|
|
|
147
|
-
NAPI_EXTERN napi_status
|
|
188
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
148
189
|
napi_add_env_cleanup_hook(napi_env env, napi_cleanup_hook fun, void* arg);
|
|
149
190
|
|
|
150
|
-
NAPI_EXTERN napi_status
|
|
191
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
151
192
|
napi_remove_env_cleanup_hook(napi_env env, napi_cleanup_hook fun, void* arg);
|
|
152
193
|
|
|
153
|
-
NAPI_EXTERN napi_status
|
|
194
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
154
195
|
napi_open_callback_scope(napi_env env,
|
|
155
196
|
napi_value resource_object,
|
|
156
197
|
napi_async_context context,
|
|
157
198
|
napi_callback_scope* result);
|
|
158
199
|
|
|
159
|
-
NAPI_EXTERN napi_status
|
|
200
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
160
201
|
napi_close_callback_scope(napi_env env, napi_callback_scope scope);
|
|
161
202
|
|
|
162
203
|
#endif // NAPI_VERSION >= 3
|
|
163
204
|
|
|
164
205
|
#if NAPI_VERSION >= 4
|
|
165
206
|
|
|
207
|
+
#if !defined(EMNAPI_UNMODIFIED_UPSTREAM) || (defined(EMNAPI_UNMODIFIED_UPSTREAM) && !defined(__wasm32__))
|
|
166
208
|
// Calling into JS from other threads
|
|
167
|
-
NAPI_EXTERN napi_status
|
|
209
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
168
210
|
napi_create_threadsafe_function(napi_env env,
|
|
169
211
|
napi_value func,
|
|
170
212
|
napi_value async_resource,
|
|
@@ -177,50 +219,49 @@ napi_create_threadsafe_function(napi_env env,
|
|
|
177
219
|
napi_threadsafe_function_call_js call_js_cb,
|
|
178
220
|
napi_threadsafe_function* result);
|
|
179
221
|
|
|
180
|
-
NAPI_EXTERN napi_status
|
|
181
|
-
|
|
182
|
-
void** result);
|
|
222
|
+
NAPI_EXTERN napi_status NAPI_CDECL napi_get_threadsafe_function_context(
|
|
223
|
+
napi_threadsafe_function func, void** result);
|
|
183
224
|
|
|
184
|
-
NAPI_EXTERN napi_status
|
|
225
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
185
226
|
napi_call_threadsafe_function(napi_threadsafe_function func,
|
|
186
227
|
void* data,
|
|
187
228
|
napi_threadsafe_function_call_mode is_blocking);
|
|
188
229
|
|
|
189
|
-
NAPI_EXTERN napi_status
|
|
230
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
190
231
|
napi_acquire_threadsafe_function(napi_threadsafe_function func);
|
|
191
232
|
|
|
192
|
-
NAPI_EXTERN napi_status
|
|
193
|
-
|
|
194
|
-
napi_threadsafe_function_release_mode mode);
|
|
233
|
+
NAPI_EXTERN napi_status NAPI_CDECL napi_release_threadsafe_function(
|
|
234
|
+
napi_threadsafe_function func, napi_threadsafe_function_release_mode mode);
|
|
195
235
|
|
|
196
|
-
NAPI_EXTERN napi_status
|
|
236
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
197
237
|
napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func);
|
|
198
238
|
|
|
199
|
-
NAPI_EXTERN napi_status
|
|
239
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
200
240
|
napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);
|
|
241
|
+
#endif // __wasm32__
|
|
201
242
|
|
|
202
|
-
#endif
|
|
243
|
+
#endif // NAPI_VERSION >= 4
|
|
203
244
|
|
|
204
245
|
#if NAPI_VERSION >= 8
|
|
205
246
|
|
|
206
|
-
NAPI_EXTERN napi_status
|
|
247
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
207
248
|
napi_add_async_cleanup_hook(napi_env env,
|
|
208
249
|
napi_async_cleanup_hook hook,
|
|
209
250
|
void* arg,
|
|
210
251
|
napi_async_cleanup_hook_handle* remove_handle);
|
|
211
252
|
|
|
212
|
-
NAPI_EXTERN napi_status
|
|
253
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
213
254
|
napi_remove_async_cleanup_hook(napi_async_cleanup_hook_handle remove_handle);
|
|
214
255
|
|
|
215
256
|
#endif // NAPI_VERSION >= 8
|
|
216
257
|
|
|
217
258
|
#ifdef NAPI_EXPERIMENTAL
|
|
218
259
|
|
|
219
|
-
NAPI_EXTERN napi_status
|
|
260
|
+
NAPI_EXTERN napi_status NAPI_CDECL
|
|
220
261
|
node_api_get_module_file_name(napi_env env, const char** result);
|
|
221
262
|
|
|
222
263
|
#endif // NAPI_EXPERIMENTAL
|
|
223
264
|
|
|
224
265
|
EXTERN_C_END
|
|
225
266
|
|
|
226
|
-
#endif
|
|
267
|
+
#endif // SRC_NODE_API_H_
|
package/include/node_api_types.h
CHANGED
|
@@ -8,7 +8,7 @@ typedef struct napi_async_context__* napi_async_context;
|
|
|
8
8
|
typedef struct napi_async_work__* napi_async_work;
|
|
9
9
|
|
|
10
10
|
#if NAPI_VERSION >= 3
|
|
11
|
-
typedef void(*napi_cleanup_hook)(void* arg);
|
|
11
|
+
typedef void(NAPI_CDECL* napi_cleanup_hook)(void* arg);
|
|
12
12
|
#endif // NAPI_VERSION >= 3
|
|
13
13
|
|
|
14
14
|
#if NAPI_VERSION >= 4
|
|
@@ -27,17 +27,13 @@ typedef enum {
|
|
|
27
27
|
} napi_threadsafe_function_call_mode;
|
|
28
28
|
#endif // NAPI_VERSION >= 4
|
|
29
29
|
|
|
30
|
-
typedef void
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
void* data);
|
|
35
|
-
|
|
30
|
+
typedef void(NAPI_CDECL* napi_async_execute_callback)(napi_env env, void* data);
|
|
31
|
+
typedef void(NAPI_CDECL* napi_async_complete_callback)(napi_env env,
|
|
32
|
+
napi_status status,
|
|
33
|
+
void* data);
|
|
36
34
|
#if NAPI_VERSION >= 4
|
|
37
|
-
typedef void
|
|
38
|
-
|
|
39
|
-
void* context,
|
|
40
|
-
void* data);
|
|
35
|
+
typedef void(NAPI_CDECL* napi_threadsafe_function_call_js)(
|
|
36
|
+
napi_env env, napi_value js_callback, void* context, void* data);
|
|
41
37
|
#endif // NAPI_VERSION >= 4
|
|
42
38
|
|
|
43
39
|
typedef struct {
|
|
@@ -49,7 +45,7 @@ typedef struct {
|
|
|
49
45
|
|
|
50
46
|
#if NAPI_VERSION >= 8
|
|
51
47
|
typedef struct napi_async_cleanup_hook_handle__* napi_async_cleanup_hook_handle;
|
|
52
|
-
typedef void(*napi_async_cleanup_hook)(
|
|
48
|
+
typedef void(NAPI_CDECL* napi_async_cleanup_hook)(
|
|
53
49
|
napi_async_cleanup_hook_handle handle, void* data);
|
|
54
50
|
#endif // NAPI_VERSION >= 8
|
|
55
51
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.
|
|
2
|
-
clang version 17.0.0 (https://github.com/llvm/llvm-project
|
|
1
|
+
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.36 (518d9fea335f7cd2b5771e43df76e0535c6df5dd)
|
|
2
|
+
clang version 17.0.0 (https://github.com/llvm/llvm-project 5084abbea933b1a510556726a9e226b5ae22f19f)
|
|
3
3
|
Target: wasm32-unknown-emscripten
|
|
4
4
|
Thread model: posix
|
|
5
5
|
InstalledDir: /home/runner/work/emnapi/emnapi/emsdk-cache/emsdk-main/upstream/bin
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emnapi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"description": "Node-API implementation for Emscripten",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"node-addon-api": ">= 6.1.0"
|
|
8
|
+
},
|
|
9
|
+
"peerDependenciesMeta": {
|
|
10
|
+
"node-addon-api": {
|
|
11
|
+
"optional": true
|
|
12
|
+
}
|
|
13
|
+
},
|
|
6
14
|
"devDependencies": {
|
|
7
15
|
"ts-macros": "2.0.1"
|
|
8
16
|
},
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
#ifndef SRC_NAPI_INL_DEPRECATED_H_
|
|
2
|
-
#define SRC_NAPI_INL_DEPRECATED_H_
|
|
3
|
-
|
|
4
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
// PropertyDescriptor class
|
|
6
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
7
|
-
|
|
8
|
-
template <typename Getter>
|
|
9
|
-
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
|
10
|
-
const char* utf8name,
|
|
11
|
-
Getter getter,
|
|
12
|
-
napi_property_attributes attributes,
|
|
13
|
-
void* /*data*/) {
|
|
14
|
-
using CbData = details::CallbackData<Getter, Napi::Value>;
|
|
15
|
-
// TODO: Delete when the function is destroyed
|
|
16
|
-
auto callbackData = new CbData({getter, nullptr});
|
|
17
|
-
|
|
18
|
-
return PropertyDescriptor({utf8name,
|
|
19
|
-
nullptr,
|
|
20
|
-
nullptr,
|
|
21
|
-
CbData::Wrapper,
|
|
22
|
-
nullptr,
|
|
23
|
-
nullptr,
|
|
24
|
-
attributes,
|
|
25
|
-
callbackData});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
template <typename Getter>
|
|
29
|
-
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
|
30
|
-
const std::string& utf8name,
|
|
31
|
-
Getter getter,
|
|
32
|
-
napi_property_attributes attributes,
|
|
33
|
-
void* data) {
|
|
34
|
-
return Accessor(utf8name.c_str(), getter, attributes, data);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
template <typename Getter>
|
|
38
|
-
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
|
39
|
-
napi_value name,
|
|
40
|
-
Getter getter,
|
|
41
|
-
napi_property_attributes attributes,
|
|
42
|
-
void* /*data*/) {
|
|
43
|
-
using CbData = details::CallbackData<Getter, Napi::Value>;
|
|
44
|
-
// TODO: Delete when the function is destroyed
|
|
45
|
-
auto callbackData = new CbData({getter, nullptr});
|
|
46
|
-
|
|
47
|
-
return PropertyDescriptor({nullptr,
|
|
48
|
-
name,
|
|
49
|
-
nullptr,
|
|
50
|
-
CbData::Wrapper,
|
|
51
|
-
nullptr,
|
|
52
|
-
nullptr,
|
|
53
|
-
attributes,
|
|
54
|
-
callbackData});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
template <typename Getter>
|
|
58
|
-
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
|
59
|
-
Name name, Getter getter, napi_property_attributes attributes, void* data) {
|
|
60
|
-
napi_value nameValue = name;
|
|
61
|
-
return PropertyDescriptor::Accessor(nameValue, getter, attributes, data);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
template <typename Getter, typename Setter>
|
|
65
|
-
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
|
66
|
-
const char* utf8name,
|
|
67
|
-
Getter getter,
|
|
68
|
-
Setter setter,
|
|
69
|
-
napi_property_attributes attributes,
|
|
70
|
-
void* /*data*/) {
|
|
71
|
-
using CbData = details::AccessorCallbackData<Getter, Setter>;
|
|
72
|
-
// TODO: Delete when the function is destroyed
|
|
73
|
-
auto callbackData = new CbData({getter, setter, nullptr});
|
|
74
|
-
|
|
75
|
-
return PropertyDescriptor({utf8name,
|
|
76
|
-
nullptr,
|
|
77
|
-
nullptr,
|
|
78
|
-
CbData::GetterWrapper,
|
|
79
|
-
CbData::SetterWrapper,
|
|
80
|
-
nullptr,
|
|
81
|
-
attributes,
|
|
82
|
-
callbackData});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
template <typename Getter, typename Setter>
|
|
86
|
-
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
|
87
|
-
const std::string& utf8name,
|
|
88
|
-
Getter getter,
|
|
89
|
-
Setter setter,
|
|
90
|
-
napi_property_attributes attributes,
|
|
91
|
-
void* data) {
|
|
92
|
-
return Accessor(utf8name.c_str(), getter, setter, attributes, data);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
template <typename Getter, typename Setter>
|
|
96
|
-
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
|
97
|
-
napi_value name,
|
|
98
|
-
Getter getter,
|
|
99
|
-
Setter setter,
|
|
100
|
-
napi_property_attributes attributes,
|
|
101
|
-
void* /*data*/) {
|
|
102
|
-
using CbData = details::AccessorCallbackData<Getter, Setter>;
|
|
103
|
-
// TODO: Delete when the function is destroyed
|
|
104
|
-
auto callbackData = new CbData({getter, setter, nullptr});
|
|
105
|
-
|
|
106
|
-
return PropertyDescriptor({nullptr,
|
|
107
|
-
name,
|
|
108
|
-
nullptr,
|
|
109
|
-
CbData::GetterWrapper,
|
|
110
|
-
CbData::SetterWrapper,
|
|
111
|
-
nullptr,
|
|
112
|
-
attributes,
|
|
113
|
-
callbackData});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
template <typename Getter, typename Setter>
|
|
117
|
-
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
|
118
|
-
Name name,
|
|
119
|
-
Getter getter,
|
|
120
|
-
Setter setter,
|
|
121
|
-
napi_property_attributes attributes,
|
|
122
|
-
void* data) {
|
|
123
|
-
napi_value nameValue = name;
|
|
124
|
-
return PropertyDescriptor::Accessor(
|
|
125
|
-
nameValue, getter, setter, attributes, data);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
template <typename Callable>
|
|
129
|
-
inline PropertyDescriptor PropertyDescriptor::Function(
|
|
130
|
-
const char* utf8name,
|
|
131
|
-
Callable cb,
|
|
132
|
-
napi_property_attributes attributes,
|
|
133
|
-
void* /*data*/) {
|
|
134
|
-
using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
|
|
135
|
-
using CbData = details::CallbackData<Callable, ReturnType>;
|
|
136
|
-
// TODO: Delete when the function is destroyed
|
|
137
|
-
auto callbackData = new CbData({cb, nullptr});
|
|
138
|
-
|
|
139
|
-
return PropertyDescriptor({utf8name,
|
|
140
|
-
nullptr,
|
|
141
|
-
CbData::Wrapper,
|
|
142
|
-
nullptr,
|
|
143
|
-
nullptr,
|
|
144
|
-
nullptr,
|
|
145
|
-
attributes,
|
|
146
|
-
callbackData});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
template <typename Callable>
|
|
150
|
-
inline PropertyDescriptor PropertyDescriptor::Function(
|
|
151
|
-
const std::string& utf8name,
|
|
152
|
-
Callable cb,
|
|
153
|
-
napi_property_attributes attributes,
|
|
154
|
-
void* data) {
|
|
155
|
-
return Function(utf8name.c_str(), cb, attributes, data);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
template <typename Callable>
|
|
159
|
-
inline PropertyDescriptor PropertyDescriptor::Function(
|
|
160
|
-
napi_value name,
|
|
161
|
-
Callable cb,
|
|
162
|
-
napi_property_attributes attributes,
|
|
163
|
-
void* /*data*/) {
|
|
164
|
-
using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
|
|
165
|
-
using CbData = details::CallbackData<Callable, ReturnType>;
|
|
166
|
-
// TODO: Delete when the function is destroyed
|
|
167
|
-
auto callbackData = new CbData({cb, nullptr});
|
|
168
|
-
|
|
169
|
-
return PropertyDescriptor({nullptr,
|
|
170
|
-
name,
|
|
171
|
-
CbData::Wrapper,
|
|
172
|
-
nullptr,
|
|
173
|
-
nullptr,
|
|
174
|
-
nullptr,
|
|
175
|
-
attributes,
|
|
176
|
-
callbackData});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
template <typename Callable>
|
|
180
|
-
inline PropertyDescriptor PropertyDescriptor::Function(
|
|
181
|
-
Name name, Callable cb, napi_property_attributes attributes, void* data) {
|
|
182
|
-
napi_value nameValue = name;
|
|
183
|
-
return PropertyDescriptor::Function(nameValue, cb, attributes, data);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
#endif // !SRC_NAPI_INL_DEPRECATED_H_
|