emnapi 0.45.0 → 1.1.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 +22 -16
- package/README.md +158 -141
- package/cmake/wasm32.cmake +1 -1
- package/common.gypi +423 -0
- package/dist/library_napi.js +8 -5
- package/emnapi.gyp +120 -0
- package/include/node/config.gypi +5 -0
- package/include/{emnapi.h → node/emnapi.h} +2 -2
- package/include/{js_native_api.h → node/js_native_api.h} +24 -20
- package/include/{js_native_api_types.h → node/js_native_api_types.h} +39 -0
- package/include/{node_api.h → node/node_api.h} +15 -15
- package/index.js +4 -2
- package/lib/wasm32/libemmalloc-mt.a +0 -0
- package/lib/wasm32/libemmalloc.a +0 -0
- package/lib/wasm64-emscripten/libemnapi-basic.a +0 -0
- package/lib/wasm64-emscripten/libemnapi-mt.a +0 -0
- package/lib/wasm64-emscripten/libemnapi.a +0 -0
- package/package.json +1 -1
- package/src/emnapi_internal.h +2 -2
- package/src/js_native_api.c +2 -0
- package/src/malloc/emmalloc/emmalloc.c +8 -3
- package/lib/wasm32-emscripten.txt +0 -5
- package/lib/wasm32-wasi-threads.txt +0 -4
- package/lib/wasm32-wasi.txt +0 -4
- package/lib/wasm32.txt +0 -4
- /package/include/{emnapi_common.h → node/emnapi_common.h} +0 -0
- /package/include/{node_api_types.h → node/node_api_types.h} +0 -0
- /package/include/{uv → node/uv}/threadpool.h +0 -0
- /package/include/{uv → node/uv}/unix.h +0 -0
- /package/include/{uv.h → node/uv.h} +0 -0
package/common.gypi
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# This file is originally created by [RReverser](https://github.com/RReverser)
|
|
2
|
+
# in https://github.com/lovell/sharp/pull/3522
|
|
3
|
+
{
|
|
4
|
+
'variables': {
|
|
5
|
+
# OS: 'emscripten' | 'wasi' | 'unknown'
|
|
6
|
+
'clang': 1,
|
|
7
|
+
'target_arch%': 'wasm32',
|
|
8
|
+
'wasm_threads%': 0,
|
|
9
|
+
'stack_size%': 1048576,
|
|
10
|
+
'initial_memory%': 16777216,
|
|
11
|
+
'max_memory%': 2147483648,
|
|
12
|
+
# must be an absolute path
|
|
13
|
+
'emnapi_js_library%': '<!(node -p "path.resolve(process.argv[1],\'dist/library_napi.js\').replace(process.argv[2],\'/\')" "<(node_root_dir)" "\\\\")',
|
|
14
|
+
'emnapi_manual_linking%': 0,
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
'target_defaults': {
|
|
18
|
+
'type': 'executable',
|
|
19
|
+
|
|
20
|
+
'defines': [
|
|
21
|
+
'BUILDING_NODE_EXTENSION',
|
|
22
|
+
'__STDC_FORMAT_MACROS',
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
'cflags': [
|
|
26
|
+
'-Wall',
|
|
27
|
+
'-Wextra',
|
|
28
|
+
'-Wno-unused-parameter',
|
|
29
|
+
],
|
|
30
|
+
'cflags_cc': [
|
|
31
|
+
'-fno-rtti',
|
|
32
|
+
'-fno-exceptions',
|
|
33
|
+
'-std=c++17'
|
|
34
|
+
],
|
|
35
|
+
|
|
36
|
+
'xcode_settings': {
|
|
37
|
+
# WARNING_CFLAGS == cflags
|
|
38
|
+
# OTHER_CFLAGS == cflags_c
|
|
39
|
+
# OTHER_CPLUSPLUSFLAGS == cflags_cc
|
|
40
|
+
# OTHER_LDFLAGS == ldflags
|
|
41
|
+
|
|
42
|
+
'CLANG_CXX_LANGUAGE_STANDARD': 'c++17',
|
|
43
|
+
'GCC_ENABLE_CPP_RTTI': 'NO',
|
|
44
|
+
'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',
|
|
45
|
+
'WARNING_CFLAGS': [
|
|
46
|
+
'-Wall',
|
|
47
|
+
'-Wextra',
|
|
48
|
+
'-Wno-unused-parameter',
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
'default_configuration': 'Release',
|
|
53
|
+
'configurations': {
|
|
54
|
+
'Debug': {
|
|
55
|
+
'defines': [ 'DEBUG', '_DEBUG' ],
|
|
56
|
+
'cflags': [ '-g', '-O0' ],
|
|
57
|
+
'ldflags': [ '-g', '-O0' ],
|
|
58
|
+
'xcode_settings': {
|
|
59
|
+
'WARNING_CFLAGS': [ '-g', '-O0' ],
|
|
60
|
+
'OTHER_LDFLAGS': [ '-g', '-O0' ],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
'Release': {
|
|
64
|
+
'cflags': [ '-O3' ],
|
|
65
|
+
'ldflags': [ '-O3' ],
|
|
66
|
+
'xcode_settings': {
|
|
67
|
+
'WARNING_CFLAGS': [ '-O3' ],
|
|
68
|
+
'OTHER_LDFLAGS': [ '-O3' ],
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
'conditions': [
|
|
74
|
+
['OS == "emscripten"', {
|
|
75
|
+
'defines': [
|
|
76
|
+
'NAPI_EXTERN=__attribute__((__import_module__(\"env\")))'
|
|
77
|
+
],
|
|
78
|
+
|
|
79
|
+
'cflags': [
|
|
80
|
+
'-sDEFAULT_TO_CXX=0',
|
|
81
|
+
],
|
|
82
|
+
'ldflags': [
|
|
83
|
+
"-sALLOW_MEMORY_GROWTH=1",
|
|
84
|
+
"-sEXPORTED_FUNCTIONS=['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']",
|
|
85
|
+
'-sNODEJS_CATCH_EXIT=0',
|
|
86
|
+
'-sNODEJS_CATCH_REJECTION=0',
|
|
87
|
+
'-sWASM_BIGINT=1',
|
|
88
|
+
'-sMIN_CHROME_VERSION=84',
|
|
89
|
+
'-sMIN_NODE_VERSION=161500',
|
|
90
|
+
'-sSTACK_SIZE=<(stack_size)',
|
|
91
|
+
'-sDEFAULT_PTHREAD_STACK_SIZE=<(stack_size)',
|
|
92
|
+
'-sINITIAL_MEMORY=<(initial_memory)',
|
|
93
|
+
'-sMAXIMUM_MEMORY=<(max_memory)',
|
|
94
|
+
],
|
|
95
|
+
'xcode_settings': {
|
|
96
|
+
'WARNING_CFLAGS': [
|
|
97
|
+
'-sDEFAULT_TO_CXX=0',
|
|
98
|
+
],
|
|
99
|
+
'OTHER_LDFLAGS': [
|
|
100
|
+
"-sALLOW_MEMORY_GROWTH=1",
|
|
101
|
+
"-sEXPORTED_FUNCTIONS=['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']",
|
|
102
|
+
'-sNODEJS_CATCH_EXIT=0',
|
|
103
|
+
'-sNODEJS_CATCH_REJECTION=0',
|
|
104
|
+
'-sWASM_BIGINT=1',
|
|
105
|
+
'-sMIN_CHROME_VERSION=84',
|
|
106
|
+
'-sMIN_NODE_VERSION=161500',
|
|
107
|
+
'-sSTACK_SIZE=<(stack_size)',
|
|
108
|
+
'-sDEFAULT_PTHREAD_STACK_SIZE=<(stack_size)',
|
|
109
|
+
'-sINITIAL_MEMORY=<(initial_memory)',
|
|
110
|
+
'-sMAXIMUM_MEMORY=<(max_memory)',
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
'configurations': {
|
|
115
|
+
'Debug': {
|
|
116
|
+
'ldflags': [ '-sSAFE_HEAP=1' ],
|
|
117
|
+
'xcode_settings': {
|
|
118
|
+
'OTHER_LDFLAGS': [ '-sSAFE_HEAP=1' ],
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
'conditions': [
|
|
124
|
+
['target_arch == "wasm64"', {
|
|
125
|
+
'cflags': [ '-sMEMORY64=1' ],
|
|
126
|
+
'ldflags': [ '-sMEMORY64=1' ],
|
|
127
|
+
'xcode_settings': {
|
|
128
|
+
'WARNING_CFLAGS': [ '-sMEMORY64=1' ],
|
|
129
|
+
'OTHER_LDFLAGS': [ '-sMEMORY64=1' ],
|
|
130
|
+
},
|
|
131
|
+
}],
|
|
132
|
+
['wasm_threads != 0', {
|
|
133
|
+
'cflags': [ '-sWASM_WORKERS=1', '-pthread' ],
|
|
134
|
+
'ldflags': [ '-pthread' ],
|
|
135
|
+
'xcode_settings': {
|
|
136
|
+
'WARNING_CFLAGS': [ '-sWASM_WORKERS=1', '-pthread' ],
|
|
137
|
+
'OTHER_LDFLAGS': [ '-pthread' ],
|
|
138
|
+
},
|
|
139
|
+
}],
|
|
140
|
+
],
|
|
141
|
+
}],
|
|
142
|
+
['OS in "wasi unknown "', {
|
|
143
|
+
'configurations': {
|
|
144
|
+
'Release': {
|
|
145
|
+
'ldflags': [ '-Wl,--strip-debug' ],
|
|
146
|
+
'xcode_settings': {
|
|
147
|
+
'OTHER_LDFLAGS': [ '-Wl,--strip-debug' ],
|
|
148
|
+
},
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
'conditions': [
|
|
153
|
+
['target_arch == "wasm64"', {
|
|
154
|
+
'ldflags': [ "-Wl,-mwasm64" ],
|
|
155
|
+
'xcode_settings': {
|
|
156
|
+
'OTHER_LDFLAGS': [ "-Wl,-mwasm64" ],
|
|
157
|
+
},
|
|
158
|
+
}],
|
|
159
|
+
['wasm_threads != 0', {
|
|
160
|
+
'cflags': [ "-matomics", "-mbulk-memory" ],
|
|
161
|
+
'xcode_settings': {
|
|
162
|
+
'WARNING_CFLAGS': [ "-matomics", "-mbulk-memory" ],
|
|
163
|
+
},
|
|
164
|
+
}],
|
|
165
|
+
['OS == "wasi"', {
|
|
166
|
+
'ldflags': [
|
|
167
|
+
'-mexec-model=reactor'
|
|
168
|
+
],
|
|
169
|
+
'xcode_settings': {
|
|
170
|
+
'OTHER_LDFLAGS': [
|
|
171
|
+
'-mexec-model=reactor'
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
'conditions': [
|
|
175
|
+
['target_arch == "wasm64"', {
|
|
176
|
+
'conditions': [
|
|
177
|
+
['wasm_threads != 0', {
|
|
178
|
+
# wasi-threads
|
|
179
|
+
'cflags': [ '--target=wasm64-wasi-threads', '-pthread' ],
|
|
180
|
+
'ldflags': [ '--target=wasm64-wasi-threads', '-pthread' ],
|
|
181
|
+
'xcode_settings': {
|
|
182
|
+
'WARNING_CFLAGS': [ '--target=wasm64-wasi-threads', '-pthread' ],
|
|
183
|
+
'OTHER_LDFLAGS': [ '--target=wasm64-wasi-threads', '-pthread' ],
|
|
184
|
+
},
|
|
185
|
+
}, {
|
|
186
|
+
# wasi
|
|
187
|
+
'cflags': [ '--target=wasm64-wasi' ],
|
|
188
|
+
'ldflags': [ '--target=wasm64-wasi' ],
|
|
189
|
+
'xcode_settings': {
|
|
190
|
+
'WARNING_CFLAGS': [ '--target=wasm64-wasi' ],
|
|
191
|
+
'OTHER_LDFLAGS': [ '--target=wasm64-wasi' ],
|
|
192
|
+
},
|
|
193
|
+
}],
|
|
194
|
+
],
|
|
195
|
+
}, {
|
|
196
|
+
'conditions': [
|
|
197
|
+
['wasm_threads != 0', {
|
|
198
|
+
# wasi-threads
|
|
199
|
+
'cflags': [ '--target=wasm32-wasi-threads', '-pthread' ],
|
|
200
|
+
'ldflags': [ '--target=wasm32-wasi-threads', '-pthread' ],
|
|
201
|
+
'xcode_settings': {
|
|
202
|
+
'WARNING_CFLAGS': [ '--target=wasm32-wasi-threads', '-pthread' ],
|
|
203
|
+
'OTHER_LDFLAGS': [ '--target=wasm32-wasi-threads', '-pthread' ],
|
|
204
|
+
},
|
|
205
|
+
}, {
|
|
206
|
+
# wasi
|
|
207
|
+
'cflags': [ '--target=wasm32-wasi' ],
|
|
208
|
+
'ldflags': [ '--target=wasm32-wasi' ],
|
|
209
|
+
'xcode_settings': {
|
|
210
|
+
'WARNING_CFLAGS': [ '--target=wasm32-wasi' ],
|
|
211
|
+
'OTHER_LDFLAGS': [ '--target=wasm32-wasi' ],
|
|
212
|
+
},
|
|
213
|
+
}],
|
|
214
|
+
],
|
|
215
|
+
}],
|
|
216
|
+
],
|
|
217
|
+
}, {
|
|
218
|
+
'conditions': [
|
|
219
|
+
['target_arch == "wasm64"', {
|
|
220
|
+
'cflags': [ '--target=wasm64-unknown-unknown' ],
|
|
221
|
+
'ldflags': [ '--target=wasm64-unknown-unknown' ],
|
|
222
|
+
'xcode_settings': {
|
|
223
|
+
'WARNING_CFLAGS': [ '--target=wasm64-unknown-unknown' ],
|
|
224
|
+
'OTHER_LDFLAGS': [ '--target=wasm64-unknown-unknown' ],
|
|
225
|
+
},
|
|
226
|
+
}, {
|
|
227
|
+
'cflags': [ '--target=wasm32-unknown-unknown' ],
|
|
228
|
+
'ldflags': [ '--target=wasm32-unknown-unknown' ],
|
|
229
|
+
'xcode_settings': {
|
|
230
|
+
'WARNING_CFLAGS': [ '--target=wasm32-unknown-unknown' ],
|
|
231
|
+
'OTHER_LDFLAGS': [ '--target=wasm32-unknown-unknown' ],
|
|
232
|
+
},
|
|
233
|
+
}],
|
|
234
|
+
],
|
|
235
|
+
}],
|
|
236
|
+
]
|
|
237
|
+
}],
|
|
238
|
+
['emnapi_manual_linking != 0', {
|
|
239
|
+
'target_conditions': [
|
|
240
|
+
['_type=="executable"', {
|
|
241
|
+
'conditions': [
|
|
242
|
+
['OS in "wasi unknown "', {
|
|
243
|
+
'product_extension': 'wasm',
|
|
244
|
+
|
|
245
|
+
'ldflags': [
|
|
246
|
+
'-Wl,--export-dynamic',
|
|
247
|
+
'-Wl,--export=malloc',
|
|
248
|
+
'-Wl,--export=free',
|
|
249
|
+
'-Wl,--export=napi_register_wasm_v1',
|
|
250
|
+
'-Wl,--export-if-defined=node_api_module_get_api_version_v1',
|
|
251
|
+
'-Wl,--import-undefined',
|
|
252
|
+
'-Wl,--export-table',
|
|
253
|
+
'-Wl,-zstack-size=<(stack_size)',
|
|
254
|
+
'-Wl,--initial-memory=<(initial_memory)',
|
|
255
|
+
'-Wl,--max-memory=<(max_memory)',
|
|
256
|
+
],
|
|
257
|
+
'xcode_settings': {
|
|
258
|
+
'OTHER_LDFLAGS': [
|
|
259
|
+
'-Wl,--export-dynamic',
|
|
260
|
+
'-Wl,--export=malloc',
|
|
261
|
+
'-Wl,--export=free',
|
|
262
|
+
'-Wl,--export=napi_register_wasm_v1',
|
|
263
|
+
'-Wl,--export-if-defined=node_api_module_get_api_version_v1',
|
|
264
|
+
'-Wl,--import-undefined',
|
|
265
|
+
'-Wl,--export-table',
|
|
266
|
+
'-Wl,-zstack-size=<(stack_size)',
|
|
267
|
+
'-Wl,--initial-memory=<(initial_memory)',
|
|
268
|
+
'-Wl,--max-memory=<(max_memory)',
|
|
269
|
+
],
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
'conditions': [
|
|
273
|
+
['wasm_threads != 0', {
|
|
274
|
+
'ldflags': [
|
|
275
|
+
'-Wl,--import-memory',
|
|
276
|
+
'-Wl,--shared-memory',
|
|
277
|
+
],
|
|
278
|
+
'xcode_settings': {
|
|
279
|
+
'OTHER_LDFLAGS': [
|
|
280
|
+
'-Wl,--import-memory',
|
|
281
|
+
'-Wl,--shared-memory',
|
|
282
|
+
]
|
|
283
|
+
},
|
|
284
|
+
}],
|
|
285
|
+
['OS != "wasi"', {
|
|
286
|
+
'ldflags': [
|
|
287
|
+
'-nostdlib',
|
|
288
|
+
'-Wl,--no-entry',
|
|
289
|
+
],
|
|
290
|
+
'xcode_settings': {
|
|
291
|
+
'OTHER_LDFLAGS': [
|
|
292
|
+
'-nostdlib',
|
|
293
|
+
'-Wl,--no-entry',
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
}],
|
|
297
|
+
]
|
|
298
|
+
}]
|
|
299
|
+
],
|
|
300
|
+
}],
|
|
301
|
+
],
|
|
302
|
+
}, {
|
|
303
|
+
'target_conditions': [
|
|
304
|
+
['_type=="executable"', {
|
|
305
|
+
'sources': [
|
|
306
|
+
'src/js_native_api.c',
|
|
307
|
+
'src/node_api.c',
|
|
308
|
+
'src/async_cleanup_hook.c',
|
|
309
|
+
'src/async_context.c',
|
|
310
|
+
'src/async_work.c',
|
|
311
|
+
'src/threadsafe_function.c',
|
|
312
|
+
'src/uv/uv-common.c',
|
|
313
|
+
'src/uv/threadpool.c',
|
|
314
|
+
'src/uv/unix/loop.c',
|
|
315
|
+
'src/uv/unix/thread.c',
|
|
316
|
+
'src/uv/unix/async.c',
|
|
317
|
+
'src/uv/unix/core.c',
|
|
318
|
+
],
|
|
319
|
+
'conditions': [
|
|
320
|
+
['OS == "emscripten"', {
|
|
321
|
+
'conditions': [
|
|
322
|
+
['emnapi_js_library != ""', {
|
|
323
|
+
'libraries': [
|
|
324
|
+
'--js-library=<(emnapi_js_library)',
|
|
325
|
+
],
|
|
326
|
+
}]
|
|
327
|
+
],
|
|
328
|
+
}],
|
|
329
|
+
['OS in "wasi unknown "', {
|
|
330
|
+
'product_extension': 'wasm',
|
|
331
|
+
|
|
332
|
+
'ldflags': [
|
|
333
|
+
'-Wl,--export-dynamic',
|
|
334
|
+
'-Wl,--export=malloc',
|
|
335
|
+
'-Wl,--export=free',
|
|
336
|
+
'-Wl,--export=napi_register_wasm_v1',
|
|
337
|
+
'-Wl,--export-if-defined=node_api_module_get_api_version_v1',
|
|
338
|
+
'-Wl,--import-undefined',
|
|
339
|
+
'-Wl,--export-table',
|
|
340
|
+
'-Wl,-zstack-size=<(stack_size)',
|
|
341
|
+
'-Wl,--initial-memory=<(initial_memory)',
|
|
342
|
+
'-Wl,--max-memory=<(max_memory)',
|
|
343
|
+
],
|
|
344
|
+
'xcode_settings': {
|
|
345
|
+
'OTHER_LDFLAGS': [
|
|
346
|
+
'-Wl,--export-dynamic',
|
|
347
|
+
'-Wl,--export=malloc',
|
|
348
|
+
'-Wl,--export=free',
|
|
349
|
+
'-Wl,--export=napi_register_wasm_v1',
|
|
350
|
+
'-Wl,--export-if-defined=node_api_module_get_api_version_v1',
|
|
351
|
+
'-Wl,--import-undefined',
|
|
352
|
+
'-Wl,--export-table',
|
|
353
|
+
'-Wl,-zstack-size=<(stack_size)',
|
|
354
|
+
'-Wl,--initial-memory=<(initial_memory)',
|
|
355
|
+
'-Wl,--max-memory=<(max_memory)',
|
|
356
|
+
],
|
|
357
|
+
},
|
|
358
|
+
|
|
359
|
+
'conditions': [
|
|
360
|
+
['wasm_threads != 0', {
|
|
361
|
+
'ldflags': [
|
|
362
|
+
'-Wl,--import-memory',
|
|
363
|
+
'-Wl,--shared-memory',
|
|
364
|
+
],
|
|
365
|
+
'xcode_settings': {
|
|
366
|
+
'OTHER_LDFLAGS': [
|
|
367
|
+
'-Wl,--import-memory',
|
|
368
|
+
'-Wl,--shared-memory',
|
|
369
|
+
]
|
|
370
|
+
},
|
|
371
|
+
}],
|
|
372
|
+
['OS != "wasi"', {
|
|
373
|
+
'defines': [
|
|
374
|
+
'PAGESIZE=65536'
|
|
375
|
+
],
|
|
376
|
+
'ldflags': [
|
|
377
|
+
'-nostdlib',
|
|
378
|
+
'-Wl,--no-entry',
|
|
379
|
+
],
|
|
380
|
+
'xcode_settings': {
|
|
381
|
+
'OTHER_LDFLAGS': [
|
|
382
|
+
'-nostdlib',
|
|
383
|
+
'-Wl,--no-entry',
|
|
384
|
+
],
|
|
385
|
+
},
|
|
386
|
+
'sources': [
|
|
387
|
+
'src/malloc/sbrk.c',
|
|
388
|
+
'src/malloc/memcpy.c',
|
|
389
|
+
'src/malloc/memset.c',
|
|
390
|
+
'src/malloc/dlmalloc/dlmalloc.c',
|
|
391
|
+
],
|
|
392
|
+
'conditions': [
|
|
393
|
+
['wasm_threads != 0', {
|
|
394
|
+
# wasm32 + threads
|
|
395
|
+
'sources': [
|
|
396
|
+
'src/thread/async_worker_create.c',
|
|
397
|
+
'src/thread/async_worker_init.S',
|
|
398
|
+
],
|
|
399
|
+
'defines': [
|
|
400
|
+
'USE_LOCKS=1'
|
|
401
|
+
],
|
|
402
|
+
'ldflags': [
|
|
403
|
+
'-Wl,--export=emnapi_async_worker_create',
|
|
404
|
+
'-Wl,--export=emnapi_async_worker_init',
|
|
405
|
+
],
|
|
406
|
+
'xcode_settings': {
|
|
407
|
+
'OTHER_LDFLAGS': [
|
|
408
|
+
'-Wl,--export=emnapi_async_worker_create',
|
|
409
|
+
'-Wl,--export=emnapi_async_worker_init',
|
|
410
|
+
],
|
|
411
|
+
},
|
|
412
|
+
}],
|
|
413
|
+
]
|
|
414
|
+
}],
|
|
415
|
+
]
|
|
416
|
+
}]
|
|
417
|
+
],
|
|
418
|
+
}],
|
|
419
|
+
],
|
|
420
|
+
}]
|
|
421
|
+
],
|
|
422
|
+
}
|
|
423
|
+
}
|
package/dist/library_napi.js
CHANGED
|
@@ -1235,9 +1235,8 @@ function _napi_get_buffer_info(env, buffer, data, length) {
|
|
|
1235
1235
|
if (!buffer)
|
|
1236
1236
|
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
1237
1237
|
var handle = emnapiCtx.handleStore.get(buffer);
|
|
1238
|
-
if (!handle.isBuffer())
|
|
1238
|
+
if (!handle.isBuffer())
|
|
1239
1239
|
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
1240
|
-
}
|
|
1241
1240
|
return _napi_get_typedarray_info(env, buffer, 0, length, data, 0, 0);
|
|
1242
1241
|
}
|
|
1243
1242
|
/**
|
|
@@ -1549,7 +1548,9 @@ function _napi_get_value_int32(env, value, result) {
|
|
|
1549
1548
|
return envObject.setLastError(6 /* napi_status.napi_number_expected */);
|
|
1550
1549
|
}
|
|
1551
1550
|
{{{ from64('result') }}};
|
|
1552
|
-
|
|
1551
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1552
|
+
var v = new Int32Array([handle.value])[0];
|
|
1553
|
+
{{{ makeSetValue('result', 0, 'v', 'i32') }}};
|
|
1553
1554
|
return envObject.clearLastError();
|
|
1554
1555
|
}
|
|
1555
1556
|
/**
|
|
@@ -1584,7 +1585,7 @@ function _napi_get_value_int64(env, value, result) {
|
|
|
1584
1585
|
{{{ makeSetValue('result', 4, '0x7fffffff', 'u32') }}};
|
|
1585
1586
|
}
|
|
1586
1587
|
else {
|
|
1587
|
-
emnapiSetValueI64(result, numberValue);
|
|
1588
|
+
emnapiSetValueI64(result, Math.trunc(numberValue));
|
|
1588
1589
|
}
|
|
1589
1590
|
return envObject.clearLastError();
|
|
1590
1591
|
}
|
|
@@ -1724,7 +1725,9 @@ function _napi_get_value_uint32(env, value, result) {
|
|
|
1724
1725
|
return envObject.setLastError(6 /* napi_status.napi_number_expected */);
|
|
1725
1726
|
}
|
|
1726
1727
|
{{{ from64('result') }}};
|
|
1727
|
-
|
|
1728
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1729
|
+
var v = new Uint32Array([handle.value])[0];
|
|
1730
|
+
{{{ makeSetValue('result', 0, 'v', 'u32') }}};
|
|
1728
1731
|
return envObject.clearLastError();
|
|
1729
1732
|
}
|
|
1730
1733
|
/* eslint-disable @typescript-eslint/indent */
|
package/emnapi.gyp
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{
|
|
2
|
+
'targets': [
|
|
3
|
+
{
|
|
4
|
+
'target_name': 'dlmalloc',
|
|
5
|
+
'type': 'static_library',
|
|
6
|
+
'defines': [
|
|
7
|
+
'PAGESIZE=65536'
|
|
8
|
+
],
|
|
9
|
+
'sources': [
|
|
10
|
+
'src/malloc/sbrk.c',
|
|
11
|
+
'src/malloc/memcpy.c',
|
|
12
|
+
'src/malloc/memset.c',
|
|
13
|
+
'src/malloc/dlmalloc/dlmalloc.c',
|
|
14
|
+
],
|
|
15
|
+
'conditions': [
|
|
16
|
+
['wasm_threads != 0', {
|
|
17
|
+
'defines': [
|
|
18
|
+
'USE_LOCKS=1'
|
|
19
|
+
],
|
|
20
|
+
}],
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
'target_name': 'emmalloc',
|
|
25
|
+
'type': 'static_library',
|
|
26
|
+
'defines': [
|
|
27
|
+
'PAGESIZE=65536'
|
|
28
|
+
],
|
|
29
|
+
'sources': [
|
|
30
|
+
'src/malloc/sbrk.c',
|
|
31
|
+
'src/malloc/memcpy.c',
|
|
32
|
+
'src/malloc/memset.c',
|
|
33
|
+
'src/malloc/emmalloc/emmalloc.c',
|
|
34
|
+
],
|
|
35
|
+
'cflags': [ '-fno-strict-aliasing' ],
|
|
36
|
+
'xcode_settings': {
|
|
37
|
+
'GCC_STRICT_ALIASING': 'NO',
|
|
38
|
+
},
|
|
39
|
+
'conditions': [
|
|
40
|
+
['wasm_threads != 0', {
|
|
41
|
+
'defines': [
|
|
42
|
+
'__EMSCRIPTEN_SHARED_MEMORY__=1'
|
|
43
|
+
],
|
|
44
|
+
}],
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
'target_name': 'emnapi_basic',
|
|
49
|
+
'type': 'static_library',
|
|
50
|
+
'sources': [
|
|
51
|
+
'src/js_native_api.c',
|
|
52
|
+
'src/node_api.c',
|
|
53
|
+
'src/async_cleanup_hook.c',
|
|
54
|
+
'src/async_context.c',
|
|
55
|
+
],
|
|
56
|
+
'link_settings': {
|
|
57
|
+
'target_conditions': [
|
|
58
|
+
['_type == "executable" and OS == "emscripten"', {
|
|
59
|
+
'libraries': [
|
|
60
|
+
'--js-library=<(emnapi_js_library)',
|
|
61
|
+
]
|
|
62
|
+
}],
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
'conditions': [
|
|
66
|
+
['wasm_threads != 0 and OS in " unknown wasi"', {
|
|
67
|
+
'sources': [
|
|
68
|
+
'src/thread/async_worker_create.c',
|
|
69
|
+
'src/thread/async_worker_init.S',
|
|
70
|
+
],
|
|
71
|
+
'link_settings': {
|
|
72
|
+
'target_conditions': [
|
|
73
|
+
['_type == "executable"', {
|
|
74
|
+
'ldflags': [
|
|
75
|
+
'-Wl,--export=emnapi_async_worker_create',
|
|
76
|
+
'-Wl,--export=emnapi_async_worker_init',
|
|
77
|
+
],
|
|
78
|
+
'xcode_settings': {
|
|
79
|
+
'OTHER_LDFLAGS': [
|
|
80
|
+
'-Wl,--export=emnapi_async_worker_create',
|
|
81
|
+
'-Wl,--export=emnapi_async_worker_init',
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
}],
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
}],
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
'target_name': 'emnapi',
|
|
92
|
+
'type': 'static_library',
|
|
93
|
+
'sources': [
|
|
94
|
+
'src/js_native_api.c',
|
|
95
|
+
'src/node_api.c',
|
|
96
|
+
'src/async_cleanup_hook.c',
|
|
97
|
+
'src/async_context.c',
|
|
98
|
+
|
|
99
|
+
'src/uv/uv-common.c',
|
|
100
|
+
'src/uv/threadpool.c',
|
|
101
|
+
'src/uv/unix/loop.c',
|
|
102
|
+
'src/uv/unix/thread.c',
|
|
103
|
+
'src/uv/unix/async.c',
|
|
104
|
+
'src/uv/unix/core.c',
|
|
105
|
+
|
|
106
|
+
'src/async_work.c',
|
|
107
|
+
'src/threadsafe_function.c',
|
|
108
|
+
],
|
|
109
|
+
'link_settings': {
|
|
110
|
+
'target_conditions': [
|
|
111
|
+
['_type == "executable" and OS == "emscripten"', {
|
|
112
|
+
'libraries': [
|
|
113
|
+
'--js-library=<(emnapi_js_library)',
|
|
114
|
+
]
|
|
115
|
+
}],
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|