unicode-width-approximation 1.0.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/README.md +77 -0
- package/index.d.ts +52 -0
- package/index.js +46 -0
- package/package.json +38 -0
- package/wasm/UnicodeWidthApproximationWASM.js +3356 -0
- package/wasm/UnicodeWidthApproximationWASM.wasm +0 -0
|
@@ -0,0 +1,3356 @@
|
|
|
1
|
+
// This code implements the `-sMODULARIZE` settings by taking the generated
|
|
2
|
+
// JS program code (INNER_JS_CODE) and wrapping it in a factory function.
|
|
3
|
+
|
|
4
|
+
// When targetting node and ES6 we use `await import ..` in the generated code
|
|
5
|
+
// so the outer function needs to be marked as async.
|
|
6
|
+
async function UnicodeWidthApproximationWASMModule(moduleArg = {}) {
|
|
7
|
+
var moduleRtn;
|
|
8
|
+
|
|
9
|
+
// include: shell.js
|
|
10
|
+
// include: minimum_runtime_check.js
|
|
11
|
+
(function() {
|
|
12
|
+
// "30.0.0" -> 300000
|
|
13
|
+
function humanReadableVersionToPacked(str) {
|
|
14
|
+
str = str.split('-')[0]; // Remove any trailing part from e.g. "12.53.3-alpha"
|
|
15
|
+
var vers = str.split('.').slice(0, 3);
|
|
16
|
+
while(vers.length < 3) vers.push('00');
|
|
17
|
+
vers = vers.map((n, i, arr) => n.padStart(2, '0'));
|
|
18
|
+
return vers.join('');
|
|
19
|
+
}
|
|
20
|
+
// 300000 -> "30.0.0"
|
|
21
|
+
var packedVersionToHumanReadable = n => [n / 10000 | 0, (n / 100 | 0) % 100, n % 100].join('.');
|
|
22
|
+
|
|
23
|
+
var TARGET_NOT_SUPPORTED = 2147483647;
|
|
24
|
+
|
|
25
|
+
// Note: We use a typeof check here instead of optional chaining using
|
|
26
|
+
// globalThis because older browsers might not have globalThis defined.
|
|
27
|
+
var currentNodeVersion = typeof process !== 'undefined' && process.versions?.node ? humanReadableVersionToPacked(process.versions.node) : TARGET_NOT_SUPPORTED;
|
|
28
|
+
if (currentNodeVersion < 160000) {
|
|
29
|
+
throw new Error(`This emscripten-generated code requires node v${ packedVersionToHumanReadable(160000) } (detected v${packedVersionToHumanReadable(currentNodeVersion)})`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var userAgent = typeof navigator !== 'undefined' && navigator.userAgent;
|
|
33
|
+
if (!userAgent) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var currentSafariVersion = userAgent.includes("Safari/") && userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/) ? humanReadableVersionToPacked(userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]) : TARGET_NOT_SUPPORTED;
|
|
38
|
+
if (currentSafariVersion < 150000) {
|
|
39
|
+
throw new Error(`This emscripten-generated code requires Safari v${ packedVersionToHumanReadable(150000) } (detected v${currentSafariVersion})`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var currentFirefoxVersion = userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/) ? parseFloat(userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED;
|
|
43
|
+
if (currentFirefoxVersion < 79) {
|
|
44
|
+
throw new Error(`This emscripten-generated code requires Firefox v79 (detected v${currentFirefoxVersion})`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var currentChromeVersion = userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/) ? parseFloat(userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED;
|
|
48
|
+
if (currentChromeVersion < 85) {
|
|
49
|
+
throw new Error(`This emscripten-generated code requires Chrome v85 (detected v${currentChromeVersion})`);
|
|
50
|
+
}
|
|
51
|
+
})();
|
|
52
|
+
|
|
53
|
+
// end include: minimum_runtime_check.js
|
|
54
|
+
// The Module object: Our interface to the outside world. We import
|
|
55
|
+
// and export values on it. There are various ways Module can be used:
|
|
56
|
+
// 1. Not defined. We create it here
|
|
57
|
+
// 2. A function parameter, function(moduleArg) => Promise<Module>
|
|
58
|
+
// 3. pre-run appended it, var Module = {}; ..generated code..
|
|
59
|
+
// 4. External script tag defines var Module.
|
|
60
|
+
// We need to check if Module already exists (e.g. case 3 above).
|
|
61
|
+
// Substitution will be replaced with actual code on later stage of the build,
|
|
62
|
+
// this way Closure Compiler will not mangle it (e.g. case 4. above).
|
|
63
|
+
// Note that if you want to run closure, and also to use Module
|
|
64
|
+
// after the generated code, you will need to define var Module = {};
|
|
65
|
+
// before the code. Then that object will be used in the code, and you
|
|
66
|
+
// can continue to use Module afterwards as well.
|
|
67
|
+
var Module = moduleArg;
|
|
68
|
+
|
|
69
|
+
// Determine the runtime environment we are in. You can customize this by
|
|
70
|
+
// setting the ENVIRONMENT setting at compile time (see settings.js).
|
|
71
|
+
|
|
72
|
+
// Attempt to auto-detect the environment
|
|
73
|
+
var ENVIRONMENT_IS_WEB = !!globalThis.window;
|
|
74
|
+
var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope;
|
|
75
|
+
// N.b. Electron.js environment is simultaneously a NODE-environment, but
|
|
76
|
+
// also a web environment.
|
|
77
|
+
var ENVIRONMENT_IS_NODE = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer';
|
|
78
|
+
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
79
|
+
|
|
80
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
81
|
+
// When building an ES module `require` is not normally available.
|
|
82
|
+
// We need to use `createRequire()` to construct the require()` function.
|
|
83
|
+
const { createRequire } = await import('module');
|
|
84
|
+
/** @suppress{duplicate} */
|
|
85
|
+
var require = createRequire(import.meta.url);
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// --pre-jses are emitted after the Module integration code, so that they can
|
|
90
|
+
// refer to Module (if they choose; they can also define Module)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
var arguments_ = [];
|
|
94
|
+
var thisProgram = './this.program';
|
|
95
|
+
var quit_ = (status, toThrow) => {
|
|
96
|
+
throw toThrow;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var _scriptName = import.meta.url;
|
|
100
|
+
|
|
101
|
+
// `/` should be present at the end if `scriptDirectory` is not empty
|
|
102
|
+
var scriptDirectory = '';
|
|
103
|
+
function locateFile(path) {
|
|
104
|
+
if (Module['locateFile']) {
|
|
105
|
+
return Module['locateFile'](path, scriptDirectory);
|
|
106
|
+
}
|
|
107
|
+
return scriptDirectory + path;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Hooks that are implemented differently in different runtime environments.
|
|
111
|
+
var readAsync, readBinary;
|
|
112
|
+
|
|
113
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
114
|
+
const isNode = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer';
|
|
115
|
+
if (!isNode) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
|
|
116
|
+
|
|
117
|
+
// These modules will usually be used on Node.js. Load them eagerly to avoid
|
|
118
|
+
// the complexity of lazy-loading.
|
|
119
|
+
var fs = require('fs');
|
|
120
|
+
|
|
121
|
+
if (_scriptName.startsWith('file:')) {
|
|
122
|
+
scriptDirectory = require('path').dirname(require('url').fileURLToPath(_scriptName)) + '/';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// include: node_shell_read.js
|
|
126
|
+
readBinary = (filename) => {
|
|
127
|
+
// We need to re-wrap `file://` strings to URLs.
|
|
128
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
129
|
+
var ret = fs.readFileSync(filename);
|
|
130
|
+
assert(Buffer.isBuffer(ret));
|
|
131
|
+
return ret;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
readAsync = async (filename, binary = true) => {
|
|
135
|
+
// See the comment in the `readBinary` function.
|
|
136
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
137
|
+
var ret = fs.readFileSync(filename, binary ? undefined : 'utf8');
|
|
138
|
+
assert(binary ? Buffer.isBuffer(ret) : typeof ret == 'string');
|
|
139
|
+
return ret;
|
|
140
|
+
};
|
|
141
|
+
// end include: node_shell_read.js
|
|
142
|
+
if (process.argv.length > 1) {
|
|
143
|
+
thisProgram = process.argv[1].replace(/\\/g, '/');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
arguments_ = process.argv.slice(2);
|
|
147
|
+
|
|
148
|
+
quit_ = (status, toThrow) => {
|
|
149
|
+
process.exitCode = status;
|
|
150
|
+
throw toThrow;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
} else
|
|
154
|
+
if (ENVIRONMENT_IS_SHELL) {
|
|
155
|
+
|
|
156
|
+
} else
|
|
157
|
+
|
|
158
|
+
// Note that this includes Node.js workers when relevant (pthreads is enabled).
|
|
159
|
+
// Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
|
|
160
|
+
// ENVIRONMENT_IS_NODE.
|
|
161
|
+
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
162
|
+
try {
|
|
163
|
+
scriptDirectory = new URL('.', _scriptName).href; // includes trailing slash
|
|
164
|
+
} catch {
|
|
165
|
+
// Must be a `blob:` or `data:` URL (e.g. `blob:http://site.com/etc/etc`), we cannot
|
|
166
|
+
// infer anything from them.
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!(globalThis.window || globalThis.WorkerGlobalScope)) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
|
|
170
|
+
|
|
171
|
+
{
|
|
172
|
+
// include: web_or_worker_shell_read.js
|
|
173
|
+
if (ENVIRONMENT_IS_WORKER) {
|
|
174
|
+
readBinary = (url) => {
|
|
175
|
+
var xhr = new XMLHttpRequest();
|
|
176
|
+
xhr.open('GET', url, false);
|
|
177
|
+
xhr.responseType = 'arraybuffer';
|
|
178
|
+
xhr.send(null);
|
|
179
|
+
return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
readAsync = async (url) => {
|
|
184
|
+
// Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
|
|
185
|
+
// See https://github.com/github/fetch/pull/92#issuecomment-140665932
|
|
186
|
+
// Cordova or Electron apps are typically loaded from a file:// url.
|
|
187
|
+
// So use XHR on webview if URL is a file URL.
|
|
188
|
+
if (isFileURI(url)) {
|
|
189
|
+
return new Promise((resolve, reject) => {
|
|
190
|
+
var xhr = new XMLHttpRequest();
|
|
191
|
+
xhr.open('GET', url, true);
|
|
192
|
+
xhr.responseType = 'arraybuffer';
|
|
193
|
+
xhr.onload = () => {
|
|
194
|
+
if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
|
|
195
|
+
resolve(xhr.response);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
reject(xhr.status);
|
|
199
|
+
};
|
|
200
|
+
xhr.onerror = reject;
|
|
201
|
+
xhr.send(null);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
var response = await fetch(url, { credentials: 'same-origin' });
|
|
205
|
+
if (response.ok) {
|
|
206
|
+
return response.arrayBuffer();
|
|
207
|
+
}
|
|
208
|
+
throw new Error(response.status + ' : ' + response.url);
|
|
209
|
+
};
|
|
210
|
+
// end include: web_or_worker_shell_read.js
|
|
211
|
+
}
|
|
212
|
+
} else
|
|
213
|
+
{
|
|
214
|
+
throw new Error('environment detection error');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
var out = console.log.bind(console);
|
|
218
|
+
var err = console.error.bind(console);
|
|
219
|
+
|
|
220
|
+
var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js';
|
|
221
|
+
var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js';
|
|
222
|
+
var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js';
|
|
223
|
+
var FETCHFS = 'FETCHFS is no longer included by default; build with -lfetchfs.js';
|
|
224
|
+
var ICASEFS = 'ICASEFS is no longer included by default; build with -licasefs.js';
|
|
225
|
+
var JSFILEFS = 'JSFILEFS is no longer included by default; build with -ljsfilefs.js';
|
|
226
|
+
var OPFS = 'OPFS is no longer included by default; build with -lopfs.js';
|
|
227
|
+
|
|
228
|
+
var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
|
|
229
|
+
|
|
230
|
+
// perform assertions in shell.js after we set up out() and err(), as otherwise
|
|
231
|
+
// if an assertion fails it cannot print the message
|
|
232
|
+
|
|
233
|
+
assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.');
|
|
234
|
+
|
|
235
|
+
// end include: shell.js
|
|
236
|
+
|
|
237
|
+
// include: preamble.js
|
|
238
|
+
// === Preamble library stuff ===
|
|
239
|
+
|
|
240
|
+
// Documentation for the public APIs defined in this file must be updated in:
|
|
241
|
+
// site/source/docs/api_reference/preamble.js.rst
|
|
242
|
+
// A prebuilt local version of the documentation is available at:
|
|
243
|
+
// site/build/text/docs/api_reference/preamble.js.txt
|
|
244
|
+
// You can also build docs locally as HTML or other formats in site/
|
|
245
|
+
// An online HTML version (which may be of a different version of Emscripten)
|
|
246
|
+
// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
|
|
247
|
+
|
|
248
|
+
var wasmBinary;
|
|
249
|
+
|
|
250
|
+
if (!globalThis.WebAssembly) {
|
|
251
|
+
err('no native wasm support detected');
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Wasm globals
|
|
255
|
+
|
|
256
|
+
//========================================
|
|
257
|
+
// Runtime essentials
|
|
258
|
+
//========================================
|
|
259
|
+
|
|
260
|
+
// whether we are quitting the application. no code should run after this.
|
|
261
|
+
// set in exit() and abort()
|
|
262
|
+
var ABORT = false;
|
|
263
|
+
|
|
264
|
+
// set by exit() and abort(). Passed to 'onExit' handler.
|
|
265
|
+
// NOTE: This is also used as the process return code code in shell environments
|
|
266
|
+
// but only when noExitRuntime is false.
|
|
267
|
+
var EXITSTATUS;
|
|
268
|
+
|
|
269
|
+
// In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we
|
|
270
|
+
// don't define it at all in release modes. This matches the behaviour of
|
|
271
|
+
// MINIMAL_RUNTIME.
|
|
272
|
+
// TODO(sbc): Make this the default even without STRICT enabled.
|
|
273
|
+
/** @type {function(*, string=)} */
|
|
274
|
+
function assert(condition, text) {
|
|
275
|
+
if (!condition) {
|
|
276
|
+
abort('Assertion failed' + (text ? ': ' + text : ''));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// We used to include malloc/free by default in the past. Show a helpful error in
|
|
281
|
+
// builds with assertions.
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Indicates whether filename is delivered via file protocol (as opposed to http/https)
|
|
285
|
+
* @noinline
|
|
286
|
+
*/
|
|
287
|
+
var isFileURI = (filename) => filename.startsWith('file://');
|
|
288
|
+
|
|
289
|
+
// include: runtime_common.js
|
|
290
|
+
// include: runtime_stack_check.js
|
|
291
|
+
// Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
|
|
292
|
+
function writeStackCookie() {
|
|
293
|
+
var max = _emscripten_stack_get_end();
|
|
294
|
+
assert((max & 3) == 0);
|
|
295
|
+
// If the stack ends at address zero we write our cookies 4 bytes into the
|
|
296
|
+
// stack. This prevents interference with SAFE_HEAP and ASAN which also
|
|
297
|
+
// monitor writes to address zero.
|
|
298
|
+
if (max == 0) {
|
|
299
|
+
max += 4;
|
|
300
|
+
}
|
|
301
|
+
// The stack grow downwards towards _emscripten_stack_get_end.
|
|
302
|
+
// We write cookies to the final two words in the stack and detect if they are
|
|
303
|
+
// ever overwritten.
|
|
304
|
+
HEAPU32[((max)>>2)] = 0x02135467;
|
|
305
|
+
HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
|
|
306
|
+
// Also test the global address 0 for integrity.
|
|
307
|
+
HEAPU32[((0)>>2)] = 1668509029;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function checkStackCookie() {
|
|
311
|
+
if (ABORT) return;
|
|
312
|
+
var max = _emscripten_stack_get_end();
|
|
313
|
+
// See writeStackCookie().
|
|
314
|
+
if (max == 0) {
|
|
315
|
+
max += 4;
|
|
316
|
+
}
|
|
317
|
+
var cookie1 = HEAPU32[((max)>>2)];
|
|
318
|
+
var cookie2 = HEAPU32[(((max)+(4))>>2)];
|
|
319
|
+
if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) {
|
|
320
|
+
abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
|
|
321
|
+
}
|
|
322
|
+
// Also test the global address 0 for integrity.
|
|
323
|
+
if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) {
|
|
324
|
+
abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
// end include: runtime_stack_check.js
|
|
328
|
+
// include: runtime_exceptions.js
|
|
329
|
+
// Base Emscripten EH error class
|
|
330
|
+
class EmscriptenEH extends Error {}
|
|
331
|
+
|
|
332
|
+
class EmscriptenSjLj extends EmscriptenEH {}
|
|
333
|
+
|
|
334
|
+
class CppException extends EmscriptenEH {
|
|
335
|
+
constructor(excPtr) {
|
|
336
|
+
super(excPtr);
|
|
337
|
+
this.excPtr = excPtr;
|
|
338
|
+
const excInfo = getExceptionMessage(excPtr);
|
|
339
|
+
this.name = excInfo[0];
|
|
340
|
+
this.message = excInfo[1];
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
// end include: runtime_exceptions.js
|
|
344
|
+
// include: runtime_debug.js
|
|
345
|
+
var runtimeDebug = true; // Switch to false at runtime to disable logging at the right times
|
|
346
|
+
|
|
347
|
+
// Used by XXXXX_DEBUG settings to output debug messages.
|
|
348
|
+
function dbg(...args) {
|
|
349
|
+
if (!runtimeDebug && typeof runtimeDebug != 'undefined') return;
|
|
350
|
+
// TODO(sbc): Make this configurable somehow. Its not always convenient for
|
|
351
|
+
// logging to show up as warnings.
|
|
352
|
+
console.warn(...args);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Endianness check
|
|
356
|
+
(() => {
|
|
357
|
+
var h16 = new Int16Array(1);
|
|
358
|
+
var h8 = new Int8Array(h16.buffer);
|
|
359
|
+
h16[0] = 0x6373;
|
|
360
|
+
if (h8[0] !== 0x73 || h8[1] !== 0x63) abort('Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)');
|
|
361
|
+
})();
|
|
362
|
+
|
|
363
|
+
function consumedModuleProp(prop) {
|
|
364
|
+
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
365
|
+
Object.defineProperty(Module, prop, {
|
|
366
|
+
configurable: true,
|
|
367
|
+
set() {
|
|
368
|
+
abort(`Attempt to set \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`);
|
|
369
|
+
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function makeInvalidEarlyAccess(name) {
|
|
376
|
+
return () => assert(false, `call to '${name}' via reference taken before Wasm module initialization`);
|
|
377
|
+
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function ignoredModuleProp(prop) {
|
|
381
|
+
if (Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
382
|
+
abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// forcing the filesystem exports a few things by default
|
|
387
|
+
function isExportedByForceFilesystem(name) {
|
|
388
|
+
return name === 'FS_createPath' ||
|
|
389
|
+
name === 'FS_createDataFile' ||
|
|
390
|
+
name === 'FS_createPreloadedFile' ||
|
|
391
|
+
name === 'FS_preloadFile' ||
|
|
392
|
+
name === 'FS_unlink' ||
|
|
393
|
+
name === 'addRunDependency' ||
|
|
394
|
+
// The old FS has some functionality that WasmFS lacks.
|
|
395
|
+
name === 'FS_createLazyFile' ||
|
|
396
|
+
name === 'FS_createDevice' ||
|
|
397
|
+
name === 'removeRunDependency';
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function missingLibrarySymbol(sym) {
|
|
401
|
+
|
|
402
|
+
// Any symbol that is not included from the JS library is also (by definition)
|
|
403
|
+
// not exported on the Module object.
|
|
404
|
+
unexportedRuntimeSymbol(sym);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function unexportedRuntimeSymbol(sym) {
|
|
408
|
+
if (!Object.getOwnPropertyDescriptor(Module, sym)) {
|
|
409
|
+
Object.defineProperty(Module, sym, {
|
|
410
|
+
configurable: true,
|
|
411
|
+
get() {
|
|
412
|
+
var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
|
|
413
|
+
if (isExportedByForceFilesystem(sym)) {
|
|
414
|
+
msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
|
|
415
|
+
}
|
|
416
|
+
abort(msg);
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// end include: runtime_debug.js
|
|
423
|
+
var readyPromiseResolve, readyPromiseReject;
|
|
424
|
+
|
|
425
|
+
// Memory management
|
|
426
|
+
var
|
|
427
|
+
/** @type {!Int8Array} */
|
|
428
|
+
HEAP8,
|
|
429
|
+
/** @type {!Uint8Array} */
|
|
430
|
+
HEAPU8,
|
|
431
|
+
/** @type {!Int16Array} */
|
|
432
|
+
HEAP16,
|
|
433
|
+
/** @type {!Uint16Array} */
|
|
434
|
+
HEAPU16,
|
|
435
|
+
/** @type {!Int32Array} */
|
|
436
|
+
HEAP32,
|
|
437
|
+
/** @type {!Uint32Array} */
|
|
438
|
+
HEAPU32,
|
|
439
|
+
/** @type {!Float32Array} */
|
|
440
|
+
HEAPF32,
|
|
441
|
+
/** @type {!Float64Array} */
|
|
442
|
+
HEAPF64;
|
|
443
|
+
|
|
444
|
+
// BigInt64Array type is not correctly defined in closure
|
|
445
|
+
var
|
|
446
|
+
/** not-@type {!BigInt64Array} */
|
|
447
|
+
HEAP64,
|
|
448
|
+
/* BigUint64Array type is not correctly defined in closure
|
|
449
|
+
/** not-@type {!BigUint64Array} */
|
|
450
|
+
HEAPU64;
|
|
451
|
+
|
|
452
|
+
var runtimeInitialized = false;
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
function updateMemoryViews() {
|
|
457
|
+
var b = wasmMemory.buffer;
|
|
458
|
+
HEAP8 = new Int8Array(b);
|
|
459
|
+
HEAP16 = new Int16Array(b);
|
|
460
|
+
HEAPU8 = new Uint8Array(b);
|
|
461
|
+
HEAPU16 = new Uint16Array(b);
|
|
462
|
+
HEAP32 = new Int32Array(b);
|
|
463
|
+
HEAPU32 = new Uint32Array(b);
|
|
464
|
+
HEAPF32 = new Float32Array(b);
|
|
465
|
+
HEAPF64 = new Float64Array(b);
|
|
466
|
+
HEAP64 = new BigInt64Array(b);
|
|
467
|
+
HEAPU64 = new BigUint64Array(b);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// include: memoryprofiler.js
|
|
471
|
+
// end include: memoryprofiler.js
|
|
472
|
+
// end include: runtime_common.js
|
|
473
|
+
assert(globalThis.Int32Array && globalThis.Float64Array && Int32Array.prototype.subarray && Int32Array.prototype.set,
|
|
474
|
+
'JS engine does not provide full typed array support');
|
|
475
|
+
|
|
476
|
+
function preRun() {
|
|
477
|
+
if (Module['preRun']) {
|
|
478
|
+
if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
|
|
479
|
+
while (Module['preRun'].length) {
|
|
480
|
+
addOnPreRun(Module['preRun'].shift());
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
consumedModuleProp('preRun');
|
|
484
|
+
// Begin ATPRERUNS hooks
|
|
485
|
+
callRuntimeCallbacks(onPreRuns);
|
|
486
|
+
// End ATPRERUNS hooks
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function initRuntime() {
|
|
490
|
+
assert(!runtimeInitialized);
|
|
491
|
+
runtimeInitialized = true;
|
|
492
|
+
|
|
493
|
+
checkStackCookie();
|
|
494
|
+
|
|
495
|
+
// No ATINITS hooks
|
|
496
|
+
|
|
497
|
+
wasmExports['__wasm_call_ctors']();
|
|
498
|
+
|
|
499
|
+
// No ATPOSTCTORS hooks
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function postRun() {
|
|
503
|
+
checkStackCookie();
|
|
504
|
+
// PThreads reuse the runtime from the main thread.
|
|
505
|
+
|
|
506
|
+
if (Module['postRun']) {
|
|
507
|
+
if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
|
|
508
|
+
while (Module['postRun'].length) {
|
|
509
|
+
addOnPostRun(Module['postRun'].shift());
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
consumedModuleProp('postRun');
|
|
513
|
+
|
|
514
|
+
// Begin ATPOSTRUNS hooks
|
|
515
|
+
callRuntimeCallbacks(onPostRuns);
|
|
516
|
+
// End ATPOSTRUNS hooks
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/** @param {string|number=} what */
|
|
520
|
+
function abort(what) {
|
|
521
|
+
Module['onAbort']?.(what);
|
|
522
|
+
|
|
523
|
+
what = 'Aborted(' + what + ')';
|
|
524
|
+
// TODO(sbc): Should we remove printing and leave it up to whoever
|
|
525
|
+
// catches the exception?
|
|
526
|
+
err(what);
|
|
527
|
+
|
|
528
|
+
ABORT = true;
|
|
529
|
+
|
|
530
|
+
// Use a wasm runtime error, because a JS error might be seen as a foreign
|
|
531
|
+
// exception, which means we'd run destructors on it. We need the error to
|
|
532
|
+
// simply make the program stop.
|
|
533
|
+
// FIXME This approach does not work in Wasm EH because it currently does not assume
|
|
534
|
+
// all RuntimeErrors are from traps; it decides whether a RuntimeError is from
|
|
535
|
+
// a trap or not based on a hidden field within the object. So at the moment
|
|
536
|
+
// we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
|
|
537
|
+
// allows this in the wasm spec.
|
|
538
|
+
|
|
539
|
+
// Suppress closure compiler warning here. Closure compiler's builtin extern
|
|
540
|
+
// definition for WebAssembly.RuntimeError claims it takes no arguments even
|
|
541
|
+
// though it can.
|
|
542
|
+
// TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
|
|
543
|
+
/** @suppress {checkTypes} */
|
|
544
|
+
var e = new WebAssembly.RuntimeError(what);
|
|
545
|
+
|
|
546
|
+
readyPromiseReject?.(e);
|
|
547
|
+
// Throw the error whether or not MODULARIZE is set because abort is used
|
|
548
|
+
// in code paths apart from instantiation where an exception is expected
|
|
549
|
+
// to be thrown when abort is called.
|
|
550
|
+
throw e;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// show errors on likely calls to FS when it was not included
|
|
554
|
+
var FS = {
|
|
555
|
+
error() {
|
|
556
|
+
abort('Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM');
|
|
557
|
+
},
|
|
558
|
+
init() { FS.error() },
|
|
559
|
+
createDataFile() { FS.error() },
|
|
560
|
+
createPreloadedFile() { FS.error() },
|
|
561
|
+
createLazyFile() { FS.error() },
|
|
562
|
+
open() { FS.error() },
|
|
563
|
+
mkdev() { FS.error() },
|
|
564
|
+
registerDevice() { FS.error() },
|
|
565
|
+
analyzePath() { FS.error() },
|
|
566
|
+
|
|
567
|
+
ErrnoError() { FS.error() },
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
function createExportWrapper(name, nargs) {
|
|
572
|
+
return (...args) => {
|
|
573
|
+
assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
|
|
574
|
+
var f = wasmExports[name];
|
|
575
|
+
assert(f, `exported native function \`${name}\` not found`);
|
|
576
|
+
// Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled.
|
|
577
|
+
assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`);
|
|
578
|
+
return f(...args);
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
var wasmBinaryFile;
|
|
583
|
+
|
|
584
|
+
function findWasmBinary() {
|
|
585
|
+
|
|
586
|
+
if (Module['locateFile']) {
|
|
587
|
+
return locateFile('UnicodeWidthApproximationWASM.wasm');
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too.
|
|
591
|
+
return new URL('UnicodeWidthApproximationWASM.wasm', import.meta.url).href;
|
|
592
|
+
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function getBinarySync(file) {
|
|
596
|
+
if (file == wasmBinaryFile && wasmBinary) {
|
|
597
|
+
return new Uint8Array(wasmBinary);
|
|
598
|
+
}
|
|
599
|
+
if (readBinary) {
|
|
600
|
+
return readBinary(file);
|
|
601
|
+
}
|
|
602
|
+
// Throwing a plain string here, even though it not normally adviables since
|
|
603
|
+
// this gets turning into an `abort` in instantiateArrayBuffer.
|
|
604
|
+
throw 'both async and sync fetching of the wasm failed';
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
async function getWasmBinary(binaryFile) {
|
|
608
|
+
// If we don't have the binary yet, load it asynchronously using readAsync.
|
|
609
|
+
if (!wasmBinary) {
|
|
610
|
+
// Fetch the binary using readAsync
|
|
611
|
+
try {
|
|
612
|
+
var response = await readAsync(binaryFile);
|
|
613
|
+
return new Uint8Array(response);
|
|
614
|
+
} catch {
|
|
615
|
+
// Fall back to getBinarySync below;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// Otherwise, getBinarySync should be able to get it synchronously
|
|
620
|
+
return getBinarySync(binaryFile);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
async function instantiateArrayBuffer(binaryFile, imports) {
|
|
624
|
+
try {
|
|
625
|
+
var binary = await getWasmBinary(binaryFile);
|
|
626
|
+
var instance = await WebAssembly.instantiate(binary, imports);
|
|
627
|
+
return instance;
|
|
628
|
+
} catch (reason) {
|
|
629
|
+
err(`failed to asynchronously prepare wasm: ${reason}`);
|
|
630
|
+
|
|
631
|
+
// Warn on some common problems.
|
|
632
|
+
if (isFileURI(binaryFile)) {
|
|
633
|
+
err(`warning: Loading from a file URI (${binaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`);
|
|
634
|
+
}
|
|
635
|
+
abort(reason);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
async function instantiateAsync(binary, binaryFile, imports) {
|
|
640
|
+
if (!binary
|
|
641
|
+
// Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
|
|
642
|
+
&& !isFileURI(binaryFile)
|
|
643
|
+
// Avoid instantiateStreaming() on Node.js environment for now, as while
|
|
644
|
+
// Node.js v18.1.0 implements it, it does not have a full fetch()
|
|
645
|
+
// implementation yet.
|
|
646
|
+
//
|
|
647
|
+
// Reference:
|
|
648
|
+
// https://github.com/emscripten-core/emscripten/pull/16917
|
|
649
|
+
&& !ENVIRONMENT_IS_NODE
|
|
650
|
+
) {
|
|
651
|
+
try {
|
|
652
|
+
var response = fetch(binaryFile, { credentials: 'same-origin' });
|
|
653
|
+
var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
|
|
654
|
+
return instantiationResult;
|
|
655
|
+
} catch (reason) {
|
|
656
|
+
// We expect the most common failure cause to be a bad MIME type for the binary,
|
|
657
|
+
// in which case falling back to ArrayBuffer instantiation should work.
|
|
658
|
+
err(`wasm streaming compile failed: ${reason}`);
|
|
659
|
+
err('falling back to ArrayBuffer instantiation');
|
|
660
|
+
// fall back of instantiateArrayBuffer below
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
return instantiateArrayBuffer(binaryFile, imports);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
function getWasmImports() {
|
|
667
|
+
// prepare imports
|
|
668
|
+
var imports = {
|
|
669
|
+
'env': wasmImports,
|
|
670
|
+
'wasi_snapshot_preview1': wasmImports,
|
|
671
|
+
};
|
|
672
|
+
return imports;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// Create the wasm instance.
|
|
676
|
+
// Receives the wasm imports, returns the exports.
|
|
677
|
+
async function createWasm() {
|
|
678
|
+
// Load the wasm module and create an instance of using native support in the JS engine.
|
|
679
|
+
// handle a generated wasm instance, receiving its exports and
|
|
680
|
+
// performing other necessary setup
|
|
681
|
+
/** @param {WebAssembly.Module=} module*/
|
|
682
|
+
function receiveInstance(instance, module) {
|
|
683
|
+
wasmExports = instance.exports;
|
|
684
|
+
|
|
685
|
+
assignWasmExports(wasmExports);
|
|
686
|
+
|
|
687
|
+
updateMemoryViews();
|
|
688
|
+
|
|
689
|
+
return wasmExports;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// Prefer streaming instantiation if available.
|
|
693
|
+
// Async compilation can be confusing when an error on the page overwrites Module
|
|
694
|
+
// (for example, if the order of elements is wrong, and the one defining Module is
|
|
695
|
+
// later), so we save Module and check it later.
|
|
696
|
+
var trueModule = Module;
|
|
697
|
+
function receiveInstantiationResult(result) {
|
|
698
|
+
// 'result' is a ResultObject object which has both the module and instance.
|
|
699
|
+
// receiveInstance() will swap in the exports (to Module.asm) so they can be called
|
|
700
|
+
assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
|
|
701
|
+
trueModule = null;
|
|
702
|
+
// TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line.
|
|
703
|
+
// When the regression is fixed, can restore the above PTHREADS-enabled path.
|
|
704
|
+
return receiveInstance(result['instance']);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
var info = getWasmImports();
|
|
708
|
+
|
|
709
|
+
// User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
|
|
710
|
+
// to manually instantiate the Wasm module themselves. This allows pages to
|
|
711
|
+
// run the instantiation parallel to any other async startup actions they are
|
|
712
|
+
// performing.
|
|
713
|
+
// Also pthreads and wasm workers initialize the wasm instance through this
|
|
714
|
+
// path.
|
|
715
|
+
if (Module['instantiateWasm']) {
|
|
716
|
+
return new Promise((resolve, reject) => {
|
|
717
|
+
try {
|
|
718
|
+
Module['instantiateWasm'](info, (inst, mod) => {
|
|
719
|
+
resolve(receiveInstance(inst, mod));
|
|
720
|
+
});
|
|
721
|
+
} catch(e) {
|
|
722
|
+
err(`Module.instantiateWasm callback failed with error: ${e}`);
|
|
723
|
+
reject(e);
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
wasmBinaryFile ??= findWasmBinary();
|
|
729
|
+
var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
|
|
730
|
+
var exports = receiveInstantiationResult(result);
|
|
731
|
+
return exports;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// end include: preamble.js
|
|
735
|
+
|
|
736
|
+
// Begin JS library code
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
class ExitStatus {
|
|
740
|
+
name = 'ExitStatus';
|
|
741
|
+
constructor(status) {
|
|
742
|
+
this.message = `Program terminated with exit(${status})`;
|
|
743
|
+
this.status = status;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
var callRuntimeCallbacks = (callbacks) => {
|
|
748
|
+
while (callbacks.length > 0) {
|
|
749
|
+
// Pass the module as the first argument.
|
|
750
|
+
callbacks.shift()(Module);
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
var onPostRuns = [];
|
|
754
|
+
var addOnPostRun = (cb) => onPostRuns.push(cb);
|
|
755
|
+
|
|
756
|
+
var onPreRuns = [];
|
|
757
|
+
var addOnPreRun = (cb) => onPreRuns.push(cb);
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* @param {number} ptr
|
|
763
|
+
* @param {string} type
|
|
764
|
+
*/
|
|
765
|
+
function getValue(ptr, type = 'i8') {
|
|
766
|
+
if (type.endsWith('*')) type = '*';
|
|
767
|
+
switch (type) {
|
|
768
|
+
case 'i1': return HEAP8[ptr];
|
|
769
|
+
case 'i8': return HEAP8[ptr];
|
|
770
|
+
case 'i16': return HEAP16[((ptr)>>1)];
|
|
771
|
+
case 'i32': return HEAP32[((ptr)>>2)];
|
|
772
|
+
case 'i64': return HEAP64[((ptr)>>3)];
|
|
773
|
+
case 'float': return HEAPF32[((ptr)>>2)];
|
|
774
|
+
case 'double': return HEAPF64[((ptr)>>3)];
|
|
775
|
+
case '*': return HEAPU32[((ptr)>>2)];
|
|
776
|
+
default: abort(`invalid type for getValue: ${type}`);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
var noExitRuntime = true;
|
|
781
|
+
|
|
782
|
+
var ptrToString = (ptr) => {
|
|
783
|
+
assert(typeof ptr === 'number', `ptrToString expects a number, got ${typeof ptr}`);
|
|
784
|
+
// Convert to 32-bit unsigned value
|
|
785
|
+
ptr >>>= 0;
|
|
786
|
+
return '0x' + ptr.toString(16).padStart(8, '0');
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* @param {number} ptr
|
|
792
|
+
* @param {number} value
|
|
793
|
+
* @param {string} type
|
|
794
|
+
*/
|
|
795
|
+
function setValue(ptr, value, type = 'i8') {
|
|
796
|
+
if (type.endsWith('*')) type = '*';
|
|
797
|
+
switch (type) {
|
|
798
|
+
case 'i1': HEAP8[ptr] = value; break;
|
|
799
|
+
case 'i8': HEAP8[ptr] = value; break;
|
|
800
|
+
case 'i16': HEAP16[((ptr)>>1)] = value; break;
|
|
801
|
+
case 'i32': HEAP32[((ptr)>>2)] = value; break;
|
|
802
|
+
case 'i64': HEAP64[((ptr)>>3)] = BigInt(value); break;
|
|
803
|
+
case 'float': HEAPF32[((ptr)>>2)] = value; break;
|
|
804
|
+
case 'double': HEAPF64[((ptr)>>3)] = value; break;
|
|
805
|
+
case '*': HEAPU32[((ptr)>>2)] = value; break;
|
|
806
|
+
default: abort(`invalid type for setValue: ${type}`);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
var stackRestore = (val) => __emscripten_stack_restore(val);
|
|
811
|
+
|
|
812
|
+
var stackSave = () => _emscripten_stack_get_current();
|
|
813
|
+
|
|
814
|
+
var warnOnce = (text) => {
|
|
815
|
+
warnOnce.shown ||= {};
|
|
816
|
+
if (!warnOnce.shown[text]) {
|
|
817
|
+
warnOnce.shown[text] = 1;
|
|
818
|
+
if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text;
|
|
819
|
+
err(text);
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
var UTF8Decoder = globalThis.TextDecoder && new TextDecoder();
|
|
826
|
+
|
|
827
|
+
var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
828
|
+
var maxIdx = idx + maxBytesToRead;
|
|
829
|
+
if (ignoreNul) return maxIdx;
|
|
830
|
+
// TextDecoder needs to know the byte length in advance, it doesn't stop on
|
|
831
|
+
// null terminator by itself.
|
|
832
|
+
// As a tiny code save trick, compare idx against maxIdx using a negation,
|
|
833
|
+
// so that maxBytesToRead=undefined/NaN means Infinity.
|
|
834
|
+
while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
|
|
835
|
+
return idx;
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
|
|
841
|
+
* array that contains uint8 values, returns a copy of that string as a
|
|
842
|
+
* Javascript String object.
|
|
843
|
+
* heapOrArray is either a regular array, or a JavaScript typed array view.
|
|
844
|
+
* @param {number=} idx
|
|
845
|
+
* @param {number=} maxBytesToRead
|
|
846
|
+
* @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
|
|
847
|
+
* @return {string}
|
|
848
|
+
*/
|
|
849
|
+
var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => {
|
|
850
|
+
|
|
851
|
+
var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul);
|
|
852
|
+
|
|
853
|
+
// When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it.
|
|
854
|
+
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
855
|
+
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
|
|
856
|
+
}
|
|
857
|
+
var str = '';
|
|
858
|
+
while (idx < endPtr) {
|
|
859
|
+
// For UTF8 byte structure, see:
|
|
860
|
+
// http://en.wikipedia.org/wiki/UTF-8#Description
|
|
861
|
+
// https://www.ietf.org/rfc/rfc2279.txt
|
|
862
|
+
// https://tools.ietf.org/html/rfc3629
|
|
863
|
+
var u0 = heapOrArray[idx++];
|
|
864
|
+
if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
|
|
865
|
+
var u1 = heapOrArray[idx++] & 63;
|
|
866
|
+
if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
|
|
867
|
+
var u2 = heapOrArray[idx++] & 63;
|
|
868
|
+
if ((u0 & 0xF0) == 0xE0) {
|
|
869
|
+
u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
|
|
870
|
+
} else {
|
|
871
|
+
if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte ' + ptrToString(u0) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!');
|
|
872
|
+
u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
if (u0 < 0x10000) {
|
|
876
|
+
str += String.fromCharCode(u0);
|
|
877
|
+
} else {
|
|
878
|
+
var ch = u0 - 0x10000;
|
|
879
|
+
str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return str;
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
|
|
887
|
+
* emscripten HEAP, returns a copy of that string as a Javascript String object.
|
|
888
|
+
*
|
|
889
|
+
* @param {number} ptr
|
|
890
|
+
* @param {number=} maxBytesToRead - An optional length that specifies the
|
|
891
|
+
* maximum number of bytes to read. You can omit this parameter to scan the
|
|
892
|
+
* string until the first 0 byte. If maxBytesToRead is passed, and the string
|
|
893
|
+
* at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
|
|
894
|
+
* string will cut short at that byte index.
|
|
895
|
+
* @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
|
|
896
|
+
* @return {string}
|
|
897
|
+
*/
|
|
898
|
+
var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
|
|
899
|
+
assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
|
|
900
|
+
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : '';
|
|
901
|
+
};
|
|
902
|
+
var ___assert_fail = (condition, filename, line, func) =>
|
|
903
|
+
abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
|
|
904
|
+
|
|
905
|
+
var exceptionCaught = [];
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
var uncaughtExceptionCount = 0;
|
|
910
|
+
var ___cxa_begin_catch = (ptr) => {
|
|
911
|
+
var info = new ExceptionInfo(ptr);
|
|
912
|
+
if (!info.get_caught()) {
|
|
913
|
+
info.set_caught(true);
|
|
914
|
+
uncaughtExceptionCount--;
|
|
915
|
+
}
|
|
916
|
+
info.set_rethrown(false);
|
|
917
|
+
exceptionCaught.push(info);
|
|
918
|
+
___cxa_increment_exception_refcount(ptr);
|
|
919
|
+
return ___cxa_get_exception_ptr(ptr);
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
var exceptionLast = 0;
|
|
923
|
+
|
|
924
|
+
class ExceptionInfo {
|
|
925
|
+
// excPtr - Thrown object pointer to wrap. Metadata pointer is calculated from it.
|
|
926
|
+
constructor(excPtr) {
|
|
927
|
+
this.excPtr = excPtr;
|
|
928
|
+
this.ptr = excPtr - 24;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
set_type(type) {
|
|
932
|
+
HEAPU32[(((this.ptr)+(4))>>2)] = type;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
get_type() {
|
|
936
|
+
return HEAPU32[(((this.ptr)+(4))>>2)];
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
set_destructor(destructor) {
|
|
940
|
+
HEAPU32[(((this.ptr)+(8))>>2)] = destructor;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
get_destructor() {
|
|
944
|
+
return HEAPU32[(((this.ptr)+(8))>>2)];
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
set_caught(caught) {
|
|
948
|
+
caught = caught ? 1 : 0;
|
|
949
|
+
HEAP8[(this.ptr)+(12)] = caught;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
get_caught() {
|
|
953
|
+
return HEAP8[(this.ptr)+(12)] != 0;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
set_rethrown(rethrown) {
|
|
957
|
+
rethrown = rethrown ? 1 : 0;
|
|
958
|
+
HEAP8[(this.ptr)+(13)] = rethrown;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
get_rethrown() {
|
|
962
|
+
return HEAP8[(this.ptr)+(13)] != 0;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// Initialize native structure fields. Should be called once after allocated.
|
|
966
|
+
init(type, destructor) {
|
|
967
|
+
this.set_adjusted_ptr(0);
|
|
968
|
+
this.set_type(type);
|
|
969
|
+
this.set_destructor(destructor);
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
set_adjusted_ptr(adjustedPtr) {
|
|
973
|
+
HEAPU32[(((this.ptr)+(16))>>2)] = adjustedPtr;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
get_adjusted_ptr() {
|
|
977
|
+
return HEAPU32[(((this.ptr)+(16))>>2)];
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
var setTempRet0 = (val) => __emscripten_tempret_set(val);
|
|
983
|
+
var findMatchingCatch = (args) => {
|
|
984
|
+
var thrown =
|
|
985
|
+
exceptionLast?.excPtr;
|
|
986
|
+
if (!thrown) {
|
|
987
|
+
// just pass through the null ptr
|
|
988
|
+
setTempRet0(0);
|
|
989
|
+
return 0;
|
|
990
|
+
}
|
|
991
|
+
var info = new ExceptionInfo(thrown);
|
|
992
|
+
info.set_adjusted_ptr(thrown);
|
|
993
|
+
var thrownType = info.get_type();
|
|
994
|
+
if (!thrownType) {
|
|
995
|
+
// just pass through the thrown ptr
|
|
996
|
+
setTempRet0(0);
|
|
997
|
+
return thrown;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// can_catch receives a **, add indirection
|
|
1001
|
+
// The different catch blocks are denoted by different types.
|
|
1002
|
+
// Due to inheritance, those types may not precisely match the
|
|
1003
|
+
// type of the thrown object. Find one which matches, and
|
|
1004
|
+
// return the type of the catch block which should be called.
|
|
1005
|
+
for (var caughtType of args) {
|
|
1006
|
+
if (caughtType === 0 || caughtType === thrownType) {
|
|
1007
|
+
// Catch all clause matched or exactly the same type is caught
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
var adjusted_ptr_addr = info.ptr + 16;
|
|
1011
|
+
if (___cxa_can_catch(caughtType, thrownType, adjusted_ptr_addr)) {
|
|
1012
|
+
setTempRet0(caughtType);
|
|
1013
|
+
return thrown;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
setTempRet0(thrownType);
|
|
1017
|
+
return thrown;
|
|
1018
|
+
};
|
|
1019
|
+
var ___cxa_find_matching_catch_2 = () => findMatchingCatch([]);
|
|
1020
|
+
|
|
1021
|
+
var ___cxa_find_matching_catch_3 = (arg0) => findMatchingCatch([arg0]);
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
var ___cxa_throw = (ptr, type, destructor) => {
|
|
1026
|
+
var info = new ExceptionInfo(ptr);
|
|
1027
|
+
// Initialize ExceptionInfo content after it was allocated in __cxa_allocate_exception.
|
|
1028
|
+
info.init(type, destructor);
|
|
1029
|
+
exceptionLast = new CppException(ptr);
|
|
1030
|
+
uncaughtExceptionCount++;
|
|
1031
|
+
throw exceptionLast;
|
|
1032
|
+
};
|
|
1033
|
+
|
|
1034
|
+
var ___resumeException = (ptr) => {
|
|
1035
|
+
if (!exceptionLast) {
|
|
1036
|
+
exceptionLast = new CppException(ptr);
|
|
1037
|
+
}
|
|
1038
|
+
throw exceptionLast;
|
|
1039
|
+
};
|
|
1040
|
+
|
|
1041
|
+
var __abort_js = () =>
|
|
1042
|
+
abort('native code called abort()');
|
|
1043
|
+
|
|
1044
|
+
var AsciiToString = (ptr) => {
|
|
1045
|
+
var str = '';
|
|
1046
|
+
while (1) {
|
|
1047
|
+
var ch = HEAPU8[ptr++];
|
|
1048
|
+
if (!ch) return str;
|
|
1049
|
+
str += String.fromCharCode(ch);
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
var awaitingDependencies = {
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
var registeredTypes = {
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
var typeDependencies = {
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
var BindingError = class BindingError extends Error { constructor(message) { super(message); this.name = 'BindingError'; }};
|
|
1063
|
+
var throwBindingError = (message) => { throw new BindingError(message); };
|
|
1064
|
+
/** @param {Object=} options */
|
|
1065
|
+
function sharedRegisterType(rawType, registeredInstance, options = {}) {
|
|
1066
|
+
var name = registeredInstance.name;
|
|
1067
|
+
if (!rawType) {
|
|
1068
|
+
throwBindingError(`type "${name}" must have a positive integer typeid pointer`);
|
|
1069
|
+
}
|
|
1070
|
+
if (registeredTypes.hasOwnProperty(rawType)) {
|
|
1071
|
+
if (options.ignoreDuplicateRegistrations) {
|
|
1072
|
+
return;
|
|
1073
|
+
} else {
|
|
1074
|
+
throwBindingError(`Cannot register type '${name}' twice`);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
registeredTypes[rawType] = registeredInstance;
|
|
1079
|
+
delete typeDependencies[rawType];
|
|
1080
|
+
|
|
1081
|
+
if (awaitingDependencies.hasOwnProperty(rawType)) {
|
|
1082
|
+
var callbacks = awaitingDependencies[rawType];
|
|
1083
|
+
delete awaitingDependencies[rawType];
|
|
1084
|
+
callbacks.forEach((cb) => cb());
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
/** @param {Object=} options */
|
|
1088
|
+
function registerType(rawType, registeredInstance, options = {}) {
|
|
1089
|
+
return sharedRegisterType(rawType, registeredInstance, options);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
var integerReadValueFromPointer = (name, width, signed) => {
|
|
1093
|
+
// integers are quite common, so generate very specialized functions
|
|
1094
|
+
switch (width) {
|
|
1095
|
+
case 1: return signed ?
|
|
1096
|
+
(pointer) => HEAP8[pointer] :
|
|
1097
|
+
(pointer) => HEAPU8[pointer];
|
|
1098
|
+
case 2: return signed ?
|
|
1099
|
+
(pointer) => HEAP16[((pointer)>>1)] :
|
|
1100
|
+
(pointer) => HEAPU16[((pointer)>>1)]
|
|
1101
|
+
case 4: return signed ?
|
|
1102
|
+
(pointer) => HEAP32[((pointer)>>2)] :
|
|
1103
|
+
(pointer) => HEAPU32[((pointer)>>2)]
|
|
1104
|
+
case 8: return signed ?
|
|
1105
|
+
(pointer) => HEAP64[((pointer)>>3)] :
|
|
1106
|
+
(pointer) => HEAPU64[((pointer)>>3)]
|
|
1107
|
+
default:
|
|
1108
|
+
throw new TypeError(`invalid integer width (${width}): ${name}`);
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
var embindRepr = (v) => {
|
|
1113
|
+
if (v === null) {
|
|
1114
|
+
return 'null';
|
|
1115
|
+
}
|
|
1116
|
+
var t = typeof v;
|
|
1117
|
+
if (t === 'object' || t === 'array' || t === 'function') {
|
|
1118
|
+
return v.toString();
|
|
1119
|
+
} else {
|
|
1120
|
+
return '' + v;
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
var assertIntegerRange = (typeName, value, minRange, maxRange) => {
|
|
1125
|
+
if (value < minRange || value > maxRange) {
|
|
1126
|
+
throw new TypeError(`Passing a number "${embindRepr(value)}" from JS side to C/C++ side to an argument of type "${typeName}", which is outside the valid range [${minRange}, ${maxRange}]!`);
|
|
1127
|
+
}
|
|
1128
|
+
};
|
|
1129
|
+
/** @suppress {globalThis} */
|
|
1130
|
+
var __embind_register_bigint = (primitiveType, name, size, minRange, maxRange) => {
|
|
1131
|
+
name = AsciiToString(name);
|
|
1132
|
+
|
|
1133
|
+
const isUnsignedType = minRange === 0n;
|
|
1134
|
+
|
|
1135
|
+
let fromWireType = (value) => value;
|
|
1136
|
+
if (isUnsignedType) {
|
|
1137
|
+
// uint64 get converted to int64 in ABI, fix them up like we do for 32-bit integers.
|
|
1138
|
+
const bitSize = size * 8;
|
|
1139
|
+
fromWireType = (value) => {
|
|
1140
|
+
return BigInt.asUintN(bitSize, value);
|
|
1141
|
+
}
|
|
1142
|
+
maxRange = fromWireType(maxRange);
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
registerType(primitiveType, {
|
|
1146
|
+
name,
|
|
1147
|
+
fromWireType: fromWireType,
|
|
1148
|
+
toWireType: (destructors, value) => {
|
|
1149
|
+
if (typeof value == "number") {
|
|
1150
|
+
value = BigInt(value);
|
|
1151
|
+
}
|
|
1152
|
+
else if (typeof value != "bigint") {
|
|
1153
|
+
throw new TypeError(`Cannot convert "${embindRepr(value)}" to ${this.name}`);
|
|
1154
|
+
}
|
|
1155
|
+
assertIntegerRange(name, value, minRange, maxRange);
|
|
1156
|
+
return value;
|
|
1157
|
+
},
|
|
1158
|
+
readValueFromPointer: integerReadValueFromPointer(name, size, !isUnsignedType),
|
|
1159
|
+
destructorFunction: null, // This type does not need a destructor
|
|
1160
|
+
});
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
/** @suppress {globalThis} */
|
|
1165
|
+
var __embind_register_bool = (rawType, name, trueValue, falseValue) => {
|
|
1166
|
+
name = AsciiToString(name);
|
|
1167
|
+
registerType(rawType, {
|
|
1168
|
+
name,
|
|
1169
|
+
fromWireType: function(wt) {
|
|
1170
|
+
// ambiguous emscripten ABI: sometimes return values are
|
|
1171
|
+
// true or false, and sometimes integers (0 or 1)
|
|
1172
|
+
return !!wt;
|
|
1173
|
+
},
|
|
1174
|
+
toWireType: function(destructors, o) {
|
|
1175
|
+
return o ? trueValue : falseValue;
|
|
1176
|
+
},
|
|
1177
|
+
readValueFromPointer: function(pointer) {
|
|
1178
|
+
return this.fromWireType(HEAPU8[pointer]);
|
|
1179
|
+
},
|
|
1180
|
+
destructorFunction: null, // This type does not need a destructor
|
|
1181
|
+
});
|
|
1182
|
+
};
|
|
1183
|
+
|
|
1184
|
+
|
|
1185
|
+
var emval_freelist = [];
|
|
1186
|
+
|
|
1187
|
+
var emval_handles = [0,1,,1,null,1,true,1,false,1];
|
|
1188
|
+
var __emval_decref = (handle) => {
|
|
1189
|
+
if (handle > 9 && 0 === --emval_handles[handle + 1]) {
|
|
1190
|
+
assert(emval_handles[handle] !== undefined, `Decref for unallocated handle.`);
|
|
1191
|
+
emval_handles[handle] = undefined;
|
|
1192
|
+
emval_freelist.push(handle);
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
var Emval = {
|
|
1199
|
+
toValue:(handle) => {
|
|
1200
|
+
if (!handle) {
|
|
1201
|
+
throwBindingError(`Cannot use deleted val. handle = ${handle}`);
|
|
1202
|
+
}
|
|
1203
|
+
// handle 2 is supposed to be `undefined`.
|
|
1204
|
+
assert(handle === 2 || emval_handles[handle] !== undefined && handle % 2 === 0, `invalid handle: ${handle}`);
|
|
1205
|
+
return emval_handles[handle];
|
|
1206
|
+
},
|
|
1207
|
+
toHandle:(value) => {
|
|
1208
|
+
switch (value) {
|
|
1209
|
+
case undefined: return 2;
|
|
1210
|
+
case null: return 4;
|
|
1211
|
+
case true: return 6;
|
|
1212
|
+
case false: return 8;
|
|
1213
|
+
default:{
|
|
1214
|
+
const handle = emval_freelist.pop() || emval_handles.length;
|
|
1215
|
+
emval_handles[handle] = value;
|
|
1216
|
+
emval_handles[handle + 1] = 1;
|
|
1217
|
+
return handle;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
},
|
|
1221
|
+
};
|
|
1222
|
+
|
|
1223
|
+
/** @suppress {globalThis} */
|
|
1224
|
+
function readPointer(pointer) {
|
|
1225
|
+
return this.fromWireType(HEAPU32[((pointer)>>2)]);
|
|
1226
|
+
}
|
|
1227
|
+
var EmValType = {
|
|
1228
|
+
name: 'emscripten::val',
|
|
1229
|
+
fromWireType: (handle) => {
|
|
1230
|
+
var rv = Emval.toValue(handle);
|
|
1231
|
+
__emval_decref(handle);
|
|
1232
|
+
return rv;
|
|
1233
|
+
},
|
|
1234
|
+
toWireType: (destructors, value) => Emval.toHandle(value),
|
|
1235
|
+
readValueFromPointer: readPointer,
|
|
1236
|
+
destructorFunction: null, // This type does not need a destructor
|
|
1237
|
+
|
|
1238
|
+
// TODO: do we need a deleteObject here? write a test where
|
|
1239
|
+
// emval is passed into JS via an interface
|
|
1240
|
+
};
|
|
1241
|
+
var __embind_register_emval = (rawType) => registerType(rawType, EmValType);
|
|
1242
|
+
|
|
1243
|
+
var floatReadValueFromPointer = (name, width) => {
|
|
1244
|
+
switch (width) {
|
|
1245
|
+
case 4: return function(pointer) {
|
|
1246
|
+
return this.fromWireType(HEAPF32[((pointer)>>2)]);
|
|
1247
|
+
};
|
|
1248
|
+
case 8: return function(pointer) {
|
|
1249
|
+
return this.fromWireType(HEAPF64[((pointer)>>3)]);
|
|
1250
|
+
};
|
|
1251
|
+
default:
|
|
1252
|
+
throw new TypeError(`invalid float width (${width}): ${name}`);
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
var __embind_register_float = (rawType, name, size) => {
|
|
1259
|
+
name = AsciiToString(name);
|
|
1260
|
+
registerType(rawType, {
|
|
1261
|
+
name,
|
|
1262
|
+
fromWireType: (value) => value,
|
|
1263
|
+
toWireType: (destructors, value) => {
|
|
1264
|
+
if (typeof value != "number" && typeof value != "boolean") {
|
|
1265
|
+
throw new TypeError(`Cannot convert ${embindRepr(value)} to ${this.name}`);
|
|
1266
|
+
}
|
|
1267
|
+
// The VM will perform JS to Wasm value conversion, according to the spec:
|
|
1268
|
+
// https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
|
|
1269
|
+
return value;
|
|
1270
|
+
},
|
|
1271
|
+
readValueFromPointer: floatReadValueFromPointer(name, size),
|
|
1272
|
+
destructorFunction: null, // This type does not need a destructor
|
|
1273
|
+
});
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
var createNamedFunction = (name, func) => Object.defineProperty(func, 'name', { value: name });
|
|
1277
|
+
|
|
1278
|
+
var runDestructors = (destructors) => {
|
|
1279
|
+
while (destructors.length) {
|
|
1280
|
+
var ptr = destructors.pop();
|
|
1281
|
+
var del = destructors.pop();
|
|
1282
|
+
del(ptr);
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
|
|
1287
|
+
function usesDestructorStack(argTypes) {
|
|
1288
|
+
// Skip return value at index 0 - it's not deleted here.
|
|
1289
|
+
for (var i = 1; i < argTypes.length; ++i) {
|
|
1290
|
+
// The type does not define a destructor function - must use dynamic stack
|
|
1291
|
+
if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) {
|
|
1292
|
+
return true;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
return false;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
|
|
1299
|
+
function checkArgCount(numArgs, minArgs, maxArgs, humanName, throwBindingError) {
|
|
1300
|
+
if (numArgs < minArgs || numArgs > maxArgs) {
|
|
1301
|
+
var argCountMessage = minArgs == maxArgs ? minArgs : `${minArgs} to ${maxArgs}`;
|
|
1302
|
+
throwBindingError(`function ${humanName} called with ${numArgs} arguments, expected ${argCountMessage}`);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
function createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync) {
|
|
1306
|
+
var needsDestructorStack = usesDestructorStack(argTypes);
|
|
1307
|
+
var argCount = argTypes.length - 2;
|
|
1308
|
+
var argsList = [];
|
|
1309
|
+
var argsListWired = ['fn'];
|
|
1310
|
+
if (isClassMethodFunc) {
|
|
1311
|
+
argsListWired.push('thisWired');
|
|
1312
|
+
}
|
|
1313
|
+
for (var i = 0; i < argCount; ++i) {
|
|
1314
|
+
argsList.push(`arg${i}`)
|
|
1315
|
+
argsListWired.push(`arg${i}Wired`)
|
|
1316
|
+
}
|
|
1317
|
+
argsList = argsList.join(',')
|
|
1318
|
+
argsListWired = argsListWired.join(',')
|
|
1319
|
+
|
|
1320
|
+
var invokerFnBody = `return function (${argsList}) {\n`;
|
|
1321
|
+
|
|
1322
|
+
invokerFnBody += "checkArgCount(arguments.length, minArgs, maxArgs, humanName, throwBindingError);\n";
|
|
1323
|
+
|
|
1324
|
+
if (needsDestructorStack) {
|
|
1325
|
+
invokerFnBody += "var destructors = [];\n";
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
var dtorStack = needsDestructorStack ? "destructors" : "null";
|
|
1329
|
+
var args1 = ["humanName", "throwBindingError", "invoker", "fn", "runDestructors", "fromRetWire", "toClassParamWire"];
|
|
1330
|
+
|
|
1331
|
+
if (isClassMethodFunc) {
|
|
1332
|
+
invokerFnBody += `var thisWired = toClassParamWire(${dtorStack}, this);\n`;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
for (var i = 0; i < argCount; ++i) {
|
|
1336
|
+
var argName = `toArg${i}Wire`;
|
|
1337
|
+
invokerFnBody += `var arg${i}Wired = ${argName}(${dtorStack}, arg${i});\n`;
|
|
1338
|
+
args1.push(argName);
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
invokerFnBody += (returns || isAsync ? "var rv = ":"") + `invoker(${argsListWired});\n`;
|
|
1342
|
+
|
|
1343
|
+
var returnVal = returns ? "rv" : "";
|
|
1344
|
+
|
|
1345
|
+
if (needsDestructorStack) {
|
|
1346
|
+
invokerFnBody += "runDestructors(destructors);\n";
|
|
1347
|
+
} else {
|
|
1348
|
+
for (var i = isClassMethodFunc?1:2; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
|
|
1349
|
+
var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
|
|
1350
|
+
if (argTypes[i].destructorFunction !== null) {
|
|
1351
|
+
invokerFnBody += `${paramName}_dtor(${paramName});\n`;
|
|
1352
|
+
args1.push(`${paramName}_dtor`);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
if (returns) {
|
|
1358
|
+
invokerFnBody += "var ret = fromRetWire(rv);\n" +
|
|
1359
|
+
"return ret;\n";
|
|
1360
|
+
} else {
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
invokerFnBody += "}\n";
|
|
1364
|
+
|
|
1365
|
+
args1.push('checkArgCount', 'minArgs', 'maxArgs');
|
|
1366
|
+
invokerFnBody = `if (arguments.length !== ${args1.length}){ throw new Error(humanName + "Expected ${args1.length} closure arguments " + arguments.length + " given."); }\n${invokerFnBody}`;
|
|
1367
|
+
return new Function(args1, invokerFnBody);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
function getRequiredArgCount(argTypes) {
|
|
1371
|
+
var requiredArgCount = argTypes.length - 2;
|
|
1372
|
+
for (var i = argTypes.length - 1; i >= 2; --i) {
|
|
1373
|
+
if (!argTypes[i].optional) {
|
|
1374
|
+
break;
|
|
1375
|
+
}
|
|
1376
|
+
requiredArgCount--;
|
|
1377
|
+
}
|
|
1378
|
+
return requiredArgCount;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, /** boolean= */ isAsync) {
|
|
1382
|
+
// humanName: a human-readable string name for the function to be generated.
|
|
1383
|
+
// argTypes: An array that contains the embind type objects for all types in the function signature.
|
|
1384
|
+
// argTypes[0] is the type object for the function return value.
|
|
1385
|
+
// argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
|
|
1386
|
+
// argTypes[2...] are the actual function parameters.
|
|
1387
|
+
// classType: The embind type object for the class to be bound, or null if this is not a method of a class.
|
|
1388
|
+
// cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
|
|
1389
|
+
// cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
|
|
1390
|
+
// isAsync: Optional. If true, returns an async function. Async bindings are only supported with JSPI.
|
|
1391
|
+
var argCount = argTypes.length;
|
|
1392
|
+
|
|
1393
|
+
if (argCount < 2) {
|
|
1394
|
+
throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
assert(!isAsync, 'Async bindings are only supported with JSPI.');
|
|
1398
|
+
var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
|
|
1399
|
+
|
|
1400
|
+
// Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
|
|
1401
|
+
// TODO: This omits argument count check - enable only at -O3 or similar.
|
|
1402
|
+
// if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
|
|
1403
|
+
// return FUNCTION_TABLE[fn];
|
|
1404
|
+
// }
|
|
1405
|
+
|
|
1406
|
+
// Determine if we need to use a dynamic stack to store the destructors for the function parameters.
|
|
1407
|
+
// TODO: Remove this completely once all function invokers are being dynamically generated.
|
|
1408
|
+
var needsDestructorStack = usesDestructorStack(argTypes);
|
|
1409
|
+
|
|
1410
|
+
var returns = !argTypes[0].isVoid;
|
|
1411
|
+
|
|
1412
|
+
var expectedArgCount = argCount - 2;
|
|
1413
|
+
var minArgs = getRequiredArgCount(argTypes);
|
|
1414
|
+
// Builld the arguments that will be passed into the closure around the invoker
|
|
1415
|
+
// function.
|
|
1416
|
+
var retType = argTypes[0];
|
|
1417
|
+
var instType = argTypes[1];
|
|
1418
|
+
var closureArgs = [humanName, throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, retType.fromWireType.bind(retType), instType?.toWireType.bind(instType)];
|
|
1419
|
+
for (var i = 2; i < argCount; ++i) {
|
|
1420
|
+
var argType = argTypes[i];
|
|
1421
|
+
closureArgs.push(argType.toWireType.bind(argType));
|
|
1422
|
+
}
|
|
1423
|
+
if (!needsDestructorStack) {
|
|
1424
|
+
// Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
|
|
1425
|
+
for (var i = isClassMethodFunc?1:2; i < argTypes.length; ++i) {
|
|
1426
|
+
if (argTypes[i].destructorFunction !== null) {
|
|
1427
|
+
closureArgs.push(argTypes[i].destructorFunction);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
closureArgs.push(checkArgCount, minArgs, expectedArgCount);
|
|
1432
|
+
|
|
1433
|
+
let invokerFactory = createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync);
|
|
1434
|
+
var invokerFn = invokerFactory(...closureArgs);
|
|
1435
|
+
return createNamedFunction(humanName, invokerFn);
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
var ensureOverloadTable = (proto, methodName, humanName) => {
|
|
1439
|
+
if (undefined === proto[methodName].overloadTable) {
|
|
1440
|
+
var prevFunc = proto[methodName];
|
|
1441
|
+
// Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
|
|
1442
|
+
proto[methodName] = function(...args) {
|
|
1443
|
+
// TODO This check can be removed in -O3 level "unsafe" optimizations.
|
|
1444
|
+
if (!proto[methodName].overloadTable.hasOwnProperty(args.length)) {
|
|
1445
|
+
throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`);
|
|
1446
|
+
}
|
|
1447
|
+
return proto[methodName].overloadTable[args.length].apply(this, args);
|
|
1448
|
+
};
|
|
1449
|
+
// Move the previous function into the overload table.
|
|
1450
|
+
proto[methodName].overloadTable = [];
|
|
1451
|
+
proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
|
|
1455
|
+
/** @param {number=} numArguments */
|
|
1456
|
+
var exposePublicSymbol = (name, value, numArguments) => {
|
|
1457
|
+
if (Module.hasOwnProperty(name)) {
|
|
1458
|
+
if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
|
|
1459
|
+
throwBindingError(`Cannot register public name '${name}' twice`);
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
// We are exposing a function with the same name as an existing function. Create an overload table and a function selector
|
|
1463
|
+
// that routes between the two.
|
|
1464
|
+
ensureOverloadTable(Module, name, name);
|
|
1465
|
+
if (Module[name].overloadTable.hasOwnProperty(numArguments)) {
|
|
1466
|
+
throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`);
|
|
1467
|
+
}
|
|
1468
|
+
// Add the new function into the overload table.
|
|
1469
|
+
Module[name].overloadTable[numArguments] = value;
|
|
1470
|
+
} else {
|
|
1471
|
+
Module[name] = value;
|
|
1472
|
+
Module[name].argCount = numArguments;
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
var heap32VectorToArray = (count, firstElement) => {
|
|
1477
|
+
var array = [];
|
|
1478
|
+
for (var i = 0; i < count; i++) {
|
|
1479
|
+
// TODO(https://github.com/emscripten-core/emscripten/issues/17310):
|
|
1480
|
+
// Find a way to hoist the `>> 2` or `>> 3` out of this loop.
|
|
1481
|
+
array.push(HEAPU32[(((firstElement)+(i * 4))>>2)]);
|
|
1482
|
+
}
|
|
1483
|
+
return array;
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
|
|
1487
|
+
var InternalError = class InternalError extends Error { constructor(message) { super(message); this.name = 'InternalError'; }};
|
|
1488
|
+
var throwInternalError = (message) => { throw new InternalError(message); };
|
|
1489
|
+
/** @param {number=} numArguments */
|
|
1490
|
+
var replacePublicSymbol = (name, value, numArguments) => {
|
|
1491
|
+
if (!Module.hasOwnProperty(name)) {
|
|
1492
|
+
throwInternalError('Replacing nonexistent public symbol');
|
|
1493
|
+
}
|
|
1494
|
+
// If there's an overload table for this symbol, replace the symbol in the overload table instead.
|
|
1495
|
+
if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
|
|
1496
|
+
Module[name].overloadTable[numArguments] = value;
|
|
1497
|
+
} else {
|
|
1498
|
+
Module[name] = value;
|
|
1499
|
+
Module[name].argCount = numArguments;
|
|
1500
|
+
}
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
var wasmTableMirror = [];
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
var getWasmTableEntry = (funcPtr) => {
|
|
1509
|
+
var func = wasmTableMirror[funcPtr];
|
|
1510
|
+
if (!func) {
|
|
1511
|
+
/** @suppress {checkTypes} */
|
|
1512
|
+
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
1513
|
+
}
|
|
1514
|
+
/** @suppress {checkTypes} */
|
|
1515
|
+
assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
|
|
1516
|
+
return func;
|
|
1517
|
+
};
|
|
1518
|
+
var embind__requireFunction = (signature, rawFunction, isAsync = false) => {
|
|
1519
|
+
assert(!isAsync, 'Async bindings are only supported with JSPI.');
|
|
1520
|
+
|
|
1521
|
+
signature = AsciiToString(signature);
|
|
1522
|
+
|
|
1523
|
+
function makeDynCaller() {
|
|
1524
|
+
var rtn = getWasmTableEntry(rawFunction);
|
|
1525
|
+
return rtn;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
var fp = makeDynCaller();
|
|
1529
|
+
if (typeof fp != 'function') {
|
|
1530
|
+
throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`);
|
|
1531
|
+
}
|
|
1532
|
+
return fp;
|
|
1533
|
+
};
|
|
1534
|
+
|
|
1535
|
+
|
|
1536
|
+
|
|
1537
|
+
class UnboundTypeError extends Error {}
|
|
1538
|
+
|
|
1539
|
+
|
|
1540
|
+
|
|
1541
|
+
var getTypeName = (type) => {
|
|
1542
|
+
var ptr = ___getTypeName(type);
|
|
1543
|
+
var rv = AsciiToString(ptr);
|
|
1544
|
+
_free(ptr);
|
|
1545
|
+
return rv;
|
|
1546
|
+
};
|
|
1547
|
+
var throwUnboundTypeError = (message, types) => {
|
|
1548
|
+
var unboundTypes = [];
|
|
1549
|
+
var seen = {};
|
|
1550
|
+
function visit(type) {
|
|
1551
|
+
if (seen[type]) {
|
|
1552
|
+
return;
|
|
1553
|
+
}
|
|
1554
|
+
if (registeredTypes[type]) {
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
if (typeDependencies[type]) {
|
|
1558
|
+
typeDependencies[type].forEach(visit);
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1561
|
+
unboundTypes.push(type);
|
|
1562
|
+
seen[type] = true;
|
|
1563
|
+
}
|
|
1564
|
+
types.forEach(visit);
|
|
1565
|
+
|
|
1566
|
+
throw new UnboundTypeError(`${message}: ` + unboundTypes.map(getTypeName).join([', ']));
|
|
1567
|
+
};
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
|
|
1571
|
+
|
|
1572
|
+
var whenDependentTypesAreResolved = (myTypes, dependentTypes, getTypeConverters) => {
|
|
1573
|
+
myTypes.forEach((type) => typeDependencies[type] = dependentTypes);
|
|
1574
|
+
|
|
1575
|
+
function onComplete(typeConverters) {
|
|
1576
|
+
var myTypeConverters = getTypeConverters(typeConverters);
|
|
1577
|
+
if (myTypeConverters.length !== myTypes.length) {
|
|
1578
|
+
throwInternalError('Mismatched type converter count');
|
|
1579
|
+
}
|
|
1580
|
+
for (var i = 0; i < myTypes.length; ++i) {
|
|
1581
|
+
registerType(myTypes[i], myTypeConverters[i]);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
var typeConverters = new Array(dependentTypes.length);
|
|
1586
|
+
var unregisteredTypes = [];
|
|
1587
|
+
var registered = 0;
|
|
1588
|
+
for (let [i, dt] of dependentTypes.entries()) {
|
|
1589
|
+
if (registeredTypes.hasOwnProperty(dt)) {
|
|
1590
|
+
typeConverters[i] = registeredTypes[dt];
|
|
1591
|
+
} else {
|
|
1592
|
+
unregisteredTypes.push(dt);
|
|
1593
|
+
if (!awaitingDependencies.hasOwnProperty(dt)) {
|
|
1594
|
+
awaitingDependencies[dt] = [];
|
|
1595
|
+
}
|
|
1596
|
+
awaitingDependencies[dt].push(() => {
|
|
1597
|
+
typeConverters[i] = registeredTypes[dt];
|
|
1598
|
+
++registered;
|
|
1599
|
+
if (registered === unregisteredTypes.length) {
|
|
1600
|
+
onComplete(typeConverters);
|
|
1601
|
+
}
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
if (0 === unregisteredTypes.length) {
|
|
1606
|
+
onComplete(typeConverters);
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
1609
|
+
|
|
1610
|
+
var getFunctionName = (signature) => {
|
|
1611
|
+
signature = signature.trim();
|
|
1612
|
+
const argsIndex = signature.indexOf("(");
|
|
1613
|
+
if (argsIndex === -1) return signature;
|
|
1614
|
+
assert(signature.endsWith(")"), "Parentheses for argument names should match.");
|
|
1615
|
+
return signature.slice(0, argsIndex);
|
|
1616
|
+
};
|
|
1617
|
+
var __embind_register_function = (name, argCount, rawArgTypesAddr, signature, rawInvoker, fn, isAsync, isNonnullReturn) => {
|
|
1618
|
+
var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
|
1619
|
+
name = AsciiToString(name);
|
|
1620
|
+
name = getFunctionName(name);
|
|
1621
|
+
|
|
1622
|
+
rawInvoker = embind__requireFunction(signature, rawInvoker, isAsync);
|
|
1623
|
+
|
|
1624
|
+
exposePublicSymbol(name, function() {
|
|
1625
|
+
throwUnboundTypeError(`Cannot call ${name} due to unbound types`, argTypes);
|
|
1626
|
+
}, argCount - 1);
|
|
1627
|
+
|
|
1628
|
+
whenDependentTypesAreResolved([], argTypes, (argTypes) => {
|
|
1629
|
+
var invokerArgsArray = [argTypes[0] /* return value */, null /* no class 'this'*/].concat(argTypes.slice(1) /* actual params */);
|
|
1630
|
+
replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null /* no class 'this'*/, rawInvoker, fn, isAsync), argCount - 1);
|
|
1631
|
+
return [];
|
|
1632
|
+
});
|
|
1633
|
+
};
|
|
1634
|
+
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
|
|
1638
|
+
|
|
1639
|
+
/** @suppress {globalThis} */
|
|
1640
|
+
var __embind_register_integer = (primitiveType, name, size, minRange, maxRange) => {
|
|
1641
|
+
name = AsciiToString(name);
|
|
1642
|
+
|
|
1643
|
+
const isUnsignedType = minRange === 0;
|
|
1644
|
+
|
|
1645
|
+
let fromWireType = (value) => value;
|
|
1646
|
+
if (isUnsignedType) {
|
|
1647
|
+
var bitshift = 32 - 8*size;
|
|
1648
|
+
fromWireType = (value) => (value << bitshift) >>> bitshift;
|
|
1649
|
+
maxRange = fromWireType(maxRange);
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
registerType(primitiveType, {
|
|
1653
|
+
name,
|
|
1654
|
+
fromWireType: fromWireType,
|
|
1655
|
+
toWireType: (destructors, value) => {
|
|
1656
|
+
if (typeof value != "number" && typeof value != "boolean") {
|
|
1657
|
+
throw new TypeError(`Cannot convert "${embindRepr(value)}" to ${name}`);
|
|
1658
|
+
}
|
|
1659
|
+
assertIntegerRange(name, value, minRange, maxRange);
|
|
1660
|
+
// The VM will perform JS to Wasm value conversion, according to the spec:
|
|
1661
|
+
// https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
|
|
1662
|
+
return value;
|
|
1663
|
+
},
|
|
1664
|
+
readValueFromPointer: integerReadValueFromPointer(name, size, minRange !== 0),
|
|
1665
|
+
destructorFunction: null, // This type does not need a destructor
|
|
1666
|
+
});
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1669
|
+
|
|
1670
|
+
var __embind_register_memory_view = (rawType, dataTypeIndex, name) => {
|
|
1671
|
+
var typeMapping = [
|
|
1672
|
+
Int8Array,
|
|
1673
|
+
Uint8Array,
|
|
1674
|
+
Int16Array,
|
|
1675
|
+
Uint16Array,
|
|
1676
|
+
Int32Array,
|
|
1677
|
+
Uint32Array,
|
|
1678
|
+
Float32Array,
|
|
1679
|
+
Float64Array,
|
|
1680
|
+
BigInt64Array,
|
|
1681
|
+
BigUint64Array,
|
|
1682
|
+
];
|
|
1683
|
+
|
|
1684
|
+
var TA = typeMapping[dataTypeIndex];
|
|
1685
|
+
|
|
1686
|
+
function decodeMemoryView(handle) {
|
|
1687
|
+
var size = HEAPU32[((handle)>>2)];
|
|
1688
|
+
var data = HEAPU32[(((handle)+(4))>>2)];
|
|
1689
|
+
return new TA(HEAP8.buffer, data, size);
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
name = AsciiToString(name);
|
|
1693
|
+
registerType(rawType, {
|
|
1694
|
+
name,
|
|
1695
|
+
fromWireType: decodeMemoryView,
|
|
1696
|
+
readValueFromPointer: decodeMemoryView,
|
|
1697
|
+
}, {
|
|
1698
|
+
ignoreDuplicateRegistrations: true,
|
|
1699
|
+
});
|
|
1700
|
+
};
|
|
1701
|
+
|
|
1702
|
+
|
|
1703
|
+
|
|
1704
|
+
|
|
1705
|
+
|
|
1706
|
+
var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
|
|
1707
|
+
assert(typeof str === 'string', `stringToUTF8Array expects a string (got ${typeof str})`);
|
|
1708
|
+
// Parameter maxBytesToWrite is not optional. Negative values, 0, null,
|
|
1709
|
+
// undefined and false each don't write out any bytes.
|
|
1710
|
+
if (!(maxBytesToWrite > 0))
|
|
1711
|
+
return 0;
|
|
1712
|
+
|
|
1713
|
+
var startIdx = outIdx;
|
|
1714
|
+
var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
|
|
1715
|
+
for (var i = 0; i < str.length; ++i) {
|
|
1716
|
+
// For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
|
|
1717
|
+
// and https://www.ietf.org/rfc/rfc2279.txt
|
|
1718
|
+
// and https://tools.ietf.org/html/rfc3629
|
|
1719
|
+
var u = str.codePointAt(i);
|
|
1720
|
+
if (u <= 0x7F) {
|
|
1721
|
+
if (outIdx >= endIdx) break;
|
|
1722
|
+
heap[outIdx++] = u;
|
|
1723
|
+
} else if (u <= 0x7FF) {
|
|
1724
|
+
if (outIdx + 1 >= endIdx) break;
|
|
1725
|
+
heap[outIdx++] = 0xC0 | (u >> 6);
|
|
1726
|
+
heap[outIdx++] = 0x80 | (u & 63);
|
|
1727
|
+
} else if (u <= 0xFFFF) {
|
|
1728
|
+
if (outIdx + 2 >= endIdx) break;
|
|
1729
|
+
heap[outIdx++] = 0xE0 | (u >> 12);
|
|
1730
|
+
heap[outIdx++] = 0x80 | ((u >> 6) & 63);
|
|
1731
|
+
heap[outIdx++] = 0x80 | (u & 63);
|
|
1732
|
+
} else {
|
|
1733
|
+
if (outIdx + 3 >= endIdx) break;
|
|
1734
|
+
if (u > 0x10FFFF) warnOnce('Invalid Unicode code point ' + ptrToString(u) + ' encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).');
|
|
1735
|
+
heap[outIdx++] = 0xF0 | (u >> 18);
|
|
1736
|
+
heap[outIdx++] = 0x80 | ((u >> 12) & 63);
|
|
1737
|
+
heap[outIdx++] = 0x80 | ((u >> 6) & 63);
|
|
1738
|
+
heap[outIdx++] = 0x80 | (u & 63);
|
|
1739
|
+
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
|
|
1740
|
+
// We need to manually skip over the second code unit for correct iteration.
|
|
1741
|
+
i++;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
// Null-terminate the pointer to the buffer.
|
|
1745
|
+
heap[outIdx] = 0;
|
|
1746
|
+
return outIdx - startIdx;
|
|
1747
|
+
};
|
|
1748
|
+
var stringToUTF8 = (str, outPtr, maxBytesToWrite) => {
|
|
1749
|
+
assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
|
1750
|
+
return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
|
|
1751
|
+
};
|
|
1752
|
+
|
|
1753
|
+
var lengthBytesUTF8 = (str) => {
|
|
1754
|
+
var len = 0;
|
|
1755
|
+
for (var i = 0; i < str.length; ++i) {
|
|
1756
|
+
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
|
|
1757
|
+
// unit, not a Unicode code point of the character! So decode
|
|
1758
|
+
// UTF16->UTF32->UTF8.
|
|
1759
|
+
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
1760
|
+
var c = str.charCodeAt(i); // possibly a lead surrogate
|
|
1761
|
+
if (c <= 0x7F) {
|
|
1762
|
+
len++;
|
|
1763
|
+
} else if (c <= 0x7FF) {
|
|
1764
|
+
len += 2;
|
|
1765
|
+
} else if (c >= 0xD800 && c <= 0xDFFF) {
|
|
1766
|
+
len += 4; ++i;
|
|
1767
|
+
} else {
|
|
1768
|
+
len += 3;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
return len;
|
|
1772
|
+
};
|
|
1773
|
+
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
var __embind_register_std_string = (rawType, name) => {
|
|
1777
|
+
name = AsciiToString(name);
|
|
1778
|
+
var stdStringIsUTF8 = true;
|
|
1779
|
+
|
|
1780
|
+
registerType(rawType, {
|
|
1781
|
+
name,
|
|
1782
|
+
// For some method names we use string keys here since they are part of
|
|
1783
|
+
// the public/external API and/or used by the runtime-generated code.
|
|
1784
|
+
fromWireType(value) {
|
|
1785
|
+
var length = HEAPU32[((value)>>2)];
|
|
1786
|
+
var payload = value + 4;
|
|
1787
|
+
|
|
1788
|
+
var str;
|
|
1789
|
+
if (stdStringIsUTF8) {
|
|
1790
|
+
str = UTF8ToString(payload, length, true);
|
|
1791
|
+
} else {
|
|
1792
|
+
str = '';
|
|
1793
|
+
for (var i = 0; i < length; ++i) {
|
|
1794
|
+
str += String.fromCharCode(HEAPU8[payload + i]);
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
_free(value);
|
|
1799
|
+
|
|
1800
|
+
return str;
|
|
1801
|
+
},
|
|
1802
|
+
toWireType(destructors, value) {
|
|
1803
|
+
if (value instanceof ArrayBuffer) {
|
|
1804
|
+
value = new Uint8Array(value);
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
var length;
|
|
1808
|
+
var valueIsOfTypeString = (typeof value == 'string');
|
|
1809
|
+
|
|
1810
|
+
// We accept `string` or array views with single byte elements
|
|
1811
|
+
if (!(valueIsOfTypeString || (ArrayBuffer.isView(value) && value.BYTES_PER_ELEMENT == 1))) {
|
|
1812
|
+
throwBindingError('Cannot pass non-string to std::string');
|
|
1813
|
+
}
|
|
1814
|
+
if (stdStringIsUTF8 && valueIsOfTypeString) {
|
|
1815
|
+
length = lengthBytesUTF8(value);
|
|
1816
|
+
} else {
|
|
1817
|
+
length = value.length;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
// assumes POINTER_SIZE alignment
|
|
1821
|
+
var base = _malloc(4 + length + 1);
|
|
1822
|
+
var ptr = base + 4;
|
|
1823
|
+
HEAPU32[((base)>>2)] = length;
|
|
1824
|
+
if (valueIsOfTypeString) {
|
|
1825
|
+
if (stdStringIsUTF8) {
|
|
1826
|
+
stringToUTF8(value, ptr, length + 1);
|
|
1827
|
+
} else {
|
|
1828
|
+
for (var i = 0; i < length; ++i) {
|
|
1829
|
+
var charCode = value.charCodeAt(i);
|
|
1830
|
+
if (charCode > 255) {
|
|
1831
|
+
_free(base);
|
|
1832
|
+
throwBindingError('String has UTF-16 code units that do not fit in 8 bits');
|
|
1833
|
+
}
|
|
1834
|
+
HEAPU8[ptr + i] = charCode;
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
} else {
|
|
1838
|
+
HEAPU8.set(value, ptr);
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
if (destructors !== null) {
|
|
1842
|
+
destructors.push(_free, base);
|
|
1843
|
+
}
|
|
1844
|
+
return base;
|
|
1845
|
+
},
|
|
1846
|
+
readValueFromPointer: readPointer,
|
|
1847
|
+
destructorFunction(ptr) {
|
|
1848
|
+
_free(ptr);
|
|
1849
|
+
},
|
|
1850
|
+
});
|
|
1851
|
+
};
|
|
1852
|
+
|
|
1853
|
+
|
|
1854
|
+
|
|
1855
|
+
|
|
1856
|
+
var UTF16Decoder = globalThis.TextDecoder ? new TextDecoder('utf-16le') : undefined;;
|
|
1857
|
+
|
|
1858
|
+
var UTF16ToString = (ptr, maxBytesToRead, ignoreNul) => {
|
|
1859
|
+
assert(ptr % 2 == 0, 'Pointer passed to UTF16ToString must be aligned to two bytes!');
|
|
1860
|
+
var idx = ((ptr)>>1);
|
|
1861
|
+
var endIdx = findStringEnd(HEAPU16, idx, maxBytesToRead / 2, ignoreNul);
|
|
1862
|
+
|
|
1863
|
+
// When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it.
|
|
1864
|
+
if (endIdx - idx > 16 && UTF16Decoder)
|
|
1865
|
+
return UTF16Decoder.decode(HEAPU16.subarray(idx, endIdx));
|
|
1866
|
+
|
|
1867
|
+
// Fallback: decode without UTF16Decoder
|
|
1868
|
+
var str = '';
|
|
1869
|
+
|
|
1870
|
+
// If maxBytesToRead is not passed explicitly, it will be undefined, and the
|
|
1871
|
+
// for-loop's condition will always evaluate to true. The loop is then
|
|
1872
|
+
// terminated on the first null char.
|
|
1873
|
+
for (var i = idx; i < endIdx; ++i) {
|
|
1874
|
+
var codeUnit = HEAPU16[i];
|
|
1875
|
+
// fromCharCode constructs a character from a UTF-16 code unit, so we can
|
|
1876
|
+
// pass the UTF16 string right through.
|
|
1877
|
+
str += String.fromCharCode(codeUnit);
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
return str;
|
|
1881
|
+
};
|
|
1882
|
+
|
|
1883
|
+
var stringToUTF16 = (str, outPtr, maxBytesToWrite) => {
|
|
1884
|
+
assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!');
|
|
1885
|
+
assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
|
1886
|
+
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
1887
|
+
maxBytesToWrite ??= 0x7FFFFFFF;
|
|
1888
|
+
if (maxBytesToWrite < 2) return 0;
|
|
1889
|
+
maxBytesToWrite -= 2; // Null terminator.
|
|
1890
|
+
var startPtr = outPtr;
|
|
1891
|
+
var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length;
|
|
1892
|
+
for (var i = 0; i < numCharsToWrite; ++i) {
|
|
1893
|
+
// charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
|
|
1894
|
+
var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
|
|
1895
|
+
HEAP16[((outPtr)>>1)] = codeUnit;
|
|
1896
|
+
outPtr += 2;
|
|
1897
|
+
}
|
|
1898
|
+
// Null-terminate the pointer to the HEAP.
|
|
1899
|
+
HEAP16[((outPtr)>>1)] = 0;
|
|
1900
|
+
return outPtr - startPtr;
|
|
1901
|
+
};
|
|
1902
|
+
|
|
1903
|
+
var lengthBytesUTF16 = (str) => str.length*2;
|
|
1904
|
+
|
|
1905
|
+
var UTF32ToString = (ptr, maxBytesToRead, ignoreNul) => {
|
|
1906
|
+
assert(ptr % 4 == 0, 'Pointer passed to UTF32ToString must be aligned to four bytes!');
|
|
1907
|
+
var str = '';
|
|
1908
|
+
var startIdx = ((ptr)>>2);
|
|
1909
|
+
// If maxBytesToRead is not passed explicitly, it will be undefined, and this
|
|
1910
|
+
// will always evaluate to true. This saves on code size.
|
|
1911
|
+
for (var i = 0; !(i >= maxBytesToRead / 4); i++) {
|
|
1912
|
+
var utf32 = HEAPU32[startIdx + i];
|
|
1913
|
+
if (!utf32 && !ignoreNul) break;
|
|
1914
|
+
str += String.fromCodePoint(utf32);
|
|
1915
|
+
}
|
|
1916
|
+
return str;
|
|
1917
|
+
};
|
|
1918
|
+
|
|
1919
|
+
var stringToUTF32 = (str, outPtr, maxBytesToWrite) => {
|
|
1920
|
+
assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!');
|
|
1921
|
+
assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
|
1922
|
+
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
1923
|
+
maxBytesToWrite ??= 0x7FFFFFFF;
|
|
1924
|
+
if (maxBytesToWrite < 4) return 0;
|
|
1925
|
+
var startPtr = outPtr;
|
|
1926
|
+
var endPtr = startPtr + maxBytesToWrite - 4;
|
|
1927
|
+
for (var i = 0; i < str.length; ++i) {
|
|
1928
|
+
var codePoint = str.codePointAt(i);
|
|
1929
|
+
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
|
|
1930
|
+
// We need to manually skip over the second code unit for correct iteration.
|
|
1931
|
+
if (codePoint > 0xFFFF) {
|
|
1932
|
+
i++;
|
|
1933
|
+
}
|
|
1934
|
+
HEAP32[((outPtr)>>2)] = codePoint;
|
|
1935
|
+
outPtr += 4;
|
|
1936
|
+
if (outPtr + 4 > endPtr) break;
|
|
1937
|
+
}
|
|
1938
|
+
// Null-terminate the pointer to the HEAP.
|
|
1939
|
+
HEAP32[((outPtr)>>2)] = 0;
|
|
1940
|
+
return outPtr - startPtr;
|
|
1941
|
+
};
|
|
1942
|
+
|
|
1943
|
+
var lengthBytesUTF32 = (str) => {
|
|
1944
|
+
var len = 0;
|
|
1945
|
+
for (var i = 0; i < str.length; ++i) {
|
|
1946
|
+
var codePoint = str.codePointAt(i);
|
|
1947
|
+
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
|
|
1948
|
+
// We need to manually skip over the second code unit for correct iteration.
|
|
1949
|
+
if (codePoint > 0xFFFF) {
|
|
1950
|
+
i++;
|
|
1951
|
+
}
|
|
1952
|
+
len += 4;
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
return len;
|
|
1956
|
+
};
|
|
1957
|
+
var __embind_register_std_wstring = (rawType, charSize, name) => {
|
|
1958
|
+
name = AsciiToString(name);
|
|
1959
|
+
var decodeString, encodeString, lengthBytesUTF;
|
|
1960
|
+
if (charSize === 2) {
|
|
1961
|
+
decodeString = UTF16ToString;
|
|
1962
|
+
encodeString = stringToUTF16;
|
|
1963
|
+
lengthBytesUTF = lengthBytesUTF16;
|
|
1964
|
+
} else {
|
|
1965
|
+
assert(charSize === 4, 'only 2-byte and 4-byte strings are currently supported');
|
|
1966
|
+
decodeString = UTF32ToString;
|
|
1967
|
+
encodeString = stringToUTF32;
|
|
1968
|
+
lengthBytesUTF = lengthBytesUTF32;
|
|
1969
|
+
}
|
|
1970
|
+
registerType(rawType, {
|
|
1971
|
+
name,
|
|
1972
|
+
fromWireType: (value) => {
|
|
1973
|
+
// Code mostly taken from _embind_register_std_string fromWireType
|
|
1974
|
+
var length = HEAPU32[((value)>>2)];
|
|
1975
|
+
var str = decodeString(value + 4, length * charSize, true);
|
|
1976
|
+
|
|
1977
|
+
_free(value);
|
|
1978
|
+
|
|
1979
|
+
return str;
|
|
1980
|
+
},
|
|
1981
|
+
toWireType: (destructors, value) => {
|
|
1982
|
+
if (!(typeof value == 'string')) {
|
|
1983
|
+
throwBindingError(`Cannot pass non-string to C++ string type ${name}`);
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
// assumes POINTER_SIZE alignment
|
|
1987
|
+
var length = lengthBytesUTF(value);
|
|
1988
|
+
var ptr = _malloc(4 + length + charSize);
|
|
1989
|
+
HEAPU32[((ptr)>>2)] = length / charSize;
|
|
1990
|
+
|
|
1991
|
+
encodeString(value, ptr + 4, length + charSize);
|
|
1992
|
+
|
|
1993
|
+
if (destructors !== null) {
|
|
1994
|
+
destructors.push(_free, ptr);
|
|
1995
|
+
}
|
|
1996
|
+
return ptr;
|
|
1997
|
+
},
|
|
1998
|
+
readValueFromPointer: readPointer,
|
|
1999
|
+
destructorFunction(ptr) {
|
|
2000
|
+
_free(ptr);
|
|
2001
|
+
}
|
|
2002
|
+
});
|
|
2003
|
+
};
|
|
2004
|
+
|
|
2005
|
+
|
|
2006
|
+
var __embind_register_void = (rawType, name) => {
|
|
2007
|
+
name = AsciiToString(name);
|
|
2008
|
+
registerType(rawType, {
|
|
2009
|
+
isVoid: true, // void return values can be optimized out sometimes
|
|
2010
|
+
name,
|
|
2011
|
+
fromWireType: () => undefined,
|
|
2012
|
+
// TODO: assert if anything else is given?
|
|
2013
|
+
toWireType: (destructors, o) => undefined,
|
|
2014
|
+
});
|
|
2015
|
+
};
|
|
2016
|
+
|
|
2017
|
+
|
|
2018
|
+
var __tzset_js = (timezone, daylight, std_name, dst_name) => {
|
|
2019
|
+
// TODO: Use (malleable) environment variables instead of system settings.
|
|
2020
|
+
var currentYear = new Date().getFullYear();
|
|
2021
|
+
var winter = new Date(currentYear, 0, 1);
|
|
2022
|
+
var summer = new Date(currentYear, 6, 1);
|
|
2023
|
+
var winterOffset = winter.getTimezoneOffset();
|
|
2024
|
+
var summerOffset = summer.getTimezoneOffset();
|
|
2025
|
+
|
|
2026
|
+
// Local standard timezone offset. Local standard time is not adjusted for
|
|
2027
|
+
// daylight savings. This code uses the fact that getTimezoneOffset returns
|
|
2028
|
+
// a greater value during Standard Time versus Daylight Saving Time (DST).
|
|
2029
|
+
// Thus it determines the expected output during Standard Time, and it
|
|
2030
|
+
// compares whether the output of the given date the same (Standard) or less
|
|
2031
|
+
// (DST).
|
|
2032
|
+
var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
|
|
2033
|
+
|
|
2034
|
+
// timezone is specified as seconds west of UTC ("The external variable
|
|
2035
|
+
// `timezone` shall be set to the difference, in seconds, between
|
|
2036
|
+
// Coordinated Universal Time (UTC) and local standard time."), the same
|
|
2037
|
+
// as returned by stdTimezoneOffset.
|
|
2038
|
+
// See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
|
|
2039
|
+
HEAPU32[((timezone)>>2)] = stdTimezoneOffset * 60;
|
|
2040
|
+
|
|
2041
|
+
HEAP32[((daylight)>>2)] = Number(winterOffset != summerOffset);
|
|
2042
|
+
|
|
2043
|
+
var extractZone = (timezoneOffset) => {
|
|
2044
|
+
// Why inverse sign?
|
|
2045
|
+
// Read here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
|
|
2046
|
+
var sign = timezoneOffset >= 0 ? "-" : "+";
|
|
2047
|
+
|
|
2048
|
+
var absOffset = Math.abs(timezoneOffset)
|
|
2049
|
+
var hours = String(Math.floor(absOffset / 60)).padStart(2, "0");
|
|
2050
|
+
var minutes = String(absOffset % 60).padStart(2, "0");
|
|
2051
|
+
|
|
2052
|
+
return `UTC${sign}${hours}${minutes}`;
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
var winterName = extractZone(winterOffset);
|
|
2056
|
+
var summerName = extractZone(summerOffset);
|
|
2057
|
+
assert(winterName);
|
|
2058
|
+
assert(summerName);
|
|
2059
|
+
assert(lengthBytesUTF8(winterName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${winterName})`);
|
|
2060
|
+
assert(lengthBytesUTF8(summerName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${summerName})`);
|
|
2061
|
+
if (summerOffset < winterOffset) {
|
|
2062
|
+
// Northern hemisphere
|
|
2063
|
+
stringToUTF8(winterName, std_name, 17);
|
|
2064
|
+
stringToUTF8(summerName, dst_name, 17);
|
|
2065
|
+
} else {
|
|
2066
|
+
stringToUTF8(winterName, dst_name, 17);
|
|
2067
|
+
stringToUTF8(summerName, std_name, 17);
|
|
2068
|
+
}
|
|
2069
|
+
};
|
|
2070
|
+
|
|
2071
|
+
var abortOnCannotGrowMemory = (requestedSize) => {
|
|
2072
|
+
abort(`Cannot enlarge memory arrays to size ${requestedSize} bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value ${HEAP8.length}, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0`);
|
|
2073
|
+
};
|
|
2074
|
+
var _emscripten_resize_heap = (requestedSize) => {
|
|
2075
|
+
var oldSize = HEAPU8.length;
|
|
2076
|
+
// With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
|
|
2077
|
+
requestedSize >>>= 0;
|
|
2078
|
+
abortOnCannotGrowMemory(requestedSize);
|
|
2079
|
+
};
|
|
2080
|
+
|
|
2081
|
+
var ENV = {
|
|
2082
|
+
};
|
|
2083
|
+
|
|
2084
|
+
var getExecutableName = () => thisProgram || './this.program';
|
|
2085
|
+
var getEnvStrings = () => {
|
|
2086
|
+
if (!getEnvStrings.strings) {
|
|
2087
|
+
// Default values.
|
|
2088
|
+
// Browser language detection #8751
|
|
2089
|
+
var lang = ((typeof navigator == 'object' && navigator.language) || 'C').replace('-', '_') + '.UTF-8';
|
|
2090
|
+
var env = {
|
|
2091
|
+
'USER': 'web_user',
|
|
2092
|
+
'LOGNAME': 'web_user',
|
|
2093
|
+
'PATH': '/',
|
|
2094
|
+
'PWD': '/',
|
|
2095
|
+
'HOME': '/home/web_user',
|
|
2096
|
+
'LANG': lang,
|
|
2097
|
+
'_': getExecutableName()
|
|
2098
|
+
};
|
|
2099
|
+
// Apply the user-provided values, if any.
|
|
2100
|
+
for (var x in ENV) {
|
|
2101
|
+
// x is a key in ENV; if ENV[x] is undefined, that means it was
|
|
2102
|
+
// explicitly set to be so. We allow user code to do that to
|
|
2103
|
+
// force variables with default values to remain unset.
|
|
2104
|
+
if (ENV[x] === undefined) delete env[x];
|
|
2105
|
+
else env[x] = ENV[x];
|
|
2106
|
+
}
|
|
2107
|
+
var strings = [];
|
|
2108
|
+
for (var x in env) {
|
|
2109
|
+
strings.push(`${x}=${env[x]}`);
|
|
2110
|
+
}
|
|
2111
|
+
getEnvStrings.strings = strings;
|
|
2112
|
+
}
|
|
2113
|
+
return getEnvStrings.strings;
|
|
2114
|
+
};
|
|
2115
|
+
|
|
2116
|
+
var _environ_get = (__environ, environ_buf) => {
|
|
2117
|
+
var bufSize = 0;
|
|
2118
|
+
var envp = 0;
|
|
2119
|
+
for (var string of getEnvStrings()) {
|
|
2120
|
+
var ptr = environ_buf + bufSize;
|
|
2121
|
+
HEAPU32[(((__environ)+(envp))>>2)] = ptr;
|
|
2122
|
+
bufSize += stringToUTF8(string, ptr, Infinity) + 1;
|
|
2123
|
+
envp += 4;
|
|
2124
|
+
}
|
|
2125
|
+
return 0;
|
|
2126
|
+
};
|
|
2127
|
+
|
|
2128
|
+
|
|
2129
|
+
var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
|
|
2130
|
+
var strings = getEnvStrings();
|
|
2131
|
+
HEAPU32[((penviron_count)>>2)] = strings.length;
|
|
2132
|
+
var bufSize = 0;
|
|
2133
|
+
for (var string of strings) {
|
|
2134
|
+
bufSize += lengthBytesUTF8(string) + 1;
|
|
2135
|
+
}
|
|
2136
|
+
HEAPU32[((penviron_buf_size)>>2)] = bufSize;
|
|
2137
|
+
return 0;
|
|
2138
|
+
};
|
|
2139
|
+
|
|
2140
|
+
var SYSCALLS = {
|
|
2141
|
+
varargs:undefined,
|
|
2142
|
+
getStr(ptr) {
|
|
2143
|
+
var ret = UTF8ToString(ptr);
|
|
2144
|
+
return ret;
|
|
2145
|
+
},
|
|
2146
|
+
};
|
|
2147
|
+
var _fd_close = (fd) => {
|
|
2148
|
+
abort('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM');
|
|
2149
|
+
};
|
|
2150
|
+
|
|
2151
|
+
var INT53_MAX = 9007199254740992;
|
|
2152
|
+
|
|
2153
|
+
var INT53_MIN = -9007199254740992;
|
|
2154
|
+
var bigintToI53Checked = (num) => (num < INT53_MIN || num > INT53_MAX) ? NaN : Number(num);
|
|
2155
|
+
function _fd_seek(fd, offset, whence, newOffset) {
|
|
2156
|
+
offset = bigintToI53Checked(offset);
|
|
2157
|
+
|
|
2158
|
+
|
|
2159
|
+
return 70;
|
|
2160
|
+
;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
var printCharBuffers = [null,[],[]];
|
|
2164
|
+
|
|
2165
|
+
var printChar = (stream, curr) => {
|
|
2166
|
+
var buffer = printCharBuffers[stream];
|
|
2167
|
+
assert(buffer);
|
|
2168
|
+
if (curr === 0 || curr === 10) {
|
|
2169
|
+
(stream === 1 ? out : err)(UTF8ArrayToString(buffer));
|
|
2170
|
+
buffer.length = 0;
|
|
2171
|
+
} else {
|
|
2172
|
+
buffer.push(curr);
|
|
2173
|
+
}
|
|
2174
|
+
};
|
|
2175
|
+
|
|
2176
|
+
var flush_NO_FILESYSTEM = () => {
|
|
2177
|
+
// flush anything remaining in the buffers during shutdown
|
|
2178
|
+
_fflush(0);
|
|
2179
|
+
if (printCharBuffers[1].length) printChar(1, 10);
|
|
2180
|
+
if (printCharBuffers[2].length) printChar(2, 10);
|
|
2181
|
+
};
|
|
2182
|
+
|
|
2183
|
+
|
|
2184
|
+
var _fd_write = (fd, iov, iovcnt, pnum) => {
|
|
2185
|
+
// hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
|
|
2186
|
+
var num = 0;
|
|
2187
|
+
for (var i = 0; i < iovcnt; i++) {
|
|
2188
|
+
var ptr = HEAPU32[((iov)>>2)];
|
|
2189
|
+
var len = HEAPU32[(((iov)+(4))>>2)];
|
|
2190
|
+
iov += 8;
|
|
2191
|
+
for (var j = 0; j < len; j++) {
|
|
2192
|
+
printChar(fd, HEAPU8[ptr+j]);
|
|
2193
|
+
}
|
|
2194
|
+
num += len;
|
|
2195
|
+
}
|
|
2196
|
+
HEAPU32[((pnum)>>2)] = num;
|
|
2197
|
+
return 0;
|
|
2198
|
+
};
|
|
2199
|
+
|
|
2200
|
+
|
|
2201
|
+
var incrementExceptionRefcount = (ptr) => ___cxa_increment_exception_refcount(ptr);
|
|
2202
|
+
|
|
2203
|
+
var decrementExceptionRefcount = (ptr) => ___cxa_decrement_exception_refcount(ptr);
|
|
2204
|
+
|
|
2205
|
+
|
|
2206
|
+
|
|
2207
|
+
|
|
2208
|
+
|
|
2209
|
+
var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
|
|
2210
|
+
|
|
2211
|
+
var getExceptionMessageCommon = (ptr) => {
|
|
2212
|
+
var sp = stackSave();
|
|
2213
|
+
var type_addr_addr = stackAlloc(4);
|
|
2214
|
+
var message_addr_addr = stackAlloc(4);
|
|
2215
|
+
___get_exception_message(ptr, type_addr_addr, message_addr_addr);
|
|
2216
|
+
var type_addr = HEAPU32[((type_addr_addr)>>2)];
|
|
2217
|
+
var message_addr = HEAPU32[((message_addr_addr)>>2)];
|
|
2218
|
+
var type = UTF8ToString(type_addr);
|
|
2219
|
+
_free(type_addr);
|
|
2220
|
+
var message;
|
|
2221
|
+
if (message_addr) {
|
|
2222
|
+
message = UTF8ToString(message_addr);
|
|
2223
|
+
_free(message_addr);
|
|
2224
|
+
}
|
|
2225
|
+
stackRestore(sp);
|
|
2226
|
+
return [type, message];
|
|
2227
|
+
};
|
|
2228
|
+
var getExceptionMessage = (ptr) => getExceptionMessageCommon(ptr);
|
|
2229
|
+
assert(emval_handles.length === 5 * 2);
|
|
2230
|
+
// End JS library code
|
|
2231
|
+
|
|
2232
|
+
// include: postlibrary.js
|
|
2233
|
+
// This file is included after the automatically-generated JS library code
|
|
2234
|
+
// but before the wasm module is created.
|
|
2235
|
+
|
|
2236
|
+
{
|
|
2237
|
+
|
|
2238
|
+
// Begin ATMODULES hooks
|
|
2239
|
+
if (Module['noExitRuntime']) noExitRuntime = Module['noExitRuntime'];
|
|
2240
|
+
if (Module['print']) out = Module['print'];
|
|
2241
|
+
if (Module['printErr']) err = Module['printErr'];
|
|
2242
|
+
if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
|
|
2243
|
+
|
|
2244
|
+
Module['FS_createDataFile'] = FS.createDataFile;
|
|
2245
|
+
Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
|
|
2246
|
+
|
|
2247
|
+
// End ATMODULES hooks
|
|
2248
|
+
|
|
2249
|
+
checkIncomingModuleAPI();
|
|
2250
|
+
|
|
2251
|
+
if (Module['arguments']) arguments_ = Module['arguments'];
|
|
2252
|
+
if (Module['thisProgram']) thisProgram = Module['thisProgram'];
|
|
2253
|
+
|
|
2254
|
+
// Assertions on removed incoming Module JS APIs.
|
|
2255
|
+
assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
|
|
2256
|
+
assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
|
|
2257
|
+
assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
|
|
2258
|
+
assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
|
|
2259
|
+
assert(typeof Module['read'] == 'undefined', 'Module.read option was removed');
|
|
2260
|
+
assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
|
|
2261
|
+
assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
|
|
2262
|
+
assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)');
|
|
2263
|
+
assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
|
|
2264
|
+
assert(typeof Module['ENVIRONMENT'] == 'undefined', 'Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');
|
|
2265
|
+
assert(typeof Module['STACK_SIZE'] == 'undefined', 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
|
|
2266
|
+
// If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY
|
|
2267
|
+
assert(typeof Module['wasmMemory'] == 'undefined', 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally');
|
|
2268
|
+
assert(typeof Module['INITIAL_MEMORY'] == 'undefined', 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically');
|
|
2269
|
+
|
|
2270
|
+
if (Module['preInit']) {
|
|
2271
|
+
if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
|
|
2272
|
+
while (Module['preInit'].length > 0) {
|
|
2273
|
+
Module['preInit'].shift()();
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
consumedModuleProp('preInit');
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2279
|
+
// Begin runtime exports
|
|
2280
|
+
var missingLibrarySymbols = [
|
|
2281
|
+
'writeI53ToI64',
|
|
2282
|
+
'writeI53ToI64Clamped',
|
|
2283
|
+
'writeI53ToI64Signaling',
|
|
2284
|
+
'writeI53ToU64Clamped',
|
|
2285
|
+
'writeI53ToU64Signaling',
|
|
2286
|
+
'readI53FromI64',
|
|
2287
|
+
'readI53FromU64',
|
|
2288
|
+
'convertI32PairToI53',
|
|
2289
|
+
'convertI32PairToI53Checked',
|
|
2290
|
+
'convertU32PairToI53',
|
|
2291
|
+
'getTempRet0',
|
|
2292
|
+
'zeroMemory',
|
|
2293
|
+
'exitJS',
|
|
2294
|
+
'getHeapMax',
|
|
2295
|
+
'growMemory',
|
|
2296
|
+
'withStackSave',
|
|
2297
|
+
'strError',
|
|
2298
|
+
'inetPton4',
|
|
2299
|
+
'inetNtop4',
|
|
2300
|
+
'inetPton6',
|
|
2301
|
+
'inetNtop6',
|
|
2302
|
+
'readSockaddr',
|
|
2303
|
+
'writeSockaddr',
|
|
2304
|
+
'readEmAsmArgs',
|
|
2305
|
+
'jstoi_q',
|
|
2306
|
+
'autoResumeAudioContext',
|
|
2307
|
+
'getDynCaller',
|
|
2308
|
+
'dynCall',
|
|
2309
|
+
'handleException',
|
|
2310
|
+
'keepRuntimeAlive',
|
|
2311
|
+
'runtimeKeepalivePush',
|
|
2312
|
+
'runtimeKeepalivePop',
|
|
2313
|
+
'callUserCallback',
|
|
2314
|
+
'maybeExit',
|
|
2315
|
+
'asyncLoad',
|
|
2316
|
+
'asmjsMangle',
|
|
2317
|
+
'alignMemory',
|
|
2318
|
+
'mmapAlloc',
|
|
2319
|
+
'HandleAllocator',
|
|
2320
|
+
'getUniqueRunDependency',
|
|
2321
|
+
'addRunDependency',
|
|
2322
|
+
'removeRunDependency',
|
|
2323
|
+
'addOnInit',
|
|
2324
|
+
'addOnPostCtor',
|
|
2325
|
+
'addOnPreMain',
|
|
2326
|
+
'addOnExit',
|
|
2327
|
+
'STACK_SIZE',
|
|
2328
|
+
'STACK_ALIGN',
|
|
2329
|
+
'POINTER_SIZE',
|
|
2330
|
+
'ASSERTIONS',
|
|
2331
|
+
'ccall',
|
|
2332
|
+
'cwrap',
|
|
2333
|
+
'convertJsFunctionToWasm',
|
|
2334
|
+
'getEmptyTableSlot',
|
|
2335
|
+
'updateTableMap',
|
|
2336
|
+
'getFunctionAddress',
|
|
2337
|
+
'addFunction',
|
|
2338
|
+
'removeFunction',
|
|
2339
|
+
'intArrayFromString',
|
|
2340
|
+
'intArrayToString',
|
|
2341
|
+
'stringToAscii',
|
|
2342
|
+
'stringToNewUTF8',
|
|
2343
|
+
'stringToUTF8OnStack',
|
|
2344
|
+
'writeArrayToMemory',
|
|
2345
|
+
'registerKeyEventCallback',
|
|
2346
|
+
'maybeCStringToJsString',
|
|
2347
|
+
'findEventTarget',
|
|
2348
|
+
'getBoundingClientRect',
|
|
2349
|
+
'fillMouseEventData',
|
|
2350
|
+
'registerMouseEventCallback',
|
|
2351
|
+
'registerWheelEventCallback',
|
|
2352
|
+
'registerUiEventCallback',
|
|
2353
|
+
'registerFocusEventCallback',
|
|
2354
|
+
'fillDeviceOrientationEventData',
|
|
2355
|
+
'registerDeviceOrientationEventCallback',
|
|
2356
|
+
'fillDeviceMotionEventData',
|
|
2357
|
+
'registerDeviceMotionEventCallback',
|
|
2358
|
+
'screenOrientation',
|
|
2359
|
+
'fillOrientationChangeEventData',
|
|
2360
|
+
'registerOrientationChangeEventCallback',
|
|
2361
|
+
'fillFullscreenChangeEventData',
|
|
2362
|
+
'registerFullscreenChangeEventCallback',
|
|
2363
|
+
'JSEvents_requestFullscreen',
|
|
2364
|
+
'JSEvents_resizeCanvasForFullscreen',
|
|
2365
|
+
'registerRestoreOldStyle',
|
|
2366
|
+
'hideEverythingExceptGivenElement',
|
|
2367
|
+
'restoreHiddenElements',
|
|
2368
|
+
'setLetterbox',
|
|
2369
|
+
'softFullscreenResizeWebGLRenderTarget',
|
|
2370
|
+
'doRequestFullscreen',
|
|
2371
|
+
'fillPointerlockChangeEventData',
|
|
2372
|
+
'registerPointerlockChangeEventCallback',
|
|
2373
|
+
'registerPointerlockErrorEventCallback',
|
|
2374
|
+
'requestPointerLock',
|
|
2375
|
+
'fillVisibilityChangeEventData',
|
|
2376
|
+
'registerVisibilityChangeEventCallback',
|
|
2377
|
+
'registerTouchEventCallback',
|
|
2378
|
+
'fillGamepadEventData',
|
|
2379
|
+
'registerGamepadEventCallback',
|
|
2380
|
+
'registerBeforeUnloadEventCallback',
|
|
2381
|
+
'fillBatteryEventData',
|
|
2382
|
+
'registerBatteryEventCallback',
|
|
2383
|
+
'setCanvasElementSize',
|
|
2384
|
+
'getCanvasElementSize',
|
|
2385
|
+
'jsStackTrace',
|
|
2386
|
+
'getCallstack',
|
|
2387
|
+
'convertPCtoSourceLocation',
|
|
2388
|
+
'checkWasiClock',
|
|
2389
|
+
'wasiRightsToMuslOFlags',
|
|
2390
|
+
'wasiOFlagsToMuslOFlags',
|
|
2391
|
+
'initRandomFill',
|
|
2392
|
+
'randomFill',
|
|
2393
|
+
'safeSetTimeout',
|
|
2394
|
+
'setImmediateWrapped',
|
|
2395
|
+
'safeRequestAnimationFrame',
|
|
2396
|
+
'clearImmediateWrapped',
|
|
2397
|
+
'registerPostMainLoop',
|
|
2398
|
+
'registerPreMainLoop',
|
|
2399
|
+
'getPromise',
|
|
2400
|
+
'makePromise',
|
|
2401
|
+
'idsToPromises',
|
|
2402
|
+
'makePromiseCallback',
|
|
2403
|
+
'Browser_asyncPrepareDataCounter',
|
|
2404
|
+
'isLeapYear',
|
|
2405
|
+
'ydayFromDate',
|
|
2406
|
+
'arraySum',
|
|
2407
|
+
'addDays',
|
|
2408
|
+
'getSocketFromFD',
|
|
2409
|
+
'getSocketAddress',
|
|
2410
|
+
'FS_createPreloadedFile',
|
|
2411
|
+
'FS_preloadFile',
|
|
2412
|
+
'FS_modeStringToFlags',
|
|
2413
|
+
'FS_getMode',
|
|
2414
|
+
'FS_stdin_getChar',
|
|
2415
|
+
'FS_mkdirTree',
|
|
2416
|
+
'_setNetworkCallback',
|
|
2417
|
+
'heapObjectForWebGLType',
|
|
2418
|
+
'toTypedArrayIndex',
|
|
2419
|
+
'webgl_enable_ANGLE_instanced_arrays',
|
|
2420
|
+
'webgl_enable_OES_vertex_array_object',
|
|
2421
|
+
'webgl_enable_WEBGL_draw_buffers',
|
|
2422
|
+
'webgl_enable_WEBGL_multi_draw',
|
|
2423
|
+
'webgl_enable_EXT_polygon_offset_clamp',
|
|
2424
|
+
'webgl_enable_EXT_clip_control',
|
|
2425
|
+
'webgl_enable_WEBGL_polygon_mode',
|
|
2426
|
+
'emscriptenWebGLGet',
|
|
2427
|
+
'computeUnpackAlignedImageSize',
|
|
2428
|
+
'colorChannelsInGlTextureFormat',
|
|
2429
|
+
'emscriptenWebGLGetTexPixelData',
|
|
2430
|
+
'emscriptenWebGLGetUniform',
|
|
2431
|
+
'webglGetUniformLocation',
|
|
2432
|
+
'webglPrepareUniformLocationsBeforeFirstUse',
|
|
2433
|
+
'webglGetLeftBracePos',
|
|
2434
|
+
'emscriptenWebGLGetVertexAttrib',
|
|
2435
|
+
'__glGetActiveAttribOrUniform',
|
|
2436
|
+
'writeGLArray',
|
|
2437
|
+
'registerWebGlEventCallback',
|
|
2438
|
+
'runAndAbortIfError',
|
|
2439
|
+
'ALLOC_NORMAL',
|
|
2440
|
+
'ALLOC_STACK',
|
|
2441
|
+
'allocate',
|
|
2442
|
+
'writeStringToMemory',
|
|
2443
|
+
'writeAsciiToMemory',
|
|
2444
|
+
'allocateUTF8',
|
|
2445
|
+
'allocateUTF8OnStack',
|
|
2446
|
+
'demangle',
|
|
2447
|
+
'stackTrace',
|
|
2448
|
+
'getNativeTypeSize',
|
|
2449
|
+
'getFunctionArgsName',
|
|
2450
|
+
'requireRegisteredType',
|
|
2451
|
+
'createJsInvokerSignature',
|
|
2452
|
+
'PureVirtualError',
|
|
2453
|
+
'getBasestPointer',
|
|
2454
|
+
'registerInheritedInstance',
|
|
2455
|
+
'unregisterInheritedInstance',
|
|
2456
|
+
'getInheritedInstance',
|
|
2457
|
+
'getInheritedInstanceCount',
|
|
2458
|
+
'getLiveInheritedInstances',
|
|
2459
|
+
'enumReadValueFromPointer',
|
|
2460
|
+
'genericPointerToWireType',
|
|
2461
|
+
'constNoSmartPtrRawPointerToWireType',
|
|
2462
|
+
'nonConstNoSmartPtrRawPointerToWireType',
|
|
2463
|
+
'init_RegisteredPointer',
|
|
2464
|
+
'RegisteredPointer',
|
|
2465
|
+
'RegisteredPointer_fromWireType',
|
|
2466
|
+
'runDestructor',
|
|
2467
|
+
'releaseClassHandle',
|
|
2468
|
+
'detachFinalizer',
|
|
2469
|
+
'attachFinalizer',
|
|
2470
|
+
'makeClassHandle',
|
|
2471
|
+
'init_ClassHandle',
|
|
2472
|
+
'ClassHandle',
|
|
2473
|
+
'throwInstanceAlreadyDeleted',
|
|
2474
|
+
'flushPendingDeletes',
|
|
2475
|
+
'setDelayFunction',
|
|
2476
|
+
'RegisteredClass',
|
|
2477
|
+
'shallowCopyInternalPointer',
|
|
2478
|
+
'downcastPointer',
|
|
2479
|
+
'upcastPointer',
|
|
2480
|
+
'validateThis',
|
|
2481
|
+
'char_0',
|
|
2482
|
+
'char_9',
|
|
2483
|
+
'makeLegalFunctionName',
|
|
2484
|
+
'count_emval_handles',
|
|
2485
|
+
'getStringOrSymbol',
|
|
2486
|
+
'emval_returnValue',
|
|
2487
|
+
'emval_lookupTypes',
|
|
2488
|
+
'emval_addMethodCaller',
|
|
2489
|
+
];
|
|
2490
|
+
missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
2491
|
+
|
|
2492
|
+
var unexportedSymbols = [
|
|
2493
|
+
'run',
|
|
2494
|
+
'out',
|
|
2495
|
+
'err',
|
|
2496
|
+
'callMain',
|
|
2497
|
+
'abort',
|
|
2498
|
+
'wasmExports',
|
|
2499
|
+
'HEAPF32',
|
|
2500
|
+
'HEAPF64',
|
|
2501
|
+
'HEAP8',
|
|
2502
|
+
'HEAPU8',
|
|
2503
|
+
'HEAP16',
|
|
2504
|
+
'HEAPU16',
|
|
2505
|
+
'HEAP32',
|
|
2506
|
+
'HEAPU32',
|
|
2507
|
+
'HEAP64',
|
|
2508
|
+
'HEAPU64',
|
|
2509
|
+
'writeStackCookie',
|
|
2510
|
+
'checkStackCookie',
|
|
2511
|
+
'INT53_MAX',
|
|
2512
|
+
'INT53_MIN',
|
|
2513
|
+
'bigintToI53Checked',
|
|
2514
|
+
'stackSave',
|
|
2515
|
+
'stackRestore',
|
|
2516
|
+
'stackAlloc',
|
|
2517
|
+
'setTempRet0',
|
|
2518
|
+
'createNamedFunction',
|
|
2519
|
+
'ptrToString',
|
|
2520
|
+
'abortOnCannotGrowMemory',
|
|
2521
|
+
'ENV',
|
|
2522
|
+
'ERRNO_CODES',
|
|
2523
|
+
'DNS',
|
|
2524
|
+
'Protocols',
|
|
2525
|
+
'Sockets',
|
|
2526
|
+
'timers',
|
|
2527
|
+
'warnOnce',
|
|
2528
|
+
'readEmAsmArgsArray',
|
|
2529
|
+
'getExecutableName',
|
|
2530
|
+
'wasmTable',
|
|
2531
|
+
'wasmMemory',
|
|
2532
|
+
'noExitRuntime',
|
|
2533
|
+
'addOnPreRun',
|
|
2534
|
+
'addOnPostRun',
|
|
2535
|
+
'freeTableIndexes',
|
|
2536
|
+
'functionsInTableMap',
|
|
2537
|
+
'setValue',
|
|
2538
|
+
'getValue',
|
|
2539
|
+
'PATH',
|
|
2540
|
+
'PATH_FS',
|
|
2541
|
+
'UTF8Decoder',
|
|
2542
|
+
'UTF8ArrayToString',
|
|
2543
|
+
'UTF8ToString',
|
|
2544
|
+
'stringToUTF8Array',
|
|
2545
|
+
'stringToUTF8',
|
|
2546
|
+
'lengthBytesUTF8',
|
|
2547
|
+
'AsciiToString',
|
|
2548
|
+
'UTF16Decoder',
|
|
2549
|
+
'UTF16ToString',
|
|
2550
|
+
'stringToUTF16',
|
|
2551
|
+
'lengthBytesUTF16',
|
|
2552
|
+
'UTF32ToString',
|
|
2553
|
+
'stringToUTF32',
|
|
2554
|
+
'lengthBytesUTF32',
|
|
2555
|
+
'JSEvents',
|
|
2556
|
+
'specialHTMLTargets',
|
|
2557
|
+
'findCanvasEventTarget',
|
|
2558
|
+
'currentFullscreenStrategy',
|
|
2559
|
+
'restoreOldWindowedStyle',
|
|
2560
|
+
'UNWIND_CACHE',
|
|
2561
|
+
'ExitStatus',
|
|
2562
|
+
'getEnvStrings',
|
|
2563
|
+
'flush_NO_FILESYSTEM',
|
|
2564
|
+
'emSetImmediate',
|
|
2565
|
+
'emClearImmediate_deps',
|
|
2566
|
+
'emClearImmediate',
|
|
2567
|
+
'promiseMap',
|
|
2568
|
+
'uncaughtExceptionCount',
|
|
2569
|
+
'exceptionLast',
|
|
2570
|
+
'exceptionCaught',
|
|
2571
|
+
'ExceptionInfo',
|
|
2572
|
+
'findMatchingCatch',
|
|
2573
|
+
'getExceptionMessageCommon',
|
|
2574
|
+
'Browser',
|
|
2575
|
+
'requestFullscreen',
|
|
2576
|
+
'requestFullScreen',
|
|
2577
|
+
'setCanvasSize',
|
|
2578
|
+
'getUserMedia',
|
|
2579
|
+
'createContext',
|
|
2580
|
+
'getPreloadedImageData__data',
|
|
2581
|
+
'wget',
|
|
2582
|
+
'MONTH_DAYS_REGULAR',
|
|
2583
|
+
'MONTH_DAYS_LEAP',
|
|
2584
|
+
'MONTH_DAYS_REGULAR_CUMULATIVE',
|
|
2585
|
+
'MONTH_DAYS_LEAP_CUMULATIVE',
|
|
2586
|
+
'SYSCALLS',
|
|
2587
|
+
'preloadPlugins',
|
|
2588
|
+
'FS_stdin_getChar_buffer',
|
|
2589
|
+
'FS_unlink',
|
|
2590
|
+
'FS_createPath',
|
|
2591
|
+
'FS_createDevice',
|
|
2592
|
+
'FS_readFile',
|
|
2593
|
+
'FS',
|
|
2594
|
+
'FS_root',
|
|
2595
|
+
'FS_mounts',
|
|
2596
|
+
'FS_devices',
|
|
2597
|
+
'FS_streams',
|
|
2598
|
+
'FS_nextInode',
|
|
2599
|
+
'FS_nameTable',
|
|
2600
|
+
'FS_currentPath',
|
|
2601
|
+
'FS_initialized',
|
|
2602
|
+
'FS_ignorePermissions',
|
|
2603
|
+
'FS_filesystems',
|
|
2604
|
+
'FS_syncFSRequests',
|
|
2605
|
+
'FS_readFiles',
|
|
2606
|
+
'FS_lookupPath',
|
|
2607
|
+
'FS_getPath',
|
|
2608
|
+
'FS_hashName',
|
|
2609
|
+
'FS_hashAddNode',
|
|
2610
|
+
'FS_hashRemoveNode',
|
|
2611
|
+
'FS_lookupNode',
|
|
2612
|
+
'FS_createNode',
|
|
2613
|
+
'FS_destroyNode',
|
|
2614
|
+
'FS_isRoot',
|
|
2615
|
+
'FS_isMountpoint',
|
|
2616
|
+
'FS_isFile',
|
|
2617
|
+
'FS_isDir',
|
|
2618
|
+
'FS_isLink',
|
|
2619
|
+
'FS_isChrdev',
|
|
2620
|
+
'FS_isBlkdev',
|
|
2621
|
+
'FS_isFIFO',
|
|
2622
|
+
'FS_isSocket',
|
|
2623
|
+
'FS_flagsToPermissionString',
|
|
2624
|
+
'FS_nodePermissions',
|
|
2625
|
+
'FS_mayLookup',
|
|
2626
|
+
'FS_mayCreate',
|
|
2627
|
+
'FS_mayDelete',
|
|
2628
|
+
'FS_mayOpen',
|
|
2629
|
+
'FS_checkOpExists',
|
|
2630
|
+
'FS_nextfd',
|
|
2631
|
+
'FS_getStreamChecked',
|
|
2632
|
+
'FS_getStream',
|
|
2633
|
+
'FS_createStream',
|
|
2634
|
+
'FS_closeStream',
|
|
2635
|
+
'FS_dupStream',
|
|
2636
|
+
'FS_doSetAttr',
|
|
2637
|
+
'FS_chrdev_stream_ops',
|
|
2638
|
+
'FS_major',
|
|
2639
|
+
'FS_minor',
|
|
2640
|
+
'FS_makedev',
|
|
2641
|
+
'FS_registerDevice',
|
|
2642
|
+
'FS_getDevice',
|
|
2643
|
+
'FS_getMounts',
|
|
2644
|
+
'FS_syncfs',
|
|
2645
|
+
'FS_mount',
|
|
2646
|
+
'FS_unmount',
|
|
2647
|
+
'FS_lookup',
|
|
2648
|
+
'FS_mknod',
|
|
2649
|
+
'FS_statfs',
|
|
2650
|
+
'FS_statfsStream',
|
|
2651
|
+
'FS_statfsNode',
|
|
2652
|
+
'FS_create',
|
|
2653
|
+
'FS_mkdir',
|
|
2654
|
+
'FS_mkdev',
|
|
2655
|
+
'FS_symlink',
|
|
2656
|
+
'FS_rename',
|
|
2657
|
+
'FS_rmdir',
|
|
2658
|
+
'FS_readdir',
|
|
2659
|
+
'FS_readlink',
|
|
2660
|
+
'FS_stat',
|
|
2661
|
+
'FS_fstat',
|
|
2662
|
+
'FS_lstat',
|
|
2663
|
+
'FS_doChmod',
|
|
2664
|
+
'FS_chmod',
|
|
2665
|
+
'FS_lchmod',
|
|
2666
|
+
'FS_fchmod',
|
|
2667
|
+
'FS_doChown',
|
|
2668
|
+
'FS_chown',
|
|
2669
|
+
'FS_lchown',
|
|
2670
|
+
'FS_fchown',
|
|
2671
|
+
'FS_doTruncate',
|
|
2672
|
+
'FS_truncate',
|
|
2673
|
+
'FS_ftruncate',
|
|
2674
|
+
'FS_utime',
|
|
2675
|
+
'FS_open',
|
|
2676
|
+
'FS_close',
|
|
2677
|
+
'FS_isClosed',
|
|
2678
|
+
'FS_llseek',
|
|
2679
|
+
'FS_read',
|
|
2680
|
+
'FS_write',
|
|
2681
|
+
'FS_mmap',
|
|
2682
|
+
'FS_msync',
|
|
2683
|
+
'FS_ioctl',
|
|
2684
|
+
'FS_writeFile',
|
|
2685
|
+
'FS_cwd',
|
|
2686
|
+
'FS_chdir',
|
|
2687
|
+
'FS_createDefaultDirectories',
|
|
2688
|
+
'FS_createDefaultDevices',
|
|
2689
|
+
'FS_createSpecialDirectories',
|
|
2690
|
+
'FS_createStandardStreams',
|
|
2691
|
+
'FS_staticInit',
|
|
2692
|
+
'FS_init',
|
|
2693
|
+
'FS_quit',
|
|
2694
|
+
'FS_findObject',
|
|
2695
|
+
'FS_analyzePath',
|
|
2696
|
+
'FS_createFile',
|
|
2697
|
+
'FS_createDataFile',
|
|
2698
|
+
'FS_forceLoadFile',
|
|
2699
|
+
'FS_createLazyFile',
|
|
2700
|
+
'FS_absolutePath',
|
|
2701
|
+
'FS_createFolder',
|
|
2702
|
+
'FS_createLink',
|
|
2703
|
+
'FS_joinPath',
|
|
2704
|
+
'FS_mmapAlloc',
|
|
2705
|
+
'FS_standardizePath',
|
|
2706
|
+
'MEMFS',
|
|
2707
|
+
'TTY',
|
|
2708
|
+
'PIPEFS',
|
|
2709
|
+
'SOCKFS',
|
|
2710
|
+
'tempFixedLengthArray',
|
|
2711
|
+
'miniTempWebGLFloatBuffers',
|
|
2712
|
+
'miniTempWebGLIntBuffers',
|
|
2713
|
+
'GL',
|
|
2714
|
+
'AL',
|
|
2715
|
+
'GLUT',
|
|
2716
|
+
'EGL',
|
|
2717
|
+
'GLEW',
|
|
2718
|
+
'IDBStore',
|
|
2719
|
+
'SDL',
|
|
2720
|
+
'SDL_gfx',
|
|
2721
|
+
'print',
|
|
2722
|
+
'printErr',
|
|
2723
|
+
'jstoi_s',
|
|
2724
|
+
'InternalError',
|
|
2725
|
+
'BindingError',
|
|
2726
|
+
'throwInternalError',
|
|
2727
|
+
'throwBindingError',
|
|
2728
|
+
'registeredTypes',
|
|
2729
|
+
'awaitingDependencies',
|
|
2730
|
+
'typeDependencies',
|
|
2731
|
+
'tupleRegistrations',
|
|
2732
|
+
'structRegistrations',
|
|
2733
|
+
'sharedRegisterType',
|
|
2734
|
+
'whenDependentTypesAreResolved',
|
|
2735
|
+
'getTypeName',
|
|
2736
|
+
'getFunctionName',
|
|
2737
|
+
'heap32VectorToArray',
|
|
2738
|
+
'usesDestructorStack',
|
|
2739
|
+
'checkArgCount',
|
|
2740
|
+
'getRequiredArgCount',
|
|
2741
|
+
'createJsInvoker',
|
|
2742
|
+
'UnboundTypeError',
|
|
2743
|
+
'EmValType',
|
|
2744
|
+
'EmValOptionalType',
|
|
2745
|
+
'throwUnboundTypeError',
|
|
2746
|
+
'ensureOverloadTable',
|
|
2747
|
+
'exposePublicSymbol',
|
|
2748
|
+
'replacePublicSymbol',
|
|
2749
|
+
'embindRepr',
|
|
2750
|
+
'registeredInstances',
|
|
2751
|
+
'registeredPointers',
|
|
2752
|
+
'registerType',
|
|
2753
|
+
'integerReadValueFromPointer',
|
|
2754
|
+
'floatReadValueFromPointer',
|
|
2755
|
+
'assertIntegerRange',
|
|
2756
|
+
'readPointer',
|
|
2757
|
+
'runDestructors',
|
|
2758
|
+
'craftInvokerFunction',
|
|
2759
|
+
'embind__requireFunction',
|
|
2760
|
+
'finalizationRegistry',
|
|
2761
|
+
'detachFinalizer_deps',
|
|
2762
|
+
'deletionQueue',
|
|
2763
|
+
'delayFunction',
|
|
2764
|
+
'emval_freelist',
|
|
2765
|
+
'emval_handles',
|
|
2766
|
+
'emval_symbols',
|
|
2767
|
+
'Emval',
|
|
2768
|
+
'emval_methodCallers',
|
|
2769
|
+
];
|
|
2770
|
+
unexportedSymbols.forEach(unexportedRuntimeSymbol);
|
|
2771
|
+
|
|
2772
|
+
// End runtime exports
|
|
2773
|
+
// Begin JS library exports
|
|
2774
|
+
Module['incrementExceptionRefcount'] = incrementExceptionRefcount;
|
|
2775
|
+
Module['decrementExceptionRefcount'] = decrementExceptionRefcount;
|
|
2776
|
+
Module['getExceptionMessage'] = getExceptionMessage;
|
|
2777
|
+
// End JS library exports
|
|
2778
|
+
|
|
2779
|
+
// end include: postlibrary.js
|
|
2780
|
+
|
|
2781
|
+
function checkIncomingModuleAPI() {
|
|
2782
|
+
ignoredModuleProp('fetchSettings');
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
// Imports from the Wasm binary.
|
|
2786
|
+
var ___getTypeName = makeInvalidEarlyAccess('___getTypeName');
|
|
2787
|
+
var _fflush = makeInvalidEarlyAccess('_fflush');
|
|
2788
|
+
var _emscripten_stack_get_end = makeInvalidEarlyAccess('_emscripten_stack_get_end');
|
|
2789
|
+
var _emscripten_stack_get_base = makeInvalidEarlyAccess('_emscripten_stack_get_base');
|
|
2790
|
+
var _malloc = makeInvalidEarlyAccess('_malloc');
|
|
2791
|
+
var _strerror = makeInvalidEarlyAccess('_strerror');
|
|
2792
|
+
var _free = makeInvalidEarlyAccess('_free');
|
|
2793
|
+
var _setThrew = makeInvalidEarlyAccess('_setThrew');
|
|
2794
|
+
var __emscripten_tempret_set = makeInvalidEarlyAccess('__emscripten_tempret_set');
|
|
2795
|
+
var _emscripten_stack_init = makeInvalidEarlyAccess('_emscripten_stack_init');
|
|
2796
|
+
var _emscripten_stack_get_free = makeInvalidEarlyAccess('_emscripten_stack_get_free');
|
|
2797
|
+
var __emscripten_stack_restore = makeInvalidEarlyAccess('__emscripten_stack_restore');
|
|
2798
|
+
var __emscripten_stack_alloc = makeInvalidEarlyAccess('__emscripten_stack_alloc');
|
|
2799
|
+
var _emscripten_stack_get_current = makeInvalidEarlyAccess('_emscripten_stack_get_current');
|
|
2800
|
+
var ___cxa_decrement_exception_refcount = makeInvalidEarlyAccess('___cxa_decrement_exception_refcount');
|
|
2801
|
+
var ___cxa_increment_exception_refcount = makeInvalidEarlyAccess('___cxa_increment_exception_refcount');
|
|
2802
|
+
var ___cxa_free_exception = makeInvalidEarlyAccess('___cxa_free_exception');
|
|
2803
|
+
var ___get_exception_message = makeInvalidEarlyAccess('___get_exception_message');
|
|
2804
|
+
var ___cxa_can_catch = makeInvalidEarlyAccess('___cxa_can_catch');
|
|
2805
|
+
var ___cxa_get_exception_ptr = makeInvalidEarlyAccess('___cxa_get_exception_ptr');
|
|
2806
|
+
var memory = makeInvalidEarlyAccess('memory');
|
|
2807
|
+
var __indirect_function_table = makeInvalidEarlyAccess('__indirect_function_table');
|
|
2808
|
+
var wasmMemory = makeInvalidEarlyAccess('wasmMemory');
|
|
2809
|
+
var wasmTable = makeInvalidEarlyAccess('wasmTable');
|
|
2810
|
+
|
|
2811
|
+
function assignWasmExports(wasmExports) {
|
|
2812
|
+
assert(typeof wasmExports['__getTypeName'] != 'undefined', 'missing Wasm export: __getTypeName');
|
|
2813
|
+
assert(typeof wasmExports['fflush'] != 'undefined', 'missing Wasm export: fflush');
|
|
2814
|
+
assert(typeof wasmExports['emscripten_stack_get_end'] != 'undefined', 'missing Wasm export: emscripten_stack_get_end');
|
|
2815
|
+
assert(typeof wasmExports['emscripten_stack_get_base'] != 'undefined', 'missing Wasm export: emscripten_stack_get_base');
|
|
2816
|
+
assert(typeof wasmExports['malloc'] != 'undefined', 'missing Wasm export: malloc');
|
|
2817
|
+
assert(typeof wasmExports['strerror'] != 'undefined', 'missing Wasm export: strerror');
|
|
2818
|
+
assert(typeof wasmExports['free'] != 'undefined', 'missing Wasm export: free');
|
|
2819
|
+
assert(typeof wasmExports['setThrew'] != 'undefined', 'missing Wasm export: setThrew');
|
|
2820
|
+
assert(typeof wasmExports['_emscripten_tempret_set'] != 'undefined', 'missing Wasm export: _emscripten_tempret_set');
|
|
2821
|
+
assert(typeof wasmExports['emscripten_stack_init'] != 'undefined', 'missing Wasm export: emscripten_stack_init');
|
|
2822
|
+
assert(typeof wasmExports['emscripten_stack_get_free'] != 'undefined', 'missing Wasm export: emscripten_stack_get_free');
|
|
2823
|
+
assert(typeof wasmExports['_emscripten_stack_restore'] != 'undefined', 'missing Wasm export: _emscripten_stack_restore');
|
|
2824
|
+
assert(typeof wasmExports['_emscripten_stack_alloc'] != 'undefined', 'missing Wasm export: _emscripten_stack_alloc');
|
|
2825
|
+
assert(typeof wasmExports['emscripten_stack_get_current'] != 'undefined', 'missing Wasm export: emscripten_stack_get_current');
|
|
2826
|
+
assert(typeof wasmExports['__cxa_decrement_exception_refcount'] != 'undefined', 'missing Wasm export: __cxa_decrement_exception_refcount');
|
|
2827
|
+
assert(typeof wasmExports['__cxa_increment_exception_refcount'] != 'undefined', 'missing Wasm export: __cxa_increment_exception_refcount');
|
|
2828
|
+
assert(typeof wasmExports['__cxa_free_exception'] != 'undefined', 'missing Wasm export: __cxa_free_exception');
|
|
2829
|
+
assert(typeof wasmExports['__get_exception_message'] != 'undefined', 'missing Wasm export: __get_exception_message');
|
|
2830
|
+
assert(typeof wasmExports['__cxa_can_catch'] != 'undefined', 'missing Wasm export: __cxa_can_catch');
|
|
2831
|
+
assert(typeof wasmExports['__cxa_get_exception_ptr'] != 'undefined', 'missing Wasm export: __cxa_get_exception_ptr');
|
|
2832
|
+
assert(typeof wasmExports['memory'] != 'undefined', 'missing Wasm export: memory');
|
|
2833
|
+
assert(typeof wasmExports['__indirect_function_table'] != 'undefined', 'missing Wasm export: __indirect_function_table');
|
|
2834
|
+
___getTypeName = createExportWrapper('__getTypeName', 1);
|
|
2835
|
+
_fflush = createExportWrapper('fflush', 1);
|
|
2836
|
+
_emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'];
|
|
2837
|
+
_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'];
|
|
2838
|
+
_malloc = createExportWrapper('malloc', 1);
|
|
2839
|
+
_strerror = createExportWrapper('strerror', 1);
|
|
2840
|
+
_free = createExportWrapper('free', 1);
|
|
2841
|
+
_setThrew = createExportWrapper('setThrew', 2);
|
|
2842
|
+
__emscripten_tempret_set = createExportWrapper('_emscripten_tempret_set', 1);
|
|
2843
|
+
_emscripten_stack_init = wasmExports['emscripten_stack_init'];
|
|
2844
|
+
_emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'];
|
|
2845
|
+
__emscripten_stack_restore = wasmExports['_emscripten_stack_restore'];
|
|
2846
|
+
__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'];
|
|
2847
|
+
_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'];
|
|
2848
|
+
___cxa_decrement_exception_refcount = createExportWrapper('__cxa_decrement_exception_refcount', 1);
|
|
2849
|
+
___cxa_increment_exception_refcount = createExportWrapper('__cxa_increment_exception_refcount', 1);
|
|
2850
|
+
___cxa_free_exception = createExportWrapper('__cxa_free_exception', 1);
|
|
2851
|
+
___get_exception_message = createExportWrapper('__get_exception_message', 3);
|
|
2852
|
+
___cxa_can_catch = createExportWrapper('__cxa_can_catch', 3);
|
|
2853
|
+
___cxa_get_exception_ptr = createExportWrapper('__cxa_get_exception_ptr', 1);
|
|
2854
|
+
memory = wasmMemory = wasmExports['memory'];
|
|
2855
|
+
__indirect_function_table = wasmTable = wasmExports['__indirect_function_table'];
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2858
|
+
var wasmImports = {
|
|
2859
|
+
/** @export */
|
|
2860
|
+
__assert_fail: ___assert_fail,
|
|
2861
|
+
/** @export */
|
|
2862
|
+
__cxa_begin_catch: ___cxa_begin_catch,
|
|
2863
|
+
/** @export */
|
|
2864
|
+
__cxa_find_matching_catch_2: ___cxa_find_matching_catch_2,
|
|
2865
|
+
/** @export */
|
|
2866
|
+
__cxa_find_matching_catch_3: ___cxa_find_matching_catch_3,
|
|
2867
|
+
/** @export */
|
|
2868
|
+
__cxa_throw: ___cxa_throw,
|
|
2869
|
+
/** @export */
|
|
2870
|
+
__resumeException: ___resumeException,
|
|
2871
|
+
/** @export */
|
|
2872
|
+
_abort_js: __abort_js,
|
|
2873
|
+
/** @export */
|
|
2874
|
+
_embind_register_bigint: __embind_register_bigint,
|
|
2875
|
+
/** @export */
|
|
2876
|
+
_embind_register_bool: __embind_register_bool,
|
|
2877
|
+
/** @export */
|
|
2878
|
+
_embind_register_emval: __embind_register_emval,
|
|
2879
|
+
/** @export */
|
|
2880
|
+
_embind_register_float: __embind_register_float,
|
|
2881
|
+
/** @export */
|
|
2882
|
+
_embind_register_function: __embind_register_function,
|
|
2883
|
+
/** @export */
|
|
2884
|
+
_embind_register_integer: __embind_register_integer,
|
|
2885
|
+
/** @export */
|
|
2886
|
+
_embind_register_memory_view: __embind_register_memory_view,
|
|
2887
|
+
/** @export */
|
|
2888
|
+
_embind_register_std_string: __embind_register_std_string,
|
|
2889
|
+
/** @export */
|
|
2890
|
+
_embind_register_std_wstring: __embind_register_std_wstring,
|
|
2891
|
+
/** @export */
|
|
2892
|
+
_embind_register_void: __embind_register_void,
|
|
2893
|
+
/** @export */
|
|
2894
|
+
_tzset_js: __tzset_js,
|
|
2895
|
+
/** @export */
|
|
2896
|
+
emscripten_resize_heap: _emscripten_resize_heap,
|
|
2897
|
+
/** @export */
|
|
2898
|
+
environ_get: _environ_get,
|
|
2899
|
+
/** @export */
|
|
2900
|
+
environ_sizes_get: _environ_sizes_get,
|
|
2901
|
+
/** @export */
|
|
2902
|
+
fd_close: _fd_close,
|
|
2903
|
+
/** @export */
|
|
2904
|
+
fd_seek: _fd_seek,
|
|
2905
|
+
/** @export */
|
|
2906
|
+
fd_write: _fd_write,
|
|
2907
|
+
/** @export */
|
|
2908
|
+
invoke_diii,
|
|
2909
|
+
/** @export */
|
|
2910
|
+
invoke_fiii,
|
|
2911
|
+
/** @export */
|
|
2912
|
+
invoke_i,
|
|
2913
|
+
/** @export */
|
|
2914
|
+
invoke_ii,
|
|
2915
|
+
/** @export */
|
|
2916
|
+
invoke_iii,
|
|
2917
|
+
/** @export */
|
|
2918
|
+
invoke_iiii,
|
|
2919
|
+
/** @export */
|
|
2920
|
+
invoke_iiiii,
|
|
2921
|
+
/** @export */
|
|
2922
|
+
invoke_iiiiii,
|
|
2923
|
+
/** @export */
|
|
2924
|
+
invoke_iiiiiii,
|
|
2925
|
+
/** @export */
|
|
2926
|
+
invoke_iiiiiiii,
|
|
2927
|
+
/** @export */
|
|
2928
|
+
invoke_iiiiiiiiiii,
|
|
2929
|
+
/** @export */
|
|
2930
|
+
invoke_iiiiiiiiiiii,
|
|
2931
|
+
/** @export */
|
|
2932
|
+
invoke_iiiiiiiiiiiii,
|
|
2933
|
+
/** @export */
|
|
2934
|
+
invoke_jiiii,
|
|
2935
|
+
/** @export */
|
|
2936
|
+
invoke_v,
|
|
2937
|
+
/** @export */
|
|
2938
|
+
invoke_vi,
|
|
2939
|
+
/** @export */
|
|
2940
|
+
invoke_vii,
|
|
2941
|
+
/** @export */
|
|
2942
|
+
invoke_viii,
|
|
2943
|
+
/** @export */
|
|
2944
|
+
invoke_viiidi,
|
|
2945
|
+
/** @export */
|
|
2946
|
+
invoke_viiifi,
|
|
2947
|
+
/** @export */
|
|
2948
|
+
invoke_viiii,
|
|
2949
|
+
/** @export */
|
|
2950
|
+
invoke_viiiiiii,
|
|
2951
|
+
/** @export */
|
|
2952
|
+
invoke_viiiiiiiiii,
|
|
2953
|
+
/** @export */
|
|
2954
|
+
invoke_viiiiiiiiiiiiiii
|
|
2955
|
+
};
|
|
2956
|
+
|
|
2957
|
+
function invoke_viiifi(index,a1,a2,a3,a4,a5) {
|
|
2958
|
+
var sp = stackSave();
|
|
2959
|
+
try {
|
|
2960
|
+
getWasmTableEntry(index)(a1,a2,a3,a4,a5);
|
|
2961
|
+
} catch(e) {
|
|
2962
|
+
stackRestore(sp);
|
|
2963
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
2964
|
+
_setThrew(1, 0);
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
function invoke_viiidi(index,a1,a2,a3,a4,a5) {
|
|
2969
|
+
var sp = stackSave();
|
|
2970
|
+
try {
|
|
2971
|
+
getWasmTableEntry(index)(a1,a2,a3,a4,a5);
|
|
2972
|
+
} catch(e) {
|
|
2973
|
+
stackRestore(sp);
|
|
2974
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
2975
|
+
_setThrew(1, 0);
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
function invoke_viiii(index,a1,a2,a3,a4) {
|
|
2980
|
+
var sp = stackSave();
|
|
2981
|
+
try {
|
|
2982
|
+
getWasmTableEntry(index)(a1,a2,a3,a4);
|
|
2983
|
+
} catch(e) {
|
|
2984
|
+
stackRestore(sp);
|
|
2985
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
2986
|
+
_setThrew(1, 0);
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
function invoke_iiii(index,a1,a2,a3) {
|
|
2991
|
+
var sp = stackSave();
|
|
2992
|
+
try {
|
|
2993
|
+
return getWasmTableEntry(index)(a1,a2,a3);
|
|
2994
|
+
} catch(e) {
|
|
2995
|
+
stackRestore(sp);
|
|
2996
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
2997
|
+
_setThrew(1, 0);
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
|
|
3001
|
+
function invoke_iii(index,a1,a2) {
|
|
3002
|
+
var sp = stackSave();
|
|
3003
|
+
try {
|
|
3004
|
+
return getWasmTableEntry(index)(a1,a2);
|
|
3005
|
+
} catch(e) {
|
|
3006
|
+
stackRestore(sp);
|
|
3007
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3008
|
+
_setThrew(1, 0);
|
|
3009
|
+
}
|
|
3010
|
+
}
|
|
3011
|
+
|
|
3012
|
+
function invoke_ii(index,a1) {
|
|
3013
|
+
var sp = stackSave();
|
|
3014
|
+
try {
|
|
3015
|
+
return getWasmTableEntry(index)(a1);
|
|
3016
|
+
} catch(e) {
|
|
3017
|
+
stackRestore(sp);
|
|
3018
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3019
|
+
_setThrew(1, 0);
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
|
|
3023
|
+
function invoke_vii(index,a1,a2) {
|
|
3024
|
+
var sp = stackSave();
|
|
3025
|
+
try {
|
|
3026
|
+
getWasmTableEntry(index)(a1,a2);
|
|
3027
|
+
} catch(e) {
|
|
3028
|
+
stackRestore(sp);
|
|
3029
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3030
|
+
_setThrew(1, 0);
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
|
|
3034
|
+
function invoke_vi(index,a1) {
|
|
3035
|
+
var sp = stackSave();
|
|
3036
|
+
try {
|
|
3037
|
+
getWasmTableEntry(index)(a1);
|
|
3038
|
+
} catch(e) {
|
|
3039
|
+
stackRestore(sp);
|
|
3040
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3041
|
+
_setThrew(1, 0);
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
|
|
3045
|
+
function invoke_v(index) {
|
|
3046
|
+
var sp = stackSave();
|
|
3047
|
+
try {
|
|
3048
|
+
getWasmTableEntry(index)();
|
|
3049
|
+
} catch(e) {
|
|
3050
|
+
stackRestore(sp);
|
|
3051
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3052
|
+
_setThrew(1, 0);
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
|
|
3056
|
+
function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6) {
|
|
3057
|
+
var sp = stackSave();
|
|
3058
|
+
try {
|
|
3059
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6);
|
|
3060
|
+
} catch(e) {
|
|
3061
|
+
stackRestore(sp);
|
|
3062
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3063
|
+
_setThrew(1, 0);
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
function invoke_iiiiii(index,a1,a2,a3,a4,a5) {
|
|
3068
|
+
var sp = stackSave();
|
|
3069
|
+
try {
|
|
3070
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5);
|
|
3071
|
+
} catch(e) {
|
|
3072
|
+
stackRestore(sp);
|
|
3073
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3074
|
+
_setThrew(1, 0);
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
function invoke_viii(index,a1,a2,a3) {
|
|
3079
|
+
var sp = stackSave();
|
|
3080
|
+
try {
|
|
3081
|
+
getWasmTableEntry(index)(a1,a2,a3);
|
|
3082
|
+
} catch(e) {
|
|
3083
|
+
stackRestore(sp);
|
|
3084
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3085
|
+
_setThrew(1, 0);
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
function invoke_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7) {
|
|
3090
|
+
var sp = stackSave();
|
|
3091
|
+
try {
|
|
3092
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7);
|
|
3093
|
+
} catch(e) {
|
|
3094
|
+
stackRestore(sp);
|
|
3095
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3096
|
+
_setThrew(1, 0);
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3100
|
+
function invoke_iiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) {
|
|
3101
|
+
var sp = stackSave();
|
|
3102
|
+
try {
|
|
3103
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);
|
|
3104
|
+
} catch(e) {
|
|
3105
|
+
stackRestore(sp);
|
|
3106
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3107
|
+
_setThrew(1, 0);
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
function invoke_iiiii(index,a1,a2,a3,a4) {
|
|
3112
|
+
var sp = stackSave();
|
|
3113
|
+
try {
|
|
3114
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4);
|
|
3115
|
+
} catch(e) {
|
|
3116
|
+
stackRestore(sp);
|
|
3117
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3118
|
+
_setThrew(1, 0);
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
|
|
3122
|
+
function invoke_jiiii(index,a1,a2,a3,a4) {
|
|
3123
|
+
var sp = stackSave();
|
|
3124
|
+
try {
|
|
3125
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4);
|
|
3126
|
+
} catch(e) {
|
|
3127
|
+
stackRestore(sp);
|
|
3128
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3129
|
+
_setThrew(1, 0);
|
|
3130
|
+
return 0n;
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
|
|
3134
|
+
function invoke_iiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) {
|
|
3135
|
+
var sp = stackSave();
|
|
3136
|
+
try {
|
|
3137
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12);
|
|
3138
|
+
} catch(e) {
|
|
3139
|
+
stackRestore(sp);
|
|
3140
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3141
|
+
_setThrew(1, 0);
|
|
3142
|
+
}
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3145
|
+
function invoke_fiii(index,a1,a2,a3) {
|
|
3146
|
+
var sp = stackSave();
|
|
3147
|
+
try {
|
|
3148
|
+
return getWasmTableEntry(index)(a1,a2,a3);
|
|
3149
|
+
} catch(e) {
|
|
3150
|
+
stackRestore(sp);
|
|
3151
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3152
|
+
_setThrew(1, 0);
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
|
|
3156
|
+
function invoke_diii(index,a1,a2,a3) {
|
|
3157
|
+
var sp = stackSave();
|
|
3158
|
+
try {
|
|
3159
|
+
return getWasmTableEntry(index)(a1,a2,a3);
|
|
3160
|
+
} catch(e) {
|
|
3161
|
+
stackRestore(sp);
|
|
3162
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3163
|
+
_setThrew(1, 0);
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
|
|
3167
|
+
function invoke_i(index) {
|
|
3168
|
+
var sp = stackSave();
|
|
3169
|
+
try {
|
|
3170
|
+
return getWasmTableEntry(index)();
|
|
3171
|
+
} catch(e) {
|
|
3172
|
+
stackRestore(sp);
|
|
3173
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3174
|
+
_setThrew(1, 0);
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3178
|
+
function invoke_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7) {
|
|
3179
|
+
var sp = stackSave();
|
|
3180
|
+
try {
|
|
3181
|
+
getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7);
|
|
3182
|
+
} catch(e) {
|
|
3183
|
+
stackRestore(sp);
|
|
3184
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3185
|
+
_setThrew(1, 0);
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
function invoke_iiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) {
|
|
3190
|
+
var sp = stackSave();
|
|
3191
|
+
try {
|
|
3192
|
+
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11);
|
|
3193
|
+
} catch(e) {
|
|
3194
|
+
stackRestore(sp);
|
|
3195
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3196
|
+
_setThrew(1, 0);
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3200
|
+
function invoke_viiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) {
|
|
3201
|
+
var sp = stackSave();
|
|
3202
|
+
try {
|
|
3203
|
+
getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);
|
|
3204
|
+
} catch(e) {
|
|
3205
|
+
stackRestore(sp);
|
|
3206
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3207
|
+
_setThrew(1, 0);
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
|
|
3211
|
+
function invoke_viiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) {
|
|
3212
|
+
var sp = stackSave();
|
|
3213
|
+
try {
|
|
3214
|
+
getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15);
|
|
3215
|
+
} catch(e) {
|
|
3216
|
+
stackRestore(sp);
|
|
3217
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
3218
|
+
_setThrew(1, 0);
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3222
|
+
|
|
3223
|
+
// include: postamble.js
|
|
3224
|
+
// === Auto-generated postamble setup entry stuff ===
|
|
3225
|
+
|
|
3226
|
+
var calledRun;
|
|
3227
|
+
|
|
3228
|
+
function stackCheckInit() {
|
|
3229
|
+
// This is normally called automatically during __wasm_call_ctors but need to
|
|
3230
|
+
// get these values before even running any of the ctors so we call it redundantly
|
|
3231
|
+
// here.
|
|
3232
|
+
_emscripten_stack_init();
|
|
3233
|
+
// TODO(sbc): Move writeStackCookie to native to to avoid this.
|
|
3234
|
+
writeStackCookie();
|
|
3235
|
+
}
|
|
3236
|
+
|
|
3237
|
+
function run() {
|
|
3238
|
+
|
|
3239
|
+
stackCheckInit();
|
|
3240
|
+
|
|
3241
|
+
preRun();
|
|
3242
|
+
|
|
3243
|
+
function doRun() {
|
|
3244
|
+
// run may have just been called through dependencies being fulfilled just in this very frame,
|
|
3245
|
+
// or while the async setStatus time below was happening
|
|
3246
|
+
assert(!calledRun);
|
|
3247
|
+
calledRun = true;
|
|
3248
|
+
Module['calledRun'] = true;
|
|
3249
|
+
|
|
3250
|
+
if (ABORT) return;
|
|
3251
|
+
|
|
3252
|
+
initRuntime();
|
|
3253
|
+
|
|
3254
|
+
readyPromiseResolve?.(Module);
|
|
3255
|
+
Module['onRuntimeInitialized']?.();
|
|
3256
|
+
consumedModuleProp('onRuntimeInitialized');
|
|
3257
|
+
|
|
3258
|
+
assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
|
|
3259
|
+
|
|
3260
|
+
postRun();
|
|
3261
|
+
}
|
|
3262
|
+
|
|
3263
|
+
if (Module['setStatus']) {
|
|
3264
|
+
Module['setStatus']('Running...');
|
|
3265
|
+
setTimeout(() => {
|
|
3266
|
+
setTimeout(() => Module['setStatus'](''), 1);
|
|
3267
|
+
doRun();
|
|
3268
|
+
}, 1);
|
|
3269
|
+
} else
|
|
3270
|
+
{
|
|
3271
|
+
doRun();
|
|
3272
|
+
}
|
|
3273
|
+
checkStackCookie();
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
function checkUnflushedContent() {
|
|
3277
|
+
// Compiler settings do not allow exiting the runtime, so flushing
|
|
3278
|
+
// the streams is not possible. but in ASSERTIONS mode we check
|
|
3279
|
+
// if there was something to flush, and if so tell the user they
|
|
3280
|
+
// should request that the runtime be exitable.
|
|
3281
|
+
// Normally we would not even include flush() at all, but in ASSERTIONS
|
|
3282
|
+
// builds we do so just for this check, and here we see if there is any
|
|
3283
|
+
// content to flush, that is, we check if there would have been
|
|
3284
|
+
// something a non-ASSERTIONS build would have not seen.
|
|
3285
|
+
// How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0
|
|
3286
|
+
// mode (which has its own special function for this; otherwise, all
|
|
3287
|
+
// the code is inside libc)
|
|
3288
|
+
var oldOut = out;
|
|
3289
|
+
var oldErr = err;
|
|
3290
|
+
var has = false;
|
|
3291
|
+
out = err = (x) => {
|
|
3292
|
+
has = true;
|
|
3293
|
+
}
|
|
3294
|
+
try { // it doesn't matter if it fails
|
|
3295
|
+
flush_NO_FILESYSTEM();
|
|
3296
|
+
} catch(e) {}
|
|
3297
|
+
out = oldOut;
|
|
3298
|
+
err = oldErr;
|
|
3299
|
+
if (has) {
|
|
3300
|
+
warnOnce('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.');
|
|
3301
|
+
warnOnce('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)');
|
|
3302
|
+
}
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
var wasmExports;
|
|
3306
|
+
|
|
3307
|
+
// In modularize mode the generated code is within a factory function so we
|
|
3308
|
+
// can use await here (since it's not top-level-await).
|
|
3309
|
+
wasmExports = await (createWasm());
|
|
3310
|
+
|
|
3311
|
+
run();
|
|
3312
|
+
|
|
3313
|
+
// end include: postamble.js
|
|
3314
|
+
|
|
3315
|
+
// include: postamble_modularize.js
|
|
3316
|
+
// In MODULARIZE mode we wrap the generated code in a factory function
|
|
3317
|
+
// and return either the Module itself, or a promise of the module.
|
|
3318
|
+
//
|
|
3319
|
+
// We assign to the `moduleRtn` global here and configure closure to see
|
|
3320
|
+
// this as and extern so it won't get minified.
|
|
3321
|
+
|
|
3322
|
+
if (runtimeInitialized) {
|
|
3323
|
+
moduleRtn = Module;
|
|
3324
|
+
} else {
|
|
3325
|
+
// Set up the promise that indicates the Module is initialized
|
|
3326
|
+
moduleRtn = new Promise((resolve, reject) => {
|
|
3327
|
+
readyPromiseResolve = resolve;
|
|
3328
|
+
readyPromiseReject = reject;
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
// Assertion for attempting to access module properties on the incoming
|
|
3333
|
+
// moduleArg. In the past we used this object as the prototype of the module
|
|
3334
|
+
// and assigned properties to it, but now we return a distinct object. This
|
|
3335
|
+
// keeps the instance private until it is ready (i.e the promise has been
|
|
3336
|
+
// resolved).
|
|
3337
|
+
for (const prop of Object.keys(Module)) {
|
|
3338
|
+
if (!(prop in moduleArg)) {
|
|
3339
|
+
Object.defineProperty(moduleArg, prop, {
|
|
3340
|
+
configurable: true,
|
|
3341
|
+
get() {
|
|
3342
|
+
abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)
|
|
3343
|
+
}
|
|
3344
|
+
});
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
// end include: postamble_modularize.js
|
|
3348
|
+
|
|
3349
|
+
|
|
3350
|
+
|
|
3351
|
+
return moduleRtn;
|
|
3352
|
+
}
|
|
3353
|
+
|
|
3354
|
+
// Export using a UMD style export, or ES6 exports if selected
|
|
3355
|
+
export default UnicodeWidthApproximationWASMModule;
|
|
3356
|
+
|