js逆向方法api调用(快手、抖音、wx、hnw、xhs)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

4709 lines
169 KiB

const fs = require('fs');
var f = "";
// The Module object: Our interface to the outside world. We import
// and export values on it. There are various ways Module can be used:
// 1. Not defined. We create it here
// 2. A function parameter, function(Module) { ..generated code.. }
// 3. pre-run appended it, var Module = {}; ..generated code..
// 4. External script tag defines var Module.
// We need to check if Module already exists (e.g. case 3 above).
// Substitution will be replaced with actual code on later stage of the build,
// this way Closure Compiler will not mangle it (e.g. case 4. above).
// Note that if you want to run closure, and also to use Module
// after the generated code, you will need to define var Module = {};
// before the code. Then that object will be used in the code, and you
// can continue to use Module afterwards as well.
var Module = typeof Module !== 'undefined' ? Module : {};
// --pre-jses are emitted after the Module integration code, so that they can
// refer to Module (if they choose; they can also define Module)
// {{PRE_JSES}}
// Sometimes an existing Module object exists with properties
// meant to overwrite the default module functionality. Here
// we collect those properties and reapply _after_ we configure
// the current environment's defaults to avoid having to be so
// defensive during initialization.
var moduleOverrides = {};
var key;
for (key in Module) {
if (Module.hasOwnProperty(key)) {
moduleOverrides[key] = Module[key];
}
}
var arguments_ = [];
var thisProgram = './this.program';
var quit_ = function(status, toThrow) {
throw toThrow;
};
// Determine the runtime environment we are in. You can customize this by
// setting the ENVIRONMENT setting at compile time (see settings.js).
var ENVIRONMENT_IS_WEB = false;
var ENVIRONMENT_IS_WORKER = true;
var ENVIRONMENT_IS_NODE = false;
var ENVIRONMENT_IS_SHELL = false;
// `/` should be present at the end if `scriptDirectory` is not empty
var scriptDirectory = '';
function locateFile(path) {
if (Module['locateFile']) {
return Module['locateFile'](path, scriptDirectory);
}
return scriptDirectory + path;
}
// Hooks that are implemented differently in different runtime environments.
var read_,
readAsync,
readBinary,
setWindowTitle;
// Note that this includes Node.js workers when relevant (pthreads is enabled).
// Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
// ENVIRONMENT_IS_NODE.
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
if (ENVIRONMENT_IS_WORKER) { // Check worker, not web, since window could be polyfilled
scriptDirectory = "";
} else if (typeof document !== 'undefined' && document.currentScript) { // web
scriptDirectory = document.currentScript.src;
}
// blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
// otherwise, slice off the final part of the url to find the script directory.
// if scriptDirectory does not contain a slash, lastIndexOf will return -1,
// and scriptDirectory will correctly be replaced with an empty string.
// If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
// they are removed because they could contain a slash.
if (scriptDirectory.indexOf('blob:') !== 0) {
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/')+1);
} else {
scriptDirectory = '';
}
// Differentiate the Web Worker from the Node Worker case, as reading must
// be done differently.
{
// include: web_or_worker_shell_read.js
read_ = function(url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
xhr.send(null);
return xhr.responseText;
};
if (ENVIRONMENT_IS_WORKER) {
readBinary = function(url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
xhr.responseType = 'arraybuffer';
xhr.send(null);
return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
};
}
readAsync = function(url, onload, onerror) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function() {
if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
onload(xhr.response);
return;
}
onerror();
};
xhr.onerror = onerror;
xhr.send(null);
};
// end include: web_or_worker_shell_read.js
}
setWindowTitle = function(title) { document.title = title };
} else
{
}
var out = Module['print'] || console.log.bind(console);
var err = Module['printErr'] || console.warn.bind(console);
// Merge back in the overrides
for (key in moduleOverrides) {
if (moduleOverrides.hasOwnProperty(key)) {
Module[key] = moduleOverrides[key];
}
}
// Free the object hierarchy contained in the overrides, this lets the GC
// reclaim data used e.g. in memoryInitializerRequest, which is a large typed array.
moduleOverrides = null;
// Emit code to handle expected values on the Module object. This applies Module.x
// to the proper local x. This has two benefits: first, we only emit it if it is
// expected to arrive, and second, by using a local everywhere else that can be
// minified.
if (Module['arguments']) arguments_ = Module['arguments'];
if (Module['thisProgram']) thisProgram = Module['thisProgram'];
if (Module['quit']) quit_ = Module['quit'];
// perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
var STACK_ALIGN = 16;
var POINTER_SIZE = 4;
function getNativeTypeSize(type) {
switch (type) {
case 'i1': case 'i8': return 1;
case 'i16': return 2;
case 'i32': return 4;
case 'i64': return 8;
case 'float': return 4;
case 'double': return 8;
default: {
if (type[type.length-1] === '*') {
return POINTER_SIZE;
} else if (type[0] === 'i') {
var bits = Number(type.substr(1));
assert(bits % 8 === 0, 'getNativeTypeSize invalid bits ' + bits + ', type ' + type);
return bits / 8;
} else {
return 0;
}
}
}
}
function warnOnce(text) {
if (!warnOnce.shown) warnOnce.shown = {};
if (!warnOnce.shown[text]) {
warnOnce.shown[text] = 1;
err(text);
}
}
// include: runtime_functions.js
// Wraps a JS function as a wasm function with a given signature.
function convertJsFunctionToWasm(func, sig) {
// If the type reflection proposal is available, use the new
// "WebAssembly.Function" constructor.
// Otherwise, construct a minimal wasm module importing the JS function and
// re-exporting it.
if (typeof WebAssembly.Function === "function") {
var typeNames = {
'i': 'i32',
'j': 'i64',
'f': 'f32',
'd': 'f64'
};
var type = {
parameters: [],
results: sig[0] == 'v' ? [] : [typeNames[sig[0]]]
};
for (var i = 1; i < sig.length; ++i) {
type.parameters.push(typeNames[sig[i]]);
}
return new WebAssembly.Function(type, func);
}
// The module is static, with the exception of the type section, which is
// generated based on the signature passed in.
var typeSection = [
0x01, // id: section,
0x00, // length: 0 (placeholder)
0x01, // count: 1
0x60, // form: func
];
var sigRet = sig.slice(0, 1);
var sigParam = sig.slice(1);
var typeCodes = {
'i': 0x7f, // i32
'j': 0x7e, // i64
'f': 0x7d, // f32
'd': 0x7c, // f64
};
// Parameters, length + signatures
typeSection.push(sigParam.length);
for (var i = 0; i < sigParam.length; ++i) {
typeSection.push(typeCodes[sigParam[i]]);
}
// Return values, length + signatures
// With no multi-return in MVP, either 0 (void) or 1 (anything else)
if (sigRet == 'v') {
typeSection.push(0x00);
} else {
typeSection = typeSection.concat([0x01, typeCodes[sigRet]]);
}
// Write the overall length of the type section back into the section header
// (excepting the 2 bytes for the section id and length)
typeSection[1] = typeSection.length - 2;
// Rest of the module is static
var bytes = new Uint8Array([
0x00, 0x61, 0x73, 0x6d, // magic ("\0asm")
0x01, 0x00, 0x00, 0x00, // version: 1
].concat(typeSection, [
0x02, 0x07, // import section
// (import "e" "f" (func 0 (type 0)))
0x01, 0x01, 0x65, 0x01, 0x66, 0x00, 0x00,
0x07, 0x05, // export section
// (export "f" (func 0 (type 0)))
0x01, 0x01, 0x66, 0x00, 0x00,
]));
// We can compile this wasm module synchronously because it is very small.
// This accepts an import (at "e.f"), that it reroutes to an export (at "f")
var module = new WebAssembly.Module(bytes);
var instance = new WebAssembly.Instance(module, {
'e': {
'f': func
}
});
var wrappedFunc = instance.exports['f'];
return wrappedFunc;
}
var freeTableIndexes = [];
// Weak map of functions in the table to their indexes, created on first use.
var functionsInTableMap;
function getEmptyTableSlot() {
// Reuse a free index if there is one, otherwise grow.
if (freeTableIndexes.length) {
return freeTableIndexes.pop();
}
// Grow the table
try {
wasmTable.grow(1);
} catch (err) {
if (!(err instanceof RangeError)) {
throw err;
}
throw 'Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.';
}
return wasmTable.length - 1;
}
function updateTableMap(offset, count) {
for (var i = offset; i < offset + count; i++) {
var item = getWasmTableEntry(i);
// Ignore null values.
if (item) {
functionsInTableMap.set(item, i);
}
}
}
// Add a function to the table.
// 'sig' parameter is required if the function being added is a JS function.
function addFunction(func, sig) {
// Check if the function is already in the table, to ensure each function
// gets a unique index. First, create the map if this is the first use.
if (!functionsInTableMap) {
functionsInTableMap = new WeakMap();
updateTableMap(0, wasmTable.length);
}
if (functionsInTableMap.has(func)) {
return functionsInTableMap.get(func);
}
// It's not in the table, add it now.
var ret = getEmptyTableSlot();
// Set the new value.
try {
// Attempting to call this with JS function will cause of table.set() to fail
setWasmTableEntry(ret, func);
} catch (err) {
if (!(err instanceof TypeError)) {
throw err;
}
var wrapped = convertJsFunctionToWasm(func, sig);
setWasmTableEntry(ret, wrapped);
}
functionsInTableMap.set(func, ret);
return ret;
}
function removeFunction(index) {
functionsInTableMap.delete(getWasmTableEntry(index));
freeTableIndexes.push(index);
}
// end include: runtime_functions.js
// include: runtime_debug.js
// end include: runtime_debug.js
var tempRet0 = 0;
var setTempRet0 = function(value) {
tempRet0 = value;
};
var getTempRet0 = function() {
return tempRet0;
};
// === Preamble library stuff ===
// Documentation for the public APIs defined in this file must be updated in:
// site/source/docs/api_reference/preamble.js.rst
// A prebuilt local version of the documentation is available at:
// site/build/text/docs/api_reference/preamble.js.txt
// You can also build docs locally as HTML or other formats in site/
// An online HTML version (which may be of a different version of Emscripten)
// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
var wasmBinary;
if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
var noExitRuntime = Module['noExitRuntime'] || true;
if (typeof WebAssembly !== 'object') {
abort('no native wasm support detected');
}
// include: runtime_safe_heap.js
// In MINIMAL_RUNTIME, setValue() and getValue() are only available when building with safe heap enabled, for heap safety checking.
// In traditional runtime, setValue() and getValue() are always available (although their use is highly discouraged due to perf penalties)
/** @param {number} ptr
@param {number} value
@param {string} type
@param {number|boolean=} noSafe */
function setValue(ptr, value, type, noSafe) {
type = type || 'i8';
if (type.charAt(type.length-1) === '*') type = 'i32';
switch (type) {
case 'i1': HEAP8[((ptr)>>0)] = value; break;
case 'i8': HEAP8[((ptr)>>0)] = value; break;
case 'i16': HEAP16[((ptr)>>1)] = value; break;
case 'i32': HEAP32[((ptr)>>2)] = value; break;
case 'i64': (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]); break;
case 'float': HEAPF32[((ptr)>>2)] = value; break;
case 'double': HEAPF64[((ptr)>>3)] = value; break;
default: abort('invalid type for setValue: ' + type);
}
}
/** @param {number} ptr
@param {string} type
@param {number|boolean=} noSafe */
function getValue(ptr, type, noSafe) {
type = type || 'i8';
if (type.charAt(type.length-1) === '*') type = 'i32';
switch (type) {
case 'i1': return HEAP8[((ptr)>>0)];
case 'i8': return HEAP8[((ptr)>>0)];
case 'i16': return HEAP16[((ptr)>>1)];
case 'i32': return HEAP32[((ptr)>>2)];
case 'i64': return HEAP32[((ptr)>>2)];
case 'float': return HEAPF32[((ptr)>>2)];
case 'double': return Number(HEAPF64[((ptr)>>3)]);
default: abort('invalid type for getValue: ' + type);
}
return null;
}
// end include: runtime_safe_heap.js
// Wasm globals
var wasmMemory;
//========================================
// Runtime essentials
//========================================
// whether we are quitting the application. no code should run after this.
// set in exit() and abort()
var ABORT = false;
// set by exit() and abort(). Passed to 'onExit' handler.
// NOTE: This is also used as the process return code code in shell environments
// but only when noExitRuntime is false.
var EXITSTATUS;
/** @type {function(*, string=)} */
function assert(condition, text) {
if (!condition) {
abort('Assertion failed: ' + text);
}
}
// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
function getCFunc(ident) {
var func = Module['_' + ident]; // closure exported function
assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported');
return func;
}
// C calling interface.
/** @param {string|null=} returnType
@param {Array=} argTypes
@param {Arguments|Array=} args
@param {Object=} opts */
function ccall(ident, returnType, argTypes, args, opts) {
// For fast lookup of conversion functions
var toC = {
'string': function(str) {
var ret = 0;
if (str !== null && str !== undefined && str !== 0) { // null string
// at most 4 bytes per UTF-8 code point, +1 for the trailing '\0'
var len = (str.length << 2) + 1;
ret = stackAlloc(len);
stringToUTF8(str, ret, len);
}
return ret;
},
'array': function(arr) {
var ret = stackAlloc(arr.length);
writeArrayToMemory(arr, ret);
return ret;
}
};
function convertReturnValue(ret) {
if (returnType === 'string') return UTF8ToString(ret);
if (returnType === 'boolean') return Boolean(ret);
return ret;
}
var func = getCFunc(ident);
var cArgs = [];
var stack = 0;
if (args) {
for (var i = 0; i < args.length; i++) {
var converter = toC[argTypes[i]];
if (converter) {
if (stack === 0) stack = stackSave();
cArgs[i] = converter(args[i]);
} else {
cArgs[i] = args[i];
}
}
}
var ret = func.apply(null, cArgs);
function onDone(ret) {
runtimeKeepalivePop();
if (stack !== 0) stackRestore(stack);
return convertReturnValue(ret);
}
runtimeKeepalivePush();
var asyncMode = opts && opts.async;
// Check if we started an async operation just now.
if (Asyncify.currData) {
// If so, the WASM function ran asynchronous and unwound its stack.
// We need to return a Promise that resolves the return value
// once the stack is rewound and execution finishes.
return Asyncify.whenDone().then(onDone);
}
ret = onDone(ret);
// If this is an async ccall, ensure we return a promise
if (asyncMode) return Promise.resolve(ret);
return ret;
}
/** @param {string=} returnType
@param {Array=} argTypes
@param {Object=} opts */
function cwrap(ident, returnType, argTypes, opts) {
argTypes = argTypes || [];
// When the function takes numbers and returns a number, we can just return
// the original function
var numericArgs = argTypes.every(function(type){ return type === 'number'});
var numericRet = returnType !== 'string';
if (numericRet && numericArgs && !opts) {
return getCFunc(ident);
}
return function() {
return ccall(ident, returnType, argTypes, arguments, opts);
}
}
var ALLOC_NORMAL = 0; // Tries to use _malloc()
var ALLOC_STACK = 1; // Lives for the duration of the current function call
// allocate(): This is for internal use. You can use it yourself as well, but the interface
// is a little tricky (see docs right below). The reason is that it is optimized
// for multiple syntaxes to save space in generated code. So you should
// normally not use allocate(), and instead allocate memory using _malloc(),
// initialize it with setValue(), and so forth.
// @slab: An array of data.
// @allocator: How to allocate memory, see ALLOC_*
/** @type {function((Uint8Array|Array<number>), number)} */
function allocate(slab, allocator) {
var ret;
if (allocator == ALLOC_STACK) {
ret = stackAlloc(slab.length);
} else {
ret = _malloc(slab.length);
}
if (slab.subarray || slab.slice) {
HEAPU8.set(/** @type {!Uint8Array} */(slab), ret);
} else {
HEAPU8.set(new Uint8Array(slab), ret);
}
return ret;
}
// include: runtime_strings.js
// runtime_strings.js: Strings related runtime functions that are part of both MINIMAL_RUNTIME and regular runtime.
// Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the given array that contains uint8 values, returns
// a copy of that string as a Javascript String object.
var UTF8Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
/**
* @param {number} idx
* @param {number=} maxBytesToRead
* @return {string}
*/
function UTF8ArrayToString(heap, idx, maxBytesToRead) {
var endIdx = idx + maxBytesToRead;
var endPtr = idx;
// TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
// Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
// (As a tiny code save trick, compare endPtr against endIdx using a negation, so that undefined means Infinity)
while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr;
if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) {
return UTF8Decoder.decode(heap.subarray(idx, endPtr));
} else {
var str = '';
// If building with TextDecoder, we have already computed the string length above, so test loop end condition against that
while (idx < endPtr) {
// For UTF8 byte structure, see:
// http://en.wikipedia.org/wiki/UTF-8#Description
// https://www.ietf.org/rfc/rfc2279.txt
// https://tools.ietf.org/html/rfc3629
var u0 = heap[idx++];
if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
var u1 = heap[idx++] & 63;
if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
var u2 = heap[idx++] & 63;
if ((u0 & 0xF0) == 0xE0) {
u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
} else {
u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heap[idx++] & 63);
}
if (u0 < 0x10000) {
str += String.fromCharCode(u0);
} else {
var ch = u0 - 0x10000;
str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
}
}
}
return str;
}
// Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the emscripten HEAP, returns a
// copy of that string as a Javascript String object.
// maxBytesToRead: an optional length that specifies the maximum number of bytes to read. You can omit
// this parameter to scan the string until the first \0 byte. If maxBytesToRead is
// passed, and the string at [ptr, ptr+maxBytesToReadr[ contains a null byte in the
// middle, then the string will cut short at that byte index (i.e. maxBytesToRead will
// not produce a string of exact length [ptr, ptr+maxBytesToRead[)
// N.B. mixing frequent uses of UTF8ToString() with and without maxBytesToRead may
// throw JS JIT optimizations off, so it is worth to consider consistently using one
// style or the other.
/**
* @param {number} ptr
* @param {number=} maxBytesToRead
* @return {string}
*/
function UTF8ToString(ptr, maxBytesToRead) {
;
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
}
// Copies the given Javascript String object 'str' to the given byte array at address 'outIdx',
// encoded in UTF8 form and null-terminated. The copy will require at most str.length*4+1 bytes of space in the HEAP.
// Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write.
// Parameters:
// str: the Javascript string to copy.
// heap: the array to copy to. Each index in this array is assumed to be one 8-byte element.
// outIdx: The starting offset in the array to begin the copying.
// maxBytesToWrite: The maximum number of bytes this function can write to the array.
// This count should include the null terminator,
// i.e. if maxBytesToWrite=1, only the null terminator will be written and nothing else.
// maxBytesToWrite=0 does not write any bytes to the output, not even the null terminator.
// Returns the number of bytes written, EXCLUDING the null terminator.
function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
if (!(maxBytesToWrite > 0)) // Parameter maxBytesToWrite is not optional. Negative values, 0, null, undefined and false each don't write out any bytes.
return 0;
var startIdx = outIdx;
var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
for (var i = 0; i < str.length; ++i) {
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
// See http://unicode.org/faq/utf_bom.html#utf16-3
// For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description and https://www.ietf.org/rfc/rfc2279.txt and https://tools.ietf.org/html/rfc3629
var u = str.charCodeAt(i); // possibly a lead surrogate
if (u >= 0xD800 && u <= 0xDFFF) {
var u1 = str.charCodeAt(++i);
u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
}
if (u <= 0x7F) {
if (outIdx >= endIdx) break;
heap[outIdx++] = u;
} else if (u <= 0x7FF) {
if (outIdx + 1 >= endIdx) break;
heap[outIdx++] = 0xC0 | (u >> 6);
heap[outIdx++] = 0x80 | (u & 63);
} else if (u <= 0xFFFF) {
if (outIdx + 2 >= endIdx) break;
heap[outIdx++] = 0xE0 | (u >> 12);
heap[outIdx++] = 0x80 | ((u >> 6) & 63);
heap[outIdx++] = 0x80 | (u & 63);
} else {
if (outIdx + 3 >= endIdx) break;
heap[outIdx++] = 0xF0 | (u >> 18);
heap[outIdx++] = 0x80 | ((u >> 12) & 63);
heap[outIdx++] = 0x80 | ((u >> 6) & 63);
heap[outIdx++] = 0x80 | (u & 63);
}
}
// Null-terminate the pointer to the buffer.
heap[outIdx] = 0;
return outIdx - startIdx;
}
// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
// null-terminated and encoded in UTF8 form. The copy will require at most str.length*4+1 bytes of space in the HEAP.
// Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write.
// Returns the number of bytes written, EXCLUDING the null terminator.
function stringToUTF8(str, outPtr, maxBytesToWrite) {
return stringToUTF8Array(str, HEAPU8,outPtr, maxBytesToWrite);
}
// Returns the number of bytes the given Javascript string takes if encoded as a UTF8 byte array, EXCLUDING the null terminator byte.
function lengthBytesUTF8(str) {
var len = 0;
for (var i = 0; i < str.length; ++i) {
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
// See http://unicode.org/faq/utf_bom.html#utf16-3
var u = str.charCodeAt(i); // possibly a lead surrogate
if (u >= 0xD800 && u <= 0xDFFF) u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt(++i) & 0x3FF);
if (u <= 0x7F) ++len;
else if (u <= 0x7FF) len += 2;
else if (u <= 0xFFFF) len += 3;
else len += 4;
}
return len;
}
// end include: runtime_strings.js
// include: runtime_strings_extra.js
// runtime_strings_extra.js: Strings related runtime functions that are available only in regular runtime.
// Given a pointer 'ptr' to a null-terminated ASCII-encoded string in the emscripten HEAP, returns
// a copy of that string as a Javascript String object.
function AsciiToString(ptr) {
var str = '';
while (1) {
var ch = HEAPU8[((ptr++)>>0)];
if (!ch) return str;
str += String.fromCharCode(ch);
}
}
// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
// null-terminated and encoded in ASCII form. The copy will require at most str.length+1 bytes of space in the HEAP.
function stringToAscii(str, outPtr) {
return writeAsciiToMemory(str, outPtr, false);
}
// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
// a copy of that string as a Javascript String object.
var UTF16Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-16le') : undefined;
function UTF16ToString(ptr, maxBytesToRead) {
var endPtr = ptr;
// TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
// Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
var idx = endPtr >> 1;
var maxIdx = idx + maxBytesToRead / 2;
// If maxBytesToRead is not passed explicitly, it will be undefined, and this
// will always evaluate to true. This saves on code size.
while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx;
endPtr = idx << 1;
if (endPtr - ptr > 32 && UTF16Decoder) {
return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
} else {
var str = '';
// If maxBytesToRead is not passed explicitly, it will be undefined, and the for-loop's condition
// will always evaluate to true. The loop is then terminated on the first null char.
for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {
var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
if (codeUnit == 0) break;
// fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
str += String.fromCharCode(codeUnit);
}
return str;
}
}
// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
// null-terminated and encoded in UTF16 form. The copy will require at most str.length*4+2 bytes of space in the HEAP.
// Use the function lengthBytesUTF16() to compute the exact number of bytes (excluding null terminator) that this function will write.
// Parameters:
// str: the Javascript string to copy.
// outPtr: Byte address in Emscripten HEAP where to write the string to.
// maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
// terminator, i.e. if maxBytesToWrite=2, only the null terminator will be written and nothing else.
// maxBytesToWrite<2 does not write any bytes to the output, not even the null terminator.
// Returns the number of bytes written, EXCLUDING the null terminator.
function stringToUTF16(str, outPtr, maxBytesToWrite) {
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
if (maxBytesToWrite === undefined) {
maxBytesToWrite = 0x7FFFFFFF;
}
if (maxBytesToWrite < 2) return 0;
maxBytesToWrite -= 2; // Null terminator.
var startPtr = outPtr;
var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length;
for (var i = 0; i < numCharsToWrite; ++i) {
// charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
HEAP16[((outPtr)>>1)] = codeUnit;
outPtr += 2;
}
// Null-terminate the pointer to the HEAP.
HEAP16[((outPtr)>>1)] = 0;
return outPtr - startPtr;
}
// Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
function lengthBytesUTF16(str) {
return str.length*2;
}
function UTF32ToString(ptr, maxBytesToRead) {
var i = 0;
var str = '';
// If maxBytesToRead is not passed explicitly, it will be undefined, and this
// will always evaluate to true. This saves on code size.
while (!(i >= maxBytesToRead / 4)) {
var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
if (utf32 == 0) break;
++i;
// Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
// See http://unicode.org/faq/utf_bom.html#utf16-3
if (utf32 >= 0x10000) {
var ch = utf32 - 0x10000;
str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
} else {
str += String.fromCharCode(utf32);
}
}
return str;
}
// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
// null-terminated and encoded in UTF32 form. The copy will require at most str.length*4+4 bytes of space in the HEAP.
// Use the function lengthBytesUTF32() to compute the exact number of bytes (excluding null terminator) that this function will write.
// Parameters:
// str: the Javascript string to copy.
// outPtr: Byte address in Emscripten HEAP where to write the string to.
// maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
// terminator, i.e. if maxBytesToWrite=4, only the null terminator will be written and nothing else.
// maxBytesToWrite<4 does not write any bytes to the output, not even the null terminator.
// Returns the number of bytes written, EXCLUDING the null terminator.
function stringToUTF32(str, outPtr, maxBytesToWrite) {
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
if (maxBytesToWrite === undefined) {
maxBytesToWrite = 0x7FFFFFFF;
}
if (maxBytesToWrite < 4) return 0;
var startPtr = outPtr;
var endPtr = startPtr + maxBytesToWrite - 4;
for (var i = 0; i < str.length; ++i) {
// 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.
// See http://unicode.org/faq/utf_bom.html#utf16-3
var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
var trailSurrogate = str.charCodeAt(++i);
codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
}
HEAP32[((outPtr)>>2)] = codeUnit;
outPtr += 4;
if (outPtr + 4 > endPtr) break;
}
// Null-terminate the pointer to the HEAP.
HEAP32[((outPtr)>>2)] = 0;
return outPtr - startPtr;
}
// Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
function lengthBytesUTF32(str) {
var len = 0;
for (var i = 0; i < str.length; ++i) {
// 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.
// See http://unicode.org/faq/utf_bom.html#utf16-3
var codeUnit = str.charCodeAt(i);
if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) ++i; // possibly a lead surrogate, so skip over the tail surrogate.
len += 4;
}
return len;
}
// Allocate heap space for a JS string, and write it there.
// It is the responsibility of the caller to free() that memory.
function allocateUTF8(str) {
var size = lengthBytesUTF8(str) + 1;
var ret = _malloc(size);
if (ret) stringToUTF8Array(str, HEAP8, ret, size);
return ret;
}
// Allocate stack space for a JS string, and write it there.
function allocateUTF8OnStack(str) {
var size = lengthBytesUTF8(str) + 1;
var ret = stackAlloc(size);
stringToUTF8Array(str, HEAP8, ret, size);
return ret;
}
// Deprecated: This function should not be called because it is unsafe and does not provide
// a maximum length limit of how many bytes it is allowed to write. Prefer calling the
// function stringToUTF8Array() instead, which takes in a maximum length that can be used
// to be secure from out of bounds writes.
/** @deprecated
@param {boolean=} dontAddNull */
function writeStringToMemory(string, buffer, dontAddNull) {
warnOnce('writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!');
var /** @type {number} */ lastChar, /** @type {number} */ end;
if (dontAddNull) {
// stringToUTF8Array always appends null. If we don't want to do that, remember the
// character that existed at the location where the null will be placed, and restore
// that after the write (below).
end = buffer + lengthBytesUTF8(string);
lastChar = HEAP8[end];
}
stringToUTF8(string, buffer, Infinity);
if (dontAddNull) HEAP8[end] = lastChar; // Restore the value under the null character.
}
function writeArrayToMemory(array, buffer) {
HEAP8.set(array, buffer);
}
/** @param {boolean=} dontAddNull */
function writeAsciiToMemory(str, buffer, dontAddNull) {
for (var i = 0; i < str.length; ++i) {
HEAP8[((buffer++)>>0)] = str.charCodeAt(i);
}
// Null-terminate the pointer to the HEAP.
if (!dontAddNull) HEAP8[((buffer)>>0)] = 0;
}
// end include: runtime_strings_extra.js
// Memory management
function alignUp(x, multiple) {
if (x % multiple > 0) {
x += multiple - (x % multiple);
}
return x;
}
var HEAP,
/** @type {ArrayBuffer} */
buffer,
/** @type {Int8Array} */
HEAP8,
/** @type {Uint8Array} */
HEAPU8,
/** @type {Int16Array} */
HEAP16,
/** @type {Uint16Array} */
HEAPU16,
/** @type {Int32Array} */
HEAP32,
/** @type {Uint32Array} */
HEAPU32,
/** @type {Float32Array} */
HEAPF32,
/** @type {Float64Array} */
HEAPF64;
function updateGlobalBufferAndViews(buf) {
buffer = buf;
Module['HEAP8'] = HEAP8 = new Int8Array(buf);
Module['HEAP16'] = HEAP16 = new Int16Array(buf);
Module['HEAP32'] = HEAP32 = new Int32Array(buf);
Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf);
Module['HEAPU16'] = HEAPU16 = new Uint16Array(buf);
Module['HEAPU32'] = HEAPU32 = new Uint32Array(buf);
Module['HEAPF32'] = HEAPF32 = new Float32Array(buf);
Module['HEAPF64'] = HEAPF64 = new Float64Array(buf);
}
var TOTAL_STACK = 5242880;
var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 33554432;
// include: runtime_init_table.js
// In regular non-RELOCATABLE mode the table is exported
// from the wasm module and this will be assigned once
// the exports are available.
var wasmTable;
// end include: runtime_init_table.js
// include: runtime_stack_check.js
// end include: runtime_stack_check.js
// include: runtime_assertions.js
// end include: runtime_assertions.js
var __ATPRERUN__ = []; // functions called before the runtime is initialized
var __ATINIT__ = []; // functions called during startup
var __ATEXIT__ = []; // functions called during shutdown
var __ATPOSTRUN__ = []; // functions called after the main() is called
var runtimeInitialized = false;
var runtimeExited = false;
var runtimeKeepaliveCounter = 0;
function keepRuntimeAlive() {
return noExitRuntime || runtimeKeepaliveCounter > 0;
}
function preRun() {
if (Module['preRun']) {
if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
while (Module['preRun'].length) {
addOnPreRun(Module['preRun'].shift());
}
}
callRuntimeCallbacks(__ATPRERUN__);
}
function initRuntime() {
runtimeInitialized = true;
callRuntimeCallbacks(__ATINIT__);
}
function exitRuntime() {
runtimeExited = true;
}
function postRun() {
if (Module['postRun']) {
if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
while (Module['postRun'].length) {
addOnPostRun(Module['postRun'].shift());
}
}
callRuntimeCallbacks(__ATPOSTRUN__);
}
function addOnPreRun(cb) {
__ATPRERUN__.unshift(cb);
}
function addOnInit(cb) {
__ATINIT__.unshift(cb);
}
function addOnExit(cb) {
}
function addOnPostRun(cb) {
__ATPOSTRUN__.unshift(cb);
}
// include: runtime_math.js
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
// || MIN_NODE_VERSION < 0.12
// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
if (!Math.imul || Math.imul(0xffffffff, 5) !== -5) Math.imul = function imul(a, b) {
var ah = a >>> 16;
var al = a & 0xffff;
var bh = b >>> 16;
var bl = b & 0xffff;
return (al*bl + ((ah*bl + al*bh) << 16))|0;
};
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
// end include: runtime_math.js
// A counter of dependencies for calling run(). If we need to
// do asynchronous work before running, increment this and
// decrement it. Incrementing must happen in a place like
// Module.preRun (used by emcc to add file preloading).
// Note that you can add dependencies in preRun, even though
// it happens right before run - run will be postponed until
// the dependencies are met.
var runDependencies = 0;
var runDependencyWatcher = null;
var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
function getUniqueRunDependency(id) {
return id;
}
function addRunDependency(id) {
runDependencies++;
if (Module['monitorRunDependencies']) {
Module['monitorRunDependencies'](runDependencies);
}
}
function removeRunDependency(id) {
runDependencies--;
if (Module['monitorRunDependencies']) {
Module['monitorRunDependencies'](runDependencies);
}
if (runDependencies == 0) {
if (runDependencyWatcher !== null) {
clearInterval(runDependencyWatcher);
runDependencyWatcher = null;
}
if (dependenciesFulfilled) {
var callback = dependenciesFulfilled;
dependenciesFulfilled = null;
callback(); // can add another dependenciesFulfilled
}
}
}
Module["preloadedImages"] = {}; // maps url to image data
Module["preloadedAudios"] = {}; // maps url to audio data
/** @param {string|number=} what */
function abort(what) {
{
if (Module['onAbort']) {
Module['onAbort'](what);
}
}
what = 'Aborted(' + what + ')';
// TODO(sbc): Should we remove printing and leave it up to whoever
// catches the exception?
err(what);
ABORT = true;
EXITSTATUS = 1;
what += '. Build with -s ASSERTIONS=1 for more info.';
// Use a wasm runtime error, because a JS error might be seen as a foreign
// exception, which means we'd run destructors on it. We need the error to
// simply make the program stop.
var e = new WebAssembly.RuntimeError(what);
// Throw the error whether or not MODULARIZE is set because abort is used
// in code paths apart from instantiation where an exception is expected
// to be thrown when abort is called.
throw e;
}
// {{MEM_INITIALIZER}}
// include: memoryprofiler.js
// end include: memoryprofiler.js
// include: URIUtils.js
// Prefix of data URIs emitted by SINGLE_FILE and related options.
var dataURIPrefix = 'data:application/octet-stream;base64,';
// Indicates whether filename is a base64 data URI.
function isDataURI(filename) {
// Prefix of data URIs emitted by SINGLE_FILE and related options.
return filename.startsWith(dataURIPrefix);
}
// Indicates whether filename is delivered via file protocol (as opposed to http/https)
function isFileURI(filename) {
return filename.startsWith('file://');
}
// end include: URIUtils.js
var wasmBinaryFile = ""; // https://aladin.wxqcloud.qq.com/aladin/ffmepeg/video-decode/1.2.50/wasm_video_decode.wasm
var wasmBinaryFileLocal = "wx_video/wasm_video_decode.wasm";
function getBinary(file) {
try {
if (file == wasmBinaryFile && wasmBinary) {
return new Uint8Array(wasmBinary);
}
if (readBinary) {
return readBinary(file);
} else {
throw "both async and sync fetching of the wasm failed";
}
}
catch (err) {
abort(err);
}
}
function getBinaryPromise() {
// If we don't have the binary yet, try to to load it asynchronously.
// Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
// See https://github.com/github/fetch/pull/92#issuecomment-140665932
// Cordova or Electron apps are typically loaded from a file:// url.
// So use fetch if it is available and the url is not a file, otherwise fall back to XHR.
if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
if (typeof fetch === 'function'
) {
return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function(response) {
if (!response['ok']) {
throw "failed to load wasm binary file at '" + wasmBinaryFile + "'";
}
return response['arrayBuffer']();
}).catch(function () {
return getBinary(wasmBinaryFile);
});
}
}
// Otherwise, getBinary should be able to get it synchronously
return Promise.resolve().then(function() { return getBinary(wasmBinaryFile); });
}
// Create the wasm instance.
// Receives the wasm imports, returns the exports.
async function createWasm() {
// prepare imports
var info = {
'env': asmLibraryArg,
'wasi_snapshot_preview1': asmLibraryArg,
};
// Load the wasm module and create an instance of using native support in the JS engine.
// handle a generated wasm instance, receiving its exports and
// performing other necessary setup
/** @param {WebAssembly.Module=} module*/
// we can't run yet (except in a pthread, where we have a custom sync instantiator)
addRunDependency('wasm-instantiate');
// User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
// to manually instantiate the Wasm module themselves. This allows pages to run the instantiation parallel
// to any other async startup actions they are performing.
if (Module['instantiateWasm']) {
try {
var exports = Module['instantiateWasm'](info, receiveInstance);
exports = Asyncify.instrumentWasmExports(exports);
return exports;
} catch(e) {
err('Module.instantiateWasm callback failed with error: ' + e);
return false;
}
}
// await instantiateAsync();
if (!wasmBinary &&
typeof WebAssembly.instantiateStreaming === 'function' &&
!isDataURI(wasmBinaryFile) &&
typeof fetch === 'function') {
// 这块是自己新增的
if(wasmBinaryFile == ""){ // 采用本地加载wasm
var result = await WebAssembly.instantiate(fs.readFileSync(wasmBinaryFileLocal), info);
var instance = result['instance'];
// console.log(instance)
var exports = instance.exports;
exports = Asyncify.instrumentWasmExports(exports);
Module['asm'] = exports;
wasmMemory = Module['asm']['memory'];
// console.log(wasmMemory.buffer)
updateGlobalBufferAndViews(wasmMemory.buffer);
wasmTable = Module['asm']['__indirect_function_table'];
addOnInit(Module['asm']['__wasm_call_ctors']);
// console.log(Module);
removeRunDependency('wasm-instantiate');
}
}
// console.log(Module["WxIsaac64"])
// console.log(Module['asm'])
// get_();
return Module; // no exports yet; we'll fill them in later
}
// Globals used by JS i64 conversions (see makeSetValue)
var tempDouble;
var tempI64;
// === Body ===
var ASM_CONSTS = {
434420: function($0, $1, $2) {wasm_ffmpeg_error_report($0, $1, $2);},
434460: function($0, $1) {wasm_isaac_generate($0, $1);},
434491: function($0, $1, $2) {return wasm_ffmpeg_fwrite($0, $1, $2);},
434532: function($0, $1) {wasm_ffmpeg_fsize($0, $1);},
434561: function($0, $1, $2, $3, $4) {wasm_ffmpeg_fseek($0, $1, $2, $3, $4);},
434602: function($0, $1) {wasm_ffmpeg_fclose($0, $1);}
};
function __asyncjs__wasm_ffmpeg_fopen_sync(filename,filelen,acc){ return Asyncify.handleAsync(async () => { const ret = await wasm_ffmpeg_fopen(filename, filelen, acc); return ret; }); }
function __asyncjs__wasm_ffmpeg_fread_sync(fd,buf,size,ffindex){ return Asyncify.handleAsync(async () => { const ret = await wasm_ffmpeg_fread(fd, buf, size, ffindex); return ret; }); }
function callRuntimeCallbacks(callbacks) {
while (callbacks.length > 0) {
var callback = callbacks.shift();
if (typeof callback == 'function') {
callback(Module); // Pass the module as the first argument.
continue;
}
var func = callback.func;
if (typeof func === 'number') {
if (callback.arg === undefined) {
(function() { dynCall_v.call(null, func); })();
} else {
(function(a1) { dynCall_vi.apply(null, [func, a1]); })(callback.arg);
}
} else {
func(callback.arg === undefined ? null : callback.arg);
}
}
}
function withStackSave(f) {
var stack = stackSave();
var ret = f();
stackRestore(stack);
return ret;
}
function demangle(func) {
return func;
}
function demangleAll(text) {
var regex =
/\b_Z[\w\d_]+/g;
return text.replace(regex,
function(x) {
var y = demangle(x);
return x === y ? x : (y + ' [' + x + ']');
});
}
var wasmTableMirror = [];
function getWasmTableEntry(funcPtr) {
var func = wasmTableMirror[funcPtr];
if (!func) {
if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
}
return func;
}
function handleException(e) {
// Certain exception types we do not treat as errors since they are used for
// internal control flow.
// 1. ExitStatus, which is thrown by exit()
// 2. "unwind", which is thrown by emscripten_unwind_to_js_event_loop() and others
// that wish to return to JS event loop.
if (e instanceof ExitStatus || e == 'unwind') {
return EXITSTATUS;
}
quit_(1, e);
}
function jsStackTrace() {
var error = new Error();
if (!error.stack) {
// IE10+ special cases: It does have callstack info, but it is only populated if an Error object is thrown,
// so try that as a special-case.
try {
throw new Error();
} catch(e) {
error = e;
}
if (!error.stack) {
return '(no stack trace available)';
}
}
return error.stack.toString();
}
function setWasmTableEntry(idx, func) {
wasmTable.set(idx, func);
wasmTableMirror[idx] = func;
}
function stackTrace() {
var js = jsStackTrace();
if (Module['extraStackTrace']) js += '\n' + Module['extraStackTrace']();
return demangleAll(js);
}
function ___cxa_allocate_exception(size) {
// Thrown object is prepended by exception metadata block
return _malloc(size + 16) + 16;
}
function _atexit(func, arg) {
}
function ___cxa_atexit(a0,a1
) {
return _atexit(a0,a1);
}
function ExceptionInfo(excPtr) {
this.excPtr = excPtr;
this.ptr = excPtr - 16;
this.set_type = function(type) {
HEAP32[(((this.ptr)+(4))>>2)] = type;
};
this.get_type = function() {
return HEAP32[(((this.ptr)+(4))>>2)];
};
this.set_destructor = function(destructor) {
HEAP32[(((this.ptr)+(8))>>2)] = destructor;
};
this.get_destructor = function() {
return HEAP32[(((this.ptr)+(8))>>2)];
};
this.set_refcount = function(refcount) {
HEAP32[((this.ptr)>>2)] = refcount;
};
this.set_caught = function (caught) {
caught = caught ? 1 : 0;
HEAP8[(((this.ptr)+(12))>>0)] = caught;
};
this.get_caught = function () {
return HEAP8[(((this.ptr)+(12))>>0)] != 0;
};
this.set_rethrown = function (rethrown) {
rethrown = rethrown ? 1 : 0;
HEAP8[(((this.ptr)+(13))>>0)] = rethrown;
};
this.get_rethrown = function () {
return HEAP8[(((this.ptr)+(13))>>0)] != 0;
};
// Initialize native structure fields. Should be called once after allocated.
this.init = function(type, destructor) {
this.set_type(type);
this.set_destructor(destructor);
this.set_refcount(0);
this.set_caught(false);
this.set_rethrown(false);
}
this.add_ref = function() {
var value = HEAP32[((this.ptr)>>2)];
HEAP32[((this.ptr)>>2)] = value + 1;
};
// Returns true if last reference released.
this.release_ref = function() {
var prev = HEAP32[((this.ptr)>>2)];
HEAP32[((this.ptr)>>2)] = prev - 1;
return prev === 1;
};
}
var exceptionLast = 0;
var uncaughtExceptionCount = 0;
function ___cxa_throw(ptr, type, destructor) {
var info = new ExceptionInfo(ptr);
// Initialize ExceptionInfo content after it was allocated in __cxa_allocate_exception.
info.init(type, destructor);
exceptionLast = ptr;
uncaughtExceptionCount++;
throw ptr;
}
function _gmtime_r(time, tmPtr) {
var date = new Date(HEAP32[((time)>>2)]*1000);
HEAP32[((tmPtr)>>2)] = date.getUTCSeconds();
HEAP32[(((tmPtr)+(4))>>2)] = date.getUTCMinutes();
HEAP32[(((tmPtr)+(8))>>2)] = date.getUTCHours();
HEAP32[(((tmPtr)+(12))>>2)] = date.getUTCDate();
HEAP32[(((tmPtr)+(16))>>2)] = date.getUTCMonth();
HEAP32[(((tmPtr)+(20))>>2)] = date.getUTCFullYear()-1900;
HEAP32[(((tmPtr)+(24))>>2)] = date.getUTCDay();
HEAP32[(((tmPtr)+(36))>>2)] = 0;
HEAP32[(((tmPtr)+(32))>>2)] = 0;
var start = Date.UTC(date.getUTCFullYear(), 0, 1, 0, 0, 0, 0);
var yday = ((date.getTime() - start) / (1000 * 60 * 60 * 24))|0;
HEAP32[(((tmPtr)+(28))>>2)] = yday;
// Allocate a string "GMT" for us to point to.
if (!_gmtime_r.GMTString) _gmtime_r.GMTString = allocateUTF8("GMT");
HEAP32[(((tmPtr)+(40))>>2)] = _gmtime_r.GMTString;
return tmPtr;
}
function ___gmtime_r(a0,a1
) {
return _gmtime_r(a0,a1);
}
function _tzset_impl() {
var currentYear = new Date().getFullYear();
var winter = new Date(currentYear, 0, 1);
var summer = new Date(currentYear, 6, 1);
var winterOffset = winter.getTimezoneOffset();
var summerOffset = summer.getTimezoneOffset();
// Local standard timezone offset. Local standard time is not adjusted for daylight savings.
// This code uses the fact that getTimezoneOffset returns a greater value during Standard Time versus Daylight Saving Time (DST).
// Thus it determines the expected output during Standard Time, and it compares whether the output of the given date the same (Standard) or less (DST).
var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
// timezone is specified as seconds west of UTC ("The external variable
// `timezone` shall be set to the difference, in seconds, between
// Coordinated Universal Time (UTC) and local standard time."), the same
// as returned by stdTimezoneOffset.
// See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
HEAP32[((__get_timezone())>>2)] = stdTimezoneOffset * 60;
HEAP32[((__get_daylight())>>2)] = Number(winterOffset != summerOffset);
function extractZone(date) {
var match = date.toTimeString().match(/\(([A-Za-z ]+)\)$/);
return match ? match[1] : "GMT";
};
var winterName = extractZone(winter);
var summerName = extractZone(summer);
var winterNamePtr = allocateUTF8(winterName);
var summerNamePtr = allocateUTF8(summerName);
if (summerOffset < winterOffset) {
// Northern hemisphere
HEAP32[((__get_tzname())>>2)] = winterNamePtr;
HEAP32[(((__get_tzname())+(4))>>2)] = summerNamePtr;
} else {
HEAP32[((__get_tzname())>>2)] = summerNamePtr;
HEAP32[(((__get_tzname())+(4))>>2)] = winterNamePtr;
}
}
function _tzset() {
// TODO: Use (malleable) environment variables instead of system settings.
if (_tzset.called) return;
_tzset.called = true;
_tzset_impl();
}
function _localtime_r(time, tmPtr) {
_tzset();
var date = new Date(HEAP32[((time)>>2)]*1000);
HEAP32[((tmPtr)>>2)] = date.getSeconds();
HEAP32[(((tmPtr)+(4))>>2)] = date.getMinutes();
HEAP32[(((tmPtr)+(8))>>2)] = date.getHours();
HEAP32[(((tmPtr)+(12))>>2)] = date.getDate();
HEAP32[(((tmPtr)+(16))>>2)] = date.getMonth();
HEAP32[(((tmPtr)+(20))>>2)] = date.getFullYear()-1900;
HEAP32[(((tmPtr)+(24))>>2)] = date.getDay();
var start = new Date(date.getFullYear(), 0, 1);
var yday = ((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))|0;
HEAP32[(((tmPtr)+(28))>>2)] = yday;
HEAP32[(((tmPtr)+(36))>>2)] = -(date.getTimezoneOffset() * 60);
// Attention: DST is in December in South, and some regions don't have DST at all.
var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
var winterOffset = start.getTimezoneOffset();
var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset))|0;
HEAP32[(((tmPtr)+(32))>>2)] = dst;
var zonePtr = HEAP32[(((__get_tzname())+(dst ? 4 : 0))>>2)];
HEAP32[(((tmPtr)+(40))>>2)] = zonePtr;
return tmPtr;
}
function ___localtime_r(a0,a1
) {
return _localtime_r(a0,a1);
}
var SYSCALLS = {mappings:{},buffers:[null,[],[]],printChar:function(stream, curr) {
var buffer = SYSCALLS.buffers[stream];
if (curr === 0 || curr === 10) {
(stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0));
buffer.length = 0;
} else {
buffer.push(curr);
}
},varargs:undefined,get:function() {
SYSCALLS.varargs += 4;
var ret = HEAP32[(((SYSCALLS.varargs)-(4))>>2)];
return ret;
},getStr:function(ptr) {
var ret = UTF8ToString(ptr);
return ret;
},get64:function(low, high) {
return low;
}};
function ___syscall__newselect(nfds, readfds, writefds, exceptfds, timeout) {
}
function setErrNo(value) {
HEAP32[((___errno_location())>>2)] = value;
return value;
}
function ___syscall_fcntl64(fd, cmd, varargs) {SYSCALLS.varargs = varargs;
return 0;
}
function ___syscall_ioctl(fd, op, varargs) {SYSCALLS.varargs = varargs;
return 0;
}
function ___syscall_mkdir(path, mode) {
path = SYSCALLS.getStr(path);
return SYSCALLS.doMkdir(path, mode);
}
function ___syscall_open(path, flags, varargs) {SYSCALLS.varargs = varargs;
}
function ___syscall_rmdir(path) {
}
function ___syscall_unlink(path) {
}
var structRegistrations = {};
function runDestructors(destructors) {
while (destructors.length) {
var ptr = destructors.pop();
var del = destructors.pop();
del(ptr);
}
}
function simpleReadValueFromPointer(pointer) {
return this['fromWireType'](HEAPU32[pointer >> 2]);
}
var awaitingDependencies = {};
var registeredTypes = {};
var typeDependencies = {};
var char_0 = 48;
var char_9 = 57;
function makeLegalFunctionName(name) {
if (undefined === name) {
return '_unknown';
}
name = name.replace(/[^a-zA-Z0-9_]/g, '$');
var f = name.charCodeAt(0);
if (f >= char_0 && f <= char_9) {
return '_' + name;
} else {
return name;
}
}
function createNamedFunction(name, body) {
name = makeLegalFunctionName(name);
/*jshint evil:true*/
return new Function(
"body",
"return function " + name + "() {\n" +
" \"use strict\";" +
" return body.apply(this, arguments);\n" +
"};\n"
)(body);
}
function extendError(baseErrorType, errorName) {
var errorClass = createNamedFunction(errorName, function(message) {
this.name = errorName;
this.message = message;
var stack = (new Error(message)).stack;
if (stack !== undefined) {
this.stack = this.toString() + '\n' +
stack.replace(/^Error(:[^\n]*)?\n/, '');
}
});
errorClass.prototype = Object.create(baseErrorType.prototype);
errorClass.prototype.constructor = errorClass;
errorClass.prototype.toString = function() {
if (this.message === undefined) {
return this.name;
} else {
return this.name + ': ' + this.message;
}
};
return errorClass;
}
var InternalError = undefined;
function throwInternalError(message) {
throw new InternalError(message);
}
function whenDependentTypesAreResolved(myTypes, dependentTypes, getTypeConverters) {
myTypes.forEach(function(type) {
typeDependencies[type] = dependentTypes;
});
function onComplete(typeConverters) {
var myTypeConverters = getTypeConverters(typeConverters);
if (myTypeConverters.length !== myTypes.length) {
throwInternalError('Mismatched type converter count');
}
for (var i = 0; i < myTypes.length; ++i) {
registerType(myTypes[i], myTypeConverters[i]);
}
}
var typeConverters = new Array(dependentTypes.length);
var unregisteredTypes = [];
var registered = 0;
dependentTypes.forEach(function(dt, i) {
if (registeredTypes.hasOwnProperty(dt)) {
typeConverters[i] = registeredTypes[dt];
} else {
unregisteredTypes.push(dt);
if (!awaitingDependencies.hasOwnProperty(dt)) {
awaitingDependencies[dt] = [];
}
awaitingDependencies[dt].push(function() {
typeConverters[i] = registeredTypes[dt];
++registered;
if (registered === unregisteredTypes.length) {
onComplete(typeConverters);
}
});
}
});
if (0 === unregisteredTypes.length) {
onComplete(typeConverters);
}
}
function __embind_finalize_value_object(structType) {
var reg = structRegistrations[structType];
delete structRegistrations[structType];
var rawConstructor = reg.rawConstructor;
var rawDestructor = reg.rawDestructor;
var fieldRecords = reg.fields;
var fieldTypes = fieldRecords.map(function(field) { return field.getterReturnType; }).
concat(fieldRecords.map(function(field) { return field.setterArgumentType; }));
whenDependentTypesAreResolved([structType], fieldTypes, function(fieldTypes) {
var fields = {};
fieldRecords.forEach(function(field, i) {
var fieldName = field.fieldName;
var getterReturnType = fieldTypes[i];
var getter = field.getter;
var getterContext = field.getterContext;
var setterArgumentType = fieldTypes[i + fieldRecords.length];
var setter = field.setter;
var setterContext = field.setterContext;
fields[fieldName] = {
read: function(ptr) {
return getterReturnType['fromWireType'](
getter(getterContext, ptr));
},
write: function(ptr, o) {
var destructors = [];
setter(setterContext, ptr, setterArgumentType['toWireType'](destructors, o));
runDestructors(destructors);
}
};
});
return [{
name: reg.name,
'fromWireType': function(ptr) {
var rv = {};
for (var i in fields) {
rv[i] = fields[i].read(ptr);
}
rawDestructor(ptr);
return rv;
},
'toWireType': function(destructors, o) {
// todo: Here we have an opportunity for -O3 level "unsafe" optimizations:
// assume all fields are present without checking.
for (var fieldName in fields) {
if (!(fieldName in o)) {
throw new TypeError('Missing field: "' + fieldName + '"');
}
}
var ptr = rawConstructor();
for (fieldName in fields) {
fields[fieldName].write(ptr, o[fieldName]);
}
if (destructors !== null) {
destructors.push(rawDestructor, ptr);
}
return ptr;
},
'argPackAdvance': 8,
'readValueFromPointer': simpleReadValueFromPointer,
destructorFunction: rawDestructor,
}];
});
}
function __embind_register_bigint(primitiveType, name, size, minRange, maxRange) {}
function getShiftFromSize(size) {
switch (size) {
case 1: return 0;
case 2: return 1;
case 4: return 2;
case 8: return 3;
default:
throw new TypeError('Unknown type size: ' + size);
}
}
function embind_init_charCodes() {
var codes = new Array(256);
for (var i = 0; i < 256; ++i) {
codes[i] = String.fromCharCode(i);
}
embind_charCodes = codes;
}
var embind_charCodes = undefined;
function readLatin1String(ptr) {
var ret = "";
var c = ptr;
while (HEAPU8[c]) {
ret += embind_charCodes[HEAPU8[c++]];
}
return ret;
}
var BindingError = undefined;
function throwBindingError(message) {
throw new BindingError(message);
}
/** @param {Object=} options */
function registerType(rawType, registeredInstance, options) {
options = options || {};
if (!('argPackAdvance' in registeredInstance)) {
throw new TypeError('registerType registeredInstance requires argPackAdvance');
}
var name = registeredInstance.name;
if (!rawType) {
throwBindingError('type "' + name + '" must have a positive integer typeid pointer');
}
if (registeredTypes.hasOwnProperty(rawType)) {
if (options.ignoreDuplicateRegistrations) {
return;
} else {
throwBindingError("Cannot register type '" + name + "' twice");
}
}
registeredTypes[rawType] = registeredInstance;
delete typeDependencies[rawType];
if (awaitingDependencies.hasOwnProperty(rawType)) {
var callbacks = awaitingDependencies[rawType];
delete awaitingDependencies[rawType];
callbacks.forEach(function(cb) {
cb();
});
}
}
function __embind_register_bool(rawType, name, size, trueValue, falseValue) {
var shift = getShiftFromSize(size);
name = readLatin1String(name);
registerType(rawType, {
name: name,
'fromWireType': function(wt) {
// ambiguous emscripten ABI: sometimes return values are
// true or false, and sometimes integers (0 or 1)
return !!wt;
},
'toWireType': function(destructors, o) {
return o ? trueValue : falseValue;
},
'argPackAdvance': 8,
'readValueFromPointer': function(pointer) {
// TODO: if heap is fixed (like in asm.js) this could be executed outside
var heap;
if (size === 1) {
heap = HEAP8;
} else if (size === 2) {
heap = HEAP16;
} else if (size === 4) {
heap = HEAP32;
} else {
throw new TypeError("Unknown boolean type size: " + name);
}
return this['fromWireType'](heap[pointer >> shift]);
},
destructorFunction: null, // This type does not need a destructor
});
}
function ClassHandle_isAliasOf(other) {
if (!(this instanceof ClassHandle)) {
return false;
}
if (!(other instanceof ClassHandle)) {
return false;
}
var leftClass = this.$$.ptrType.registeredClass;
var left = this.$$.ptr;
var rightClass = other.$$.ptrType.registeredClass;
var right = other.$$.ptr;
while (leftClass.baseClass) {
left = leftClass.upcast(left);
leftClass = leftClass.baseClass;
}
while (rightClass.baseClass) {
right = rightClass.upcast(right);
rightClass = rightClass.baseClass;
}
return leftClass === rightClass && left === right;
}
function shallowCopyInternalPointer(o) {
return {
count: o.count,
deleteScheduled: o.deleteScheduled,
preservePointerOnDelete: o.preservePointerOnDelete,
ptr: o.ptr,
ptrType: o.ptrType,
smartPtr: o.smartPtr,
smartPtrType: o.smartPtrType,
};
}
function throwInstanceAlreadyDeleted(obj) {
function getInstanceTypeName(handle) {
return handle.$$.ptrType.registeredClass.name;
}
throwBindingError(getInstanceTypeName(obj) + ' instance already deleted');
}
var finalizationGroup = false;
function detachFinalizer(handle) {}
function runDestructor($$) {
if ($$.smartPtr) {
$$.smartPtrType.rawDestructor($$.smartPtr);
} else {
$$.ptrType.registeredClass.rawDestructor($$.ptr);
}
}
function releaseClassHandle($$) {
$$.count.value -= 1;
var toDelete = 0 === $$.count.value;
if (toDelete) {
runDestructor($$);
}
}
function attachFinalizer(handle) {
if ('undefined' === typeof FinalizationGroup) {
attachFinalizer = function (handle) { return handle; };
return handle;
}
// If the running environment has a FinalizationGroup (see
// https://github.com/tc39/proposal-weakrefs), then attach finalizers
// for class handles. We check for the presence of FinalizationGroup
// at run-time, not build-time.
finalizationGroup = new FinalizationGroup(function (iter) {
for (var result = iter.next(); !result.done; result = iter.next()) {
var $$ = result.value;
if (!$$.ptr) {
console.warn('object already deleted: ' + $$.ptr);
} else {
releaseClassHandle($$);
}
}
});
attachFinalizer = function(handle) {
finalizationGroup.register(handle, handle.$$, handle.$$);
return handle;
};
detachFinalizer = function(handle) {
finalizationGroup.unregister(handle.$$);
};
return attachFinalizer(handle);
}
function ClassHandle_clone() {
if (!this.$$.ptr) {
throwInstanceAlreadyDeleted(this);
}
if (this.$$.preservePointerOnDelete) {
this.$$.count.value += 1;
return this;
} else {
var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), {
$$: {
value: shallowCopyInternalPointer(this.$$),
}
}));
clone.$$.count.value += 1;
clone.$$.deleteScheduled = false;
return clone;
}
}
function ClassHandle_delete() {
if (!this.$$.ptr) {
throwInstanceAlreadyDeleted(this);
}
if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
throwBindingError('Object already scheduled for deletion');
}
detachFinalizer(this);
releaseClassHandle(this.$$);
if (!this.$$.preservePointerOnDelete) {
this.$$.smartPtr = undefined;
this.$$.ptr = undefined;
}
}
function ClassHandle_isDeleted() {
return !this.$$.ptr;
}
var delayFunction = undefined;
var deletionQueue = [];
function flushPendingDeletes() {
while (deletionQueue.length) {
var obj = deletionQueue.pop();
obj.$$.deleteScheduled = false;
obj['delete']();
}
}
function ClassHandle_deleteLater() {
if (!this.$$.ptr) {
throwInstanceAlreadyDeleted(this);
}
if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
throwBindingError('Object already scheduled for deletion');
}
deletionQueue.push(this);
if (deletionQueue.length === 1 && delayFunction) {
delayFunction(flushPendingDeletes);
}
this.$$.deleteScheduled = true;
return this;
}
function init_ClassHandle() {
ClassHandle.prototype['isAliasOf'] = ClassHandle_isAliasOf;
ClassHandle.prototype['clone'] = ClassHandle_clone;
ClassHandle.prototype['delete'] = ClassHandle_delete;
ClassHandle.prototype['isDeleted'] = ClassHandle_isDeleted;
ClassHandle.prototype['deleteLater'] = ClassHandle_deleteLater;
}
function ClassHandle() {
}
var registeredPointers = {};
function ensureOverloadTable(proto, methodName, humanName) {
if (undefined === proto[methodName].overloadTable) {
var prevFunc = proto[methodName];
// Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
proto[methodName] = function() {
// TODO This check can be removed in -O3 level "unsafe" optimizations.
if (!proto[methodName].overloadTable.hasOwnProperty(arguments.length)) {
throwBindingError("Function '" + humanName + "' called with an invalid number of arguments (" + arguments.length + ") - expects one of (" + proto[methodName].overloadTable + ")!");
}
return proto[methodName].overloadTable[arguments.length].apply(this, arguments);
};
// Move the previous function into the overload table.
proto[methodName].overloadTable = [];
proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
}
}
/** @param {number=} numArguments */
function exposePublicSymbol(name, value, numArguments) {
if (Module.hasOwnProperty(name)) {
if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
throwBindingError("Cannot register public name '" + name + "' twice");
}
// We are exposing a function with the same name as an existing function. Create an overload table and a function selector
// that routes between the two.
ensureOverloadTable(Module, name, name);
if (Module.hasOwnProperty(numArguments)) {
throwBindingError("Cannot register multiple overloads of a function with the same number of arguments (" + numArguments + ")!");
}
// Add the new function into the overload table.
Module[name].overloadTable[numArguments] = value;
}
else {
Module[name] = value;
if (undefined !== numArguments) {
Module[name].numArguments = numArguments;
}
}
}
/** @constructor */
function RegisteredClass(
name,
constructor,
instancePrototype,
rawDestructor,
baseClass,
getActualType,
upcast,
downcast
) {
this.name = name;
this.constructor = constructor;
this.instancePrototype = instancePrototype;
this.rawDestructor = rawDestructor;
this.baseClass = baseClass;
this.getActualType = getActualType;
this.upcast = upcast;
this.downcast = downcast;
this.pureVirtualFunctions = [];
}
function upcastPointer(ptr, ptrClass, desiredClass) {
while (ptrClass !== desiredClass) {
if (!ptrClass.upcast) {
throwBindingError("Expected null or instance of " + desiredClass.name + ", got an instance of " + ptrClass.name);
}
ptr = ptrClass.upcast(ptr);
ptrClass = ptrClass.baseClass;
}
return ptr;
}
function constNoSmartPtrRawPointerToWireType(destructors, handle) {
if (handle === null) {
if (this.isReference) {
throwBindingError('null is not a valid ' + this.name);
}
return 0;
}
if (!handle.$$) {
throwBindingError('Cannot pass "' + _embind_repr(handle) + '" as a ' + this.name);
}
if (!handle.$$.ptr) {
throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
}
var handleClass = handle.$$.ptrType.registeredClass;
var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
return ptr;
}
function genericPointerToWireType(destructors, handle) {
var ptr;
if (handle === null) {
if (this.isReference) {
throwBindingError('null is not a valid ' + this.name);
}
if (this.isSmartPointer) {
ptr = this.rawConstructor();
if (destructors !== null) {
destructors.push(this.rawDestructor, ptr);
}
return ptr;
} else {
return 0;
}
}
if (!handle.$$) {
throwBindingError('Cannot pass "' + _embind_repr(handle) + '" as a ' + this.name);
}
if (!handle.$$.ptr) {
throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
}
if (!this.isConst && handle.$$.ptrType.isConst) {
throwBindingError('Cannot convert argument of type ' + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + ' to parameter type ' + this.name);
}
var handleClass = handle.$$.ptrType.registeredClass;
ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
if (this.isSmartPointer) {
// TODO: this is not strictly true
// We could support BY_EMVAL conversions from raw pointers to smart pointers
// because the smart pointer can hold a reference to the handle
if (undefined === handle.$$.smartPtr) {
throwBindingError('Passing raw pointer to smart pointer is illegal');
}
switch (this.sharingPolicy) {
case 0: // NONE
// no upcasting
if (handle.$$.smartPtrType === this) {
ptr = handle.$$.smartPtr;
} else {
throwBindingError('Cannot convert argument of type ' + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + ' to parameter type ' + this.name);
}
break;
case 1: // INTRUSIVE
ptr = handle.$$.smartPtr;
break;
case 2: // BY_EMVAL
if (handle.$$.smartPtrType === this) {
ptr = handle.$$.smartPtr;
} else {
var clonedHandle = handle['clone']();
ptr = this.rawShare(
ptr,
Emval.toHandle(function() {
clonedHandle['delete']();
})
);
if (destructors !== null) {
destructors.push(this.rawDestructor, ptr);
}
}
break;
default:
throwBindingError('Unsupporting sharing policy');
}
}
return ptr;
}
function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) {
if (handle === null) {
if (this.isReference) {
throwBindingError('null is not a valid ' + this.name);
}
return 0;
}
if (!handle.$$) {
throwBindingError('Cannot pass "' + _embind_repr(handle) + '" as a ' + this.name);
}
if (!handle.$$.ptr) {
throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
}
if (handle.$$.ptrType.isConst) {
throwBindingError('Cannot convert argument of type ' + handle.$$.ptrType.name + ' to parameter type ' + this.name);
}
var handleClass = handle.$$.ptrType.registeredClass;
var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
return ptr;
}
function RegisteredPointer_getPointee(ptr) {
if (this.rawGetPointee) {
ptr = this.rawGetPointee(ptr);
}
return ptr;
}
function RegisteredPointer_destructor(ptr) {
if (this.rawDestructor) {
this.rawDestructor(ptr);
}
}
function RegisteredPointer_deleteObject(handle) {
if (handle !== null) {
handle['delete']();
}
}
function downcastPointer(ptr, ptrClass, desiredClass) {
if (ptrClass === desiredClass) {
return ptr;
}
if (undefined === desiredClass.baseClass) {
return null; // no conversion
}
var rv = downcastPointer(ptr, ptrClass, desiredClass.baseClass);
if (rv === null) {
return null;
}
return desiredClass.downcast(rv);
}
function getInheritedInstanceCount() {
return Object.keys(registeredInstances).length;
}
function getLiveInheritedInstances() {
var rv = [];
for (var k in registeredInstances) {
if (registeredInstances.hasOwnProperty(k)) {
rv.push(registeredInstances[k]);
}
}
return rv;
}
function setDelayFunction(fn) {
delayFunction = fn;
if (deletionQueue.length && delayFunction) {
delayFunction(flushPendingDeletes);
}
}
function init_embind() {
Module['getInheritedInstanceCount'] = getInheritedInstanceCount;
Module['getLiveInheritedInstances'] = getLiveInheritedInstances;
Module['flushPendingDeletes'] = flushPendingDeletes;
Module['setDelayFunction'] = setDelayFunction;
}
var registeredInstances = {};
function getBasestPointer(class_, ptr) {
if (ptr === undefined) {
throwBindingError('ptr should not be undefined');
}
while (class_.baseClass) {
ptr = class_.upcast(ptr);
class_ = class_.baseClass;
}
return ptr;
}
function getInheritedInstance(class_, ptr) {
ptr = getBasestPointer(class_, ptr);
return registeredInstances[ptr];
}
function makeClassHandle(prototype, record) {
if (!record.ptrType || !record.ptr) {
throwInternalError('makeClassHandle requires ptr and ptrType');
}
var hasSmartPtrType = !!record.smartPtrType;
var hasSmartPtr = !!record.smartPtr;
if (hasSmartPtrType !== hasSmartPtr) {
throwInternalError('Both smartPtrType and smartPtr must be specified');
}
record.count = { value: 1 };
return attachFinalizer(Object.create(prototype, {
$$: {
value: record,
},
}));
}
function RegisteredPointer_fromWireType(ptr) {
// ptr is a raw pointer (or a raw smartpointer)
// rawPointer is a maybe-null raw pointer
var rawPointer = this.getPointee(ptr);
if (!rawPointer) {
this.destructor(ptr);
return null;
}
var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer);
if (undefined !== registeredInstance) {
// JS object has been neutered, time to repopulate it
if (0 === registeredInstance.$$.count.value) {
registeredInstance.$$.ptr = rawPointer;
registeredInstance.$$.smartPtr = ptr;
return registeredInstance['clone']();
} else {
// else, just increment reference count on existing object
// it already has a reference to the smart pointer
var rv = registeredInstance['clone']();
this.destructor(ptr);
return rv;
}
}
function makeDefaultHandle() {
if (this.isSmartPointer) {
return makeClassHandle(this.registeredClass.instancePrototype, {
ptrType: this.pointeeType,
ptr: rawPointer,
smartPtrType: this,
smartPtr: ptr,
});
} else {
return makeClassHandle(this.registeredClass.instancePrototype, {
ptrType: this,
ptr: ptr,
});
}
}
var actualType = this.registeredClass.getActualType(rawPointer);
var registeredPointerRecord = registeredPointers[actualType];
if (!registeredPointerRecord) {
return makeDefaultHandle.call(this);
}
var toType;
if (this.isConst) {
toType = registeredPointerRecord.constPointerType;
} else {
toType = registeredPointerRecord.pointerType;
}
var dp = downcastPointer(
rawPointer,
this.registeredClass,
toType.registeredClass);
if (dp === null) {
return makeDefaultHandle.call(this);
}
if (this.isSmartPointer) {
return makeClassHandle(toType.registeredClass.instancePrototype, {
ptrType: toType,
ptr: dp,
smartPtrType: this,
smartPtr: ptr,
});
} else {
return makeClassHandle(toType.registeredClass.instancePrototype, {
ptrType: toType,
ptr: dp,
});
}
}
function init_RegisteredPointer() {
RegisteredPointer.prototype.getPointee = RegisteredPointer_getPointee;
RegisteredPointer.prototype.destructor = RegisteredPointer_destructor;
RegisteredPointer.prototype['argPackAdvance'] = 8;
RegisteredPointer.prototype['readValueFromPointer'] = simpleReadValueFromPointer;
RegisteredPointer.prototype['deleteObject'] = RegisteredPointer_deleteObject;
RegisteredPointer.prototype['fromWireType'] = RegisteredPointer_fromWireType;
}
/** @constructor
@param {*=} pointeeType,
@param {*=} sharingPolicy,
@param {*=} rawGetPointee,
@param {*=} rawConstructor,
@param {*=} rawShare,
@param {*=} rawDestructor,
*/
function RegisteredPointer(
name,
registeredClass,
isReference,
isConst,
// smart pointer properties
isSmartPointer,
pointeeType,
sharingPolicy,
rawGetPointee,
rawConstructor,
rawShare,
rawDestructor
) {
this.name = name;
this.registeredClass = registeredClass;
this.isReference = isReference;
this.isConst = isConst;
// smart pointer properties
this.isSmartPointer = isSmartPointer;
this.pointeeType = pointeeType;
this.sharingPolicy = sharingPolicy;
this.rawGetPointee = rawGetPointee;
this.rawConstructor = rawConstructor;
this.rawShare = rawShare;
this.rawDestructor = rawDestructor;
if (!isSmartPointer && registeredClass.baseClass === undefined) {
if (isConst) {
this['toWireType'] = constNoSmartPtrRawPointerToWireType;
this.destructorFunction = null;
} else {
this['toWireType'] = nonConstNoSmartPtrRawPointerToWireType;
this.destructorFunction = null;
}
} else {
this['toWireType'] = genericPointerToWireType;
// Here we must leave this.destructorFunction undefined, since whether genericPointerToWireType returns
// a pointer that needs to be freed up is runtime-dependent, and cannot be evaluated at registration time.
// TODO: Create an alternative mechanism that allows removing the use of var destructors = []; array in
// craftInvokerFunction altogether.
}
}
/** @param {number=} numArguments */
function replacePublicSymbol(name, value, numArguments) {
if (!Module.hasOwnProperty(name)) {
throwInternalError('Replacing nonexistant public symbol');
}
// If there's an overload table for this symbol, replace the symbol in the overload table instead.
if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
Module[name].overloadTable[numArguments] = value;
}
else {
Module[name] = value;
Module[name].argCount = numArguments;
}
}
function dynCallLegacy(sig, ptr, args) { // viii\ 94  [5741320, 5744120, 131072]
var f = Module["dynCall_" + sig];
return args && args.length ? f.apply(null, [ptr].concat(args)) : f.call(null, ptr);
}
function dynCall(sig, ptr, args) {
return dynCallLegacy(sig, ptr, args);
}
function getDynCaller(sig, ptr) {// viii 94
var argCache = [];
return function() {
argCache.length = arguments.length;
for (var i = 0; i < arguments.length; i++) {
argCache[i] = arguments[i];
}
return dynCall(sig, ptr, argCache);
};
}
function embind__requireFunction(signature, rawFunction) {
signature = readLatin1String(signature);
function makeDynCaller() {
return getDynCaller(signature, rawFunction);
}
var fp = makeDynCaller();
if (typeof fp !== "function") {
throwBindingError("unknown function pointer with signature " + signature + ": " + rawFunction);
}
return fp;
}
var UnboundTypeError = undefined;
function getTypeName(type) {
var ptr = ___getTypeName(type);
var rv = readLatin1String(ptr);
_free(ptr);
return rv;
}
function throwUnboundTypeError(message, types) {
var unboundTypes = [];
var seen = {};
function visit(type) {
if (seen[type]) {
return;
}
if (registeredTypes[type]) {
return;
}
if (typeDependencies[type]) {
typeDependencies[type].forEach(visit);
return;
}
unboundTypes.push(type);
seen[type] = true;
}
types.forEach(visit);
throw new UnboundTypeError(message + ': ' + unboundTypes.map(getTypeName).join([', ']));
}
function __embind_register_class(
rawType,
rawPointerType,
rawConstPointerType,
baseClassRawType,
getActualTypeSignature,
getActualType,
upcastSignature,
upcast,
downcastSignature,
downcast,
name,
destructorSignature,
rawDestructor
) {
name = readLatin1String(name);
getActualType = embind__requireFunction(getActualTypeSignature, getActualType);
if (upcast) {
upcast = embind__requireFunction(upcastSignature, upcast);
}
if (downcast) {
downcast = embind__requireFunction(downcastSignature, downcast);
}
rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);
var legalFunctionName = makeLegalFunctionName(name);
exposePublicSymbol(legalFunctionName, function() {
// this code cannot run if baseClassRawType is zero
throwUnboundTypeError('Cannot construct ' + name + ' due to unbound types', [baseClassRawType]);
});
whenDependentTypesAreResolved(
[rawType, rawPointerType, rawConstPointerType],
baseClassRawType ? [baseClassRawType] : [],
function(base) {
base = base[0];
var baseClass;
var basePrototype;
if (baseClassRawType) {
baseClass = base.registeredClass;
basePrototype = baseClass.instancePrototype;
} else {
basePrototype = ClassHandle.prototype;
}
var constructor = createNamedFunction(legalFunctionName, function() {
if (Object.getPrototypeOf(this) !== instancePrototype) {
throw new BindingError("Use 'new' to construct " + name);
}
if (undefined === registeredClass.constructor_body) {
throw new BindingError(name + " has no accessible constructor");
}
var body = registeredClass.constructor_body[arguments.length];
if (undefined === body) {
throw new BindingError("Tried to invoke ctor of " + name + " with invalid number of parameters (" + arguments.length + ") - expected (" + Object.keys(registeredClass.constructor_body).toString() + ") parameters instead!");
}
return body.apply(this, arguments);
});
var instancePrototype = Object.create(basePrototype, {
constructor: { value: constructor },
});
constructor.prototype = instancePrototype;
var registeredClass = new RegisteredClass(
name,
constructor,
instancePrototype,
rawDestructor,
baseClass,
getActualType,
upcast,
downcast);
var referenceConverter = new RegisteredPointer(
name,
registeredClass,
true,
false,
false);
var pointerConverter = new RegisteredPointer(
name + '*',
registeredClass,
false,
false,
false);
var constPointerConverter = new RegisteredPointer(
name + ' const*',
registeredClass,
false,
true,
false);
registeredPointers[rawType] = {
pointerType: pointerConverter,
constPointerType: constPointerConverter
};
replacePublicSymbol(legalFunctionName, constructor);
return [referenceConverter, pointerConverter, constPointerConverter];
}
);
}
function heap32VectorToArray(count, firstElement) {
var array = [];
for (var i = 0; i < count; i++) {
array.push(HEAP32[(firstElement >> 2) + i]);
}
return array;
}
function __embind_register_class_constructor(
rawClassType,
argCount,
rawArgTypesAddr,
invokerSignature,
invoker,
rawConstructor
) {
assert(argCount > 0);
var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
invoker = embind__requireFunction(invokerSignature, invoker);
var args = [rawConstructor];
var destructors = [];
whenDependentTypesAreResolved([], [rawClassType], function(classType) {
classType = classType[0];
var humanName = 'constructor ' + classType.name;
if (undefined === classType.registeredClass.constructor_body) {
classType.registeredClass.constructor_body = [];
}
if (undefined !== classType.registeredClass.constructor_body[argCount - 1]) {
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!");
}
classType.registeredClass.constructor_body[argCount - 1] = function unboundTypeHandler() {
throwUnboundTypeError('Cannot construct ' + classType.name + ' due to unbound types', rawArgTypes);
};
whenDependentTypesAreResolved([], rawArgTypes, function(argTypes) {
// Insert empty slot for context type (argTypes[1]).
argTypes.splice(1, 0, null);
classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor);
return [];
});
return [];
});
}
function new_(constructor, argumentList) {
if (!(constructor instanceof Function)) {
throw new TypeError('new_ called with constructor type ' + typeof(constructor) + " which is not a function");
}
/*
* Previously, the following line was just:
function dummy() {};
* Unfortunately, Chrome was preserving 'dummy' as the object's name, even though at creation, the 'dummy' has the
* correct constructor name. Thus, objects created with IMVU.new would show up in the debugger as 'dummy', which
* isn't very helpful. Using IMVU.createNamedFunction addresses the issue. Doublely-unfortunately, there's no way
* to write a test for this behavior. -NRD 2013.02.22
*/
var dummy = createNamedFunction(constructor.name || 'unknownFunctionName', function(){});
dummy.prototype = constructor.prototype;
var obj = new dummy;
var r = constructor.apply(obj, argumentList);
return (r instanceof Object) ? r : obj;
}
function runAndAbortIfError(func) {
try {
return func();
} catch (e) {
abort(e);
}
}
function callUserCallback(func, synchronous) {
if (runtimeExited || ABORT) {
return;
}
// For synchronous calls, let any exceptions propagate, and don't let the runtime exit.
if (synchronous) {
func();
return;
}
try {
func();
} catch (e) {
handleException(e);
}
}
function runtimeKeepalivePush() {
runtimeKeepaliveCounter += 1;
}
function runtimeKeepalivePop() {
runtimeKeepaliveCounter -= 1;
}
var Asyncify = {State:{Normal:0,Unwinding:1,Rewinding:2,Disabled:3},state:0,StackSize:65536,currData:null,handleSleepReturnValue:0,exportCallStack:[],callStackNameToId:{},callStackIdToName:{},callStackId:0,asyncPromiseHandlers:null,sleepCallbacks:[],getCallStackId:function(funcName) {
var id = Asyncify.callStackNameToId[funcName];
if (id === undefined) {
id = Asyncify.callStackId++;
Asyncify.callStackNameToId[funcName] = id;
Asyncify.callStackIdToName[id] = funcName;
}
return id;
},instrumentWasmExports:function(exports) {
var ret = {};
for (var x in exports) {
(function(x) {
var original = exports[x];
if (typeof original === 'function') {
ret[x] = function() {
Asyncify.exportCallStack.push(x);
try {
return original.apply(null, arguments);
} finally {
if (!ABORT) {
var y = Asyncify.exportCallStack.pop();
assert(y === x);
Asyncify.maybeStopUnwind();
}
}
};
} else {
ret[x] = original;
}
})(x);
}
return ret;
},maybeStopUnwind:function() {
if (Asyncify.currData &&
Asyncify.state === Asyncify.State.Unwinding &&
Asyncify.exportCallStack.length === 0) {
// We just finished unwinding.
Asyncify.state = Asyncify.State.Normal;
// Keep the runtime alive so that a re-wind can be done later.
runAndAbortIfError(Module['_asyncify_stop_unwind']);
if (typeof Fibers !== 'undefined') {
Fibers.trampoline();
}
}
},whenDone:function() {
return new Promise(function(resolve, reject) {
Asyncify.asyncPromiseHandlers = {
resolve: resolve,
reject: reject
};
});
},allocateData:function() {
// An asyncify data structure has three fields:
// 0 current stack pos
// 4 max stack pos
// 8 id of function at bottom of the call stack (callStackIdToName[id] == name of js function)
//
// The Asyncify ABI only interprets the first two fields, the rest is for the runtime.
// We also embed a stack in the same memory region here, right next to the structure.
// This struct is also defined as asyncify_data_t in emscripten/fiber.h
var ptr = _malloc(12 + Asyncify.StackSize);
Asyncify.setDataHeader(ptr, ptr + 12, Asyncify.StackSize);
Asyncify.setDataRewindFunc(ptr);
return ptr;
},setDataHeader:function(ptr, stack, stackSize) {
HEAP32[((ptr)>>2)] = stack;
HEAP32[(((ptr)+(4))>>2)] = stack + stackSize;
},setDataRewindFunc:function(ptr) {
var bottomOfCallStack = Asyncify.exportCallStack[0];
var rewindId = Asyncify.getCallStackId(bottomOfCallStack);
HEAP32[(((ptr)+(8))>>2)] = rewindId;
},getDataRewindFunc:function(ptr) {
var id = HEAP32[(((ptr)+(8))>>2)];
var name = Asyncify.callStackIdToName[id];
var func = Module['asm'][name];
return func;
},doRewind:function(ptr) {
var start = Asyncify.getDataRewindFunc(ptr);
// Once we have rewound and the stack we no longer need to artificially keep
// the runtime alive.
return start();
},handleSleep:function(startAsync) {
if (ABORT) return;
if (Asyncify.state === Asyncify.State.Normal) {
// Prepare to sleep. Call startAsync, and see what happens:
// if the code decided to call our callback synchronously,
// then no async operation was in fact begun, and we don't
// need to do anything.
var reachedCallback = false;
var reachedAfterCallback = false;
startAsync(function(handleSleepReturnValue) {
if (ABORT) return;
Asyncify.handleSleepReturnValue = handleSleepReturnValue || 0;
reachedCallback = true;
if (!reachedAfterCallback) {
// We are happening synchronously, so no need for async.
return;
}
Asyncify.state = Asyncify.State.Rewinding;
runAndAbortIfError(function() { Module['_asyncify_start_rewind'](Asyncify.currData) });
if (typeof Browser !== 'undefined' && Browser.mainLoop.func) {
Browser.mainLoop.resume();
}
var asyncWasmReturnValue, isError = false;
try {
asyncWasmReturnValue = Asyncify.doRewind(Asyncify.currData);
} catch (err) {
asyncWasmReturnValue = err;
isError = true;
}
// Track whether the return value was handled by any promise handlers.
var handled = false;
if (!Asyncify.currData) {
// All asynchronous execution has finished.
// `asyncWasmReturnValue` now contains the final
// return value of the exported async WASM function.
//
// Note: `asyncWasmReturnValue` is distinct from
// `Asyncify.handleSleepReturnValue`.
// `Asyncify.handleSleepReturnValue` contains the return
// value of the last C function to have executed
// `Asyncify.handleSleep()`, where as `asyncWasmReturnValue`
// contains the return value of the exported WASM function
// that may have called C functions that
// call `Asyncify.handleSleep()`.
var asyncPromiseHandlers = Asyncify.asyncPromiseHandlers;
if (asyncPromiseHandlers) {
Asyncify.asyncPromiseHandlers = null;
(isError ? asyncPromiseHandlers.reject : asyncPromiseHandlers.resolve)(asyncWasmReturnValue);
handled = true;
}
}
if (isError && !handled) {
// If there was an error and it was not handled by now, we have no choice but to
// rethrow that error into the global scope where it can be caught only by
// `onerror` or `onunhandledpromiserejection`.
throw asyncWasmReturnValue;
}
});
reachedAfterCallback = true;
if (!reachedCallback) {
// A true async operation was begun; start a sleep.
Asyncify.state = Asyncify.State.Unwinding;
// TODO: reuse, don't alloc/free every sleep
Asyncify.currData = Asyncify.allocateData();
runAndAbortIfError(function() { Module['_asyncify_start_unwind'](Asyncify.currData) });
if (typeof Browser !== 'undefined' && Browser.mainLoop.func) {
Browser.mainLoop.pause();
}
}
} else if (Asyncify.state === Asyncify.State.Rewinding) {
// Stop a resume.
Asyncify.state = Asyncify.State.Normal;
runAndAbortIfError(Module['_asyncify_stop_rewind']);
_free(Asyncify.currData);
Asyncify.currData = null;
// Call all sleep callbacks now that the sleep-resume is all done.
Asyncify.sleepCallbacks.forEach(function(func) {
callUserCallback(func);
});
} else {
abort('invalid state: ' + Asyncify.state);
}
return Asyncify.handleSleepReturnValue;
},handleAsync:function(startAsync) {
return Asyncify.handleSleep(function(wakeUp) {
// TODO: add error handling as a second param when handleSleep implements it.
startAsync().then(wakeUp);
});
}};
function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc) {
// humanName: a human-readable string name for the function to be generated.
// argTypes: An array that contains the embind type objects for all types in the function signature.
// argTypes[0] is the type object for the function return value.
// argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
// argTypes[2...] are the actual function parameters.
// classType: The embind type object for the class to be bound, or null if this is not a method of a class.
// cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
// cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
var argCount = argTypes.length;
if (argCount < 2) {
throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
}
var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
// Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
// TODO: This omits argument count check - enable only at -O3 or similar.
// if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
// return FUNCTION_TABLE[fn];
// }
// Determine if we need to use a dynamic stack to store the destructors for the function parameters.
// TODO: Remove this completely once all function invokers are being dynamically generated.
var needsDestructorStack = false;
for (var i = 1; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here.
if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) { // The type does not define a destructor function - must use dynamic stack
needsDestructorStack = true;
break;
}
}
var returns = (argTypes[0].name !== "void");
var argsList = "";
var argsListWired = "";
for (var i = 0; i < argCount - 2; ++i) {
argsList += (i!==0?", ":"")+"arg"+i;
argsListWired += (i!==0?", ":"")+"arg"+i+"Wired";
}
var invokerFnBody =
"return function "+makeLegalFunctionName(humanName)+"("+argsList+") {\n" +
"if (arguments.length !== "+(argCount - 2)+") {\n" +
"throwBindingError('function "+humanName+" called with ' + arguments.length + ' arguments, expected "+(argCount - 2)+" args!');\n" +
"}\n";
if (needsDestructorStack) {
invokerFnBody +=
"var destructors = [];\n";
}
var dtorStack = needsDestructorStack ? "destructors" : "null";
var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
if (isClassMethodFunc) {
invokerFnBody += "var thisWired = classParam.toWireType("+dtorStack+", this);\n";
}
for (var i = 0; i < argCount - 2; ++i) {
invokerFnBody += "var arg"+i+"Wired = argType"+i+".toWireType("+dtorStack+", arg"+i+"); // "+argTypes[i+2].name+"\n";
args1.push("argType"+i);
args2.push(argTypes[i+2]);
}
if (isClassMethodFunc) {
argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
}
invokerFnBody +=
(returns?"var rv = ":"") + "invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";
args1.push("Asyncify");
args2.push(Asyncify);
invokerFnBody += "function onDone(" + (returns ? "rv" : "") + ") {\n";
if (needsDestructorStack) {
invokerFnBody += "runDestructors(destructors);\n";
} else {
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.
var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
if (argTypes[i].destructorFunction !== null) {
invokerFnBody += paramName+"_dtor("+paramName+"); // "+argTypes[i].name+"\n";
args1.push(paramName+"_dtor");
args2.push(argTypes[i].destructorFunction);
}
}
}
if (returns) {
invokerFnBody += "var ret = retType.fromWireType(rv);\n" +
"return ret;\n";
} else {
}
invokerFnBody += "}\n";
invokerFnBody += "return Asyncify.currData ? Asyncify.whenDone().then(onDone) : onDone(" + (returns ? "rv" : "") +");\n"
invokerFnBody += "}\n";
args1.push(invokerFnBody);
var invokerFunction = new_(Function, args1).apply(null, args2);
return invokerFunction;
}
function __embind_register_class_function(
rawClassType,
methodName,
argCount,
rawArgTypesAddr, // [ReturnType, ThisType, Args...]
invokerSignature,
rawInvoker,
context,
isPureVirtual
) {
var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
methodName = readLatin1String(methodName);
rawInvoker = embind__requireFunction(invokerSignature, rawInvoker);
whenDependentTypesAreResolved([], [rawClassType], function(classType) {
classType = classType[0];
var humanName = classType.name + '.' + methodName;
if (methodName.startsWith("@@")) {
methodName = Symbol[methodName.substring(2)];
}
if (isPureVirtual) {
classType.registeredClass.pureVirtualFunctions.push(methodName);
}
function unboundTypesHandler() {
throwUnboundTypeError('Cannot call ' + humanName + ' due to unbound types', rawArgTypes);
}
var proto = classType.registeredClass.instancePrototype;
var method = proto[methodName];
if (undefined === method || (undefined === method.overloadTable && method.className !== classType.name && method.argCount === argCount - 2)) {
// This is the first overload to be registered, OR we are replacing a function in the base class with a function in the derived class.
unboundTypesHandler.argCount = argCount - 2;
unboundTypesHandler.className = classType.name;
proto[methodName] = unboundTypesHandler;
} else {
// There was an existing function with the same name registered. Set up a function overload routing table.
ensureOverloadTable(proto, methodName, humanName);
proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler;
}
whenDependentTypesAreResolved([], rawArgTypes, function(argTypes) {
var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context);
// Replace the initial unbound-handler-stub function with the appropriate member function, now that all types
// are resolved. If multiple overloads are registered for this function, the function goes into an overload table.
if (undefined === proto[methodName].overloadTable) {
// Set argCount in case an overload is registered later
memberFunction.argCount = argCount - 2;
proto[methodName] = memberFunction;
} else {
proto[methodName].overloadTable[argCount - 2] = memberFunction;
}
return [];
});
return [];
});
}
var emval_free_list = [];
var emval_handle_array = [{},{value:undefined},{value:null},{value:true},{value:false}];
function __emval_decref(handle) {
if (handle > 4 && 0 === --emval_handle_array[handle].refcount) {
emval_handle_array[handle] = undefined;
emval_free_list.push(handle);
}
}
function count_emval_handles() {
var count = 0;
for (var i = 5; i < emval_handle_array.length; ++i) {
if (emval_handle_array[i] !== undefined) {
++count;
}
}
return count;
}
function get_first_emval() {
for (var i = 5; i < emval_handle_array.length; ++i) {
if (emval_handle_array[i] !== undefined) {
return emval_handle_array[i];
}
}
return null;
}
function init_emval() {
Module['count_emval_handles'] = count_emval_handles;
Module['get_first_emval'] = get_first_emval;
}
var Emval = {toValue:function(handle) {
if (!handle) {
throwBindingError('Cannot use deleted val. handle = ' + handle);
}
return emval_handle_array[handle].value;
},toHandle:function(value) {
switch (value) {
case undefined :{ return 1; }
case null :{ return 2; }
case true :{ return 3; }
case false :{ return 4; }
default:{
var handle = emval_free_list.length ?
emval_free_list.pop() :
emval_handle_array.length;
emval_handle_array[handle] = {refcount: 1, value: value};
return handle;
}
}
}};
function __embind_register_emval(rawType, name) {
name = readLatin1String(name);
registerType(rawType, {
name: name,
'fromWireType': function(handle) {
var rv = Emval.toValue(handle);
__emval_decref(handle);
return rv;
},
'toWireType': function(destructors, value) {
return Emval.toHandle(value);
},
'argPackAdvance': 8,
'readValueFromPointer': simpleReadValueFromPointer,
destructorFunction: null, // This type does not need a destructor
// TODO: do we need a deleteObject here? write a test where
// emval is passed into JS via an interface
});
}
function _embind_repr(v) {
if (v === null) {
return 'null';
}
var t = typeof v;
if (t === 'object' || t === 'array' || t === 'function') {
return v.toString();
} else {
return '' + v;
}
}
function floatReadValueFromPointer(name, shift) {
switch (shift) {
case 2: return function(pointer) {
return this['fromWireType'](HEAPF32[pointer >> 2]);
};
case 3: return function(pointer) {
return this['fromWireType'](HEAPF64[pointer >> 3]);
};
default:
throw new TypeError("Unknown float type: " + name);
}
}
function __embind_register_float(rawType, name, size) {
var shift = getShiftFromSize(size);
name = readLatin1String(name);
registerType(rawType, {
name: name,
'fromWireType': function(value) {
return value;
},
'toWireType': function(destructors, value) {
// The VM will perform JS to Wasm value conversion, according to the spec:
// https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
return value;
},
'argPackAdvance': 8,
'readValueFromPointer': floatReadValueFromPointer(name, shift),
destructorFunction: null, // This type does not need a destructor
});
}
function __embind_register_function(name, argCount, rawArgTypesAddr, signature, rawInvoker, fn) {
var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
name = readLatin1String(name);
rawInvoker = embind__requireFunction(signature, rawInvoker);
exposePublicSymbol(name, function() {
throwUnboundTypeError('Cannot call ' + name + ' due to unbound types', argTypes);
}, argCount - 1);
whenDependentTypesAreResolved([], argTypes, function(argTypes) {
var invokerArgsArray = [argTypes[0] /* return value */, null /* no class 'this'*/].concat(argTypes.slice(1) /* actual params */);
replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null /* no class 'this'*/, rawInvoker, fn), argCount - 1);
return [];
});
}
function integerReadValueFromPointer(name, shift, signed) {
// integers are quite common, so generate very specialized functions
switch (shift) {
case 0: return signed ?
function readS8FromPointer(pointer) { return HEAP8[pointer]; } :
function readU8FromPointer(pointer) { return HEAPU8[pointer]; };
case 1: return signed ?
function readS16FromPointer(pointer) { return HEAP16[pointer >> 1]; } :
function readU16FromPointer(pointer) { return HEAPU16[pointer >> 1]; };
case 2: return signed ?
function readS32FromPointer(pointer) { return HEAP32[pointer >> 2]; } :
function readU32FromPointer(pointer) { return HEAPU32[pointer >> 2]; };
default:
throw new TypeError("Unknown integer type: " + name);
}
}
function __embind_register_integer(primitiveType, name, size, minRange, maxRange) {
name = readLatin1String(name);
if (maxRange === -1) { // LLVM doesn't have signed and unsigned 32-bit types, so u32 literals come out as 'i32 -1'. Always treat those as max u32.
maxRange = 4294967295;
}
var shift = getShiftFromSize(size);
var fromWireType = function(value) {
return value;
};
if (minRange === 0) {
var bitshift = 32 - 8*size;
fromWireType = function(value) {
return (value << bitshift) >>> bitshift;
};
}
var isUnsignedType = (name.includes('unsigned'));
registerType(primitiveType, {
name: name,
'fromWireType': fromWireType,
'toWireType': function(destructors, value) {
// todo: Here we have an opportunity for -O3 level "unsafe" optimizations: we could
// avoid the following two if()s and assume value is of proper type.
if (typeof value !== "number" && typeof value !== "boolean") {
throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name);
}
if (value < minRange || value > maxRange) {
throw new TypeError('Passing a number "' + _embind_repr(value) + '" from JS side to C/C++ side to an argument of type "' + name + '", which is outside the valid range [' + minRange + ', ' + maxRange + ']!');
}
return isUnsignedType ? (value >>> 0) : (value | 0);
},
'argPackAdvance': 8,
'readValueFromPointer': integerReadValueFromPointer(name, shift, minRange !== 0),
destructorFunction: null, // This type does not need a destructor
});
}
function __embind_register_memory_view(rawType, dataTypeIndex, name) {
var typeMapping = [
Int8Array,
Uint8Array,
Int16Array,
Uint16Array,
Int32Array,
Uint32Array,
Float32Array,
Float64Array,
];
var TA = typeMapping[dataTypeIndex];
function decodeMemoryView(handle) {
handle = handle >> 2;
var heap = HEAPU32;
var size = heap[handle]; // in elements
var data = heap[handle + 1]; // byte offset into emscripten heap
return new TA(buffer, data, size);
}
name = readLatin1String(name);
registerType(rawType, {
name: name,
'fromWireType': decodeMemoryView,
'argPackAdvance': 8,
'readValueFromPointer': decodeMemoryView,
}, {
ignoreDuplicateRegistrations: true,
});
}
function __embind_register_std_string(rawType, name) {
name = readLatin1String(name);
var stdStringIsUTF8
//process only std::string bindings with UTF8 support, in contrast to e.g. std::basic_string<unsigned char>
= (name === "std::string");
registerType(rawType, {
name: name,
'fromWireType': function(value) {
var length = HEAPU32[value >> 2];
var str;
if (stdStringIsUTF8) {
var decodeStartPtr = value + 4;
// Looping here to support possible embedded '0' bytes
for (var i = 0; i <= length; ++i) {
var currentBytePtr = value + 4 + i;
if (i == length || HEAPU8[currentBytePtr] == 0) {
var maxRead = currentBytePtr - decodeStartPtr;
var stringSegment = UTF8ToString(decodeStartPtr, maxRead);
if (str === undefined) {
str = stringSegment;
} else {
str += String.fromCharCode(0);
str += stringSegment;
}
decodeStartPtr = currentBytePtr + 1;
}
}
} else {
var a = new Array(length);
for (var i = 0; i < length; ++i) {
a[i] = String.fromCharCode(HEAPU8[value + 4 + i]);
}
str = a.join('');
}
_free(value);
return str;
},
'toWireType': function(destructors, value) {
if (value instanceof ArrayBuffer) {
value = new Uint8Array(value);
}
var getLength;
var valueIsOfTypeString = (typeof value === 'string');
if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {
throwBindingError('Cannot pass non-string to std::string');
}
if (stdStringIsUTF8 && valueIsOfTypeString) {
getLength = function() {return lengthBytesUTF8(value);};
} else {
getLength = function() {return value.length;};
}
// assumes 4-byte alignment
var length = getLength();
var ptr = _malloc(4 + length + 1);
HEAPU32[ptr >> 2] = length;
if (stdStringIsUTF8 && valueIsOfTypeString) {
stringToUTF8(value, ptr + 4, length + 1);
} else {
if (valueIsOfTypeString) {
for (var i = 0; i < length; ++i) {
var charCode = value.charCodeAt(i);
if (charCode > 255) {
_free(ptr);
throwBindingError('String has UTF-16 code units that do not fit in 8 bits');
}
HEAPU8[ptr + 4 + i] = charCode;
}
} else {
for (var i = 0; i < length; ++i) {
HEAPU8[ptr + 4 + i] = value[i];
}
}
}
if (destructors !== null) {
destructors.push(_free, ptr);
}
return ptr;
},
'argPackAdvance': 8,
'readValueFromPointer': simpleReadValueFromPointer,
destructorFunction: function(ptr) { _free(ptr); },
});
}
function __embind_register_std_wstring(rawType, charSize, name) {
name = readLatin1String(name);
var decodeString, encodeString, getHeap, lengthBytesUTF, shift;
if (charSize === 2) {
decodeString = UTF16ToString;
encodeString = stringToUTF16;
lengthBytesUTF = lengthBytesUTF16;
getHeap = function() { return HEAPU16; };
shift = 1;
} else if (charSize === 4) {
decodeString = UTF32ToString;
encodeString = stringToUTF32;
lengthBytesUTF = lengthBytesUTF32;
getHeap = function() { return HEAPU32; };
shift = 2;
}
registerType(rawType, {
name: name,
'fromWireType': function(value) {
// Code mostly taken from _embind_register_std_string fromWireType
var length = HEAPU32[value >> 2];
var HEAP = getHeap();
var str;
var decodeStartPtr = value + 4;
// Looping here to support possible embedded '0' bytes
for (var i = 0; i <= length; ++i) {
var currentBytePtr = value + 4 + i * charSize;
if (i == length || HEAP[currentBytePtr >> shift] == 0) {
var maxReadBytes = currentBytePtr - decodeStartPtr;
var stringSegment = decodeString(decodeStartPtr, maxReadBytes);
if (str === undefined) {
str = stringSegment;
} else {
str += String.fromCharCode(0);
str += stringSegment;
}
decodeStartPtr = currentBytePtr + charSize;
}
}
_free(value);
return str;
},
'toWireType': function(destructors, value) {
if (!(typeof value === 'string')) {
throwBindingError('Cannot pass non-string to C++ string type ' + name);
}
// assumes 4-byte alignment
var length = lengthBytesUTF(value);
var ptr = _malloc(4 + length + charSize);
HEAPU32[ptr >> 2] = length >> shift;
encodeString(value, ptr + 4, length + charSize);
if (destructors !== null) {
destructors.push(_free, ptr);
}
return ptr;
},
'argPackAdvance': 8,
'readValueFromPointer': simpleReadValueFromPointer,
destructorFunction: function(ptr) { _free(ptr); },
});
}
function __embind_register_value_object(
rawType,
name,
constructorSignature,
rawConstructor,
destructorSignature,
rawDestructor
) {
structRegistrations[rawType] = {
name: readLatin1String(name),
rawConstructor: embind__requireFunction(constructorSignature, rawConstructor),
rawDestructor: embind__requireFunction(destructorSignature, rawDestructor),
fields: [],
};
}
function __embind_register_value_object_field(
structType,
fieldName,
getterReturnType,
getterSignature,
getter,
getterContext,
setterArgumentType,
setterSignature,
setter,
setterContext
) {
structRegistrations[structType].fields.push({
fieldName: readLatin1String(fieldName),
getterReturnType: getterReturnType,
getter: embind__requireFunction(getterSignature, getter),
getterContext: getterContext,
setterArgumentType: setterArgumentType,
setter: embind__requireFunction(setterSignature, setter),
setterContext: setterContext,
});
}
function __embind_register_void(rawType, name) {
name = readLatin1String(name);
registerType(rawType, {
isVoid: true, // void return values can be optimized out sometimes
name: name,
'argPackAdvance': 0,
'fromWireType': function() {
return undefined;
},
'toWireType': function(destructors, o) {
// TODO: assert if anything else is given?
return undefined;
},
});
}
function _abort() {
abort('');
}
function _clock() {
if (_clock.start === undefined) _clock.start = Date.now();
return ((Date.now() - _clock.start) * (1000000 / 1000))|0;
}
var _emscripten_get_now;if (typeof performance !== 'undefined' && performance.now) {
_emscripten_get_now = function() { return performance.now(); }
} else {
_emscripten_get_now = Date.now;
}
var _emscripten_get_now_is_monotonic =
((typeof performance === 'object' && performance && typeof performance['now'] === 'function')
);;
function _clock_gettime(clk_id, tp) {
// int clock_gettime(clockid_t clk_id, struct timespec *tp);
var now;
if (clk_id === 0) {
now = Date.now();
} else if ((clk_id === 1 || clk_id === 4) && _emscripten_get_now_is_monotonic) {
now = _emscripten_get_now();
} else {
setErrNo(28);
return -1;
}
HEAP32[((tp)>>2)] = (now/1000)|0; // seconds
HEAP32[(((tp)+(4))>>2)] = ((now % 1000)*1000*1000)|0; // nanoseconds
return 0;
}
var readAsmConstArgsArray = [];
function readAsmConstArgs(sigPtr, buf) {
;
readAsmConstArgsArray.length = 0;
var ch;
// Most arguments are i32s, so shift the buffer pointer so it is a plain
// index into HEAP32.
buf >>= 2;
while (ch = HEAPU8[sigPtr++]) {
// A double takes two 32-bit slots, and must also be aligned - the backend
// will emit padding to avoid that.
var readAsmConstArgsDouble = ch < 105;
if (readAsmConstArgsDouble && (buf & 1)) buf++;
readAsmConstArgsArray.push(readAsmConstArgsDouble ? HEAPF64[buf++ >> 1] : HEAP32[buf]);
++buf;
}
return readAsmConstArgsArray;
}
function _emscripten_asm_const_int(code, sigPtr, argbuf) {
var args = readAsmConstArgs(sigPtr, argbuf);
return ASM_CONSTS[code].apply(null, args);
}
var _emscripten_memcpy_big = Uint8Array.prototype.copyWithin
? function(dest, src, num) { HEAPU8.copyWithin(dest, src, src + num); }
: function(dest, src, num) { HEAPU8.set(HEAPU8.subarray(src, src+num), dest); }
;
function emscripten_realloc_buffer(size) {
try {
// round size grow request up to wasm page size (fixed 64KB per spec)
wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16); // .grow() takes a delta compared to the previous size
updateGlobalBufferAndViews(wasmMemory.buffer);
return 1 /*success*/;
} catch(e) {
}
// implicit 0 return to save code size (caller will cast "undefined" into 0
// anyhow)
}
function _emscripten_resize_heap(requestedSize) {
var oldSize = HEAPU8.length;
requestedSize = requestedSize >>> 0;
// With pthreads, races can happen (another thread might increase the size in between), so return a failure, and let the caller retry.
// Memory resize rules:
// 1. Always increase heap size to at least the requested size, rounded up to next page multiple.
// 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap geometrically: increase the heap size according to
// MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%),
// At most overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB).
// 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap linearly: increase the heap size by at least MEMORY_GROWTH_LINEAR_STEP bytes.
// 3. Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest
// 4. If we were unable to allocate as much memory, it may be due to over-eager decision to excessively reserve due to (3) above.
// Hence if an allocation fails, cut down on the amount of excess growth, in an attempt to succeed to perform a smaller allocation.
// A limit is set for how much we can grow. We should not exceed that
// (the wasm binary specifies it, so if we tried, we'd fail anyhow).
// In CAN_ADDRESS_2GB mode, stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate full 4GB Wasm memories, the size will wrap
// back to 0 bytes in Wasm side for any code that deals with heap sizes, which would require special casing all heap size related code to treat
// 0 specially.
var maxHeapSize = MAX_HEAP_SIZE;
if (requestedSize > maxHeapSize) {
return false;
}
// Loop through potential heap size increases. If we attempt a too eager reservation that fails, cut down on the
// attempted size and reserve a smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); // ensure geometric growth
// but limit overreserving (default to capping at +96MB overgrowth at most)
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296 );
var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
var replacement = emscripten_realloc_buffer(newSize);
if (replacement) {
return true;
}
}
return false;
}
var ENV = {};
function getExecutableName() {
return thisProgram || './this.program';
}
function getEnvStrings() {
if (!getEnvStrings.strings) {
// Default values.
// Browser language detection #8751
var lang = ((typeof navigator === 'object' && navigator.languages && navigator.languages[0]) || 'C').replace('-', '_') + '.UTF-8';
var env = {
'USER': 'web_user',
'LOGNAME': 'web_user',
'PATH': '/',
'PWD': '/',
'HOME': '/home/web_user',
'LANG': lang,
'_': getExecutableName()
};
// Apply the user-provided values, if any.
for (var x in ENV) {
// x is a key in ENV; if ENV[x] is undefined, that means it was
// explicitly set to be so. We allow user code to do that to
// force variables with default values to remain unset.
if (ENV[x] === undefined) delete env[x];
else env[x] = ENV[x];
}
var strings = [];
for (var x in env) {
strings.push(x + '=' + env[x]);
}
getEnvStrings.strings = strings;
}
return getEnvStrings.strings;
}
function _environ_get(__environ, environ_buf) {
var bufSize = 0;
getEnvStrings().forEach(function(string, i) {
var ptr = environ_buf + bufSize;
HEAP32[(((__environ)+(i * 4))>>2)] = ptr;
writeAsciiToMemory(string, ptr);
bufSize += string.length + 1;
});
return 0;
}
function _environ_sizes_get(penviron_count, penviron_buf_size) {
var strings = getEnvStrings();
HEAP32[((penviron_count)>>2)] = strings.length;
var bufSize = 0;
strings.forEach(function(string) {
bufSize += string.length + 1;
});
HEAP32[((penviron_buf_size)>>2)] = bufSize;
return 0;
}
function _exit(status) {
// void _exit(int status);
// http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html
exit(status);
}
function _fd_close(fd) {
return 0;
}
function _fd_fdstat_get(fd, pbuf) {
// hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
var type = fd == 1 || fd == 2 ? 2 : abort();
HEAP8[((pbuf)>>0)] = type;
// TODO HEAP16[(((pbuf)+(2))>>1)] = ?;
// TODO (tempI64 = [?>>>0,(tempDouble=?,(+(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[(((pbuf)+(8))>>2)] = tempI64[0],HEAP32[(((pbuf)+(12))>>2)] = tempI64[1]);
// TODO (tempI64 = [?>>>0,(tempDouble=?,(+(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[(((pbuf)+(16))>>2)] = tempI64[0],HEAP32[(((pbuf)+(20))>>2)] = tempI64[1]);
return 0;
}
function _fd_read(fd, iov, iovcnt, pnum) {
var stream = SYSCALLS.getStreamFromFD(fd);
var num = SYSCALLS.doReadv(stream, iov, iovcnt);
HEAP32[((pnum)>>2)] = num;
return 0;
}
function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {
}
function flush_NO_FILESYSTEM() {
// flush anything remaining in the buffers during shutdown
if (typeof _fflush !== 'undefined') _fflush(0);
var buffers = SYSCALLS.buffers;
if (buffers[1].length) SYSCALLS.printChar(1, 10);
if (buffers[2].length) SYSCALLS.printChar(2, 10);
}
function _fd_write(fd, iov, iovcnt, pnum) {
;
// hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
var num = 0;
for (var i = 0; i < iovcnt; i++) {
var ptr = HEAP32[((iov)>>2)];
var len = HEAP32[(((iov)+(4))>>2)];
iov += 8;
for (var j = 0; j < len; j++) {
SYSCALLS.printChar(fd, HEAPU8[ptr+j]);
}
num += len;
}
HEAP32[((pnum)>>2)] = num;
return 0;
}
function _gettimeofday(ptr) {
var now = Date.now();
HEAP32[((ptr)>>2)] = (now/1000)|0; // seconds
HEAP32[(((ptr)+(4))>>2)] = ((now % 1000)*1000)|0; // microseconds
return 0;
}
function _mktime(tmPtr) {
_tzset();
var date = new Date(HEAP32[(((tmPtr)+(20))>>2)] + 1900,
HEAP32[(((tmPtr)+(16))>>2)],
HEAP32[(((tmPtr)+(12))>>2)],
HEAP32[(((tmPtr)+(8))>>2)],
HEAP32[(((tmPtr)+(4))>>2)],
HEAP32[((tmPtr)>>2)],
0);
// There's an ambiguous hour when the time goes back; the tm_isdst field is
// used to disambiguate it. Date() basically guesses, so we fix it up if it
// guessed wrong, or fill in tm_isdst with the guess if it's -1.
var dst = HEAP32[(((tmPtr)+(32))>>2)];
var guessedOffset = date.getTimezoneOffset();
var start = new Date(date.getFullYear(), 0, 1);
var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
var winterOffset = start.getTimezoneOffset();
var dstOffset = Math.min(winterOffset, summerOffset); // DST is in December in South
if (dst < 0) {
// Attention: some regions don't have DST at all.
HEAP32[(((tmPtr)+(32))>>2)] = Number(summerOffset != winterOffset && dstOffset == guessedOffset);
} else if ((dst > 0) != (dstOffset == guessedOffset)) {
var nonDstOffset = Math.max(winterOffset, summerOffset);
var trueOffset = dst > 0 ? dstOffset : nonDstOffset;
// Don't try setMinutes(date.getMinutes() + ...) -- it's messed up.
date.setTime(date.getTime() + (trueOffset - guessedOffset)*60000);
}
HEAP32[(((tmPtr)+(24))>>2)] = date.getDay();
var yday = ((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))|0;
HEAP32[(((tmPtr)+(28))>>2)] = yday;
// To match expected behavior, update fields from date
HEAP32[((tmPtr)>>2)] = date.getSeconds();
HEAP32[(((tmPtr)+(4))>>2)] = date.getMinutes();
HEAP32[(((tmPtr)+(8))>>2)] = date.getHours();
HEAP32[(((tmPtr)+(12))>>2)] = date.getDate();
HEAP32[(((tmPtr)+(16))>>2)] = date.getMonth();
return (date.getTime() / 1000)|0;
}
function _setTempRet0(val) {
setTempRet0(val);
}
function __isLeapYear(year) {
return year%4 === 0 && (year%100 !== 0 || year%400 === 0);
}
function __arraySum(array, index) {
var sum = 0;
for (var i = 0; i <= index; sum += array[i++]) {
// no-op
}
return sum;
}
var __MONTH_DAYS_LEAP = [31,29,31,30,31,30,31,31,30,31,30,31];
var __MONTH_DAYS_REGULAR = [31,28,31,30,31,30,31,31,30,31,30,31];
function __addDays(date, days) {
var newDate = new Date(date.getTime());
while (days > 0) {
var leap = __isLeapYear(newDate.getFullYear());
var currentMonth = newDate.getMonth();
var daysInCurrentMonth = (leap ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR)[currentMonth];
if (days > daysInCurrentMonth-newDate.getDate()) {
// we spill over to next month
days -= (daysInCurrentMonth-newDate.getDate()+1);
newDate.setDate(1);
if (currentMonth < 11) {
newDate.setMonth(currentMonth+1)
} else {
newDate.setMonth(0);
newDate.setFullYear(newDate.getFullYear()+1);
}
} else {
// we stay in current month
newDate.setDate(newDate.getDate()+days);
return newDate;
}
}
return newDate;
}
function _strftime(s, maxsize, format, tm) {
// size_t strftime(char *restrict s, size_t maxsize, const char *restrict format, const struct tm *restrict timeptr);
// http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html
var tm_zone = HEAP32[(((tm)+(40))>>2)];
var date = {
tm_sec: HEAP32[((tm)>>2)],
tm_min: HEAP32[(((tm)+(4))>>2)],
tm_hour: HEAP32[(((tm)+(8))>>2)],
tm_mday: HEAP32[(((tm)+(12))>>2)],
tm_mon: HEAP32[(((tm)+(16))>>2)],
tm_year: HEAP32[(((tm)+(20))>>2)],
tm_wday: HEAP32[(((tm)+(24))>>2)],
tm_yday: HEAP32[(((tm)+(28))>>2)],
tm_isdst: HEAP32[(((tm)+(32))>>2)],
tm_gmtoff: HEAP32[(((tm)+(36))>>2)],
tm_zone: tm_zone ? UTF8ToString(tm_zone) : ''
};
var pattern = UTF8ToString(format);
// expand format
var EXPANSION_RULES_1 = {
'%c': '%a %b %d %H:%M:%S %Y', // Replaced by the locale's appropriate date and time representation - e.g., Mon Aug 3 14:02:01 2013
'%D': '%m/%d/%y', // Equivalent to %m / %d / %y
'%F': '%Y-%m-%d', // Equivalent to %Y - %m - %d
'%h': '%b', // Equivalent to %b
'%r': '%I:%M:%S %p', // Replaced by the time in a.m. and p.m. notation
'%R': '%H:%M', // Replaced by the time in 24-hour notation
'%T': '%H:%M:%S', // Replaced by the time
'%x': '%m/%d/%y', // Replaced by the locale's appropriate date representation
'%X': '%H:%M:%S', // Replaced by the locale's appropriate time representation
// Modified Conversion Specifiers
'%Ec': '%c', // Replaced by the locale's alternative appropriate date and time representation.
'%EC': '%C', // Replaced by the name of the base year (period) in the locale's alternative representation.
'%Ex': '%m/%d/%y', // Replaced by the locale's alternative date representation.
'%EX': '%H:%M:%S', // Replaced by the locale's alternative time representation.
'%Ey': '%y', // Replaced by the offset from %EC (year only) in the locale's alternative representation.
'%EY': '%Y', // Replaced by the full alternative year representation.
'%Od': '%d', // Replaced by the day of the month, using the locale's alternative numeric symbols, filled as needed with leading zeros if there is any alternative symbol for zero; otherwise, with leading <space> characters.
'%Oe': '%e', // Replaced by the day of the month, using the locale's alternative numeric symbols, filled as needed with leading <space> characters.
'%OH': '%H', // Replaced by the hour (24-hour clock) using the locale's alternative numeric symbols.
'%OI': '%I', // Replaced by the hour (12-hour clock) using the locale's alternative numeric symbols.
'%Om': '%m', // Replaced by the month using the locale's alternative numeric symbols.
'%OM': '%M', // Replaced by the minutes using the locale's alternative numeric symbols.
'%OS': '%S', // Replaced by the seconds using the locale's alternative numeric symbols.
'%Ou': '%u', // Replaced by the weekday as a number in the locale's alternative representation (Monday=1).
'%OU': '%U', // Replaced by the week number of the year (Sunday as the first day of the week, rules corresponding to %U ) using the locale's alternative numeric symbols.
'%OV': '%V', // Replaced by the week number of the year (Monday as the first day of the week, rules corresponding to %V ) using the locale's alternative numeric symbols.
'%Ow': '%w', // Replaced by the number of the weekday (Sunday=0) using the locale's alternative numeric symbols.
'%OW': '%W', // Replaced by the week number of the year (Monday as the first day of the week) using the locale's alternative numeric symbols.
'%Oy': '%y', // Replaced by the year (offset from %C ) using the locale's alternative numeric symbols.
};
for (var rule in EXPANSION_RULES_1) {
pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_1[rule]);
}
var WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
function leadingSomething(value, digits, character) {
var str = typeof value === 'number' ? value.toString() : (value || '');
while (str.length < digits) {
str = character[0]+str;
}
return str;
}
function leadingNulls(value, digits) {
return leadingSomething(value, digits, '0');
}
function compareByDay(date1, date2) {
function sgn(value) {
return value < 0 ? -1 : (value > 0 ? 1 : 0);
}
var compare;
if ((compare = sgn(date1.getFullYear()-date2.getFullYear())) === 0) {
if ((compare = sgn(date1.getMonth()-date2.getMonth())) === 0) {
compare = sgn(date1.getDate()-date2.getDate());
}
}
return compare;
}
function getFirstWeekStartDate(janFourth) {
switch (janFourth.getDay()) {
case 0: // Sunday
return new Date(janFourth.getFullYear()-1, 11, 29);
case 1: // Monday
return janFourth;
case 2: // Tuesday
return new Date(janFourth.getFullYear(), 0, 3);
case 3: // Wednesday
return new Date(janFourth.getFullYear(), 0, 2);
case 4: // Thursday
return new Date(janFourth.getFullYear(), 0, 1);
case 5: // Friday
return new Date(janFourth.getFullYear()-1, 11, 31);
case 6: // Saturday
return new Date(janFourth.getFullYear()-1, 11, 30);
}
}
function getWeekBasedYear(date) {
var thisDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);
var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4);
var janFourthNextYear = new Date(thisDate.getFullYear()+1, 0, 4);
var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);
var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);
if (compareByDay(firstWeekStartThisYear, thisDate) <= 0) {
// this date is after the start of the first week of this year
if (compareByDay(firstWeekStartNextYear, thisDate) <= 0) {
return thisDate.getFullYear()+1;
} else {
return thisDate.getFullYear();
}
} else {
return thisDate.getFullYear()-1;
}
}
var EXPANSION_RULES_2 = {
'%a': function(date) {
return WEEKDAYS[date.tm_wday].substring(0,3);
},
'%A': function(date) {
return WEEKDAYS[date.tm_wday];
},
'%b': function(date) {
return MONTHS[date.tm_mon].substring(0,3);
},
'%B': function(date) {
return MONTHS[date.tm_mon];
},
'%C': function(date) {
var year = date.tm_year+1900;
return leadingNulls((year/100)|0,2);
},
'%d': function(date) {
return leadingNulls(date.tm_mday, 2);
},
'%e': function(date) {
return leadingSomething(date.tm_mday, 2, ' ');
},
'%g': function(date) {
// %g, %G, and %V give values according to the ISO 8601:2000 standard week-based year.
// In this system, weeks begin on a Monday and week 1 of the year is the week that includes
// January 4th, which is also the week that includes the first Thursday of the year, and
// is also the first week that contains at least four days in the year.
// If the first Monday of January is the 2nd, 3rd, or 4th, the preceding days are part of
// the last week of the preceding year; thus, for Saturday 2nd January 1999,
// %G is replaced by 1998 and %V is replaced by 53. If December 29th, 30th,
// or 31st is a Monday, it and any following days are part of week 1 of the following year.
// Thus, for Tuesday 30th December 1997, %G is replaced by 1998 and %V is replaced by 01.
return getWeekBasedYear(date).toString().substring(2);
},
'%G': function(date) {
return getWeekBasedYear(date);
},
'%H': function(date) {
return leadingNulls(date.tm_hour, 2);
},
'%I': function(date) {
var twelveHour = date.tm_hour;
if (twelveHour == 0) twelveHour = 12;
else if (twelveHour > 12) twelveHour -= 12;
return leadingNulls(twelveHour, 2);
},
'%j': function(date) {
// Day of the year (001-366)
return leadingNulls(date.tm_mday+__arraySum(__isLeapYear(date.tm_year+1900) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, date.tm_mon-1), 3);
},
'%m': function(date) {
return leadingNulls(date.tm_mon+1, 2);
},
'%M': function(date) {
return leadingNulls(date.tm_min, 2);
},
'%n': function() {
return '\n';
},
'%p': function(date) {
if (date.tm_hour >= 0 && date.tm_hour < 12) {
return 'AM';
} else {
return 'PM';
}
},
'%S': function(date) {
return leadingNulls(date.tm_sec, 2);
},
'%t': function() {
return '\t';
},
'%u': function(date) {
return date.tm_wday || 7;
},
'%U': function(date) {
// Replaced by the week number of the year as a decimal number [00,53].
// The first Sunday of January is the first day of week 1;
// days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday]
var janFirst = new Date(date.tm_year+1900, 0, 1);
var firstSunday = janFirst.getDay() === 0 ? janFirst : __addDays(janFirst, 7-janFirst.getDay());
var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);
// is target date after the first Sunday?
if (compareByDay(firstSunday, endDate) < 0) {
// calculate difference in days between first Sunday and endDate
var februaryFirstUntilEndMonth = __arraySum(__isLeapYear(endDate.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, endDate.getMonth()-1)-31;
var firstSundayUntilEndJanuary = 31-firstSunday.getDate();
var days = firstSundayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();
return leadingNulls(Math.ceil(days/7), 2);
}
return compareByDay(firstSunday, janFirst) === 0 ? '01': '00';
},
'%V': function(date) {
// Replaced by the week number of the year (Monday as the first day of the week)
// as a decimal number [01,53]. If the week containing 1 January has four
// or more days in the new year, then it is considered week 1.
// Otherwise, it is the last week of the previous year, and the next week is week 1.
// Both January 4th and the first Thursday of January are always in week 1. [ tm_year, tm_wday, tm_yday]
var janFourthThisYear = new Date(date.tm_year+1900, 0, 4);
var janFourthNextYear = new Date(date.tm_year+1901, 0, 4);
var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);
var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);
var endDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);
if (compareByDay(endDate, firstWeekStartThisYear) < 0) {
// if given date is before this years first week, then it belongs to the 53rd week of last year
return '53';
}
if (compareByDay(firstWeekStartNextYear, endDate) <= 0) {
// if given date is after next years first week, then it belongs to the 01th week of next year
return '01';
}
// given date is in between CW 01..53 of this calendar year
var daysDifference;
if (firstWeekStartThisYear.getFullYear() < date.tm_year+1900) {
// first CW of this year starts last year
daysDifference = date.tm_yday+32-firstWeekStartThisYear.getDate()
} else {
// first CW of this year starts this year
daysDifference = date.tm_yday+1-firstWeekStartThisYear.getDate();
}
return leadingNulls(Math.ceil(daysDifference/7), 2);
},
'%w': function(date) {
return date.tm_wday;
},
'%W': function(date) {
// Replaced by the week number of the year as a decimal number [00,53].
// The first Monday of January is the first day of week 1;
// days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday]
var janFirst = new Date(date.tm_year, 0, 1);
var firstMonday = janFirst.getDay() === 1 ? janFirst : __addDays(janFirst, janFirst.getDay() === 0 ? 1 : 7-janFirst.getDay()+1);
var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);
// is target date after the first Monday?
if (compareByDay(firstMonday, endDate) < 0) {
var februaryFirstUntilEndMonth = __arraySum(__isLeapYear(endDate.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, endDate.getMonth()-1)-31;
var firstMondayUntilEndJanuary = 31-firstMonday.getDate();
var days = firstMondayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();
return leadingNulls(Math.ceil(days/7), 2);
}
return compareByDay(firstMonday, janFirst) === 0 ? '01': '00';
},
'%y': function(date) {
// Replaced by the last two digits of the year as a decimal number [00,99]. [ tm_year]
return (date.tm_year+1900).toString().substring(2);
},
'%Y': function(date) {
// Replaced by the year as a decimal number (for example, 1997). [ tm_year]
return date.tm_year+1900;
},
'%z': function(date) {
// Replaced by the offset from UTC in the ISO 8601:2000 standard format ( +hhmm or -hhmm ).
// For example, "-0430" means 4 hours 30 minutes behind UTC (west of Greenwich).
var off = date.tm_gmtoff;
var ahead = off >= 0;
off = Math.abs(off) / 60;
// convert from minutes into hhmm format (which means 60 minutes = 100 units)
off = (off / 60)*100 + (off % 60);
return (ahead ? '+' : '-') + String("0000" + off).slice(-4);
},
'%Z': function(date) {
return date.tm_zone;
},
'%%': function() {
return '%';
}
};
for (var rule in EXPANSION_RULES_2) {
if (pattern.includes(rule)) {
pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_2[rule](date));
}
}
var bytes = intArrayFromString(pattern, false);
if (bytes.length > maxsize) {
return 0;
}
writeArrayToMemory(bytes, s);
return bytes.length-1;
}
function _strftime_l(s, maxsize, format, tm) {
return _strftime(s, maxsize, format, tm); // no locale support yet
}
function _time(ptr) {
;
var ret = (Date.now()/1000)|0;
if (ptr) {
HEAP32[((ptr)>>2)] = ret;
}
return ret;
}
InternalError = Module['InternalError'] = extendError(Error, 'InternalError');;
embind_init_charCodes();
BindingError = Module['BindingError'] = extendError(Error, 'BindingError');;
init_ClassHandle();
init_RegisteredPointer();
init_embind();;
UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');;
init_emval();;
var ASSERTIONS = false;
/** @type {function(string, boolean=, number=)} */
function intArrayFromString(stringy, dontAddNull, length) {
var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
var u8array = new Array(len);
var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
if (dontAddNull) u8array.length = numBytesWritten;
return u8array;
}
function intArrayToString(array) {
var ret = [];
for (var i = 0; i < array.length; i++) {
var chr = array[i];
if (chr > 0xFF) {
if (ASSERTIONS) {
assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.');
}
chr &= 0xFF;
}
ret.push(String.fromCharCode(chr));
}
return ret.join('');
}
var asmLibraryArg = {
"__asyncjs__wasm_ffmpeg_fopen_sync": __asyncjs__wasm_ffmpeg_fopen_sync,
"__asyncjs__wasm_ffmpeg_fread_sync": __asyncjs__wasm_ffmpeg_fread_sync,
"__cxa_allocate_exception": ___cxa_allocate_exception,
"__cxa_atexit": ___cxa_atexit,
"__cxa_throw": ___cxa_throw,
"__gmtime_r": ___gmtime_r,
"__localtime_r": ___localtime_r,
"__syscall__newselect": ___syscall__newselect,
"__syscall_fcntl64": ___syscall_fcntl64,
"__syscall_ioctl": ___syscall_ioctl,
"__syscall_mkdir": ___syscall_mkdir,
"__syscall_open": ___syscall_open,
"__syscall_rmdir": ___syscall_rmdir,
"__syscall_unlink": ___syscall_unlink,
"_embind_finalize_value_object": __embind_finalize_value_object,
"_embind_register_bigint": __embind_register_bigint,
"_embind_register_bool": __embind_register_bool,
"_embind_register_class": __embind_register_class,
"_embind_register_class_constructor": __embind_register_class_constructor,
"_embind_register_class_function": __embind_register_class_function,
"_embind_register_emval": __embind_register_emval,
"_embind_register_float": __embind_register_float,
"_embind_register_function": __embind_register_function,
"_embind_register_integer": __embind_register_integer,
"_embind_register_memory_view": __embind_register_memory_view,
"_embind_register_std_string": __embind_register_std_string,
"_embind_register_std_wstring": __embind_register_std_wstring,
"_embind_register_value_object": __embind_register_value_object,
"_embind_register_value_object_field": __embind_register_value_object_field,
"_embind_register_void": __embind_register_void,
"abort": _abort,
"clock": _clock,
"clock_gettime": _clock_gettime,
"emscripten_asm_const_int": _emscripten_asm_const_int,
"emscripten_get_now": _emscripten_get_now,
"emscripten_memcpy_big": _emscripten_memcpy_big,
"emscripten_resize_heap": _emscripten_resize_heap,
"environ_get": _environ_get,
"environ_sizes_get": _environ_sizes_get,
"exit": _exit,
"fd_close": _fd_close,
"fd_fdstat_get": _fd_fdstat_get,
"fd_read": _fd_read,
"fd_seek": _fd_seek,
"fd_write": _fd_write,
"gettimeofday": _gettimeofday,
"gmtime_r": _gmtime_r,
"localtime_r": _localtime_r,
"mktime": _mktime,
"setTempRet0": _setTempRet0,
"strftime": _strftime,
"strftime_l": _strftime_l,
"time": _time
};
// var asm = createWasm();
// console.log("isaac64: ", Module["WxIsaac64"])
// console.log("Module:", Module)
/** @type {function(...*):?} */
var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function() {
return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["__wasm_call_ctors"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var ___getTypeName = Module["___getTypeName"] = function() {
return (___getTypeName = Module["___getTypeName"] = Module["asm"]["__getTypeName"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var ___embind_register_native_and_builtin_types = Module["___embind_register_native_and_builtin_types"] = function() {
return (___embind_register_native_and_builtin_types = Module["___embind_register_native_and_builtin_types"] = Module["asm"]["__embind_register_native_and_builtin_types"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var _free = Module["_free"] = function() {
return (_free = Module["_free"] = Module["asm"]["free"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var _malloc = Module["_malloc"] = function() {
return (_malloc = Module["_malloc"] = Module["asm"]["malloc"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var ___errno_location = Module["___errno_location"] = function() {
return (___errno_location = Module["___errno_location"] = Module["asm"]["__errno_location"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var __get_tzname = Module["__get_tzname"] = function() {
return (__get_tzname = Module["__get_tzname"] = Module["asm"]["_get_tzname"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var __get_daylight = Module["__get_daylight"] = function() {
return (__get_daylight = Module["__get_daylight"] = Module["asm"]["_get_daylight"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var __get_timezone = Module["__get_timezone"] = function() {
return (__get_timezone = Module["__get_timezone"] = Module["asm"]["_get_timezone"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var stackSave = Module["stackSave"] = function() {
return (stackSave = Module["stackSave"] = Module["asm"]["stackSave"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var stackRestore = Module["stackRestore"] = function() {
return (stackRestore = Module["stackRestore"] = Module["asm"]["stackRestore"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var stackAlloc = Module["stackAlloc"] = function() {
return (stackAlloc = Module["stackAlloc"] = Module["asm"]["stackAlloc"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var _emscripten_stack_set_limits = Module["_emscripten_stack_set_limits"] = function() {
return (_emscripten_stack_set_limits = Module["_emscripten_stack_set_limits"] = Module["asm"]["emscripten_stack_set_limits"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var _emscripten_stack_get_base = Module["_emscripten_stack_get_base"] = function() {
return (_emscripten_stack_get_base = Module["_emscripten_stack_get_base"] = Module["asm"]["emscripten_stack_get_base"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var _emscripten_stack_get_end = Module["_emscripten_stack_get_end"] = function() {
return (_emscripten_stack_get_end = Module["_emscripten_stack_get_end"] = Module["asm"]["emscripten_stack_get_end"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var _memalign = Module["_memalign"] = function() {
return (_memalign = Module["_memalign"] = Module["asm"]["memalign"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_vi = Module["dynCall_vi"] = function() {
return (dynCall_vi = Module["dynCall_vi"] = Module["asm"]["dynCall_vi"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_ii = Module["dynCall_ii"] = function() {
return (dynCall_ii = Module["dynCall_ii"] = Module["asm"]["dynCall_ii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_viiii = Module["dynCall_viiii"] = function() {
return (dynCall_viiii = Module["dynCall_viiii"] = Module["asm"]["dynCall_viiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiii = Module["dynCall_iiii"] = function() {
return (dynCall_iiii = Module["dynCall_iiii"] = Module["asm"]["dynCall_iiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iii = Module["dynCall_iii"] = function() {
return (dynCall_iii = Module["dynCall_iii"] = Module["asm"]["dynCall_iii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_vii = Module["dynCall_vii"] = function() {
return (dynCall_vii = Module["dynCall_vii"] = Module["asm"]["dynCall_vii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_viiiiifiii = Module["dynCall_viiiiifiii"] = function() {
return (dynCall_viiiiifiii = Module["dynCall_viiiiifiii"] = Module["asm"]["dynCall_viiiiifiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_i = Module["dynCall_i"] = function() {
return (dynCall_i = Module["dynCall_i"] = Module["asm"]["dynCall_i"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_viii = Module["dynCall_viii"] = function() {
return (dynCall_viii = Module["dynCall_viii"] = Module["asm"]["dynCall_viii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiiiiifiii = Module["dynCall_iiiiiifiii"] = function() {
return (dynCall_iiiiiifiii = Module["dynCall_iiiiiifiii"] = Module["asm"]["dynCall_iiiiiifiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_v = Module["dynCall_v"] = function() {
return (dynCall_v = Module["dynCall_v"] = Module["asm"]["dynCall_v"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiiiii = Module["dynCall_iiiiii"] = function() {
return (dynCall_iiiiii = Module["dynCall_iiiiii"] = Module["asm"]["dynCall_iiiiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiiiiii = Module["dynCall_iiiiiii"] = function() {
return (dynCall_iiiiiii = Module["dynCall_iiiiiii"] = Module["asm"]["dynCall_iiiiiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_ijiii = Module["dynCall_ijiii"] = function() {
return (dynCall_ijiii = Module["dynCall_ijiii"] = Module["asm"]["dynCall_ijiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_jiji = Module["dynCall_jiji"] = function() {
return (dynCall_jiji = Module["dynCall_jiji"] = Module["asm"]["dynCall_jiji"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiiji = Module["dynCall_iiiji"] = function() {
return (dynCall_iiiji = Module["dynCall_iiiji"] = Module["asm"]["dynCall_iiiji"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_viiiiii = Module["dynCall_viiiiii"] = function() {
return (dynCall_viiiiii = Module["dynCall_viiiiii"] = Module["asm"]["dynCall_viiiiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiiii = Module["dynCall_iiiii"] = function() {
return (dynCall_iiiii = Module["dynCall_iiiii"] = Module["asm"]["dynCall_iiiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_dd = Module["dynCall_dd"] = function() {
return (dynCall_dd = Module["dynCall_dd"] = Module["asm"]["dynCall_dd"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iidiiii = Module["dynCall_iidiiii"] = function() {
return (dynCall_iidiiii = Module["dynCall_iidiiii"] = Module["asm"]["dynCall_iidiiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_viijii = Module["dynCall_viijii"] = function() {
return (dynCall_viijii = Module["dynCall_viijii"] = Module["asm"]["dynCall_viijii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiiiiiiii = Module["dynCall_iiiiiiiii"] = function() {
return (dynCall_iiiiiiiii = Module["dynCall_iiiiiiiii"] = Module["asm"]["dynCall_iiiiiiiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiiiij = Module["dynCall_iiiiij"] = function() {
return (dynCall_iiiiij = Module["dynCall_iiiiij"] = Module["asm"]["dynCall_iiiiij"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiiiid = Module["dynCall_iiiiid"] = function() {
return (dynCall_iiiiid = Module["dynCall_iiiiid"] = Module["asm"]["dynCall_iiiiid"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiiiijj = Module["dynCall_iiiiijj"] = function() {
return (dynCall_iiiiijj = Module["dynCall_iiiiijj"] = Module["asm"]["dynCall_iiiiijj"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiiiiiii = Module["dynCall_iiiiiiii"] = function() {
return (dynCall_iiiiiiii = Module["dynCall_iiiiiiii"] = Module["asm"]["dynCall_iiiiiiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_iiiiiijj = Module["dynCall_iiiiiijj"] = function() {
return (dynCall_iiiiiijj = Module["dynCall_iiiiiijj"] = Module["asm"]["dynCall_iiiiiijj"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var dynCall_viiiii = Module["dynCall_viiiii"] = function() {
return (dynCall_viiiii = Module["dynCall_viiiii"] = Module["asm"]["dynCall_viiiii"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var _asyncify_start_unwind = Module["_asyncify_start_unwind"] = function() {
return (_asyncify_start_unwind = Module["_asyncify_start_unwind"] = Module["asm"]["asyncify_start_unwind"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var _asyncify_stop_unwind = Module["_asyncify_stop_unwind"] = function() {
return (_asyncify_stop_unwind = Module["_asyncify_stop_unwind"] = Module["asm"]["asyncify_stop_unwind"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var _asyncify_start_rewind = Module["_asyncify_start_rewind"] = function() {
return (_asyncify_start_rewind = Module["_asyncify_start_rewind"] = Module["asm"]["asyncify_start_rewind"]).apply(null, arguments);
};
/** @type {function(...*):?} */
var _asyncify_stop_rewind = Module["_asyncify_stop_rewind"] = function() {
return (_asyncify_stop_rewind = Module["_asyncify_stop_rewind"] = Module["asm"]["asyncify_stop_rewind"]).apply(null, arguments);
};
// === Auto-generated postamble setup entry stuff ===
Module["ccall"] = ccall;
Module["cwrap"] = cwrap;
var calledRun;
/**
* @constructor
* @this {ExitStatus}
*/
function ExitStatus(status) {
this.name = "ExitStatus";
this.message = "Program terminated with exit(" + status + ")";
this.status = status;
}
var calledMain = false;
dependenciesFulfilled = function runCaller() {
// If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
if (!calledRun) run();
if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
};
/** @type {function(Array=)} */
function run(args) {
args = args || arguments_;
if (runDependencies > 0) {
return;
}
preRun();
// a preRun added a dependency, run will be called later
if (runDependencies > 0) {
return;
}
function doRun() {
// run may have just been called through dependencies being fulfilled just in this very frame,
// or while the async setStatus time below was happening
if (calledRun) return;
calledRun = true;
Module['calledRun'] = true;
if (ABORT) return;
initRuntime();
if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();
postRun();
}
if (Module['setStatus']) {
Module['setStatus']('Running...');
setTimeout(function() {
setTimeout(function() {
Module['setStatus']('');
}, 1);
doRun();
}, 1);
} else
{
doRun();
}
}
Module['run'] = run;
/** @param {boolean|number=} implicit */
function exit(status, implicit) {
EXITSTATUS = status;
if (keepRuntimeAlive()) {
} else {
exitRuntime();
}
procExit(status);
}
function procExit(code) {
EXITSTATUS = code;
if (!keepRuntimeAlive()) {
if (Module['onExit']) Module['onExit'](code);
ABORT = true;
}
quit_(code, new ExitStatus(code));
}
var p = {
};
var wasm_isaac_generate = function(t, e){
p.decryptor_array = new Uint8Array(e);
var r = new Uint8Array(Module.HEAPU8.buffer,t,e);
p.decryptor_array.set(r.reverse())
}
// console.log(Module);
// var asm = createWasm();
module.exports = {createWasm, p, wasm_isaac_generate};