autumnplot-gl 3.2.0 → 4.0.0-beta
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/lib/AutumnTypes.d.ts +53 -5
- package/lib/AutumnTypes.js +25 -1
- package/lib/Barbs.d.ts +6 -5
- package/lib/BillboardCollection.d.ts +8 -7
- package/lib/BillboardCollection.js +69 -58
- package/lib/Color.d.ts +1 -0
- package/lib/Color.js +3 -0
- package/lib/ColorBar.d.ts +10 -0
- package/lib/ColorBar.js +4 -2
- package/lib/Colormap.js +8 -8
- package/lib/Contour.d.ts +18 -8
- package/lib/Contour.js +17 -54
- package/lib/ContourCreator.d.ts +4 -0
- package/lib/ContourCreator.js +2 -1
- package/lib/Fill.d.ts +26 -14
- package/lib/Fill.js +97 -50
- package/lib/Grid.d.ts +124 -29
- package/lib/Grid.js +297 -94
- package/lib/Hodographs.d.ts +9 -8
- package/lib/Hodographs.js +14 -11
- package/lib/Map.js +1 -1
- package/lib/Paintball.d.ts +6 -5
- package/lib/Paintball.js +35 -30
- package/lib/ParticleTracer.d.ts +19 -0
- package/lib/ParticleTracer.js +37 -0
- package/lib/PlotComponent.d.ts +6 -7
- package/lib/PlotComponent.js +8 -3
- package/lib/PlotLayer.d.ts +3 -3
- package/lib/PlotLayer.worker.d.ts +1 -2
- package/lib/PlotLayer.worker.js +15 -50
- package/lib/PolylineCollection.d.ts +5 -3
- package/lib/PolylineCollection.js +60 -37
- package/lib/RawField.d.ts +76 -23
- package/lib/RawField.js +138 -29
- package/lib/ShaderManager.d.ts +12 -0
- package/lib/ShaderManager.js +58 -0
- package/lib/StationPlot.d.ts +136 -25
- package/lib/StationPlot.js +192 -60
- package/lib/TextCollection.d.ts +9 -6
- package/lib/TextCollection.js +94 -62
- package/lib/cpp/marchingsquares.js +483 -585
- package/lib/cpp/marchingsquares.wasm +0 -0
- package/lib/cpp/marchingsquares_embind.d.ts +23 -3
- package/lib/index.d.ts +4 -3
- package/lib/index.js +4 -3
- package/lib/utils.d.ts +4 -1
- package/lib/utils.js +12 -1
- package/package.json +2 -2
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
var Module = (() => {
|
|
3
|
-
var
|
|
3
|
+
var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
|
|
4
4
|
|
|
5
5
|
return (
|
|
6
6
|
function(moduleArg = {}) {
|
|
7
|
+
var moduleRtn;
|
|
7
8
|
|
|
8
9
|
// include: shell.js
|
|
9
10
|
// The Module object: Our interface to the outside world. We import
|
|
10
11
|
// and export values on it. There are various ways Module can be used:
|
|
11
12
|
// 1. Not defined. We create it here
|
|
12
|
-
// 2. A function parameter, function(
|
|
13
|
+
// 2. A function parameter, function(moduleArg) => Promise<Module>
|
|
13
14
|
// 3. pre-run appended it, var Module = {}; ..generated code..
|
|
14
15
|
// 4. External script tag defines var Module.
|
|
15
16
|
// We need to check if Module already exists (e.g. case 3 above).
|
|
@@ -23,19 +24,31 @@ var Module = moduleArg;
|
|
|
23
24
|
|
|
24
25
|
// Set up the promise that indicates the Module is initialized
|
|
25
26
|
var readyPromiseResolve, readyPromiseReject;
|
|
26
|
-
|
|
27
|
+
var readyPromise = new Promise((resolve, reject) => {
|
|
27
28
|
readyPromiseResolve = resolve;
|
|
28
29
|
readyPromiseReject = reject;
|
|
29
30
|
});
|
|
30
|
-
["
|
|
31
|
-
if (!Object.getOwnPropertyDescriptor(
|
|
32
|
-
Object.defineProperty(
|
|
31
|
+
["getExceptionMessage","incrementExceptionRefcount","decrementExceptionRefcount","_memory","___indirect_function_table","onRuntimeInitialized"].forEach((prop) => {
|
|
32
|
+
if (!Object.getOwnPropertyDescriptor(readyPromise, prop)) {
|
|
33
|
+
Object.defineProperty(readyPromise, prop, {
|
|
33
34
|
get: () => abort('You are getting ' + prop + ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'),
|
|
34
35
|
set: () => abort('You are setting ' + prop + ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'),
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
});
|
|
38
39
|
|
|
40
|
+
// Determine the runtime environment we are in. You can customize this by
|
|
41
|
+
// setting the ENVIRONMENT setting at compile time (see settings.js).
|
|
42
|
+
|
|
43
|
+
var ENVIRONMENT_IS_WEB = true;
|
|
44
|
+
var ENVIRONMENT_IS_WORKER = false;
|
|
45
|
+
var ENVIRONMENT_IS_NODE = false;
|
|
46
|
+
var ENVIRONMENT_IS_SHELL = false;
|
|
47
|
+
|
|
48
|
+
if (Module['ENVIRONMENT']) {
|
|
49
|
+
throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');
|
|
50
|
+
}
|
|
51
|
+
|
|
39
52
|
// --pre-jses are emitted after the Module integration code, so that they can
|
|
40
53
|
// refer to Module (if they choose; they can also define Module)
|
|
41
54
|
|
|
@@ -53,18 +66,6 @@ var quit_ = (status, toThrow) => {
|
|
|
53
66
|
throw toThrow;
|
|
54
67
|
};
|
|
55
68
|
|
|
56
|
-
// Determine the runtime environment we are in. You can customize this by
|
|
57
|
-
// setting the ENVIRONMENT setting at compile time (see settings.js).
|
|
58
|
-
|
|
59
|
-
var ENVIRONMENT_IS_WEB = true;
|
|
60
|
-
var ENVIRONMENT_IS_WORKER = false;
|
|
61
|
-
var ENVIRONMENT_IS_NODE = false;
|
|
62
|
-
var ENVIRONMENT_IS_SHELL = false;
|
|
63
|
-
|
|
64
|
-
if (Module['ENVIRONMENT']) {
|
|
65
|
-
throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
69
|
// `/` should be present at the end if `scriptDirectory` is not empty
|
|
69
70
|
var scriptDirectory = '';
|
|
70
71
|
function locateFile(path) {
|
|
@@ -75,78 +76,12 @@ function locateFile(path) {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
// Hooks that are implemented differently in different runtime environments.
|
|
78
|
-
var
|
|
79
|
-
readAsync,
|
|
80
|
-
readBinary;
|
|
79
|
+
var readAsync, readBinary;
|
|
81
80
|
|
|
82
81
|
if (ENVIRONMENT_IS_SHELL) {
|
|
83
82
|
|
|
84
83
|
if ((typeof process == 'object' && typeof require === 'function') || typeof window == 'object' || typeof importScripts == 'function') 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?)');
|
|
85
84
|
|
|
86
|
-
if (typeof read != 'undefined') {
|
|
87
|
-
read_ = read;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
readBinary = (f) => {
|
|
91
|
-
if (typeof readbuffer == 'function') {
|
|
92
|
-
return new Uint8Array(readbuffer(f));
|
|
93
|
-
}
|
|
94
|
-
let data = read(f, 'binary');
|
|
95
|
-
assert(typeof data == 'object');
|
|
96
|
-
return data;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
readAsync = (f, onload, onerror) => {
|
|
100
|
-
setTimeout(() => onload(readBinary(f)));
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
if (typeof clearTimeout == 'undefined') {
|
|
104
|
-
globalThis.clearTimeout = (id) => {};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (typeof setTimeout == 'undefined') {
|
|
108
|
-
// spidermonkey lacks setTimeout but we use it above in readAsync.
|
|
109
|
-
globalThis.setTimeout = (f) => (typeof f == 'function') ? f() : abort();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (typeof scriptArgs != 'undefined') {
|
|
113
|
-
arguments_ = scriptArgs;
|
|
114
|
-
} else if (typeof arguments != 'undefined') {
|
|
115
|
-
arguments_ = arguments;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (typeof quit == 'function') {
|
|
119
|
-
quit_ = (status, toThrow) => {
|
|
120
|
-
// Unlike node which has process.exitCode, d8 has no such mechanism. So we
|
|
121
|
-
// have no way to set the exit code and then let the program exit with
|
|
122
|
-
// that code when it naturally stops running (say, when all setTimeouts
|
|
123
|
-
// have completed). For that reason, we must call `quit` - the only way to
|
|
124
|
-
// set the exit code - but quit also halts immediately. To increase
|
|
125
|
-
// consistency with node (and the web) we schedule the actual quit call
|
|
126
|
-
// using a setTimeout to give the current stack and any exception handlers
|
|
127
|
-
// a chance to run. This enables features such as addOnPostRun (which
|
|
128
|
-
// expected to be able to run code after main returns).
|
|
129
|
-
setTimeout(() => {
|
|
130
|
-
if (!(toThrow instanceof ExitStatus)) {
|
|
131
|
-
let toLog = toThrow;
|
|
132
|
-
if (toThrow && typeof toThrow == 'object' && toThrow.stack) {
|
|
133
|
-
toLog = [toThrow, toThrow.stack];
|
|
134
|
-
}
|
|
135
|
-
err(`exiting due to exception: ${toLog}`);
|
|
136
|
-
}
|
|
137
|
-
quit(status);
|
|
138
|
-
});
|
|
139
|
-
throw toThrow;
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (typeof print != 'undefined') {
|
|
144
|
-
// Prefer to use print/printErr where they exist, as they usually work better.
|
|
145
|
-
if (typeof console == 'undefined') console = /** @type{!Console} */({});
|
|
146
|
-
console.log = /** @type{!function(this:Console, ...*): undefined} */ (print);
|
|
147
|
-
console.warn = console.error = /** @type{!function(this:Console, ...*): undefined} */ (typeof printErr != 'undefined' ? printErr : print);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
85
|
} else
|
|
151
86
|
|
|
152
87
|
// Note that this includes Node.js workers when relevant (pthreads is enabled).
|
|
@@ -160,8 +95,8 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
|
160
95
|
}
|
|
161
96
|
// When MODULARIZE, this JS may be executed later, after document.currentScript
|
|
162
97
|
// is gone, so we saved it, and we use it here instead of any other info.
|
|
163
|
-
if (
|
|
164
|
-
scriptDirectory =
|
|
98
|
+
if (_scriptName) {
|
|
99
|
+
scriptDirectory = _scriptName;
|
|
165
100
|
}
|
|
166
101
|
// blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
|
|
167
102
|
// otherwise, slice off the final part of the url to find the script directory.
|
|
@@ -169,50 +104,26 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
|
169
104
|
// and scriptDirectory will correctly be replaced with an empty string.
|
|
170
105
|
// If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
|
|
171
106
|
// they are removed because they could contain a slash.
|
|
172
|
-
if (scriptDirectory.
|
|
173
|
-
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/')+1);
|
|
174
|
-
} else {
|
|
107
|
+
if (scriptDirectory.startsWith('blob:')) {
|
|
175
108
|
scriptDirectory = '';
|
|
109
|
+
} else {
|
|
110
|
+
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, '').lastIndexOf('/')+1);
|
|
176
111
|
}
|
|
177
112
|
|
|
178
113
|
if (!(typeof window == 'object' || typeof importScripts == 'function')) 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?)');
|
|
179
114
|
|
|
180
|
-
// Differentiate the Web Worker from the Node Worker case, as reading must
|
|
181
|
-
// be done differently.
|
|
182
115
|
{
|
|
183
116
|
// include: web_or_worker_shell_read.js
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
xhr.open('GET', url, false);
|
|
195
|
-
xhr.responseType = 'arraybuffer';
|
|
196
|
-
xhr.send(null);
|
|
197
|
-
return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
readAsync = (url, onload, onerror) => {
|
|
202
|
-
var xhr = new XMLHttpRequest();
|
|
203
|
-
xhr.open('GET', url, true);
|
|
204
|
-
xhr.responseType = 'arraybuffer';
|
|
205
|
-
xhr.onload = () => {
|
|
206
|
-
if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
|
|
207
|
-
onload(xhr.response);
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
onerror();
|
|
211
|
-
};
|
|
212
|
-
xhr.onerror = onerror;
|
|
213
|
-
xhr.send(null);
|
|
214
|
-
}
|
|
215
|
-
|
|
117
|
+
readAsync = (url) => {
|
|
118
|
+
assert(!isFileURI(url), "readAsync does not work with file:// URLs");
|
|
119
|
+
return fetch(url, { credentials: 'same-origin' })
|
|
120
|
+
.then((response) => {
|
|
121
|
+
if (response.ok) {
|
|
122
|
+
return response.arrayBuffer();
|
|
123
|
+
}
|
|
124
|
+
return Promise.reject(new Error(response.status + ' : ' + response.url));
|
|
125
|
+
})
|
|
126
|
+
};
|
|
216
127
|
// end include: web_or_worker_shell_read.js
|
|
217
128
|
}
|
|
218
129
|
} else
|
|
@@ -226,7 +137,7 @@ var err = Module['printErr'] || console.error.bind(console);
|
|
|
226
137
|
// Merge back in the overrides
|
|
227
138
|
Object.assign(Module, moduleOverrides);
|
|
228
139
|
// Free the object hierarchy contained in the overrides, this lets the GC
|
|
229
|
-
// reclaim data used
|
|
140
|
+
// reclaim data used.
|
|
230
141
|
moduleOverrides = null;
|
|
231
142
|
checkIncomingModuleAPI();
|
|
232
143
|
|
|
@@ -247,13 +158,12 @@ assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memor
|
|
|
247
158
|
assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
|
|
248
159
|
assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
|
|
249
160
|
assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
|
|
250
|
-
assert(typeof Module['read'] == 'undefined', 'Module.read option was removed
|
|
161
|
+
assert(typeof Module['read'] == 'undefined', 'Module.read option was removed');
|
|
251
162
|
assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
|
|
252
163
|
assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
|
|
253
164
|
assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)');
|
|
254
165
|
assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
|
|
255
166
|
legacyModuleProp('asm', 'wasmExports');
|
|
256
|
-
legacyModuleProp('read', 'read_');
|
|
257
167
|
legacyModuleProp('readAsync', 'readAsync');
|
|
258
168
|
legacyModuleProp('readBinary', 'readBinary');
|
|
259
169
|
legacyModuleProp('setWindowTitle', 'setWindowTitle');
|
|
@@ -267,14 +177,14 @@ var OPFS = 'OPFS is no longer included by default; build with -lopfs.js';
|
|
|
267
177
|
|
|
268
178
|
var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
|
|
269
179
|
|
|
270
|
-
assert(!ENVIRONMENT_IS_WORKER,
|
|
180
|
+
assert(!ENVIRONMENT_IS_WORKER, 'worker environment detected but not enabled at build time. Add `worker` to `-sENVIRONMENT` to enable.');
|
|
271
181
|
|
|
272
|
-
assert(!ENVIRONMENT_IS_NODE,
|
|
273
|
-
|
|
274
|
-
assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");
|
|
182
|
+
assert(!ENVIRONMENT_IS_NODE, 'node environment detected but not enabled at build time. Add `node` to `-sENVIRONMENT` to enable.');
|
|
275
183
|
|
|
184
|
+
assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.');
|
|
276
185
|
|
|
277
186
|
// end include: shell.js
|
|
187
|
+
|
|
278
188
|
// include: preamble.js
|
|
279
189
|
// === Preamble library stuff ===
|
|
280
190
|
|
|
@@ -290,7 +200,7 @@ var wasmBinary;
|
|
|
290
200
|
if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];legacyModuleProp('wasmBinary', 'wasmBinary');
|
|
291
201
|
|
|
292
202
|
if (typeof WebAssembly != 'object') {
|
|
293
|
-
|
|
203
|
+
err('no native wasm support detected');
|
|
294
204
|
}
|
|
295
205
|
|
|
296
206
|
// Wasm globals
|
|
@@ -344,6 +254,7 @@ var HEAP,
|
|
|
344
254
|
/** @type {!Float64Array} */
|
|
345
255
|
HEAPF64;
|
|
346
256
|
|
|
257
|
+
// include: runtime_shared.js
|
|
347
258
|
function updateMemoryViews() {
|
|
348
259
|
var b = wasmMemory.buffer;
|
|
349
260
|
Module['HEAP8'] = HEAP8 = new Int8Array(b);
|
|
@@ -355,7 +266,7 @@ function updateMemoryViews() {
|
|
|
355
266
|
Module['HEAPF32'] = HEAPF32 = new Float32Array(b);
|
|
356
267
|
Module['HEAPF64'] = HEAPF64 = new Float64Array(b);
|
|
357
268
|
}
|
|
358
|
-
|
|
269
|
+
// end include: runtime_shared.js
|
|
359
270
|
assert(!Module['STACK_SIZE'], 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
|
|
360
271
|
|
|
361
272
|
assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined,
|
|
@@ -505,9 +416,7 @@ function getUniqueRunDependency(id) {
|
|
|
505
416
|
function addRunDependency(id) {
|
|
506
417
|
runDependencies++;
|
|
507
418
|
|
|
508
|
-
|
|
509
|
-
Module['monitorRunDependencies'](runDependencies);
|
|
510
|
-
}
|
|
419
|
+
Module['monitorRunDependencies']?.(runDependencies);
|
|
511
420
|
|
|
512
421
|
if (id) {
|
|
513
422
|
assert(!runDependencyTracking[id]);
|
|
@@ -541,9 +450,7 @@ function addRunDependency(id) {
|
|
|
541
450
|
function removeRunDependency(id) {
|
|
542
451
|
runDependencies--;
|
|
543
452
|
|
|
544
|
-
|
|
545
|
-
Module['monitorRunDependencies'](runDependencies);
|
|
546
|
-
}
|
|
453
|
+
Module['monitorRunDependencies']?.(runDependencies);
|
|
547
454
|
|
|
548
455
|
if (id) {
|
|
549
456
|
assert(runDependencyTracking[id]);
|
|
@@ -566,9 +473,7 @@ function removeRunDependency(id) {
|
|
|
566
473
|
|
|
567
474
|
/** @param {string|number=} what */
|
|
568
475
|
function abort(what) {
|
|
569
|
-
|
|
570
|
-
Module['onAbort'](what);
|
|
571
|
-
}
|
|
476
|
+
Module['onAbort']?.(what);
|
|
572
477
|
|
|
573
478
|
what = 'Aborted(' + what + ')';
|
|
574
479
|
// TODO(sbc): Should we remove printing and leave it up to whoever
|
|
@@ -588,7 +493,7 @@ function abort(what) {
|
|
|
588
493
|
// allows this in the wasm spec.
|
|
589
494
|
|
|
590
495
|
// Suppress closure compiler warning here. Closure compiler's builtin extern
|
|
591
|
-
//
|
|
496
|
+
// definition for WebAssembly.RuntimeError claims it takes no arguments even
|
|
592
497
|
// though it can.
|
|
593
498
|
// TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
|
|
594
499
|
/** @suppress {checkTypes} */
|
|
@@ -638,12 +543,14 @@ var isDataURI = (filename) => filename.startsWith(dataURIPrefix);
|
|
|
638
543
|
*/
|
|
639
544
|
var isFileURI = (filename) => filename.startsWith('file://');
|
|
640
545
|
// end include: URIUtils.js
|
|
641
|
-
function createExportWrapper(name) {
|
|
642
|
-
return
|
|
546
|
+
function createExportWrapper(name, nargs) {
|
|
547
|
+
return (...args) => {
|
|
643
548
|
assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
|
|
644
549
|
var f = wasmExports[name];
|
|
645
550
|
assert(f, `exported native function \`${name}\` not found`);
|
|
646
|
-
|
|
551
|
+
// Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled.
|
|
552
|
+
assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`);
|
|
553
|
+
return f(...args);
|
|
647
554
|
};
|
|
648
555
|
}
|
|
649
556
|
|
|
@@ -663,11 +570,15 @@ class CppException extends EmscriptenEH {
|
|
|
663
570
|
}
|
|
664
571
|
}
|
|
665
572
|
// end include: runtime_exceptions.js
|
|
573
|
+
function findWasmBinary() {
|
|
574
|
+
var f = 'marchingsquares.wasm';
|
|
575
|
+
if (!isDataURI(f)) {
|
|
576
|
+
return locateFile(f);
|
|
577
|
+
}
|
|
578
|
+
return f;
|
|
579
|
+
}
|
|
580
|
+
|
|
666
581
|
var wasmBinaryFile;
|
|
667
|
-
wasmBinaryFile = 'marchingsquares.wasm';
|
|
668
|
-
if (!isDataURI(wasmBinaryFile)) {
|
|
669
|
-
wasmBinaryFile = locateFile(wasmBinaryFile);
|
|
670
|
-
}
|
|
671
582
|
|
|
672
583
|
function getBinarySync(file) {
|
|
673
584
|
if (file == wasmBinaryFile && wasmBinary) {
|
|
@@ -676,26 +587,19 @@ function getBinarySync(file) {
|
|
|
676
587
|
if (readBinary) {
|
|
677
588
|
return readBinary(file);
|
|
678
589
|
}
|
|
679
|
-
throw
|
|
590
|
+
throw 'both async and sync fetching of the wasm failed';
|
|
680
591
|
}
|
|
681
592
|
|
|
682
593
|
function getBinaryPromise(binaryFile) {
|
|
683
|
-
// If we don't have the binary yet,
|
|
684
|
-
// Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
|
|
685
|
-
// See https://github.com/github/fetch/pull/92#issuecomment-140665932
|
|
686
|
-
// Cordova or Electron apps are typically loaded from a file:// url.
|
|
687
|
-
// So use fetch if it is available and the url is not a file, otherwise fall back to XHR.
|
|
594
|
+
// If we don't have the binary yet, load it asynchronously using readAsync.
|
|
688
595
|
if (!wasmBinary
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
)
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
return response['arrayBuffer']();
|
|
697
|
-
}).catch(() => getBinarySync(binaryFile));
|
|
698
|
-
}
|
|
596
|
+
) {
|
|
597
|
+
// Fetch the binary using readAsync
|
|
598
|
+
return readAsync(binaryFile).then(
|
|
599
|
+
(response) => new Uint8Array(/** @type{!ArrayBuffer} */(response)),
|
|
600
|
+
// Fall back to getBinarySync if readAsync fails
|
|
601
|
+
() => getBinarySync(binaryFile)
|
|
602
|
+
);
|
|
699
603
|
}
|
|
700
604
|
|
|
701
605
|
// Otherwise, getBinarySync should be able to get it synchronously
|
|
@@ -705,8 +609,6 @@ function getBinaryPromise(binaryFile) {
|
|
|
705
609
|
function instantiateArrayBuffer(binaryFile, imports, receiver) {
|
|
706
610
|
return getBinaryPromise(binaryFile).then((binary) => {
|
|
707
611
|
return WebAssembly.instantiate(binary, imports);
|
|
708
|
-
}).then((instance) => {
|
|
709
|
-
return instance;
|
|
710
612
|
}).then(receiver, (reason) => {
|
|
711
613
|
err(`failed to asynchronously prepare wasm: ${reason}`);
|
|
712
614
|
|
|
@@ -745,14 +647,18 @@ function instantiateAsync(binary, binaryFile, imports, callback) {
|
|
|
745
647
|
return instantiateArrayBuffer(binaryFile, imports, callback);
|
|
746
648
|
}
|
|
747
649
|
|
|
748
|
-
|
|
749
|
-
// Receives the wasm imports, returns the exports.
|
|
750
|
-
function createWasm() {
|
|
650
|
+
function getWasmImports() {
|
|
751
651
|
// prepare imports
|
|
752
|
-
|
|
652
|
+
return {
|
|
753
653
|
'env': wasmImports,
|
|
754
654
|
'wasi_snapshot_preview1': wasmImports,
|
|
755
|
-
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// Create the wasm instance.
|
|
659
|
+
// Receives the wasm imports, returns the exports.
|
|
660
|
+
function createWasm() {
|
|
661
|
+
var info = getWasmImports();
|
|
756
662
|
// Load the wasm module and create an instance of using native support in the JS engine.
|
|
757
663
|
// handle a generated wasm instance, receiving its exports and
|
|
758
664
|
// performing other necessary setup
|
|
@@ -764,16 +670,12 @@ function createWasm() {
|
|
|
764
670
|
|
|
765
671
|
wasmMemory = wasmExports['memory'];
|
|
766
672
|
|
|
767
|
-
assert(wasmMemory,
|
|
768
|
-
// This assertion doesn't hold when emscripten is run in --post-link
|
|
769
|
-
// mode.
|
|
770
|
-
// TODO(sbc): Read INITIAL_MEMORY out of the wasm file in post-link mode.
|
|
771
|
-
//assert(wasmMemory.buffer.byteLength === 16777216);
|
|
673
|
+
assert(wasmMemory, 'memory not found in wasm exports');
|
|
772
674
|
updateMemoryViews();
|
|
773
675
|
|
|
774
676
|
wasmTable = wasmExports['__indirect_function_table'];
|
|
775
677
|
|
|
776
|
-
assert(wasmTable,
|
|
678
|
+
assert(wasmTable, 'table not found in wasm exports');
|
|
777
679
|
|
|
778
680
|
addOnInit(wasmExports['__wasm_call_ctors']);
|
|
779
681
|
|
|
@@ -805,7 +707,6 @@ function createWasm() {
|
|
|
805
707
|
// Also pthreads and wasm workers initialize the wasm instance through this
|
|
806
708
|
// path.
|
|
807
709
|
if (Module['instantiateWasm']) {
|
|
808
|
-
|
|
809
710
|
try {
|
|
810
711
|
return Module['instantiateWasm'](info, receiveInstance);
|
|
811
712
|
} catch(e) {
|
|
@@ -815,6 +716,8 @@ function createWasm() {
|
|
|
815
716
|
}
|
|
816
717
|
}
|
|
817
718
|
|
|
719
|
+
if (!wasmBinaryFile) wasmBinaryFile = findWasmBinary();
|
|
720
|
+
|
|
818
721
|
// If instantiation fails, reject the module ready promise.
|
|
819
722
|
instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject);
|
|
820
723
|
return {}; // no exports yet; we'll fill them in later
|
|
@@ -825,12 +728,12 @@ var tempDouble;
|
|
|
825
728
|
var tempI64;
|
|
826
729
|
|
|
827
730
|
// include: runtime_debug.js
|
|
828
|
-
function legacyModuleProp(prop, newName,
|
|
731
|
+
function legacyModuleProp(prop, newName, incoming=true) {
|
|
829
732
|
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
830
733
|
Object.defineProperty(Module, prop, {
|
|
831
734
|
configurable: true,
|
|
832
735
|
get() {
|
|
833
|
-
let extra =
|
|
736
|
+
let extra = incoming ? ' (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)' : '';
|
|
834
737
|
abort(`\`Module.${prop}\` has been replaced by \`${newName}\`` + extra);
|
|
835
738
|
|
|
836
739
|
}
|
|
@@ -858,7 +761,7 @@ function isExportedByForceFilesystem(name) {
|
|
|
858
761
|
}
|
|
859
762
|
|
|
860
763
|
function missingGlobal(sym, msg) {
|
|
861
|
-
if (typeof globalThis
|
|
764
|
+
if (typeof globalThis != 'undefined') {
|
|
862
765
|
Object.defineProperty(globalThis, sym, {
|
|
863
766
|
configurable: true,
|
|
864
767
|
get() {
|
|
@@ -873,7 +776,7 @@ missingGlobal('buffer', 'Please use HEAP8.buffer or wasmMemory.buffer');
|
|
|
873
776
|
missingGlobal('asm', 'Please use wasmExports instead');
|
|
874
777
|
|
|
875
778
|
function missingLibrarySymbol(sym) {
|
|
876
|
-
if (typeof globalThis
|
|
779
|
+
if (typeof globalThis != 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
|
|
877
780
|
Object.defineProperty(globalThis, sym, {
|
|
878
781
|
configurable: true,
|
|
879
782
|
get() {
|
|
@@ -896,7 +799,7 @@ function missingLibrarySymbol(sym) {
|
|
|
896
799
|
}
|
|
897
800
|
});
|
|
898
801
|
}
|
|
899
|
-
// Any symbol that is not included from the JS
|
|
802
|
+
// Any symbol that is not included from the JS library is also (by definition)
|
|
900
803
|
// not exported on the Module object.
|
|
901
804
|
unexportedRuntimeSymbol(sym);
|
|
902
805
|
}
|
|
@@ -917,16 +820,16 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
917
820
|
}
|
|
918
821
|
|
|
919
822
|
// Used by XXXXX_DEBUG settings to output debug messages.
|
|
920
|
-
function dbg(
|
|
823
|
+
function dbg(...args) {
|
|
921
824
|
// TODO(sbc): Make this configurable somehow. Its not always convenient for
|
|
922
825
|
// logging to show up as warnings.
|
|
923
|
-
console.warn
|
|
826
|
+
console.warn(...args);
|
|
924
827
|
}
|
|
925
828
|
// end include: runtime_debug.js
|
|
926
829
|
// === Body ===
|
|
927
|
-
|
|
928
830
|
// end include: preamble.js
|
|
929
831
|
|
|
832
|
+
|
|
930
833
|
/** @constructor */
|
|
931
834
|
function ExitStatus(status) {
|
|
932
835
|
this.name = 'ExitStatus';
|
|
@@ -941,18 +844,69 @@ function dbg(text) {
|
|
|
941
844
|
}
|
|
942
845
|
};
|
|
943
846
|
|
|
944
|
-
var decrementExceptionRefcount = (ptr) => ___cxa_decrement_exception_refcount(ptr);
|
|
945
|
-
|
|
946
|
-
|
|
947
847
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
848
|
+
/**
|
|
849
|
+
* @param {number} ptr
|
|
850
|
+
* @param {string} type
|
|
851
|
+
*/
|
|
852
|
+
function getValue(ptr, type = 'i8') {
|
|
853
|
+
if (type.endsWith('*')) type = '*';
|
|
854
|
+
switch (type) {
|
|
855
|
+
case 'i1': return HEAP8[ptr];
|
|
856
|
+
case 'i8': return HEAP8[ptr];
|
|
857
|
+
case 'i16': return HEAP16[((ptr)>>1)];
|
|
858
|
+
case 'i32': return HEAP32[((ptr)>>2)];
|
|
859
|
+
case 'i64': abort('to do getValue(i64) use WASM_BIGINT');
|
|
860
|
+
case 'float': return HEAPF32[((ptr)>>2)];
|
|
861
|
+
case 'double': return HEAPF64[((ptr)>>3)];
|
|
862
|
+
case '*': return HEAPU32[((ptr)>>2)];
|
|
863
|
+
default: abort(`invalid type for getValue: ${type}`);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
var noExitRuntime = Module['noExitRuntime'] || true;
|
|
868
|
+
|
|
869
|
+
var ptrToString = (ptr) => {
|
|
870
|
+
assert(typeof ptr === 'number');
|
|
871
|
+
// With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
|
|
872
|
+
ptr >>>= 0;
|
|
873
|
+
return '0x' + ptr.toString(16).padStart(8, '0');
|
|
953
874
|
};
|
|
875
|
+
|
|
954
876
|
|
|
955
|
-
|
|
877
|
+
/**
|
|
878
|
+
* @param {number} ptr
|
|
879
|
+
* @param {number} value
|
|
880
|
+
* @param {string} type
|
|
881
|
+
*/
|
|
882
|
+
function setValue(ptr, value, type = 'i8') {
|
|
883
|
+
if (type.endsWith('*')) type = '*';
|
|
884
|
+
switch (type) {
|
|
885
|
+
case 'i1': HEAP8[ptr] = value; break;
|
|
886
|
+
case 'i8': HEAP8[ptr] = value; break;
|
|
887
|
+
case 'i16': HEAP16[((ptr)>>1)] = value; break;
|
|
888
|
+
case 'i32': HEAP32[((ptr)>>2)] = value; break;
|
|
889
|
+
case 'i64': abort('to do setValue(i64) use WASM_BIGINT');
|
|
890
|
+
case 'float': HEAPF32[((ptr)>>2)] = value; break;
|
|
891
|
+
case 'double': HEAPF64[((ptr)>>3)] = value; break;
|
|
892
|
+
case '*': HEAPU32[((ptr)>>2)] = value; break;
|
|
893
|
+
default: abort(`invalid type for setValue: ${type}`);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
var stackRestore = (val) => __emscripten_stack_restore(val);
|
|
898
|
+
|
|
899
|
+
var stackSave = () => _emscripten_stack_get_current();
|
|
900
|
+
|
|
901
|
+
var warnOnce = (text) => {
|
|
902
|
+
warnOnce.shown ||= {};
|
|
903
|
+
if (!warnOnce.shown[text]) {
|
|
904
|
+
warnOnce.shown[text] = 1;
|
|
905
|
+
err(text);
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder() : undefined;
|
|
956
910
|
|
|
957
911
|
/**
|
|
958
912
|
* Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
|
|
@@ -1025,84 +979,6 @@ function dbg(text) {
|
|
|
1025
979
|
assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
|
|
1026
980
|
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
|
|
1027
981
|
};
|
|
1028
|
-
var getExceptionMessageCommon = (ptr) => withStackSave(() => {
|
|
1029
|
-
var type_addr_addr = stackAlloc(4);
|
|
1030
|
-
var message_addr_addr = stackAlloc(4);
|
|
1031
|
-
___get_exception_message(ptr, type_addr_addr, message_addr_addr);
|
|
1032
|
-
var type_addr = HEAPU32[((type_addr_addr)>>2)];
|
|
1033
|
-
var message_addr = HEAPU32[((message_addr_addr)>>2)];
|
|
1034
|
-
var type = UTF8ToString(type_addr);
|
|
1035
|
-
_free(type_addr);
|
|
1036
|
-
var message;
|
|
1037
|
-
if (message_addr) {
|
|
1038
|
-
message = UTF8ToString(message_addr);
|
|
1039
|
-
_free(message_addr);
|
|
1040
|
-
}
|
|
1041
|
-
return [type, message];
|
|
1042
|
-
});
|
|
1043
|
-
var getExceptionMessage = (ptr) => getExceptionMessageCommon(ptr);
|
|
1044
|
-
Module['getExceptionMessage'] = getExceptionMessage;
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
/**
|
|
1048
|
-
* @param {number} ptr
|
|
1049
|
-
* @param {string} type
|
|
1050
|
-
*/
|
|
1051
|
-
function getValue(ptr, type = 'i8') {
|
|
1052
|
-
if (type.endsWith('*')) type = '*';
|
|
1053
|
-
switch (type) {
|
|
1054
|
-
case 'i1': return HEAP8[((ptr)>>0)];
|
|
1055
|
-
case 'i8': return HEAP8[((ptr)>>0)];
|
|
1056
|
-
case 'i16': return HEAP16[((ptr)>>1)];
|
|
1057
|
-
case 'i32': return HEAP32[((ptr)>>2)];
|
|
1058
|
-
case 'i64': abort('to do getValue(i64) use WASM_BIGINT');
|
|
1059
|
-
case 'float': return HEAPF32[((ptr)>>2)];
|
|
1060
|
-
case 'double': return HEAPF64[((ptr)>>3)];
|
|
1061
|
-
case '*': return HEAPU32[((ptr)>>2)];
|
|
1062
|
-
default: abort(`invalid type for getValue: ${type}`);
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
var incrementExceptionRefcount = (ptr) => ___cxa_increment_exception_refcount(ptr);
|
|
1067
|
-
|
|
1068
|
-
var noExitRuntime = Module['noExitRuntime'] || true;
|
|
1069
|
-
|
|
1070
|
-
var ptrToString = (ptr) => {
|
|
1071
|
-
assert(typeof ptr === 'number');
|
|
1072
|
-
// With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
|
|
1073
|
-
ptr >>>= 0;
|
|
1074
|
-
return '0x' + ptr.toString(16).padStart(8, '0');
|
|
1075
|
-
};
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
/**
|
|
1079
|
-
* @param {number} ptr
|
|
1080
|
-
* @param {number} value
|
|
1081
|
-
* @param {string} type
|
|
1082
|
-
*/
|
|
1083
|
-
function setValue(ptr, value, type = 'i8') {
|
|
1084
|
-
if (type.endsWith('*')) type = '*';
|
|
1085
|
-
switch (type) {
|
|
1086
|
-
case 'i1': HEAP8[((ptr)>>0)] = value; break;
|
|
1087
|
-
case 'i8': HEAP8[((ptr)>>0)] = value; break;
|
|
1088
|
-
case 'i16': HEAP16[((ptr)>>1)] = value; break;
|
|
1089
|
-
case 'i32': HEAP32[((ptr)>>2)] = value; break;
|
|
1090
|
-
case 'i64': abort('to do setValue(i64) use WASM_BIGINT');
|
|
1091
|
-
case 'float': HEAPF32[((ptr)>>2)] = value; break;
|
|
1092
|
-
case 'double': HEAPF64[((ptr)>>3)] = value; break;
|
|
1093
|
-
case '*': HEAPU32[((ptr)>>2)] = value; break;
|
|
1094
|
-
default: abort(`invalid type for setValue: ${type}`);
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
var warnOnce = (text) => {
|
|
1099
|
-
if (!warnOnce.shown) warnOnce.shown = {};
|
|
1100
|
-
if (!warnOnce.shown[text]) {
|
|
1101
|
-
warnOnce.shown[text] = 1;
|
|
1102
|
-
err(text);
|
|
1103
|
-
}
|
|
1104
|
-
};
|
|
1105
|
-
|
|
1106
982
|
var ___assert_fail = (condition, filename, line, func) => {
|
|
1107
983
|
abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
|
|
1108
984
|
};
|
|
@@ -1125,65 +1001,67 @@ function dbg(text) {
|
|
|
1125
1001
|
|
|
1126
1002
|
var exceptionLast = 0;
|
|
1127
1003
|
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1004
|
+
class ExceptionInfo {
|
|
1005
|
+
// excPtr - Thrown object pointer to wrap. Metadata pointer is calculated from it.
|
|
1006
|
+
constructor(excPtr) {
|
|
1007
|
+
this.excPtr = excPtr;
|
|
1008
|
+
this.ptr = excPtr - 24;
|
|
1009
|
+
}
|
|
1132
1010
|
|
|
1133
|
-
|
|
1011
|
+
set_type(type) {
|
|
1134
1012
|
HEAPU32[(((this.ptr)+(4))>>2)] = type;
|
|
1135
|
-
}
|
|
1013
|
+
}
|
|
1136
1014
|
|
|
1137
|
-
|
|
1015
|
+
get_type() {
|
|
1138
1016
|
return HEAPU32[(((this.ptr)+(4))>>2)];
|
|
1139
|
-
}
|
|
1017
|
+
}
|
|
1140
1018
|
|
|
1141
|
-
|
|
1019
|
+
set_destructor(destructor) {
|
|
1142
1020
|
HEAPU32[(((this.ptr)+(8))>>2)] = destructor;
|
|
1143
|
-
}
|
|
1021
|
+
}
|
|
1144
1022
|
|
|
1145
|
-
|
|
1023
|
+
get_destructor() {
|
|
1146
1024
|
return HEAPU32[(((this.ptr)+(8))>>2)];
|
|
1147
|
-
}
|
|
1025
|
+
}
|
|
1148
1026
|
|
|
1149
|
-
|
|
1027
|
+
set_caught(caught) {
|
|
1150
1028
|
caught = caught ? 1 : 0;
|
|
1151
|
-
HEAP8[(
|
|
1152
|
-
}
|
|
1029
|
+
HEAP8[(this.ptr)+(12)] = caught;
|
|
1030
|
+
}
|
|
1153
1031
|
|
|
1154
|
-
|
|
1155
|
-
return HEAP8[(
|
|
1156
|
-
}
|
|
1032
|
+
get_caught() {
|
|
1033
|
+
return HEAP8[(this.ptr)+(12)] != 0;
|
|
1034
|
+
}
|
|
1157
1035
|
|
|
1158
|
-
|
|
1036
|
+
set_rethrown(rethrown) {
|
|
1159
1037
|
rethrown = rethrown ? 1 : 0;
|
|
1160
|
-
HEAP8[(
|
|
1161
|
-
}
|
|
1038
|
+
HEAP8[(this.ptr)+(13)] = rethrown;
|
|
1039
|
+
}
|
|
1162
1040
|
|
|
1163
|
-
|
|
1164
|
-
return HEAP8[(
|
|
1165
|
-
}
|
|
1041
|
+
get_rethrown() {
|
|
1042
|
+
return HEAP8[(this.ptr)+(13)] != 0;
|
|
1043
|
+
}
|
|
1166
1044
|
|
|
1167
1045
|
// Initialize native structure fields. Should be called once after allocated.
|
|
1168
|
-
|
|
1046
|
+
init(type, destructor) {
|
|
1169
1047
|
this.set_adjusted_ptr(0);
|
|
1170
1048
|
this.set_type(type);
|
|
1171
1049
|
this.set_destructor(destructor);
|
|
1172
1050
|
}
|
|
1173
1051
|
|
|
1174
|
-
|
|
1052
|
+
set_adjusted_ptr(adjustedPtr) {
|
|
1175
1053
|
HEAPU32[(((this.ptr)+(16))>>2)] = adjustedPtr;
|
|
1176
|
-
}
|
|
1054
|
+
}
|
|
1177
1055
|
|
|
1178
|
-
|
|
1056
|
+
get_adjusted_ptr() {
|
|
1179
1057
|
return HEAPU32[(((this.ptr)+(16))>>2)];
|
|
1180
|
-
}
|
|
1058
|
+
}
|
|
1181
1059
|
|
|
1182
1060
|
// Get pointer which is expected to be received by catch clause in C++ code. It may be adjusted
|
|
1183
1061
|
// when the pointer is casted to some of the exception object base classes (e.g. when virtual
|
|
1184
1062
|
// inheritance is used). When a pointer is thrown this method should return the thrown pointer
|
|
1185
1063
|
// itself.
|
|
1186
|
-
|
|
1064
|
+
get_exception_ptr() {
|
|
1187
1065
|
// Work around a fastcomp bug, this code is still included for some reason in a build without
|
|
1188
1066
|
// exceptions support.
|
|
1189
1067
|
var isPointer = ___cxa_is_pointer_type(this.get_type());
|
|
@@ -1193,7 +1071,7 @@ function dbg(text) {
|
|
|
1193
1071
|
var adjusted = this.get_adjusted_ptr();
|
|
1194
1072
|
if (adjusted !== 0) return adjusted;
|
|
1195
1073
|
return this.excPtr;
|
|
1196
|
-
}
|
|
1074
|
+
}
|
|
1197
1075
|
}
|
|
1198
1076
|
|
|
1199
1077
|
var ___resumeException = (ptr) => {
|
|
@@ -1204,9 +1082,10 @@ function dbg(text) {
|
|
|
1204
1082
|
};
|
|
1205
1083
|
|
|
1206
1084
|
|
|
1085
|
+
var setTempRet0 = (val) => __emscripten_tempret_set(val);
|
|
1207
1086
|
var findMatchingCatch = (args) => {
|
|
1208
1087
|
var thrown =
|
|
1209
|
-
exceptionLast
|
|
1088
|
+
exceptionLast?.excPtr;
|
|
1210
1089
|
if (!thrown) {
|
|
1211
1090
|
// just pass through the null ptr
|
|
1212
1091
|
setTempRet0(0);
|
|
@@ -1226,9 +1105,7 @@ function dbg(text) {
|
|
|
1226
1105
|
// Due to inheritance, those types may not precisely match the
|
|
1227
1106
|
// type of the thrown object. Find one which matches, and
|
|
1228
1107
|
// return the type of the catch block which should be called.
|
|
1229
|
-
for (var
|
|
1230
|
-
var caughtType = args[arg];
|
|
1231
|
-
|
|
1108
|
+
for (var caughtType of args) {
|
|
1232
1109
|
if (caughtType === 0 || caughtType === thrownType) {
|
|
1233
1110
|
// Catch all clause matched or exactly the same type is caught
|
|
1234
1111
|
break;
|
|
@@ -1258,6 +1135,10 @@ function dbg(text) {
|
|
|
1258
1135
|
};
|
|
1259
1136
|
|
|
1260
1137
|
|
|
1138
|
+
var __abort_js = () => {
|
|
1139
|
+
abort('native code called abort()');
|
|
1140
|
+
};
|
|
1141
|
+
|
|
1261
1142
|
var __embind_register_bigint = (primitiveType, name, size, minRange, maxRange) => {};
|
|
1262
1143
|
|
|
1263
1144
|
var embind_init_charCodes = () => {
|
|
@@ -1386,64 +1267,36 @@ function dbg(text) {
|
|
|
1386
1267
|
});
|
|
1387
1268
|
};
|
|
1388
1269
|
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
return this.allocated[id];
|
|
1394
|
-
},
|
|
1395
|
-
has(id) {
|
|
1396
|
-
return this.allocated[id] !== undefined;
|
|
1397
|
-
},
|
|
1398
|
-
allocate(handle) {
|
|
1399
|
-
var id = this.freelist.pop() || this.allocated.length;
|
|
1400
|
-
this.allocated[id] = handle;
|
|
1401
|
-
return id;
|
|
1402
|
-
},
|
|
1403
|
-
free(id) {
|
|
1404
|
-
assert(this.allocated[id] !== undefined);
|
|
1405
|
-
// Set the slot to `undefined` rather than using `delete` here since
|
|
1406
|
-
// apparently arrays with holes in them can be less efficient.
|
|
1407
|
-
this.allocated[id] = undefined;
|
|
1408
|
-
this.freelist.push(id);
|
|
1409
|
-
}
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
|
-
/** @constructor */
|
|
1413
|
-
function HandleAllocator() {
|
|
1414
|
-
// Reserve slot 0 so that 0 is always an invalid handle
|
|
1415
|
-
this.allocated = [undefined];
|
|
1416
|
-
this.freelist = [];
|
|
1417
|
-
}
|
|
1418
|
-
var emval_handles = new HandleAllocator();;
|
|
1270
|
+
|
|
1271
|
+
var emval_freelist = [];
|
|
1272
|
+
|
|
1273
|
+
var emval_handles = [];
|
|
1419
1274
|
var __emval_decref = (handle) => {
|
|
1420
|
-
if (handle
|
|
1421
|
-
emval_handles
|
|
1275
|
+
if (handle > 9 && 0 === --emval_handles[handle + 1]) {
|
|
1276
|
+
assert(emval_handles[handle] !== undefined, `Decref for unallocated handle.`);
|
|
1277
|
+
emval_handles[handle] = undefined;
|
|
1278
|
+
emval_freelist.push(handle);
|
|
1422
1279
|
}
|
|
1423
1280
|
};
|
|
1424
1281
|
|
|
1425
1282
|
|
|
1426
1283
|
|
|
1284
|
+
|
|
1285
|
+
|
|
1427
1286
|
var count_emval_handles = () => {
|
|
1428
|
-
|
|
1429
|
-
for (var i = emval_handles.reserved; i < emval_handles.allocated.length; ++i) {
|
|
1430
|
-
if (emval_handles.allocated[i] !== undefined) {
|
|
1431
|
-
++count;
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
return count;
|
|
1287
|
+
return emval_handles.length / 2 - 5 - emval_freelist.length;
|
|
1435
1288
|
};
|
|
1436
1289
|
|
|
1437
1290
|
var init_emval = () => {
|
|
1438
|
-
// reserve some special values. These never get de-allocated.
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1291
|
+
// reserve 0 and some special values. These never get de-allocated.
|
|
1292
|
+
emval_handles.push(
|
|
1293
|
+
0, 1,
|
|
1294
|
+
undefined, 1,
|
|
1295
|
+
null, 1,
|
|
1296
|
+
true, 1,
|
|
1297
|
+
false, 1,
|
|
1445
1298
|
);
|
|
1446
|
-
emval_handles.
|
|
1299
|
+
assert(emval_handles.length === 5 * 2);
|
|
1447
1300
|
Module['count_emval_handles'] = count_emval_handles;
|
|
1448
1301
|
};
|
|
1449
1302
|
var Emval = {
|
|
@@ -1451,45 +1304,47 @@ function dbg(text) {
|
|
|
1451
1304
|
if (!handle) {
|
|
1452
1305
|
throwBindingError('Cannot use deleted val. handle = ' + handle);
|
|
1453
1306
|
}
|
|
1454
|
-
|
|
1307
|
+
// handle 2 is supposed to be `undefined`.
|
|
1308
|
+
assert(handle === 2 || emval_handles[handle] !== undefined && handle % 2 === 0, `invalid handle: ${handle}`);
|
|
1309
|
+
return emval_handles[handle];
|
|
1455
1310
|
},
|
|
1456
1311
|
toHandle:(value) => {
|
|
1457
1312
|
switch (value) {
|
|
1458
|
-
case undefined: return
|
|
1459
|
-
case null: return
|
|
1460
|
-
case true: return
|
|
1461
|
-
case false: return
|
|
1313
|
+
case undefined: return 2;
|
|
1314
|
+
case null: return 4;
|
|
1315
|
+
case true: return 6;
|
|
1316
|
+
case false: return 8;
|
|
1462
1317
|
default:{
|
|
1463
|
-
|
|
1318
|
+
const handle = emval_freelist.pop() || emval_handles.length;
|
|
1319
|
+
emval_handles[handle] = value;
|
|
1320
|
+
emval_handles[handle + 1] = 1;
|
|
1321
|
+
return handle;
|
|
1464
1322
|
}
|
|
1465
1323
|
}
|
|
1466
1324
|
},
|
|
1467
1325
|
};
|
|
1468
1326
|
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
1327
|
/** @suppress {globalThis} */
|
|
1472
|
-
function
|
|
1473
|
-
return this['fromWireType'](
|
|
1328
|
+
function readPointer(pointer) {
|
|
1329
|
+
return this['fromWireType'](HEAPU32[((pointer)>>2)]);
|
|
1474
1330
|
}
|
|
1475
|
-
var __embind_register_emval = (rawType, name) => {
|
|
1476
|
-
name = readLatin1String(name);
|
|
1477
|
-
registerType(rawType, {
|
|
1478
|
-
name,
|
|
1479
|
-
'fromWireType': (handle) => {
|
|
1480
|
-
var rv = Emval.toValue(handle);
|
|
1481
|
-
__emval_decref(handle);
|
|
1482
|
-
return rv;
|
|
1483
|
-
},
|
|
1484
|
-
'toWireType': (destructors, value) => Emval.toHandle(value),
|
|
1485
|
-
'argPackAdvance': GenericWireTypeSize,
|
|
1486
|
-
'readValueFromPointer': simpleReadValueFromPointer,
|
|
1487
|
-
destructorFunction: null, // This type does not need a destructor
|
|
1488
1331
|
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1332
|
+
var EmValType = {
|
|
1333
|
+
name: 'emscripten::val',
|
|
1334
|
+
'fromWireType': (handle) => {
|
|
1335
|
+
var rv = Emval.toValue(handle);
|
|
1336
|
+
__emval_decref(handle);
|
|
1337
|
+
return rv;
|
|
1338
|
+
},
|
|
1339
|
+
'toWireType': (destructors, value) => Emval.toHandle(value),
|
|
1340
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
1341
|
+
'readValueFromPointer': readPointer,
|
|
1342
|
+
destructorFunction: null, // This type does not need a destructor
|
|
1343
|
+
|
|
1344
|
+
// TODO: do we need a deleteObject here? write a test where
|
|
1345
|
+
// emval is passed into JS via an interface
|
|
1492
1346
|
};
|
|
1347
|
+
var __embind_register_emval = (rawType) => registerType(rawType, EmValType);
|
|
1493
1348
|
|
|
1494
1349
|
var embindRepr = (v) => {
|
|
1495
1350
|
if (v === null) {
|
|
@@ -1549,6 +1404,17 @@ function dbg(text) {
|
|
|
1549
1404
|
};
|
|
1550
1405
|
|
|
1551
1406
|
|
|
1407
|
+
function usesDestructorStack(argTypes) {
|
|
1408
|
+
// Skip return value at index 0 - it's not deleted here.
|
|
1409
|
+
for (var i = 1; i < argTypes.length; ++i) {
|
|
1410
|
+
// The type does not define a destructor function - must use dynamic stack
|
|
1411
|
+
if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) {
|
|
1412
|
+
return true;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
return false;
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1552
1418
|
function newFunc(constructor, argumentList) {
|
|
1553
1419
|
if (!(constructor instanceof Function)) {
|
|
1554
1420
|
throw new TypeError(`new_ called with constructor type ${typeof(constructor)} which is not a function`);
|
|
@@ -1560,7 +1426,7 @@ function dbg(text) {
|
|
|
1560
1426
|
* though at creation, the 'dummy' has the correct constructor name. Thus,
|
|
1561
1427
|
* objects created with IMVU.new would show up in the debugger as 'dummy',
|
|
1562
1428
|
* which isn't very helpful. Using IMVU.createNamedFunction addresses the
|
|
1563
|
-
* issue.
|
|
1429
|
+
* issue. Doubly-unfortunately, there's no way to write a test for this
|
|
1564
1430
|
* behavior. -NRD 2013.02.22
|
|
1565
1431
|
*/
|
|
1566
1432
|
var dummy = createNamedFunction(constructor.name || 'unknownFunctionName', function(){});
|
|
@@ -1570,45 +1436,10 @@ function dbg(text) {
|
|
|
1570
1436
|
var r = constructor.apply(obj, argumentList);
|
|
1571
1437
|
return (r instanceof Object) ? r : obj;
|
|
1572
1438
|
}
|
|
1573
|
-
function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, /** boolean= */ isAsync) {
|
|
1574
|
-
// humanName: a human-readable string name for the function to be generated.
|
|
1575
|
-
// argTypes: An array that contains the embind type objects for all types in the function signature.
|
|
1576
|
-
// argTypes[0] is the type object for the function return value.
|
|
1577
|
-
// argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
|
|
1578
|
-
// argTypes[2...] are the actual function parameters.
|
|
1579
|
-
// classType: The embind type object for the class to be bound, or null if this is not a method of a class.
|
|
1580
|
-
// cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
|
|
1581
|
-
// cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
|
|
1582
|
-
// isAsync: Optional. If true, returns an async function. Async bindings are only supported with JSPI.
|
|
1583
|
-
var argCount = argTypes.length;
|
|
1584
|
-
|
|
1585
|
-
if (argCount < 2) {
|
|
1586
|
-
throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
|
-
assert(!isAsync, 'Async bindings are only supported with JSPI.');
|
|
1590
|
-
|
|
1591
|
-
var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
|
|
1592
|
-
|
|
1593
|
-
// Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
|
|
1594
|
-
// TODO: This omits argument count check - enable only at -O3 or similar.
|
|
1595
|
-
// if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
|
|
1596
|
-
// return FUNCTION_TABLE[fn];
|
|
1597
|
-
// }
|
|
1598
|
-
|
|
1599
|
-
// Determine if we need to use a dynamic stack to store the destructors for the function parameters.
|
|
1600
|
-
// TODO: Remove this completely once all function invokers are being dynamically generated.
|
|
1601
|
-
var needsDestructorStack = false;
|
|
1602
|
-
|
|
1603
|
-
for (var i = 1; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here.
|
|
1604
|
-
if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) { // The type does not define a destructor function - must use dynamic stack
|
|
1605
|
-
needsDestructorStack = true;
|
|
1606
|
-
break;
|
|
1607
|
-
}
|
|
1608
|
-
}
|
|
1609
|
-
|
|
1610
|
-
var returns = (argTypes[0].name !== "void");
|
|
1611
1439
|
|
|
1440
|
+
function createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync) {
|
|
1441
|
+
var needsDestructorStack = usesDestructorStack(argTypes);
|
|
1442
|
+
var argCount = argTypes.length;
|
|
1612
1443
|
var argsList = "";
|
|
1613
1444
|
var argsListWired = "";
|
|
1614
1445
|
for (var i = 0; i < argCount - 2; ++i) {
|
|
@@ -1619,7 +1450,7 @@ function dbg(text) {
|
|
|
1619
1450
|
var invokerFnBody = `
|
|
1620
1451
|
return function (${argsList}) {
|
|
1621
1452
|
if (arguments.length !== ${argCount - 2}) {
|
|
1622
|
-
throwBindingError('function
|
|
1453
|
+
throwBindingError('function ' + humanName + ' called with ' + arguments.length + ' arguments, expected ${argCount - 2}');
|
|
1623
1454
|
}`;
|
|
1624
1455
|
|
|
1625
1456
|
if (needsDestructorStack) {
|
|
@@ -1627,17 +1458,15 @@ function dbg(text) {
|
|
|
1627
1458
|
}
|
|
1628
1459
|
|
|
1629
1460
|
var dtorStack = needsDestructorStack ? "destructors" : "null";
|
|
1630
|
-
var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
|
|
1631
|
-
var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
|
|
1461
|
+
var args1 = ["humanName", "throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
|
|
1632
1462
|
|
|
1633
1463
|
if (isClassMethodFunc) {
|
|
1634
|
-
invokerFnBody += "var thisWired = classParam
|
|
1464
|
+
invokerFnBody += "var thisWired = classParam['toWireType']("+dtorStack+", this);\n";
|
|
1635
1465
|
}
|
|
1636
1466
|
|
|
1637
1467
|
for (var i = 0; i < argCount - 2; ++i) {
|
|
1638
|
-
invokerFnBody += "var arg"+i+"Wired = argType"+i+"
|
|
1468
|
+
invokerFnBody += "var arg"+i+"Wired = argType"+i+"['toWireType']("+dtorStack+", arg"+i+");\n";
|
|
1639
1469
|
args1.push("argType"+i);
|
|
1640
|
-
args2.push(argTypes[i+2]);
|
|
1641
1470
|
}
|
|
1642
1471
|
|
|
1643
1472
|
if (isClassMethodFunc) {
|
|
@@ -1647,30 +1476,80 @@ function dbg(text) {
|
|
|
1647
1476
|
invokerFnBody +=
|
|
1648
1477
|
(returns || isAsync ? "var rv = ":"") + "invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";
|
|
1649
1478
|
|
|
1479
|
+
var returnVal = returns ? "rv" : "";
|
|
1480
|
+
|
|
1650
1481
|
if (needsDestructorStack) {
|
|
1651
1482
|
invokerFnBody += "runDestructors(destructors);\n";
|
|
1652
1483
|
} else {
|
|
1653
1484
|
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.
|
|
1654
1485
|
var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
|
|
1655
1486
|
if (argTypes[i].destructorFunction !== null) {
|
|
1656
|
-
invokerFnBody += paramName
|
|
1657
|
-
args1.push(paramName
|
|
1658
|
-
args2.push(argTypes[i].destructorFunction);
|
|
1487
|
+
invokerFnBody += `${paramName}_dtor(${paramName});\n`;
|
|
1488
|
+
args1.push(`${paramName}_dtor`);
|
|
1659
1489
|
}
|
|
1660
1490
|
}
|
|
1661
1491
|
}
|
|
1662
1492
|
|
|
1663
1493
|
if (returns) {
|
|
1664
|
-
invokerFnBody += "var ret = retType
|
|
1494
|
+
invokerFnBody += "var ret = retType['fromWireType'](rv);\n" +
|
|
1665
1495
|
"return ret;\n";
|
|
1666
1496
|
} else {
|
|
1667
1497
|
}
|
|
1668
1498
|
|
|
1669
1499
|
invokerFnBody += "}\n";
|
|
1670
1500
|
|
|
1671
|
-
args1.
|
|
1501
|
+
invokerFnBody = `if (arguments.length !== ${args1.length}){ throw new Error(humanName + "Expected ${args1.length} closure arguments " + arguments.length + " given."); }\n${invokerFnBody}`;
|
|
1502
|
+
return [args1, invokerFnBody];
|
|
1503
|
+
}
|
|
1504
|
+
function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, /** boolean= */ isAsync) {
|
|
1505
|
+
// humanName: a human-readable string name for the function to be generated.
|
|
1506
|
+
// argTypes: An array that contains the embind type objects for all types in the function signature.
|
|
1507
|
+
// argTypes[0] is the type object for the function return value.
|
|
1508
|
+
// argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
|
|
1509
|
+
// argTypes[2...] are the actual function parameters.
|
|
1510
|
+
// classType: The embind type object for the class to be bound, or null if this is not a method of a class.
|
|
1511
|
+
// cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
|
|
1512
|
+
// cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
|
|
1513
|
+
// isAsync: Optional. If true, returns an async function. Async bindings are only supported with JSPI.
|
|
1514
|
+
var argCount = argTypes.length;
|
|
1515
|
+
|
|
1516
|
+
if (argCount < 2) {
|
|
1517
|
+
throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
assert(!isAsync, 'Async bindings are only supported with JSPI.');
|
|
1672
1521
|
|
|
1673
|
-
var
|
|
1522
|
+
var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
|
|
1523
|
+
|
|
1524
|
+
// Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
|
|
1525
|
+
// TODO: This omits argument count check - enable only at -O3 or similar.
|
|
1526
|
+
// if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
|
|
1527
|
+
// return FUNCTION_TABLE[fn];
|
|
1528
|
+
// }
|
|
1529
|
+
|
|
1530
|
+
// Determine if we need to use a dynamic stack to store the destructors for the function parameters.
|
|
1531
|
+
// TODO: Remove this completely once all function invokers are being dynamically generated.
|
|
1532
|
+
var needsDestructorStack = usesDestructorStack(argTypes);
|
|
1533
|
+
|
|
1534
|
+
var returns = (argTypes[0].name !== "void");
|
|
1535
|
+
|
|
1536
|
+
// Builld the arguments that will be passed into the closure around the invoker
|
|
1537
|
+
// function.
|
|
1538
|
+
var closureArgs = [humanName, throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
|
|
1539
|
+
for (var i = 0; i < argCount - 2; ++i) {
|
|
1540
|
+
closureArgs.push(argTypes[i+2]);
|
|
1541
|
+
}
|
|
1542
|
+
if (!needsDestructorStack) {
|
|
1543
|
+
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.
|
|
1544
|
+
if (argTypes[i].destructorFunction !== null) {
|
|
1545
|
+
closureArgs.push(argTypes[i].destructorFunction);
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
let [args, invokerFnBody] = createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync);
|
|
1551
|
+
args.push(invokerFnBody);
|
|
1552
|
+
var invokerFn = newFunc(Function, args)(...closureArgs);
|
|
1674
1553
|
return createNamedFunction(humanName, invokerFn);
|
|
1675
1554
|
}
|
|
1676
1555
|
|
|
@@ -1678,12 +1557,12 @@ function dbg(text) {
|
|
|
1678
1557
|
if (undefined === proto[methodName].overloadTable) {
|
|
1679
1558
|
var prevFunc = proto[methodName];
|
|
1680
1559
|
// Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
|
|
1681
|
-
proto[methodName] = function() {
|
|
1560
|
+
proto[methodName] = function(...args) {
|
|
1682
1561
|
// TODO This check can be removed in -O3 level "unsafe" optimizations.
|
|
1683
|
-
if (!proto[methodName].overloadTable.hasOwnProperty(
|
|
1684
|
-
|
|
1562
|
+
if (!proto[methodName].overloadTable.hasOwnProperty(args.length)) {
|
|
1563
|
+
throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`);
|
|
1685
1564
|
}
|
|
1686
|
-
return proto[methodName].overloadTable[
|
|
1565
|
+
return proto[methodName].overloadTable[args.length].apply(this, args);
|
|
1687
1566
|
};
|
|
1688
1567
|
// Move the previous function into the overload table.
|
|
1689
1568
|
proto[methodName].overloadTable = [];
|
|
@@ -1718,9 +1597,9 @@ function dbg(text) {
|
|
|
1718
1597
|
var heap32VectorToArray = (count, firstElement) => {
|
|
1719
1598
|
var array = [];
|
|
1720
1599
|
for (var i = 0; i < count; i++) {
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1600
|
+
// TODO(https://github.com/emscripten-core/emscripten/issues/17310):
|
|
1601
|
+
// Find a way to hoist the `>> 2` or `>> 3` out of this loop.
|
|
1602
|
+
array.push(HEAPU32[(((firstElement)+(i * 4))>>2)]);
|
|
1724
1603
|
}
|
|
1725
1604
|
return array;
|
|
1726
1605
|
};
|
|
@@ -1729,7 +1608,7 @@ function dbg(text) {
|
|
|
1729
1608
|
/** @param {number=} numArguments */
|
|
1730
1609
|
var replacePublicSymbol = (name, value, numArguments) => {
|
|
1731
1610
|
if (!Module.hasOwnProperty(name)) {
|
|
1732
|
-
throwInternalError('Replacing
|
|
1611
|
+
throwInternalError('Replacing nonexistent public symbol');
|
|
1733
1612
|
}
|
|
1734
1613
|
// If there's an overload table for this symbol, replace the symbol in the overload table instead.
|
|
1735
1614
|
if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
|
|
@@ -1744,19 +1623,21 @@ function dbg(text) {
|
|
|
1744
1623
|
|
|
1745
1624
|
|
|
1746
1625
|
var dynCallLegacy = (sig, ptr, args) => {
|
|
1626
|
+
sig = sig.replace(/p/g, 'i')
|
|
1747
1627
|
assert(('dynCall_' + sig) in Module, `bad function pointer type - dynCall function not found for sig '${sig}'`);
|
|
1748
|
-
if (args
|
|
1628
|
+
if (args?.length) {
|
|
1749
1629
|
// j (64-bit integer) must be passed in as two numbers [low 32, high 32].
|
|
1750
1630
|
assert(args.length === sig.substring(1).replace(/j/g, '--').length);
|
|
1751
1631
|
} else {
|
|
1752
1632
|
assert(sig.length == 1);
|
|
1753
1633
|
}
|
|
1754
1634
|
var f = Module['dynCall_' + sig];
|
|
1755
|
-
return
|
|
1635
|
+
return f(ptr, ...args);
|
|
1756
1636
|
};
|
|
1757
1637
|
|
|
1758
1638
|
var wasmTableMirror = [];
|
|
1759
1639
|
|
|
1640
|
+
/** @type {WebAssembly.Table} */
|
|
1760
1641
|
var wasmTable;
|
|
1761
1642
|
var getWasmTableEntry = (funcPtr) => {
|
|
1762
1643
|
var func = wasmTableMirror[funcPtr];
|
|
@@ -1764,30 +1645,24 @@ function dbg(text) {
|
|
|
1764
1645
|
if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
|
|
1765
1646
|
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
1766
1647
|
}
|
|
1767
|
-
assert(wasmTable.get(funcPtr) == func,
|
|
1648
|
+
assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
|
|
1768
1649
|
return func;
|
|
1769
1650
|
};
|
|
1770
1651
|
|
|
1771
|
-
|
|
1772
|
-
var dynCall = (sig, ptr, args) => {
|
|
1652
|
+
var dynCall = (sig, ptr, args = []) => {
|
|
1773
1653
|
// Without WASM_BIGINT support we cannot directly call function with i64 as
|
|
1774
|
-
// part of
|
|
1654
|
+
// part of their signature, so we rely on the dynCall functions generated by
|
|
1775
1655
|
// wasm-emscripten-finalize
|
|
1776
1656
|
if (sig.includes('j')) {
|
|
1777
1657
|
return dynCallLegacy(sig, ptr, args);
|
|
1778
1658
|
}
|
|
1779
1659
|
assert(getWasmTableEntry(ptr), `missing table entry in dynCall: ${ptr}`);
|
|
1780
|
-
var rtn = getWasmTableEntry(ptr)
|
|
1660
|
+
var rtn = getWasmTableEntry(ptr)(...args);
|
|
1781
1661
|
return rtn;
|
|
1782
1662
|
};
|
|
1783
1663
|
var getDynCaller = (sig, ptr) => {
|
|
1784
1664
|
assert(sig.includes('j') || sig.includes('p'), 'getDynCaller should only be called with i64 sigs')
|
|
1785
|
-
|
|
1786
|
-
return function() {
|
|
1787
|
-
argCache.length = 0;
|
|
1788
|
-
Object.assign(argCache, arguments);
|
|
1789
|
-
return dynCall(sig, ptr, argCache);
|
|
1790
|
-
};
|
|
1665
|
+
return (...args) => dynCall(sig, ptr, args);
|
|
1791
1666
|
};
|
|
1792
1667
|
|
|
1793
1668
|
|
|
@@ -1887,7 +1762,7 @@ function dbg(text) {
|
|
|
1887
1762
|
throwUnboundTypeError(`Cannot call ${name} due to unbound types`, argTypes);
|
|
1888
1763
|
}, argCount - 1);
|
|
1889
1764
|
|
|
1890
|
-
whenDependentTypesAreResolved([], argTypes,
|
|
1765
|
+
whenDependentTypesAreResolved([], argTypes, (argTypes) => {
|
|
1891
1766
|
var invokerArgsArray = [argTypes[0] /* return value */, null /* no class 'this'*/].concat(argTypes.slice(1) /* actual params */);
|
|
1892
1767
|
replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null /* no class 'this'*/, rawInvoker, fn, isAsync), argCount - 1);
|
|
1893
1768
|
return [];
|
|
@@ -1899,8 +1774,8 @@ function dbg(text) {
|
|
|
1899
1774
|
// integers are quite common, so generate very specialized functions
|
|
1900
1775
|
switch (width) {
|
|
1901
1776
|
case 1: return signed ?
|
|
1902
|
-
(pointer) => HEAP8[
|
|
1903
|
-
(pointer) => HEAPU8[
|
|
1777
|
+
(pointer) => HEAP8[pointer] :
|
|
1778
|
+
(pointer) => HEAPU8[pointer];
|
|
1904
1779
|
case 2: return signed ?
|
|
1905
1780
|
(pointer) => HEAP16[((pointer)>>1)] :
|
|
1906
1781
|
(pointer) => HEAPU16[((pointer)>>1)]
|
|
@@ -1996,10 +1871,6 @@ function dbg(text) {
|
|
|
1996
1871
|
|
|
1997
1872
|
|
|
1998
1873
|
|
|
1999
|
-
/** @suppress {globalThis} */
|
|
2000
|
-
function readPointer(pointer) {
|
|
2001
|
-
return this['fromWireType'](HEAPU32[((pointer)>>2)]);
|
|
2002
|
-
}
|
|
2003
1874
|
|
|
2004
1875
|
|
|
2005
1876
|
var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
|
|
@@ -2138,7 +2009,7 @@ function dbg(text) {
|
|
|
2138
2009
|
length = value.length;
|
|
2139
2010
|
}
|
|
2140
2011
|
|
|
2141
|
-
// assumes
|
|
2012
|
+
// assumes POINTER_SIZE alignment
|
|
2142
2013
|
var base = _malloc(4 + length + 1);
|
|
2143
2014
|
var ptr = base + 4;
|
|
2144
2015
|
HEAPU32[((base)>>2)] = length;
|
|
@@ -2216,9 +2087,7 @@ function dbg(text) {
|
|
|
2216
2087
|
assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!');
|
|
2217
2088
|
assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
|
2218
2089
|
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
2219
|
-
|
|
2220
|
-
maxBytesToWrite = 0x7FFFFFFF;
|
|
2221
|
-
}
|
|
2090
|
+
maxBytesToWrite ??= 0x7FFFFFFF;
|
|
2222
2091
|
if (maxBytesToWrite < 2) return 0;
|
|
2223
2092
|
maxBytesToWrite -= 2; // Null terminator.
|
|
2224
2093
|
var startPtr = outPtr;
|
|
@@ -2265,9 +2134,7 @@ function dbg(text) {
|
|
|
2265
2134
|
assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!');
|
|
2266
2135
|
assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
|
|
2267
2136
|
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
2268
|
-
|
|
2269
|
-
maxBytesToWrite = 0x7FFFFFFF;
|
|
2270
|
-
}
|
|
2137
|
+
maxBytesToWrite ??= 0x7FFFFFFF;
|
|
2271
2138
|
if (maxBytesToWrite < 4) return 0;
|
|
2272
2139
|
var startPtr = outPtr;
|
|
2273
2140
|
var endPtr = startPtr + maxBytesToWrite - 4;
|
|
@@ -2302,33 +2169,30 @@ function dbg(text) {
|
|
|
2302
2169
|
};
|
|
2303
2170
|
var __embind_register_std_wstring = (rawType, charSize, name) => {
|
|
2304
2171
|
name = readLatin1String(name);
|
|
2305
|
-
var decodeString, encodeString,
|
|
2172
|
+
var decodeString, encodeString, readCharAt, lengthBytesUTF;
|
|
2306
2173
|
if (charSize === 2) {
|
|
2307
2174
|
decodeString = UTF16ToString;
|
|
2308
2175
|
encodeString = stringToUTF16;
|
|
2309
2176
|
lengthBytesUTF = lengthBytesUTF16;
|
|
2310
|
-
|
|
2311
|
-
shift = 1;
|
|
2177
|
+
readCharAt = (pointer) => HEAPU16[((pointer)>>1)];
|
|
2312
2178
|
} else if (charSize === 4) {
|
|
2313
2179
|
decodeString = UTF32ToString;
|
|
2314
2180
|
encodeString = stringToUTF32;
|
|
2315
2181
|
lengthBytesUTF = lengthBytesUTF32;
|
|
2316
|
-
|
|
2317
|
-
shift = 2;
|
|
2182
|
+
readCharAt = (pointer) => HEAPU32[((pointer)>>2)];
|
|
2318
2183
|
}
|
|
2319
2184
|
registerType(rawType, {
|
|
2320
2185
|
name,
|
|
2321
2186
|
'fromWireType': (value) => {
|
|
2322
2187
|
// Code mostly taken from _embind_register_std_string fromWireType
|
|
2323
2188
|
var length = HEAPU32[((value)>>2)];
|
|
2324
|
-
var HEAP = getHeap();
|
|
2325
2189
|
var str;
|
|
2326
2190
|
|
|
2327
2191
|
var decodeStartPtr = value + 4;
|
|
2328
2192
|
// Looping here to support possible embedded '0' bytes
|
|
2329
2193
|
for (var i = 0; i <= length; ++i) {
|
|
2330
2194
|
var currentBytePtr = value + 4 + i * charSize;
|
|
2331
|
-
if (i == length ||
|
|
2195
|
+
if (i == length || readCharAt(currentBytePtr) == 0) {
|
|
2332
2196
|
var maxReadBytes = currentBytePtr - decodeStartPtr;
|
|
2333
2197
|
var stringSegment = decodeString(decodeStartPtr, maxReadBytes);
|
|
2334
2198
|
if (str === undefined) {
|
|
@@ -2350,10 +2214,10 @@ function dbg(text) {
|
|
|
2350
2214
|
throwBindingError(`Cannot pass non-string to C++ string type ${name}`);
|
|
2351
2215
|
}
|
|
2352
2216
|
|
|
2353
|
-
// assumes
|
|
2217
|
+
// assumes POINTER_SIZE alignment
|
|
2354
2218
|
var length = lengthBytesUTF(value);
|
|
2355
2219
|
var ptr = _malloc(4 + length + charSize);
|
|
2356
|
-
HEAPU32[ptr
|
|
2220
|
+
HEAPU32[((ptr)>>2)] = length / charSize;
|
|
2357
2221
|
|
|
2358
2222
|
encodeString(value, ptr + 4, length + charSize);
|
|
2359
2223
|
|
|
@@ -2363,7 +2227,7 @@ function dbg(text) {
|
|
|
2363
2227
|
return ptr;
|
|
2364
2228
|
},
|
|
2365
2229
|
'argPackAdvance': GenericWireTypeSize,
|
|
2366
|
-
'readValueFromPointer':
|
|
2230
|
+
'readValueFromPointer': readPointer,
|
|
2367
2231
|
destructorFunction(ptr) {
|
|
2368
2232
|
_free(ptr);
|
|
2369
2233
|
}
|
|
@@ -2386,13 +2250,15 @@ function dbg(text) {
|
|
|
2386
2250
|
var nowIsMonotonic = 1;
|
|
2387
2251
|
var __emscripten_get_now_is_monotonic = () => nowIsMonotonic;
|
|
2388
2252
|
|
|
2253
|
+
var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
|
|
2254
|
+
|
|
2389
2255
|
|
|
2390
2256
|
|
|
2391
2257
|
|
|
2392
2258
|
var requireRegisteredType = (rawType, humanName) => {
|
|
2393
2259
|
var impl = registeredTypes[rawType];
|
|
2394
2260
|
if (undefined === impl) {
|
|
2395
|
-
|
|
2261
|
+
throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`);
|
|
2396
2262
|
}
|
|
2397
2263
|
return impl;
|
|
2398
2264
|
};
|
|
@@ -2485,12 +2351,6 @@ function dbg(text) {
|
|
|
2485
2351
|
var invoker = kind === /* CONSTRUCTOR */ 1 ? 'new func' : 'func.call';
|
|
2486
2352
|
functionBody +=
|
|
2487
2353
|
` var rv = ${invoker}(${argsList.join(", ")});\n`;
|
|
2488
|
-
for (var i = 0; i < argCount; ++i) {
|
|
2489
|
-
if (types[i]['deleteObject']) {
|
|
2490
|
-
functionBody +=
|
|
2491
|
-
` argType${i}.deleteObject(arg${i});\n`;
|
|
2492
|
-
}
|
|
2493
|
-
}
|
|
2494
2354
|
if (!retType.isVoid) {
|
|
2495
2355
|
params.push("emval_returnValue");
|
|
2496
2356
|
args.push(emval_returnValue);
|
|
@@ -2501,7 +2361,7 @@ function dbg(text) {
|
|
|
2501
2361
|
"};\n";
|
|
2502
2362
|
|
|
2503
2363
|
params.push(functionBody);
|
|
2504
|
-
var invokerFunction = newFunc(Function, params)
|
|
2364
|
+
var invokerFunction = newFunc(Function, params)(...args);
|
|
2505
2365
|
var functionName = `methodCaller<(${types.map(t => t.name).join(', ')}) => ${retType.name}>`;
|
|
2506
2366
|
return emval_addMethodCaller(createNamedFunction(functionName, invokerFunction));
|
|
2507
2367
|
};
|
|
@@ -2519,8 +2379,8 @@ function dbg(text) {
|
|
|
2519
2379
|
};
|
|
2520
2380
|
|
|
2521
2381
|
var __emval_incref = (handle) => {
|
|
2522
|
-
if (handle >
|
|
2523
|
-
emval_handles
|
|
2382
|
+
if (handle > 9) {
|
|
2383
|
+
emval_handles[handle + 1] += 1;
|
|
2524
2384
|
}
|
|
2525
2385
|
};
|
|
2526
2386
|
|
|
@@ -2553,10 +2413,6 @@ function dbg(text) {
|
|
|
2553
2413
|
return Emval.toHandle(v);
|
|
2554
2414
|
};
|
|
2555
2415
|
|
|
2556
|
-
var _abort = () => {
|
|
2557
|
-
abort('native code called abort()');
|
|
2558
|
-
};
|
|
2559
|
-
|
|
2560
2416
|
var _emscripten_date_now = () => Date.now();
|
|
2561
2417
|
|
|
2562
2418
|
var _emscripten_get_now;
|
|
@@ -2566,8 +2422,6 @@ function dbg(text) {
|
|
|
2566
2422
|
_emscripten_get_now = () => performance.now();
|
|
2567
2423
|
;
|
|
2568
2424
|
|
|
2569
|
-
var _emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
|
|
2570
|
-
|
|
2571
2425
|
var getHeapMax = () =>
|
|
2572
2426
|
// Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
|
|
2573
2427
|
// full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
|
|
@@ -2646,14 +2500,6 @@ function dbg(text) {
|
|
|
2646
2500
|
|
|
2647
2501
|
var SYSCALLS = {
|
|
2648
2502
|
varargs:undefined,
|
|
2649
|
-
get() {
|
|
2650
|
-
assert(SYSCALLS.varargs != undefined);
|
|
2651
|
-
// the `+` prepended here is necessary to convince the JSCompiler that varargs is indeed a number.
|
|
2652
|
-
var ret = HEAP32[((+SYSCALLS.varargs)>>2)];
|
|
2653
|
-
SYSCALLS.varargs += 4;
|
|
2654
|
-
return ret;
|
|
2655
|
-
},
|
|
2656
|
-
getp() { return SYSCALLS.get() },
|
|
2657
2503
|
getStr(ptr) {
|
|
2658
2504
|
var ret = UTF8ToString(ptr);
|
|
2659
2505
|
return ret;
|
|
@@ -2663,14 +2509,13 @@ function dbg(text) {
|
|
|
2663
2509
|
abort('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM');
|
|
2664
2510
|
};
|
|
2665
2511
|
|
|
2666
|
-
|
|
2667
2512
|
var convertI32PairToI53Checked = (lo, hi) => {
|
|
2668
2513
|
assert(lo == (lo >>> 0) || lo == (lo|0)); // lo should either be a i32 or a u32
|
|
2669
2514
|
assert(hi === (hi|0)); // hi should be a i32
|
|
2670
2515
|
return ((hi + 0x200000) >>> 0 < 0x400001 - !!lo) ? (lo >>> 0) + hi * 4294967296 : NaN;
|
|
2671
2516
|
};
|
|
2672
2517
|
function _fd_seek(fd,offset_low, offset_high,whence,newOffset) {
|
|
2673
|
-
var offset = convertI32PairToI53Checked(offset_low, offset_high)
|
|
2518
|
+
var offset = convertI32PairToI53Checked(offset_low, offset_high);
|
|
2674
2519
|
|
|
2675
2520
|
|
|
2676
2521
|
return 70;
|
|
@@ -2714,10 +2559,41 @@ function dbg(text) {
|
|
|
2714
2559
|
return 0;
|
|
2715
2560
|
};
|
|
2716
2561
|
|
|
2562
|
+
|
|
2563
|
+
var incrementExceptionRefcount = (ptr) => ___cxa_increment_exception_refcount(ptr);
|
|
2564
|
+
Module['incrementExceptionRefcount'] = incrementExceptionRefcount;
|
|
2565
|
+
|
|
2566
|
+
var decrementExceptionRefcount = (ptr) => ___cxa_decrement_exception_refcount(ptr);
|
|
2567
|
+
Module['decrementExceptionRefcount'] = decrementExceptionRefcount;
|
|
2568
|
+
|
|
2569
|
+
|
|
2570
|
+
|
|
2571
|
+
|
|
2572
|
+
|
|
2573
|
+
var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
|
|
2574
|
+
|
|
2575
|
+
var getExceptionMessageCommon = (ptr) => {
|
|
2576
|
+
var sp = stackSave();
|
|
2577
|
+
var type_addr_addr = stackAlloc(4);
|
|
2578
|
+
var message_addr_addr = stackAlloc(4);
|
|
2579
|
+
___get_exception_message(ptr, type_addr_addr, message_addr_addr);
|
|
2580
|
+
var type_addr = HEAPU32[((type_addr_addr)>>2)];
|
|
2581
|
+
var message_addr = HEAPU32[((message_addr_addr)>>2)];
|
|
2582
|
+
var type = UTF8ToString(type_addr);
|
|
2583
|
+
_free(type_addr);
|
|
2584
|
+
var message;
|
|
2585
|
+
if (message_addr) {
|
|
2586
|
+
message = UTF8ToString(message_addr);
|
|
2587
|
+
_free(message_addr);
|
|
2588
|
+
}
|
|
2589
|
+
stackRestore(sp);
|
|
2590
|
+
return [type, message];
|
|
2591
|
+
};
|
|
2592
|
+
var getExceptionMessage = (ptr) => getExceptionMessageCommon(ptr);
|
|
2593
|
+
Module['getExceptionMessage'] = getExceptionMessage;
|
|
2717
2594
|
embind_init_charCodes();
|
|
2718
2595
|
BindingError = Module['BindingError'] = class BindingError extends Error { constructor(message) { super(message); this.name = 'BindingError'; }};
|
|
2719
2596
|
InternalError = Module['InternalError'] = class InternalError extends Error { constructor(message) { super(message); this.name = 'InternalError'; }};
|
|
2720
|
-
handleAllocatorInit();
|
|
2721
2597
|
init_emval();;
|
|
2722
2598
|
UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');;
|
|
2723
2599
|
function checkIncomingModuleAPI() {
|
|
@@ -2737,6 +2613,8 @@ var wasmImports = {
|
|
|
2737
2613
|
/** @export */
|
|
2738
2614
|
__resumeException: ___resumeException,
|
|
2739
2615
|
/** @export */
|
|
2616
|
+
_abort_js: __abort_js,
|
|
2617
|
+
/** @export */
|
|
2740
2618
|
_embind_register_bigint: __embind_register_bigint,
|
|
2741
2619
|
/** @export */
|
|
2742
2620
|
_embind_register_bool: __embind_register_bool,
|
|
@@ -2759,6 +2637,8 @@ var wasmImports = {
|
|
|
2759
2637
|
/** @export */
|
|
2760
2638
|
_emscripten_get_now_is_monotonic: __emscripten_get_now_is_monotonic,
|
|
2761
2639
|
/** @export */
|
|
2640
|
+
_emscripten_memcpy_js: __emscripten_memcpy_js,
|
|
2641
|
+
/** @export */
|
|
2762
2642
|
_emval_as: __emval_as,
|
|
2763
2643
|
/** @export */
|
|
2764
2644
|
_emval_call: __emval_call,
|
|
@@ -2787,14 +2667,10 @@ var wasmImports = {
|
|
|
2787
2667
|
/** @export */
|
|
2788
2668
|
_emval_take_value: __emval_take_value,
|
|
2789
2669
|
/** @export */
|
|
2790
|
-
abort: _abort,
|
|
2791
|
-
/** @export */
|
|
2792
2670
|
emscripten_date_now: _emscripten_date_now,
|
|
2793
2671
|
/** @export */
|
|
2794
2672
|
emscripten_get_now: _emscripten_get_now,
|
|
2795
2673
|
/** @export */
|
|
2796
|
-
emscripten_memcpy_js: _emscripten_memcpy_js,
|
|
2797
|
-
/** @export */
|
|
2798
2674
|
emscripten_resize_heap: _emscripten_resize_heap,
|
|
2799
2675
|
/** @export */
|
|
2800
2676
|
fd_close: _fd_close,
|
|
@@ -2803,60 +2679,48 @@ var wasmImports = {
|
|
|
2803
2679
|
/** @export */
|
|
2804
2680
|
fd_write: _fd_write,
|
|
2805
2681
|
/** @export */
|
|
2806
|
-
invoke_ii
|
|
2682
|
+
invoke_ii,
|
|
2807
2683
|
/** @export */
|
|
2808
|
-
invoke_iii
|
|
2684
|
+
invoke_iii,
|
|
2809
2685
|
/** @export */
|
|
2810
|
-
invoke_iiii
|
|
2686
|
+
invoke_iiii,
|
|
2811
2687
|
/** @export */
|
|
2812
|
-
invoke_j
|
|
2688
|
+
invoke_j,
|
|
2813
2689
|
/** @export */
|
|
2814
|
-
invoke_v
|
|
2690
|
+
invoke_v,
|
|
2815
2691
|
/** @export */
|
|
2816
|
-
invoke_vi
|
|
2692
|
+
invoke_vi,
|
|
2817
2693
|
/** @export */
|
|
2818
|
-
invoke_vii
|
|
2694
|
+
invoke_vii,
|
|
2819
2695
|
/** @export */
|
|
2820
|
-
invoke_viii
|
|
2696
|
+
invoke_viii,
|
|
2821
2697
|
/** @export */
|
|
2822
|
-
invoke_viiii
|
|
2698
|
+
invoke_viiii
|
|
2823
2699
|
};
|
|
2824
2700
|
var wasmExports = createWasm();
|
|
2825
|
-
var ___wasm_call_ctors = createExportWrapper('__wasm_call_ctors');
|
|
2826
|
-
var ___getTypeName = createExportWrapper('__getTypeName');
|
|
2827
|
-
var
|
|
2828
|
-
var
|
|
2829
|
-
var
|
|
2830
|
-
var _free =
|
|
2831
|
-
var _setThrew = createExportWrapper('setThrew');
|
|
2832
|
-
var
|
|
2701
|
+
var ___wasm_call_ctors = createExportWrapper('__wasm_call_ctors', 0);
|
|
2702
|
+
var ___getTypeName = createExportWrapper('__getTypeName', 1);
|
|
2703
|
+
var _fflush = createExportWrapper('fflush', 1);
|
|
2704
|
+
var _malloc = createExportWrapper('malloc', 1);
|
|
2705
|
+
var _strerror = createExportWrapper('strerror', 1);
|
|
2706
|
+
var _free = createExportWrapper('free', 1);
|
|
2707
|
+
var _setThrew = createExportWrapper('setThrew', 2);
|
|
2708
|
+
var __emscripten_tempret_set = createExportWrapper('_emscripten_tempret_set', 1);
|
|
2833
2709
|
var _emscripten_stack_init = () => (_emscripten_stack_init = wasmExports['emscripten_stack_init'])();
|
|
2834
2710
|
var _emscripten_stack_get_free = () => (_emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'])();
|
|
2835
2711
|
var _emscripten_stack_get_base = () => (_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'])();
|
|
2836
2712
|
var _emscripten_stack_get_end = () => (_emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'])();
|
|
2837
|
-
var
|
|
2838
|
-
var
|
|
2839
|
-
var stackAlloc = createExportWrapper('stackAlloc');
|
|
2713
|
+
var __emscripten_stack_restore = (a0) => (__emscripten_stack_restore = wasmExports['_emscripten_stack_restore'])(a0);
|
|
2714
|
+
var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'])(a0);
|
|
2840
2715
|
var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
|
|
2841
|
-
var ___cxa_free_exception = createExportWrapper('__cxa_free_exception');
|
|
2842
|
-
var ___cxa_increment_exception_refcount = createExportWrapper('__cxa_increment_exception_refcount');
|
|
2843
|
-
var ___cxa_decrement_exception_refcount = createExportWrapper('__cxa_decrement_exception_refcount');
|
|
2844
|
-
var ___get_exception_message =
|
|
2845
|
-
var ___cxa_can_catch = createExportWrapper('__cxa_can_catch');
|
|
2846
|
-
var ___cxa_is_pointer_type = createExportWrapper('__cxa_is_pointer_type');
|
|
2847
|
-
var dynCall_j = Module['dynCall_j'] = createExportWrapper('dynCall_j');
|
|
2848
|
-
var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji');
|
|
2849
|
-
|
|
2850
|
-
function invoke_iiii(index,a1,a2,a3) {
|
|
2851
|
-
var sp = stackSave();
|
|
2852
|
-
try {
|
|
2853
|
-
return getWasmTableEntry(index)(a1,a2,a3);
|
|
2854
|
-
} catch(e) {
|
|
2855
|
-
stackRestore(sp);
|
|
2856
|
-
if (!(e instanceof EmscriptenEH)) throw e;
|
|
2857
|
-
_setThrew(1, 0);
|
|
2858
|
-
}
|
|
2859
|
-
}
|
|
2716
|
+
var ___cxa_free_exception = createExportWrapper('__cxa_free_exception', 1);
|
|
2717
|
+
var ___cxa_increment_exception_refcount = createExportWrapper('__cxa_increment_exception_refcount', 1);
|
|
2718
|
+
var ___cxa_decrement_exception_refcount = createExportWrapper('__cxa_decrement_exception_refcount', 1);
|
|
2719
|
+
var ___get_exception_message = createExportWrapper('__get_exception_message', 3);
|
|
2720
|
+
var ___cxa_can_catch = createExportWrapper('__cxa_can_catch', 3);
|
|
2721
|
+
var ___cxa_is_pointer_type = createExportWrapper('__cxa_is_pointer_type', 1);
|
|
2722
|
+
var dynCall_j = Module['dynCall_j'] = createExportWrapper('dynCall_j', 1);
|
|
2723
|
+
var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5);
|
|
2860
2724
|
|
|
2861
2725
|
function invoke_iii(index,a1,a2) {
|
|
2862
2726
|
var sp = stackSave();
|
|
@@ -2913,6 +2777,17 @@ function invoke_viii(index,a1,a2,a3) {
|
|
|
2913
2777
|
}
|
|
2914
2778
|
}
|
|
2915
2779
|
|
|
2780
|
+
function invoke_iiii(index,a1,a2,a3) {
|
|
2781
|
+
var sp = stackSave();
|
|
2782
|
+
try {
|
|
2783
|
+
return getWasmTableEntry(index)(a1,a2,a3);
|
|
2784
|
+
} catch(e) {
|
|
2785
|
+
stackRestore(sp);
|
|
2786
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
2787
|
+
_setThrew(1, 0);
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2916
2791
|
function invoke_viiii(index,a1,a2,a3,a4) {
|
|
2917
2792
|
var sp = stackSave();
|
|
2918
2793
|
try {
|
|
@@ -2960,28 +2835,25 @@ var missingLibrarySymbols = [
|
|
|
2960
2835
|
'readI53FromU64',
|
|
2961
2836
|
'convertI32PairToI53',
|
|
2962
2837
|
'convertU32PairToI53',
|
|
2838
|
+
'getTempRet0',
|
|
2963
2839
|
'zeroMemory',
|
|
2964
2840
|
'exitJS',
|
|
2965
2841
|
'isLeapYear',
|
|
2966
2842
|
'ydayFromDate',
|
|
2967
2843
|
'arraySum',
|
|
2968
2844
|
'addDays',
|
|
2969
|
-
'
|
|
2845
|
+
'strError',
|
|
2970
2846
|
'inetPton4',
|
|
2971
2847
|
'inetNtop4',
|
|
2972
2848
|
'inetPton6',
|
|
2973
2849
|
'inetNtop6',
|
|
2974
2850
|
'readSockaddr',
|
|
2975
2851
|
'writeSockaddr',
|
|
2976
|
-
'getHostByName',
|
|
2977
2852
|
'initRandomFill',
|
|
2978
2853
|
'randomFill',
|
|
2979
|
-
'getCallstack',
|
|
2980
2854
|
'emscriptenLog',
|
|
2981
|
-
'convertPCtoSourceLocation',
|
|
2982
2855
|
'readEmAsmArgs',
|
|
2983
2856
|
'jstoi_q',
|
|
2984
|
-
'jstoi_s',
|
|
2985
2857
|
'getExecutableName',
|
|
2986
2858
|
'listenOnce',
|
|
2987
2859
|
'autoResumeAudioContext',
|
|
@@ -2995,6 +2867,7 @@ var missingLibrarySymbols = [
|
|
|
2995
2867
|
'asyncLoad',
|
|
2996
2868
|
'alignMemory',
|
|
2997
2869
|
'mmapAlloc',
|
|
2870
|
+
'HandleAllocator',
|
|
2998
2871
|
'getNativeTypeSize',
|
|
2999
2872
|
'STACK_SIZE',
|
|
3000
2873
|
'STACK_ALIGN',
|
|
@@ -3027,7 +2900,6 @@ var missingLibrarySymbols = [
|
|
|
3027
2900
|
'registerKeyEventCallback',
|
|
3028
2901
|
'maybeCStringToJsString',
|
|
3029
2902
|
'findEventTarget',
|
|
3030
|
-
'findCanvasEventTarget',
|
|
3031
2903
|
'getBoundingClientRect',
|
|
3032
2904
|
'fillMouseEventData',
|
|
3033
2905
|
'registerMouseEventCallback',
|
|
@@ -3066,10 +2938,9 @@ var missingLibrarySymbols = [
|
|
|
3066
2938
|
'registerBatteryEventCallback',
|
|
3067
2939
|
'setCanvasElementSize',
|
|
3068
2940
|
'getCanvasElementSize',
|
|
3069
|
-
'demangle',
|
|
3070
|
-
'demangleAll',
|
|
3071
2941
|
'jsStackTrace',
|
|
3072
|
-
'
|
|
2942
|
+
'getCallstack',
|
|
2943
|
+
'convertPCtoSourceLocation',
|
|
3073
2944
|
'getEnvStrings',
|
|
3074
2945
|
'checkWasiClock',
|
|
3075
2946
|
'wasiRightsToMuslOFlags',
|
|
@@ -3083,6 +2954,7 @@ var missingLibrarySymbols = [
|
|
|
3083
2954
|
'makePromise',
|
|
3084
2955
|
'idsToPromises',
|
|
3085
2956
|
'makePromiseCallback',
|
|
2957
|
+
'Browser_asyncPrepareDataCounter',
|
|
3086
2958
|
'setMainLoop',
|
|
3087
2959
|
'getSocketFromFD',
|
|
3088
2960
|
'getSocketAddress',
|
|
@@ -3090,12 +2962,12 @@ var missingLibrarySymbols = [
|
|
|
3090
2962
|
'FS_modeStringToFlags',
|
|
3091
2963
|
'FS_getMode',
|
|
3092
2964
|
'FS_stdin_getChar',
|
|
3093
|
-
'FS_createDataFile',
|
|
3094
2965
|
'FS_unlink',
|
|
2966
|
+
'FS_createDataFile',
|
|
3095
2967
|
'FS_mkdirTree',
|
|
3096
2968
|
'_setNetworkCallback',
|
|
3097
2969
|
'heapObjectForWebGLType',
|
|
3098
|
-
'
|
|
2970
|
+
'toTypedArrayIndex',
|
|
3099
2971
|
'webgl_enable_ANGLE_instanced_arrays',
|
|
3100
2972
|
'webgl_enable_OES_vertex_array_object',
|
|
3101
2973
|
'webgl_enable_WEBGL_draw_buffers',
|
|
@@ -3104,7 +2976,6 @@ var missingLibrarySymbols = [
|
|
|
3104
2976
|
'computeUnpackAlignedImageSize',
|
|
3105
2977
|
'colorChannelsInGlTextureFormat',
|
|
3106
2978
|
'emscriptenWebGLGetTexPixelData',
|
|
3107
|
-
'__glGenObject',
|
|
3108
2979
|
'emscriptenWebGLGetUniform',
|
|
3109
2980
|
'webglGetUniformLocation',
|
|
3110
2981
|
'webglPrepareUniformLocationsBeforeFirstUse',
|
|
@@ -3114,15 +2985,16 @@ var missingLibrarySymbols = [
|
|
|
3114
2985
|
'writeGLArray',
|
|
3115
2986
|
'registerWebGlEventCallback',
|
|
3116
2987
|
'runAndAbortIfError',
|
|
3117
|
-
'SDL_unicode',
|
|
3118
|
-
'SDL_ttfContext',
|
|
3119
|
-
'SDL_audio',
|
|
3120
2988
|
'ALLOC_NORMAL',
|
|
3121
2989
|
'ALLOC_STACK',
|
|
3122
2990
|
'allocate',
|
|
3123
2991
|
'writeStringToMemory',
|
|
3124
2992
|
'writeAsciiToMemory',
|
|
2993
|
+
'setErrNo',
|
|
2994
|
+
'demangle',
|
|
2995
|
+
'stackTrace',
|
|
3125
2996
|
'getFunctionArgsName',
|
|
2997
|
+
'createJsInvokerSignature',
|
|
3126
2998
|
'init_embind',
|
|
3127
2999
|
'getBasestPointer',
|
|
3128
3000
|
'registerInheritedInstance',
|
|
@@ -3168,26 +3040,19 @@ var unexportedSymbols = [
|
|
|
3168
3040
|
'addOnPostRun',
|
|
3169
3041
|
'addRunDependency',
|
|
3170
3042
|
'removeRunDependency',
|
|
3171
|
-
'FS_createFolder',
|
|
3172
|
-
'FS_createPath',
|
|
3173
|
-
'FS_createLazyFile',
|
|
3174
|
-
'FS_createLink',
|
|
3175
|
-
'FS_createDevice',
|
|
3176
|
-
'FS_readFile',
|
|
3177
3043
|
'out',
|
|
3178
3044
|
'err',
|
|
3179
3045
|
'callMain',
|
|
3180
3046
|
'abort',
|
|
3181
3047
|
'wasmMemory',
|
|
3182
3048
|
'wasmExports',
|
|
3183
|
-
'stackAlloc',
|
|
3184
|
-
'stackSave',
|
|
3185
|
-
'stackRestore',
|
|
3186
|
-
'getTempRet0',
|
|
3187
|
-
'setTempRet0',
|
|
3188
3049
|
'writeStackCookie',
|
|
3189
3050
|
'checkStackCookie',
|
|
3190
3051
|
'convertI32PairToI53Checked',
|
|
3052
|
+
'stackSave',
|
|
3053
|
+
'stackRestore',
|
|
3054
|
+
'stackAlloc',
|
|
3055
|
+
'setTempRet0',
|
|
3191
3056
|
'ptrToString',
|
|
3192
3057
|
'getHeapMax',
|
|
3193
3058
|
'growMemory',
|
|
@@ -3197,19 +3062,16 @@ var unexportedSymbols = [
|
|
|
3197
3062
|
'MONTH_DAYS_REGULAR_CUMULATIVE',
|
|
3198
3063
|
'MONTH_DAYS_LEAP_CUMULATIVE',
|
|
3199
3064
|
'ERRNO_CODES',
|
|
3200
|
-
'ERRNO_MESSAGES',
|
|
3201
3065
|
'DNS',
|
|
3202
3066
|
'Protocols',
|
|
3203
3067
|
'Sockets',
|
|
3204
3068
|
'timers',
|
|
3205
3069
|
'warnOnce',
|
|
3206
|
-
'UNWIND_CACHE',
|
|
3207
3070
|
'readEmAsmArgsArray',
|
|
3071
|
+
'jstoi_s',
|
|
3208
3072
|
'dynCallLegacy',
|
|
3209
3073
|
'getDynCaller',
|
|
3210
3074
|
'dynCall',
|
|
3211
|
-
'handleAllocatorInit',
|
|
3212
|
-
'HandleAllocator',
|
|
3213
3075
|
'wasmTable',
|
|
3214
3076
|
'noExitRuntime',
|
|
3215
3077
|
'freeTableIndexes',
|
|
@@ -3233,8 +3095,10 @@ var unexportedSymbols = [
|
|
|
3233
3095
|
'lengthBytesUTF32',
|
|
3234
3096
|
'JSEvents',
|
|
3235
3097
|
'specialHTMLTargets',
|
|
3098
|
+
'findCanvasEventTarget',
|
|
3236
3099
|
'currentFullscreenStrategy',
|
|
3237
3100
|
'restoreOldWindowedStyle',
|
|
3101
|
+
'UNWIND_CACHE',
|
|
3238
3102
|
'ExitStatus',
|
|
3239
3103
|
'flush_NO_FILESYSTEM',
|
|
3240
3104
|
'promiseMap',
|
|
@@ -3248,11 +3112,16 @@ var unexportedSymbols = [
|
|
|
3248
3112
|
'decrementExceptionRefcount',
|
|
3249
3113
|
'getExceptionMessage',
|
|
3250
3114
|
'Browser',
|
|
3115
|
+
'getPreloadedImageData__data',
|
|
3251
3116
|
'wget',
|
|
3252
3117
|
'SYSCALLS',
|
|
3253
3118
|
'preloadPlugins',
|
|
3254
3119
|
'FS_stdin_getChar_buffer',
|
|
3120
|
+
'FS_createPath',
|
|
3121
|
+
'FS_createDevice',
|
|
3122
|
+
'FS_readFile',
|
|
3255
3123
|
'FS',
|
|
3124
|
+
'FS_createLazyFile',
|
|
3256
3125
|
'MEMFS',
|
|
3257
3126
|
'TTY',
|
|
3258
3127
|
'PIPEFS',
|
|
@@ -3261,7 +3130,6 @@ var unexportedSymbols = [
|
|
|
3261
3130
|
'miniTempWebGLFloatBuffers',
|
|
3262
3131
|
'miniTempWebGLIntBuffers',
|
|
3263
3132
|
'GL',
|
|
3264
|
-
'emscripten_webgl_power_preferences',
|
|
3265
3133
|
'AL',
|
|
3266
3134
|
'GLUT',
|
|
3267
3135
|
'EGL',
|
|
@@ -3271,6 +3139,8 @@ var unexportedSymbols = [
|
|
|
3271
3139
|
'SDL_gfx',
|
|
3272
3140
|
'allocateUTF8',
|
|
3273
3141
|
'allocateUTF8OnStack',
|
|
3142
|
+
'print',
|
|
3143
|
+
'printErr',
|
|
3274
3144
|
'InternalError',
|
|
3275
3145
|
'BindingError',
|
|
3276
3146
|
'throwInternalError',
|
|
@@ -3289,9 +3159,12 @@ var unexportedSymbols = [
|
|
|
3289
3159
|
'getFunctionName',
|
|
3290
3160
|
'heap32VectorToArray',
|
|
3291
3161
|
'requireRegisteredType',
|
|
3162
|
+
'usesDestructorStack',
|
|
3163
|
+
'createJsInvoker',
|
|
3292
3164
|
'UnboundTypeError',
|
|
3293
3165
|
'PureVirtualError',
|
|
3294
3166
|
'GenericWireTypeSize',
|
|
3167
|
+
'EmValType',
|
|
3295
3168
|
'throwUnboundTypeError',
|
|
3296
3169
|
'ensureOverloadTable',
|
|
3297
3170
|
'exposePublicSymbol',
|
|
@@ -3304,7 +3177,6 @@ var unexportedSymbols = [
|
|
|
3304
3177
|
'registerType',
|
|
3305
3178
|
'integerReadValueFromPointer',
|
|
3306
3179
|
'floatReadValueFromPointer',
|
|
3307
|
-
'simpleReadValueFromPointer',
|
|
3308
3180
|
'readPointer',
|
|
3309
3181
|
'runDestructors',
|
|
3310
3182
|
'newFunc',
|
|
@@ -3314,6 +3186,7 @@ var unexportedSymbols = [
|
|
|
3314
3186
|
'detachFinalizer_deps',
|
|
3315
3187
|
'deletionQueue',
|
|
3316
3188
|
'delayFunction',
|
|
3189
|
+
'emval_freelist',
|
|
3317
3190
|
'emval_handles',
|
|
3318
3191
|
'emval_symbols',
|
|
3319
3192
|
'init_emval',
|
|
@@ -3374,7 +3247,7 @@ function run() {
|
|
|
3374
3247
|
initRuntime();
|
|
3375
3248
|
|
|
3376
3249
|
readyPromiseResolve(Module);
|
|
3377
|
-
|
|
3250
|
+
Module['onRuntimeInitialized']?.();
|
|
3378
3251
|
|
|
3379
3252
|
assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
|
|
3380
3253
|
|
|
@@ -3434,15 +3307,40 @@ if (Module['preInit']) {
|
|
|
3434
3307
|
|
|
3435
3308
|
run();
|
|
3436
3309
|
|
|
3437
|
-
|
|
3438
3310
|
// end include: postamble.js
|
|
3439
3311
|
|
|
3312
|
+
// include: postamble_modularize.js
|
|
3313
|
+
// In MODULARIZE mode we wrap the generated code in a factory function
|
|
3314
|
+
// and return either the Module itself, or a promise of the module.
|
|
3315
|
+
//
|
|
3316
|
+
// We assign to the `moduleRtn` global here and configure closure to see
|
|
3317
|
+
// this as and extern so it won't get minified.
|
|
3318
|
+
|
|
3319
|
+
moduleRtn = readyPromise;
|
|
3320
|
+
|
|
3321
|
+
// Assertion for attempting to access module properties on the incoming
|
|
3322
|
+
// moduleArg. In the past we used this object as the prototype of the module
|
|
3323
|
+
// and assigned properties to it, but now we return a distinct object. This
|
|
3324
|
+
// keeps the instance private until it is ready (i.e the promise has been
|
|
3325
|
+
// resolved).
|
|
3326
|
+
for (const prop of Object.keys(Module)) {
|
|
3327
|
+
if (!(prop in moduleArg)) {
|
|
3328
|
+
Object.defineProperty(moduleArg, prop, {
|
|
3329
|
+
configurable: true,
|
|
3330
|
+
get() {
|
|
3331
|
+
abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)
|
|
3332
|
+
}
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
// end include: postamble_modularize.js
|
|
3337
|
+
|
|
3338
|
+
|
|
3440
3339
|
|
|
3441
|
-
return
|
|
3340
|
+
return moduleRtn;
|
|
3442
3341
|
}
|
|
3443
3342
|
);
|
|
3444
3343
|
})();
|
|
3445
|
-
;
|
|
3446
3344
|
if (typeof exports === 'object' && typeof module === 'object')
|
|
3447
3345
|
module.exports = Module;
|
|
3448
3346
|
else if (typeof define === 'function' && define['amd'])
|