koffi 2.8.9 → 2.8.10

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/koffi/darwin_arm64/koffi.node +0 -0
  3. package/build/koffi/darwin_x64/koffi.node +0 -0
  4. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  5. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  6. package/build/koffi/freebsd_x64/koffi.node +0 -0
  7. package/build/koffi/linux_arm64/koffi.node +0 -0
  8. package/build/koffi/linux_armhf/koffi.node +0 -0
  9. package/build/koffi/linux_ia32/koffi.node +0 -0
  10. package/build/koffi/linux_riscv64d/koffi.node +0 -0
  11. package/build/koffi/linux_x64/koffi.node +0 -0
  12. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  13. package/build/koffi/openbsd_x64/koffi.node +0 -0
  14. package/build/koffi/win32_arm64/koffi.exp +0 -0
  15. package/build/koffi/win32_arm64/koffi.lib +0 -0
  16. package/build/koffi/win32_arm64/koffi.node +0 -0
  17. package/build/koffi/win32_ia32/koffi.exp +0 -0
  18. package/build/koffi/win32_ia32/koffi.lib +0 -0
  19. package/build/koffi/win32_ia32/koffi.node +0 -0
  20. package/build/koffi/win32_x64/koffi.exp +0 -0
  21. package/build/koffi/win32_x64/koffi.lib +0 -0
  22. package/build/koffi/win32_x64/koffi.node +0 -0
  23. package/index.js +28 -48
  24. package/indirect.js +24 -44
  25. package/package.json +5 -3
  26. package/src/cnoke/assets/FindCNoke.cmake +16 -3
  27. package/src/cnoke/src/builder.js +109 -102
  28. package/src/cnoke/src/tools.js +5 -23
  29. package/src/koffi/CMakeLists.txt +1 -1
  30. package/vendor/node-api-headers/CHANGELOG.md +79 -0
  31. package/vendor/node-api-headers/CODE_OF_CONDUCT.md +4 -0
  32. package/vendor/node-api-headers/CONTRIBUTING.md +32 -0
  33. package/vendor/node-api-headers/CREATING_A_RELEASE.md +58 -0
  34. package/vendor/node-api-headers/LICENSE +21 -0
  35. package/vendor/node-api-headers/README.md +106 -0
  36. package/vendor/node-api-headers/def/js_native_api.def +120 -0
  37. package/vendor/node-api-headers/def/node_api.def +151 -0
  38. package/vendor/node-api-headers/include/js_native_api.h +569 -0
  39. package/vendor/node-api-headers/include/js_native_api_types.h +168 -0
  40. package/vendor/node-api-headers/include/node_api.h +260 -0
  41. package/vendor/node-api-headers/include/node_api_types.h +52 -0
  42. package/vendor/node-api-headers/index.js +17 -0
  43. package/vendor/node-api-headers/package.json +59 -0
  44. package/vendor/node-api-headers/scripts/clang-utils.js +50 -0
  45. package/vendor/node-api-headers/scripts/update-headers.js +189 -0
  46. package/vendor/node-api-headers/scripts/write-symbols.js +154 -0
  47. package/vendor/node-api-headers/scripts/write-win32-def.js +52 -0
  48. package/vendor/node-api-headers/symbols.js +241 -0
  49. package/build/koffi/linux_arm32hf/koffi.node +0 -0
  50. package/build/koffi/linux_riscv64hf64/koffi.node +0 -0
@@ -0,0 +1,168 @@
1
+ #ifndef SRC_JS_NATIVE_API_TYPES_H_
2
+ #define SRC_JS_NATIVE_API_TYPES_H_
3
+
4
+ // This file needs to be compatible with C compilers.
5
+ // This is a public include file, and these includes have essentially
6
+ // became part of it's API.
7
+ #include <stddef.h> // NOLINT(modernize-deprecated-headers)
8
+ #include <stdint.h> // NOLINT(modernize-deprecated-headers)
9
+
10
+ #if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900)
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
20
+ #endif
21
+
22
+ // JSVM API types are all opaque pointers for ABI stability
23
+ // typedef undefined structs instead of void* for compile time type safety
24
+ typedef struct napi_env__* napi_env;
25
+ typedef struct napi_value__* napi_value;
26
+ typedef struct napi_ref__* napi_ref;
27
+ typedef struct napi_handle_scope__* napi_handle_scope;
28
+ typedef struct napi_escapable_handle_scope__* napi_escapable_handle_scope;
29
+ typedef struct napi_callback_info__* napi_callback_info;
30
+ typedef struct napi_deferred__* napi_deferred;
31
+
32
+ typedef enum {
33
+ napi_default = 0,
34
+ napi_writable = 1 << 0,
35
+ napi_enumerable = 1 << 1,
36
+ napi_configurable = 1 << 2,
37
+
38
+ // Used with napi_define_class to distinguish static properties
39
+ // from instance properties. Ignored by napi_define_properties.
40
+ napi_static = 1 << 10,
41
+
42
+ #if NAPI_VERSION >= 8
43
+ // Default for class methods.
44
+ napi_default_method = napi_writable | napi_configurable,
45
+
46
+ // Default for object properties, like in JS obj[prop].
47
+ napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable,
48
+ #endif // NAPI_VERSION >= 8
49
+ } napi_property_attributes;
50
+
51
+ typedef enum {
52
+ // ES6 types (corresponds to typeof)
53
+ napi_undefined,
54
+ napi_null,
55
+ napi_boolean,
56
+ napi_number,
57
+ napi_string,
58
+ napi_symbol,
59
+ napi_object,
60
+ napi_function,
61
+ napi_external,
62
+ napi_bigint,
63
+ } napi_valuetype;
64
+
65
+ typedef enum {
66
+ napi_int8_array,
67
+ napi_uint8_array,
68
+ napi_uint8_clamped_array,
69
+ napi_int16_array,
70
+ napi_uint16_array,
71
+ napi_int32_array,
72
+ napi_uint32_array,
73
+ napi_float32_array,
74
+ napi_float64_array,
75
+ napi_bigint64_array,
76
+ napi_biguint64_array,
77
+ } napi_typedarray_type;
78
+
79
+ typedef enum {
80
+ napi_ok,
81
+ napi_invalid_arg,
82
+ napi_object_expected,
83
+ napi_string_expected,
84
+ napi_name_expected,
85
+ napi_function_expected,
86
+ napi_number_expected,
87
+ napi_boolean_expected,
88
+ napi_array_expected,
89
+ napi_generic_failure,
90
+ napi_pending_exception,
91
+ napi_cancelled,
92
+ napi_escape_called_twice,
93
+ napi_handle_scope_mismatch,
94
+ napi_callback_scope_mismatch,
95
+ napi_queue_full,
96
+ napi_closing,
97
+ napi_bigint_expected,
98
+ napi_date_expected,
99
+ napi_arraybuffer_expected,
100
+ napi_detachable_arraybuffer_expected,
101
+ napi_would_deadlock, // unused
102
+ napi_no_external_buffers_allowed,
103
+ napi_cannot_run_js,
104
+ } napi_status;
105
+ // Note: when adding a new enum value to `napi_status`, please also update
106
+ // * `const int last_status` in the definition of `napi_get_last_error_info()'
107
+ // in file js_native_api_v8.cc.
108
+ // * `const char* error_messages[]` in file js_native_api_v8.cc with a brief
109
+ // message explaining the error.
110
+ // * the definition of `napi_status` in doc/api/n-api.md to reflect the newly
111
+ // added value(s).
112
+
113
+ typedef napi_value(NAPI_CDECL* napi_callback)(napi_env env,
114
+ napi_callback_info info);
115
+ typedef void(NAPI_CDECL* napi_finalize)(napi_env env,
116
+ void* finalize_data,
117
+ void* finalize_hint);
118
+
119
+ typedef struct {
120
+ // One of utf8name or name should be NULL.
121
+ const char* utf8name;
122
+ napi_value name;
123
+
124
+ napi_callback method;
125
+ napi_callback getter;
126
+ napi_callback setter;
127
+ napi_value value;
128
+
129
+ napi_property_attributes attributes;
130
+ void* data;
131
+ } napi_property_descriptor;
132
+
133
+ typedef struct {
134
+ const char* error_message;
135
+ void* engine_reserved;
136
+ uint32_t engine_error_code;
137
+ napi_status error_code;
138
+ } napi_extended_error_info;
139
+
140
+ #if NAPI_VERSION >= 6
141
+ typedef enum {
142
+ napi_key_include_prototypes,
143
+ napi_key_own_only
144
+ } napi_key_collection_mode;
145
+
146
+ typedef enum {
147
+ napi_key_all_properties = 0,
148
+ napi_key_writable = 1,
149
+ napi_key_enumerable = 1 << 1,
150
+ napi_key_configurable = 1 << 2,
151
+ napi_key_skip_strings = 1 << 3,
152
+ napi_key_skip_symbols = 1 << 4
153
+ } napi_key_filter;
154
+
155
+ typedef enum {
156
+ napi_key_keep_numbers,
157
+ napi_key_numbers_to_strings
158
+ } napi_key_conversion;
159
+ #endif // NAPI_VERSION >= 6
160
+
161
+ #if NAPI_VERSION >= 8
162
+ typedef struct {
163
+ uint64_t lower;
164
+ uint64_t upper;
165
+ } napi_type_tag;
166
+ #endif // NAPI_VERSION >= 8
167
+
168
+ #endif // SRC_JS_NATIVE_API_TYPES_H_
@@ -0,0 +1,260 @@
1
+ #ifndef SRC_NODE_API_H_
2
+ #define SRC_NODE_API_H_
3
+
4
+ #ifdef BUILDING_NODE_EXTENSION
5
+ #ifdef _WIN32
6
+ // Building native addon against node
7
+ #define NAPI_EXTERN __declspec(dllimport)
8
+ #elif defined(__wasm32__)
9
+ #define NAPI_EXTERN __attribute__((__import_module__("napi")))
10
+ #endif
11
+ #endif
12
+ #include "js_native_api.h"
13
+ #include "node_api_types.h"
14
+
15
+ struct uv_loop_s; // Forward declaration.
16
+
17
+ #ifdef _WIN32
18
+ #define NAPI_MODULE_EXPORT __declspec(dllexport)
19
+ #else
20
+ #define NAPI_MODULE_EXPORT __attribute__((visibility("default")))
21
+ #endif
22
+
23
+ #if defined(__GNUC__)
24
+ #define NAPI_NO_RETURN __attribute__((noreturn))
25
+ #elif defined(_WIN32)
26
+ #define NAPI_NO_RETURN __declspec(noreturn)
27
+ #else
28
+ #define NAPI_NO_RETURN
29
+ #endif
30
+
31
+ typedef napi_value(NAPI_CDECL* napi_addon_register_func)(napi_env env,
32
+ napi_value exports);
33
+ typedef int32_t(NAPI_CDECL* node_api_addon_get_api_version_func)();
34
+
35
+ // Used by deprecated registration method napi_module_register.
36
+ typedef struct napi_module {
37
+ int nm_version;
38
+ unsigned int nm_flags;
39
+ const char* nm_filename;
40
+ napi_addon_register_func nm_register_func;
41
+ const char* nm_modname;
42
+ void* nm_priv;
43
+ void* reserved[4];
44
+ } napi_module;
45
+
46
+ #define NAPI_MODULE_VERSION 1
47
+
48
+ #define NAPI_MODULE_INITIALIZER_X(base, version) \
49
+ NAPI_MODULE_INITIALIZER_X_HELPER(base, version)
50
+ #define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version
51
+
52
+ #ifdef __wasm32__
53
+ #define NAPI_MODULE_INITIALIZER_BASE napi_register_wasm_v
54
+ #else
55
+ #define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v
56
+ #endif
57
+
58
+ #define NODE_API_MODULE_GET_API_VERSION_BASE node_api_module_get_api_version_v
59
+
60
+ #define NAPI_MODULE_INITIALIZER \
61
+ NAPI_MODULE_INITIALIZER_X(NAPI_MODULE_INITIALIZER_BASE, NAPI_MODULE_VERSION)
62
+
63
+ #define NODE_API_MODULE_GET_API_VERSION \
64
+ NAPI_MODULE_INITIALIZER_X(NODE_API_MODULE_GET_API_VERSION_BASE, \
65
+ NAPI_MODULE_VERSION)
66
+
67
+ #define NAPI_MODULE_INIT() \
68
+ EXTERN_C_START \
69
+ NAPI_MODULE_EXPORT int32_t NODE_API_MODULE_GET_API_VERSION() { \
70
+ return NAPI_VERSION; \
71
+ } \
72
+ NAPI_MODULE_EXPORT napi_value NAPI_MODULE_INITIALIZER(napi_env env, \
73
+ napi_value exports); \
74
+ EXTERN_C_END \
75
+ napi_value NAPI_MODULE_INITIALIZER(napi_env env, napi_value exports)
76
+
77
+ #define NAPI_MODULE(modname, regfunc) \
78
+ NAPI_MODULE_INIT() { return regfunc(env, exports); }
79
+
80
+ // Deprecated. Use NAPI_MODULE.
81
+ #define NAPI_MODULE_X(modname, regfunc, priv, flags) \
82
+ NAPI_MODULE(modname, regfunc)
83
+
84
+ EXTERN_C_START
85
+
86
+ // Deprecated. Replaced by symbol-based registration defined by NAPI_MODULE
87
+ // and NAPI_MODULE_INIT macros.
88
+ #if defined(__cplusplus) && __cplusplus >= 201402L
89
+ [[deprecated]]
90
+ #endif
91
+ NAPI_EXTERN void NAPI_CDECL
92
+ napi_module_register(napi_module* mod);
93
+
94
+ NAPI_EXTERN NAPI_NO_RETURN void NAPI_CDECL
95
+ napi_fatal_error(const char* location,
96
+ size_t location_len,
97
+ const char* message,
98
+ size_t message_len);
99
+
100
+ // Methods for custom handling of async operations
101
+ NAPI_EXTERN napi_status NAPI_CDECL
102
+ napi_async_init(napi_env env,
103
+ napi_value async_resource,
104
+ napi_value async_resource_name,
105
+ napi_async_context* result);
106
+
107
+ NAPI_EXTERN napi_status NAPI_CDECL
108
+ napi_async_destroy(napi_env env, napi_async_context async_context);
109
+
110
+ NAPI_EXTERN napi_status NAPI_CDECL
111
+ napi_make_callback(napi_env env,
112
+ napi_async_context async_context,
113
+ napi_value recv,
114
+ napi_value func,
115
+ size_t argc,
116
+ const napi_value* argv,
117
+ napi_value* result);
118
+
119
+ // Methods to provide node::Buffer functionality with napi types
120
+ NAPI_EXTERN napi_status NAPI_CDECL napi_create_buffer(napi_env env,
121
+ size_t length,
122
+ void** data,
123
+ napi_value* result);
124
+ #ifndef NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED
125
+ NAPI_EXTERN napi_status NAPI_CDECL
126
+ napi_create_external_buffer(napi_env env,
127
+ size_t length,
128
+ void* data,
129
+ napi_finalize finalize_cb,
130
+ void* finalize_hint,
131
+ napi_value* result);
132
+ #endif // NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED
133
+ NAPI_EXTERN napi_status NAPI_CDECL napi_create_buffer_copy(napi_env env,
134
+ size_t length,
135
+ const void* data,
136
+ void** result_data,
137
+ napi_value* result);
138
+ NAPI_EXTERN napi_status NAPI_CDECL napi_is_buffer(napi_env env,
139
+ napi_value value,
140
+ bool* result);
141
+ NAPI_EXTERN napi_status NAPI_CDECL napi_get_buffer_info(napi_env env,
142
+ napi_value value,
143
+ void** data,
144
+ size_t* length);
145
+
146
+ #ifndef __wasm32__
147
+ // Methods to manage simple async operations
148
+ NAPI_EXTERN napi_status NAPI_CDECL
149
+ napi_create_async_work(napi_env env,
150
+ napi_value async_resource,
151
+ napi_value async_resource_name,
152
+ napi_async_execute_callback execute,
153
+ napi_async_complete_callback complete,
154
+ void* data,
155
+ napi_async_work* result);
156
+ NAPI_EXTERN napi_status NAPI_CDECL napi_delete_async_work(napi_env env,
157
+ napi_async_work work);
158
+ NAPI_EXTERN napi_status NAPI_CDECL napi_queue_async_work(napi_env env,
159
+ napi_async_work work);
160
+ NAPI_EXTERN napi_status NAPI_CDECL napi_cancel_async_work(napi_env env,
161
+ napi_async_work work);
162
+ #endif // __wasm32__
163
+
164
+ // version management
165
+ NAPI_EXTERN napi_status NAPI_CDECL
166
+ napi_get_node_version(napi_env env, const napi_node_version** version);
167
+
168
+ #if NAPI_VERSION >= 2
169
+
170
+ // Return the current libuv event loop for a given environment
171
+ NAPI_EXTERN napi_status NAPI_CDECL
172
+ napi_get_uv_event_loop(napi_env env, struct uv_loop_s** loop);
173
+
174
+ #endif // NAPI_VERSION >= 2
175
+
176
+ #if NAPI_VERSION >= 3
177
+
178
+ NAPI_EXTERN napi_status NAPI_CDECL napi_fatal_exception(napi_env env,
179
+ napi_value err);
180
+
181
+ NAPI_EXTERN napi_status NAPI_CDECL
182
+ napi_add_env_cleanup_hook(napi_env env, napi_cleanup_hook fun, void* arg);
183
+
184
+ NAPI_EXTERN napi_status NAPI_CDECL
185
+ napi_remove_env_cleanup_hook(napi_env env, napi_cleanup_hook fun, void* arg);
186
+
187
+ NAPI_EXTERN napi_status NAPI_CDECL
188
+ napi_open_callback_scope(napi_env env,
189
+ napi_value resource_object,
190
+ napi_async_context context,
191
+ napi_callback_scope* result);
192
+
193
+ NAPI_EXTERN napi_status NAPI_CDECL
194
+ napi_close_callback_scope(napi_env env, napi_callback_scope scope);
195
+
196
+ #endif // NAPI_VERSION >= 3
197
+
198
+ #if NAPI_VERSION >= 4
199
+
200
+ #ifndef __wasm32__
201
+ // Calling into JS from other threads
202
+ NAPI_EXTERN napi_status NAPI_CDECL
203
+ napi_create_threadsafe_function(napi_env env,
204
+ napi_value func,
205
+ napi_value async_resource,
206
+ napi_value async_resource_name,
207
+ size_t max_queue_size,
208
+ size_t initial_thread_count,
209
+ void* thread_finalize_data,
210
+ napi_finalize thread_finalize_cb,
211
+ void* context,
212
+ napi_threadsafe_function_call_js call_js_cb,
213
+ napi_threadsafe_function* result);
214
+
215
+ NAPI_EXTERN napi_status NAPI_CDECL napi_get_threadsafe_function_context(
216
+ napi_threadsafe_function func, void** result);
217
+
218
+ NAPI_EXTERN napi_status NAPI_CDECL
219
+ napi_call_threadsafe_function(napi_threadsafe_function func,
220
+ void* data,
221
+ napi_threadsafe_function_call_mode is_blocking);
222
+
223
+ NAPI_EXTERN napi_status NAPI_CDECL
224
+ napi_acquire_threadsafe_function(napi_threadsafe_function func);
225
+
226
+ NAPI_EXTERN napi_status NAPI_CDECL napi_release_threadsafe_function(
227
+ napi_threadsafe_function func, napi_threadsafe_function_release_mode mode);
228
+
229
+ NAPI_EXTERN napi_status NAPI_CDECL
230
+ napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func);
231
+
232
+ NAPI_EXTERN napi_status NAPI_CDECL
233
+ napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);
234
+ #endif // __wasm32__
235
+
236
+ #endif // NAPI_VERSION >= 4
237
+
238
+ #if NAPI_VERSION >= 8
239
+
240
+ NAPI_EXTERN napi_status NAPI_CDECL
241
+ napi_add_async_cleanup_hook(napi_env env,
242
+ napi_async_cleanup_hook hook,
243
+ void* arg,
244
+ napi_async_cleanup_hook_handle* remove_handle);
245
+
246
+ NAPI_EXTERN napi_status NAPI_CDECL
247
+ napi_remove_async_cleanup_hook(napi_async_cleanup_hook_handle remove_handle);
248
+
249
+ #endif // NAPI_VERSION >= 8
250
+
251
+ #if NAPI_VERSION >= 9
252
+
253
+ NAPI_EXTERN napi_status NAPI_CDECL
254
+ node_api_get_module_file_name(napi_env env, const char** result);
255
+
256
+ #endif // NAPI_VERSION >= 9
257
+
258
+ EXTERN_C_END
259
+
260
+ #endif // SRC_NODE_API_H_
@@ -0,0 +1,52 @@
1
+ #ifndef SRC_NODE_API_TYPES_H_
2
+ #define SRC_NODE_API_TYPES_H_
3
+
4
+ #include "js_native_api_types.h"
5
+
6
+ typedef struct napi_callback_scope__* napi_callback_scope;
7
+ typedef struct napi_async_context__* napi_async_context;
8
+ typedef struct napi_async_work__* napi_async_work;
9
+
10
+ #if NAPI_VERSION >= 3
11
+ typedef void(NAPI_CDECL* napi_cleanup_hook)(void* arg);
12
+ #endif // NAPI_VERSION >= 3
13
+
14
+ #if NAPI_VERSION >= 4
15
+ typedef struct napi_threadsafe_function__* napi_threadsafe_function;
16
+ #endif // NAPI_VERSION >= 4
17
+
18
+ #if NAPI_VERSION >= 4
19
+ typedef enum {
20
+ napi_tsfn_release,
21
+ napi_tsfn_abort
22
+ } napi_threadsafe_function_release_mode;
23
+
24
+ typedef enum {
25
+ napi_tsfn_nonblocking,
26
+ napi_tsfn_blocking
27
+ } napi_threadsafe_function_call_mode;
28
+ #endif // NAPI_VERSION >= 4
29
+
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);
34
+ #if NAPI_VERSION >= 4
35
+ typedef void(NAPI_CDECL* napi_threadsafe_function_call_js)(
36
+ napi_env env, napi_value js_callback, void* context, void* data);
37
+ #endif // NAPI_VERSION >= 4
38
+
39
+ typedef struct {
40
+ uint32_t major;
41
+ uint32_t minor;
42
+ uint32_t patch;
43
+ const char* release;
44
+ } napi_node_version;
45
+
46
+ #if NAPI_VERSION >= 8
47
+ typedef struct napi_async_cleanup_hook_handle__* napi_async_cleanup_hook_handle;
48
+ typedef void(NAPI_CDECL* napi_async_cleanup_hook)(
49
+ napi_async_cleanup_hook_handle handle, void* data);
50
+ #endif // NAPI_VERSION >= 8
51
+
52
+ #endif // SRC_NODE_API_TYPES_H_
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+
3
+ const path = require('path');
4
+ const symbols = require('./symbols');
5
+
6
+ const include_dir = path.resolve(__dirname, 'include');
7
+ const defRoot = path.resolve(__dirname, 'def')
8
+ const def_paths = {
9
+ js_native_api_def: path.join(defRoot, 'js_native_api.def'),
10
+ node_api_def: path.join(defRoot, 'node_api.def')
11
+ }
12
+
13
+ module.exports = {
14
+ include_dir,
15
+ def_paths,
16
+ symbols
17
+ }
@@ -0,0 +1,59 @@
1
+ {
2
+ "bugs": {
3
+ "url": "https://github.com/nodejs/node-api-headers/issues"
4
+ },
5
+ "contributors": [
6
+ {
7
+ "name": "Gabriel Schulhof",
8
+ "url": "https://github.com/gabrielschulhof"
9
+ },
10
+ {
11
+ "name": "Jim Schlight",
12
+ "url": "https://github.com/jschlight"
13
+ },
14
+ {
15
+ "name": "Kevin Eady",
16
+ "url": "https://github.com/KevinEady"
17
+ },
18
+ {
19
+ "name": "legendecas",
20
+ "url": "https://github.com/legendecas"
21
+ },
22
+ {
23
+ "name": "Leonid Pospelov",
24
+ "url": "https://github.com/Pospelove"
25
+ },
26
+ {
27
+ "name": "Michael Dawson",
28
+ "url": "https://github.com/mhdawson"
29
+ },
30
+ {
31
+ "name": "Nicola Del Gobbo",
32
+ "url": "https://github.com/NickNaso"
33
+ }
34
+ ],
35
+ "description": "Node-API headers",
36
+ "dependencies": {},
37
+ "devDependencies": {},
38
+ "directories": {},
39
+ "gypfile": false,
40
+ "homepage": "https://github.com/nodejs/node-api-headers",
41
+ "keywords": [
42
+ ],
43
+ "license": "MIT",
44
+ "main": "index.js",
45
+ "name": "node-api-headers",
46
+ "optionalDependencies": {},
47
+ "readme": "README.md",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git://github.com/nodejs/node-api-headers.git"
51
+ },
52
+ "scripts": {
53
+ "update-headers": "node --no-warnings scripts/update-headers.js",
54
+ "write-symbols": "node --no-warnings scripts/write-symbols.js",
55
+ "write-win32-def": "node --no-warnings scripts/write-win32-def.js"
56
+ },
57
+ "version": "1.1.0",
58
+ "support": true
59
+ }
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ const { spawn } = require('child_process');
4
+
5
+ /**
6
+ * @param {Array<string>} [args]
7
+ * @returns {Promise<{exitCode: number | null, stdout: string, stderr: string}>}
8
+ */
9
+ async function runClang(args = []) {
10
+ try {
11
+ const { exitCode, stdout, stderr } = await new Promise((resolve, reject) => {
12
+ const spawned = spawn('clang',
13
+ ['-Xclang', ...args]
14
+ );
15
+
16
+ let stdout = '';
17
+ let stderr = '';
18
+
19
+ spawned.stdout?.on('data', (data) => {
20
+ stdout += data.toString('utf-8');
21
+ });
22
+ spawned.stderr?.on('data', (data) => {
23
+ stderr += data.toString('utf-8');
24
+ });
25
+
26
+ spawned.on('exit', function (exitCode) {
27
+ resolve({ exitCode, stdout, stderr });
28
+ });
29
+
30
+ spawned.on('error', function (err) {
31
+ reject(err);
32
+ });
33
+ });
34
+
35
+ if (exitCode !== 0) {
36
+ throw new Error(`clang exited with non-zero exit code ${exitCode}. stderr: ${stderr ? stderr : '<empty>'}`);
37
+ }
38
+
39
+ return { exitCode, stdout, stderr };
40
+ } catch (err) {
41
+ if (err.code === 'ENOENT') {
42
+ throw new Error('This tool requires clang to be installed.');
43
+ }
44
+ throw err;
45
+ }
46
+ }
47
+
48
+ module.exports = {
49
+ runClang
50
+ };