@keymanapp/kmc-kmn 18.0.91-alpha → 18.0.93-alpha
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/build/src/import/kmcmplib/wasm-host.d.ts +1 -1
- package/build/src/import/kmcmplib/wasm-host.d.ts.map +1 -1
- package/build/src/import/kmcmplib/wasm-host.js +1075 -1262
- package/build/src/import/kmcmplib/wasm-host.js.map +1 -1
- package/build/src/import/kmcmplib/wasm-host.wasm +0 -0
- package/package.json +5 -5
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
var Module = (() => {
|
|
2
|
-
var
|
|
3
|
-
return (async function (
|
|
2
|
+
var _scriptName = import.meta.url;
|
|
3
|
+
return (async function (moduleArg = {}) {
|
|
4
|
+
var moduleRtn;
|
|
4
5
|
// include: shell.js
|
|
5
6
|
// The Module object: Our interface to the outside world. We import
|
|
6
7
|
// and export values on it. There are various ways Module can be used:
|
|
7
8
|
// 1. Not defined. We create it here
|
|
8
|
-
// 2. A function parameter, function(
|
|
9
|
+
// 2. A function parameter, function(moduleArg) => Promise<Module>
|
|
9
10
|
// 3. pre-run appended it, var Module = {}; ..generated code..
|
|
10
11
|
// 4. External script tag defines var Module.
|
|
11
12
|
// We need to check if Module already exists (e.g. case 3 above).
|
|
@@ -15,13 +16,31 @@ var Module = (() => {
|
|
|
15
16
|
// after the generated code, you will need to define var Module = {};
|
|
16
17
|
// before the code. Then that object will be used in the code, and you
|
|
17
18
|
// can continue to use Module afterwards as well.
|
|
18
|
-
var Module =
|
|
19
|
+
var Module = Object.assign({}, moduleArg);
|
|
19
20
|
// Set up the promise that indicates the Module is initialized
|
|
20
21
|
var readyPromiseResolve, readyPromiseReject;
|
|
21
|
-
|
|
22
|
+
var readyPromise = new Promise((resolve, reject) => {
|
|
22
23
|
readyPromiseResolve = resolve;
|
|
23
24
|
readyPromiseReject = reject;
|
|
24
25
|
});
|
|
26
|
+
// Determine the runtime environment we are in. You can customize this by
|
|
27
|
+
// setting the ENVIRONMENT setting at compile time (see settings.js).
|
|
28
|
+
// Attempt to auto-detect the environment
|
|
29
|
+
var ENVIRONMENT_IS_WEB = typeof window == 'object';
|
|
30
|
+
var ENVIRONMENT_IS_WORKER = typeof importScripts == 'function';
|
|
31
|
+
// N.b. Electron.js environment is simultaneously a NODE-environment, but
|
|
32
|
+
// also a web environment.
|
|
33
|
+
var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string';
|
|
34
|
+
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
35
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
36
|
+
// `require()` is no-op in an ESM module, use `createRequire()` to construct
|
|
37
|
+
// the require()` function. This is only necessary for multi-environment
|
|
38
|
+
// builds, `-sENVIRONMENT=node` emits a static import declaration instead.
|
|
39
|
+
// TODO: Swap all `require()`'s with `import()`'s?
|
|
40
|
+
const { createRequire } = await import('module');
|
|
41
|
+
/** @suppress{duplicate} */
|
|
42
|
+
var require = createRequire(import.meta.url);
|
|
43
|
+
}
|
|
25
44
|
// --pre-jses are emitted after the Module integration code, so that they can
|
|
26
45
|
// refer to Module (if they choose; they can also define Module)
|
|
27
46
|
// Sometimes an existing Module object exists with properties
|
|
@@ -35,15 +54,6 @@ var Module = (() => {
|
|
|
35
54
|
var quit_ = (status, toThrow) => {
|
|
36
55
|
throw toThrow;
|
|
37
56
|
};
|
|
38
|
-
// Determine the runtime environment we are in. You can customize this by
|
|
39
|
-
// setting the ENVIRONMENT setting at compile time (see settings.js).
|
|
40
|
-
// Attempt to auto-detect the environment
|
|
41
|
-
var ENVIRONMENT_IS_WEB = typeof window == 'object';
|
|
42
|
-
var ENVIRONMENT_IS_WORKER = typeof importScripts == 'function';
|
|
43
|
-
// N.b. Electron.js environment is simultaneously a NODE-environment, but
|
|
44
|
-
// also a web environment.
|
|
45
|
-
var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string';
|
|
46
|
-
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
47
57
|
// `/` should be present at the end if `scriptDirectory` is not empty
|
|
48
58
|
var scriptDirectory = '';
|
|
49
59
|
function locateFile(path) {
|
|
@@ -53,15 +63,8 @@ var Module = (() => {
|
|
|
53
63
|
return scriptDirectory + path;
|
|
54
64
|
}
|
|
55
65
|
// Hooks that are implemented differently in different runtime environments.
|
|
56
|
-
var read_, readAsync, readBinary
|
|
66
|
+
var read_, readAsync, readBinary;
|
|
57
67
|
if (ENVIRONMENT_IS_NODE) {
|
|
58
|
-
// `require()` is no-op in an ESM module, use `createRequire()` to construct
|
|
59
|
-
// the require()` function. This is only necessary for multi-environment
|
|
60
|
-
// builds, `-sENVIRONMENT=node` emits a static import declaration instead.
|
|
61
|
-
// TODO: Swap all `require()`'s with `import()`'s?
|
|
62
|
-
const { createRequire } = await import('module');
|
|
63
|
-
/** @suppress{duplicate} */
|
|
64
|
-
var require = createRequire(import.meta.url);
|
|
65
68
|
// These modules will usually be used on Node.js. Load them eagerly to avoid
|
|
66
69
|
// the complexity of lazy-loading.
|
|
67
70
|
var fs = require('fs');
|
|
@@ -89,42 +92,26 @@ var Module = (() => {
|
|
|
89
92
|
}
|
|
90
93
|
return ret;
|
|
91
94
|
};
|
|
92
|
-
readAsync = (filename, onload, onerror) => {
|
|
95
|
+
readAsync = (filename, onload, onerror, binary = true) => {
|
|
93
96
|
// See the comment in the `read_` function.
|
|
94
97
|
filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
|
|
95
|
-
fs.readFile(filename,
|
|
98
|
+
fs.readFile(filename, binary ? undefined : 'utf8', (err, data) => {
|
|
96
99
|
if (err)
|
|
97
100
|
onerror(err);
|
|
98
101
|
else
|
|
99
|
-
onload(data.buffer);
|
|
102
|
+
onload(binary ? data.buffer : data);
|
|
100
103
|
});
|
|
101
104
|
};
|
|
102
105
|
// end include: node_shell_read.js
|
|
103
|
-
if (process.argv.length > 1) {
|
|
106
|
+
if (!Module['thisProgram'] && process.argv.length > 1) {
|
|
104
107
|
thisProgram = process.argv[1].replace(/\\/g, '/');
|
|
105
108
|
}
|
|
106
109
|
arguments_ = process.argv.slice(2);
|
|
107
110
|
// MODULARIZE will export the module in the proper place outside, we don't need to export here
|
|
108
|
-
process.on('uncaughtException', function (ex) {
|
|
109
|
-
// suppress ExitStatus exceptions from showing an error
|
|
110
|
-
if (ex !== 'unwind' && !(ex instanceof ExitStatus) && !(ex.context instanceof ExitStatus)) {
|
|
111
|
-
throw ex;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
// Without this older versions of node (< v15) will log unhandled rejections
|
|
115
|
-
// but return 0, which is not normally the desired behaviour. This is
|
|
116
|
-
// not be needed with node v15 and about because it is now the default
|
|
117
|
-
// behaviour:
|
|
118
|
-
// See https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode
|
|
119
|
-
var nodeMajor = process.versions.node.split(".")[0];
|
|
120
|
-
if (nodeMajor < 15) {
|
|
121
|
-
process.on('unhandledRejection', function (reason) { throw reason; });
|
|
122
|
-
}
|
|
123
111
|
quit_ = (status, toThrow) => {
|
|
124
112
|
process.exitCode = status;
|
|
125
113
|
throw toThrow;
|
|
126
114
|
};
|
|
127
|
-
Module['inspect'] = function () { return '[Emscripten Module object]'; };
|
|
128
115
|
}
|
|
129
116
|
else
|
|
130
117
|
// Note that this includes Node.js workers when relevant (pthreads is enabled).
|
|
@@ -139,8 +126,8 @@ var Module = (() => {
|
|
|
139
126
|
}
|
|
140
127
|
// When MODULARIZE, this JS may be executed later, after document.currentScript
|
|
141
128
|
// is gone, so we saved it, and we use it here instead of any other info.
|
|
142
|
-
if (
|
|
143
|
-
scriptDirectory =
|
|
129
|
+
if (_scriptName) {
|
|
130
|
+
scriptDirectory = _scriptName;
|
|
144
131
|
}
|
|
145
132
|
// blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
|
|
146
133
|
// otherwise, slice off the final part of the url to find the script directory.
|
|
@@ -148,14 +135,12 @@ var Module = (() => {
|
|
|
148
135
|
// and scriptDirectory will correctly be replaced with an empty string.
|
|
149
136
|
// If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
|
|
150
137
|
// they are removed because they could contain a slash.
|
|
151
|
-
if (scriptDirectory.
|
|
152
|
-
scriptDirectory =
|
|
138
|
+
if (scriptDirectory.startsWith('blob:')) {
|
|
139
|
+
scriptDirectory = '';
|
|
153
140
|
}
|
|
154
141
|
else {
|
|
155
|
-
scriptDirectory = '';
|
|
142
|
+
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, '').lastIndexOf('/') + 1);
|
|
156
143
|
}
|
|
157
|
-
// Differentiate the Web Worker from the Node Worker case, as reading must
|
|
158
|
-
// be done differently.
|
|
159
144
|
{
|
|
160
145
|
// include: web_or_worker_shell_read.js
|
|
161
146
|
read_ = (url) => {
|
|
@@ -189,16 +174,15 @@ var Module = (() => {
|
|
|
189
174
|
};
|
|
190
175
|
// end include: web_or_worker_shell_read.js
|
|
191
176
|
}
|
|
192
|
-
setWindowTitle = (title) => document.title = title;
|
|
193
177
|
}
|
|
194
178
|
else {
|
|
195
179
|
}
|
|
196
180
|
var out = Module['print'] || console.log.bind(console);
|
|
197
|
-
var err = Module['printErr'] || console.
|
|
181
|
+
var err = Module['printErr'] || console.error.bind(console);
|
|
198
182
|
// Merge back in the overrides
|
|
199
183
|
Object.assign(Module, moduleOverrides);
|
|
200
184
|
// Free the object hierarchy contained in the overrides, this lets the GC
|
|
201
|
-
// reclaim data used
|
|
185
|
+
// reclaim data used.
|
|
202
186
|
moduleOverrides = null;
|
|
203
187
|
// Emit code to handle expected values on the Module object. This applies Module.x
|
|
204
188
|
// to the proper local x. This has two benefits: first, we only emit it if it is
|
|
@@ -224,10 +208,6 @@ var Module = (() => {
|
|
|
224
208
|
var wasmBinary;
|
|
225
209
|
if (Module['wasmBinary'])
|
|
226
210
|
wasmBinary = Module['wasmBinary'];
|
|
227
|
-
var noExitRuntime = Module['noExitRuntime'] || true;
|
|
228
|
-
if (typeof WebAssembly != 'object') {
|
|
229
|
-
abort('no native wasm support detected');
|
|
230
|
-
}
|
|
231
211
|
// Wasm globals
|
|
232
212
|
var wasmMemory;
|
|
233
213
|
//========================================
|
|
@@ -240,211 +220,19 @@ var Module = (() => {
|
|
|
240
220
|
// NOTE: This is also used as the process return code code in shell environments
|
|
241
221
|
// but only when noExitRuntime is false.
|
|
242
222
|
var EXITSTATUS;
|
|
223
|
+
// In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we
|
|
224
|
+
// don't define it at all in release modes. This matches the behaviour of
|
|
225
|
+
// MINIMAL_RUNTIME.
|
|
226
|
+
// TODO(sbc): Make this the default even without STRICT enabled.
|
|
243
227
|
/** @type {function(*, string=)} */
|
|
244
228
|
function assert(condition, text) {
|
|
245
229
|
if (!condition) {
|
|
246
230
|
// This build was created without ASSERTIONS defined. `assert()` should not
|
|
247
231
|
// ever be called in this configuration but in case there are callers in
|
|
248
|
-
// the wild leave this simple abort()
|
|
232
|
+
// the wild leave this simple abort() implementation here for now.
|
|
249
233
|
abort(text);
|
|
250
234
|
}
|
|
251
235
|
}
|
|
252
|
-
// include: runtime_strings.js
|
|
253
|
-
// runtime_strings.js: String related runtime functions that are part of both
|
|
254
|
-
// MINIMAL_RUNTIME and regular runtime.
|
|
255
|
-
var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf8') : undefined;
|
|
256
|
-
/**
|
|
257
|
-
* Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
|
|
258
|
-
* array that contains uint8 values, returns a copy of that string as a
|
|
259
|
-
* Javascript String object.
|
|
260
|
-
* heapOrArray is either a regular array, or a JavaScript typed array view.
|
|
261
|
-
* @param {number} idx
|
|
262
|
-
* @param {number=} maxBytesToRead
|
|
263
|
-
* @return {string}
|
|
264
|
-
*/
|
|
265
|
-
function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) {
|
|
266
|
-
var endIdx = idx + maxBytesToRead;
|
|
267
|
-
var endPtr = idx;
|
|
268
|
-
// TextDecoder needs to know the byte length in advance, it doesn't stop on
|
|
269
|
-
// null terminator by itself. Also, use the length info to avoid running tiny
|
|
270
|
-
// strings through TextDecoder, since .subarray() allocates garbage.
|
|
271
|
-
// (As a tiny code save trick, compare endPtr against endIdx using a negation,
|
|
272
|
-
// so that undefined means Infinity)
|
|
273
|
-
while (heapOrArray[endPtr] && !(endPtr >= endIdx))
|
|
274
|
-
++endPtr;
|
|
275
|
-
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
276
|
-
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
|
|
277
|
-
}
|
|
278
|
-
var str = '';
|
|
279
|
-
// If building with TextDecoder, we have already computed the string length
|
|
280
|
-
// above, so test loop end condition against that
|
|
281
|
-
while (idx < endPtr) {
|
|
282
|
-
// For UTF8 byte structure, see:
|
|
283
|
-
// http://en.wikipedia.org/wiki/UTF-8#Description
|
|
284
|
-
// https://www.ietf.org/rfc/rfc2279.txt
|
|
285
|
-
// https://tools.ietf.org/html/rfc3629
|
|
286
|
-
var u0 = heapOrArray[idx++];
|
|
287
|
-
if (!(u0 & 0x80)) {
|
|
288
|
-
str += String.fromCharCode(u0);
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
var u1 = heapOrArray[idx++] & 63;
|
|
292
|
-
if ((u0 & 0xE0) == 0xC0) {
|
|
293
|
-
str += String.fromCharCode(((u0 & 31) << 6) | u1);
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
var u2 = heapOrArray[idx++] & 63;
|
|
297
|
-
if ((u0 & 0xF0) == 0xE0) {
|
|
298
|
-
u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
|
|
302
|
-
}
|
|
303
|
-
if (u0 < 0x10000) {
|
|
304
|
-
str += String.fromCharCode(u0);
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
var ch = u0 - 0x10000;
|
|
308
|
-
str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
return str;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
|
|
315
|
-
* emscripten HEAP, returns a copy of that string as a Javascript String object.
|
|
316
|
-
*
|
|
317
|
-
* @param {number} ptr
|
|
318
|
-
* @param {number=} maxBytesToRead - An optional length that specifies the
|
|
319
|
-
* maximum number of bytes to read. You can omit this parameter to scan the
|
|
320
|
-
* string until the first \0 byte. If maxBytesToRead is passed, and the string
|
|
321
|
-
* at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
|
|
322
|
-
* string will cut short at that byte index (i.e. maxBytesToRead will not
|
|
323
|
-
* produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
|
|
324
|
-
* frequent uses of UTF8ToString() with and without maxBytesToRead may throw
|
|
325
|
-
* JS JIT optimizations off, so it is worth to consider consistently using one
|
|
326
|
-
* @return {string}
|
|
327
|
-
*/
|
|
328
|
-
function UTF8ToString(ptr, maxBytesToRead) {
|
|
329
|
-
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Copies the given Javascript String object 'str' to the given byte array at
|
|
333
|
-
* address 'outIdx', encoded in UTF8 form and null-terminated. The copy will
|
|
334
|
-
* require at most str.length*4+1 bytes of space in the HEAP. Use the function
|
|
335
|
-
* lengthBytesUTF8 to compute the exact number of bytes (excluding null
|
|
336
|
-
* terminator) that this function will write.
|
|
337
|
-
*
|
|
338
|
-
* @param {string} str - The Javascript string to copy.
|
|
339
|
-
* @param {ArrayBufferView|Array<number>} heap - The array to copy to. Each
|
|
340
|
-
* index in this array is assumed
|
|
341
|
-
* to be one 8-byte element.
|
|
342
|
-
* @param {number} outIdx - The starting offset in the array to begin the copying.
|
|
343
|
-
* @param {number} maxBytesToWrite - The maximum number of bytes this function
|
|
344
|
-
* can write to the array. This count should
|
|
345
|
-
* include the null terminator, i.e. if
|
|
346
|
-
* maxBytesToWrite=1, only the null terminator
|
|
347
|
-
* will be written and nothing else.
|
|
348
|
-
* maxBytesToWrite=0 does not write any bytes
|
|
349
|
-
* to the output, not even the null
|
|
350
|
-
* terminator.
|
|
351
|
-
* @return {number} The number of bytes written, EXCLUDING the null terminator.
|
|
352
|
-
*/
|
|
353
|
-
function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
|
|
354
|
-
// Parameter maxBytesToWrite is not optional. Negative values, 0, null,
|
|
355
|
-
// undefined and false each don't write out any bytes.
|
|
356
|
-
if (!(maxBytesToWrite > 0))
|
|
357
|
-
return 0;
|
|
358
|
-
var startIdx = outIdx;
|
|
359
|
-
var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
|
|
360
|
-
for (var i = 0; i < str.length; ++i) {
|
|
361
|
-
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
|
|
362
|
-
// unit, not a Unicode code point of the character! So decode
|
|
363
|
-
// UTF16->UTF32->UTF8.
|
|
364
|
-
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
365
|
-
// For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
|
|
366
|
-
// and https://www.ietf.org/rfc/rfc2279.txt
|
|
367
|
-
// and https://tools.ietf.org/html/rfc3629
|
|
368
|
-
var u = str.charCodeAt(i); // possibly a lead surrogate
|
|
369
|
-
if (u >= 0xD800 && u <= 0xDFFF) {
|
|
370
|
-
var u1 = str.charCodeAt(++i);
|
|
371
|
-
u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
|
|
372
|
-
}
|
|
373
|
-
if (u <= 0x7F) {
|
|
374
|
-
if (outIdx >= endIdx)
|
|
375
|
-
break;
|
|
376
|
-
heap[outIdx++] = u;
|
|
377
|
-
}
|
|
378
|
-
else if (u <= 0x7FF) {
|
|
379
|
-
if (outIdx + 1 >= endIdx)
|
|
380
|
-
break;
|
|
381
|
-
heap[outIdx++] = 0xC0 | (u >> 6);
|
|
382
|
-
heap[outIdx++] = 0x80 | (u & 63);
|
|
383
|
-
}
|
|
384
|
-
else if (u <= 0xFFFF) {
|
|
385
|
-
if (outIdx + 2 >= endIdx)
|
|
386
|
-
break;
|
|
387
|
-
heap[outIdx++] = 0xE0 | (u >> 12);
|
|
388
|
-
heap[outIdx++] = 0x80 | ((u >> 6) & 63);
|
|
389
|
-
heap[outIdx++] = 0x80 | (u & 63);
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
392
|
-
if (outIdx + 3 >= endIdx)
|
|
393
|
-
break;
|
|
394
|
-
heap[outIdx++] = 0xF0 | (u >> 18);
|
|
395
|
-
heap[outIdx++] = 0x80 | ((u >> 12) & 63);
|
|
396
|
-
heap[outIdx++] = 0x80 | ((u >> 6) & 63);
|
|
397
|
-
heap[outIdx++] = 0x80 | (u & 63);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
// Null-terminate the pointer to the buffer.
|
|
401
|
-
heap[outIdx] = 0;
|
|
402
|
-
return outIdx - startIdx;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Copies the given Javascript String object 'str' to the emscripten HEAP at
|
|
406
|
-
* address 'outPtr', null-terminated and encoded in UTF8 form. The copy will
|
|
407
|
-
* require at most str.length*4+1 bytes of space in the HEAP.
|
|
408
|
-
* Use the function lengthBytesUTF8 to compute the exact number of bytes
|
|
409
|
-
* (excluding null terminator) that this function will write.
|
|
410
|
-
*
|
|
411
|
-
* @return {number} The number of bytes written, EXCLUDING the null terminator.
|
|
412
|
-
*/
|
|
413
|
-
function stringToUTF8(str, outPtr, maxBytesToWrite) {
|
|
414
|
-
return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Returns the number of bytes the given Javascript string takes if encoded as a
|
|
418
|
-
* UTF8 byte array, EXCLUDING the null terminator byte.
|
|
419
|
-
*
|
|
420
|
-
* @param {string} str - JavaScript string to operator on
|
|
421
|
-
* @return {number} Length, in bytes, of the UTF8 encoded string.
|
|
422
|
-
*/
|
|
423
|
-
function lengthBytesUTF8(str) {
|
|
424
|
-
var len = 0;
|
|
425
|
-
for (var i = 0; i < str.length; ++i) {
|
|
426
|
-
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
|
|
427
|
-
// unit, not a Unicode code point of the character! So decode
|
|
428
|
-
// UTF16->UTF32->UTF8.
|
|
429
|
-
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
430
|
-
var c = str.charCodeAt(i); // possibly a lead surrogate
|
|
431
|
-
if (c <= 0x7F) {
|
|
432
|
-
len++;
|
|
433
|
-
}
|
|
434
|
-
else if (c <= 0x7FF) {
|
|
435
|
-
len += 2;
|
|
436
|
-
}
|
|
437
|
-
else if (c >= 0xD800 && c <= 0xDFFF) {
|
|
438
|
-
len += 4;
|
|
439
|
-
++i;
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
442
|
-
len += 3;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
return len;
|
|
446
|
-
}
|
|
447
|
-
// end include: runtime_strings.js
|
|
448
236
|
// Memory management
|
|
449
237
|
var HEAP,
|
|
450
238
|
/** @type {!Int8Array} */
|
|
@@ -463,23 +251,19 @@ var Module = (() => {
|
|
|
463
251
|
HEAPF32,
|
|
464
252
|
/** @type {!Float64Array} */
|
|
465
253
|
HEAPF64;
|
|
254
|
+
// include: runtime_shared.js
|
|
466
255
|
function updateMemoryViews() {
|
|
467
256
|
var b = wasmMemory.buffer;
|
|
468
257
|
Module['HEAP8'] = HEAP8 = new Int8Array(b);
|
|
469
258
|
Module['HEAP16'] = HEAP16 = new Int16Array(b);
|
|
470
|
-
Module['HEAP32'] = HEAP32 = new Int32Array(b);
|
|
471
259
|
Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
|
|
472
260
|
Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
|
|
261
|
+
Module['HEAP32'] = HEAP32 = new Int32Array(b);
|
|
473
262
|
Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
|
|
474
263
|
Module['HEAPF32'] = HEAPF32 = new Float32Array(b);
|
|
475
264
|
Module['HEAPF64'] = HEAPF64 = new Float64Array(b);
|
|
476
265
|
}
|
|
477
|
-
// include:
|
|
478
|
-
// In regular non-RELOCATABLE mode the table is exported
|
|
479
|
-
// from the wasm module and this will be assigned once
|
|
480
|
-
// the exports are available.
|
|
481
|
-
var wasmTable;
|
|
482
|
-
// end include: runtime_init_table.js
|
|
266
|
+
// end include: runtime_shared.js
|
|
483
267
|
// include: runtime_stack_check.js
|
|
484
268
|
// end include: runtime_stack_check.js
|
|
485
269
|
// include: runtime_assertions.js
|
|
@@ -489,10 +273,6 @@ var Module = (() => {
|
|
|
489
273
|
var __ATEXIT__ = []; // functions called during shutdown
|
|
490
274
|
var __ATPOSTRUN__ = []; // functions called after the main() is called
|
|
491
275
|
var runtimeInitialized = false;
|
|
492
|
-
var runtimeKeepaliveCounter = 0;
|
|
493
|
-
function keepRuntimeAlive() {
|
|
494
|
-
return noExitRuntime || runtimeKeepaliveCounter > 0;
|
|
495
|
-
}
|
|
496
276
|
function preRun() {
|
|
497
277
|
if (Module['preRun']) {
|
|
498
278
|
if (typeof Module['preRun'] == 'function')
|
|
@@ -549,15 +329,11 @@ var Module = (() => {
|
|
|
549
329
|
}
|
|
550
330
|
function addRunDependency(id) {
|
|
551
331
|
runDependencies++;
|
|
552
|
-
|
|
553
|
-
Module['monitorRunDependencies'](runDependencies);
|
|
554
|
-
}
|
|
332
|
+
Module['monitorRunDependencies']?.(runDependencies);
|
|
555
333
|
}
|
|
556
334
|
function removeRunDependency(id) {
|
|
557
335
|
runDependencies--;
|
|
558
|
-
|
|
559
|
-
Module['monitorRunDependencies'](runDependencies);
|
|
560
|
-
}
|
|
336
|
+
Module['monitorRunDependencies']?.(runDependencies);
|
|
561
337
|
if (runDependencies == 0) {
|
|
562
338
|
if (runDependencyWatcher !== null) {
|
|
563
339
|
clearInterval(runDependencyWatcher);
|
|
@@ -572,9 +348,7 @@ var Module = (() => {
|
|
|
572
348
|
}
|
|
573
349
|
/** @param {string|number=} what */
|
|
574
350
|
function abort(what) {
|
|
575
|
-
|
|
576
|
-
Module['onAbort'](what);
|
|
577
|
-
}
|
|
351
|
+
Module['onAbort']?.(what);
|
|
578
352
|
what = 'Aborted(' + what + ')';
|
|
579
353
|
// TODO(sbc): Should we remove printing and leave it up to whoever
|
|
580
354
|
// catches the exception?
|
|
@@ -591,12 +365,12 @@ var Module = (() => {
|
|
|
591
365
|
// we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
|
|
592
366
|
// allows this in the wasm spec.
|
|
593
367
|
// Suppress closure compiler warning here. Closure compiler's builtin extern
|
|
594
|
-
//
|
|
368
|
+
// definition for WebAssembly.RuntimeError claims it takes no arguments even
|
|
595
369
|
// though it can.
|
|
596
370
|
// TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
|
|
597
371
|
// See above, in the meantime, we resort to wasm code for trapping.
|
|
598
372
|
//
|
|
599
|
-
// In case abort() is called before the module is initialized,
|
|
373
|
+
// In case abort() is called before the module is initialized, wasmExports
|
|
600
374
|
// and its exported '__trap' function is not available, in which case we throw
|
|
601
375
|
// a RuntimeError.
|
|
602
376
|
//
|
|
@@ -620,15 +394,16 @@ var Module = (() => {
|
|
|
620
394
|
// include: URIUtils.js
|
|
621
395
|
// Prefix of data URIs emitted by SINGLE_FILE and related options.
|
|
622
396
|
var dataURIPrefix = 'data:application/octet-stream;base64,';
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
397
|
+
/**
|
|
398
|
+
* Indicates whether filename is a base64 data URI.
|
|
399
|
+
* @noinline
|
|
400
|
+
*/
|
|
401
|
+
var isDataURI = (filename) => filename.startsWith(dataURIPrefix);
|
|
402
|
+
/**
|
|
403
|
+
* Indicates whether filename is delivered via file protocol (as opposed to http/https)
|
|
404
|
+
* @noinline
|
|
405
|
+
*/
|
|
406
|
+
var isFileURI = (filename) => filename.startsWith('file://');
|
|
632
407
|
// end include: URIUtils.js
|
|
633
408
|
// include: runtime_exceptions.js
|
|
634
409
|
// end include: runtime_exceptions.js
|
|
@@ -643,57 +418,47 @@ var Module = (() => {
|
|
|
643
418
|
// Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too.
|
|
644
419
|
wasmBinaryFile = new URL('wasm-host.wasm', import.meta.url).href;
|
|
645
420
|
}
|
|
646
|
-
function
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
return new Uint8Array(wasmBinary);
|
|
650
|
-
}
|
|
651
|
-
if (readBinary) {
|
|
652
|
-
return readBinary(file);
|
|
653
|
-
}
|
|
654
|
-
throw "both async and sync fetching of the wasm failed";
|
|
421
|
+
function getBinarySync(file) {
|
|
422
|
+
if (file == wasmBinaryFile && wasmBinary) {
|
|
423
|
+
return new Uint8Array(wasmBinary);
|
|
655
424
|
}
|
|
656
|
-
|
|
657
|
-
|
|
425
|
+
if (readBinary) {
|
|
426
|
+
return readBinary(file);
|
|
658
427
|
}
|
|
428
|
+
throw 'both async and sync fetching of the wasm failed';
|
|
659
429
|
}
|
|
660
430
|
function getBinaryPromise(binaryFile) {
|
|
661
|
-
// If we don't have the binary yet, try to
|
|
431
|
+
// If we don't have the binary yet, try to load it asynchronously.
|
|
662
432
|
// Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
|
|
663
433
|
// See https://github.com/github/fetch/pull/92#issuecomment-140665932
|
|
664
434
|
// Cordova or Electron apps are typically loaded from a file:// url.
|
|
665
435
|
// So use fetch if it is available and the url is not a file, otherwise fall back to XHR.
|
|
666
|
-
if (!wasmBinary
|
|
436
|
+
if (!wasmBinary
|
|
437
|
+
&& (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
|
|
667
438
|
if (typeof fetch == 'function'
|
|
668
439
|
&& !isFileURI(binaryFile)) {
|
|
669
|
-
return fetch(binaryFile, { credentials: 'same-origin' }).then(
|
|
440
|
+
return fetch(binaryFile, { credentials: 'same-origin' }).then((response) => {
|
|
670
441
|
if (!response['ok']) {
|
|
671
|
-
throw
|
|
442
|
+
throw `failed to load wasm binary file at '${binaryFile}'`;
|
|
672
443
|
}
|
|
673
444
|
return response['arrayBuffer']();
|
|
674
|
-
}).catch(
|
|
675
|
-
return getBinary(binaryFile);
|
|
676
|
-
});
|
|
445
|
+
}).catch(() => getBinarySync(binaryFile));
|
|
677
446
|
}
|
|
678
|
-
else {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
});
|
|
684
|
-
}
|
|
447
|
+
else if (readAsync) {
|
|
448
|
+
// fetch is not available or url is file => try XHR (readAsync uses XHR internally)
|
|
449
|
+
return new Promise((resolve, reject) => {
|
|
450
|
+
readAsync(binaryFile, (response) => resolve(new Uint8Array(/** @type{!ArrayBuffer} */ (response))), reject);
|
|
451
|
+
});
|
|
685
452
|
}
|
|
686
453
|
}
|
|
687
|
-
// Otherwise,
|
|
688
|
-
return Promise.resolve().then(
|
|
454
|
+
// Otherwise, getBinarySync should be able to get it synchronously
|
|
455
|
+
return Promise.resolve().then(() => getBinarySync(binaryFile));
|
|
689
456
|
}
|
|
690
457
|
function instantiateArrayBuffer(binaryFile, imports, receiver) {
|
|
691
|
-
return getBinaryPromise(binaryFile).then(
|
|
458
|
+
return getBinaryPromise(binaryFile).then((binary) => {
|
|
692
459
|
return WebAssembly.instantiate(binary, imports);
|
|
693
|
-
}).then(
|
|
694
|
-
|
|
695
|
-
}).then(receiver, function (reason) {
|
|
696
|
-
err('failed to asynchronously prepare wasm: ' + reason);
|
|
460
|
+
}).then(receiver, (reason) => {
|
|
461
|
+
err(`failed to asynchronously prepare wasm: ${reason}`);
|
|
697
462
|
abort(reason);
|
|
698
463
|
});
|
|
699
464
|
}
|
|
@@ -711,7 +476,7 @@ var Module = (() => {
|
|
|
711
476
|
// https://github.com/emscripten-core/emscripten/pull/16917
|
|
712
477
|
!ENVIRONMENT_IS_NODE &&
|
|
713
478
|
typeof fetch == 'function') {
|
|
714
|
-
return fetch(binaryFile, { credentials: 'same-origin' }).then(
|
|
479
|
+
return fetch(binaryFile, { credentials: 'same-origin' }).then((response) => {
|
|
715
480
|
// Suppress closure warning here since the upstream definition for
|
|
716
481
|
// instantiateStreaming only allows Promise<Repsponse> rather than
|
|
717
482
|
// an actual Response.
|
|
@@ -721,37 +486,38 @@ var Module = (() => {
|
|
|
721
486
|
return result.then(callback, function (reason) {
|
|
722
487
|
// We expect the most common failure cause to be a bad MIME type for the binary,
|
|
723
488
|
// in which case falling back to ArrayBuffer instantiation should work.
|
|
724
|
-
err(
|
|
489
|
+
err(`wasm streaming compile failed: ${reason}`);
|
|
725
490
|
err('falling back to ArrayBuffer instantiation');
|
|
726
491
|
return instantiateArrayBuffer(binaryFile, imports, callback);
|
|
727
492
|
});
|
|
728
493
|
});
|
|
729
494
|
}
|
|
730
|
-
|
|
731
|
-
return instantiateArrayBuffer(binaryFile, imports, callback);
|
|
732
|
-
}
|
|
495
|
+
return instantiateArrayBuffer(binaryFile, imports, callback);
|
|
733
496
|
}
|
|
734
|
-
|
|
735
|
-
// Receives the wasm imports, returns the exports.
|
|
736
|
-
function createWasm() {
|
|
497
|
+
function getWasmImports() {
|
|
737
498
|
// prepare imports
|
|
738
|
-
|
|
499
|
+
return {
|
|
739
500
|
'env': wasmImports,
|
|
740
501
|
'wasi_snapshot_preview1': wasmImports,
|
|
741
502
|
};
|
|
503
|
+
}
|
|
504
|
+
// Create the wasm instance.
|
|
505
|
+
// Receives the wasm imports, returns the exports.
|
|
506
|
+
function createWasm() {
|
|
507
|
+
var info = getWasmImports();
|
|
742
508
|
// Load the wasm module and create an instance of using native support in the JS engine.
|
|
743
509
|
// handle a generated wasm instance, receiving its exports and
|
|
744
510
|
// performing other necessary setup
|
|
745
511
|
/** @param {WebAssembly.Module=} module*/
|
|
746
512
|
function receiveInstance(instance, module) {
|
|
747
|
-
|
|
748
|
-
Module['
|
|
749
|
-
wasmMemory =
|
|
513
|
+
wasmExports = instance.exports;
|
|
514
|
+
Module['wasmExports'] = wasmExports;
|
|
515
|
+
wasmMemory = wasmExports['memory'];
|
|
750
516
|
updateMemoryViews();
|
|
751
|
-
wasmTable =
|
|
752
|
-
addOnInit(
|
|
517
|
+
wasmTable = wasmExports['__indirect_function_table'];
|
|
518
|
+
addOnInit(wasmExports['__wasm_call_ctors']);
|
|
753
519
|
removeRunDependency('wasm-instantiate');
|
|
754
|
-
return
|
|
520
|
+
return wasmExports;
|
|
755
521
|
}
|
|
756
522
|
// wait for the pthread pool (if any)
|
|
757
523
|
addRunDependency('wasm-instantiate');
|
|
@@ -760,19 +526,21 @@ var Module = (() => {
|
|
|
760
526
|
// 'result' is a ResultObject object which has both the module and instance.
|
|
761
527
|
// receiveInstance() will swap in the exports (to Module.asm) so they can be called
|
|
762
528
|
// 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.
|
|
763
|
-
// When the regression is fixed, can restore the above
|
|
529
|
+
// When the regression is fixed, can restore the above PTHREADS-enabled path.
|
|
764
530
|
receiveInstance(result['instance']);
|
|
765
531
|
}
|
|
766
532
|
// User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
|
|
767
|
-
// to manually instantiate the Wasm module themselves. This allows pages to
|
|
768
|
-
// to any other async startup actions they are
|
|
769
|
-
//
|
|
533
|
+
// to manually instantiate the Wasm module themselves. This allows pages to
|
|
534
|
+
// run the instantiation parallel to any other async startup actions they are
|
|
535
|
+
// performing.
|
|
536
|
+
// Also pthreads and wasm workers initialize the wasm instance through this
|
|
537
|
+
// path.
|
|
770
538
|
if (Module['instantiateWasm']) {
|
|
771
539
|
try {
|
|
772
540
|
return Module['instantiateWasm'](info, receiveInstance);
|
|
773
541
|
}
|
|
774
542
|
catch (e) {
|
|
775
|
-
err(
|
|
543
|
+
err(`Module.instantiateWasm callback failed with error: ${e}`);
|
|
776
544
|
// If instantiation fails, reject the module ready promise.
|
|
777
545
|
readyPromiseReject(e);
|
|
778
546
|
}
|
|
@@ -791,15 +559,15 @@ var Module = (() => {
|
|
|
791
559
|
/** @constructor */
|
|
792
560
|
function ExitStatus(status) {
|
|
793
561
|
this.name = 'ExitStatus';
|
|
794
|
-
this.message =
|
|
562
|
+
this.message = `Program terminated with exit(${status})`;
|
|
795
563
|
this.status = status;
|
|
796
564
|
}
|
|
797
|
-
|
|
565
|
+
var callRuntimeCallbacks = (callbacks) => {
|
|
798
566
|
while (callbacks.length > 0) {
|
|
799
567
|
// Pass the module as the first argument.
|
|
800
568
|
callbacks.shift()(Module);
|
|
801
569
|
}
|
|
802
|
-
}
|
|
570
|
+
};
|
|
803
571
|
/**
|
|
804
572
|
* @param {number} ptr
|
|
805
573
|
* @param {string} type
|
|
@@ -808,17 +576,18 @@ var Module = (() => {
|
|
|
808
576
|
if (type.endsWith('*'))
|
|
809
577
|
type = '*';
|
|
810
578
|
switch (type) {
|
|
811
|
-
case 'i1': return HEAP8[
|
|
812
|
-
case 'i8': return HEAP8[
|
|
579
|
+
case 'i1': return HEAP8[ptr];
|
|
580
|
+
case 'i8': return HEAP8[ptr];
|
|
813
581
|
case 'i16': return HEAP16[((ptr) >> 1)];
|
|
814
582
|
case 'i32': return HEAP32[((ptr) >> 2)];
|
|
815
|
-
case 'i64':
|
|
583
|
+
case 'i64': abort('to do getValue(i64) use WASM_BIGINT');
|
|
816
584
|
case 'float': return HEAPF32[((ptr) >> 2)];
|
|
817
585
|
case 'double': return HEAPF64[((ptr) >> 3)];
|
|
818
586
|
case '*': return HEAPU32[((ptr) >> 2)];
|
|
819
|
-
default: abort(
|
|
587
|
+
default: abort(`invalid type for getValue: ${type}`);
|
|
820
588
|
}
|
|
821
589
|
}
|
|
590
|
+
var noExitRuntime = Module['noExitRuntime'] || true;
|
|
822
591
|
/**
|
|
823
592
|
* @param {number} ptr
|
|
824
593
|
* @param {number} value
|
|
@@ -829,10 +598,10 @@ var Module = (() => {
|
|
|
829
598
|
type = '*';
|
|
830
599
|
switch (type) {
|
|
831
600
|
case 'i1':
|
|
832
|
-
HEAP8[
|
|
601
|
+
HEAP8[ptr] = value;
|
|
833
602
|
break;
|
|
834
603
|
case 'i8':
|
|
835
|
-
HEAP8[
|
|
604
|
+
HEAP8[ptr] = value;
|
|
836
605
|
break;
|
|
837
606
|
case 'i16':
|
|
838
607
|
HEAP16[((ptr) >> 1)] = value;
|
|
@@ -840,9 +609,7 @@ var Module = (() => {
|
|
|
840
609
|
case 'i32':
|
|
841
610
|
HEAP32[((ptr) >> 2)] = value;
|
|
842
611
|
break;
|
|
843
|
-
case 'i64':
|
|
844
|
-
(tempI64 = [value >>> 0, (tempDouble = value, (+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? ((Math.min((+(Math.floor((tempDouble) / 4294967296.0))), 4294967295.0)) | 0) >>> 0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble))) >>> 0)) / 4294967296.0))))) >>> 0) : 0)], HEAP32[((ptr) >> 2)] = tempI64[0], HEAP32[(((ptr) + (4)) >> 2)] = tempI64[1]);
|
|
845
|
-
break;
|
|
612
|
+
case 'i64': abort('to do setValue(i64) use WASM_BIGINT');
|
|
846
613
|
case 'float':
|
|
847
614
|
HEAPF32[((ptr) >> 2)] = value;
|
|
848
615
|
break;
|
|
@@ -852,38 +619,126 @@ var Module = (() => {
|
|
|
852
619
|
case '*':
|
|
853
620
|
HEAPU32[((ptr) >> 2)] = value;
|
|
854
621
|
break;
|
|
855
|
-
default: abort(
|
|
622
|
+
default: abort(`invalid type for setValue: ${type}`);
|
|
856
623
|
}
|
|
857
624
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
625
|
+
var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf8') : undefined;
|
|
626
|
+
/**
|
|
627
|
+
* Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
|
|
628
|
+
* array that contains uint8 values, returns a copy of that string as a
|
|
629
|
+
* Javascript String object.
|
|
630
|
+
* heapOrArray is either a regular array, or a JavaScript typed array view.
|
|
631
|
+
* @param {number} idx
|
|
632
|
+
* @param {number=} maxBytesToRead
|
|
633
|
+
* @return {string}
|
|
634
|
+
*/
|
|
635
|
+
var UTF8ArrayToString = (heapOrArray, idx, maxBytesToRead) => {
|
|
636
|
+
var endIdx = idx + maxBytesToRead;
|
|
637
|
+
var endPtr = idx;
|
|
638
|
+
// TextDecoder needs to know the byte length in advance, it doesn't stop on
|
|
639
|
+
// null terminator by itself. Also, use the length info to avoid running tiny
|
|
640
|
+
// strings through TextDecoder, since .subarray() allocates garbage.
|
|
641
|
+
// (As a tiny code save trick, compare endPtr against endIdx using a negation,
|
|
642
|
+
// so that undefined means Infinity)
|
|
643
|
+
while (heapOrArray[endPtr] && !(endPtr >= endIdx))
|
|
644
|
+
++endPtr;
|
|
645
|
+
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
646
|
+
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
|
|
866
647
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
648
|
+
var str = '';
|
|
649
|
+
// If building with TextDecoder, we have already computed the string length
|
|
650
|
+
// above, so test loop end condition against that
|
|
651
|
+
while (idx < endPtr) {
|
|
652
|
+
// For UTF8 byte structure, see:
|
|
653
|
+
// http://en.wikipedia.org/wiki/UTF-8#Description
|
|
654
|
+
// https://www.ietf.org/rfc/rfc2279.txt
|
|
655
|
+
// https://tools.ietf.org/html/rfc3629
|
|
656
|
+
var u0 = heapOrArray[idx++];
|
|
657
|
+
if (!(u0 & 0x80)) {
|
|
658
|
+
str += String.fromCharCode(u0);
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
var u1 = heapOrArray[idx++] & 63;
|
|
662
|
+
if ((u0 & 0xE0) == 0xC0) {
|
|
663
|
+
str += String.fromCharCode(((u0 & 31) << 6) | u1);
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
var u2 = heapOrArray[idx++] & 63;
|
|
667
|
+
if ((u0 & 0xF0) == 0xE0) {
|
|
668
|
+
u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
|
|
672
|
+
}
|
|
673
|
+
if (u0 < 0x10000) {
|
|
674
|
+
str += String.fromCharCode(u0);
|
|
675
|
+
}
|
|
676
|
+
else {
|
|
677
|
+
var ch = u0 - 0x10000;
|
|
678
|
+
str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
|
|
679
|
+
}
|
|
871
680
|
}
|
|
872
|
-
return
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
681
|
+
return str;
|
|
682
|
+
};
|
|
683
|
+
/**
|
|
684
|
+
* Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
|
|
685
|
+
* emscripten HEAP, returns a copy of that string as a Javascript String object.
|
|
686
|
+
*
|
|
687
|
+
* @param {number} ptr
|
|
688
|
+
* @param {number=} maxBytesToRead - An optional length that specifies the
|
|
689
|
+
* maximum number of bytes to read. You can omit this parameter to scan the
|
|
690
|
+
* string until the first 0 byte. If maxBytesToRead is passed, and the string
|
|
691
|
+
* at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
|
|
692
|
+
* string will cut short at that byte index (i.e. maxBytesToRead will not
|
|
693
|
+
* produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
|
|
694
|
+
* frequent uses of UTF8ToString() with and without maxBytesToRead may throw
|
|
695
|
+
* JS JIT optimizations off, so it is worth to consider consistently using one
|
|
696
|
+
* @return {string}
|
|
697
|
+
*/
|
|
698
|
+
var UTF8ToString = (ptr, maxBytesToRead) => {
|
|
699
|
+
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
|
|
700
|
+
};
|
|
701
|
+
var ___assert_fail = (condition, filename, line, func) => {
|
|
702
|
+
abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
|
|
703
|
+
};
|
|
704
|
+
var createNamedFunction = (name, body) => Object.defineProperty(body, 'name', {
|
|
705
|
+
value: name
|
|
706
|
+
});
|
|
707
|
+
var emval_freelist = [];
|
|
708
|
+
var emval_handles = [];
|
|
709
|
+
var BindingError;
|
|
710
|
+
var throwBindingError = (message) => { throw new BindingError(message); };
|
|
711
|
+
var count_emval_handles = () => {
|
|
712
|
+
return emval_handles.length / 2 - 5 - emval_freelist.length;
|
|
713
|
+
};
|
|
714
|
+
var init_emval = () => {
|
|
715
|
+
// reserve 0 and some special values. These never get de-allocated.
|
|
716
|
+
emval_handles.push(0, 1, undefined, 1, null, 1, true, 1, false, 1);
|
|
717
|
+
Module['count_emval_handles'] = count_emval_handles;
|
|
718
|
+
};
|
|
719
|
+
var Emval = {
|
|
720
|
+
toValue: (handle) => {
|
|
721
|
+
if (!handle) {
|
|
722
|
+
throwBindingError('Cannot use deleted val. handle = ' + handle);
|
|
881
723
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
724
|
+
return emval_handles[handle];
|
|
725
|
+
},
|
|
726
|
+
toHandle: (value) => {
|
|
727
|
+
switch (value) {
|
|
728
|
+
case undefined: return 2;
|
|
729
|
+
case null: return 4;
|
|
730
|
+
case true: return 6;
|
|
731
|
+
case false: return 8;
|
|
732
|
+
default: {
|
|
733
|
+
const handle = emval_freelist.pop() || emval_handles.length;
|
|
734
|
+
emval_handles[handle] = value;
|
|
735
|
+
emval_handles[handle + 1] = 1;
|
|
736
|
+
return handle;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
},
|
|
740
|
+
};
|
|
741
|
+
var extendError = (baseErrorType, errorName) => {
|
|
887
742
|
var errorClass = createNamedFunction(errorName, function (message) {
|
|
888
743
|
this.name = errorName;
|
|
889
744
|
this.message = message;
|
|
@@ -900,77 +755,30 @@ var Module = (() => {
|
|
|
900
755
|
return this.name;
|
|
901
756
|
}
|
|
902
757
|
else {
|
|
903
|
-
return this.name
|
|
758
|
+
return `${this.name}: ${this.message}`;
|
|
904
759
|
}
|
|
905
760
|
};
|
|
906
761
|
return errorClass;
|
|
907
|
-
}
|
|
908
|
-
var
|
|
909
|
-
|
|
910
|
-
throw new BindingError(message);
|
|
911
|
-
}
|
|
912
|
-
function count_emval_handles() {
|
|
913
|
-
var count = 0;
|
|
914
|
-
for (var i = 5; i < emval_handle_array.length; ++i) {
|
|
915
|
-
if (emval_handle_array[i] !== undefined) {
|
|
916
|
-
++count;
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
return count;
|
|
920
|
-
}
|
|
921
|
-
function get_first_emval() {
|
|
922
|
-
for (var i = 5; i < emval_handle_array.length; ++i) {
|
|
923
|
-
if (emval_handle_array[i] !== undefined) {
|
|
924
|
-
return emval_handle_array[i];
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
return null;
|
|
928
|
-
}
|
|
929
|
-
function init_emval() {
|
|
930
|
-
Module['count_emval_handles'] = count_emval_handles;
|
|
931
|
-
Module['get_first_emval'] = get_first_emval;
|
|
932
|
-
}
|
|
933
|
-
var Emval = { toValue: (handle) => {
|
|
934
|
-
if (!handle) {
|
|
935
|
-
throwBindingError('Cannot use deleted val. handle = ' + handle);
|
|
936
|
-
}
|
|
937
|
-
return emval_handle_array[handle].value;
|
|
938
|
-
}, toHandle: (value) => {
|
|
939
|
-
switch (value) {
|
|
940
|
-
case undefined: return 1;
|
|
941
|
-
case null: return 2;
|
|
942
|
-
case true: return 3;
|
|
943
|
-
case false: return 4;
|
|
944
|
-
default: {
|
|
945
|
-
var handle = emval_free_list.length ?
|
|
946
|
-
emval_free_list.pop() :
|
|
947
|
-
emval_handle_array.length;
|
|
948
|
-
emval_handle_array[handle] = { refcount: 1, value: value };
|
|
949
|
-
return handle;
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
} };
|
|
953
|
-
var PureVirtualError = undefined;
|
|
954
|
-
function embind_init_charCodes() {
|
|
762
|
+
};
|
|
763
|
+
var PureVirtualError;
|
|
764
|
+
var embind_init_charCodes = () => {
|
|
955
765
|
var codes = new Array(256);
|
|
956
766
|
for (var i = 0; i < 256; ++i) {
|
|
957
767
|
codes[i] = String.fromCharCode(i);
|
|
958
768
|
}
|
|
959
769
|
embind_charCodes = codes;
|
|
960
|
-
}
|
|
961
|
-
var embind_charCodes
|
|
962
|
-
|
|
770
|
+
};
|
|
771
|
+
var embind_charCodes;
|
|
772
|
+
var readLatin1String = (ptr) => {
|
|
963
773
|
var ret = "";
|
|
964
774
|
var c = ptr;
|
|
965
775
|
while (HEAPU8[c]) {
|
|
966
776
|
ret += embind_charCodes[HEAPU8[c++]];
|
|
967
777
|
}
|
|
968
778
|
return ret;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
}
|
|
973
|
-
function getLiveInheritedInstances() {
|
|
779
|
+
};
|
|
780
|
+
var getInheritedInstanceCount = () => Object.keys(registeredInstances).length;
|
|
781
|
+
var getLiveInheritedInstances = () => {
|
|
974
782
|
var rv = [];
|
|
975
783
|
for (var k in registeredInstances) {
|
|
976
784
|
if (registeredInstances.hasOwnProperty(k)) {
|
|
@@ -978,30 +786,30 @@ var Module = (() => {
|
|
|
978
786
|
}
|
|
979
787
|
}
|
|
980
788
|
return rv;
|
|
981
|
-
}
|
|
789
|
+
};
|
|
982
790
|
var deletionQueue = [];
|
|
983
|
-
|
|
791
|
+
var flushPendingDeletes = () => {
|
|
984
792
|
while (deletionQueue.length) {
|
|
985
793
|
var obj = deletionQueue.pop();
|
|
986
794
|
obj.$$.deleteScheduled = false;
|
|
987
795
|
obj['delete']();
|
|
988
796
|
}
|
|
989
|
-
}
|
|
990
|
-
var delayFunction
|
|
991
|
-
|
|
797
|
+
};
|
|
798
|
+
var delayFunction;
|
|
799
|
+
var setDelayFunction = (fn) => {
|
|
992
800
|
delayFunction = fn;
|
|
993
801
|
if (deletionQueue.length && delayFunction) {
|
|
994
802
|
delayFunction(flushPendingDeletes);
|
|
995
803
|
}
|
|
996
|
-
}
|
|
997
|
-
|
|
804
|
+
};
|
|
805
|
+
var init_embind = () => {
|
|
998
806
|
Module['getInheritedInstanceCount'] = getInheritedInstanceCount;
|
|
999
807
|
Module['getLiveInheritedInstances'] = getLiveInheritedInstances;
|
|
1000
808
|
Module['flushPendingDeletes'] = flushPendingDeletes;
|
|
1001
809
|
Module['setDelayFunction'] = setDelayFunction;
|
|
1002
|
-
}
|
|
810
|
+
};
|
|
1003
811
|
var registeredInstances = {};
|
|
1004
|
-
|
|
812
|
+
var getBasestPointer = (class_, ptr) => {
|
|
1005
813
|
if (ptr === undefined) {
|
|
1006
814
|
throwBindingError('ptr should not be undefined');
|
|
1007
815
|
}
|
|
@@ -1010,57 +818,57 @@ var Module = (() => {
|
|
|
1010
818
|
class_ = class_.baseClass;
|
|
1011
819
|
}
|
|
1012
820
|
return ptr;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
821
|
+
};
|
|
822
|
+
var registerInheritedInstance = (class_, ptr, instance) => {
|
|
1015
823
|
ptr = getBasestPointer(class_, ptr);
|
|
1016
824
|
if (registeredInstances.hasOwnProperty(ptr)) {
|
|
1017
|
-
throwBindingError(
|
|
825
|
+
throwBindingError(`Tried to register registered instance: ${ptr}`);
|
|
1018
826
|
}
|
|
1019
827
|
else {
|
|
1020
828
|
registeredInstances[ptr] = instance;
|
|
1021
829
|
}
|
|
1022
|
-
}
|
|
830
|
+
};
|
|
1023
831
|
var registeredTypes = {};
|
|
1024
|
-
|
|
832
|
+
var getTypeName = (type) => {
|
|
1025
833
|
var ptr = ___getTypeName(type);
|
|
1026
834
|
var rv = readLatin1String(ptr);
|
|
1027
835
|
_free(ptr);
|
|
1028
836
|
return rv;
|
|
1029
|
-
}
|
|
1030
|
-
|
|
837
|
+
};
|
|
838
|
+
var requireRegisteredType = (rawType, humanName) => {
|
|
1031
839
|
var impl = registeredTypes[rawType];
|
|
1032
840
|
if (undefined === impl) {
|
|
1033
|
-
throwBindingError(humanName
|
|
841
|
+
throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`);
|
|
1034
842
|
}
|
|
1035
843
|
return impl;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
844
|
+
};
|
|
845
|
+
var unregisterInheritedInstance = (class_, ptr) => {
|
|
1038
846
|
ptr = getBasestPointer(class_, ptr);
|
|
1039
847
|
if (registeredInstances.hasOwnProperty(ptr)) {
|
|
1040
848
|
delete registeredInstances[ptr];
|
|
1041
849
|
}
|
|
1042
850
|
else {
|
|
1043
|
-
throwBindingError(
|
|
851
|
+
throwBindingError(`Tried to unregister unregistered instance: ${ptr}`);
|
|
1044
852
|
}
|
|
1045
|
-
}
|
|
1046
|
-
|
|
853
|
+
};
|
|
854
|
+
var detachFinalizer = (handle) => { };
|
|
1047
855
|
var finalizationRegistry = false;
|
|
1048
|
-
|
|
856
|
+
var runDestructor = ($$) => {
|
|
1049
857
|
if ($$.smartPtr) {
|
|
1050
858
|
$$.smartPtrType.rawDestructor($$.smartPtr);
|
|
1051
859
|
}
|
|
1052
860
|
else {
|
|
1053
861
|
$$.ptrType.registeredClass.rawDestructor($$.ptr);
|
|
1054
862
|
}
|
|
1055
|
-
}
|
|
1056
|
-
|
|
863
|
+
};
|
|
864
|
+
var releaseClassHandle = ($$) => {
|
|
1057
865
|
$$.count.value -= 1;
|
|
1058
866
|
var toDelete = 0 === $$.count.value;
|
|
1059
867
|
if (toDelete) {
|
|
1060
868
|
runDestructor($$);
|
|
1061
869
|
}
|
|
1062
|
-
}
|
|
1063
|
-
|
|
870
|
+
};
|
|
871
|
+
var downcastPointer = (ptr, ptrClass, desiredClass) => {
|
|
1064
872
|
if (ptrClass === desiredClass) {
|
|
1065
873
|
return ptr;
|
|
1066
874
|
}
|
|
@@ -1072,17 +880,15 @@ var Module = (() => {
|
|
|
1072
880
|
return null;
|
|
1073
881
|
}
|
|
1074
882
|
return desiredClass.downcast(rv);
|
|
1075
|
-
}
|
|
883
|
+
};
|
|
1076
884
|
var registeredPointers = {};
|
|
1077
|
-
|
|
885
|
+
var getInheritedInstance = (class_, ptr) => {
|
|
1078
886
|
ptr = getBasestPointer(class_, ptr);
|
|
1079
887
|
return registeredInstances[ptr];
|
|
1080
|
-
}
|
|
1081
|
-
var InternalError
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
}
|
|
1085
|
-
function makeClassHandle(prototype, record) {
|
|
888
|
+
};
|
|
889
|
+
var InternalError;
|
|
890
|
+
var throwInternalError = (message) => { throw new InternalError(message); };
|
|
891
|
+
var makeClassHandle = (prototype, record) => {
|
|
1086
892
|
if (!record.ptrType || !record.ptr) {
|
|
1087
893
|
throwInternalError('makeClassHandle requires ptr and ptrType');
|
|
1088
894
|
}
|
|
@@ -1095,9 +901,11 @@ var Module = (() => {
|
|
|
1095
901
|
return attachFinalizer(Object.create(prototype, {
|
|
1096
902
|
$$: {
|
|
1097
903
|
value: record,
|
|
904
|
+
writable: true,
|
|
1098
905
|
},
|
|
1099
906
|
}));
|
|
1100
|
-
}
|
|
907
|
+
};
|
|
908
|
+
/** @suppress {globalThis} */
|
|
1101
909
|
function RegisteredPointer_fromWireType(ptr) {
|
|
1102
910
|
// ptr is a raw pointer (or a raw smartpointer)
|
|
1103
911
|
// rawPointer is a maybe-null raw pointer
|
|
@@ -1134,7 +942,7 @@ var Module = (() => {
|
|
|
1134
942
|
else {
|
|
1135
943
|
return makeClassHandle(this.registeredClass.instancePrototype, {
|
|
1136
944
|
ptrType: this,
|
|
1137
|
-
ptr
|
|
945
|
+
ptr,
|
|
1138
946
|
});
|
|
1139
947
|
}
|
|
1140
948
|
}
|
|
@@ -1169,7 +977,7 @@ var Module = (() => {
|
|
|
1169
977
|
});
|
|
1170
978
|
}
|
|
1171
979
|
}
|
|
1172
|
-
|
|
980
|
+
var attachFinalizer = (handle) => {
|
|
1173
981
|
if ('undefined' === typeof FinalizationRegistry) {
|
|
1174
982
|
attachFinalizer = (handle) => handle;
|
|
1175
983
|
return handle;
|
|
@@ -1193,34 +1001,33 @@ var Module = (() => {
|
|
|
1193
1001
|
};
|
|
1194
1002
|
detachFinalizer = (handle) => finalizationRegistry.unregister(handle);
|
|
1195
1003
|
return attachFinalizer(handle);
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1004
|
+
};
|
|
1005
|
+
var __embind_create_inheriting_constructor = (constructorName, wrapperType, properties) => {
|
|
1198
1006
|
constructorName = readLatin1String(constructorName);
|
|
1199
1007
|
wrapperType = requireRegisteredType(wrapperType, 'wrapper');
|
|
1200
1008
|
properties = Emval.toValue(properties);
|
|
1201
|
-
var arraySlice = [].slice;
|
|
1202
1009
|
var registeredClass = wrapperType.registeredClass;
|
|
1203
1010
|
var wrapperPrototype = registeredClass.instancePrototype;
|
|
1204
1011
|
var baseClass = registeredClass.baseClass;
|
|
1205
1012
|
var baseClassPrototype = baseClass.instancePrototype;
|
|
1206
1013
|
var baseConstructor = registeredClass.baseClass.constructor;
|
|
1207
|
-
var ctor = createNamedFunction(constructorName, function () {
|
|
1014
|
+
var ctor = createNamedFunction(constructorName, function (...args) {
|
|
1208
1015
|
registeredClass.baseClass.pureVirtualFunctions.forEach(function (name) {
|
|
1209
1016
|
if (this[name] === baseClassPrototype[name]) {
|
|
1210
|
-
throw new PureVirtualError(
|
|
1017
|
+
throw new PureVirtualError(`Pure virtual function ${name} must be implemented in JavaScript`);
|
|
1211
1018
|
}
|
|
1212
1019
|
}.bind(this));
|
|
1213
1020
|
Object.defineProperty(this, '__parent', {
|
|
1214
1021
|
value: wrapperPrototype
|
|
1215
1022
|
});
|
|
1216
|
-
this["__construct"]
|
|
1023
|
+
this["__construct"](...args);
|
|
1217
1024
|
});
|
|
1218
1025
|
// It's a little nasty that we're modifying the wrapper prototype here.
|
|
1219
|
-
wrapperPrototype["__construct"] = function __construct() {
|
|
1026
|
+
wrapperPrototype["__construct"] = function __construct(...args) {
|
|
1220
1027
|
if (this === wrapperPrototype) {
|
|
1221
1028
|
throwBindingError("Pass correct 'this' to __construct");
|
|
1222
1029
|
}
|
|
1223
|
-
var inner = baseConstructor["implement"]
|
|
1030
|
+
var inner = baseConstructor["implement"](this, ...args);
|
|
1224
1031
|
detachFinalizer(inner);
|
|
1225
1032
|
var $$ = inner.$$;
|
|
1226
1033
|
inner["notifyOnDestruction"]();
|
|
@@ -1239,25 +1046,24 @@ var Module = (() => {
|
|
|
1239
1046
|
unregisterInheritedInstance(registeredClass, this.$$.ptr);
|
|
1240
1047
|
};
|
|
1241
1048
|
ctor.prototype = Object.create(wrapperPrototype);
|
|
1242
|
-
|
|
1243
|
-
ctor.prototype[p] = properties[p];
|
|
1244
|
-
}
|
|
1049
|
+
Object.assign(ctor.prototype, properties);
|
|
1245
1050
|
return Emval.toHandle(ctor);
|
|
1246
|
-
}
|
|
1051
|
+
};
|
|
1247
1052
|
var structRegistrations = {};
|
|
1248
|
-
|
|
1053
|
+
var runDestructors = (destructors) => {
|
|
1249
1054
|
while (destructors.length) {
|
|
1250
1055
|
var ptr = destructors.pop();
|
|
1251
1056
|
var del = destructors.pop();
|
|
1252
1057
|
del(ptr);
|
|
1253
1058
|
}
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
|
|
1059
|
+
};
|
|
1060
|
+
/** @suppress {globalThis} */
|
|
1061
|
+
function readPointer(pointer) {
|
|
1062
|
+
return this['fromWireType'](HEAPU32[((pointer) >> 2)]);
|
|
1257
1063
|
}
|
|
1258
1064
|
var awaitingDependencies = {};
|
|
1259
1065
|
var typeDependencies = {};
|
|
1260
|
-
|
|
1066
|
+
var whenDependentTypesAreResolved = (myTypes, dependentTypes, getTypeConverters) => {
|
|
1261
1067
|
myTypes.forEach(function (type) {
|
|
1262
1068
|
typeDependencies[type] = dependentTypes;
|
|
1263
1069
|
});
|
|
@@ -1294,8 +1100,8 @@ var Module = (() => {
|
|
|
1294
1100
|
if (0 === unregisteredTypes.length) {
|
|
1295
1101
|
onComplete(typeConverters);
|
|
1296
1102
|
}
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1103
|
+
};
|
|
1104
|
+
var __embind_finalize_value_object = (structType) => {
|
|
1299
1105
|
var reg = structRegistrations[structType];
|
|
1300
1106
|
delete structRegistrations[structType];
|
|
1301
1107
|
var rawConstructor = reg.rawConstructor;
|
|
@@ -1314,9 +1120,7 @@ var Module = (() => {
|
|
|
1314
1120
|
var setter = field.setter;
|
|
1315
1121
|
var setterContext = field.setterContext;
|
|
1316
1122
|
fields[fieldName] = {
|
|
1317
|
-
read: (ptr) =>
|
|
1318
|
-
return getterReturnType['fromWireType'](getter(getterContext, ptr));
|
|
1319
|
-
},
|
|
1123
|
+
read: (ptr) => getterReturnType['fromWireType'](getter(getterContext, ptr)),
|
|
1320
1124
|
write: (ptr, o) => {
|
|
1321
1125
|
var destructors = [];
|
|
1322
1126
|
setter(setterContext, ptr, setterArgumentType['toWireType'](destructors, o));
|
|
@@ -1326,7 +1130,7 @@ var Module = (() => {
|
|
|
1326
1130
|
});
|
|
1327
1131
|
return [{
|
|
1328
1132
|
name: reg.name,
|
|
1329
|
-
'fromWireType':
|
|
1133
|
+
'fromWireType': (ptr) => {
|
|
1330
1134
|
var rv = {};
|
|
1331
1135
|
for (var i in fields) {
|
|
1332
1136
|
rv[i] = fields[i].read(ptr);
|
|
@@ -1334,12 +1138,12 @@ var Module = (() => {
|
|
|
1334
1138
|
rawDestructor(ptr);
|
|
1335
1139
|
return rv;
|
|
1336
1140
|
},
|
|
1337
|
-
'toWireType':
|
|
1141
|
+
'toWireType': (destructors, o) => {
|
|
1338
1142
|
// todo: Here we have an opportunity for -O3 level "unsafe" optimizations:
|
|
1339
1143
|
// assume all fields are present without checking.
|
|
1340
1144
|
for (var fieldName in fields) {
|
|
1341
1145
|
if (!(fieldName in o)) {
|
|
1342
|
-
throw new TypeError(
|
|
1146
|
+
throw new TypeError(`Missing field: "${fieldName}"`);
|
|
1343
1147
|
}
|
|
1344
1148
|
}
|
|
1345
1149
|
var ptr = rawConstructor();
|
|
@@ -1351,38 +1155,25 @@ var Module = (() => {
|
|
|
1351
1155
|
}
|
|
1352
1156
|
return ptr;
|
|
1353
1157
|
},
|
|
1354
|
-
'argPackAdvance':
|
|
1355
|
-
'readValueFromPointer':
|
|
1158
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
1159
|
+
'readValueFromPointer': readPointer,
|
|
1356
1160
|
destructorFunction: rawDestructor,
|
|
1357
1161
|
}];
|
|
1358
1162
|
});
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
function getShiftFromSize(size) {
|
|
1362
|
-
switch (size) {
|
|
1363
|
-
case 1: return 0;
|
|
1364
|
-
case 2: return 1;
|
|
1365
|
-
case 4: return 2;
|
|
1366
|
-
case 8: return 3;
|
|
1367
|
-
default:
|
|
1368
|
-
throw new TypeError('Unknown type size: ' + size);
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1163
|
+
};
|
|
1164
|
+
var __embind_register_bigint = (primitiveType, name, size, minRange, maxRange) => { };
|
|
1371
1165
|
/** @param {Object=} options */
|
|
1372
|
-
function
|
|
1373
|
-
if (!('argPackAdvance' in registeredInstance)) {
|
|
1374
|
-
throw new TypeError('registerType registeredInstance requires argPackAdvance');
|
|
1375
|
-
}
|
|
1166
|
+
function sharedRegisterType(rawType, registeredInstance, options = {}) {
|
|
1376
1167
|
var name = registeredInstance.name;
|
|
1377
1168
|
if (!rawType) {
|
|
1378
|
-
throwBindingError(
|
|
1169
|
+
throwBindingError(`type "${name}" must have a positive integer typeid pointer`);
|
|
1379
1170
|
}
|
|
1380
1171
|
if (registeredTypes.hasOwnProperty(rawType)) {
|
|
1381
1172
|
if (options.ignoreDuplicateRegistrations) {
|
|
1382
1173
|
return;
|
|
1383
1174
|
}
|
|
1384
1175
|
else {
|
|
1385
|
-
throwBindingError(
|
|
1176
|
+
throwBindingError(`Cannot register type '${name}' twice`);
|
|
1386
1177
|
}
|
|
1387
1178
|
}
|
|
1388
1179
|
registeredTypes[rawType] = registeredInstance;
|
|
@@ -1393,11 +1184,19 @@ var Module = (() => {
|
|
|
1393
1184
|
callbacks.forEach((cb) => cb());
|
|
1394
1185
|
}
|
|
1395
1186
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1187
|
+
/** @param {Object=} options */
|
|
1188
|
+
function registerType(rawType, registeredInstance, options = {}) {
|
|
1189
|
+
if (!('argPackAdvance' in registeredInstance)) {
|
|
1190
|
+
throw new TypeError('registerType registeredInstance requires argPackAdvance');
|
|
1191
|
+
}
|
|
1192
|
+
return sharedRegisterType(rawType, registeredInstance, options);
|
|
1193
|
+
}
|
|
1194
|
+
var GenericWireTypeSize = 8;
|
|
1195
|
+
/** @suppress {globalThis} */
|
|
1196
|
+
var __embind_register_bool = (rawType, name, trueValue, falseValue) => {
|
|
1398
1197
|
name = readLatin1String(name);
|
|
1399
1198
|
registerType(rawType, {
|
|
1400
|
-
name
|
|
1199
|
+
name,
|
|
1401
1200
|
'fromWireType': function (wt) {
|
|
1402
1201
|
// ambiguous emscripten ABI: sometimes return values are
|
|
1403
1202
|
// true or false, and sometimes integers (0 or 1)
|
|
@@ -1406,49 +1205,14 @@ var Module = (() => {
|
|
|
1406
1205
|
'toWireType': function (destructors, o) {
|
|
1407
1206
|
return o ? trueValue : falseValue;
|
|
1408
1207
|
},
|
|
1409
|
-
'argPackAdvance':
|
|
1208
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
1410
1209
|
'readValueFromPointer': function (pointer) {
|
|
1411
|
-
|
|
1412
|
-
var heap;
|
|
1413
|
-
if (size === 1) {
|
|
1414
|
-
heap = HEAP8;
|
|
1415
|
-
}
|
|
1416
|
-
else if (size === 2) {
|
|
1417
|
-
heap = HEAP16;
|
|
1418
|
-
}
|
|
1419
|
-
else if (size === 4) {
|
|
1420
|
-
heap = HEAP32;
|
|
1421
|
-
}
|
|
1422
|
-
else {
|
|
1423
|
-
throw new TypeError("Unknown boolean type size: " + name);
|
|
1424
|
-
}
|
|
1425
|
-
return this['fromWireType'](heap[pointer >> shift]);
|
|
1210
|
+
return this['fromWireType'](HEAPU8[pointer]);
|
|
1426
1211
|
},
|
|
1427
1212
|
destructorFunction: null, // This type does not need a destructor
|
|
1428
1213
|
});
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
if (!(this instanceof ClassHandle)) {
|
|
1432
|
-
return false;
|
|
1433
|
-
}
|
|
1434
|
-
if (!(other instanceof ClassHandle)) {
|
|
1435
|
-
return false;
|
|
1436
|
-
}
|
|
1437
|
-
var leftClass = this.$$.ptrType.registeredClass;
|
|
1438
|
-
var left = this.$$.ptr;
|
|
1439
|
-
var rightClass = other.$$.ptrType.registeredClass;
|
|
1440
|
-
var right = other.$$.ptr;
|
|
1441
|
-
while (leftClass.baseClass) {
|
|
1442
|
-
left = leftClass.upcast(left);
|
|
1443
|
-
leftClass = leftClass.baseClass;
|
|
1444
|
-
}
|
|
1445
|
-
while (rightClass.baseClass) {
|
|
1446
|
-
right = rightClass.upcast(right);
|
|
1447
|
-
rightClass = rightClass.baseClass;
|
|
1448
|
-
}
|
|
1449
|
-
return leftClass === rightClass && left === right;
|
|
1450
|
-
}
|
|
1451
|
-
function shallowCopyInternalPointer(o) {
|
|
1214
|
+
};
|
|
1215
|
+
var shallowCopyInternalPointer = (o) => {
|
|
1452
1216
|
return {
|
|
1453
1217
|
count: o.count,
|
|
1454
1218
|
deleteScheduled: o.deleteScheduled,
|
|
@@ -1458,99 +1222,119 @@ var Module = (() => {
|
|
|
1458
1222
|
smartPtr: o.smartPtr,
|
|
1459
1223
|
smartPtrType: o.smartPtrType,
|
|
1460
1224
|
};
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1225
|
+
};
|
|
1226
|
+
var throwInstanceAlreadyDeleted = (obj) => {
|
|
1463
1227
|
function getInstanceTypeName(handle) {
|
|
1464
1228
|
return handle.$$.ptrType.registeredClass.name;
|
|
1465
1229
|
}
|
|
1466
1230
|
throwBindingError(getInstanceTypeName(obj) + ' instance already deleted');
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
this.$$.count.value += 1;
|
|
1474
|
-
return this;
|
|
1475
|
-
}
|
|
1476
|
-
else {
|
|
1477
|
-
var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), {
|
|
1478
|
-
$$: {
|
|
1479
|
-
value: shallowCopyInternalPointer(this.$$),
|
|
1231
|
+
};
|
|
1232
|
+
var init_ClassHandle = () => {
|
|
1233
|
+
Object.assign(ClassHandle.prototype, {
|
|
1234
|
+
"isAliasOf"(other) {
|
|
1235
|
+
if (!(this instanceof ClassHandle)) {
|
|
1236
|
+
return false;
|
|
1480
1237
|
}
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1238
|
+
if (!(other instanceof ClassHandle)) {
|
|
1239
|
+
return false;
|
|
1240
|
+
}
|
|
1241
|
+
var leftClass = this.$$.ptrType.registeredClass;
|
|
1242
|
+
var left = this.$$.ptr;
|
|
1243
|
+
other.$$ = /** @type {Object} */ (other.$$);
|
|
1244
|
+
var rightClass = other.$$.ptrType.registeredClass;
|
|
1245
|
+
var right = other.$$.ptr;
|
|
1246
|
+
while (leftClass.baseClass) {
|
|
1247
|
+
left = leftClass.upcast(left);
|
|
1248
|
+
leftClass = leftClass.baseClass;
|
|
1249
|
+
}
|
|
1250
|
+
while (rightClass.baseClass) {
|
|
1251
|
+
right = rightClass.upcast(right);
|
|
1252
|
+
rightClass = rightClass.baseClass;
|
|
1253
|
+
}
|
|
1254
|
+
return leftClass === rightClass && left === right;
|
|
1255
|
+
},
|
|
1256
|
+
"clone"() {
|
|
1257
|
+
if (!this.$$.ptr) {
|
|
1258
|
+
throwInstanceAlreadyDeleted(this);
|
|
1259
|
+
}
|
|
1260
|
+
if (this.$$.preservePointerOnDelete) {
|
|
1261
|
+
this.$$.count.value += 1;
|
|
1262
|
+
return this;
|
|
1263
|
+
}
|
|
1264
|
+
else {
|
|
1265
|
+
var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), {
|
|
1266
|
+
$$: {
|
|
1267
|
+
value: shallowCopyInternalPointer(this.$$),
|
|
1268
|
+
}
|
|
1269
|
+
}));
|
|
1270
|
+
clone.$$.count.value += 1;
|
|
1271
|
+
clone.$$.deleteScheduled = false;
|
|
1272
|
+
return clone;
|
|
1273
|
+
}
|
|
1274
|
+
},
|
|
1275
|
+
"delete"() {
|
|
1276
|
+
if (!this.$$.ptr) {
|
|
1277
|
+
throwInstanceAlreadyDeleted(this);
|
|
1278
|
+
}
|
|
1279
|
+
if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
|
|
1280
|
+
throwBindingError('Object already scheduled for deletion');
|
|
1281
|
+
}
|
|
1282
|
+
detachFinalizer(this);
|
|
1283
|
+
releaseClassHandle(this.$$);
|
|
1284
|
+
if (!this.$$.preservePointerOnDelete) {
|
|
1285
|
+
this.$$.smartPtr = undefined;
|
|
1286
|
+
this.$$.ptr = undefined;
|
|
1287
|
+
}
|
|
1288
|
+
},
|
|
1289
|
+
"isDeleted"() {
|
|
1290
|
+
return !this.$$.ptr;
|
|
1291
|
+
},
|
|
1292
|
+
"deleteLater"() {
|
|
1293
|
+
if (!this.$$.ptr) {
|
|
1294
|
+
throwInstanceAlreadyDeleted(this);
|
|
1295
|
+
}
|
|
1296
|
+
if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
|
|
1297
|
+
throwBindingError('Object already scheduled for deletion');
|
|
1298
|
+
}
|
|
1299
|
+
deletionQueue.push(this);
|
|
1300
|
+
if (deletionQueue.length === 1 && delayFunction) {
|
|
1301
|
+
delayFunction(flushPendingDeletes);
|
|
1302
|
+
}
|
|
1303
|
+
this.$$.deleteScheduled = true;
|
|
1304
|
+
return this;
|
|
1305
|
+
},
|
|
1306
|
+
});
|
|
1307
|
+
};
|
|
1308
|
+
/** @constructor */
|
|
1525
1309
|
function ClassHandle() {
|
|
1526
1310
|
}
|
|
1527
|
-
|
|
1311
|
+
var ensureOverloadTable = (proto, methodName, humanName) => {
|
|
1528
1312
|
if (undefined === proto[methodName].overloadTable) {
|
|
1529
1313
|
var prevFunc = proto[methodName];
|
|
1530
1314
|
// Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
|
|
1531
|
-
proto[methodName] = function () {
|
|
1315
|
+
proto[methodName] = function (...args) {
|
|
1532
1316
|
// TODO This check can be removed in -O3 level "unsafe" optimizations.
|
|
1533
|
-
if (!proto[methodName].overloadTable.hasOwnProperty(
|
|
1534
|
-
throwBindingError(
|
|
1317
|
+
if (!proto[methodName].overloadTable.hasOwnProperty(args.length)) {
|
|
1318
|
+
throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`);
|
|
1535
1319
|
}
|
|
1536
|
-
return proto[methodName].overloadTable[
|
|
1320
|
+
return proto[methodName].overloadTable[args.length].apply(this, args);
|
|
1537
1321
|
};
|
|
1538
1322
|
// Move the previous function into the overload table.
|
|
1539
1323
|
proto[methodName].overloadTable = [];
|
|
1540
1324
|
proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
|
|
1541
1325
|
}
|
|
1542
|
-
}
|
|
1326
|
+
};
|
|
1543
1327
|
/** @param {number=} numArguments */
|
|
1544
|
-
|
|
1328
|
+
var exposePublicSymbol = (name, value, numArguments) => {
|
|
1545
1329
|
if (Module.hasOwnProperty(name)) {
|
|
1546
1330
|
if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
|
|
1547
|
-
throwBindingError(
|
|
1331
|
+
throwBindingError(`Cannot register public name '${name}' twice`);
|
|
1548
1332
|
}
|
|
1549
1333
|
// We are exposing a function with the same name as an existing function. Create an overload table and a function selector
|
|
1550
1334
|
// that routes between the two.
|
|
1551
1335
|
ensureOverloadTable(Module, name, name);
|
|
1552
1336
|
if (Module.hasOwnProperty(numArguments)) {
|
|
1553
|
-
throwBindingError(
|
|
1337
|
+
throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`);
|
|
1554
1338
|
}
|
|
1555
1339
|
// Add the new function into the overload table.
|
|
1556
1340
|
Module[name].overloadTable[numArguments] = value;
|
|
@@ -1561,7 +1345,20 @@ var Module = (() => {
|
|
|
1561
1345
|
Module[name].numArguments = numArguments;
|
|
1562
1346
|
}
|
|
1563
1347
|
}
|
|
1564
|
-
}
|
|
1348
|
+
};
|
|
1349
|
+
var char_0 = 48;
|
|
1350
|
+
var char_9 = 57;
|
|
1351
|
+
var makeLegalFunctionName = (name) => {
|
|
1352
|
+
if (undefined === name) {
|
|
1353
|
+
return '_unknown';
|
|
1354
|
+
}
|
|
1355
|
+
name = name.replace(/[^a-zA-Z0-9_]/g, '$');
|
|
1356
|
+
var f = name.charCodeAt(0);
|
|
1357
|
+
if (f >= char_0 && f <= char_9) {
|
|
1358
|
+
return `_${name}`;
|
|
1359
|
+
}
|
|
1360
|
+
return name;
|
|
1361
|
+
};
|
|
1565
1362
|
/** @constructor */
|
|
1566
1363
|
function RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast) {
|
|
1567
1364
|
this.name = name;
|
|
@@ -1574,38 +1371,40 @@ var Module = (() => {
|
|
|
1574
1371
|
this.downcast = downcast;
|
|
1575
1372
|
this.pureVirtualFunctions = [];
|
|
1576
1373
|
}
|
|
1577
|
-
|
|
1374
|
+
var upcastPointer = (ptr, ptrClass, desiredClass) => {
|
|
1578
1375
|
while (ptrClass !== desiredClass) {
|
|
1579
1376
|
if (!ptrClass.upcast) {
|
|
1580
|
-
throwBindingError(
|
|
1377
|
+
throwBindingError(`Expected null or instance of ${desiredClass.name}, got an instance of ${ptrClass.name}`);
|
|
1581
1378
|
}
|
|
1582
1379
|
ptr = ptrClass.upcast(ptr);
|
|
1583
1380
|
ptrClass = ptrClass.baseClass;
|
|
1584
1381
|
}
|
|
1585
1382
|
return ptr;
|
|
1586
|
-
}
|
|
1383
|
+
};
|
|
1384
|
+
/** @suppress {globalThis} */
|
|
1587
1385
|
function constNoSmartPtrRawPointerToWireType(destructors, handle) {
|
|
1588
1386
|
if (handle === null) {
|
|
1589
1387
|
if (this.isReference) {
|
|
1590
|
-
throwBindingError(
|
|
1388
|
+
throwBindingError(`null is not a valid ${this.name}`);
|
|
1591
1389
|
}
|
|
1592
1390
|
return 0;
|
|
1593
1391
|
}
|
|
1594
1392
|
if (!handle.$$) {
|
|
1595
|
-
throwBindingError(
|
|
1393
|
+
throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`);
|
|
1596
1394
|
}
|
|
1597
1395
|
if (!handle.$$.ptr) {
|
|
1598
|
-
throwBindingError(
|
|
1396
|
+
throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`);
|
|
1599
1397
|
}
|
|
1600
1398
|
var handleClass = handle.$$.ptrType.registeredClass;
|
|
1601
1399
|
var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
|
1602
1400
|
return ptr;
|
|
1603
1401
|
}
|
|
1402
|
+
/** @suppress {globalThis} */
|
|
1604
1403
|
function genericPointerToWireType(destructors, handle) {
|
|
1605
1404
|
var ptr;
|
|
1606
1405
|
if (handle === null) {
|
|
1607
1406
|
if (this.isReference) {
|
|
1608
|
-
throwBindingError(
|
|
1407
|
+
throwBindingError(`null is not a valid ${this.name}`);
|
|
1609
1408
|
}
|
|
1610
1409
|
if (this.isSmartPointer) {
|
|
1611
1410
|
ptr = this.rawConstructor();
|
|
@@ -1618,14 +1417,14 @@ var Module = (() => {
|
|
|
1618
1417
|
return 0;
|
|
1619
1418
|
}
|
|
1620
1419
|
}
|
|
1621
|
-
if (!handle.$$) {
|
|
1622
|
-
throwBindingError(
|
|
1420
|
+
if (!handle || !handle.$$) {
|
|
1421
|
+
throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`);
|
|
1623
1422
|
}
|
|
1624
1423
|
if (!handle.$$.ptr) {
|
|
1625
|
-
throwBindingError(
|
|
1424
|
+
throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`);
|
|
1626
1425
|
}
|
|
1627
1426
|
if (!this.isConst && handle.$$.ptrType.isConst) {
|
|
1628
|
-
throwBindingError(
|
|
1427
|
+
throwBindingError(`Cannot convert argument of type ${(handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name)} to parameter type ${this.name}`);
|
|
1629
1428
|
}
|
|
1630
1429
|
var handleClass = handle.$$.ptrType.registeredClass;
|
|
1631
1430
|
ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
|
@@ -1643,7 +1442,7 @@ var Module = (() => {
|
|
|
1643
1442
|
ptr = handle.$$.smartPtr;
|
|
1644
1443
|
}
|
|
1645
1444
|
else {
|
|
1646
|
-
throwBindingError(
|
|
1445
|
+
throwBindingError(`Cannot convert argument of type ${(handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name)} to parameter type ${this.name}`);
|
|
1647
1446
|
}
|
|
1648
1447
|
break;
|
|
1649
1448
|
case 1: // INTRUSIVE
|
|
@@ -1655,9 +1454,7 @@ var Module = (() => {
|
|
|
1655
1454
|
}
|
|
1656
1455
|
else {
|
|
1657
1456
|
var clonedHandle = handle['clone']();
|
|
1658
|
-
ptr = this.rawShare(ptr, Emval.toHandle(
|
|
1659
|
-
clonedHandle['delete']();
|
|
1660
|
-
}));
|
|
1457
|
+
ptr = this.rawShare(ptr, Emval.toHandle(() => clonedHandle['delete']()));
|
|
1661
1458
|
if (destructors !== null) {
|
|
1662
1459
|
destructors.push(this.rawDestructor, ptr);
|
|
1663
1460
|
}
|
|
@@ -1669,50 +1466,43 @@ var Module = (() => {
|
|
|
1669
1466
|
}
|
|
1670
1467
|
return ptr;
|
|
1671
1468
|
}
|
|
1469
|
+
/** @suppress {globalThis} */
|
|
1672
1470
|
function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) {
|
|
1673
1471
|
if (handle === null) {
|
|
1674
1472
|
if (this.isReference) {
|
|
1675
|
-
throwBindingError(
|
|
1473
|
+
throwBindingError(`null is not a valid ${this.name}`);
|
|
1676
1474
|
}
|
|
1677
1475
|
return 0;
|
|
1678
1476
|
}
|
|
1679
1477
|
if (!handle.$$) {
|
|
1680
|
-
throwBindingError(
|
|
1478
|
+
throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`);
|
|
1681
1479
|
}
|
|
1682
1480
|
if (!handle.$$.ptr) {
|
|
1683
|
-
throwBindingError(
|
|
1481
|
+
throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`);
|
|
1684
1482
|
}
|
|
1685
1483
|
if (handle.$$.ptrType.isConst) {
|
|
1686
|
-
throwBindingError(
|
|
1484
|
+
throwBindingError(`Cannot convert argument of type ${handle.$$.ptrType.name} to parameter type ${this.name}`);
|
|
1687
1485
|
}
|
|
1688
1486
|
var handleClass = handle.$$.ptrType.registeredClass;
|
|
1689
1487
|
var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
|
1690
1488
|
return ptr;
|
|
1691
1489
|
}
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
function init_RegisteredPointer() {
|
|
1709
|
-
RegisteredPointer.prototype.getPointee = RegisteredPointer_getPointee;
|
|
1710
|
-
RegisteredPointer.prototype.destructor = RegisteredPointer_destructor;
|
|
1711
|
-
RegisteredPointer.prototype['argPackAdvance'] = 8;
|
|
1712
|
-
RegisteredPointer.prototype['readValueFromPointer'] = simpleReadValueFromPointer;
|
|
1713
|
-
RegisteredPointer.prototype['deleteObject'] = RegisteredPointer_deleteObject;
|
|
1714
|
-
RegisteredPointer.prototype['fromWireType'] = RegisteredPointer_fromWireType;
|
|
1715
|
-
}
|
|
1490
|
+
var init_RegisteredPointer = () => {
|
|
1491
|
+
Object.assign(RegisteredPointer.prototype, {
|
|
1492
|
+
getPointee(ptr) {
|
|
1493
|
+
if (this.rawGetPointee) {
|
|
1494
|
+
ptr = this.rawGetPointee(ptr);
|
|
1495
|
+
}
|
|
1496
|
+
return ptr;
|
|
1497
|
+
},
|
|
1498
|
+
destructor(ptr) {
|
|
1499
|
+
this.rawDestructor?.(ptr);
|
|
1500
|
+
},
|
|
1501
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
1502
|
+
'readValueFromPointer': readPointer,
|
|
1503
|
+
'fromWireType': RegisteredPointer_fromWireType,
|
|
1504
|
+
});
|
|
1505
|
+
};
|
|
1716
1506
|
/** @constructor
|
|
1717
1507
|
@param {*=} pointeeType,
|
|
1718
1508
|
@param {*=} sharingPolicy,
|
|
@@ -1755,9 +1545,9 @@ var Module = (() => {
|
|
|
1755
1545
|
}
|
|
1756
1546
|
}
|
|
1757
1547
|
/** @param {number=} numArguments */
|
|
1758
|
-
|
|
1548
|
+
var replacePublicSymbol = (name, value, numArguments) => {
|
|
1759
1549
|
if (!Module.hasOwnProperty(name)) {
|
|
1760
|
-
throwInternalError('Replacing
|
|
1550
|
+
throwInternalError('Replacing nonexistent public symbol');
|
|
1761
1551
|
}
|
|
1762
1552
|
// If there's an overload table for this symbol, replace the symbol in the overload table instead.
|
|
1763
1553
|
if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
|
|
@@ -1767,13 +1557,15 @@ var Module = (() => {
|
|
|
1767
1557
|
Module[name] = value;
|
|
1768
1558
|
Module[name].argCount = numArguments;
|
|
1769
1559
|
}
|
|
1770
|
-
}
|
|
1771
|
-
|
|
1560
|
+
};
|
|
1561
|
+
var dynCallLegacy = (sig, ptr, args) => {
|
|
1562
|
+
sig = sig.replace(/p/g, 'i');
|
|
1772
1563
|
var f = Module['dynCall_' + sig];
|
|
1773
|
-
return
|
|
1774
|
-
}
|
|
1564
|
+
return f(ptr, ...args);
|
|
1565
|
+
};
|
|
1775
1566
|
var wasmTableMirror = [];
|
|
1776
|
-
|
|
1567
|
+
var wasmTable;
|
|
1568
|
+
var getWasmTableEntry = (funcPtr) => {
|
|
1777
1569
|
var func = wasmTableMirror[funcPtr];
|
|
1778
1570
|
if (!func) {
|
|
1779
1571
|
if (funcPtr >= wasmTableMirror.length)
|
|
@@ -1781,27 +1573,21 @@ var Module = (() => {
|
|
|
1781
1573
|
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
1782
1574
|
}
|
|
1783
1575
|
return func;
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
function dynCall(sig, ptr, args) {
|
|
1576
|
+
};
|
|
1577
|
+
var dynCall = (sig, ptr, args = []) => {
|
|
1787
1578
|
// Without WASM_BIGINT support we cannot directly call function with i64 as
|
|
1788
|
-
// part of
|
|
1579
|
+
// part of their signature, so we rely on the dynCall functions generated by
|
|
1789
1580
|
// wasm-emscripten-finalize
|
|
1790
1581
|
if (sig.includes('j')) {
|
|
1791
1582
|
return dynCallLegacy(sig, ptr, args);
|
|
1792
1583
|
}
|
|
1793
|
-
var rtn = getWasmTableEntry(ptr)
|
|
1584
|
+
var rtn = getWasmTableEntry(ptr)(...args);
|
|
1794
1585
|
return rtn;
|
|
1795
|
-
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
Object.assign(argCache, arguments);
|
|
1801
|
-
return dynCall(sig, ptr, argCache);
|
|
1802
|
-
};
|
|
1803
|
-
}
|
|
1804
|
-
function embind__requireFunction(signature, rawFunction) {
|
|
1586
|
+
};
|
|
1587
|
+
var getDynCaller = (sig, ptr) => {
|
|
1588
|
+
return (...args) => dynCall(sig, ptr, args);
|
|
1589
|
+
};
|
|
1590
|
+
var embind__requireFunction = (signature, rawFunction) => {
|
|
1805
1591
|
signature = readLatin1String(signature);
|
|
1806
1592
|
function makeDynCaller() {
|
|
1807
1593
|
if (signature.includes('j')) {
|
|
@@ -1811,12 +1597,12 @@ var Module = (() => {
|
|
|
1811
1597
|
}
|
|
1812
1598
|
var fp = makeDynCaller();
|
|
1813
1599
|
if (typeof fp != "function") {
|
|
1814
|
-
throwBindingError(
|
|
1600
|
+
throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`);
|
|
1815
1601
|
}
|
|
1816
1602
|
return fp;
|
|
1817
|
-
}
|
|
1818
|
-
var UnboundTypeError
|
|
1819
|
-
|
|
1603
|
+
};
|
|
1604
|
+
var UnboundTypeError;
|
|
1605
|
+
var throwUnboundTypeError = (message, types) => {
|
|
1820
1606
|
var unboundTypes = [];
|
|
1821
1607
|
var seen = {};
|
|
1822
1608
|
function visit(type) {
|
|
@@ -1834,24 +1620,20 @@ var Module = (() => {
|
|
|
1834
1620
|
seen[type] = true;
|
|
1835
1621
|
}
|
|
1836
1622
|
types.forEach(visit);
|
|
1837
|
-
throw new UnboundTypeError(message
|
|
1838
|
-
}
|
|
1839
|
-
|
|
1623
|
+
throw new UnboundTypeError(`${message}: ` + unboundTypes.map(getTypeName).join([', ']));
|
|
1624
|
+
};
|
|
1625
|
+
var __embind_register_class = (rawType, rawPointerType, rawConstPointerType, baseClassRawType, getActualTypeSignature, getActualType, upcastSignature, upcast, downcastSignature, downcast, name, destructorSignature, rawDestructor) => {
|
|
1840
1626
|
name = readLatin1String(name);
|
|
1841
1627
|
getActualType = embind__requireFunction(getActualTypeSignature, getActualType);
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
}
|
|
1845
|
-
if (downcast) {
|
|
1846
|
-
downcast = embind__requireFunction(downcastSignature, downcast);
|
|
1847
|
-
}
|
|
1628
|
+
upcast &&= embind__requireFunction(upcastSignature, upcast);
|
|
1629
|
+
downcast &&= embind__requireFunction(downcastSignature, downcast);
|
|
1848
1630
|
rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);
|
|
1849
1631
|
var legalFunctionName = makeLegalFunctionName(name);
|
|
1850
1632
|
exposePublicSymbol(legalFunctionName, function () {
|
|
1851
1633
|
// this code cannot run if baseClassRawType is zero
|
|
1852
|
-
throwUnboundTypeError(
|
|
1634
|
+
throwUnboundTypeError(`Cannot construct ${name} due to unbound types`, [baseClassRawType]);
|
|
1853
1635
|
});
|
|
1854
|
-
whenDependentTypesAreResolved([rawType, rawPointerType, rawConstPointerType], baseClassRawType ? [baseClassRawType] : [],
|
|
1636
|
+
whenDependentTypesAreResolved([rawType, rawPointerType, rawConstPointerType], baseClassRawType ? [baseClassRawType] : [], (base) => {
|
|
1855
1637
|
base = base[0];
|
|
1856
1638
|
var baseClass;
|
|
1857
1639
|
var basePrototype;
|
|
@@ -1862,24 +1644,29 @@ var Module = (() => {
|
|
|
1862
1644
|
else {
|
|
1863
1645
|
basePrototype = ClassHandle.prototype;
|
|
1864
1646
|
}
|
|
1865
|
-
var constructor = createNamedFunction(
|
|
1647
|
+
var constructor = createNamedFunction(name, function (...args) {
|
|
1866
1648
|
if (Object.getPrototypeOf(this) !== instancePrototype) {
|
|
1867
1649
|
throw new BindingError("Use 'new' to construct " + name);
|
|
1868
1650
|
}
|
|
1869
1651
|
if (undefined === registeredClass.constructor_body) {
|
|
1870
1652
|
throw new BindingError(name + " has no accessible constructor");
|
|
1871
1653
|
}
|
|
1872
|
-
var body = registeredClass.constructor_body[
|
|
1654
|
+
var body = registeredClass.constructor_body[args.length];
|
|
1873
1655
|
if (undefined === body) {
|
|
1874
|
-
throw new BindingError(
|
|
1656
|
+
throw new BindingError(`Tried to invoke ctor of ${name} with invalid number of parameters (${args.length}) - expected (${Object.keys(registeredClass.constructor_body).toString()}) parameters instead!`);
|
|
1875
1657
|
}
|
|
1876
|
-
return body.apply(this,
|
|
1658
|
+
return body.apply(this, args);
|
|
1877
1659
|
});
|
|
1878
1660
|
var instancePrototype = Object.create(basePrototype, {
|
|
1879
1661
|
constructor: { value: constructor },
|
|
1880
1662
|
});
|
|
1881
1663
|
constructor.prototype = instancePrototype;
|
|
1882
1664
|
var registeredClass = new RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast);
|
|
1665
|
+
if (registeredClass.baseClass) {
|
|
1666
|
+
// Keep track of class hierarchy. Used to allow sub-classes to inherit class functions.
|
|
1667
|
+
registeredClass.baseClass.__derivedClasses ??= [];
|
|
1668
|
+
registeredClass.baseClass.__derivedClasses.push(registeredClass);
|
|
1669
|
+
}
|
|
1883
1670
|
var referenceConverter = new RegisteredPointer(name, registeredClass, true, false, false);
|
|
1884
1671
|
var pointerConverter = new RegisteredPointer(name + '*', registeredClass, false, false, false);
|
|
1885
1672
|
var constPointerConverter = new RegisteredPointer(name + ' const*', registeredClass, false, true, false);
|
|
@@ -1890,10 +1677,20 @@ var Module = (() => {
|
|
|
1890
1677
|
replacePublicSymbol(legalFunctionName, constructor);
|
|
1891
1678
|
return [referenceConverter, pointerConverter, constPointerConverter];
|
|
1892
1679
|
});
|
|
1680
|
+
};
|
|
1681
|
+
function usesDestructorStack(argTypes) {
|
|
1682
|
+
// Skip return value at index 0 - it's not deleted here.
|
|
1683
|
+
for (var i = 1; i < argTypes.length; ++i) {
|
|
1684
|
+
// The type does not define a destructor function - must use dynamic stack
|
|
1685
|
+
if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) {
|
|
1686
|
+
return true;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
return false;
|
|
1893
1690
|
}
|
|
1894
|
-
function
|
|
1691
|
+
function newFunc(constructor, argumentList) {
|
|
1895
1692
|
if (!(constructor instanceof Function)) {
|
|
1896
|
-
throw new TypeError(
|
|
1693
|
+
throw new TypeError(`new_ called with constructor type ${typeof (constructor)} which is not a function`);
|
|
1897
1694
|
}
|
|
1898
1695
|
/*
|
|
1899
1696
|
* Previously, the following line was just:
|
|
@@ -1902,7 +1699,7 @@ var Module = (() => {
|
|
|
1902
1699
|
* though at creation, the 'dummy' has the correct constructor name. Thus,
|
|
1903
1700
|
* objects created with IMVU.new would show up in the debugger as 'dummy',
|
|
1904
1701
|
* which isn't very helpful. Using IMVU.createNamedFunction addresses the
|
|
1905
|
-
* issue.
|
|
1702
|
+
* issue. Doubly-unfortunately, there's no way to write a test for this
|
|
1906
1703
|
* behavior. -NRD 2013.02.22
|
|
1907
1704
|
*/
|
|
1908
1705
|
var dummy = createNamedFunction(constructor.name || 'unknownFunctionName', function () { });
|
|
@@ -1911,64 +1708,38 @@ var Module = (() => {
|
|
|
1911
1708
|
var r = constructor.apply(obj, argumentList);
|
|
1912
1709
|
return (r instanceof Object) ? r : obj;
|
|
1913
1710
|
}
|
|
1914
|
-
function
|
|
1915
|
-
|
|
1916
|
-
// argTypes: An array that contains the embind type objects for all types in the function signature.
|
|
1917
|
-
// argTypes[0] is the type object for the function return value.
|
|
1918
|
-
// argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
|
|
1919
|
-
// argTypes[2...] are the actual function parameters.
|
|
1920
|
-
// classType: The embind type object for the class to be bound, or null if this is not a method of a class.
|
|
1921
|
-
// cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
|
|
1922
|
-
// cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
|
|
1711
|
+
function createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync) {
|
|
1712
|
+
var needsDestructorStack = usesDestructorStack(argTypes);
|
|
1923
1713
|
var argCount = argTypes.length;
|
|
1924
|
-
if (argCount < 2) {
|
|
1925
|
-
throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
|
|
1926
|
-
}
|
|
1927
|
-
var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
|
|
1928
|
-
// Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
|
|
1929
|
-
// TODO: This omits argument count check - enable only at -O3 or similar.
|
|
1930
|
-
// if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
|
|
1931
|
-
// return FUNCTION_TABLE[fn];
|
|
1932
|
-
// }
|
|
1933
|
-
// Determine if we need to use a dynamic stack to store the destructors for the function parameters.
|
|
1934
|
-
// TODO: Remove this completely once all function invokers are being dynamically generated.
|
|
1935
|
-
var needsDestructorStack = false;
|
|
1936
|
-
for (var i = 1; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here.
|
|
1937
|
-
if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) { // The type does not define a destructor function - must use dynamic stack
|
|
1938
|
-
needsDestructorStack = true;
|
|
1939
|
-
break;
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
var returns = (argTypes[0].name !== "void");
|
|
1943
1714
|
var argsList = "";
|
|
1944
1715
|
var argsListWired = "";
|
|
1945
1716
|
for (var i = 0; i < argCount - 2; ++i) {
|
|
1946
1717
|
argsList += (i !== 0 ? ", " : "") + "arg" + i;
|
|
1947
1718
|
argsListWired += (i !== 0 ? ", " : "") + "arg" + i + "Wired";
|
|
1948
1719
|
}
|
|
1949
|
-
var invokerFnBody =
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1720
|
+
var invokerFnBody = `
|
|
1721
|
+
return function (${argsList}) {
|
|
1722
|
+
if (arguments.length !== ${argCount - 2}) {
|
|
1723
|
+
throwBindingError('function ' + humanName + ' called with ' + arguments.length + ' arguments, expected ${argCount - 2}');
|
|
1724
|
+
}`;
|
|
1953
1725
|
if (needsDestructorStack) {
|
|
1954
1726
|
invokerFnBody += "var destructors = [];\n";
|
|
1955
1727
|
}
|
|
1956
1728
|
var dtorStack = needsDestructorStack ? "destructors" : "null";
|
|
1957
|
-
var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
|
|
1958
|
-
var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
|
|
1729
|
+
var args1 = ["humanName", "throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
|
|
1959
1730
|
if (isClassMethodFunc) {
|
|
1960
|
-
invokerFnBody += "var thisWired = classParam
|
|
1731
|
+
invokerFnBody += "var thisWired = classParam['toWireType'](" + dtorStack + ", this);\n";
|
|
1961
1732
|
}
|
|
1962
1733
|
for (var i = 0; i < argCount - 2; ++i) {
|
|
1963
|
-
invokerFnBody += "var arg" + i + "Wired = argType" + i + "
|
|
1734
|
+
invokerFnBody += "var arg" + i + "Wired = argType" + i + "['toWireType'](" + dtorStack + ", arg" + i + ");\n";
|
|
1964
1735
|
args1.push("argType" + i);
|
|
1965
|
-
args2.push(argTypes[i + 2]);
|
|
1966
1736
|
}
|
|
1967
1737
|
if (isClassMethodFunc) {
|
|
1968
1738
|
argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
|
|
1969
1739
|
}
|
|
1970
1740
|
invokerFnBody +=
|
|
1971
1741
|
(returns || isAsync ? "var rv = " : "") + "invoker(fn" + (argsListWired.length > 0 ? ", " : "") + argsListWired + ");\n";
|
|
1742
|
+
var returnVal = returns ? "rv" : "";
|
|
1972
1743
|
if (needsDestructorStack) {
|
|
1973
1744
|
invokerFnBody += "runDestructors(destructors);\n";
|
|
1974
1745
|
}
|
|
@@ -1976,24 +1747,63 @@ var Module = (() => {
|
|
|
1976
1747
|
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.
|
|
1977
1748
|
var paramName = (i === 1 ? "thisWired" : ("arg" + (i - 2) + "Wired"));
|
|
1978
1749
|
if (argTypes[i].destructorFunction !== null) {
|
|
1979
|
-
invokerFnBody += paramName
|
|
1980
|
-
args1.push(paramName
|
|
1981
|
-
args2.push(argTypes[i].destructorFunction);
|
|
1750
|
+
invokerFnBody += `${paramName}_dtor(${paramName});\n`;
|
|
1751
|
+
args1.push(`${paramName}_dtor`);
|
|
1982
1752
|
}
|
|
1983
1753
|
}
|
|
1984
1754
|
}
|
|
1985
1755
|
if (returns) {
|
|
1986
|
-
invokerFnBody += "var ret = retType
|
|
1756
|
+
invokerFnBody += "var ret = retType['fromWireType'](rv);\n" +
|
|
1987
1757
|
"return ret;\n";
|
|
1988
1758
|
}
|
|
1989
1759
|
else {
|
|
1990
1760
|
}
|
|
1991
|
-
invokerFnBody += "}\n";
|
|
1992
|
-
args1
|
|
1993
|
-
|
|
1994
|
-
|
|
1761
|
+
invokerFnBody += "}\n";
|
|
1762
|
+
return [args1, invokerFnBody];
|
|
1763
|
+
}
|
|
1764
|
+
function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, /** boolean= */ isAsync) {
|
|
1765
|
+
// humanName: a human-readable string name for the function to be generated.
|
|
1766
|
+
// argTypes: An array that contains the embind type objects for all types in the function signature.
|
|
1767
|
+
// argTypes[0] is the type object for the function return value.
|
|
1768
|
+
// argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
|
|
1769
|
+
// argTypes[2...] are the actual function parameters.
|
|
1770
|
+
// classType: The embind type object for the class to be bound, or null if this is not a method of a class.
|
|
1771
|
+
// cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
|
|
1772
|
+
// cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
|
|
1773
|
+
// isAsync: Optional. If true, returns an async function. Async bindings are only supported with JSPI.
|
|
1774
|
+
var argCount = argTypes.length;
|
|
1775
|
+
if (argCount < 2) {
|
|
1776
|
+
throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
|
|
1777
|
+
}
|
|
1778
|
+
var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
|
|
1779
|
+
// Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
|
|
1780
|
+
// TODO: This omits argument count check - enable only at -O3 or similar.
|
|
1781
|
+
// if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
|
|
1782
|
+
// return FUNCTION_TABLE[fn];
|
|
1783
|
+
// }
|
|
1784
|
+
// Determine if we need to use a dynamic stack to store the destructors for the function parameters.
|
|
1785
|
+
// TODO: Remove this completely once all function invokers are being dynamically generated.
|
|
1786
|
+
var needsDestructorStack = usesDestructorStack(argTypes);
|
|
1787
|
+
var returns = (argTypes[0].name !== "void");
|
|
1788
|
+
// Builld the arguments that will be passed into the closure around the invoker
|
|
1789
|
+
// function.
|
|
1790
|
+
var closureArgs = [humanName, throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
|
|
1791
|
+
for (var i = 0; i < argCount - 2; ++i) {
|
|
1792
|
+
closureArgs.push(argTypes[i + 2]);
|
|
1793
|
+
}
|
|
1794
|
+
if (!needsDestructorStack) {
|
|
1795
|
+
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.
|
|
1796
|
+
if (argTypes[i].destructorFunction !== null) {
|
|
1797
|
+
closureArgs.push(argTypes[i].destructorFunction);
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
let [args, invokerFnBody] = createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync);
|
|
1802
|
+
args.push(invokerFnBody);
|
|
1803
|
+
var invokerFn = newFunc(Function, args)(...closureArgs);
|
|
1804
|
+
return createNamedFunction(humanName, invokerFn);
|
|
1995
1805
|
}
|
|
1996
|
-
|
|
1806
|
+
var heap32VectorToArray = (count, firstElement) => {
|
|
1997
1807
|
var array = [];
|
|
1998
1808
|
for (var i = 0; i < count; i++) {
|
|
1999
1809
|
// TODO(https://github.com/emscripten-core/emscripten/issues/17310):
|
|
@@ -2001,16 +1811,27 @@ var Module = (() => {
|
|
|
2001
1811
|
array.push(HEAPU32[(((firstElement) + (i * 4)) >> 2)]);
|
|
2002
1812
|
}
|
|
2003
1813
|
return array;
|
|
2004
|
-
}
|
|
2005
|
-
|
|
1814
|
+
};
|
|
1815
|
+
var getFunctionName = (signature) => {
|
|
1816
|
+
signature = signature.trim();
|
|
1817
|
+
const argsIndex = signature.indexOf("(");
|
|
1818
|
+
if (argsIndex !== -1) {
|
|
1819
|
+
return signature.substr(0, argsIndex);
|
|
1820
|
+
}
|
|
1821
|
+
else {
|
|
1822
|
+
return signature;
|
|
1823
|
+
}
|
|
1824
|
+
};
|
|
1825
|
+
var __embind_register_class_class_function = (rawClassType, methodName, argCount, rawArgTypesAddr, invokerSignature, rawInvoker, fn, isAsync) => {
|
|
2006
1826
|
var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
|
2007
1827
|
methodName = readLatin1String(methodName);
|
|
1828
|
+
methodName = getFunctionName(methodName);
|
|
2008
1829
|
rawInvoker = embind__requireFunction(invokerSignature, rawInvoker);
|
|
2009
|
-
whenDependentTypesAreResolved([], [rawClassType],
|
|
1830
|
+
whenDependentTypesAreResolved([], [rawClassType], (classType) => {
|
|
2010
1831
|
classType = classType[0];
|
|
2011
|
-
var humanName = classType.name
|
|
1832
|
+
var humanName = `${classType.name}.${methodName}`;
|
|
2012
1833
|
function unboundTypesHandler() {
|
|
2013
|
-
throwUnboundTypeError(
|
|
1834
|
+
throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`, rawArgTypes);
|
|
2014
1835
|
}
|
|
2015
1836
|
if (methodName.startsWith("@@")) {
|
|
2016
1837
|
methodName = Symbol[methodName.substring(2)];
|
|
@@ -2027,7 +1848,7 @@ var Module = (() => {
|
|
|
2027
1848
|
ensureOverloadTable(proto, methodName, humanName);
|
|
2028
1849
|
proto[methodName].overloadTable[argCount - 1] = unboundTypesHandler;
|
|
2029
1850
|
}
|
|
2030
|
-
whenDependentTypesAreResolved([], rawArgTypes,
|
|
1851
|
+
whenDependentTypesAreResolved([], rawArgTypes, (argTypes) => {
|
|
2031
1852
|
// Replace the initial unbound-types-handler stub with the proper
|
|
2032
1853
|
// function. If multiple overloads are registered, the function handlers
|
|
2033
1854
|
// go into an overload table.
|
|
@@ -2040,30 +1861,37 @@ var Module = (() => {
|
|
|
2040
1861
|
else {
|
|
2041
1862
|
proto[methodName].overloadTable[argCount - 1] = func;
|
|
2042
1863
|
}
|
|
1864
|
+
if (classType.registeredClass.__derivedClasses) {
|
|
1865
|
+
for (const derivedClass of classType.registeredClass.__derivedClasses) {
|
|
1866
|
+
if (!derivedClass.constructor.hasOwnProperty(methodName)) {
|
|
1867
|
+
// TODO: Add support for overloads
|
|
1868
|
+
derivedClass.constructor[methodName] = func;
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
2043
1872
|
return [];
|
|
2044
1873
|
});
|
|
2045
1874
|
return [];
|
|
2046
1875
|
});
|
|
2047
|
-
}
|
|
2048
|
-
|
|
2049
|
-
assert(argCount > 0);
|
|
1876
|
+
};
|
|
1877
|
+
var __embind_register_class_constructor = (rawClassType, argCount, rawArgTypesAddr, invokerSignature, invoker, rawConstructor) => {
|
|
2050
1878
|
var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
|
2051
1879
|
invoker = embind__requireFunction(invokerSignature, invoker);
|
|
2052
1880
|
var args = [rawConstructor];
|
|
2053
1881
|
var destructors = [];
|
|
2054
|
-
whenDependentTypesAreResolved([], [rawClassType],
|
|
1882
|
+
whenDependentTypesAreResolved([], [rawClassType], (classType) => {
|
|
2055
1883
|
classType = classType[0];
|
|
2056
|
-
var humanName =
|
|
1884
|
+
var humanName = `constructor ${classType.name}`;
|
|
2057
1885
|
if (undefined === classType.registeredClass.constructor_body) {
|
|
2058
1886
|
classType.registeredClass.constructor_body = [];
|
|
2059
1887
|
}
|
|
2060
1888
|
if (undefined !== classType.registeredClass.constructor_body[argCount - 1]) {
|
|
2061
|
-
throw new BindingError(
|
|
1889
|
+
throw new BindingError(`Cannot register multiple constructors with identical number of parameters (${argCount - 1}) for class '${classType.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);
|
|
2062
1890
|
}
|
|
2063
1891
|
classType.registeredClass.constructor_body[argCount - 1] = () => {
|
|
2064
|
-
throwUnboundTypeError(
|
|
1892
|
+
throwUnboundTypeError(`Cannot construct ${classType.name} due to unbound types`, rawArgTypes);
|
|
2065
1893
|
};
|
|
2066
|
-
whenDependentTypesAreResolved([], rawArgTypes,
|
|
1894
|
+
whenDependentTypesAreResolved([], rawArgTypes, (argTypes) => {
|
|
2067
1895
|
// Insert empty slot for context type (argTypes[1]).
|
|
2068
1896
|
argTypes.splice(1, 0, null);
|
|
2069
1897
|
classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor);
|
|
@@ -2071,15 +1899,16 @@ var Module = (() => {
|
|
|
2071
1899
|
});
|
|
2072
1900
|
return [];
|
|
2073
1901
|
});
|
|
2074
|
-
}
|
|
2075
|
-
|
|
2076
|
-
invokerSignature, rawInvoker, context, isPureVirtual, isAsync) {
|
|
1902
|
+
};
|
|
1903
|
+
var __embind_register_class_function = (rawClassType, methodName, argCount, rawArgTypesAddr, // [ReturnType, ThisType, Args...]
|
|
1904
|
+
invokerSignature, rawInvoker, context, isPureVirtual, isAsync) => {
|
|
2077
1905
|
var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
|
2078
1906
|
methodName = readLatin1String(methodName);
|
|
1907
|
+
methodName = getFunctionName(methodName);
|
|
2079
1908
|
rawInvoker = embind__requireFunction(invokerSignature, rawInvoker);
|
|
2080
|
-
whenDependentTypesAreResolved([], [rawClassType],
|
|
1909
|
+
whenDependentTypesAreResolved([], [rawClassType], (classType) => {
|
|
2081
1910
|
classType = classType[0];
|
|
2082
|
-
var humanName = classType.name
|
|
1911
|
+
var humanName = `${classType.name}.${methodName}`;
|
|
2083
1912
|
if (methodName.startsWith("@@")) {
|
|
2084
1913
|
methodName = Symbol[methodName.substring(2)];
|
|
2085
1914
|
}
|
|
@@ -2087,7 +1916,7 @@ var Module = (() => {
|
|
|
2087
1916
|
classType.registeredClass.pureVirtualFunctions.push(methodName);
|
|
2088
1917
|
}
|
|
2089
1918
|
function unboundTypesHandler() {
|
|
2090
|
-
throwUnboundTypeError(
|
|
1919
|
+
throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`, rawArgTypes);
|
|
2091
1920
|
}
|
|
2092
1921
|
var proto = classType.registeredClass.instancePrototype;
|
|
2093
1922
|
var method = proto[methodName];
|
|
@@ -2104,10 +1933,12 @@ var Module = (() => {
|
|
|
2104
1933
|
ensureOverloadTable(proto, methodName, humanName);
|
|
2105
1934
|
proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler;
|
|
2106
1935
|
}
|
|
2107
|
-
whenDependentTypesAreResolved([], rawArgTypes,
|
|
1936
|
+
whenDependentTypesAreResolved([], rawArgTypes, (argTypes) => {
|
|
2108
1937
|
var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context, isAsync);
|
|
2109
|
-
// Replace the initial unbound-handler-stub function with the
|
|
2110
|
-
//
|
|
1938
|
+
// Replace the initial unbound-handler-stub function with the
|
|
1939
|
+
// appropriate member function, now that all types are resolved. If
|
|
1940
|
+
// multiple overloads are registered for this function, the function
|
|
1941
|
+
// goes into an overload table.
|
|
2111
1942
|
if (undefined === proto[methodName].overloadTable) {
|
|
2112
1943
|
// Set argCount in case an overload is registered later
|
|
2113
1944
|
memberFunction.argCount = argCount - 2;
|
|
@@ -2120,48 +1951,44 @@ var Module = (() => {
|
|
|
2120
1951
|
});
|
|
2121
1952
|
return [];
|
|
2122
1953
|
});
|
|
2123
|
-
}
|
|
2124
|
-
|
|
1954
|
+
};
|
|
1955
|
+
var validateThis = (this_, classType, humanName) => {
|
|
2125
1956
|
if (!(this_ instanceof Object)) {
|
|
2126
|
-
throwBindingError(humanName
|
|
1957
|
+
throwBindingError(`${humanName} with invalid "this": ${this_}`);
|
|
2127
1958
|
}
|
|
2128
1959
|
if (!(this_ instanceof classType.registeredClass.constructor)) {
|
|
2129
|
-
throwBindingError(humanName
|
|
1960
|
+
throwBindingError(`${humanName} incompatible with "this" of type ${this_.constructor.name}`);
|
|
2130
1961
|
}
|
|
2131
1962
|
if (!this_.$$.ptr) {
|
|
2132
|
-
throwBindingError(
|
|
1963
|
+
throwBindingError(`cannot call emscripten binding method ${humanName} on deleted object`);
|
|
2133
1964
|
}
|
|
2134
1965
|
// todo: kill this
|
|
2135
1966
|
return upcastPointer(this_.$$.ptr, this_.$$.ptrType.registeredClass, classType.registeredClass);
|
|
2136
|
-
}
|
|
2137
|
-
|
|
1967
|
+
};
|
|
1968
|
+
var __embind_register_class_property = (classType, fieldName, getterReturnType, getterSignature, getter, getterContext, setterArgumentType, setterSignature, setter, setterContext) => {
|
|
2138
1969
|
fieldName = readLatin1String(fieldName);
|
|
2139
1970
|
getter = embind__requireFunction(getterSignature, getter);
|
|
2140
|
-
whenDependentTypesAreResolved([], [classType],
|
|
1971
|
+
whenDependentTypesAreResolved([], [classType], (classType) => {
|
|
2141
1972
|
classType = classType[0];
|
|
2142
|
-
var humanName = classType.name
|
|
1973
|
+
var humanName = `${classType.name}.${fieldName}`;
|
|
2143
1974
|
var desc = {
|
|
2144
|
-
get
|
|
2145
|
-
throwUnboundTypeError(
|
|
1975
|
+
get() {
|
|
1976
|
+
throwUnboundTypeError(`Cannot access ${humanName} due to unbound types`, [getterReturnType, setterArgumentType]);
|
|
2146
1977
|
},
|
|
2147
1978
|
enumerable: true,
|
|
2148
1979
|
configurable: true
|
|
2149
1980
|
};
|
|
2150
1981
|
if (setter) {
|
|
2151
|
-
desc.set = () => {
|
|
2152
|
-
throwUnboundTypeError('Cannot access ' + humanName + ' due to unbound types', [getterReturnType, setterArgumentType]);
|
|
2153
|
-
};
|
|
1982
|
+
desc.set = () => throwUnboundTypeError(`Cannot access ${humanName} due to unbound types`, [getterReturnType, setterArgumentType]);
|
|
2154
1983
|
}
|
|
2155
1984
|
else {
|
|
2156
|
-
desc.set = (v) =>
|
|
2157
|
-
throwBindingError(humanName + ' is a read-only property');
|
|
2158
|
-
};
|
|
1985
|
+
desc.set = (v) => throwBindingError(humanName + ' is a read-only property');
|
|
2159
1986
|
}
|
|
2160
1987
|
Object.defineProperty(classType.registeredClass.instancePrototype, fieldName, desc);
|
|
2161
|
-
whenDependentTypesAreResolved([], (setter ? [getterReturnType, setterArgumentType] : [getterReturnType]),
|
|
1988
|
+
whenDependentTypesAreResolved([], (setter ? [getterReturnType, setterArgumentType] : [getterReturnType]), (types) => {
|
|
2162
1989
|
var getterReturnType = types[0];
|
|
2163
1990
|
var desc = {
|
|
2164
|
-
get
|
|
1991
|
+
get() {
|
|
2165
1992
|
var ptr = validateThis(this, classType, humanName + ' getter');
|
|
2166
1993
|
return getterReturnType['fromWireType'](getter(getterContext, ptr));
|
|
2167
1994
|
},
|
|
@@ -2182,33 +2009,29 @@ var Module = (() => {
|
|
|
2182
2009
|
});
|
|
2183
2010
|
return [];
|
|
2184
2011
|
});
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
|
-
if (handle >
|
|
2188
|
-
|
|
2189
|
-
|
|
2012
|
+
};
|
|
2013
|
+
var __emval_decref = (handle) => {
|
|
2014
|
+
if (handle > 9 && 0 === --emval_handles[handle + 1]) {
|
|
2015
|
+
emval_handles[handle] = undefined;
|
|
2016
|
+
emval_freelist.push(handle);
|
|
2190
2017
|
}
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
name
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
// emval is passed into JS via an interface
|
|
2209
|
-
});
|
|
2210
|
-
}
|
|
2211
|
-
function embindRepr(v) {
|
|
2018
|
+
};
|
|
2019
|
+
var EmValType = {
|
|
2020
|
+
name: 'emscripten::val',
|
|
2021
|
+
'fromWireType': (handle) => {
|
|
2022
|
+
var rv = Emval.toValue(handle);
|
|
2023
|
+
__emval_decref(handle);
|
|
2024
|
+
return rv;
|
|
2025
|
+
},
|
|
2026
|
+
'toWireType': (destructors, value) => Emval.toHandle(value),
|
|
2027
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
2028
|
+
'readValueFromPointer': readPointer,
|
|
2029
|
+
destructorFunction: null, // This type does not need a destructor
|
|
2030
|
+
// TODO: do we need a deleteObject here? write a test where
|
|
2031
|
+
// emval is passed into JS via an interface
|
|
2032
|
+
};
|
|
2033
|
+
var __embind_register_emval = (rawType) => registerType(rawType, EmValType);
|
|
2034
|
+
var embindRepr = (v) => {
|
|
2212
2035
|
if (v === null) {
|
|
2213
2036
|
return 'null';
|
|
2214
2037
|
}
|
|
@@ -2219,74 +2042,72 @@ var Module = (() => {
|
|
|
2219
2042
|
else {
|
|
2220
2043
|
return '' + v;
|
|
2221
2044
|
}
|
|
2222
|
-
}
|
|
2223
|
-
|
|
2224
|
-
switch (
|
|
2225
|
-
case
|
|
2226
|
-
return this['fromWireType'](HEAPF32[pointer >> 2]);
|
|
2045
|
+
};
|
|
2046
|
+
var floatReadValueFromPointer = (name, width) => {
|
|
2047
|
+
switch (width) {
|
|
2048
|
+
case 4: return function (pointer) {
|
|
2049
|
+
return this['fromWireType'](HEAPF32[((pointer) >> 2)]);
|
|
2227
2050
|
};
|
|
2228
|
-
case
|
|
2229
|
-
return this['fromWireType'](HEAPF64[pointer >> 3]);
|
|
2051
|
+
case 8: return function (pointer) {
|
|
2052
|
+
return this['fromWireType'](HEAPF64[((pointer) >> 3)]);
|
|
2230
2053
|
};
|
|
2231
2054
|
default:
|
|
2232
|
-
throw new TypeError(
|
|
2055
|
+
throw new TypeError(`invalid float width (${width}): ${name}`);
|
|
2233
2056
|
}
|
|
2234
|
-
}
|
|
2235
|
-
|
|
2236
|
-
var shift = getShiftFromSize(size);
|
|
2057
|
+
};
|
|
2058
|
+
var __embind_register_float = (rawType, name, size) => {
|
|
2237
2059
|
name = readLatin1String(name);
|
|
2238
2060
|
registerType(rawType, {
|
|
2239
|
-
name
|
|
2240
|
-
'fromWireType':
|
|
2241
|
-
|
|
2242
|
-
},
|
|
2243
|
-
'toWireType': function (destructors, value) {
|
|
2061
|
+
name,
|
|
2062
|
+
'fromWireType': (value) => value,
|
|
2063
|
+
'toWireType': (destructors, value) => {
|
|
2244
2064
|
// The VM will perform JS to Wasm value conversion, according to the spec:
|
|
2245
2065
|
// https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
|
|
2246
2066
|
return value;
|
|
2247
2067
|
},
|
|
2248
|
-
'argPackAdvance':
|
|
2249
|
-
'readValueFromPointer': floatReadValueFromPointer(name,
|
|
2068
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
2069
|
+
'readValueFromPointer': floatReadValueFromPointer(name, size),
|
|
2250
2070
|
destructorFunction: null, // This type does not need a destructor
|
|
2251
2071
|
});
|
|
2252
|
-
}
|
|
2253
|
-
|
|
2072
|
+
};
|
|
2073
|
+
var __embind_register_function = (name, argCount, rawArgTypesAddr, signature, rawInvoker, fn, isAsync) => {
|
|
2254
2074
|
var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
|
2255
2075
|
name = readLatin1String(name);
|
|
2076
|
+
name = getFunctionName(name);
|
|
2256
2077
|
rawInvoker = embind__requireFunction(signature, rawInvoker);
|
|
2257
2078
|
exposePublicSymbol(name, function () {
|
|
2258
|
-
throwUnboundTypeError(
|
|
2079
|
+
throwUnboundTypeError(`Cannot call ${name} due to unbound types`, argTypes);
|
|
2259
2080
|
}, argCount - 1);
|
|
2260
|
-
whenDependentTypesAreResolved([], argTypes,
|
|
2081
|
+
whenDependentTypesAreResolved([], argTypes, (argTypes) => {
|
|
2261
2082
|
var invokerArgsArray = [argTypes[0] /* return value */, null /* no class 'this'*/].concat(argTypes.slice(1) /* actual params */);
|
|
2262
2083
|
replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null /* no class 'this'*/, rawInvoker, fn, isAsync), argCount - 1);
|
|
2263
2084
|
return [];
|
|
2264
2085
|
});
|
|
2265
|
-
}
|
|
2266
|
-
|
|
2086
|
+
};
|
|
2087
|
+
var integerReadValueFromPointer = (name, width, signed) => {
|
|
2267
2088
|
// integers are quite common, so generate very specialized functions
|
|
2268
|
-
switch (
|
|
2269
|
-
case 0: return signed ?
|
|
2270
|
-
function readS8FromPointer(pointer) { return HEAP8[pointer]; } :
|
|
2271
|
-
function readU8FromPointer(pointer) { return HEAPU8[pointer]; };
|
|
2089
|
+
switch (width) {
|
|
2272
2090
|
case 1: return signed ?
|
|
2273
|
-
|
|
2274
|
-
|
|
2091
|
+
(pointer) => HEAP8[pointer] :
|
|
2092
|
+
(pointer) => HEAPU8[pointer];
|
|
2275
2093
|
case 2: return signed ?
|
|
2276
|
-
|
|
2277
|
-
|
|
2094
|
+
(pointer) => HEAP16[((pointer) >> 1)] :
|
|
2095
|
+
(pointer) => HEAPU16[((pointer) >> 1)];
|
|
2096
|
+
case 4: return signed ?
|
|
2097
|
+
(pointer) => HEAP32[((pointer) >> 2)] :
|
|
2098
|
+
(pointer) => HEAPU32[((pointer) >> 2)];
|
|
2278
2099
|
default:
|
|
2279
|
-
throw new TypeError(
|
|
2100
|
+
throw new TypeError(`invalid integer width (${width}): ${name}`);
|
|
2280
2101
|
}
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2102
|
+
};
|
|
2103
|
+
/** @suppress {globalThis} */
|
|
2104
|
+
var __embind_register_integer = (primitiveType, name, size, minRange, maxRange) => {
|
|
2283
2105
|
name = readLatin1String(name);
|
|
2284
2106
|
// LLVM doesn't have signed and unsigned 32-bit types, so u32 literals come
|
|
2285
2107
|
// out as 'i32 -1'. Always treat those as max u32.
|
|
2286
2108
|
if (maxRange === -1) {
|
|
2287
2109
|
maxRange = 4294967295;
|
|
2288
2110
|
}
|
|
2289
|
-
var shift = getShiftFromSize(size);
|
|
2290
2111
|
var fromWireType = (value) => value;
|
|
2291
2112
|
if (minRange === 0) {
|
|
2292
2113
|
var bitshift = 32 - 8 * size;
|
|
@@ -2311,15 +2132,15 @@ var Module = (() => {
|
|
|
2311
2132
|
};
|
|
2312
2133
|
}
|
|
2313
2134
|
registerType(primitiveType, {
|
|
2314
|
-
name
|
|
2135
|
+
name,
|
|
2315
2136
|
'fromWireType': fromWireType,
|
|
2316
2137
|
'toWireType': toWireType,
|
|
2317
|
-
'argPackAdvance':
|
|
2318
|
-
'readValueFromPointer': integerReadValueFromPointer(name,
|
|
2138
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
2139
|
+
'readValueFromPointer': integerReadValueFromPointer(name, size, minRange !== 0),
|
|
2319
2140
|
destructorFunction: null, // This type does not need a destructor
|
|
2320
2141
|
});
|
|
2321
|
-
}
|
|
2322
|
-
|
|
2142
|
+
};
|
|
2143
|
+
var __embind_register_memory_view = (rawType, dataTypeIndex, name) => {
|
|
2323
2144
|
var typeMapping = [
|
|
2324
2145
|
Int8Array,
|
|
2325
2146
|
Uint8Array,
|
|
@@ -2332,30 +2153,108 @@ var Module = (() => {
|
|
|
2332
2153
|
];
|
|
2333
2154
|
var TA = typeMapping[dataTypeIndex];
|
|
2334
2155
|
function decodeMemoryView(handle) {
|
|
2335
|
-
|
|
2336
|
-
var
|
|
2337
|
-
|
|
2338
|
-
var data = heap[handle + 1]; // byte offset into emscripten heap
|
|
2339
|
-
return new TA(heap.buffer, data, size);
|
|
2156
|
+
var size = HEAPU32[((handle) >> 2)];
|
|
2157
|
+
var data = HEAPU32[(((handle) + (4)) >> 2)];
|
|
2158
|
+
return new TA(HEAP8.buffer, data, size);
|
|
2340
2159
|
}
|
|
2341
2160
|
name = readLatin1String(name);
|
|
2342
2161
|
registerType(rawType, {
|
|
2343
|
-
name
|
|
2162
|
+
name,
|
|
2344
2163
|
'fromWireType': decodeMemoryView,
|
|
2345
|
-
'argPackAdvance':
|
|
2164
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
2346
2165
|
'readValueFromPointer': decodeMemoryView,
|
|
2347
2166
|
}, {
|
|
2348
2167
|
ignoreDuplicateRegistrations: true,
|
|
2349
2168
|
});
|
|
2350
|
-
}
|
|
2351
|
-
|
|
2169
|
+
};
|
|
2170
|
+
var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
|
|
2171
|
+
// Parameter maxBytesToWrite is not optional. Negative values, 0, null,
|
|
2172
|
+
// undefined and false each don't write out any bytes.
|
|
2173
|
+
if (!(maxBytesToWrite > 0))
|
|
2174
|
+
return 0;
|
|
2175
|
+
var startIdx = outIdx;
|
|
2176
|
+
var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
|
|
2177
|
+
for (var i = 0; i < str.length; ++i) {
|
|
2178
|
+
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
|
|
2179
|
+
// unit, not a Unicode code point of the character! So decode
|
|
2180
|
+
// UTF16->UTF32->UTF8.
|
|
2181
|
+
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
2182
|
+
// For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
|
|
2183
|
+
// and https://www.ietf.org/rfc/rfc2279.txt
|
|
2184
|
+
// and https://tools.ietf.org/html/rfc3629
|
|
2185
|
+
var u = str.charCodeAt(i); // possibly a lead surrogate
|
|
2186
|
+
if (u >= 0xD800 && u <= 0xDFFF) {
|
|
2187
|
+
var u1 = str.charCodeAt(++i);
|
|
2188
|
+
u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
|
|
2189
|
+
}
|
|
2190
|
+
if (u <= 0x7F) {
|
|
2191
|
+
if (outIdx >= endIdx)
|
|
2192
|
+
break;
|
|
2193
|
+
heap[outIdx++] = u;
|
|
2194
|
+
}
|
|
2195
|
+
else if (u <= 0x7FF) {
|
|
2196
|
+
if (outIdx + 1 >= endIdx)
|
|
2197
|
+
break;
|
|
2198
|
+
heap[outIdx++] = 0xC0 | (u >> 6);
|
|
2199
|
+
heap[outIdx++] = 0x80 | (u & 63);
|
|
2200
|
+
}
|
|
2201
|
+
else if (u <= 0xFFFF) {
|
|
2202
|
+
if (outIdx + 2 >= endIdx)
|
|
2203
|
+
break;
|
|
2204
|
+
heap[outIdx++] = 0xE0 | (u >> 12);
|
|
2205
|
+
heap[outIdx++] = 0x80 | ((u >> 6) & 63);
|
|
2206
|
+
heap[outIdx++] = 0x80 | (u & 63);
|
|
2207
|
+
}
|
|
2208
|
+
else {
|
|
2209
|
+
if (outIdx + 3 >= endIdx)
|
|
2210
|
+
break;
|
|
2211
|
+
heap[outIdx++] = 0xF0 | (u >> 18);
|
|
2212
|
+
heap[outIdx++] = 0x80 | ((u >> 12) & 63);
|
|
2213
|
+
heap[outIdx++] = 0x80 | ((u >> 6) & 63);
|
|
2214
|
+
heap[outIdx++] = 0x80 | (u & 63);
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
// Null-terminate the pointer to the buffer.
|
|
2218
|
+
heap[outIdx] = 0;
|
|
2219
|
+
return outIdx - startIdx;
|
|
2220
|
+
};
|
|
2221
|
+
var stringToUTF8 = (str, outPtr, maxBytesToWrite) => {
|
|
2222
|
+
return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
|
|
2223
|
+
};
|
|
2224
|
+
var lengthBytesUTF8 = (str) => {
|
|
2225
|
+
var len = 0;
|
|
2226
|
+
for (var i = 0; i < str.length; ++i) {
|
|
2227
|
+
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
|
|
2228
|
+
// unit, not a Unicode code point of the character! So decode
|
|
2229
|
+
// UTF16->UTF32->UTF8.
|
|
2230
|
+
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
2231
|
+
var c = str.charCodeAt(i); // possibly a lead surrogate
|
|
2232
|
+
if (c <= 0x7F) {
|
|
2233
|
+
len++;
|
|
2234
|
+
}
|
|
2235
|
+
else if (c <= 0x7FF) {
|
|
2236
|
+
len += 2;
|
|
2237
|
+
}
|
|
2238
|
+
else if (c >= 0xD800 && c <= 0xDFFF) {
|
|
2239
|
+
len += 4;
|
|
2240
|
+
++i;
|
|
2241
|
+
}
|
|
2242
|
+
else {
|
|
2243
|
+
len += 3;
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
return len;
|
|
2247
|
+
};
|
|
2248
|
+
var __embind_register_std_string = (rawType, name) => {
|
|
2352
2249
|
name = readLatin1String(name);
|
|
2353
2250
|
var stdStringIsUTF8
|
|
2354
2251
|
//process only std::string bindings with UTF8 support, in contrast to e.g. std::basic_string<unsigned char>
|
|
2355
2252
|
= (name === "std::string");
|
|
2356
2253
|
registerType(rawType, {
|
|
2357
|
-
name
|
|
2358
|
-
|
|
2254
|
+
name,
|
|
2255
|
+
// For some method names we use string keys here since they are part of
|
|
2256
|
+
// the public/external API and/or used by the runtime-generated code.
|
|
2257
|
+
'fromWireType'(value) {
|
|
2359
2258
|
var length = HEAPU32[((value) >> 2)];
|
|
2360
2259
|
var payload = value + 4;
|
|
2361
2260
|
var str;
|
|
@@ -2388,7 +2287,7 @@ var Module = (() => {
|
|
|
2388
2287
|
_free(value);
|
|
2389
2288
|
return str;
|
|
2390
2289
|
},
|
|
2391
|
-
'toWireType'
|
|
2290
|
+
'toWireType'(destructors, value) {
|
|
2392
2291
|
if (value instanceof ArrayBuffer) {
|
|
2393
2292
|
value = new Uint8Array(value);
|
|
2394
2293
|
}
|
|
@@ -2403,7 +2302,7 @@ var Module = (() => {
|
|
|
2403
2302
|
else {
|
|
2404
2303
|
length = value.length;
|
|
2405
2304
|
}
|
|
2406
|
-
// assumes
|
|
2305
|
+
// assumes POINTER_SIZE alignment
|
|
2407
2306
|
var base = _malloc(4 + length + 1);
|
|
2408
2307
|
var ptr = base + 4;
|
|
2409
2308
|
HEAPU32[((base) >> 2)] = length;
|
|
@@ -2432,14 +2331,16 @@ var Module = (() => {
|
|
|
2432
2331
|
}
|
|
2433
2332
|
return base;
|
|
2434
2333
|
},
|
|
2435
|
-
'argPackAdvance':
|
|
2436
|
-
'readValueFromPointer':
|
|
2437
|
-
destructorFunction
|
|
2334
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
2335
|
+
'readValueFromPointer': readPointer,
|
|
2336
|
+
destructorFunction(ptr) {
|
|
2337
|
+
_free(ptr);
|
|
2338
|
+
},
|
|
2438
2339
|
});
|
|
2439
|
-
}
|
|
2340
|
+
};
|
|
2440
2341
|
var UTF16Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf-16le') : undefined;
|
|
2441
2342
|
;
|
|
2442
|
-
|
|
2343
|
+
var UTF16ToString = (ptr, maxBytesToRead) => {
|
|
2443
2344
|
var endPtr = ptr;
|
|
2444
2345
|
// TextDecoder needs to know the byte length in advance, it doesn't stop on
|
|
2445
2346
|
// null terminator by itself.
|
|
@@ -2468,12 +2369,10 @@ var Module = (() => {
|
|
|
2468
2369
|
str += String.fromCharCode(codeUnit);
|
|
2469
2370
|
}
|
|
2470
2371
|
return str;
|
|
2471
|
-
}
|
|
2472
|
-
|
|
2372
|
+
};
|
|
2373
|
+
var stringToUTF16 = (str, outPtr, maxBytesToWrite) => {
|
|
2473
2374
|
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
2474
|
-
|
|
2475
|
-
maxBytesToWrite = 0x7FFFFFFF;
|
|
2476
|
-
}
|
|
2375
|
+
maxBytesToWrite ??= 0x7FFFFFFF;
|
|
2477
2376
|
if (maxBytesToWrite < 2)
|
|
2478
2377
|
return 0;
|
|
2479
2378
|
maxBytesToWrite -= 2; // Null terminator.
|
|
@@ -2488,11 +2387,11 @@ var Module = (() => {
|
|
|
2488
2387
|
// Null-terminate the pointer to the HEAP.
|
|
2489
2388
|
HEAP16[((outPtr) >> 1)] = 0;
|
|
2490
2389
|
return outPtr - startPtr;
|
|
2491
|
-
}
|
|
2492
|
-
|
|
2390
|
+
};
|
|
2391
|
+
var lengthBytesUTF16 = (str) => {
|
|
2493
2392
|
return str.length * 2;
|
|
2494
|
-
}
|
|
2495
|
-
|
|
2393
|
+
};
|
|
2394
|
+
var UTF32ToString = (ptr, maxBytesToRead) => {
|
|
2496
2395
|
var i = 0;
|
|
2497
2396
|
var str = '';
|
|
2498
2397
|
// If maxBytesToRead is not passed explicitly, it will be undefined, and this
|
|
@@ -2513,12 +2412,10 @@ var Module = (() => {
|
|
|
2513
2412
|
}
|
|
2514
2413
|
}
|
|
2515
2414
|
return str;
|
|
2516
|
-
}
|
|
2517
|
-
|
|
2415
|
+
};
|
|
2416
|
+
var stringToUTF32 = (str, outPtr, maxBytesToWrite) => {
|
|
2518
2417
|
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
2519
|
-
|
|
2520
|
-
maxBytesToWrite = 0x7FFFFFFF;
|
|
2521
|
-
}
|
|
2418
|
+
maxBytesToWrite ??= 0x7FFFFFFF;
|
|
2522
2419
|
if (maxBytesToWrite < 4)
|
|
2523
2420
|
return 0;
|
|
2524
2421
|
var startPtr = outPtr;
|
|
@@ -2539,8 +2436,8 @@ var Module = (() => {
|
|
|
2539
2436
|
// Null-terminate the pointer to the HEAP.
|
|
2540
2437
|
HEAP32[((outPtr) >> 2)] = 0;
|
|
2541
2438
|
return outPtr - startPtr;
|
|
2542
|
-
}
|
|
2543
|
-
|
|
2439
|
+
};
|
|
2440
|
+
var lengthBytesUTF32 = (str) => {
|
|
2544
2441
|
var len = 0;
|
|
2545
2442
|
for (var i = 0; i < str.length; ++i) {
|
|
2546
2443
|
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
|
|
@@ -2551,36 +2448,33 @@ var Module = (() => {
|
|
|
2551
2448
|
len += 4;
|
|
2552
2449
|
}
|
|
2553
2450
|
return len;
|
|
2554
|
-
}
|
|
2555
|
-
|
|
2451
|
+
};
|
|
2452
|
+
var __embind_register_std_wstring = (rawType, charSize, name) => {
|
|
2556
2453
|
name = readLatin1String(name);
|
|
2557
|
-
var decodeString, encodeString,
|
|
2454
|
+
var decodeString, encodeString, readCharAt, lengthBytesUTF;
|
|
2558
2455
|
if (charSize === 2) {
|
|
2559
2456
|
decodeString = UTF16ToString;
|
|
2560
2457
|
encodeString = stringToUTF16;
|
|
2561
2458
|
lengthBytesUTF = lengthBytesUTF16;
|
|
2562
|
-
|
|
2563
|
-
shift = 1;
|
|
2459
|
+
readCharAt = (pointer) => HEAPU16[((pointer) >> 1)];
|
|
2564
2460
|
}
|
|
2565
2461
|
else if (charSize === 4) {
|
|
2566
2462
|
decodeString = UTF32ToString;
|
|
2567
2463
|
encodeString = stringToUTF32;
|
|
2568
2464
|
lengthBytesUTF = lengthBytesUTF32;
|
|
2569
|
-
|
|
2570
|
-
shift = 2;
|
|
2465
|
+
readCharAt = (pointer) => HEAPU32[((pointer) >> 2)];
|
|
2571
2466
|
}
|
|
2572
2467
|
registerType(rawType, {
|
|
2573
|
-
name
|
|
2574
|
-
'fromWireType':
|
|
2468
|
+
name,
|
|
2469
|
+
'fromWireType': (value) => {
|
|
2575
2470
|
// Code mostly taken from _embind_register_std_string fromWireType
|
|
2576
|
-
var length = HEAPU32[value >> 2];
|
|
2577
|
-
var HEAP = getHeap();
|
|
2471
|
+
var length = HEAPU32[((value) >> 2)];
|
|
2578
2472
|
var str;
|
|
2579
2473
|
var decodeStartPtr = value + 4;
|
|
2580
2474
|
// Looping here to support possible embedded '0' bytes
|
|
2581
2475
|
for (var i = 0; i <= length; ++i) {
|
|
2582
2476
|
var currentBytePtr = value + 4 + i * charSize;
|
|
2583
|
-
if (i == length ||
|
|
2477
|
+
if (i == length || readCharAt(currentBytePtr) == 0) {
|
|
2584
2478
|
var maxReadBytes = currentBytePtr - decodeStartPtr;
|
|
2585
2479
|
var stringSegment = decodeString(decodeStartPtr, maxReadBytes);
|
|
2586
2480
|
if (str === undefined) {
|
|
@@ -2596,202 +2490,176 @@ var Module = (() => {
|
|
|
2596
2490
|
_free(value);
|
|
2597
2491
|
return str;
|
|
2598
2492
|
},
|
|
2599
|
-
'toWireType':
|
|
2493
|
+
'toWireType': (destructors, value) => {
|
|
2600
2494
|
if (!(typeof value == 'string')) {
|
|
2601
|
-
throwBindingError(
|
|
2495
|
+
throwBindingError(`Cannot pass non-string to C++ string type ${name}`);
|
|
2602
2496
|
}
|
|
2603
|
-
// assumes
|
|
2497
|
+
// assumes POINTER_SIZE alignment
|
|
2604
2498
|
var length = lengthBytesUTF(value);
|
|
2605
2499
|
var ptr = _malloc(4 + length + charSize);
|
|
2606
|
-
HEAPU32[ptr >> 2] = length
|
|
2500
|
+
HEAPU32[((ptr) >> 2)] = length / charSize;
|
|
2607
2501
|
encodeString(value, ptr + 4, length + charSize);
|
|
2608
2502
|
if (destructors !== null) {
|
|
2609
2503
|
destructors.push(_free, ptr);
|
|
2610
2504
|
}
|
|
2611
2505
|
return ptr;
|
|
2612
2506
|
},
|
|
2613
|
-
'argPackAdvance':
|
|
2614
|
-
'readValueFromPointer':
|
|
2615
|
-
destructorFunction
|
|
2507
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
2508
|
+
'readValueFromPointer': readPointer,
|
|
2509
|
+
destructorFunction(ptr) {
|
|
2510
|
+
_free(ptr);
|
|
2511
|
+
}
|
|
2616
2512
|
});
|
|
2617
|
-
}
|
|
2618
|
-
|
|
2513
|
+
};
|
|
2514
|
+
var __embind_register_value_object = (rawType, name, constructorSignature, rawConstructor, destructorSignature, rawDestructor) => {
|
|
2619
2515
|
structRegistrations[rawType] = {
|
|
2620
2516
|
name: readLatin1String(name),
|
|
2621
2517
|
rawConstructor: embind__requireFunction(constructorSignature, rawConstructor),
|
|
2622
2518
|
rawDestructor: embind__requireFunction(destructorSignature, rawDestructor),
|
|
2623
2519
|
fields: [],
|
|
2624
2520
|
};
|
|
2625
|
-
}
|
|
2626
|
-
|
|
2521
|
+
};
|
|
2522
|
+
var __embind_register_value_object_field = (structType, fieldName, getterReturnType, getterSignature, getter, getterContext, setterArgumentType, setterSignature, setter, setterContext) => {
|
|
2627
2523
|
structRegistrations[structType].fields.push({
|
|
2628
2524
|
fieldName: readLatin1String(fieldName),
|
|
2629
|
-
getterReturnType
|
|
2525
|
+
getterReturnType,
|
|
2630
2526
|
getter: embind__requireFunction(getterSignature, getter),
|
|
2631
|
-
getterContext
|
|
2632
|
-
setterArgumentType
|
|
2527
|
+
getterContext,
|
|
2528
|
+
setterArgumentType,
|
|
2633
2529
|
setter: embind__requireFunction(setterSignature, setter),
|
|
2634
|
-
setterContext
|
|
2530
|
+
setterContext,
|
|
2635
2531
|
});
|
|
2636
|
-
}
|
|
2637
|
-
|
|
2532
|
+
};
|
|
2533
|
+
var __embind_register_void = (rawType, name) => {
|
|
2638
2534
|
name = readLatin1String(name);
|
|
2639
2535
|
registerType(rawType, {
|
|
2640
2536
|
isVoid: true, // void return values can be optimized out sometimes
|
|
2641
|
-
name
|
|
2537
|
+
name,
|
|
2642
2538
|
'argPackAdvance': 0,
|
|
2643
|
-
'fromWireType':
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
'toWireType': function (destructors, o) {
|
|
2647
|
-
// TODO: assert if anything else is given?
|
|
2648
|
-
return undefined;
|
|
2649
|
-
},
|
|
2539
|
+
'fromWireType': () => undefined,
|
|
2540
|
+
// TODO: assert if anything else is given?
|
|
2541
|
+
'toWireType': (destructors, o) => undefined,
|
|
2650
2542
|
});
|
|
2651
|
-
}
|
|
2652
|
-
|
|
2543
|
+
};
|
|
2544
|
+
var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
|
|
2545
|
+
var emval_returnValue = (returnType, destructorsRef, handle) => {
|
|
2546
|
+
var destructors = [];
|
|
2547
|
+
var result = returnType['toWireType'](destructors, handle);
|
|
2548
|
+
if (destructors.length) {
|
|
2549
|
+
// void, primitives and any other types w/o destructors don't need to allocate a handle
|
|
2550
|
+
HEAPU32[((destructorsRef) >> 2)] = Emval.toHandle(destructors);
|
|
2551
|
+
}
|
|
2552
|
+
return result;
|
|
2553
|
+
};
|
|
2554
|
+
var __emval_as = (handle, returnType, destructorsRef) => {
|
|
2653
2555
|
handle = Emval.toValue(handle);
|
|
2654
2556
|
returnType = requireRegisteredType(returnType, 'emval::as');
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
HEAPU32[((destructorsRef) >> 2)] = rd;
|
|
2658
|
-
return returnType['toWireType'](destructors, handle);
|
|
2659
|
-
}
|
|
2660
|
-
function emval_allocateDestructors(destructorsRef) {
|
|
2661
|
-
var destructors = [];
|
|
2662
|
-
HEAPU32[((destructorsRef) >> 2)] = Emval.toHandle(destructors);
|
|
2663
|
-
return destructors;
|
|
2664
|
-
}
|
|
2557
|
+
return emval_returnValue(returnType, destructorsRef, handle);
|
|
2558
|
+
};
|
|
2665
2559
|
var emval_symbols = {};
|
|
2666
|
-
|
|
2560
|
+
var getStringOrSymbol = (address) => {
|
|
2667
2561
|
var symbol = emval_symbols[address];
|
|
2668
2562
|
if (symbol === undefined) {
|
|
2669
2563
|
return readLatin1String(address);
|
|
2670
2564
|
}
|
|
2671
2565
|
return symbol;
|
|
2672
|
-
}
|
|
2566
|
+
};
|
|
2673
2567
|
var emval_methodCallers = [];
|
|
2674
|
-
|
|
2568
|
+
var __emval_call_method = (caller, objHandle, methodName, destructorsRef, args) => {
|
|
2675
2569
|
caller = emval_methodCallers[caller];
|
|
2676
|
-
|
|
2677
|
-
methodName = getStringOrSymbol(methodName);
|
|
2678
|
-
return caller(handle, methodName, emval_allocateDestructors(destructorsRef), args);
|
|
2679
|
-
}
|
|
2680
|
-
function __emval_call_void_method(caller, handle, methodName, args) {
|
|
2681
|
-
caller = emval_methodCallers[caller];
|
|
2682
|
-
handle = Emval.toValue(handle);
|
|
2570
|
+
objHandle = Emval.toValue(objHandle);
|
|
2683
2571
|
methodName = getStringOrSymbol(methodName);
|
|
2684
|
-
caller(
|
|
2685
|
-
}
|
|
2686
|
-
|
|
2572
|
+
return caller(objHandle, objHandle[methodName], destructorsRef, args);
|
|
2573
|
+
};
|
|
2574
|
+
var emval_addMethodCaller = (caller) => {
|
|
2687
2575
|
var id = emval_methodCallers.length;
|
|
2688
2576
|
emval_methodCallers.push(caller);
|
|
2689
2577
|
return id;
|
|
2690
|
-
}
|
|
2691
|
-
|
|
2578
|
+
};
|
|
2579
|
+
var emval_lookupTypes = (argCount, argTypes) => {
|
|
2692
2580
|
var a = new Array(argCount);
|
|
2693
2581
|
for (var i = 0; i < argCount; ++i) {
|
|
2694
2582
|
a[i] = requireRegisteredType(HEAPU32[(((argTypes) + (i * 4)) >> 2)], "parameter " + i);
|
|
2695
2583
|
}
|
|
2696
2584
|
return a;
|
|
2697
|
-
}
|
|
2698
|
-
var
|
|
2699
|
-
|
|
2585
|
+
};
|
|
2586
|
+
var reflectConstruct = Reflect.construct;
|
|
2587
|
+
var __emval_get_method_caller = (argCount, argTypes, kind) => {
|
|
2700
2588
|
var types = emval_lookupTypes(argCount, argTypes);
|
|
2701
|
-
var retType = types
|
|
2702
|
-
|
|
2703
|
-
var
|
|
2704
|
-
|
|
2705
|
-
|
|
2589
|
+
var retType = types.shift();
|
|
2590
|
+
argCount--; // remove the shifted off return type
|
|
2591
|
+
var functionBody = `return function (obj, func, destructorsRef, args) {\n`;
|
|
2592
|
+
var offset = 0;
|
|
2593
|
+
var argsList = []; // 'obj?, arg0, arg1, arg2, ... , argN'
|
|
2594
|
+
if (kind === /* FUNCTION */ 0) {
|
|
2595
|
+
argsList.push("obj");
|
|
2706
2596
|
}
|
|
2707
2597
|
var params = ["retType"];
|
|
2708
2598
|
var args = [retType];
|
|
2709
|
-
var
|
|
2710
|
-
|
|
2711
|
-
argsList += (i !== 0 ? ", " : "") + "arg" + i;
|
|
2599
|
+
for (var i = 0; i < argCount; ++i) {
|
|
2600
|
+
argsList.push("arg" + i);
|
|
2712
2601
|
params.push("argType" + i);
|
|
2713
|
-
args.push(types[
|
|
2714
|
-
}
|
|
2715
|
-
var functionName = makeLegalFunctionName("methodCaller_" + signatureName);
|
|
2716
|
-
var functionBody = "return function " + functionName + "(handle, name, destructors, args) {\n";
|
|
2717
|
-
var offset = 0;
|
|
2718
|
-
for (var i = 0; i < argCount - 1; ++i) {
|
|
2602
|
+
args.push(types[i]);
|
|
2719
2603
|
functionBody +=
|
|
2720
|
-
|
|
2721
|
-
offset += types[i
|
|
2604
|
+
` var arg${i} = argType${i}.readValueFromPointer(args${offset ? "+" + offset : ""});\n`;
|
|
2605
|
+
offset += types[i]['argPackAdvance'];
|
|
2722
2606
|
}
|
|
2607
|
+
var invoker = kind === /* CONSTRUCTOR */ 1 ? 'new func' : 'func.call';
|
|
2723
2608
|
functionBody +=
|
|
2724
|
-
|
|
2725
|
-
for (var i = 0; i < argCount - 1; ++i) {
|
|
2726
|
-
if (types[i + 1]['deleteObject']) {
|
|
2727
|
-
functionBody +=
|
|
2728
|
-
" argType" + i + ".deleteObject(arg" + i + ");\n";
|
|
2729
|
-
}
|
|
2730
|
-
}
|
|
2609
|
+
` var rv = ${invoker}(${argsList.join(", ")});\n`;
|
|
2731
2610
|
if (!retType.isVoid) {
|
|
2611
|
+
params.push("emval_returnValue");
|
|
2612
|
+
args.push(emval_returnValue);
|
|
2732
2613
|
functionBody +=
|
|
2733
|
-
"
|
|
2614
|
+
" return emval_returnValue(retType, destructorsRef, rv);\n";
|
|
2734
2615
|
}
|
|
2735
2616
|
functionBody +=
|
|
2736
2617
|
"};\n";
|
|
2737
2618
|
params.push(functionBody);
|
|
2738
|
-
var invokerFunction =
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
function __emval_get_property(handle, key) {
|
|
2619
|
+
var invokerFunction = newFunc(Function, params)(...args);
|
|
2620
|
+
var functionName = `methodCaller<(${types.map(t => t.name).join(', ')}) => ${retType.name}>`;
|
|
2621
|
+
return emval_addMethodCaller(createNamedFunction(functionName, invokerFunction));
|
|
2622
|
+
};
|
|
2623
|
+
var __emval_get_property = (handle, key) => {
|
|
2744
2624
|
handle = Emval.toValue(handle);
|
|
2745
2625
|
key = Emval.toValue(key);
|
|
2746
2626
|
return Emval.toHandle(handle[key]);
|
|
2747
|
-
}
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
emval_handle_array[handle].refcount += 1;
|
|
2751
|
-
}
|
|
2752
|
-
}
|
|
2753
|
-
function __emval_new_array() {
|
|
2754
|
-
return Emval.toHandle([]);
|
|
2755
|
-
}
|
|
2756
|
-
function __emval_new_array_from_memory_view(view) {
|
|
2627
|
+
};
|
|
2628
|
+
var __emval_new_array = () => Emval.toHandle([]);
|
|
2629
|
+
var __emval_new_array_from_memory_view = (view) => {
|
|
2757
2630
|
view = Emval.toValue(view);
|
|
2758
2631
|
// using for..loop is faster than Array.from
|
|
2759
2632
|
var a = new Array(view.length);
|
|
2760
2633
|
for (var i = 0; i < view.length; i++)
|
|
2761
2634
|
a[i] = view[i];
|
|
2762
2635
|
return Emval.toHandle(a);
|
|
2763
|
-
}
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
}
|
|
2767
|
-
function __emval_run_destructors(handle) {
|
|
2636
|
+
};
|
|
2637
|
+
var __emval_new_cstring = (v) => Emval.toHandle(getStringOrSymbol(v));
|
|
2638
|
+
var __emval_run_destructors = (handle) => {
|
|
2768
2639
|
var destructors = Emval.toValue(handle);
|
|
2769
2640
|
runDestructors(destructors);
|
|
2770
2641
|
__emval_decref(handle);
|
|
2771
|
-
}
|
|
2772
|
-
|
|
2642
|
+
};
|
|
2643
|
+
var __emval_take_value = (type, arg) => {
|
|
2773
2644
|
type = requireRegisteredType(type, '_emval_take_value');
|
|
2774
2645
|
var v = type['readValueFromPointer'](arg);
|
|
2775
2646
|
return Emval.toHandle(v);
|
|
2776
|
-
}
|
|
2777
|
-
|
|
2647
|
+
};
|
|
2648
|
+
var _abort = () => {
|
|
2778
2649
|
abort('');
|
|
2779
|
-
}
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
// casing all heap size related code to treat 0 specially.
|
|
2788
|
-
return 2147483648;
|
|
2789
|
-
}
|
|
2790
|
-
function emscripten_realloc_buffer(size) {
|
|
2650
|
+
};
|
|
2651
|
+
var getHeapMax = () =>
|
|
2652
|
+
// Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
|
|
2653
|
+
// full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
|
|
2654
|
+
// for any code that deals with heap sizes, which would require special
|
|
2655
|
+
// casing all heap size related code to treat 0 specially.
|
|
2656
|
+
2147483648;
|
|
2657
|
+
var growMemory = (size) => {
|
|
2791
2658
|
var b = wasmMemory.buffer;
|
|
2659
|
+
var pages = (size - b.byteLength + 65535) / 65536;
|
|
2792
2660
|
try {
|
|
2793
2661
|
// round size grow request up to wasm page size (fixed 64KB per spec)
|
|
2794
|
-
wasmMemory.grow(
|
|
2662
|
+
wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size
|
|
2795
2663
|
updateMemoryViews();
|
|
2796
2664
|
return 1 /*success*/;
|
|
2797
2665
|
}
|
|
@@ -2799,10 +2667,11 @@ var Module = (() => {
|
|
|
2799
2667
|
}
|
|
2800
2668
|
// implicit 0 return to save code size (caller will cast "undefined" into 0
|
|
2801
2669
|
// anyhow)
|
|
2802
|
-
}
|
|
2803
|
-
|
|
2670
|
+
};
|
|
2671
|
+
var _emscripten_resize_heap = (requestedSize) => {
|
|
2804
2672
|
var oldSize = HEAPU8.length;
|
|
2805
|
-
|
|
2673
|
+
// With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
|
|
2674
|
+
requestedSize >>>= 0;
|
|
2806
2675
|
// With multithreaded builds, races can happen (another thread might increase the size
|
|
2807
2676
|
// in between), so return a failure, and let the caller retry.
|
|
2808
2677
|
// Memory resize rules:
|
|
@@ -2827,7 +2696,7 @@ var Module = (() => {
|
|
|
2827
2696
|
if (requestedSize > maxHeapSize) {
|
|
2828
2697
|
return false;
|
|
2829
2698
|
}
|
|
2830
|
-
|
|
2699
|
+
var alignUp = (x, multiple) => x + (multiple - x % multiple) % multiple;
|
|
2831
2700
|
// Loop through potential heap size increases. If we attempt a too eager
|
|
2832
2701
|
// reservation that fails, cut down on the attempted size and reserve a
|
|
2833
2702
|
// smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
|
|
@@ -2836,18 +2705,18 @@ var Module = (() => {
|
|
|
2836
2705
|
// but limit overreserving (default to capping at +96MB overgrowth at most)
|
|
2837
2706
|
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
|
|
2838
2707
|
var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
|
|
2839
|
-
var replacement =
|
|
2708
|
+
var replacement = growMemory(newSize);
|
|
2840
2709
|
if (replacement) {
|
|
2841
2710
|
return true;
|
|
2842
2711
|
}
|
|
2843
2712
|
}
|
|
2844
2713
|
return false;
|
|
2845
|
-
}
|
|
2714
|
+
};
|
|
2846
2715
|
var ENV = {};
|
|
2847
|
-
|
|
2716
|
+
var getExecutableName = () => {
|
|
2848
2717
|
return thisProgram || './this.program';
|
|
2849
|
-
}
|
|
2850
|
-
|
|
2718
|
+
};
|
|
2719
|
+
var getEnvStrings = () => {
|
|
2851
2720
|
if (!getEnvStrings.strings) {
|
|
2852
2721
|
// Default values.
|
|
2853
2722
|
// Browser language detection #8751
|
|
@@ -2873,67 +2742,53 @@ var Module = (() => {
|
|
|
2873
2742
|
}
|
|
2874
2743
|
var strings = [];
|
|
2875
2744
|
for (var x in env) {
|
|
2876
|
-
strings.push(x
|
|
2745
|
+
strings.push(`${x}=${env[x]}`);
|
|
2877
2746
|
}
|
|
2878
2747
|
getEnvStrings.strings = strings;
|
|
2879
2748
|
}
|
|
2880
2749
|
return getEnvStrings.strings;
|
|
2881
|
-
}
|
|
2882
|
-
|
|
2883
|
-
function writeAsciiToMemory(str, buffer, dontAddNull) {
|
|
2750
|
+
};
|
|
2751
|
+
var stringToAscii = (str, buffer) => {
|
|
2884
2752
|
for (var i = 0; i < str.length; ++i) {
|
|
2885
|
-
HEAP8[
|
|
2753
|
+
HEAP8[buffer++] = str.charCodeAt(i);
|
|
2886
2754
|
}
|
|
2887
|
-
// Null-terminate the
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
var SYSCALLS = { varargs: undefined, get: function () {
|
|
2892
|
-
SYSCALLS.varargs += 4;
|
|
2893
|
-
var ret = HEAP32[(((SYSCALLS.varargs) - (4)) >> 2)];
|
|
2894
|
-
return ret;
|
|
2895
|
-
}, getStr: function (ptr) {
|
|
2896
|
-
var ret = UTF8ToString(ptr);
|
|
2897
|
-
return ret;
|
|
2898
|
-
} };
|
|
2899
|
-
function _environ_get(__environ, environ_buf) {
|
|
2755
|
+
// Null-terminate the string
|
|
2756
|
+
HEAP8[buffer] = 0;
|
|
2757
|
+
};
|
|
2758
|
+
var _environ_get = (__environ, environ_buf) => {
|
|
2900
2759
|
var bufSize = 0;
|
|
2901
|
-
getEnvStrings().forEach(
|
|
2760
|
+
getEnvStrings().forEach((string, i) => {
|
|
2902
2761
|
var ptr = environ_buf + bufSize;
|
|
2903
2762
|
HEAPU32[(((__environ) + (i * 4)) >> 2)] = ptr;
|
|
2904
|
-
|
|
2763
|
+
stringToAscii(string, ptr);
|
|
2905
2764
|
bufSize += string.length + 1;
|
|
2906
2765
|
});
|
|
2907
2766
|
return 0;
|
|
2908
|
-
}
|
|
2909
|
-
|
|
2767
|
+
};
|
|
2768
|
+
var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
|
|
2910
2769
|
var strings = getEnvStrings();
|
|
2911
2770
|
HEAPU32[((penviron_count) >> 2)] = strings.length;
|
|
2912
2771
|
var bufSize = 0;
|
|
2913
|
-
strings.forEach(
|
|
2914
|
-
bufSize += string.length + 1;
|
|
2915
|
-
});
|
|
2772
|
+
strings.forEach((string) => bufSize += string.length + 1);
|
|
2916
2773
|
HEAPU32[((penviron_buf_size) >> 2)] = bufSize;
|
|
2917
2774
|
return 0;
|
|
2918
|
-
}
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
}
|
|
2922
|
-
function __arraySum(array, index) {
|
|
2775
|
+
};
|
|
2776
|
+
var isLeapYear = (year) => year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
2777
|
+
var arraySum = (array, index) => {
|
|
2923
2778
|
var sum = 0;
|
|
2924
2779
|
for (var i = 0; i <= index; sum += array[i++]) {
|
|
2925
2780
|
// no-op
|
|
2926
2781
|
}
|
|
2927
2782
|
return sum;
|
|
2928
|
-
}
|
|
2929
|
-
var
|
|
2930
|
-
var
|
|
2931
|
-
|
|
2783
|
+
};
|
|
2784
|
+
var MONTH_DAYS_LEAP = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
2785
|
+
var MONTH_DAYS_REGULAR = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
2786
|
+
var addDays = (date, days) => {
|
|
2932
2787
|
var newDate = new Date(date.getTime());
|
|
2933
2788
|
while (days > 0) {
|
|
2934
|
-
var leap =
|
|
2789
|
+
var leap = isLeapYear(newDate.getFullYear());
|
|
2935
2790
|
var currentMonth = newDate.getMonth();
|
|
2936
|
-
var daysInCurrentMonth = (leap ?
|
|
2791
|
+
var daysInCurrentMonth = (leap ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR)[currentMonth];
|
|
2937
2792
|
if (days > daysInCurrentMonth - newDate.getDate()) {
|
|
2938
2793
|
// we spill over to next month
|
|
2939
2794
|
days -= (daysInCurrentMonth - newDate.getDate() + 1);
|
|
@@ -2953,7 +2808,7 @@ var Module = (() => {
|
|
|
2953
2808
|
}
|
|
2954
2809
|
}
|
|
2955
2810
|
return newDate;
|
|
2956
|
-
}
|
|
2811
|
+
};
|
|
2957
2812
|
/** @type {function(string, boolean=, number=)} */
|
|
2958
2813
|
function intArrayFromString(stringy, dontAddNull, length) {
|
|
2959
2814
|
var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;
|
|
@@ -2963,13 +2818,13 @@ var Module = (() => {
|
|
|
2963
2818
|
u8array.length = numBytesWritten;
|
|
2964
2819
|
return u8array;
|
|
2965
2820
|
}
|
|
2966
|
-
|
|
2821
|
+
var writeArrayToMemory = (array, buffer) => {
|
|
2967
2822
|
HEAP8.set(array, buffer);
|
|
2968
|
-
}
|
|
2969
|
-
|
|
2823
|
+
};
|
|
2824
|
+
var _strftime = (s, maxsize, format, tm) => {
|
|
2970
2825
|
// size_t strftime(char *restrict s, size_t maxsize, const char *restrict format, const struct tm *restrict timeptr);
|
|
2971
2826
|
// http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html
|
|
2972
|
-
var tm_zone =
|
|
2827
|
+
var tm_zone = HEAPU32[(((tm) + (40)) >> 2)];
|
|
2973
2828
|
var date = {
|
|
2974
2829
|
tm_sec: HEAP32[((tm) >> 2)],
|
|
2975
2830
|
tm_min: HEAP32[(((tm) + (4)) >> 2)],
|
|
@@ -3062,7 +2917,7 @@ var Module = (() => {
|
|
|
3062
2917
|
}
|
|
3063
2918
|
}
|
|
3064
2919
|
function getWeekBasedYear(date) {
|
|
3065
|
-
var thisDate =
|
|
2920
|
+
var thisDate = addDays(new Date(date.tm_year + 1900, 0, 1), date.tm_yday);
|
|
3066
2921
|
var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4);
|
|
3067
2922
|
var janFourthNextYear = new Date(thisDate.getFullYear() + 1, 0, 4);
|
|
3068
2923
|
var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);
|
|
@@ -3077,29 +2932,17 @@ var Module = (() => {
|
|
|
3077
2932
|
return thisDate.getFullYear() - 1;
|
|
3078
2933
|
}
|
|
3079
2934
|
var EXPANSION_RULES_2 = {
|
|
3080
|
-
'%a':
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
'%
|
|
3084
|
-
|
|
3085
|
-
},
|
|
3086
|
-
'%b': function (date) {
|
|
3087
|
-
return MONTHS[date.tm_mon].substring(0, 3);
|
|
3088
|
-
},
|
|
3089
|
-
'%B': function (date) {
|
|
3090
|
-
return MONTHS[date.tm_mon];
|
|
3091
|
-
},
|
|
3092
|
-
'%C': function (date) {
|
|
2935
|
+
'%a': (date) => WEEKDAYS[date.tm_wday].substring(0, 3),
|
|
2936
|
+
'%A': (date) => WEEKDAYS[date.tm_wday],
|
|
2937
|
+
'%b': (date) => MONTHS[date.tm_mon].substring(0, 3),
|
|
2938
|
+
'%B': (date) => MONTHS[date.tm_mon],
|
|
2939
|
+
'%C': (date) => {
|
|
3093
2940
|
var year = date.tm_year + 1900;
|
|
3094
2941
|
return leadingNulls((year / 100) | 0, 2);
|
|
3095
2942
|
},
|
|
3096
|
-
'%d':
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
'%e': function (date) {
|
|
3100
|
-
return leadingSomething(date.tm_mday, 2, ' ');
|
|
3101
|
-
},
|
|
3102
|
-
'%g': function (date) {
|
|
2943
|
+
'%d': (date) => leadingNulls(date.tm_mday, 2),
|
|
2944
|
+
'%e': (date) => leadingSomething(date.tm_mday, 2, ' '),
|
|
2945
|
+
'%g': (date) => {
|
|
3103
2946
|
// %g, %G, and %V give values according to the ISO 8601:2000 standard week-based year.
|
|
3104
2947
|
// In this system, weeks begin on a Monday and week 1 of the year is the week that includes
|
|
3105
2948
|
// January 4th, which is also the week that includes the first Thursday of the year, and
|
|
@@ -3111,13 +2954,9 @@ var Module = (() => {
|
|
|
3111
2954
|
// Thus, for Tuesday 30th December 1997, %G is replaced by 1998 and %V is replaced by 01.
|
|
3112
2955
|
return getWeekBasedYear(date).toString().substring(2);
|
|
3113
2956
|
},
|
|
3114
|
-
'%G':
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
'%H': function (date) {
|
|
3118
|
-
return leadingNulls(date.tm_hour, 2);
|
|
3119
|
-
},
|
|
3120
|
-
'%I': function (date) {
|
|
2957
|
+
'%G': getWeekBasedYear,
|
|
2958
|
+
'%H': (date) => leadingNulls(date.tm_hour, 2),
|
|
2959
|
+
'%I': (date) => {
|
|
3121
2960
|
var twelveHour = date.tm_hour;
|
|
3122
2961
|
if (twelveHour == 0)
|
|
3123
2962
|
twelveHour = 12;
|
|
@@ -3125,39 +2964,27 @@ var Module = (() => {
|
|
|
3125
2964
|
twelveHour -= 12;
|
|
3126
2965
|
return leadingNulls(twelveHour, 2);
|
|
3127
2966
|
},
|
|
3128
|
-
'%j':
|
|
2967
|
+
'%j': (date) => {
|
|
3129
2968
|
// Day of the year (001-366)
|
|
3130
|
-
return leadingNulls(date.tm_mday +
|
|
3131
|
-
},
|
|
3132
|
-
'%m': function (date) {
|
|
3133
|
-
return leadingNulls(date.tm_mon + 1, 2);
|
|
3134
|
-
},
|
|
3135
|
-
'%M': function (date) {
|
|
3136
|
-
return leadingNulls(date.tm_min, 2);
|
|
2969
|
+
return leadingNulls(date.tm_mday + arraySum(isLeapYear(date.tm_year + 1900) ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR, date.tm_mon - 1), 3);
|
|
3137
2970
|
},
|
|
3138
|
-
'%
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
'%p':
|
|
2971
|
+
'%m': (date) => leadingNulls(date.tm_mon + 1, 2),
|
|
2972
|
+
'%M': (date) => leadingNulls(date.tm_min, 2),
|
|
2973
|
+
'%n': () => '\n',
|
|
2974
|
+
'%p': (date) => {
|
|
3142
2975
|
if (date.tm_hour >= 0 && date.tm_hour < 12) {
|
|
3143
2976
|
return 'AM';
|
|
3144
2977
|
}
|
|
3145
2978
|
return 'PM';
|
|
3146
2979
|
},
|
|
3147
|
-
'%S':
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
'%
|
|
3151
|
-
return '\t';
|
|
3152
|
-
},
|
|
3153
|
-
'%u': function (date) {
|
|
3154
|
-
return date.tm_wday || 7;
|
|
3155
|
-
},
|
|
3156
|
-
'%U': function (date) {
|
|
2980
|
+
'%S': (date) => leadingNulls(date.tm_sec, 2),
|
|
2981
|
+
'%t': () => '\t',
|
|
2982
|
+
'%u': (date) => date.tm_wday || 7,
|
|
2983
|
+
'%U': (date) => {
|
|
3157
2984
|
var days = date.tm_yday + 7 - date.tm_wday;
|
|
3158
2985
|
return leadingNulls(Math.floor(days / 7), 2);
|
|
3159
2986
|
},
|
|
3160
|
-
'%V':
|
|
2987
|
+
'%V': (date) => {
|
|
3161
2988
|
// Replaced by the week number of the year (Monday as the first day of the week)
|
|
3162
2989
|
// as a decimal number [01,53]. If the week containing 1 January has four
|
|
3163
2990
|
// or more days in the new year, then it is considered week 1.
|
|
@@ -3174,7 +3001,7 @@ var Module = (() => {
|
|
|
3174
3001
|
// If 31 December of prev year a Thursday, or Friday of a
|
|
3175
3002
|
// leap year, then the prev year has 53 weeks.
|
|
3176
3003
|
var dec31 = (date.tm_wday + 7 - date.tm_yday - 1) % 7;
|
|
3177
|
-
if (dec31 == 4 || (dec31 == 5 &&
|
|
3004
|
+
if (dec31 == 4 || (dec31 == 5 && isLeapYear(date.tm_year % 400 - 1))) {
|
|
3178
3005
|
val++;
|
|
3179
3006
|
}
|
|
3180
3007
|
}
|
|
@@ -3182,27 +3009,23 @@ var Module = (() => {
|
|
|
3182
3009
|
// If 1 January is not a Thursday, and not a Wednesday of a
|
|
3183
3010
|
// leap year, then this year has only 52 weeks.
|
|
3184
3011
|
var jan1 = (date.tm_wday + 371 - date.tm_yday) % 7;
|
|
3185
|
-
if (jan1 != 4 && (jan1 != 3 || !
|
|
3012
|
+
if (jan1 != 4 && (jan1 != 3 || !isLeapYear(date.tm_year)))
|
|
3186
3013
|
val = 1;
|
|
3187
3014
|
}
|
|
3188
3015
|
return leadingNulls(val, 2);
|
|
3189
3016
|
},
|
|
3190
|
-
'%w':
|
|
3191
|
-
|
|
3192
|
-
},
|
|
3193
|
-
'%W': function (date) {
|
|
3017
|
+
'%w': (date) => date.tm_wday,
|
|
3018
|
+
'%W': (date) => {
|
|
3194
3019
|
var days = date.tm_yday + 7 - ((date.tm_wday + 6) % 7);
|
|
3195
3020
|
return leadingNulls(Math.floor(days / 7), 2);
|
|
3196
3021
|
},
|
|
3197
|
-
'%y':
|
|
3022
|
+
'%y': (date) => {
|
|
3198
3023
|
// Replaced by the last two digits of the year as a decimal number [00,99]. [ tm_year]
|
|
3199
3024
|
return (date.tm_year + 1900).toString().substring(2);
|
|
3200
3025
|
},
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
},
|
|
3205
|
-
'%z': function (date) {
|
|
3026
|
+
// Replaced by the year as a decimal number (for example, 1997). [ tm_year]
|
|
3027
|
+
'%Y': (date) => date.tm_year + 1900,
|
|
3028
|
+
'%z': (date) => {
|
|
3206
3029
|
// Replaced by the offset from UTC in the ISO 8601:2000 standard format ( +hhmm or -hhmm ).
|
|
3207
3030
|
// For example, "-0430" means 4 hours 30 minutes behind UTC (west of Greenwich).
|
|
3208
3031
|
var off = date.tm_gmtoff;
|
|
@@ -3212,12 +3035,8 @@ var Module = (() => {
|
|
|
3212
3035
|
off = (off / 60) * 100 + (off % 60);
|
|
3213
3036
|
return (ahead ? '+' : '-') + String("0000" + off).slice(-4);
|
|
3214
3037
|
},
|
|
3215
|
-
'%Z':
|
|
3216
|
-
|
|
3217
|
-
},
|
|
3218
|
-
'%%': function () {
|
|
3219
|
-
return '%';
|
|
3220
|
-
}
|
|
3038
|
+
'%Z': (date) => date.tm_zone,
|
|
3039
|
+
'%%': () => '%'
|
|
3221
3040
|
};
|
|
3222
3041
|
// Replace %% with a pair of NULLs (which cannot occur in a C string), then
|
|
3223
3042
|
// re-inject them after processing.
|
|
@@ -3234,12 +3053,13 @@ var Module = (() => {
|
|
|
3234
3053
|
}
|
|
3235
3054
|
writeArrayToMemory(bytes, s);
|
|
3236
3055
|
return bytes.length - 1;
|
|
3237
|
-
}
|
|
3238
|
-
|
|
3056
|
+
};
|
|
3057
|
+
var _strftime_l = (s, maxsize, format, tm, loc) => {
|
|
3239
3058
|
return _strftime(s, maxsize, format, tm); // no locale support yet
|
|
3240
|
-
}
|
|
3241
|
-
BindingError = Module['BindingError'] =
|
|
3242
|
-
|
|
3059
|
+
};
|
|
3060
|
+
BindingError = Module['BindingError'] = class BindingError extends Error {
|
|
3061
|
+
constructor(message) { super(message); this.name = 'BindingError'; }
|
|
3062
|
+
};
|
|
3243
3063
|
init_emval();
|
|
3244
3064
|
;
|
|
3245
3065
|
PureVirtualError = Module['PureVirtualError'] = extendError(Error, 'PureVirtualError');
|
|
@@ -3247,120 +3067,105 @@ var Module = (() => {
|
|
|
3247
3067
|
embind_init_charCodes();
|
|
3248
3068
|
init_embind();
|
|
3249
3069
|
;
|
|
3250
|
-
InternalError = Module['InternalError'] =
|
|
3251
|
-
|
|
3070
|
+
InternalError = Module['InternalError'] = class InternalError extends Error {
|
|
3071
|
+
constructor(message) { super(message); this.name = 'InternalError'; }
|
|
3072
|
+
};
|
|
3252
3073
|
init_ClassHandle();
|
|
3253
3074
|
init_RegisteredPointer();
|
|
3254
3075
|
UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');
|
|
3255
3076
|
;
|
|
3256
3077
|
var wasmImports = {
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
/** @type {function(...*):?} */
|
|
3330
|
-
var ___trap = function () {
|
|
3331
|
-
return (___trap = Module["asm"]["__trap"]).apply(null, arguments);
|
|
3332
|
-
};
|
|
3333
|
-
/** @type {function(...*):?} */
|
|
3334
|
-
var stackSave = function () {
|
|
3335
|
-
return (stackSave = Module["asm"]["stackSave"]).apply(null, arguments);
|
|
3336
|
-
};
|
|
3337
|
-
/** @type {function(...*):?} */
|
|
3338
|
-
var stackRestore = function () {
|
|
3339
|
-
return (stackRestore = Module["asm"]["stackRestore"]).apply(null, arguments);
|
|
3340
|
-
};
|
|
3341
|
-
/** @type {function(...*):?} */
|
|
3342
|
-
var stackAlloc = function () {
|
|
3343
|
-
return (stackAlloc = Module["asm"]["stackAlloc"]).apply(null, arguments);
|
|
3344
|
-
};
|
|
3345
|
-
/** @type {function(...*):?} */
|
|
3346
|
-
var dynCall_viijii = Module["dynCall_viijii"] = function () {
|
|
3347
|
-
return (dynCall_viijii = Module["dynCall_viijii"] = Module["asm"]["dynCall_viijii"]).apply(null, arguments);
|
|
3348
|
-
};
|
|
3349
|
-
/** @type {function(...*):?} */
|
|
3350
|
-
var dynCall_iiiiij = Module["dynCall_iiiiij"] = function () {
|
|
3351
|
-
return (dynCall_iiiiij = Module["dynCall_iiiiij"] = Module["asm"]["dynCall_iiiiij"]).apply(null, arguments);
|
|
3352
|
-
};
|
|
3353
|
-
/** @type {function(...*):?} */
|
|
3354
|
-
var dynCall_iiiiijj = Module["dynCall_iiiiijj"] = function () {
|
|
3355
|
-
return (dynCall_iiiiijj = Module["dynCall_iiiiijj"] = Module["asm"]["dynCall_iiiiijj"]).apply(null, arguments);
|
|
3356
|
-
};
|
|
3357
|
-
/** @type {function(...*):?} */
|
|
3358
|
-
var dynCall_iiiiiijj = Module["dynCall_iiiiiijj"] = function () {
|
|
3359
|
-
return (dynCall_iiiiiijj = Module["dynCall_iiiiiijj"] = Module["asm"]["dynCall_iiiiiijj"]).apply(null, arguments);
|
|
3078
|
+
/** @export */
|
|
3079
|
+
__assert_fail: ___assert_fail,
|
|
3080
|
+
/** @export */
|
|
3081
|
+
_embind_create_inheriting_constructor: __embind_create_inheriting_constructor,
|
|
3082
|
+
/** @export */
|
|
3083
|
+
_embind_finalize_value_object: __embind_finalize_value_object,
|
|
3084
|
+
/** @export */
|
|
3085
|
+
_embind_register_bigint: __embind_register_bigint,
|
|
3086
|
+
/** @export */
|
|
3087
|
+
_embind_register_bool: __embind_register_bool,
|
|
3088
|
+
/** @export */
|
|
3089
|
+
_embind_register_class: __embind_register_class,
|
|
3090
|
+
/** @export */
|
|
3091
|
+
_embind_register_class_class_function: __embind_register_class_class_function,
|
|
3092
|
+
/** @export */
|
|
3093
|
+
_embind_register_class_constructor: __embind_register_class_constructor,
|
|
3094
|
+
/** @export */
|
|
3095
|
+
_embind_register_class_function: __embind_register_class_function,
|
|
3096
|
+
/** @export */
|
|
3097
|
+
_embind_register_class_property: __embind_register_class_property,
|
|
3098
|
+
/** @export */
|
|
3099
|
+
_embind_register_emval: __embind_register_emval,
|
|
3100
|
+
/** @export */
|
|
3101
|
+
_embind_register_float: __embind_register_float,
|
|
3102
|
+
/** @export */
|
|
3103
|
+
_embind_register_function: __embind_register_function,
|
|
3104
|
+
/** @export */
|
|
3105
|
+
_embind_register_integer: __embind_register_integer,
|
|
3106
|
+
/** @export */
|
|
3107
|
+
_embind_register_memory_view: __embind_register_memory_view,
|
|
3108
|
+
/** @export */
|
|
3109
|
+
_embind_register_std_string: __embind_register_std_string,
|
|
3110
|
+
/** @export */
|
|
3111
|
+
_embind_register_std_wstring: __embind_register_std_wstring,
|
|
3112
|
+
/** @export */
|
|
3113
|
+
_embind_register_value_object: __embind_register_value_object,
|
|
3114
|
+
/** @export */
|
|
3115
|
+
_embind_register_value_object_field: __embind_register_value_object_field,
|
|
3116
|
+
/** @export */
|
|
3117
|
+
_embind_register_void: __embind_register_void,
|
|
3118
|
+
/** @export */
|
|
3119
|
+
_emscripten_memcpy_js: __emscripten_memcpy_js,
|
|
3120
|
+
/** @export */
|
|
3121
|
+
_emval_as: __emval_as,
|
|
3122
|
+
/** @export */
|
|
3123
|
+
_emval_call_method: __emval_call_method,
|
|
3124
|
+
/** @export */
|
|
3125
|
+
_emval_decref: __emval_decref,
|
|
3126
|
+
/** @export */
|
|
3127
|
+
_emval_get_method_caller: __emval_get_method_caller,
|
|
3128
|
+
/** @export */
|
|
3129
|
+
_emval_get_property: __emval_get_property,
|
|
3130
|
+
/** @export */
|
|
3131
|
+
_emval_new_array: __emval_new_array,
|
|
3132
|
+
/** @export */
|
|
3133
|
+
_emval_new_array_from_memory_view: __emval_new_array_from_memory_view,
|
|
3134
|
+
/** @export */
|
|
3135
|
+
_emval_new_cstring: __emval_new_cstring,
|
|
3136
|
+
/** @export */
|
|
3137
|
+
_emval_run_destructors: __emval_run_destructors,
|
|
3138
|
+
/** @export */
|
|
3139
|
+
_emval_take_value: __emval_take_value,
|
|
3140
|
+
/** @export */
|
|
3141
|
+
abort: _abort,
|
|
3142
|
+
/** @export */
|
|
3143
|
+
emscripten_resize_heap: _emscripten_resize_heap,
|
|
3144
|
+
/** @export */
|
|
3145
|
+
environ_get: _environ_get,
|
|
3146
|
+
/** @export */
|
|
3147
|
+
environ_sizes_get: _environ_sizes_get,
|
|
3148
|
+
/** @export */
|
|
3149
|
+
strftime_l: _strftime_l
|
|
3360
3150
|
};
|
|
3151
|
+
var wasmExports = createWasm();
|
|
3152
|
+
var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports['__wasm_call_ctors'])();
|
|
3153
|
+
var _kmcmp_CompileKeyboard = Module['_kmcmp_CompileKeyboard'] = (a0, a1, a2, a3, a4, a5) => (_kmcmp_CompileKeyboard = Module['_kmcmp_CompileKeyboard'] = wasmExports['kmcmp_CompileKeyboard'])(a0, a1, a2, a3, a4, a5);
|
|
3154
|
+
var _kmcmp_parseUnicodeSet = Module['_kmcmp_parseUnicodeSet'] = (a0, a1, a2) => (_kmcmp_parseUnicodeSet = Module['_kmcmp_parseUnicodeSet'] = wasmExports['kmcmp_parseUnicodeSet'])(a0, a1, a2);
|
|
3155
|
+
var _malloc = (a0) => (_malloc = wasmExports['malloc'])(a0);
|
|
3156
|
+
var _free = (a0) => (_free = wasmExports['free'])(a0);
|
|
3157
|
+
var ___getTypeName = (a0) => (___getTypeName = wasmExports['__getTypeName'])(a0);
|
|
3158
|
+
var ___trap = () => (___trap = wasmExports['__trap'])();
|
|
3159
|
+
var __emscripten_tempret_set = (a0) => (__emscripten_tempret_set = wasmExports['_emscripten_tempret_set'])(a0);
|
|
3160
|
+
var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'])(a0);
|
|
3161
|
+
var dynCall_viijii = Module['dynCall_viijii'] = (a0, a1, a2, a3, a4, a5, a6) => (dynCall_viijii = Module['dynCall_viijii'] = wasmExports['dynCall_viijii'])(a0, a1, a2, a3, a4, a5, a6);
|
|
3162
|
+
var dynCall_iiiiij = Module['dynCall_iiiiij'] = (a0, a1, a2, a3, a4, a5, a6) => (dynCall_iiiiij = Module['dynCall_iiiiij'] = wasmExports['dynCall_iiiiij'])(a0, a1, a2, a3, a4, a5, a6);
|
|
3163
|
+
var dynCall_iiiiijj = Module['dynCall_iiiiijj'] = (a0, a1, a2, a3, a4, a5, a6, a7, a8) => (dynCall_iiiiijj = Module['dynCall_iiiiijj'] = wasmExports['dynCall_iiiiijj'])(a0, a1, a2, a3, a4, a5, a6, a7, a8);
|
|
3164
|
+
var dynCall_iiiiiijj = Module['dynCall_iiiiiijj'] = (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) => (dynCall_iiiiiijj = Module['dynCall_iiiiiijj'] = wasmExports['dynCall_iiiiiijj'])(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
3361
3165
|
// include: postamble.js
|
|
3362
3166
|
// === Auto-generated postamble setup entry stuff ===
|
|
3363
|
-
Module[
|
|
3167
|
+
Module['wasmExports'] = wasmExports;
|
|
3168
|
+
Module['UTF8ToString'] = UTF8ToString;
|
|
3364
3169
|
var calledRun;
|
|
3365
3170
|
dependenciesFulfilled = function runCaller() {
|
|
3366
3171
|
// If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
|
|
@@ -3415,7 +3220,15 @@ var Module = (() => {
|
|
|
3415
3220
|
}
|
|
3416
3221
|
run();
|
|
3417
3222
|
// end include: postamble.js
|
|
3418
|
-
|
|
3223
|
+
// include: postamble_modularize.js
|
|
3224
|
+
// In MODULARIZE mode we wrap the generated code in a factory function
|
|
3225
|
+
// and return either the Module itself, or a promise of the module.
|
|
3226
|
+
//
|
|
3227
|
+
// We assign to the `moduleRtn` global here and configure closure to see
|
|
3228
|
+
// this as and extern so it won't get minified.
|
|
3229
|
+
moduleRtn = readyPromise;
|
|
3230
|
+
// end include: postamble_modularize.js
|
|
3231
|
+
return moduleRtn;
|
|
3419
3232
|
});
|
|
3420
3233
|
})();
|
|
3421
3234
|
export default Module;
|