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.

4708 lines
169 KiB

7 months ago
  1. const fs = require('fs');
  2. var f = "";
  3. // The Module object: Our interface to the outside world. We import
  4. // and export values on it. There are various ways Module can be used:
  5. // 1. Not defined. We create it here
  6. // 2. A function parameter, function(Module) { ..generated code.. }
  7. // 3. pre-run appended it, var Module = {}; ..generated code..
  8. // 4. External script tag defines var Module.
  9. // We need to check if Module already exists (e.g. case 3 above).
  10. // Substitution will be replaced with actual code on later stage of the build,
  11. // this way Closure Compiler will not mangle it (e.g. case 4. above).
  12. // Note that if you want to run closure, and also to use Module
  13. // after the generated code, you will need to define var Module = {};
  14. // before the code. Then that object will be used in the code, and you
  15. // can continue to use Module afterwards as well.
  16. var Module = typeof Module !== 'undefined' ? Module : {};
  17. // --pre-jses are emitted after the Module integration code, so that they can
  18. // refer to Module (if they choose; they can also define Module)
  19. // {{PRE_JSES}}
  20. // Sometimes an existing Module object exists with properties
  21. // meant to overwrite the default module functionality. Here
  22. // we collect those properties and reapply _after_ we configure
  23. // the current environment's defaults to avoid having to be so
  24. // defensive during initialization.
  25. var moduleOverrides = {};
  26. var key;
  27. for (key in Module) {
  28. if (Module.hasOwnProperty(key)) {
  29. moduleOverrides[key] = Module[key];
  30. }
  31. }
  32. var arguments_ = [];
  33. var thisProgram = './this.program';
  34. var quit_ = function(status, toThrow) {
  35. throw toThrow;
  36. };
  37. // Determine the runtime environment we are in. You can customize this by
  38. // setting the ENVIRONMENT setting at compile time (see settings.js).
  39. var ENVIRONMENT_IS_WEB = false;
  40. var ENVIRONMENT_IS_WORKER = true;
  41. var ENVIRONMENT_IS_NODE = false;
  42. var ENVIRONMENT_IS_SHELL = false;
  43. // `/` should be present at the end if `scriptDirectory` is not empty
  44. var scriptDirectory = '';
  45. function locateFile(path) {
  46. if (Module['locateFile']) {
  47. return Module['locateFile'](path, scriptDirectory);
  48. }
  49. return scriptDirectory + path;
  50. }
  51. // Hooks that are implemented differently in different runtime environments.
  52. var read_,
  53. readAsync,
  54. readBinary,
  55. setWindowTitle;
  56. // Note that this includes Node.js workers when relevant (pthreads is enabled).
  57. // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
  58. // ENVIRONMENT_IS_NODE.
  59. if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
  60. if (ENVIRONMENT_IS_WORKER) { // Check worker, not web, since window could be polyfilled
  61. scriptDirectory = "";
  62. } else if (typeof document !== 'undefined' && document.currentScript) { // web
  63. scriptDirectory = document.currentScript.src;
  64. }
  65. // blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
  66. // otherwise, slice off the final part of the url to find the script directory.
  67. // if scriptDirectory does not contain a slash, lastIndexOf will return -1,
  68. // and scriptDirectory will correctly be replaced with an empty string.
  69. // If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
  70. // they are removed because they could contain a slash.
  71. if (scriptDirectory.indexOf('blob:') !== 0) {
  72. scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/')+1);
  73. } else {
  74. scriptDirectory = '';
  75. }
  76. // Differentiate the Web Worker from the Node Worker case, as reading must
  77. // be done differently.
  78. {
  79. // include: web_or_worker_shell_read.js
  80. read_ = function(url) {
  81. var xhr = new XMLHttpRequest();
  82. xhr.open('GET', url, false);
  83. xhr.send(null);
  84. return xhr.responseText;
  85. };
  86. if (ENVIRONMENT_IS_WORKER) {
  87. readBinary = function(url) {
  88. var xhr = new XMLHttpRequest();
  89. xhr.open('GET', url, false);
  90. xhr.responseType = 'arraybuffer';
  91. xhr.send(null);
  92. return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
  93. };
  94. }
  95. readAsync = function(url, onload, onerror) {
  96. var xhr = new XMLHttpRequest();
  97. xhr.open('GET', url, true);
  98. xhr.responseType = 'arraybuffer';
  99. xhr.onload = function() {
  100. if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
  101. onload(xhr.response);
  102. return;
  103. }
  104. onerror();
  105. };
  106. xhr.onerror = onerror;
  107. xhr.send(null);
  108. };
  109. // end include: web_or_worker_shell_read.js
  110. }
  111. setWindowTitle = function(title) { document.title = title };
  112. } else
  113. {
  114. }
  115. var out = Module['print'] || console.log.bind(console);
  116. var err = Module['printErr'] || console.warn.bind(console);
  117. // Merge back in the overrides
  118. for (key in moduleOverrides) {
  119. if (moduleOverrides.hasOwnProperty(key)) {
  120. Module[key] = moduleOverrides[key];
  121. }
  122. }
  123. // Free the object hierarchy contained in the overrides, this lets the GC
  124. // reclaim data used e.g. in memoryInitializerRequest, which is a large typed array.
  125. moduleOverrides = null;
  126. // Emit code to handle expected values on the Module object. This applies Module.x
  127. // to the proper local x. This has two benefits: first, we only emit it if it is
  128. // expected to arrive, and second, by using a local everywhere else that can be
  129. // minified.
  130. if (Module['arguments']) arguments_ = Module['arguments'];
  131. if (Module['thisProgram']) thisProgram = Module['thisProgram'];
  132. if (Module['quit']) quit_ = Module['quit'];
  133. // perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
  134. var STACK_ALIGN = 16;
  135. var POINTER_SIZE = 4;
  136. function getNativeTypeSize(type) {
  137. switch (type) {
  138. case 'i1': case 'i8': return 1;
  139. case 'i16': return 2;
  140. case 'i32': return 4;
  141. case 'i64': return 8;
  142. case 'float': return 4;
  143. case 'double': return 8;
  144. default: {
  145. if (type[type.length-1] === '*') {
  146. return POINTER_SIZE;
  147. } else if (type[0] === 'i') {
  148. var bits = Number(type.substr(1));
  149. assert(bits % 8 === 0, 'getNativeTypeSize invalid bits ' + bits + ', type ' + type);
  150. return bits / 8;
  151. } else {
  152. return 0;
  153. }
  154. }
  155. }
  156. }
  157. function warnOnce(text) {
  158. if (!warnOnce.shown) warnOnce.shown = {};
  159. if (!warnOnce.shown[text]) {
  160. warnOnce.shown[text] = 1;
  161. err(text);
  162. }
  163. }
  164. // include: runtime_functions.js
  165. // Wraps a JS function as a wasm function with a given signature.
  166. function convertJsFunctionToWasm(func, sig) {
  167. // If the type reflection proposal is available, use the new
  168. // "WebAssembly.Function" constructor.
  169. // Otherwise, construct a minimal wasm module importing the JS function and
  170. // re-exporting it.
  171. if (typeof WebAssembly.Function === "function") {
  172. var typeNames = {
  173. 'i': 'i32',
  174. 'j': 'i64',
  175. 'f': 'f32',
  176. 'd': 'f64'
  177. };
  178. var type = {
  179. parameters: [],
  180. results: sig[0] == 'v' ? [] : [typeNames[sig[0]]]
  181. };
  182. for (var i = 1; i < sig.length; ++i) {
  183. type.parameters.push(typeNames[sig[i]]);
  184. }
  185. return new WebAssembly.Function(type, func);
  186. }
  187. // The module is static, with the exception of the type section, which is
  188. // generated based on the signature passed in.
  189. var typeSection = [
  190. 0x01, // id: section,
  191. 0x00, // length: 0 (placeholder)
  192. 0x01, // count: 1
  193. 0x60, // form: func
  194. ];
  195. var sigRet = sig.slice(0, 1);
  196. var sigParam = sig.slice(1);
  197. var typeCodes = {
  198. 'i': 0x7f, // i32
  199. 'j': 0x7e, // i64
  200. 'f': 0x7d, // f32
  201. 'd': 0x7c, // f64
  202. };
  203. // Parameters, length + signatures
  204. typeSection.push(sigParam.length);
  205. for (var i = 0; i < sigParam.length; ++i) {
  206. typeSection.push(typeCodes[sigParam[i]]);
  207. }
  208. // Return values, length + signatures
  209. // With no multi-return in MVP, either 0 (void) or 1 (anything else)
  210. if (sigRet == 'v') {
  211. typeSection.push(0x00);
  212. } else {
  213. typeSection = typeSection.concat([0x01, typeCodes[sigRet]]);
  214. }
  215. // Write the overall length of the type section back into the section header
  216. // (excepting the 2 bytes for the section id and length)
  217. typeSection[1] = typeSection.length - 2;
  218. // Rest of the module is static
  219. var bytes = new Uint8Array([
  220. 0x00, 0x61, 0x73, 0x6d, // magic ("\0asm")
  221. 0x01, 0x00, 0x00, 0x00, // version: 1
  222. ].concat(typeSection, [
  223. 0x02, 0x07, // import section
  224. // (import "e" "f" (func 0 (type 0)))
  225. 0x01, 0x01, 0x65, 0x01, 0x66, 0x00, 0x00,
  226. 0x07, 0x05, // export section
  227. // (export "f" (func 0 (type 0)))
  228. 0x01, 0x01, 0x66, 0x00, 0x00,
  229. ]));
  230. // We can compile this wasm module synchronously because it is very small.
  231. // This accepts an import (at "e.f"), that it reroutes to an export (at "f")
  232. var module = new WebAssembly.Module(bytes);
  233. var instance = new WebAssembly.Instance(module, {
  234. 'e': {
  235. 'f': func
  236. }
  237. });
  238. var wrappedFunc = instance.exports['f'];
  239. return wrappedFunc;
  240. }
  241. var freeTableIndexes = [];
  242. // Weak map of functions in the table to their indexes, created on first use.
  243. var functionsInTableMap;
  244. function getEmptyTableSlot() {
  245. // Reuse a free index if there is one, otherwise grow.
  246. if (freeTableIndexes.length) {
  247. return freeTableIndexes.pop();
  248. }
  249. // Grow the table
  250. try {
  251. wasmTable.grow(1);
  252. } catch (err) {
  253. if (!(err instanceof RangeError)) {
  254. throw err;
  255. }
  256. throw 'Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.';
  257. }
  258. return wasmTable.length - 1;
  259. }
  260. function updateTableMap(offset, count) {
  261. for (var i = offset; i < offset + count; i++) {
  262. var item = getWasmTableEntry(i);
  263. // Ignore null values.
  264. if (item) {
  265. functionsInTableMap.set(item, i);
  266. }
  267. }
  268. }
  269. // Add a function to the table.
  270. // 'sig' parameter is required if the function being added is a JS function.
  271. function addFunction(func, sig) {
  272. // Check if the function is already in the table, to ensure each function
  273. // gets a unique index. First, create the map if this is the first use.
  274. if (!functionsInTableMap) {
  275. functionsInTableMap = new WeakMap();
  276. updateTableMap(0, wasmTable.length);
  277. }
  278. if (functionsInTableMap.has(func)) {
  279. return functionsInTableMap.get(func);
  280. }
  281. // It's not in the table, add it now.
  282. var ret = getEmptyTableSlot();
  283. // Set the new value.
  284. try {
  285. // Attempting to call this with JS function will cause of table.set() to fail
  286. setWasmTableEntry(ret, func);
  287. } catch (err) {
  288. if (!(err instanceof TypeError)) {
  289. throw err;
  290. }
  291. var wrapped = convertJsFunctionToWasm(func, sig);
  292. setWasmTableEntry(ret, wrapped);
  293. }
  294. functionsInTableMap.set(func, ret);
  295. return ret;
  296. }
  297. function removeFunction(index) {
  298. functionsInTableMap.delete(getWasmTableEntry(index));
  299. freeTableIndexes.push(index);
  300. }
  301. // end include: runtime_functions.js
  302. // include: runtime_debug.js
  303. // end include: runtime_debug.js
  304. var tempRet0 = 0;
  305. var setTempRet0 = function(value) {
  306. tempRet0 = value;
  307. };
  308. var getTempRet0 = function() {
  309. return tempRet0;
  310. };
  311. // === Preamble library stuff ===
  312. // Documentation for the public APIs defined in this file must be updated in:
  313. // site/source/docs/api_reference/preamble.js.rst
  314. // A prebuilt local version of the documentation is available at:
  315. // site/build/text/docs/api_reference/preamble.js.txt
  316. // You can also build docs locally as HTML or other formats in site/
  317. // An online HTML version (which may be of a different version of Emscripten)
  318. // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
  319. var wasmBinary;
  320. if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
  321. var noExitRuntime = Module['noExitRuntime'] || true;
  322. if (typeof WebAssembly !== 'object') {
  323. abort('no native wasm support detected');
  324. }
  325. // include: runtime_safe_heap.js
  326. // In MINIMAL_RUNTIME, setValue() and getValue() are only available when building with safe heap enabled, for heap safety checking.
  327. // In traditional runtime, setValue() and getValue() are always available (although their use is highly discouraged due to perf penalties)
  328. /** @param {number} ptr
  329. @param {number} value
  330. @param {string} type
  331. @param {number|boolean=} noSafe */
  332. function setValue(ptr, value, type, noSafe) {
  333. type = type || 'i8';
  334. if (type.charAt(type.length-1) === '*') type = 'i32';
  335. switch (type) {
  336. case 'i1': HEAP8[((ptr)>>0)] = value; break;
  337. case 'i8': HEAP8[((ptr)>>0)] = value; break;
  338. case 'i16': HEAP16[((ptr)>>1)] = value; break;
  339. case 'i32': HEAP32[((ptr)>>2)] = value; break;
  340. 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;
  341. case 'float': HEAPF32[((ptr)>>2)] = value; break;
  342. case 'double': HEAPF64[((ptr)>>3)] = value; break;
  343. default: abort('invalid type for setValue: ' + type);
  344. }
  345. }
  346. /** @param {number} ptr
  347. @param {string} type
  348. @param {number|boolean=} noSafe */
  349. function getValue(ptr, type, noSafe) {
  350. type = type || 'i8';
  351. if (type.charAt(type.length-1) === '*') type = 'i32';
  352. switch (type) {
  353. case 'i1': return HEAP8[((ptr)>>0)];
  354. case 'i8': return HEAP8[((ptr)>>0)];
  355. case 'i16': return HEAP16[((ptr)>>1)];
  356. case 'i32': return HEAP32[((ptr)>>2)];
  357. case 'i64': return HEAP32[((ptr)>>2)];
  358. case 'float': return HEAPF32[((ptr)>>2)];
  359. case 'double': return Number(HEAPF64[((ptr)>>3)]);
  360. default: abort('invalid type for getValue: ' + type);
  361. }
  362. return null;
  363. }
  364. // end include: runtime_safe_heap.js
  365. // Wasm globals
  366. var wasmMemory;
  367. //========================================
  368. // Runtime essentials
  369. //========================================
  370. // whether we are quitting the application. no code should run after this.
  371. // set in exit() and abort()
  372. var ABORT = false;
  373. // set by exit() and abort(). Passed to 'onExit' handler.
  374. // NOTE: This is also used as the process return code code in shell environments
  375. // but only when noExitRuntime is false.
  376. var EXITSTATUS;
  377. /** @type {function(*, string=)} */
  378. function assert(condition, text) {
  379. if (!condition) {
  380. abort('Assertion failed: ' + text);
  381. }
  382. }
  383. // Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
  384. function getCFunc(ident) {
  385. var func = Module['_' + ident]; // closure exported function
  386. assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported');
  387. return func;
  388. }
  389. // C calling interface.
  390. /** @param {string|null=} returnType
  391. @param {Array=} argTypes
  392. @param {Arguments|Array=} args
  393. @param {Object=} opts */
  394. function ccall(ident, returnType, argTypes, args, opts) {
  395. // For fast lookup of conversion functions
  396. var toC = {
  397. 'string': function(str) {
  398. var ret = 0;
  399. if (str !== null && str !== undefined && str !== 0) { // null string
  400. // at most 4 bytes per UTF-8 code point, +1 for the trailing '\0'
  401. var len = (str.length << 2) + 1;
  402. ret = stackAlloc(len);
  403. stringToUTF8(str, ret, len);
  404. }
  405. return ret;
  406. },
  407. 'array': function(arr) {
  408. var ret = stackAlloc(arr.length);
  409. writeArrayToMemory(arr, ret);
  410. return ret;
  411. }
  412. };
  413. function convertReturnValue(ret) {
  414. if (returnType === 'string') return UTF8ToString(ret);
  415. if (returnType === 'boolean') return Boolean(ret);
  416. return ret;
  417. }
  418. var func = getCFunc(ident);
  419. var cArgs = [];
  420. var stack = 0;
  421. if (args) {
  422. for (var i = 0; i < args.length; i++) {
  423. var converter = toC[argTypes[i]];
  424. if (converter) {
  425. if (stack === 0) stack = stackSave();
  426. cArgs[i] = converter(args[i]);
  427. } else {
  428. cArgs[i] = args[i];
  429. }
  430. }
  431. }
  432. var ret = func.apply(null, cArgs);
  433. function onDone(ret) {
  434. runtimeKeepalivePop();
  435. if (stack !== 0) stackRestore(stack);
  436. return convertReturnValue(ret);
  437. }
  438. runtimeKeepalivePush();
  439. var asyncMode = opts && opts.async;
  440. // Check if we started an async operation just now.
  441. if (Asyncify.currData) {
  442. // If so, the WASM function ran asynchronous and unwound its stack.
  443. // We need to return a Promise that resolves the return value
  444. // once the stack is rewound and execution finishes.
  445. return Asyncify.whenDone().then(onDone);
  446. }
  447. ret = onDone(ret);
  448. // If this is an async ccall, ensure we return a promise
  449. if (asyncMode) return Promise.resolve(ret);
  450. return ret;
  451. }
  452. /** @param {string=} returnType
  453. @param {Array=} argTypes
  454. @param {Object=} opts */
  455. function cwrap(ident, returnType, argTypes, opts) {
  456. argTypes = argTypes || [];
  457. // When the function takes numbers and returns a number, we can just return
  458. // the original function
  459. var numericArgs = argTypes.every(function(type){ return type === 'number'});
  460. var numericRet = returnType !== 'string';
  461. if (numericRet && numericArgs && !opts) {
  462. return getCFunc(ident);
  463. }
  464. return function() {
  465. return ccall(ident, returnType, argTypes, arguments, opts);
  466. }
  467. }
  468. var ALLOC_NORMAL = 0; // Tries to use _malloc()
  469. var ALLOC_STACK = 1; // Lives for the duration of the current function call
  470. // allocate(): This is for internal use. You can use it yourself as well, but the interface
  471. // is a little tricky (see docs right below). The reason is that it is optimized
  472. // for multiple syntaxes to save space in generated code. So you should
  473. // normally not use allocate(), and instead allocate memory using _malloc(),
  474. // initialize it with setValue(), and so forth.
  475. // @slab: An array of data.
  476. // @allocator: How to allocate memory, see ALLOC_*
  477. /** @type {function((Uint8Array|Array<number>), number)} */
  478. function allocate(slab, allocator) {
  479. var ret;
  480. if (allocator == ALLOC_STACK) {
  481. ret = stackAlloc(slab.length);
  482. } else {
  483. ret = _malloc(slab.length);
  484. }
  485. if (slab.subarray || slab.slice) {
  486. HEAPU8.set(/** @type {!Uint8Array} */(slab), ret);
  487. } else {
  488. HEAPU8.set(new Uint8Array(slab), ret);
  489. }
  490. return ret;
  491. }
  492. // include: runtime_strings.js
  493. // runtime_strings.js: Strings related runtime functions that are part of both MINIMAL_RUNTIME and regular runtime.
  494. // Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the given array that contains uint8 values, returns
  495. // a copy of that string as a Javascript String object.
  496. var UTF8Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
  497. /**
  498. * @param {number} idx
  499. * @param {number=} maxBytesToRead
  500. * @return {string}
  501. */
  502. function UTF8ArrayToString(heap, idx, maxBytesToRead) {
  503. var endIdx = idx + maxBytesToRead;
  504. var endPtr = idx;
  505. // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
  506. // Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
  507. // (As a tiny code save trick, compare endPtr against endIdx using a negation, so that undefined means Infinity)
  508. while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr;
  509. if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) {
  510. return UTF8Decoder.decode(heap.subarray(idx, endPtr));
  511. } else {
  512. var str = '';
  513. // If building with TextDecoder, we have already computed the string length above, so test loop end condition against that
  514. while (idx < endPtr) {
  515. // For UTF8 byte structure, see:
  516. // http://en.wikipedia.org/wiki/UTF-8#Description
  517. // https://www.ietf.org/rfc/rfc2279.txt
  518. // https://tools.ietf.org/html/rfc3629
  519. var u0 = heap[idx++];
  520. if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
  521. var u1 = heap[idx++] & 63;
  522. if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
  523. var u2 = heap[idx++] & 63;
  524. if ((u0 & 0xF0) == 0xE0) {
  525. u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
  526. } else {
  527. u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heap[idx++] & 63);
  528. }
  529. if (u0 < 0x10000) {
  530. str += String.fromCharCode(u0);
  531. } else {
  532. var ch = u0 - 0x10000;
  533. str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
  534. }
  535. }
  536. }
  537. return str;
  538. }
  539. // Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the emscripten HEAP, returns a
  540. // copy of that string as a Javascript String object.
  541. // maxBytesToRead: an optional length that specifies the maximum number of bytes to read. You can omit
  542. // this parameter to scan the string until the first \0 byte. If maxBytesToRead is
  543. // passed, and the string at [ptr, ptr+maxBytesToReadr[ contains a null byte in the
  544. // middle, then the string will cut short at that byte index (i.e. maxBytesToRead will
  545. // not produce a string of exact length [ptr, ptr+maxBytesToRead[)
  546. // N.B. mixing frequent uses of UTF8ToString() with and without maxBytesToRead may
  547. // throw JS JIT optimizations off, so it is worth to consider consistently using one
  548. // style or the other.
  549. /**
  550. * @param {number} ptr
  551. * @param {number=} maxBytesToRead
  552. * @return {string}
  553. */
  554. function UTF8ToString(ptr, maxBytesToRead) {
  555. ;
  556. return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
  557. }
  558. // Copies the given Javascript String object 'str' to the given byte array at address 'outIdx',
  559. // encoded in UTF8 form and null-terminated. The copy will require at most str.length*4+1 bytes of space in the HEAP.
  560. // Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write.
  561. // Parameters:
  562. // str: the Javascript string to copy.
  563. // heap: the array to copy to. Each index in this array is assumed to be one 8-byte element.
  564. // outIdx: The starting offset in the array to begin the copying.
  565. // maxBytesToWrite: The maximum number of bytes this function can write to the array.
  566. // This count should include the null terminator,
  567. // i.e. if maxBytesToWrite=1, only the null terminator will be written and nothing else.
  568. // maxBytesToWrite=0 does not write any bytes to the output, not even the null terminator.
  569. // Returns the number of bytes written, EXCLUDING the null terminator.
  570. function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
  571. if (!(maxBytesToWrite > 0)) // Parameter maxBytesToWrite is not optional. Negative values, 0, null, undefined and false each don't write out any bytes.
  572. return 0;
  573. var startIdx = outIdx;
  574. var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
  575. for (var i = 0; i < str.length; ++i) {
  576. // 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.
  577. // See http://unicode.org/faq/utf_bom.html#utf16-3
  578. // 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
  579. var u = str.charCodeAt(i); // possibly a lead surrogate
  580. if (u >= 0xD800 && u <= 0xDFFF) {
  581. var u1 = str.charCodeAt(++i);
  582. u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
  583. }
  584. if (u <= 0x7F) {
  585. if (outIdx >= endIdx) break;
  586. heap[outIdx++] = u;
  587. } else if (u <= 0x7FF) {
  588. if (outIdx + 1 >= endIdx) break;
  589. heap[outIdx++] = 0xC0 | (u >> 6);
  590. heap[outIdx++] = 0x80 | (u & 63);
  591. } else if (u <= 0xFFFF) {
  592. if (outIdx + 2 >= endIdx) break;
  593. heap[outIdx++] = 0xE0 | (u >> 12);
  594. heap[outIdx++] = 0x80 | ((u >> 6) & 63);
  595. heap[outIdx++] = 0x80 | (u & 63);
  596. } else {
  597. if (outIdx + 3 >= endIdx) break;
  598. heap[outIdx++] = 0xF0 | (u >> 18);
  599. heap[outIdx++] = 0x80 | ((u >> 12) & 63);
  600. heap[outIdx++] = 0x80 | ((u >> 6) & 63);
  601. heap[outIdx++] = 0x80 | (u & 63);
  602. }
  603. }
  604. // Null-terminate the pointer to the buffer.
  605. heap[outIdx] = 0;
  606. return outIdx - startIdx;
  607. }
  608. // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
  609. // null-terminated and encoded in UTF8 form. The copy will require at most str.length*4+1 bytes of space in the HEAP.
  610. // Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write.
  611. // Returns the number of bytes written, EXCLUDING the null terminator.
  612. function stringToUTF8(str, outPtr, maxBytesToWrite) {
  613. return stringToUTF8Array(str, HEAPU8,outPtr, maxBytesToWrite);
  614. }
  615. // Returns the number of bytes the given Javascript string takes if encoded as a UTF8 byte array, EXCLUDING the null terminator byte.
  616. function lengthBytesUTF8(str) {
  617. var len = 0;
  618. for (var i = 0; i < str.length; ++i) {
  619. // 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.
  620. // See http://unicode.org/faq/utf_bom.html#utf16-3
  621. var u = str.charCodeAt(i); // possibly a lead surrogate
  622. if (u >= 0xD800 && u <= 0xDFFF) u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt(++i) & 0x3FF);
  623. if (u <= 0x7F) ++len;
  624. else if (u <= 0x7FF) len += 2;
  625. else if (u <= 0xFFFF) len += 3;
  626. else len += 4;
  627. }
  628. return len;
  629. }
  630. // end include: runtime_strings.js
  631. // include: runtime_strings_extra.js
  632. // runtime_strings_extra.js: Strings related runtime functions that are available only in regular runtime.
  633. // Given a pointer 'ptr' to a null-terminated ASCII-encoded string in the emscripten HEAP, returns
  634. // a copy of that string as a Javascript String object.
  635. function AsciiToString(ptr) {
  636. var str = '';
  637. while (1) {
  638. var ch = HEAPU8[((ptr++)>>0)];
  639. if (!ch) return str;
  640. str += String.fromCharCode(ch);
  641. }
  642. }
  643. // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
  644. // null-terminated and encoded in ASCII form. The copy will require at most str.length+1 bytes of space in the HEAP.
  645. function stringToAscii(str, outPtr) {
  646. return writeAsciiToMemory(str, outPtr, false);
  647. }
  648. // Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
  649. // a copy of that string as a Javascript String object.
  650. var UTF16Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-16le') : undefined;
  651. function UTF16ToString(ptr, maxBytesToRead) {
  652. var endPtr = ptr;
  653. // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
  654. // Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
  655. var idx = endPtr >> 1;
  656. var maxIdx = idx + maxBytesToRead / 2;
  657. // If maxBytesToRead is not passed explicitly, it will be undefined, and this
  658. // will always evaluate to true. This saves on code size.
  659. while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx;
  660. endPtr = idx << 1;
  661. if (endPtr - ptr > 32 && UTF16Decoder) {
  662. return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
  663. } else {
  664. var str = '';
  665. // If maxBytesToRead is not passed explicitly, it will be undefined, and the for-loop's condition
  666. // will always evaluate to true. The loop is then terminated on the first null char.
  667. for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {
  668. var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
  669. if (codeUnit == 0) break;
  670. // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
  671. str += String.fromCharCode(codeUnit);
  672. }
  673. return str;
  674. }
  675. }
  676. // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
  677. // null-terminated and encoded in UTF16 form. The copy will require at most str.length*4+2 bytes of space in the HEAP.
  678. // Use the function lengthBytesUTF16() to compute the exact number of bytes (excluding null terminator) that this function will write.
  679. // Parameters:
  680. // str: the Javascript string to copy.
  681. // outPtr: Byte address in Emscripten HEAP where to write the string to.
  682. // maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
  683. // terminator, i.e. if maxBytesToWrite=2, only the null terminator will be written and nothing else.
  684. // maxBytesToWrite<2 does not write any bytes to the output, not even the null terminator.
  685. // Returns the number of bytes written, EXCLUDING the null terminator.
  686. function stringToUTF16(str, outPtr, maxBytesToWrite) {
  687. // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
  688. if (maxBytesToWrite === undefined) {
  689. maxBytesToWrite = 0x7FFFFFFF;
  690. }
  691. if (maxBytesToWrite < 2) return 0;
  692. maxBytesToWrite -= 2; // Null terminator.
  693. var startPtr = outPtr;
  694. var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length;
  695. for (var i = 0; i < numCharsToWrite; ++i) {
  696. // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
  697. var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
  698. HEAP16[((outPtr)>>1)] = codeUnit;
  699. outPtr += 2;
  700. }
  701. // Null-terminate the pointer to the HEAP.
  702. HEAP16[((outPtr)>>1)] = 0;
  703. return outPtr - startPtr;
  704. }
  705. // Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
  706. function lengthBytesUTF16(str) {
  707. return str.length*2;
  708. }
  709. function UTF32ToString(ptr, maxBytesToRead) {
  710. var i = 0;
  711. var str = '';
  712. // If maxBytesToRead is not passed explicitly, it will be undefined, and this
  713. // will always evaluate to true. This saves on code size.
  714. while (!(i >= maxBytesToRead / 4)) {
  715. var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
  716. if (utf32 == 0) break;
  717. ++i;
  718. // 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.
  719. // See http://unicode.org/faq/utf_bom.html#utf16-3
  720. if (utf32 >= 0x10000) {
  721. var ch = utf32 - 0x10000;
  722. str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
  723. } else {
  724. str += String.fromCharCode(utf32);
  725. }
  726. }
  727. return str;
  728. }
  729. // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
  730. // null-terminated and encoded in UTF32 form. The copy will require at most str.length*4+4 bytes of space in the HEAP.
  731. // Use the function lengthBytesUTF32() to compute the exact number of bytes (excluding null terminator) that this function will write.
  732. // Parameters:
  733. // str: the Javascript string to copy.
  734. // outPtr: Byte address in Emscripten HEAP where to write the string to.
  735. // maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
  736. // terminator, i.e. if maxBytesToWrite=4, only the null terminator will be written and nothing else.
  737. // maxBytesToWrite<4 does not write any bytes to the output, not even the null terminator.
  738. // Returns the number of bytes written, EXCLUDING the null terminator.
  739. function stringToUTF32(str, outPtr, maxBytesToWrite) {
  740. // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
  741. if (maxBytesToWrite === undefined) {
  742. maxBytesToWrite = 0x7FFFFFFF;
  743. }
  744. if (maxBytesToWrite < 4) return 0;
  745. var startPtr = outPtr;
  746. var endPtr = startPtr + maxBytesToWrite - 4;
  747. for (var i = 0; i < str.length; ++i) {
  748. // 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.
  749. // See http://unicode.org/faq/utf_bom.html#utf16-3
  750. var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
  751. if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
  752. var trailSurrogate = str.charCodeAt(++i);
  753. codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
  754. }
  755. HEAP32[((outPtr)>>2)] = codeUnit;
  756. outPtr += 4;
  757. if (outPtr + 4 > endPtr) break;
  758. }
  759. // Null-terminate the pointer to the HEAP.
  760. HEAP32[((outPtr)>>2)] = 0;
  761. return outPtr - startPtr;
  762. }
  763. // Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
  764. function lengthBytesUTF32(str) {
  765. var len = 0;
  766. for (var i = 0; i < str.length; ++i) {
  767. // 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.
  768. // See http://unicode.org/faq/utf_bom.html#utf16-3
  769. var codeUnit = str.charCodeAt(i);
  770. if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) ++i; // possibly a lead surrogate, so skip over the tail surrogate.
  771. len += 4;
  772. }
  773. return len;
  774. }
  775. // Allocate heap space for a JS string, and write it there.
  776. // It is the responsibility of the caller to free() that memory.
  777. function allocateUTF8(str) {
  778. var size = lengthBytesUTF8(str) + 1;
  779. var ret = _malloc(size);
  780. if (ret) stringToUTF8Array(str, HEAP8, ret, size);
  781. return ret;
  782. }
  783. // Allocate stack space for a JS string, and write it there.
  784. function allocateUTF8OnStack(str) {
  785. var size = lengthBytesUTF8(str) + 1;
  786. var ret = stackAlloc(size);
  787. stringToUTF8Array(str, HEAP8, ret, size);
  788. return ret;
  789. }
  790. // Deprecated: This function should not be called because it is unsafe and does not provide
  791. // a maximum length limit of how many bytes it is allowed to write. Prefer calling the
  792. // function stringToUTF8Array() instead, which takes in a maximum length that can be used
  793. // to be secure from out of bounds writes.
  794. /** @deprecated
  795. @param {boolean=} dontAddNull */
  796. function writeStringToMemory(string, buffer, dontAddNull) {
  797. warnOnce('writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!');
  798. var /** @type {number} */ lastChar, /** @type {number} */ end;
  799. if (dontAddNull) {
  800. // stringToUTF8Array always appends null. If we don't want to do that, remember the
  801. // character that existed at the location where the null will be placed, and restore
  802. // that after the write (below).
  803. end = buffer + lengthBytesUTF8(string);
  804. lastChar = HEAP8[end];
  805. }
  806. stringToUTF8(string, buffer, Infinity);
  807. if (dontAddNull) HEAP8[end] = lastChar; // Restore the value under the null character.
  808. }
  809. function writeArrayToMemory(array, buffer) {
  810. HEAP8.set(array, buffer);
  811. }
  812. /** @param {boolean=} dontAddNull */
  813. function writeAsciiToMemory(str, buffer, dontAddNull) {
  814. for (var i = 0; i < str.length; ++i) {
  815. HEAP8[((buffer++)>>0)] = str.charCodeAt(i);
  816. }
  817. // Null-terminate the pointer to the HEAP.
  818. if (!dontAddNull) HEAP8[((buffer)>>0)] = 0;
  819. }
  820. // end include: runtime_strings_extra.js
  821. // Memory management
  822. function alignUp(x, multiple) {
  823. if (x % multiple > 0) {
  824. x += multiple - (x % multiple);
  825. }
  826. return x;
  827. }
  828. var HEAP,
  829. /** @type {ArrayBuffer} */
  830. buffer,
  831. /** @type {Int8Array} */
  832. HEAP8,
  833. /** @type {Uint8Array} */
  834. HEAPU8,
  835. /** @type {Int16Array} */
  836. HEAP16,
  837. /** @type {Uint16Array} */
  838. HEAPU16,
  839. /** @type {Int32Array} */
  840. HEAP32,
  841. /** @type {Uint32Array} */
  842. HEAPU32,
  843. /** @type {Float32Array} */
  844. HEAPF32,
  845. /** @type {Float64Array} */
  846. HEAPF64;
  847. function updateGlobalBufferAndViews(buf) {
  848. buffer = buf;
  849. Module['HEAP8'] = HEAP8 = new Int8Array(buf);
  850. Module['HEAP16'] = HEAP16 = new Int16Array(buf);
  851. Module['HEAP32'] = HEAP32 = new Int32Array(buf);
  852. Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf);
  853. Module['HEAPU16'] = HEAPU16 = new Uint16Array(buf);
  854. Module['HEAPU32'] = HEAPU32 = new Uint32Array(buf);
  855. Module['HEAPF32'] = HEAPF32 = new Float32Array(buf);
  856. Module['HEAPF64'] = HEAPF64 = new Float64Array(buf);
  857. }
  858. var TOTAL_STACK = 5242880;
  859. var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 33554432;
  860. // include: runtime_init_table.js
  861. // In regular non-RELOCATABLE mode the table is exported
  862. // from the wasm module and this will be assigned once
  863. // the exports are available.
  864. var wasmTable;
  865. // end include: runtime_init_table.js
  866. // include: runtime_stack_check.js
  867. // end include: runtime_stack_check.js
  868. // include: runtime_assertions.js
  869. // end include: runtime_assertions.js
  870. var __ATPRERUN__ = []; // functions called before the runtime is initialized
  871. var __ATINIT__ = []; // functions called during startup
  872. var __ATEXIT__ = []; // functions called during shutdown
  873. var __ATPOSTRUN__ = []; // functions called after the main() is called
  874. var runtimeInitialized = false;
  875. var runtimeExited = false;
  876. var runtimeKeepaliveCounter = 0;
  877. function keepRuntimeAlive() {
  878. return noExitRuntime || runtimeKeepaliveCounter > 0;
  879. }
  880. function preRun() {
  881. if (Module['preRun']) {
  882. if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
  883. while (Module['preRun'].length) {
  884. addOnPreRun(Module['preRun'].shift());
  885. }
  886. }
  887. callRuntimeCallbacks(__ATPRERUN__);
  888. }
  889. function initRuntime() {
  890. runtimeInitialized = true;
  891. callRuntimeCallbacks(__ATINIT__);
  892. }
  893. function exitRuntime() {
  894. runtimeExited = true;
  895. }
  896. function postRun() {
  897. if (Module['postRun']) {
  898. if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
  899. while (Module['postRun'].length) {
  900. addOnPostRun(Module['postRun'].shift());
  901. }
  902. }
  903. callRuntimeCallbacks(__ATPOSTRUN__);
  904. }
  905. function addOnPreRun(cb) {
  906. __ATPRERUN__.unshift(cb);
  907. }
  908. function addOnInit(cb) {
  909. __ATINIT__.unshift(cb);
  910. }
  911. function addOnExit(cb) {
  912. }
  913. function addOnPostRun(cb) {
  914. __ATPOSTRUN__.unshift(cb);
  915. }
  916. // include: runtime_math.js
  917. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
  918. // || MIN_NODE_VERSION < 0.12
  919. // check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
  920. if (!Math.imul || Math.imul(0xffffffff, 5) !== -5) Math.imul = function imul(a, b) {
  921. var ah = a >>> 16;
  922. var al = a & 0xffff;
  923. var bh = b >>> 16;
  924. var bl = b & 0xffff;
  925. return (al*bl + ((ah*bl + al*bh) << 16))|0;
  926. };
  927. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
  928. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
  929. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
  930. // end include: runtime_math.js
  931. // A counter of dependencies for calling run(). If we need to
  932. // do asynchronous work before running, increment this and
  933. // decrement it. Incrementing must happen in a place like
  934. // Module.preRun (used by emcc to add file preloading).
  935. // Note that you can add dependencies in preRun, even though
  936. // it happens right before run - run will be postponed until
  937. // the dependencies are met.
  938. var runDependencies = 0;
  939. var runDependencyWatcher = null;
  940. var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
  941. function getUniqueRunDependency(id) {
  942. return id;
  943. }
  944. function addRunDependency(id) {
  945. runDependencies++;
  946. if (Module['monitorRunDependencies']) {
  947. Module['monitorRunDependencies'](runDependencies);
  948. }
  949. }
  950. function removeRunDependency(id) {
  951. runDependencies--;
  952. if (Module['monitorRunDependencies']) {
  953. Module['monitorRunDependencies'](runDependencies);
  954. }
  955. if (runDependencies == 0) {
  956. if (runDependencyWatcher !== null) {
  957. clearInterval(runDependencyWatcher);
  958. runDependencyWatcher = null;
  959. }
  960. if (dependenciesFulfilled) {
  961. var callback = dependenciesFulfilled;
  962. dependenciesFulfilled = null;
  963. callback(); // can add another dependenciesFulfilled
  964. }
  965. }
  966. }
  967. Module["preloadedImages"] = {}; // maps url to image data
  968. Module["preloadedAudios"] = {}; // maps url to audio data
  969. /** @param {string|number=} what */
  970. function abort(what) {
  971. {
  972. if (Module['onAbort']) {
  973. Module['onAbort'](what);
  974. }
  975. }
  976. what = 'Aborted(' + what + ')';
  977. // TODO(sbc): Should we remove printing and leave it up to whoever
  978. // catches the exception?
  979. err(what);
  980. ABORT = true;
  981. EXITSTATUS = 1;
  982. what += '. Build with -s ASSERTIONS=1 for more info.';
  983. // Use a wasm runtime error, because a JS error might be seen as a foreign
  984. // exception, which means we'd run destructors on it. We need the error to
  985. // simply make the program stop.
  986. var e = new WebAssembly.RuntimeError(what);
  987. // Throw the error whether or not MODULARIZE is set because abort is used
  988. // in code paths apart from instantiation where an exception is expected
  989. // to be thrown when abort is called.
  990. throw e;
  991. }
  992. // {{MEM_INITIALIZER}}
  993. // include: memoryprofiler.js
  994. // end include: memoryprofiler.js
  995. // include: URIUtils.js
  996. // Prefix of data URIs emitted by SINGLE_FILE and related options.
  997. var dataURIPrefix = 'data:application/octet-stream;base64,';
  998. // Indicates whether filename is a base64 data URI.
  999. function isDataURI(filename) {
  1000. // Prefix of data URIs emitted by SINGLE_FILE and related options.
  1001. return filename.startsWith(dataURIPrefix);
  1002. }
  1003. // Indicates whether filename is delivered via file protocol (as opposed to http/https)
  1004. function isFileURI(filename) {
  1005. return filename.startsWith('file://');
  1006. }
  1007. // end include: URIUtils.js
  1008. var wasmBinaryFile = ""; // https://aladin.wxqcloud.qq.com/aladin/ffmepeg/video-decode/1.2.50/wasm_video_decode.wasm
  1009. var wasmBinaryFileLocal = "wx_video/wasm_video_decode.wasm";
  1010. function getBinary(file) {
  1011. try {
  1012. if (file == wasmBinaryFile && wasmBinary) {
  1013. return new Uint8Array(wasmBinary);
  1014. }
  1015. if (readBinary) {
  1016. return readBinary(file);
  1017. } else {
  1018. throw "both async and sync fetching of the wasm failed";
  1019. }
  1020. }
  1021. catch (err) {
  1022. abort(err);
  1023. }
  1024. }
  1025. function getBinaryPromise() {
  1026. // If we don't have the binary yet, try to to load it asynchronously.
  1027. // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
  1028. // See https://github.com/github/fetch/pull/92#issuecomment-140665932
  1029. // Cordova or Electron apps are typically loaded from a file:// url.
  1030. // So use fetch if it is available and the url is not a file, otherwise fall back to XHR.
  1031. if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
  1032. if (typeof fetch === 'function'
  1033. ) {
  1034. return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function(response) {
  1035. if (!response['ok']) {
  1036. throw "failed to load wasm binary file at '" + wasmBinaryFile + "'";
  1037. }
  1038. return response['arrayBuffer']();
  1039. }).catch(function () {
  1040. return getBinary(wasmBinaryFile);
  1041. });
  1042. }
  1043. }
  1044. // Otherwise, getBinary should be able to get it synchronously
  1045. return Promise.resolve().then(function() { return getBinary(wasmBinaryFile); });
  1046. }
  1047. // Create the wasm instance.
  1048. // Receives the wasm imports, returns the exports.
  1049. async function createWasm() {
  1050. // prepare imports
  1051. var info = {
  1052. 'env': asmLibraryArg,
  1053. 'wasi_snapshot_preview1': asmLibraryArg,
  1054. };
  1055. // Load the wasm module and create an instance of using native support in the JS engine.
  1056. // handle a generated wasm instance, receiving its exports and
  1057. // performing other necessary setup
  1058. /** @param {WebAssembly.Module=} module*/
  1059. // we can't run yet (except in a pthread, where we have a custom sync instantiator)
  1060. addRunDependency('wasm-instantiate');
  1061. // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
  1062. // to manually instantiate the Wasm module themselves. This allows pages to run the instantiation parallel
  1063. // to any other async startup actions they are performing.
  1064. if (Module['instantiateWasm']) {
  1065. try {
  1066. var exports = Module['instantiateWasm'](info, receiveInstance);
  1067. exports = Asyncify.instrumentWasmExports(exports);
  1068. return exports;
  1069. } catch(e) {
  1070. err('Module.instantiateWasm callback failed with error: ' + e);
  1071. return false;
  1072. }
  1073. }
  1074. // await instantiateAsync();
  1075. if (!wasmBinary &&
  1076. typeof WebAssembly.instantiateStreaming === 'function' &&
  1077. !isDataURI(wasmBinaryFile) &&
  1078. typeof fetch === 'function') {
  1079. // 这块是自己新增的
  1080. if(wasmBinaryFile == ""){ // 采用本地加载wasm
  1081. var result = await WebAssembly.instantiate(fs.readFileSync(wasmBinaryFileLocal), info);
  1082. var instance = result['instance'];
  1083. // console.log(instance)
  1084. var exports = instance.exports;
  1085. exports = Asyncify.instrumentWasmExports(exports);
  1086. Module['asm'] = exports;
  1087. wasmMemory = Module['asm']['memory'];
  1088. // console.log(wasmMemory.buffer)
  1089. updateGlobalBufferAndViews(wasmMemory.buffer);
  1090. wasmTable = Module['asm']['__indirect_function_table'];
  1091. addOnInit(Module['asm']['__wasm_call_ctors']);
  1092. // console.log(Module);
  1093. removeRunDependency('wasm-instantiate');
  1094. }
  1095. }
  1096. // console.log(Module["WxIsaac64"])
  1097. // console.log(Module['asm'])
  1098. // get_();
  1099. return Module; // no exports yet; we'll fill them in later
  1100. }
  1101. // Globals used by JS i64 conversions (see makeSetValue)
  1102. var tempDouble;
  1103. var tempI64;
  1104. // === Body ===
  1105. var ASM_CONSTS = {
  1106. 434420: function($0, $1, $2) {wasm_ffmpeg_error_report($0, $1, $2);},
  1107. 434460: function($0, $1) {wasm_isaac_generate($0, $1);},
  1108. 434491: function($0, $1, $2) {return wasm_ffmpeg_fwrite($0, $1, $2);},
  1109. 434532: function($0, $1) {wasm_ffmpeg_fsize($0, $1);},
  1110. 434561: function($0, $1, $2, $3, $4) {wasm_ffmpeg_fseek($0, $1, $2, $3, $4);},
  1111. 434602: function($0, $1) {wasm_ffmpeg_fclose($0, $1);}
  1112. };
  1113. function __asyncjs__wasm_ffmpeg_fopen_sync(filename,filelen,acc){ return Asyncify.handleAsync(async () => { const ret = await wasm_ffmpeg_fopen(filename, filelen, acc); return ret; }); }
  1114. 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; }); }
  1115. function callRuntimeCallbacks(callbacks) {
  1116. while (callbacks.length > 0) {
  1117. var callback = callbacks.shift();
  1118. if (typeof callback == 'function') {
  1119. callback(Module); // Pass the module as the first argument.
  1120. continue;
  1121. }
  1122. var func = callback.func;
  1123. if (typeof func === 'number') {
  1124. if (callback.arg === undefined) {
  1125. (function() { dynCall_v.call(null, func); })();
  1126. } else {
  1127. (function(a1) { dynCall_vi.apply(null, [func, a1]); })(callback.arg);
  1128. }
  1129. } else {
  1130. func(callback.arg === undefined ? null : callback.arg);
  1131. }
  1132. }
  1133. }
  1134. function withStackSave(f) {
  1135. var stack = stackSave();
  1136. var ret = f();
  1137. stackRestore(stack);
  1138. return ret;
  1139. }
  1140. function demangle(func) {
  1141. return func;
  1142. }
  1143. function demangleAll(text) {
  1144. var regex =
  1145. /\b_Z[\w\d_]+/g;
  1146. return text.replace(regex,
  1147. function(x) {
  1148. var y = demangle(x);
  1149. return x === y ? x : (y + ' [' + x + ']');
  1150. });
  1151. }
  1152. var wasmTableMirror = [];
  1153. function getWasmTableEntry(funcPtr) {
  1154. var func = wasmTableMirror[funcPtr];
  1155. if (!func) {
  1156. if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
  1157. wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
  1158. }
  1159. return func;
  1160. }
  1161. function handleException(e) {
  1162. // Certain exception types we do not treat as errors since they are used for
  1163. // internal control flow.
  1164. // 1. ExitStatus, which is thrown by exit()
  1165. // 2. "unwind", which is thrown by emscripten_unwind_to_js_event_loop() and others
  1166. // that wish to return to JS event loop.
  1167. if (e instanceof ExitStatus || e == 'unwind') {
  1168. return EXITSTATUS;
  1169. }
  1170. quit_(1, e);
  1171. }
  1172. function jsStackTrace() {
  1173. var error = new Error();
  1174. if (!error.stack) {
  1175. // IE10+ special cases: It does have callstack info, but it is only populated if an Error object is thrown,
  1176. // so try that as a special-case.
  1177. try {
  1178. throw new Error();
  1179. } catch(e) {
  1180. error = e;
  1181. }
  1182. if (!error.stack) {
  1183. return '(no stack trace available)';
  1184. }
  1185. }
  1186. return error.stack.toString();
  1187. }
  1188. function setWasmTableEntry(idx, func) {
  1189. wasmTable.set(idx, func);
  1190. wasmTableMirror[idx] = func;
  1191. }
  1192. function stackTrace() {
  1193. var js = jsStackTrace();
  1194. if (Module['extraStackTrace']) js += '\n' + Module['extraStackTrace']();
  1195. return demangleAll(js);
  1196. }
  1197. function ___cxa_allocate_exception(size) {
  1198. // Thrown object is prepended by exception metadata block
  1199. return _malloc(size + 16) + 16;
  1200. }
  1201. function _atexit(func, arg) {
  1202. }
  1203. function ___cxa_atexit(a0,a1
  1204. ) {
  1205. return _atexit(a0,a1);
  1206. }
  1207. function ExceptionInfo(excPtr) {
  1208. this.excPtr = excPtr;
  1209. this.ptr = excPtr - 16;
  1210. this.set_type = function(type) {
  1211. HEAP32[(((this.ptr)+(4))>>2)] = type;
  1212. };
  1213. this.get_type = function() {
  1214. return HEAP32[(((this.ptr)+(4))>>2)];
  1215. };
  1216. this.set_destructor = function(destructor) {
  1217. HEAP32[(((this.ptr)+(8))>>2)] = destructor;
  1218. };
  1219. this.get_destructor = function() {
  1220. return HEAP32[(((this.ptr)+(8))>>2)];
  1221. };
  1222. this.set_refcount = function(refcount) {
  1223. HEAP32[((this.ptr)>>2)] = refcount;
  1224. };
  1225. this.set_caught = function (caught) {
  1226. caught = caught ? 1 : 0;
  1227. HEAP8[(((this.ptr)+(12))>>0)] = caught;
  1228. };
  1229. this.get_caught = function () {
  1230. return HEAP8[(((this.ptr)+(12))>>0)] != 0;
  1231. };
  1232. this.set_rethrown = function (rethrown) {
  1233. rethrown = rethrown ? 1 : 0;
  1234. HEAP8[(((this.ptr)+(13))>>0)] = rethrown;
  1235. };
  1236. this.get_rethrown = function () {
  1237. return HEAP8[(((this.ptr)+(13))>>0)] != 0;
  1238. };
  1239. // Initialize native structure fields. Should be called once after allocated.
  1240. this.init = function(type, destructor) {
  1241. this.set_type(type);
  1242. this.set_destructor(destructor);
  1243. this.set_refcount(0);
  1244. this.set_caught(false);
  1245. this.set_rethrown(false);
  1246. }
  1247. this.add_ref = function() {
  1248. var value = HEAP32[((this.ptr)>>2)];
  1249. HEAP32[((this.ptr)>>2)] = value + 1;
  1250. };
  1251. // Returns true if last reference released.
  1252. this.release_ref = function() {
  1253. var prev = HEAP32[((this.ptr)>>2)];
  1254. HEAP32[((this.ptr)>>2)] = prev - 1;
  1255. return prev === 1;
  1256. };
  1257. }
  1258. var exceptionLast = 0;
  1259. var uncaughtExceptionCount = 0;
  1260. function ___cxa_throw(ptr, type, destructor) {
  1261. var info = new ExceptionInfo(ptr);
  1262. // Initialize ExceptionInfo content after it was allocated in __cxa_allocate_exception.
  1263. info.init(type, destructor);
  1264. exceptionLast = ptr;
  1265. uncaughtExceptionCount++;
  1266. throw ptr;
  1267. }
  1268. function _gmtime_r(time, tmPtr) {
  1269. var date = new Date(HEAP32[((time)>>2)]*1000);
  1270. HEAP32[((tmPtr)>>2)] = date.getUTCSeconds();
  1271. HEAP32[(((tmPtr)+(4))>>2)] = date.getUTCMinutes();
  1272. HEAP32[(((tmPtr)+(8))>>2)] = date.getUTCHours();
  1273. HEAP32[(((tmPtr)+(12))>>2)] = date.getUTCDate();
  1274. HEAP32[(((tmPtr)+(16))>>2)] = date.getUTCMonth();
  1275. HEAP32[(((tmPtr)+(20))>>2)] = date.getUTCFullYear()-1900;
  1276. HEAP32[(((tmPtr)+(24))>>2)] = date.getUTCDay();
  1277. HEAP32[(((tmPtr)+(36))>>2)] = 0;
  1278. HEAP32[(((tmPtr)+(32))>>2)] = 0;
  1279. var start = Date.UTC(date.getUTCFullYear(), 0, 1, 0, 0, 0, 0);
  1280. var yday = ((date.getTime() - start) / (1000 * 60 * 60 * 24))|0;
  1281. HEAP32[(((tmPtr)+(28))>>2)] = yday;
  1282. // Allocate a string "GMT" for us to point to.
  1283. if (!_gmtime_r.GMTString) _gmtime_r.GMTString = allocateUTF8("GMT");
  1284. HEAP32[(((tmPtr)+(40))>>2)] = _gmtime_r.GMTString;
  1285. return tmPtr;
  1286. }
  1287. function ___gmtime_r(a0,a1
  1288. ) {
  1289. return _gmtime_r(a0,a1);
  1290. }
  1291. function _tzset_impl() {
  1292. var currentYear = new Date().getFullYear();
  1293. var winter = new Date(currentYear, 0, 1);
  1294. var summer = new Date(currentYear, 6, 1);
  1295. var winterOffset = winter.getTimezoneOffset();
  1296. var summerOffset = summer.getTimezoneOffset();
  1297. // Local standard timezone offset. Local standard time is not adjusted for daylight savings.
  1298. // This code uses the fact that getTimezoneOffset returns a greater value during Standard Time versus Daylight Saving Time (DST).
  1299. // 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).
  1300. var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
  1301. // timezone is specified as seconds west of UTC ("The external variable
  1302. // `timezone` shall be set to the difference, in seconds, between
  1303. // Coordinated Universal Time (UTC) and local standard time."), the same
  1304. // as returned by stdTimezoneOffset.
  1305. // See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
  1306. HEAP32[((__get_timezone())>>2)] = stdTimezoneOffset * 60;
  1307. HEAP32[((__get_daylight())>>2)] = Number(winterOffset != summerOffset);
  1308. function extractZone(date) {
  1309. var match = date.toTimeString().match(/\(([A-Za-z ]+)\)$/);
  1310. return match ? match[1] : "GMT";
  1311. };
  1312. var winterName = extractZone(winter);
  1313. var summerName = extractZone(summer);
  1314. var winterNamePtr = allocateUTF8(winterName);
  1315. var summerNamePtr = allocateUTF8(summerName);
  1316. if (summerOffset < winterOffset) {
  1317. // Northern hemisphere
  1318. HEAP32[((__get_tzname())>>2)] = winterNamePtr;
  1319. HEAP32[(((__get_tzname())+(4))>>2)] = summerNamePtr;
  1320. } else {
  1321. HEAP32[((__get_tzname())>>2)] = summerNamePtr;
  1322. HEAP32[(((__get_tzname())+(4))>>2)] = winterNamePtr;
  1323. }
  1324. }
  1325. function _tzset() {
  1326. // TODO: Use (malleable) environment variables instead of system settings.
  1327. if (_tzset.called) return;
  1328. _tzset.called = true;
  1329. _tzset_impl();
  1330. }
  1331. function _localtime_r(time, tmPtr) {
  1332. _tzset();
  1333. var date = new Date(HEAP32[((time)>>2)]*1000);
  1334. HEAP32[((tmPtr)>>2)] = date.getSeconds();
  1335. HEAP32[(((tmPtr)+(4))>>2)] = date.getMinutes();
  1336. HEAP32[(((tmPtr)+(8))>>2)] = date.getHours();
  1337. HEAP32[(((tmPtr)+(12))>>2)] = date.getDate();
  1338. HEAP32[(((tmPtr)+(16))>>2)] = date.getMonth();
  1339. HEAP32[(((tmPtr)+(20))>>2)] = date.getFullYear()-1900;
  1340. HEAP32[(((tmPtr)+(24))>>2)] = date.getDay();
  1341. var start = new Date(date.getFullYear(), 0, 1);
  1342. var yday = ((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))|0;
  1343. HEAP32[(((tmPtr)+(28))>>2)] = yday;
  1344. HEAP32[(((tmPtr)+(36))>>2)] = -(date.getTimezoneOffset() * 60);
  1345. // Attention: DST is in December in South, and some regions don't have DST at all.
  1346. var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
  1347. var winterOffset = start.getTimezoneOffset();
  1348. var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset))|0;
  1349. HEAP32[(((tmPtr)+(32))>>2)] = dst;
  1350. var zonePtr = HEAP32[(((__get_tzname())+(dst ? 4 : 0))>>2)];
  1351. HEAP32[(((tmPtr)+(40))>>2)] = zonePtr;
  1352. return tmPtr;
  1353. }
  1354. function ___localtime_r(a0,a1
  1355. ) {
  1356. return _localtime_r(a0,a1);
  1357. }
  1358. var SYSCALLS = {mappings:{},buffers:[null,[],[]],printChar:function(stream, curr) {
  1359. var buffer = SYSCALLS.buffers[stream];
  1360. if (curr === 0 || curr === 10) {
  1361. (stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0));
  1362. buffer.length = 0;
  1363. } else {
  1364. buffer.push(curr);
  1365. }
  1366. },varargs:undefined,get:function() {
  1367. SYSCALLS.varargs += 4;
  1368. var ret = HEAP32[(((SYSCALLS.varargs)-(4))>>2)];
  1369. return ret;
  1370. },getStr:function(ptr) {
  1371. var ret = UTF8ToString(ptr);
  1372. return ret;
  1373. },get64:function(low, high) {
  1374. return low;
  1375. }};
  1376. function ___syscall__newselect(nfds, readfds, writefds, exceptfds, timeout) {
  1377. }
  1378. function setErrNo(value) {
  1379. HEAP32[((___errno_location())>>2)] = value;
  1380. return value;
  1381. }
  1382. function ___syscall_fcntl64(fd, cmd, varargs) {SYSCALLS.varargs = varargs;
  1383. return 0;
  1384. }
  1385. function ___syscall_ioctl(fd, op, varargs) {SYSCALLS.varargs = varargs;
  1386. return 0;
  1387. }
  1388. function ___syscall_mkdir(path, mode) {
  1389. path = SYSCALLS.getStr(path);
  1390. return SYSCALLS.doMkdir(path, mode);
  1391. }
  1392. function ___syscall_open(path, flags, varargs) {SYSCALLS.varargs = varargs;
  1393. }
  1394. function ___syscall_rmdir(path) {
  1395. }
  1396. function ___syscall_unlink(path) {
  1397. }
  1398. var structRegistrations = {};
  1399. function runDestructors(destructors) {
  1400. while (destructors.length) {
  1401. var ptr = destructors.pop();
  1402. var del = destructors.pop();
  1403. del(ptr);
  1404. }
  1405. }
  1406. function simpleReadValueFromPointer(pointer) {
  1407. return this['fromWireType'](HEAPU32[pointer >> 2]);
  1408. }
  1409. var awaitingDependencies = {};
  1410. var registeredTypes = {};
  1411. var typeDependencies = {};
  1412. var char_0 = 48;
  1413. var char_9 = 57;
  1414. function makeLegalFunctionName(name) {
  1415. if (undefined === name) {
  1416. return '_unknown';
  1417. }
  1418. name = name.replace(/[^a-zA-Z0-9_]/g, '$');
  1419. var f = name.charCodeAt(0);
  1420. if (f >= char_0 && f <= char_9) {
  1421. return '_' + name;
  1422. } else {
  1423. return name;
  1424. }
  1425. }
  1426. function createNamedFunction(name, body) {
  1427. name = makeLegalFunctionName(name);
  1428. /*jshint evil:true*/
  1429. return new Function(
  1430. "body",
  1431. "return function " + name + "() {\n" +
  1432. " \"use strict\";" +
  1433. " return body.apply(this, arguments);\n" +
  1434. "};\n"
  1435. )(body);
  1436. }
  1437. function extendError(baseErrorType, errorName) {
  1438. var errorClass = createNamedFunction(errorName, function(message) {
  1439. this.name = errorName;
  1440. this.message = message;
  1441. var stack = (new Error(message)).stack;
  1442. if (stack !== undefined) {
  1443. this.stack = this.toString() + '\n' +
  1444. stack.replace(/^Error(:[^\n]*)?\n/, '');
  1445. }
  1446. });
  1447. errorClass.prototype = Object.create(baseErrorType.prototype);
  1448. errorClass.prototype.constructor = errorClass;
  1449. errorClass.prototype.toString = function() {
  1450. if (this.message === undefined) {
  1451. return this.name;
  1452. } else {
  1453. return this.name + ': ' + this.message;
  1454. }
  1455. };
  1456. return errorClass;
  1457. }
  1458. var InternalError = undefined;
  1459. function throwInternalError(message) {
  1460. throw new InternalError(message);
  1461. }
  1462. function whenDependentTypesAreResolved(myTypes, dependentTypes, getTypeConverters) {
  1463. myTypes.forEach(function(type) {
  1464. typeDependencies[type] = dependentTypes;
  1465. });
  1466. function onComplete(typeConverters) {
  1467. var myTypeConverters = getTypeConverters(typeConverters);
  1468. if (myTypeConverters.length !== myTypes.length) {
  1469. throwInternalError('Mismatched type converter count');
  1470. }
  1471. for (var i = 0; i < myTypes.length; ++i) {
  1472. registerType(myTypes[i], myTypeConverters[i]);
  1473. }
  1474. }
  1475. var typeConverters = new Array(dependentTypes.length);
  1476. var unregisteredTypes = [];
  1477. var registered = 0;
  1478. dependentTypes.forEach(function(dt, i) {
  1479. if (registeredTypes.hasOwnProperty(dt)) {
  1480. typeConverters[i] = registeredTypes[dt];
  1481. } else {
  1482. unregisteredTypes.push(dt);
  1483. if (!awaitingDependencies.hasOwnProperty(dt)) {
  1484. awaitingDependencies[dt] = [];
  1485. }
  1486. awaitingDependencies[dt].push(function() {
  1487. typeConverters[i] = registeredTypes[dt];
  1488. ++registered;
  1489. if (registered === unregisteredTypes.length) {
  1490. onComplete(typeConverters);
  1491. }
  1492. });
  1493. }
  1494. });
  1495. if (0 === unregisteredTypes.length) {
  1496. onComplete(typeConverters);
  1497. }
  1498. }
  1499. function __embind_finalize_value_object(structType) {
  1500. var reg = structRegistrations[structType];
  1501. delete structRegistrations[structType];
  1502. var rawConstructor = reg.rawConstructor;
  1503. var rawDestructor = reg.rawDestructor;
  1504. var fieldRecords = reg.fields;
  1505. var fieldTypes = fieldRecords.map(function(field) { return field.getterReturnType; }).
  1506. concat(fieldRecords.map(function(field) { return field.setterArgumentType; }));
  1507. whenDependentTypesAreResolved([structType], fieldTypes, function(fieldTypes) {
  1508. var fields = {};
  1509. fieldRecords.forEach(function(field, i) {
  1510. var fieldName = field.fieldName;
  1511. var getterReturnType = fieldTypes[i];
  1512. var getter = field.getter;
  1513. var getterContext = field.getterContext;
  1514. var setterArgumentType = fieldTypes[i + fieldRecords.length];
  1515. var setter = field.setter;
  1516. var setterContext = field.setterContext;
  1517. fields[fieldName] = {
  1518. read: function(ptr) {
  1519. return getterReturnType['fromWireType'](
  1520. getter(getterContext, ptr));
  1521. },
  1522. write: function(ptr, o) {
  1523. var destructors = [];
  1524. setter(setterContext, ptr, setterArgumentType['toWireType'](destructors, o));
  1525. runDestructors(destructors);
  1526. }
  1527. };
  1528. });
  1529. return [{
  1530. name: reg.name,
  1531. 'fromWireType': function(ptr) {
  1532. var rv = {};
  1533. for (var i in fields) {
  1534. rv[i] = fields[i].read(ptr);
  1535. }
  1536. rawDestructor(ptr);
  1537. return rv;
  1538. },
  1539. 'toWireType': function(destructors, o) {
  1540. // todo: Here we have an opportunity for -O3 level "unsafe" optimizations:
  1541. // assume all fields are present without checking.
  1542. for (var fieldName in fields) {
  1543. if (!(fieldName in o)) {
  1544. throw new TypeError('Missing field: "' + fieldName + '"');
  1545. }
  1546. }
  1547. var ptr = rawConstructor();
  1548. for (fieldName in fields) {
  1549. fields[fieldName].write(ptr, o[fieldName]);
  1550. }
  1551. if (destructors !== null) {
  1552. destructors.push(rawDestructor, ptr);
  1553. }
  1554. return ptr;
  1555. },
  1556. 'argPackAdvance': 8,
  1557. 'readValueFromPointer': simpleReadValueFromPointer,
  1558. destructorFunction: rawDestructor,
  1559. }];
  1560. });
  1561. }
  1562. function __embind_register_bigint(primitiveType, name, size, minRange, maxRange) {}
  1563. function getShiftFromSize(size) {
  1564. switch (size) {
  1565. case 1: return 0;
  1566. case 2: return 1;
  1567. case 4: return 2;
  1568. case 8: return 3;
  1569. default:
  1570. throw new TypeError('Unknown type size: ' + size);
  1571. }
  1572. }
  1573. function embind_init_charCodes() {
  1574. var codes = new Array(256);
  1575. for (var i = 0; i < 256; ++i) {
  1576. codes[i] = String.fromCharCode(i);
  1577. }
  1578. embind_charCodes = codes;
  1579. }
  1580. var embind_charCodes = undefined;
  1581. function readLatin1String(ptr) {
  1582. var ret = "";
  1583. var c = ptr;
  1584. while (HEAPU8[c]) {
  1585. ret += embind_charCodes[HEAPU8[c++]];
  1586. }
  1587. return ret;
  1588. }
  1589. var BindingError = undefined;
  1590. function throwBindingError(message) {
  1591. throw new BindingError(message);
  1592. }
  1593. /** @param {Object=} options */
  1594. function registerType(rawType, registeredInstance, options) {
  1595. options = options || {};
  1596. if (!('argPackAdvance' in registeredInstance)) {
  1597. throw new TypeError('registerType registeredInstance requires argPackAdvance');
  1598. }
  1599. var name = registeredInstance.name;
  1600. if (!rawType) {
  1601. throwBindingError('type "' + name + '" must have a positive integer typeid pointer');
  1602. }
  1603. if (registeredTypes.hasOwnProperty(rawType)) {
  1604. if (options.ignoreDuplicateRegistrations) {
  1605. return;
  1606. } else {
  1607. throwBindingError("Cannot register type '" + name + "' twice");
  1608. }
  1609. }
  1610. registeredTypes[rawType] = registeredInstance;
  1611. delete typeDependencies[rawType];
  1612. if (awaitingDependencies.hasOwnProperty(rawType)) {
  1613. var callbacks = awaitingDependencies[rawType];
  1614. delete awaitingDependencies[rawType];
  1615. callbacks.forEach(function(cb) {
  1616. cb();
  1617. });
  1618. }
  1619. }
  1620. function __embind_register_bool(rawType, name, size, trueValue, falseValue) {
  1621. var shift = getShiftFromSize(size);
  1622. name = readLatin1String(name);
  1623. registerType(rawType, {
  1624. name: name,
  1625. 'fromWireType': function(wt) {
  1626. // ambiguous emscripten ABI: sometimes return values are
  1627. // true or false, and sometimes integers (0 or 1)
  1628. return !!wt;
  1629. },
  1630. 'toWireType': function(destructors, o) {
  1631. return o ? trueValue : falseValue;
  1632. },
  1633. 'argPackAdvance': 8,
  1634. 'readValueFromPointer': function(pointer) {
  1635. // TODO: if heap is fixed (like in asm.js) this could be executed outside
  1636. var heap;
  1637. if (size === 1) {
  1638. heap = HEAP8;
  1639. } else if (size === 2) {
  1640. heap = HEAP16;
  1641. } else if (size === 4) {
  1642. heap = HEAP32;
  1643. } else {
  1644. throw new TypeError("Unknown boolean type size: " + name);
  1645. }
  1646. return this['fromWireType'](heap[pointer >> shift]);
  1647. },
  1648. destructorFunction: null, // This type does not need a destructor
  1649. });
  1650. }
  1651. function ClassHandle_isAliasOf(other) {
  1652. if (!(this instanceof ClassHandle)) {
  1653. return false;
  1654. }
  1655. if (!(other instanceof ClassHandle)) {
  1656. return false;
  1657. }
  1658. var leftClass = this.$$.ptrType.registeredClass;
  1659. var left = this.$$.ptr;
  1660. var rightClass = other.$$.ptrType.registeredClass;
  1661. var right = other.$$.ptr;
  1662. while (leftClass.baseClass) {
  1663. left = leftClass.upcast(left);
  1664. leftClass = leftClass.baseClass;
  1665. }
  1666. while (rightClass.baseClass) {
  1667. right = rightClass.upcast(right);
  1668. rightClass = rightClass.baseClass;
  1669. }
  1670. return leftClass === rightClass && left === right;
  1671. }
  1672. function shallowCopyInternalPointer(o) {
  1673. return {
  1674. count: o.count,
  1675. deleteScheduled: o.deleteScheduled,
  1676. preservePointerOnDelete: o.preservePointerOnDelete,
  1677. ptr: o.ptr,
  1678. ptrType: o.ptrType,
  1679. smartPtr: o.smartPtr,
  1680. smartPtrType: o.smartPtrType,
  1681. };
  1682. }
  1683. function throwInstanceAlreadyDeleted(obj) {
  1684. function getInstanceTypeName(handle) {
  1685. return handle.$$.ptrType.registeredClass.name;
  1686. }
  1687. throwBindingError(getInstanceTypeName(obj) + ' instance already deleted');
  1688. }
  1689. var finalizationGroup = false;
  1690. function detachFinalizer(handle) {}
  1691. function runDestructor($$) {
  1692. if ($$.smartPtr) {
  1693. $$.smartPtrType.rawDestructor($$.smartPtr);
  1694. } else {
  1695. $$.ptrType.registeredClass.rawDestructor($$.ptr);
  1696. }
  1697. }
  1698. function releaseClassHandle($$) {
  1699. $$.count.value -= 1;
  1700. var toDelete = 0 === $$.count.value;
  1701. if (toDelete) {
  1702. runDestructor($$);
  1703. }
  1704. }
  1705. function attachFinalizer(handle) {
  1706. if ('undefined' === typeof FinalizationGroup) {
  1707. attachFinalizer = function (handle) { return handle; };
  1708. return handle;
  1709. }
  1710. // If the running environment has a FinalizationGroup (see
  1711. // https://github.com/tc39/proposal-weakrefs), then attach finalizers
  1712. // for class handles. We check for the presence of FinalizationGroup
  1713. // at run-time, not build-time.
  1714. finalizationGroup = new FinalizationGroup(function (iter) {
  1715. for (var result = iter.next(); !result.done; result = iter.next()) {
  1716. var $$ = result.value;
  1717. if (!$$.ptr) {
  1718. console.warn('object already deleted: ' + $$.ptr);
  1719. } else {
  1720. releaseClassHandle($$);
  1721. }
  1722. }
  1723. });
  1724. attachFinalizer = function(handle) {
  1725. finalizationGroup.register(handle, handle.$$, handle.$$);
  1726. return handle;
  1727. };
  1728. detachFinalizer = function(handle) {
  1729. finalizationGroup.unregister(handle.$$);
  1730. };
  1731. return attachFinalizer(handle);
  1732. }
  1733. function ClassHandle_clone() {
  1734. if (!this.$$.ptr) {
  1735. throwInstanceAlreadyDeleted(this);
  1736. }
  1737. if (this.$$.preservePointerOnDelete) {
  1738. this.$$.count.value += 1;
  1739. return this;
  1740. } else {
  1741. var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), {
  1742. $$: {
  1743. value: shallowCopyInternalPointer(this.$$),
  1744. }
  1745. }));
  1746. clone.$$.count.value += 1;
  1747. clone.$$.deleteScheduled = false;
  1748. return clone;
  1749. }
  1750. }
  1751. function ClassHandle_delete() {
  1752. if (!this.$$.ptr) {
  1753. throwInstanceAlreadyDeleted(this);
  1754. }
  1755. if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
  1756. throwBindingError('Object already scheduled for deletion');
  1757. }
  1758. detachFinalizer(this);
  1759. releaseClassHandle(this.$$);
  1760. if (!this.$$.preservePointerOnDelete) {
  1761. this.$$.smartPtr = undefined;
  1762. this.$$.ptr = undefined;
  1763. }
  1764. }
  1765. function ClassHandle_isDeleted() {
  1766. return !this.$$.ptr;
  1767. }
  1768. var delayFunction = undefined;
  1769. var deletionQueue = [];
  1770. function flushPendingDeletes() {
  1771. while (deletionQueue.length) {
  1772. var obj = deletionQueue.pop();
  1773. obj.$$.deleteScheduled = false;
  1774. obj['delete']();
  1775. }
  1776. }
  1777. function ClassHandle_deleteLater() {
  1778. if (!this.$$.ptr) {
  1779. throwInstanceAlreadyDeleted(this);
  1780. }
  1781. if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
  1782. throwBindingError('Object already scheduled for deletion');
  1783. }
  1784. deletionQueue.push(this);
  1785. if (deletionQueue.length === 1 && delayFunction) {
  1786. delayFunction(flushPendingDeletes);
  1787. }
  1788. this.$$.deleteScheduled = true;
  1789. return this;
  1790. }
  1791. function init_ClassHandle() {
  1792. ClassHandle.prototype['isAliasOf'] = ClassHandle_isAliasOf;
  1793. ClassHandle.prototype['clone'] = ClassHandle_clone;
  1794. ClassHandle.prototype['delete'] = ClassHandle_delete;
  1795. ClassHandle.prototype['isDeleted'] = ClassHandle_isDeleted;
  1796. ClassHandle.prototype['deleteLater'] = ClassHandle_deleteLater;
  1797. }
  1798. function ClassHandle() {
  1799. }
  1800. var registeredPointers = {};
  1801. function ensureOverloadTable(proto, methodName, humanName) {
  1802. if (undefined === proto[methodName].overloadTable) {
  1803. var prevFunc = proto[methodName];
  1804. // Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
  1805. proto[methodName] = function() {
  1806. // TODO This check can be removed in -O3 level "unsafe" optimizations.
  1807. if (!proto[methodName].overloadTable.hasOwnProperty(arguments.length)) {
  1808. throwBindingError("Function '" + humanName + "' called with an invalid number of arguments (" + arguments.length + ") - expects one of (" + proto[methodName].overloadTable + ")!");
  1809. }
  1810. return proto[methodName].overloadTable[arguments.length].apply(this, arguments);
  1811. };
  1812. // Move the previous function into the overload table.
  1813. proto[methodName].overloadTable = [];
  1814. proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
  1815. }
  1816. }
  1817. /** @param {number=} numArguments */
  1818. function exposePublicSymbol(name, value, numArguments) {
  1819. if (Module.hasOwnProperty(name)) {
  1820. if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
  1821. throwBindingError("Cannot register public name '" + name + "' twice");
  1822. }
  1823. // We are exposing a function with the same name as an existing function. Create an overload table and a function selector
  1824. // that routes between the two.
  1825. ensureOverloadTable(Module, name, name);
  1826. if (Module.hasOwnProperty(numArguments)) {
  1827. throwBindingError("Cannot register multiple overloads of a function with the same number of arguments (" + numArguments + ")!");
  1828. }
  1829. // Add the new function into the overload table.
  1830. Module[name].overloadTable[numArguments] = value;
  1831. }
  1832. else {
  1833. Module[name] = value;
  1834. if (undefined !== numArguments) {
  1835. Module[name].numArguments = numArguments;
  1836. }
  1837. }
  1838. }
  1839. /** @constructor */
  1840. function RegisteredClass(
  1841. name,
  1842. constructor,
  1843. instancePrototype,
  1844. rawDestructor,
  1845. baseClass,
  1846. getActualType,
  1847. upcast,
  1848. downcast
  1849. ) {
  1850. this.name = name;
  1851. this.constructor = constructor;
  1852. this.instancePrototype = instancePrototype;
  1853. this.rawDestructor = rawDestructor;
  1854. this.baseClass = baseClass;
  1855. this.getActualType = getActualType;
  1856. this.upcast = upcast;
  1857. this.downcast = downcast;
  1858. this.pureVirtualFunctions = [];
  1859. }
  1860. function upcastPointer(ptr, ptrClass, desiredClass) {
  1861. while (ptrClass !== desiredClass) {
  1862. if (!ptrClass.upcast) {
  1863. throwBindingError("Expected null or instance of " + desiredClass.name + ", got an instance of " + ptrClass.name);
  1864. }
  1865. ptr = ptrClass.upcast(ptr);
  1866. ptrClass = ptrClass.baseClass;
  1867. }
  1868. return ptr;
  1869. }
  1870. function constNoSmartPtrRawPointerToWireType(destructors, handle) {
  1871. if (handle === null) {
  1872. if (this.isReference) {
  1873. throwBindingError('null is not a valid ' + this.name);
  1874. }
  1875. return 0;
  1876. }
  1877. if (!handle.$$) {
  1878. throwBindingError('Cannot pass "' + _embind_repr(handle) + '" as a ' + this.name);
  1879. }
  1880. if (!handle.$$.ptr) {
  1881. throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
  1882. }
  1883. var handleClass = handle.$$.ptrType.registeredClass;
  1884. var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
  1885. return ptr;
  1886. }
  1887. function genericPointerToWireType(destructors, handle) {
  1888. var ptr;
  1889. if (handle === null) {
  1890. if (this.isReference) {
  1891. throwBindingError('null is not a valid ' + this.name);
  1892. }
  1893. if (this.isSmartPointer) {
  1894. ptr = this.rawConstructor();
  1895. if (destructors !== null) {
  1896. destructors.push(this.rawDestructor, ptr);
  1897. }
  1898. return ptr;
  1899. } else {
  1900. return 0;
  1901. }
  1902. }
  1903. if (!handle.$$) {
  1904. throwBindingError('Cannot pass "' + _embind_repr(handle) + '" as a ' + this.name);
  1905. }
  1906. if (!handle.$$.ptr) {
  1907. throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
  1908. }
  1909. if (!this.isConst && handle.$$.ptrType.isConst) {
  1910. throwBindingError('Cannot convert argument of type ' + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + ' to parameter type ' + this.name);
  1911. }
  1912. var handleClass = handle.$$.ptrType.registeredClass;
  1913. ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
  1914. if (this.isSmartPointer) {
  1915. // TODO: this is not strictly true
  1916. // We could support BY_EMVAL conversions from raw pointers to smart pointers
  1917. // because the smart pointer can hold a reference to the handle
  1918. if (undefined === handle.$$.smartPtr) {
  1919. throwBindingError('Passing raw pointer to smart pointer is illegal');
  1920. }
  1921. switch (this.sharingPolicy) {
  1922. case 0: // NONE
  1923. // no upcasting
  1924. if (handle.$$.smartPtrType === this) {
  1925. ptr = handle.$$.smartPtr;
  1926. } else {
  1927. throwBindingError('Cannot convert argument of type ' + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + ' to parameter type ' + this.name);
  1928. }
  1929. break;
  1930. case 1: // INTRUSIVE
  1931. ptr = handle.$$.smartPtr;
  1932. break;
  1933. case 2: // BY_EMVAL
  1934. if (handle.$$.smartPtrType === this) {
  1935. ptr = handle.$$.smartPtr;
  1936. } else {
  1937. var clonedHandle = handle['clone']();
  1938. ptr = this.rawShare(
  1939. ptr,
  1940. Emval.toHandle(function() {
  1941. clonedHandle['delete']();
  1942. })
  1943. );
  1944. if (destructors !== null) {
  1945. destructors.push(this.rawDestructor, ptr);
  1946. }
  1947. }
  1948. break;
  1949. default:
  1950. throwBindingError('Unsupporting sharing policy');
  1951. }
  1952. }
  1953. return ptr;
  1954. }
  1955. function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) {
  1956. if (handle === null) {
  1957. if (this.isReference) {
  1958. throwBindingError('null is not a valid ' + this.name);
  1959. }
  1960. return 0;
  1961. }
  1962. if (!handle.$$) {
  1963. throwBindingError('Cannot pass "' + _embind_repr(handle) + '" as a ' + this.name);
  1964. }
  1965. if (!handle.$$.ptr) {
  1966. throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
  1967. }
  1968. if (handle.$$.ptrType.isConst) {
  1969. throwBindingError('Cannot convert argument of type ' + handle.$$.ptrType.name + ' to parameter type ' + this.name);
  1970. }
  1971. var handleClass = handle.$$.ptrType.registeredClass;
  1972. var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
  1973. return ptr;
  1974. }
  1975. function RegisteredPointer_getPointee(ptr) {
  1976. if (this.rawGetPointee) {
  1977. ptr = this.rawGetPointee(ptr);
  1978. }
  1979. return ptr;
  1980. }
  1981. function RegisteredPointer_destructor(ptr) {
  1982. if (this.rawDestructor) {
  1983. this.rawDestructor(ptr);
  1984. }
  1985. }
  1986. function RegisteredPointer_deleteObject(handle) {
  1987. if (handle !== null) {
  1988. handle['delete']();
  1989. }
  1990. }
  1991. function downcastPointer(ptr, ptrClass, desiredClass) {
  1992. if (ptrClass === desiredClass) {
  1993. return ptr;
  1994. }
  1995. if (undefined === desiredClass.baseClass) {
  1996. return null; // no conversion
  1997. }
  1998. var rv = downcastPointer(ptr, ptrClass, desiredClass.baseClass);
  1999. if (rv === null) {
  2000. return null;
  2001. }
  2002. return desiredClass.downcast(rv);
  2003. }
  2004. function getInheritedInstanceCount() {
  2005. return Object.keys(registeredInstances).length;
  2006. }
  2007. function getLiveInheritedInstances() {
  2008. var rv = [];
  2009. for (var k in registeredInstances) {
  2010. if (registeredInstances.hasOwnProperty(k)) {
  2011. rv.push(registeredInstances[k]);
  2012. }
  2013. }
  2014. return rv;
  2015. }
  2016. function setDelayFunction(fn) {
  2017. delayFunction = fn;
  2018. if (deletionQueue.length && delayFunction) {
  2019. delayFunction(flushPendingDeletes);
  2020. }
  2021. }
  2022. function init_embind() {
  2023. Module['getInheritedInstanceCount'] = getInheritedInstanceCount;
  2024. Module['getLiveInheritedInstances'] = getLiveInheritedInstances;
  2025. Module['flushPendingDeletes'] = flushPendingDeletes;
  2026. Module['setDelayFunction'] = setDelayFunction;
  2027. }
  2028. var registeredInstances = {};
  2029. function getBasestPointer(class_, ptr) {
  2030. if (ptr === undefined) {
  2031. throwBindingError('ptr should not be undefined');
  2032. }
  2033. while (class_.baseClass) {
  2034. ptr = class_.upcast(ptr);
  2035. class_ = class_.baseClass;
  2036. }
  2037. return ptr;
  2038. }
  2039. function getInheritedInstance(class_, ptr) {
  2040. ptr = getBasestPointer(class_, ptr);
  2041. return registeredInstances[ptr];
  2042. }
  2043. function makeClassHandle(prototype, record) {
  2044. if (!record.ptrType || !record.ptr) {
  2045. throwInternalError('makeClassHandle requires ptr and ptrType');
  2046. }
  2047. var hasSmartPtrType = !!record.smartPtrType;
  2048. var hasSmartPtr = !!record.smartPtr;
  2049. if (hasSmartPtrType !== hasSmartPtr) {
  2050. throwInternalError('Both smartPtrType and smartPtr must be specified');
  2051. }
  2052. record.count = { value: 1 };
  2053. return attachFinalizer(Object.create(prototype, {
  2054. $$: {
  2055. value: record,
  2056. },
  2057. }));
  2058. }
  2059. function RegisteredPointer_fromWireType(ptr) {
  2060. // ptr is a raw pointer (or a raw smartpointer)
  2061. // rawPointer is a maybe-null raw pointer
  2062. var rawPointer = this.getPointee(ptr);
  2063. if (!rawPointer) {
  2064. this.destructor(ptr);
  2065. return null;
  2066. }
  2067. var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer);
  2068. if (undefined !== registeredInstance) {
  2069. // JS object has been neutered, time to repopulate it
  2070. if (0 === registeredInstance.$$.count.value) {
  2071. registeredInstance.$$.ptr = rawPointer;
  2072. registeredInstance.$$.smartPtr = ptr;
  2073. return registeredInstance['clone']();
  2074. } else {
  2075. // else, just increment reference count on existing object
  2076. // it already has a reference to the smart pointer
  2077. var rv = registeredInstance['clone']();
  2078. this.destructor(ptr);
  2079. return rv;
  2080. }
  2081. }
  2082. function makeDefaultHandle() {
  2083. if (this.isSmartPointer) {
  2084. return makeClassHandle(this.registeredClass.instancePrototype, {
  2085. ptrType: this.pointeeType,
  2086. ptr: rawPointer,
  2087. smartPtrType: this,
  2088. smartPtr: ptr,
  2089. });
  2090. } else {
  2091. return makeClassHandle(this.registeredClass.instancePrototype, {
  2092. ptrType: this,
  2093. ptr: ptr,
  2094. });
  2095. }
  2096. }
  2097. var actualType = this.registeredClass.getActualType(rawPointer);
  2098. var registeredPointerRecord = registeredPointers[actualType];
  2099. if (!registeredPointerRecord) {
  2100. return makeDefaultHandle.call(this);
  2101. }
  2102. var toType;
  2103. if (this.isConst) {
  2104. toType = registeredPointerRecord.constPointerType;
  2105. } else {
  2106. toType = registeredPointerRecord.pointerType;
  2107. }
  2108. var dp = downcastPointer(
  2109. rawPointer,
  2110. this.registeredClass,
  2111. toType.registeredClass);
  2112. if (dp === null) {
  2113. return makeDefaultHandle.call(this);
  2114. }
  2115. if (this.isSmartPointer) {
  2116. return makeClassHandle(toType.registeredClass.instancePrototype, {
  2117. ptrType: toType,
  2118. ptr: dp,
  2119. smartPtrType: this,
  2120. smartPtr: ptr,
  2121. });
  2122. } else {
  2123. return makeClassHandle(toType.registeredClass.instancePrototype, {
  2124. ptrType: toType,
  2125. ptr: dp,
  2126. });
  2127. }
  2128. }
  2129. function init_RegisteredPointer() {
  2130. RegisteredPointer.prototype.getPointee = RegisteredPointer_getPointee;
  2131. RegisteredPointer.prototype.destructor = RegisteredPointer_destructor;
  2132. RegisteredPointer.prototype['argPackAdvance'] = 8;
  2133. RegisteredPointer.prototype['readValueFromPointer'] = simpleReadValueFromPointer;
  2134. RegisteredPointer.prototype['deleteObject'] = RegisteredPointer_deleteObject;
  2135. RegisteredPointer.prototype['fromWireType'] = RegisteredPointer_fromWireType;
  2136. }
  2137. /** @constructor
  2138. @param {*=} pointeeType,
  2139. @param {*=} sharingPolicy,
  2140. @param {*=} rawGetPointee,
  2141. @param {*=} rawConstructor,
  2142. @param {*=} rawShare,
  2143. @param {*=} rawDestructor,
  2144. */
  2145. function RegisteredPointer(
  2146. name,
  2147. registeredClass,
  2148. isReference,
  2149. isConst,
  2150. // smart pointer properties
  2151. isSmartPointer,
  2152. pointeeType,
  2153. sharingPolicy,
  2154. rawGetPointee,
  2155. rawConstructor,
  2156. rawShare,
  2157. rawDestructor
  2158. ) {
  2159. this.name = name;
  2160. this.registeredClass = registeredClass;
  2161. this.isReference = isReference;
  2162. this.isConst = isConst;
  2163. // smart pointer properties
  2164. this.isSmartPointer = isSmartPointer;
  2165. this.pointeeType = pointeeType;
  2166. this.sharingPolicy = sharingPolicy;
  2167. this.rawGetPointee = rawGetPointee;
  2168. this.rawConstructor = rawConstructor;
  2169. this.rawShare = rawShare;
  2170. this.rawDestructor = rawDestructor;
  2171. if (!isSmartPointer && registeredClass.baseClass === undefined) {
  2172. if (isConst) {
  2173. this['toWireType'] = constNoSmartPtrRawPointerToWireType;
  2174. this.destructorFunction = null;
  2175. } else {
  2176. this['toWireType'] = nonConstNoSmartPtrRawPointerToWireType;
  2177. this.destructorFunction = null;
  2178. }
  2179. } else {
  2180. this['toWireType'] = genericPointerToWireType;
  2181. // Here we must leave this.destructorFunction undefined, since whether genericPointerToWireType returns
  2182. // a pointer that needs to be freed up is runtime-dependent, and cannot be evaluated at registration time.
  2183. // TODO: Create an alternative mechanism that allows removing the use of var destructors = []; array in
  2184. // craftInvokerFunction altogether.
  2185. }
  2186. }
  2187. /** @param {number=} numArguments */
  2188. function replacePublicSymbol(name, value, numArguments) {
  2189. if (!Module.hasOwnProperty(name)) {
  2190. throwInternalError('Replacing nonexistant public symbol');
  2191. }
  2192. // If there's an overload table for this symbol, replace the symbol in the overload table instead.
  2193. if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
  2194. Module[name].overloadTable[numArguments] = value;
  2195. }
  2196. else {
  2197. Module[name] = value;
  2198. Module[name].argCount = numArguments;
  2199. }
  2200. }
  2201. function dynCallLegacy(sig, ptr, args) { // viii\ 94  [5741320, 5744120, 131072]
  2202. var f = Module["dynCall_" + sig];
  2203. return args && args.length ? f.apply(null, [ptr].concat(args)) : f.call(null, ptr);
  2204. }
  2205. function dynCall(sig, ptr, args) {
  2206. return dynCallLegacy(sig, ptr, args);
  2207. }
  2208. function getDynCaller(sig, ptr) {// viii 94
  2209. var argCache = [];
  2210. return function() {
  2211. argCache.length = arguments.length;
  2212. for (var i = 0; i < arguments.length; i++) {
  2213. argCache[i] = arguments[i];
  2214. }
  2215. return dynCall(sig, ptr, argCache);
  2216. };
  2217. }
  2218. function embind__requireFunction(signature, rawFunction) {
  2219. signature = readLatin1String(signature);
  2220. function makeDynCaller() {
  2221. return getDynCaller(signature, rawFunction);
  2222. }
  2223. var fp = makeDynCaller();
  2224. if (typeof fp !== "function") {
  2225. throwBindingError("unknown function pointer with signature " + signature + ": " + rawFunction);
  2226. }
  2227. return fp;
  2228. }
  2229. var UnboundTypeError = undefined;
  2230. function getTypeName(type) {
  2231. var ptr = ___getTypeName(type);
  2232. var rv = readLatin1String(ptr);
  2233. _free(ptr);
  2234. return rv;
  2235. }
  2236. function throwUnboundTypeError(message, types) {
  2237. var unboundTypes = [];
  2238. var seen = {};
  2239. function visit(type) {
  2240. if (seen[type]) {
  2241. return;
  2242. }
  2243. if (registeredTypes[type]) {
  2244. return;
  2245. }
  2246. if (typeDependencies[type]) {
  2247. typeDependencies[type].forEach(visit);
  2248. return;
  2249. }
  2250. unboundTypes.push(type);
  2251. seen[type] = true;
  2252. }
  2253. types.forEach(visit);
  2254. throw new UnboundTypeError(message + ': ' + unboundTypes.map(getTypeName).join([', ']));
  2255. }
  2256. function __embind_register_class(
  2257. rawType,
  2258. rawPointerType,
  2259. rawConstPointerType,
  2260. baseClassRawType,
  2261. getActualTypeSignature,
  2262. getActualType,
  2263. upcastSignature,
  2264. upcast,
  2265. downcastSignature,
  2266. downcast,
  2267. name,
  2268. destructorSignature,
  2269. rawDestructor
  2270. ) {
  2271. name = readLatin1String(name);
  2272. getActualType = embind__requireFunction(getActualTypeSignature, getActualType);
  2273. if (upcast) {
  2274. upcast = embind__requireFunction(upcastSignature, upcast);
  2275. }
  2276. if (downcast) {
  2277. downcast = embind__requireFunction(downcastSignature, downcast);
  2278. }
  2279. rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);
  2280. var legalFunctionName = makeLegalFunctionName(name);
  2281. exposePublicSymbol(legalFunctionName, function() {
  2282. // this code cannot run if baseClassRawType is zero
  2283. throwUnboundTypeError('Cannot construct ' + name + ' due to unbound types', [baseClassRawType]);
  2284. });
  2285. whenDependentTypesAreResolved(
  2286. [rawType, rawPointerType, rawConstPointerType],
  2287. baseClassRawType ? [baseClassRawType] : [],
  2288. function(base) {
  2289. base = base[0];
  2290. var baseClass;
  2291. var basePrototype;
  2292. if (baseClassRawType) {
  2293. baseClass = base.registeredClass;
  2294. basePrototype = baseClass.instancePrototype;
  2295. } else {
  2296. basePrototype = ClassHandle.prototype;
  2297. }
  2298. var constructor = createNamedFunction(legalFunctionName, function() {
  2299. if (Object.getPrototypeOf(this) !== instancePrototype) {
  2300. throw new BindingError("Use 'new' to construct " + name);
  2301. }
  2302. if (undefined === registeredClass.constructor_body) {
  2303. throw new BindingError(name + " has no accessible constructor");
  2304. }
  2305. var body = registeredClass.constructor_body[arguments.length];
  2306. if (undefined === body) {
  2307. 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!");
  2308. }
  2309. return body.apply(this, arguments);
  2310. });
  2311. var instancePrototype = Object.create(basePrototype, {
  2312. constructor: { value: constructor },
  2313. });
  2314. constructor.prototype = instancePrototype;
  2315. var registeredClass = new RegisteredClass(
  2316. name,
  2317. constructor,
  2318. instancePrototype,
  2319. rawDestructor,
  2320. baseClass,
  2321. getActualType,
  2322. upcast,
  2323. downcast);
  2324. var referenceConverter = new RegisteredPointer(
  2325. name,
  2326. registeredClass,
  2327. true,
  2328. false,
  2329. false);
  2330. var pointerConverter = new RegisteredPointer(
  2331. name + '*',
  2332. registeredClass,
  2333. false,
  2334. false,
  2335. false);
  2336. var constPointerConverter = new RegisteredPointer(
  2337. name + ' const*',
  2338. registeredClass,
  2339. false,
  2340. true,
  2341. false);
  2342. registeredPointers[rawType] = {
  2343. pointerType: pointerConverter,
  2344. constPointerType: constPointerConverter
  2345. };
  2346. replacePublicSymbol(legalFunctionName, constructor);
  2347. return [referenceConverter, pointerConverter, constPointerConverter];
  2348. }
  2349. );
  2350. }
  2351. function heap32VectorToArray(count, firstElement) {
  2352. var array = [];
  2353. for (var i = 0; i < count; i++) {
  2354. array.push(HEAP32[(firstElement >> 2) + i]);
  2355. }
  2356. return array;
  2357. }
  2358. function __embind_register_class_constructor(
  2359. rawClassType,
  2360. argCount,
  2361. rawArgTypesAddr,
  2362. invokerSignature,
  2363. invoker,
  2364. rawConstructor
  2365. ) {
  2366. assert(argCount > 0);
  2367. var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
  2368. invoker = embind__requireFunction(invokerSignature, invoker);
  2369. var args = [rawConstructor];
  2370. var destructors = [];
  2371. whenDependentTypesAreResolved([], [rawClassType], function(classType) {
  2372. classType = classType[0];
  2373. var humanName = 'constructor ' + classType.name;
  2374. if (undefined === classType.registeredClass.constructor_body) {
  2375. classType.registeredClass.constructor_body = [];
  2376. }
  2377. if (undefined !== classType.registeredClass.constructor_body[argCount - 1]) {
  2378. 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!");
  2379. }
  2380. classType.registeredClass.constructor_body[argCount - 1] = function unboundTypeHandler() {
  2381. throwUnboundTypeError('Cannot construct ' + classType.name + ' due to unbound types', rawArgTypes);
  2382. };
  2383. whenDependentTypesAreResolved([], rawArgTypes, function(argTypes) {
  2384. // Insert empty slot for context type (argTypes[1]).
  2385. argTypes.splice(1, 0, null);
  2386. classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor);
  2387. return [];
  2388. });
  2389. return [];
  2390. });
  2391. }
  2392. function new_(constructor, argumentList) {
  2393. if (!(constructor instanceof Function)) {
  2394. throw new TypeError('new_ called with constructor type ' + typeof(constructor) + " which is not a function");
  2395. }
  2396. /*
  2397. * Previously, the following line was just:
  2398. function dummy() {};
  2399. * Unfortunately, Chrome was preserving 'dummy' as the object's name, even though at creation, the 'dummy' has the
  2400. * correct constructor name. Thus, objects created with IMVU.new would show up in the debugger as 'dummy', which
  2401. * isn't very helpful. Using IMVU.createNamedFunction addresses the issue. Doublely-unfortunately, there's no way
  2402. * to write a test for this behavior. -NRD 2013.02.22
  2403. */
  2404. var dummy = createNamedFunction(constructor.name || 'unknownFunctionName', function(){});
  2405. dummy.prototype = constructor.prototype;
  2406. var obj = new dummy;
  2407. var r = constructor.apply(obj, argumentList);
  2408. return (r instanceof Object) ? r : obj;
  2409. }
  2410. function runAndAbortIfError(func) {
  2411. try {
  2412. return func();
  2413. } catch (e) {
  2414. abort(e);
  2415. }
  2416. }
  2417. function callUserCallback(func, synchronous) {
  2418. if (runtimeExited || ABORT) {
  2419. return;
  2420. }
  2421. // For synchronous calls, let any exceptions propagate, and don't let the runtime exit.
  2422. if (synchronous) {
  2423. func();
  2424. return;
  2425. }
  2426. try {
  2427. func();
  2428. } catch (e) {
  2429. handleException(e);
  2430. }
  2431. }
  2432. function runtimeKeepalivePush() {
  2433. runtimeKeepaliveCounter += 1;
  2434. }
  2435. function runtimeKeepalivePop() {
  2436. runtimeKeepaliveCounter -= 1;
  2437. }
  2438. 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) {
  2439. var id = Asyncify.callStackNameToId[funcName];
  2440. if (id === undefined) {
  2441. id = Asyncify.callStackId++;
  2442. Asyncify.callStackNameToId[funcName] = id;
  2443. Asyncify.callStackIdToName[id] = funcName;
  2444. }
  2445. return id;
  2446. },instrumentWasmExports:function(exports) {
  2447. var ret = {};
  2448. for (var x in exports) {
  2449. (function(x) {
  2450. var original = exports[x];
  2451. if (typeof original === 'function') {
  2452. ret[x] = function() {
  2453. Asyncify.exportCallStack.push(x);
  2454. try {
  2455. return original.apply(null, arguments);
  2456. } finally {
  2457. if (!ABORT) {
  2458. var y = Asyncify.exportCallStack.pop();
  2459. assert(y === x);
  2460. Asyncify.maybeStopUnwind();
  2461. }
  2462. }
  2463. };
  2464. } else {
  2465. ret[x] = original;
  2466. }
  2467. })(x);
  2468. }
  2469. return ret;
  2470. },maybeStopUnwind:function() {
  2471. if (Asyncify.currData &&
  2472. Asyncify.state === Asyncify.State.Unwinding &&
  2473. Asyncify.exportCallStack.length === 0) {
  2474. // We just finished unwinding.
  2475. Asyncify.state = Asyncify.State.Normal;
  2476. // Keep the runtime alive so that a re-wind can be done later.
  2477. runAndAbortIfError(Module['_asyncify_stop_unwind']);
  2478. if (typeof Fibers !== 'undefined') {
  2479. Fibers.trampoline();
  2480. }
  2481. }
  2482. },whenDone:function() {
  2483. return new Promise(function(resolve, reject) {
  2484. Asyncify.asyncPromiseHandlers = {
  2485. resolve: resolve,
  2486. reject: reject
  2487. };
  2488. });
  2489. },allocateData:function() {
  2490. // An asyncify data structure has three fields:
  2491. // 0 current stack pos
  2492. // 4 max stack pos
  2493. // 8 id of function at bottom of the call stack (callStackIdToName[id] == name of js function)
  2494. //
  2495. // The Asyncify ABI only interprets the first two fields, the rest is for the runtime.
  2496. // We also embed a stack in the same memory region here, right next to the structure.
  2497. // This struct is also defined as asyncify_data_t in emscripten/fiber.h
  2498. var ptr = _malloc(12 + Asyncify.StackSize);
  2499. Asyncify.setDataHeader(ptr, ptr + 12, Asyncify.StackSize);
  2500. Asyncify.setDataRewindFunc(ptr);
  2501. return ptr;
  2502. },setDataHeader:function(ptr, stack, stackSize) {
  2503. HEAP32[((ptr)>>2)] = stack;
  2504. HEAP32[(((ptr)+(4))>>2)] = stack + stackSize;
  2505. },setDataRewindFunc:function(ptr) {
  2506. var bottomOfCallStack = Asyncify.exportCallStack[0];
  2507. var rewindId = Asyncify.getCallStackId(bottomOfCallStack);
  2508. HEAP32[(((ptr)+(8))>>2)] = rewindId;
  2509. },getDataRewindFunc:function(ptr) {
  2510. var id = HEAP32[(((ptr)+(8))>>2)];
  2511. var name = Asyncify.callStackIdToName[id];
  2512. var func = Module['asm'][name];
  2513. return func;
  2514. },doRewind:function(ptr) {
  2515. var start = Asyncify.getDataRewindFunc(ptr);
  2516. // Once we have rewound and the stack we no longer need to artificially keep
  2517. // the runtime alive.
  2518. return start();
  2519. },handleSleep:function(startAsync) {
  2520. if (ABORT) return;
  2521. if (Asyncify.state === Asyncify.State.Normal) {
  2522. // Prepare to sleep. Call startAsync, and see what happens:
  2523. // if the code decided to call our callback synchronously,
  2524. // then no async operation was in fact begun, and we don't
  2525. // need to do anything.
  2526. var reachedCallback = false;
  2527. var reachedAfterCallback = false;
  2528. startAsync(function(handleSleepReturnValue) {
  2529. if (ABORT) return;
  2530. Asyncify.handleSleepReturnValue = handleSleepReturnValue || 0;
  2531. reachedCallback = true;
  2532. if (!reachedAfterCallback) {
  2533. // We are happening synchronously, so no need for async.
  2534. return;
  2535. }
  2536. Asyncify.state = Asyncify.State.Rewinding;
  2537. runAndAbortIfError(function() { Module['_asyncify_start_rewind'](Asyncify.currData) });
  2538. if (typeof Browser !== 'undefined' && Browser.mainLoop.func) {
  2539. Browser.mainLoop.resume();
  2540. }
  2541. var asyncWasmReturnValue, isError = false;
  2542. try {
  2543. asyncWasmReturnValue = Asyncify.doRewind(Asyncify.currData);
  2544. } catch (err) {
  2545. asyncWasmReturnValue = err;
  2546. isError = true;
  2547. }
  2548. // Track whether the return value was handled by any promise handlers.
  2549. var handled = false;
  2550. if (!Asyncify.currData) {
  2551. // All asynchronous execution has finished.
  2552. // `asyncWasmReturnValue` now contains the final
  2553. // return value of the exported async WASM function.
  2554. //
  2555. // Note: `asyncWasmReturnValue` is distinct from
  2556. // `Asyncify.handleSleepReturnValue`.
  2557. // `Asyncify.handleSleepReturnValue` contains the return
  2558. // value of the last C function to have executed
  2559. // `Asyncify.handleSleep()`, where as `asyncWasmReturnValue`
  2560. // contains the return value of the exported WASM function
  2561. // that may have called C functions that
  2562. // call `Asyncify.handleSleep()`.
  2563. var asyncPromiseHandlers = Asyncify.asyncPromiseHandlers;
  2564. if (asyncPromiseHandlers) {
  2565. Asyncify.asyncPromiseHandlers = null;
  2566. (isError ? asyncPromiseHandlers.reject : asyncPromiseHandlers.resolve)(asyncWasmReturnValue);
  2567. handled = true;
  2568. }
  2569. }
  2570. if (isError && !handled) {
  2571. // If there was an error and it was not handled by now, we have no choice but to
  2572. // rethrow that error into the global scope where it can be caught only by
  2573. // `onerror` or `onunhandledpromiserejection`.
  2574. throw asyncWasmReturnValue;
  2575. }
  2576. });
  2577. reachedAfterCallback = true;
  2578. if (!reachedCallback) {
  2579. // A true async operation was begun; start a sleep.
  2580. Asyncify.state = Asyncify.State.Unwinding;
  2581. // TODO: reuse, don't alloc/free every sleep
  2582. Asyncify.currData = Asyncify.allocateData();
  2583. runAndAbortIfError(function() { Module['_asyncify_start_unwind'](Asyncify.currData) });
  2584. if (typeof Browser !== 'undefined' && Browser.mainLoop.func) {
  2585. Browser.mainLoop.pause();
  2586. }
  2587. }
  2588. } else if (Asyncify.state === Asyncify.State.Rewinding) {
  2589. // Stop a resume.
  2590. Asyncify.state = Asyncify.State.Normal;
  2591. runAndAbortIfError(Module['_asyncify_stop_rewind']);
  2592. _free(Asyncify.currData);
  2593. Asyncify.currData = null;
  2594. // Call all sleep callbacks now that the sleep-resume is all done.
  2595. Asyncify.sleepCallbacks.forEach(function(func) {
  2596. callUserCallback(func);
  2597. });
  2598. } else {
  2599. abort('invalid state: ' + Asyncify.state);
  2600. }
  2601. return Asyncify.handleSleepReturnValue;
  2602. },handleAsync:function(startAsync) {
  2603. return Asyncify.handleSleep(function(wakeUp) {
  2604. // TODO: add error handling as a second param when handleSleep implements it.
  2605. startAsync().then(wakeUp);
  2606. });
  2607. }};
  2608. function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc) {
  2609. // humanName: a human-readable string name for the function to be generated.
  2610. // argTypes: An array that contains the embind type objects for all types in the function signature.
  2611. // argTypes[0] is the type object for the function return value.
  2612. // argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
  2613. // argTypes[2...] are the actual function parameters.
  2614. // classType: The embind type object for the class to be bound, or null if this is not a method of a class.
  2615. // cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
  2616. // cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
  2617. var argCount = argTypes.length;
  2618. if (argCount < 2) {
  2619. throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
  2620. }
  2621. var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
  2622. // Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
  2623. // TODO: This omits argument count check - enable only at -O3 or similar.
  2624. // if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
  2625. // return FUNCTION_TABLE[fn];
  2626. // }
  2627. // Determine if we need to use a dynamic stack to store the destructors for the function parameters.
  2628. // TODO: Remove this completely once all function invokers are being dynamically generated.
  2629. var needsDestructorStack = false;
  2630. for (var i = 1; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here.
  2631. if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) { // The type does not define a destructor function - must use dynamic stack
  2632. needsDestructorStack = true;
  2633. break;
  2634. }
  2635. }
  2636. var returns = (argTypes[0].name !== "void");
  2637. var argsList = "";
  2638. var argsListWired = "";
  2639. for (var i = 0; i < argCount - 2; ++i) {
  2640. argsList += (i!==0?", ":"")+"arg"+i;
  2641. argsListWired += (i!==0?", ":"")+"arg"+i+"Wired";
  2642. }
  2643. var invokerFnBody =
  2644. "return function "+makeLegalFunctionName(humanName)+"("+argsList+") {\n" +
  2645. "if (arguments.length !== "+(argCount - 2)+") {\n" +
  2646. "throwBindingError('function "+humanName+" called with ' + arguments.length + ' arguments, expected "+(argCount - 2)+" args!');\n" +
  2647. "}\n";
  2648. if (needsDestructorStack) {
  2649. invokerFnBody +=
  2650. "var destructors = [];\n";
  2651. }
  2652. var dtorStack = needsDestructorStack ? "destructors" : "null";
  2653. var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
  2654. var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
  2655. if (isClassMethodFunc) {
  2656. invokerFnBody += "var thisWired = classParam.toWireType("+dtorStack+", this);\n";
  2657. }
  2658. for (var i = 0; i < argCount - 2; ++i) {
  2659. invokerFnBody += "var arg"+i+"Wired = argType"+i+".toWireType("+dtorStack+", arg"+i+"); // "+argTypes[i+2].name+"\n";
  2660. args1.push("argType"+i);
  2661. args2.push(argTypes[i+2]);
  2662. }
  2663. if (isClassMethodFunc) {
  2664. argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
  2665. }
  2666. invokerFnBody +=
  2667. (returns?"var rv = ":"") + "invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";
  2668. args1.push("Asyncify");
  2669. args2.push(Asyncify);
  2670. invokerFnBody += "function onDone(" + (returns ? "rv" : "") + ") {\n";
  2671. if (needsDestructorStack) {
  2672. invokerFnBody += "runDestructors(destructors);\n";
  2673. } else {
  2674. 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.
  2675. var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
  2676. if (argTypes[i].destructorFunction !== null) {
  2677. invokerFnBody += paramName+"_dtor("+paramName+"); // "+argTypes[i].name+"\n";
  2678. args1.push(paramName+"_dtor");
  2679. args2.push(argTypes[i].destructorFunction);
  2680. }
  2681. }
  2682. }
  2683. if (returns) {
  2684. invokerFnBody += "var ret = retType.fromWireType(rv);\n" +
  2685. "return ret;\n";
  2686. } else {
  2687. }
  2688. invokerFnBody += "}\n";
  2689. invokerFnBody += "return Asyncify.currData ? Asyncify.whenDone().then(onDone) : onDone(" + (returns ? "rv" : "") +");\n"
  2690. invokerFnBody += "}\n";
  2691. args1.push(invokerFnBody);
  2692. var invokerFunction = new_(Function, args1).apply(null, args2);
  2693. return invokerFunction;
  2694. }
  2695. function __embind_register_class_function(
  2696. rawClassType,
  2697. methodName,
  2698. argCount,
  2699. rawArgTypesAddr, // [ReturnType, ThisType, Args...]
  2700. invokerSignature,
  2701. rawInvoker,
  2702. context,
  2703. isPureVirtual
  2704. ) {
  2705. var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
  2706. methodName = readLatin1String(methodName);
  2707. rawInvoker = embind__requireFunction(invokerSignature, rawInvoker);
  2708. whenDependentTypesAreResolved([], [rawClassType], function(classType) {
  2709. classType = classType[0];
  2710. var humanName = classType.name + '.' + methodName;
  2711. if (methodName.startsWith("@@")) {
  2712. methodName = Symbol[methodName.substring(2)];
  2713. }
  2714. if (isPureVirtual) {
  2715. classType.registeredClass.pureVirtualFunctions.push(methodName);
  2716. }
  2717. function unboundTypesHandler() {
  2718. throwUnboundTypeError('Cannot call ' + humanName + ' due to unbound types', rawArgTypes);
  2719. }
  2720. var proto = classType.registeredClass.instancePrototype;
  2721. var method = proto[methodName];
  2722. if (undefined === method || (undefined === method.overloadTable && method.className !== classType.name && method.argCount === argCount - 2)) {
  2723. // 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.
  2724. unboundTypesHandler.argCount = argCount - 2;
  2725. unboundTypesHandler.className = classType.name;
  2726. proto[methodName] = unboundTypesHandler;
  2727. } else {
  2728. // There was an existing function with the same name registered. Set up a function overload routing table.
  2729. ensureOverloadTable(proto, methodName, humanName);
  2730. proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler;
  2731. }
  2732. whenDependentTypesAreResolved([], rawArgTypes, function(argTypes) {
  2733. var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context);
  2734. // Replace the initial unbound-handler-stub function with the appropriate member function, now that all types
  2735. // are resolved. If multiple overloads are registered for this function, the function goes into an overload table.
  2736. if (undefined === proto[methodName].overloadTable) {
  2737. // Set argCount in case an overload is registered later
  2738. memberFunction.argCount = argCount - 2;
  2739. proto[methodName] = memberFunction;
  2740. } else {
  2741. proto[methodName].overloadTable[argCount - 2] = memberFunction;
  2742. }
  2743. return [];
  2744. });
  2745. return [];
  2746. });
  2747. }
  2748. var emval_free_list = [];
  2749. var emval_handle_array = [{},{value:undefined},{value:null},{value:true},{value:false}];
  2750. function __emval_decref(handle) {
  2751. if (handle > 4 && 0 === --emval_handle_array[handle].refcount) {
  2752. emval_handle_array[handle] = undefined;
  2753. emval_free_list.push(handle);
  2754. }
  2755. }
  2756. function count_emval_handles() {
  2757. var count = 0;
  2758. for (var i = 5; i < emval_handle_array.length; ++i) {
  2759. if (emval_handle_array[i] !== undefined) {
  2760. ++count;
  2761. }
  2762. }
  2763. return count;
  2764. }
  2765. function get_first_emval() {
  2766. for (var i = 5; i < emval_handle_array.length; ++i) {
  2767. if (emval_handle_array[i] !== undefined) {
  2768. return emval_handle_array[i];
  2769. }
  2770. }
  2771. return null;
  2772. }
  2773. function init_emval() {
  2774. Module['count_emval_handles'] = count_emval_handles;
  2775. Module['get_first_emval'] = get_first_emval;
  2776. }
  2777. var Emval = {toValue:function(handle) {
  2778. if (!handle) {
  2779. throwBindingError('Cannot use deleted val. handle = ' + handle);
  2780. }
  2781. return emval_handle_array[handle].value;
  2782. },toHandle:function(value) {
  2783. switch (value) {
  2784. case undefined :{ return 1; }
  2785. case null :{ return 2; }
  2786. case true :{ return 3; }
  2787. case false :{ return 4; }
  2788. default:{
  2789. var handle = emval_free_list.length ?
  2790. emval_free_list.pop() :
  2791. emval_handle_array.length;
  2792. emval_handle_array[handle] = {refcount: 1, value: value};
  2793. return handle;
  2794. }
  2795. }
  2796. }};
  2797. function __embind_register_emval(rawType, name) {
  2798. name = readLatin1String(name);
  2799. registerType(rawType, {
  2800. name: name,
  2801. 'fromWireType': function(handle) {
  2802. var rv = Emval.toValue(handle);
  2803. __emval_decref(handle);
  2804. return rv;
  2805. },
  2806. 'toWireType': function(destructors, value) {
  2807. return Emval.toHandle(value);
  2808. },
  2809. 'argPackAdvance': 8,
  2810. 'readValueFromPointer': simpleReadValueFromPointer,
  2811. destructorFunction: null, // This type does not need a destructor
  2812. // TODO: do we need a deleteObject here? write a test where
  2813. // emval is passed into JS via an interface
  2814. });
  2815. }
  2816. function _embind_repr(v) {
  2817. if (v === null) {
  2818. return 'null';
  2819. }
  2820. var t = typeof v;
  2821. if (t === 'object' || t === 'array' || t === 'function') {
  2822. return v.toString();
  2823. } else {
  2824. return '' + v;
  2825. }
  2826. }
  2827. function floatReadValueFromPointer(name, shift) {
  2828. switch (shift) {
  2829. case 2: return function(pointer) {
  2830. return this['fromWireType'](HEAPF32[pointer >> 2]);
  2831. };
  2832. case 3: return function(pointer) {
  2833. return this['fromWireType'](HEAPF64[pointer >> 3]);
  2834. };
  2835. default:
  2836. throw new TypeError("Unknown float type: " + name);
  2837. }
  2838. }
  2839. function __embind_register_float(rawType, name, size) {
  2840. var shift = getShiftFromSize(size);
  2841. name = readLatin1String(name);
  2842. registerType(rawType, {
  2843. name: name,
  2844. 'fromWireType': function(value) {
  2845. return value;
  2846. },
  2847. 'toWireType': function(destructors, value) {
  2848. // The VM will perform JS to Wasm value conversion, according to the spec:
  2849. // https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
  2850. return value;
  2851. },
  2852. 'argPackAdvance': 8,
  2853. 'readValueFromPointer': floatReadValueFromPointer(name, shift),
  2854. destructorFunction: null, // This type does not need a destructor
  2855. });
  2856. }
  2857. function __embind_register_function(name, argCount, rawArgTypesAddr, signature, rawInvoker, fn) {
  2858. var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
  2859. name = readLatin1String(name);
  2860. rawInvoker = embind__requireFunction(signature, rawInvoker);
  2861. exposePublicSymbol(name, function() {
  2862. throwUnboundTypeError('Cannot call ' + name + ' due to unbound types', argTypes);
  2863. }, argCount - 1);
  2864. whenDependentTypesAreResolved([], argTypes, function(argTypes) {
  2865. var invokerArgsArray = [argTypes[0] /* return value */, null /* no class 'this'*/].concat(argTypes.slice(1) /* actual params */);
  2866. replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null /* no class 'this'*/, rawInvoker, fn), argCount - 1);
  2867. return [];
  2868. });
  2869. }
  2870. function integerReadValueFromPointer(name, shift, signed) {
  2871. // integers are quite common, so generate very specialized functions
  2872. switch (shift) {
  2873. case 0: return signed ?
  2874. function readS8FromPointer(pointer) { return HEAP8[pointer]; } :
  2875. function readU8FromPointer(pointer) { return HEAPU8[pointer]; };
  2876. case 1: return signed ?
  2877. function readS16FromPointer(pointer) { return HEAP16[pointer >> 1]; } :
  2878. function readU16FromPointer(pointer) { return HEAPU16[pointer >> 1]; };
  2879. case 2: return signed ?
  2880. function readS32FromPointer(pointer) { return HEAP32[pointer >> 2]; } :
  2881. function readU32FromPointer(pointer) { return HEAPU32[pointer >> 2]; };
  2882. default:
  2883. throw new TypeError("Unknown integer type: " + name);
  2884. }
  2885. }
  2886. function __embind_register_integer(primitiveType, name, size, minRange, maxRange) {
  2887. name = readLatin1String(name);
  2888. 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.
  2889. maxRange = 4294967295;
  2890. }
  2891. var shift = getShiftFromSize(size);
  2892. var fromWireType = function(value) {
  2893. return value;
  2894. };
  2895. if (minRange === 0) {
  2896. var bitshift = 32 - 8*size;
  2897. fromWireType = function(value) {
  2898. return (value << bitshift) >>> bitshift;
  2899. };
  2900. }
  2901. var isUnsignedType = (name.includes('unsigned'));
  2902. registerType(primitiveType, {
  2903. name: name,
  2904. 'fromWireType': fromWireType,
  2905. 'toWireType': function(destructors, value) {
  2906. // todo: Here we have an opportunity for -O3 level "unsafe" optimizations: we could
  2907. // avoid the following two if()s and assume value is of proper type.
  2908. if (typeof value !== "number" && typeof value !== "boolean") {
  2909. throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name);
  2910. }
  2911. if (value < minRange || value > maxRange) {
  2912. 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 + ']!');
  2913. }
  2914. return isUnsignedType ? (value >>> 0) : (value | 0);
  2915. },
  2916. 'argPackAdvance': 8,
  2917. 'readValueFromPointer': integerReadValueFromPointer(name, shift, minRange !== 0),
  2918. destructorFunction: null, // This type does not need a destructor
  2919. });
  2920. }
  2921. function __embind_register_memory_view(rawType, dataTypeIndex, name) {
  2922. var typeMapping = [
  2923. Int8Array,
  2924. Uint8Array,
  2925. Int16Array,
  2926. Uint16Array,
  2927. Int32Array,
  2928. Uint32Array,
  2929. Float32Array,
  2930. Float64Array,
  2931. ];
  2932. var TA = typeMapping[dataTypeIndex];
  2933. function decodeMemoryView(handle) {
  2934. handle = handle >> 2;
  2935. var heap = HEAPU32;
  2936. var size = heap[handle]; // in elements
  2937. var data = heap[handle + 1]; // byte offset into emscripten heap
  2938. return new TA(buffer, data, size);
  2939. }
  2940. name = readLatin1String(name);
  2941. registerType(rawType, {
  2942. name: name,
  2943. 'fromWireType': decodeMemoryView,
  2944. 'argPackAdvance': 8,
  2945. 'readValueFromPointer': decodeMemoryView,
  2946. }, {
  2947. ignoreDuplicateRegistrations: true,
  2948. });
  2949. }
  2950. function __embind_register_std_string(rawType, name) {
  2951. name = readLatin1String(name);
  2952. var stdStringIsUTF8
  2953. //process only std::string bindings with UTF8 support, in contrast to e.g. std::basic_string<unsigned char>
  2954. = (name === "std::string");
  2955. registerType(rawType, {
  2956. name: name,
  2957. 'fromWireType': function(value) {
  2958. var length = HEAPU32[value >> 2];
  2959. var str;
  2960. if (stdStringIsUTF8) {
  2961. var decodeStartPtr = value + 4;
  2962. // Looping here to support possible embedded '0' bytes
  2963. for (var i = 0; i <= length; ++i) {
  2964. var currentBytePtr = value + 4 + i;
  2965. if (i == length || HEAPU8[currentBytePtr] == 0) {
  2966. var maxRead = currentBytePtr - decodeStartPtr;
  2967. var stringSegment = UTF8ToString(decodeStartPtr, maxRead);
  2968. if (str === undefined) {
  2969. str = stringSegment;
  2970. } else {
  2971. str += String.fromCharCode(0);
  2972. str += stringSegment;
  2973. }
  2974. decodeStartPtr = currentBytePtr + 1;
  2975. }
  2976. }
  2977. } else {
  2978. var a = new Array(length);
  2979. for (var i = 0; i < length; ++i) {
  2980. a[i] = String.fromCharCode(HEAPU8[value + 4 + i]);
  2981. }
  2982. str = a.join('');
  2983. }
  2984. _free(value);
  2985. return str;
  2986. },
  2987. 'toWireType': function(destructors, value) {
  2988. if (value instanceof ArrayBuffer) {
  2989. value = new Uint8Array(value);
  2990. }
  2991. var getLength;
  2992. var valueIsOfTypeString = (typeof value === 'string');
  2993. if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {
  2994. throwBindingError('Cannot pass non-string to std::string');
  2995. }
  2996. if (stdStringIsUTF8 && valueIsOfTypeString) {
  2997. getLength = function() {return lengthBytesUTF8(value);};
  2998. } else {
  2999. getLength = function() {return value.length;};
  3000. }
  3001. // assumes 4-byte alignment
  3002. var length = getLength();
  3003. var ptr = _malloc(4 + length + 1);
  3004. HEAPU32[ptr >> 2] = length;
  3005. if (stdStringIsUTF8 && valueIsOfTypeString) {
  3006. stringToUTF8(value, ptr + 4, length + 1);
  3007. } else {
  3008. if (valueIsOfTypeString) {
  3009. for (var i = 0; i < length; ++i) {
  3010. var charCode = value.charCodeAt(i);
  3011. if (charCode > 255) {
  3012. _free(ptr);
  3013. throwBindingError('String has UTF-16 code units that do not fit in 8 bits');
  3014. }
  3015. HEAPU8[ptr + 4 + i] = charCode;
  3016. }
  3017. } else {
  3018. for (var i = 0; i < length; ++i) {
  3019. HEAPU8[ptr + 4 + i] = value[i];
  3020. }
  3021. }
  3022. }
  3023. if (destructors !== null) {
  3024. destructors.push(_free, ptr);
  3025. }
  3026. return ptr;
  3027. },
  3028. 'argPackAdvance': 8,
  3029. 'readValueFromPointer': simpleReadValueFromPointer,
  3030. destructorFunction: function(ptr) { _free(ptr); },
  3031. });
  3032. }
  3033. function __embind_register_std_wstring(rawType, charSize, name) {
  3034. name = readLatin1String(name);
  3035. var decodeString, encodeString, getHeap, lengthBytesUTF, shift;
  3036. if (charSize === 2) {
  3037. decodeString = UTF16ToString;
  3038. encodeString = stringToUTF16;
  3039. lengthBytesUTF = lengthBytesUTF16;
  3040. getHeap = function() { return HEAPU16; };
  3041. shift = 1;
  3042. } else if (charSize === 4) {
  3043. decodeString = UTF32ToString;
  3044. encodeString = stringToUTF32;
  3045. lengthBytesUTF = lengthBytesUTF32;
  3046. getHeap = function() { return HEAPU32; };
  3047. shift = 2;
  3048. }
  3049. registerType(rawType, {
  3050. name: name,
  3051. 'fromWireType': function(value) {
  3052. // Code mostly taken from _embind_register_std_string fromWireType
  3053. var length = HEAPU32[value >> 2];
  3054. var HEAP = getHeap();
  3055. var str;
  3056. var decodeStartPtr = value + 4;
  3057. // Looping here to support possible embedded '0' bytes
  3058. for (var i = 0; i <= length; ++i) {
  3059. var currentBytePtr = value + 4 + i * charSize;
  3060. if (i == length || HEAP[currentBytePtr >> shift] == 0) {
  3061. var maxReadBytes = currentBytePtr - decodeStartPtr;
  3062. var stringSegment = decodeString(decodeStartPtr, maxReadBytes);
  3063. if (str === undefined) {
  3064. str = stringSegment;
  3065. } else {
  3066. str += String.fromCharCode(0);
  3067. str += stringSegment;
  3068. }
  3069. decodeStartPtr = currentBytePtr + charSize;
  3070. }
  3071. }
  3072. _free(value);
  3073. return str;
  3074. },
  3075. 'toWireType': function(destructors, value) {
  3076. if (!(typeof value === 'string')) {
  3077. throwBindingError('Cannot pass non-string to C++ string type ' + name);
  3078. }
  3079. // assumes 4-byte alignment
  3080. var length = lengthBytesUTF(value);
  3081. var ptr = _malloc(4 + length + charSize);
  3082. HEAPU32[ptr >> 2] = length >> shift;
  3083. encodeString(value, ptr + 4, length + charSize);
  3084. if (destructors !== null) {
  3085. destructors.push(_free, ptr);
  3086. }
  3087. return ptr;
  3088. },
  3089. 'argPackAdvance': 8,
  3090. 'readValueFromPointer': simpleReadValueFromPointer,
  3091. destructorFunction: function(ptr) { _free(ptr); },
  3092. });
  3093. }
  3094. function __embind_register_value_object(
  3095. rawType,
  3096. name,
  3097. constructorSignature,
  3098. rawConstructor,
  3099. destructorSignature,
  3100. rawDestructor
  3101. ) {
  3102. structRegistrations[rawType] = {
  3103. name: readLatin1String(name),
  3104. rawConstructor: embind__requireFunction(constructorSignature, rawConstructor),
  3105. rawDestructor: embind__requireFunction(destructorSignature, rawDestructor),
  3106. fields: [],
  3107. };
  3108. }
  3109. function __embind_register_value_object_field(
  3110. structType,
  3111. fieldName,
  3112. getterReturnType,
  3113. getterSignature,
  3114. getter,
  3115. getterContext,
  3116. setterArgumentType,
  3117. setterSignature,
  3118. setter,
  3119. setterContext
  3120. ) {
  3121. structRegistrations[structType].fields.push({
  3122. fieldName: readLatin1String(fieldName),
  3123. getterReturnType: getterReturnType,
  3124. getter: embind__requireFunction(getterSignature, getter),
  3125. getterContext: getterContext,
  3126. setterArgumentType: setterArgumentType,
  3127. setter: embind__requireFunction(setterSignature, setter),
  3128. setterContext: setterContext,
  3129. });
  3130. }
  3131. function __embind_register_void(rawType, name) {
  3132. name = readLatin1String(name);
  3133. registerType(rawType, {
  3134. isVoid: true, // void return values can be optimized out sometimes
  3135. name: name,
  3136. 'argPackAdvance': 0,
  3137. 'fromWireType': function() {
  3138. return undefined;
  3139. },
  3140. 'toWireType': function(destructors, o) {
  3141. // TODO: assert if anything else is given?
  3142. return undefined;
  3143. },
  3144. });
  3145. }
  3146. function _abort() {
  3147. abort('');
  3148. }
  3149. function _clock() {
  3150. if (_clock.start === undefined) _clock.start = Date.now();
  3151. return ((Date.now() - _clock.start) * (1000000 / 1000))|0;
  3152. }
  3153. var _emscripten_get_now;if (typeof performance !== 'undefined' && performance.now) {
  3154. _emscripten_get_now = function() { return performance.now(); }
  3155. } else {
  3156. _emscripten_get_now = Date.now;
  3157. }
  3158. var _emscripten_get_now_is_monotonic =
  3159. ((typeof performance === 'object' && performance && typeof performance['now'] === 'function')
  3160. );;
  3161. function _clock_gettime(clk_id, tp) {
  3162. // int clock_gettime(clockid_t clk_id, struct timespec *tp);
  3163. var now;
  3164. if (clk_id === 0) {
  3165. now = Date.now();
  3166. } else if ((clk_id === 1 || clk_id === 4) && _emscripten_get_now_is_monotonic) {
  3167. now = _emscripten_get_now();
  3168. } else {
  3169. setErrNo(28);
  3170. return -1;
  3171. }
  3172. HEAP32[((tp)>>2)] = (now/1000)|0; // seconds
  3173. HEAP32[(((tp)+(4))>>2)] = ((now % 1000)*1000*1000)|0; // nanoseconds
  3174. return 0;
  3175. }
  3176. var readAsmConstArgsArray = [];
  3177. function readAsmConstArgs(sigPtr, buf) {
  3178. ;
  3179. readAsmConstArgsArray.length = 0;
  3180. var ch;
  3181. // Most arguments are i32s, so shift the buffer pointer so it is a plain
  3182. // index into HEAP32.
  3183. buf >>= 2;
  3184. while (ch = HEAPU8[sigPtr++]) {
  3185. // A double takes two 32-bit slots, and must also be aligned - the backend
  3186. // will emit padding to avoid that.
  3187. var readAsmConstArgsDouble = ch < 105;
  3188. if (readAsmConstArgsDouble && (buf & 1)) buf++;
  3189. readAsmConstArgsArray.push(readAsmConstArgsDouble ? HEAPF64[buf++ >> 1] : HEAP32[buf]);
  3190. ++buf;
  3191. }
  3192. return readAsmConstArgsArray;
  3193. }
  3194. function _emscripten_asm_const_int(code, sigPtr, argbuf) {
  3195. var args = readAsmConstArgs(sigPtr, argbuf);
  3196. return ASM_CONSTS[code].apply(null, args);
  3197. }
  3198. var _emscripten_memcpy_big = Uint8Array.prototype.copyWithin
  3199. ? function(dest, src, num) { HEAPU8.copyWithin(dest, src, src + num); }
  3200. : function(dest, src, num) { HEAPU8.set(HEAPU8.subarray(src, src+num), dest); }
  3201. ;
  3202. function emscripten_realloc_buffer(size) {
  3203. try {
  3204. // round size grow request up to wasm page size (fixed 64KB per spec)
  3205. wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16); // .grow() takes a delta compared to the previous size
  3206. updateGlobalBufferAndViews(wasmMemory.buffer);
  3207. return 1 /*success*/;
  3208. } catch(e) {
  3209. }
  3210. // implicit 0 return to save code size (caller will cast "undefined" into 0
  3211. // anyhow)
  3212. }
  3213. function _emscripten_resize_heap(requestedSize) {
  3214. var oldSize = HEAPU8.length;
  3215. requestedSize = requestedSize >>> 0;
  3216. // With pthreads, races can happen (another thread might increase the size in between), so return a failure, and let the caller retry.
  3217. // Memory resize rules:
  3218. // 1. Always increase heap size to at least the requested size, rounded up to next page multiple.
  3219. // 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap geometrically: increase the heap size according to
  3220. // MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%),
  3221. // At most overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB).
  3222. // 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap linearly: increase the heap size by at least MEMORY_GROWTH_LINEAR_STEP bytes.
  3223. // 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
  3224. // 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.
  3225. // Hence if an allocation fails, cut down on the amount of excess growth, in an attempt to succeed to perform a smaller allocation.
  3226. // A limit is set for how much we can grow. We should not exceed that
  3227. // (the wasm binary specifies it, so if we tried, we'd fail anyhow).
  3228. // 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
  3229. // 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
  3230. // 0 specially.
  3231. var maxHeapSize = MAX_HEAP_SIZE;
  3232. if (requestedSize > maxHeapSize) {
  3233. return false;
  3234. }
  3235. // Loop through potential heap size increases. If we attempt a too eager reservation that fails, cut down on the
  3236. // attempted size and reserve a smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
  3237. for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
  3238. var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); // ensure geometric growth
  3239. // but limit overreserving (default to capping at +96MB overgrowth at most)
  3240. overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296 );
  3241. var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
  3242. var replacement = emscripten_realloc_buffer(newSize);
  3243. if (replacement) {
  3244. return true;
  3245. }
  3246. }
  3247. return false;
  3248. }
  3249. var ENV = {};
  3250. function getExecutableName() {
  3251. return thisProgram || './this.program';
  3252. }
  3253. function getEnvStrings() {
  3254. if (!getEnvStrings.strings) {
  3255. // Default values.
  3256. // Browser language detection #8751
  3257. var lang = ((typeof navigator === 'object' && navigator.languages && navigator.languages[0]) || 'C').replace('-', '_') + '.UTF-8';
  3258. var env = {
  3259. 'USER': 'web_user',
  3260. 'LOGNAME': 'web_user',
  3261. 'PATH': '/',
  3262. 'PWD': '/',
  3263. 'HOME': '/home/web_user',
  3264. 'LANG': lang,
  3265. '_': getExecutableName()
  3266. };
  3267. // Apply the user-provided values, if any.
  3268. for (var x in ENV) {
  3269. // x is a key in ENV; if ENV[x] is undefined, that means it was
  3270. // explicitly set to be so. We allow user code to do that to
  3271. // force variables with default values to remain unset.
  3272. if (ENV[x] === undefined) delete env[x];
  3273. else env[x] = ENV[x];
  3274. }
  3275. var strings = [];
  3276. for (var x in env) {
  3277. strings.push(x + '=' + env[x]);
  3278. }
  3279. getEnvStrings.strings = strings;
  3280. }
  3281. return getEnvStrings.strings;
  3282. }
  3283. function _environ_get(__environ, environ_buf) {
  3284. var bufSize = 0;
  3285. getEnvStrings().forEach(function(string, i) {
  3286. var ptr = environ_buf + bufSize;
  3287. HEAP32[(((__environ)+(i * 4))>>2)] = ptr;
  3288. writeAsciiToMemory(string, ptr);
  3289. bufSize += string.length + 1;
  3290. });
  3291. return 0;
  3292. }
  3293. function _environ_sizes_get(penviron_count, penviron_buf_size) {
  3294. var strings = getEnvStrings();
  3295. HEAP32[((penviron_count)>>2)] = strings.length;
  3296. var bufSize = 0;
  3297. strings.forEach(function(string) {
  3298. bufSize += string.length + 1;
  3299. });
  3300. HEAP32[((penviron_buf_size)>>2)] = bufSize;
  3301. return 0;
  3302. }
  3303. function _exit(status) {
  3304. // void _exit(int status);
  3305. // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html
  3306. exit(status);
  3307. }
  3308. function _fd_close(fd) {
  3309. return 0;
  3310. }
  3311. function _fd_fdstat_get(fd, pbuf) {
  3312. // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
  3313. var type = fd == 1 || fd == 2 ? 2 : abort();
  3314. HEAP8[((pbuf)>>0)] = type;
  3315. // TODO HEAP16[(((pbuf)+(2))>>1)] = ?;
  3316. // 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]);
  3317. // 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]);
  3318. return 0;
  3319. }
  3320. function _fd_read(fd, iov, iovcnt, pnum) {
  3321. var stream = SYSCALLS.getStreamFromFD(fd);
  3322. var num = SYSCALLS.doReadv(stream, iov, iovcnt);
  3323. HEAP32[((pnum)>>2)] = num;
  3324. return 0;
  3325. }
  3326. function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {
  3327. }
  3328. function flush_NO_FILESYSTEM() {
  3329. // flush anything remaining in the buffers during shutdown
  3330. if (typeof _fflush !== 'undefined') _fflush(0);
  3331. var buffers = SYSCALLS.buffers;
  3332. if (buffers[1].length) SYSCALLS.printChar(1, 10);
  3333. if (buffers[2].length) SYSCALLS.printChar(2, 10);
  3334. }
  3335. function _fd_write(fd, iov, iovcnt, pnum) {
  3336. ;
  3337. // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
  3338. var num = 0;
  3339. for (var i = 0; i < iovcnt; i++) {
  3340. var ptr = HEAP32[((iov)>>2)];
  3341. var len = HEAP32[(((iov)+(4))>>2)];
  3342. iov += 8;
  3343. for (var j = 0; j < len; j++) {
  3344. SYSCALLS.printChar(fd, HEAPU8[ptr+j]);
  3345. }
  3346. num += len;
  3347. }
  3348. HEAP32[((pnum)>>2)] = num;
  3349. return 0;
  3350. }
  3351. function _gettimeofday(ptr) {
  3352. var now = Date.now();
  3353. HEAP32[((ptr)>>2)] = (now/1000)|0; // seconds
  3354. HEAP32[(((ptr)+(4))>>2)] = ((now % 1000)*1000)|0; // microseconds
  3355. return 0;
  3356. }
  3357. function _mktime(tmPtr) {
  3358. _tzset();
  3359. var date = new Date(HEAP32[(((tmPtr)+(20))>>2)] + 1900,
  3360. HEAP32[(((tmPtr)+(16))>>2)],
  3361. HEAP32[(((tmPtr)+(12))>>2)],
  3362. HEAP32[(((tmPtr)+(8))>>2)],
  3363. HEAP32[(((tmPtr)+(4))>>2)],
  3364. HEAP32[((tmPtr)>>2)],
  3365. 0);
  3366. // There's an ambiguous hour when the time goes back; the tm_isdst field is
  3367. // used to disambiguate it. Date() basically guesses, so we fix it up if it
  3368. // guessed wrong, or fill in tm_isdst with the guess if it's -1.
  3369. var dst = HEAP32[(((tmPtr)+(32))>>2)];
  3370. var guessedOffset = date.getTimezoneOffset();
  3371. var start = new Date(date.getFullYear(), 0, 1);
  3372. var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
  3373. var winterOffset = start.getTimezoneOffset();
  3374. var dstOffset = Math.min(winterOffset, summerOffset); // DST is in December in South
  3375. if (dst < 0) {
  3376. // Attention: some regions don't have DST at all.
  3377. HEAP32[(((tmPtr)+(32))>>2)] = Number(summerOffset != winterOffset && dstOffset == guessedOffset);
  3378. } else if ((dst > 0) != (dstOffset == guessedOffset)) {
  3379. var nonDstOffset = Math.max(winterOffset, summerOffset);
  3380. var trueOffset = dst > 0 ? dstOffset : nonDstOffset;
  3381. // Don't try setMinutes(date.getMinutes() + ...) -- it's messed up.
  3382. date.setTime(date.getTime() + (trueOffset - guessedOffset)*60000);
  3383. }
  3384. HEAP32[(((tmPtr)+(24))>>2)] = date.getDay();
  3385. var yday = ((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))|0;
  3386. HEAP32[(((tmPtr)+(28))>>2)] = yday;
  3387. // To match expected behavior, update fields from date
  3388. HEAP32[((tmPtr)>>2)] = date.getSeconds();
  3389. HEAP32[(((tmPtr)+(4))>>2)] = date.getMinutes();
  3390. HEAP32[(((tmPtr)+(8))>>2)] = date.getHours();
  3391. HEAP32[(((tmPtr)+(12))>>2)] = date.getDate();
  3392. HEAP32[(((tmPtr)+(16))>>2)] = date.getMonth();
  3393. return (date.getTime() / 1000)|0;
  3394. }
  3395. function _setTempRet0(val) {
  3396. setTempRet0(val);
  3397. }
  3398. function __isLeapYear(year) {
  3399. return year%4 === 0 && (year%100 !== 0 || year%400 === 0);
  3400. }
  3401. function __arraySum(array, index) {
  3402. var sum = 0;
  3403. for (var i = 0; i <= index; sum += array[i++]) {
  3404. // no-op
  3405. }
  3406. return sum;
  3407. }
  3408. var __MONTH_DAYS_LEAP = [31,29,31,30,31,30,31,31,30,31,30,31];
  3409. var __MONTH_DAYS_REGULAR = [31,28,31,30,31,30,31,31,30,31,30,31];
  3410. function __addDays(date, days) {
  3411. var newDate = new Date(date.getTime());
  3412. while (days > 0) {
  3413. var leap = __isLeapYear(newDate.getFullYear());
  3414. var currentMonth = newDate.getMonth();
  3415. var daysInCurrentMonth = (leap ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR)[currentMonth];
  3416. if (days > daysInCurrentMonth-newDate.getDate()) {
  3417. // we spill over to next month
  3418. days -= (daysInCurrentMonth-newDate.getDate()+1);
  3419. newDate.setDate(1);
  3420. if (currentMonth < 11) {
  3421. newDate.setMonth(currentMonth+1)
  3422. } else {
  3423. newDate.setMonth(0);
  3424. newDate.setFullYear(newDate.getFullYear()+1);
  3425. }
  3426. } else {
  3427. // we stay in current month
  3428. newDate.setDate(newDate.getDate()+days);
  3429. return newDate;
  3430. }
  3431. }
  3432. return newDate;
  3433. }
  3434. function _strftime(s, maxsize, format, tm) {
  3435. // size_t strftime(char *restrict s, size_t maxsize, const char *restrict format, const struct tm *restrict timeptr);
  3436. // http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html
  3437. var tm_zone = HEAP32[(((tm)+(40))>>2)];
  3438. var date = {
  3439. tm_sec: HEAP32[((tm)>>2)],
  3440. tm_min: HEAP32[(((tm)+(4))>>2)],
  3441. tm_hour: HEAP32[(((tm)+(8))>>2)],
  3442. tm_mday: HEAP32[(((tm)+(12))>>2)],
  3443. tm_mon: HEAP32[(((tm)+(16))>>2)],
  3444. tm_year: HEAP32[(((tm)+(20))>>2)],
  3445. tm_wday: HEAP32[(((tm)+(24))>>2)],
  3446. tm_yday: HEAP32[(((tm)+(28))>>2)],
  3447. tm_isdst: HEAP32[(((tm)+(32))>>2)],
  3448. tm_gmtoff: HEAP32[(((tm)+(36))>>2)],
  3449. tm_zone: tm_zone ? UTF8ToString(tm_zone) : ''
  3450. };
  3451. var pattern = UTF8ToString(format);
  3452. // expand format
  3453. var EXPANSION_RULES_1 = {
  3454. '%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
  3455. '%D': '%m/%d/%y', // Equivalent to %m / %d / %y
  3456. '%F': '%Y-%m-%d', // Equivalent to %Y - %m - %d
  3457. '%h': '%b', // Equivalent to %b
  3458. '%r': '%I:%M:%S %p', // Replaced by the time in a.m. and p.m. notation
  3459. '%R': '%H:%M', // Replaced by the time in 24-hour notation
  3460. '%T': '%H:%M:%S', // Replaced by the time
  3461. '%x': '%m/%d/%y', // Replaced by the locale's appropriate date representation
  3462. '%X': '%H:%M:%S', // Replaced by the locale's appropriate time representation
  3463. // Modified Conversion Specifiers
  3464. '%Ec': '%c', // Replaced by the locale's alternative appropriate date and time representation.
  3465. '%EC': '%C', // Replaced by the name of the base year (period) in the locale's alternative representation.
  3466. '%Ex': '%m/%d/%y', // Replaced by the locale's alternative date representation.
  3467. '%EX': '%H:%M:%S', // Replaced by the locale's alternative time representation.
  3468. '%Ey': '%y', // Replaced by the offset from %EC (year only) in the locale's alternative representation.
  3469. '%EY': '%Y', // Replaced by the full alternative year representation.
  3470. '%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.
  3471. '%Oe': '%e', // Replaced by the day of the month, using the locale's alternative numeric symbols, filled as needed with leading <space> characters.
  3472. '%OH': '%H', // Replaced by the hour (24-hour clock) using the locale's alternative numeric symbols.
  3473. '%OI': '%I', // Replaced by the hour (12-hour clock) using the locale's alternative numeric symbols.
  3474. '%Om': '%m', // Replaced by the month using the locale's alternative numeric symbols.
  3475. '%OM': '%M', // Replaced by the minutes using the locale's alternative numeric symbols.
  3476. '%OS': '%S', // Replaced by the seconds using the locale's alternative numeric symbols.
  3477. '%Ou': '%u', // Replaced by the weekday as a number in the locale's alternative representation (Monday=1).
  3478. '%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.
  3479. '%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.
  3480. '%Ow': '%w', // Replaced by the number of the weekday (Sunday=0) using the locale's alternative numeric symbols.
  3481. '%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.
  3482. '%Oy': '%y', // Replaced by the year (offset from %C ) using the locale's alternative numeric symbols.
  3483. };
  3484. for (var rule in EXPANSION_RULES_1) {
  3485. pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_1[rule]);
  3486. }
  3487. var WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
  3488. var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
  3489. function leadingSomething(value, digits, character) {
  3490. var str = typeof value === 'number' ? value.toString() : (value || '');
  3491. while (str.length < digits) {
  3492. str = character[0]+str;
  3493. }
  3494. return str;
  3495. }
  3496. function leadingNulls(value, digits) {
  3497. return leadingSomething(value, digits, '0');
  3498. }
  3499. function compareByDay(date1, date2) {
  3500. function sgn(value) {
  3501. return value < 0 ? -1 : (value > 0 ? 1 : 0);
  3502. }
  3503. var compare;
  3504. if ((compare = sgn(date1.getFullYear()-date2.getFullYear())) === 0) {
  3505. if ((compare = sgn(date1.getMonth()-date2.getMonth())) === 0) {
  3506. compare = sgn(date1.getDate()-date2.getDate());
  3507. }
  3508. }
  3509. return compare;
  3510. }
  3511. function getFirstWeekStartDate(janFourth) {
  3512. switch (janFourth.getDay()) {
  3513. case 0: // Sunday
  3514. return new Date(janFourth.getFullYear()-1, 11, 29);
  3515. case 1: // Monday
  3516. return janFourth;
  3517. case 2: // Tuesday
  3518. return new Date(janFourth.getFullYear(), 0, 3);
  3519. case 3: // Wednesday
  3520. return new Date(janFourth.getFullYear(), 0, 2);
  3521. case 4: // Thursday
  3522. return new Date(janFourth.getFullYear(), 0, 1);
  3523. case 5: // Friday
  3524. return new Date(janFourth.getFullYear()-1, 11, 31);
  3525. case 6: // Saturday
  3526. return new Date(janFourth.getFullYear()-1, 11, 30);
  3527. }
  3528. }
  3529. function getWeekBasedYear(date) {
  3530. var thisDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);
  3531. var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4);
  3532. var janFourthNextYear = new Date(thisDate.getFullYear()+1, 0, 4);
  3533. var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);
  3534. var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);
  3535. if (compareByDay(firstWeekStartThisYear, thisDate) <= 0) {
  3536. // this date is after the start of the first week of this year
  3537. if (compareByDay(firstWeekStartNextYear, thisDate) <= 0) {
  3538. return thisDate.getFullYear()+1;
  3539. } else {
  3540. return thisDate.getFullYear();
  3541. }
  3542. } else {
  3543. return thisDate.getFullYear()-1;
  3544. }
  3545. }
  3546. var EXPANSION_RULES_2 = {
  3547. '%a': function(date) {
  3548. return WEEKDAYS[date.tm_wday].substring(0,3);
  3549. },
  3550. '%A': function(date) {
  3551. return WEEKDAYS[date.tm_wday];
  3552. },
  3553. '%b': function(date) {
  3554. return MONTHS[date.tm_mon].substring(0,3);
  3555. },
  3556. '%B': function(date) {
  3557. return MONTHS[date.tm_mon];
  3558. },
  3559. '%C': function(date) {
  3560. var year = date.tm_year+1900;
  3561. return leadingNulls((year/100)|0,2);
  3562. },
  3563. '%d': function(date) {
  3564. return leadingNulls(date.tm_mday, 2);
  3565. },
  3566. '%e': function(date) {
  3567. return leadingSomething(date.tm_mday, 2, ' ');
  3568. },
  3569. '%g': function(date) {
  3570. // %g, %G, and %V give values according to the ISO 8601:2000 standard week-based year.
  3571. // In this system, weeks begin on a Monday and week 1 of the year is the week that includes
  3572. // January 4th, which is also the week that includes the first Thursday of the year, and
  3573. // is also the first week that contains at least four days in the year.
  3574. // If the first Monday of January is the 2nd, 3rd, or 4th, the preceding days are part of
  3575. // the last week of the preceding year; thus, for Saturday 2nd January 1999,
  3576. // %G is replaced by 1998 and %V is replaced by 53. If December 29th, 30th,
  3577. // or 31st is a Monday, it and any following days are part of week 1 of the following year.
  3578. // Thus, for Tuesday 30th December 1997, %G is replaced by 1998 and %V is replaced by 01.
  3579. return getWeekBasedYear(date).toString().substring(2);
  3580. },
  3581. '%G': function(date) {
  3582. return getWeekBasedYear(date);
  3583. },
  3584. '%H': function(date) {
  3585. return leadingNulls(date.tm_hour, 2);
  3586. },
  3587. '%I': function(date) {
  3588. var twelveHour = date.tm_hour;
  3589. if (twelveHour == 0) twelveHour = 12;
  3590. else if (twelveHour > 12) twelveHour -= 12;
  3591. return leadingNulls(twelveHour, 2);
  3592. },
  3593. '%j': function(date) {
  3594. // Day of the year (001-366)
  3595. return leadingNulls(date.tm_mday+__arraySum(__isLeapYear(date.tm_year+1900) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, date.tm_mon-1), 3);
  3596. },
  3597. '%m': function(date) {
  3598. return leadingNulls(date.tm_mon+1, 2);
  3599. },
  3600. '%M': function(date) {
  3601. return leadingNulls(date.tm_min, 2);
  3602. },
  3603. '%n': function() {
  3604. return '\n';
  3605. },
  3606. '%p': function(date) {
  3607. if (date.tm_hour >= 0 && date.tm_hour < 12) {
  3608. return 'AM';
  3609. } else {
  3610. return 'PM';
  3611. }
  3612. },
  3613. '%S': function(date) {
  3614. return leadingNulls(date.tm_sec, 2);
  3615. },
  3616. '%t': function() {
  3617. return '\t';
  3618. },
  3619. '%u': function(date) {
  3620. return date.tm_wday || 7;
  3621. },
  3622. '%U': function(date) {
  3623. // Replaced by the week number of the year as a decimal number [00,53].
  3624. // The first Sunday of January is the first day of week 1;
  3625. // days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday]
  3626. var janFirst = new Date(date.tm_year+1900, 0, 1);
  3627. var firstSunday = janFirst.getDay() === 0 ? janFirst : __addDays(janFirst, 7-janFirst.getDay());
  3628. var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);
  3629. // is target date after the first Sunday?
  3630. if (compareByDay(firstSunday, endDate) < 0) {
  3631. // calculate difference in days between first Sunday and endDate
  3632. var februaryFirstUntilEndMonth = __arraySum(__isLeapYear(endDate.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, endDate.getMonth()-1)-31;
  3633. var firstSundayUntilEndJanuary = 31-firstSunday.getDate();
  3634. var days = firstSundayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();
  3635. return leadingNulls(Math.ceil(days/7), 2);
  3636. }
  3637. return compareByDay(firstSunday, janFirst) === 0 ? '01': '00';
  3638. },
  3639. '%V': function(date) {
  3640. // Replaced by the week number of the year (Monday as the first day of the week)
  3641. // as a decimal number [01,53]. If the week containing 1 January has four
  3642. // or more days in the new year, then it is considered week 1.
  3643. // Otherwise, it is the last week of the previous year, and the next week is week 1.
  3644. // Both January 4th and the first Thursday of January are always in week 1. [ tm_year, tm_wday, tm_yday]
  3645. var janFourthThisYear = new Date(date.tm_year+1900, 0, 4);
  3646. var janFourthNextYear = new Date(date.tm_year+1901, 0, 4);
  3647. var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);
  3648. var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);
  3649. var endDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);
  3650. if (compareByDay(endDate, firstWeekStartThisYear) < 0) {
  3651. // if given date is before this years first week, then it belongs to the 53rd week of last year
  3652. return '53';
  3653. }
  3654. if (compareByDay(firstWeekStartNextYear, endDate) <= 0) {
  3655. // if given date is after next years first week, then it belongs to the 01th week of next year
  3656. return '01';
  3657. }
  3658. // given date is in between CW 01..53 of this calendar year
  3659. var daysDifference;
  3660. if (firstWeekStartThisYear.getFullYear() < date.tm_year+1900) {
  3661. // first CW of this year starts last year
  3662. daysDifference = date.tm_yday+32-firstWeekStartThisYear.getDate()
  3663. } else {
  3664. // first CW of this year starts this year
  3665. daysDifference = date.tm_yday+1-firstWeekStartThisYear.getDate();
  3666. }
  3667. return leadingNulls(Math.ceil(daysDifference/7), 2);
  3668. },
  3669. '%w': function(date) {
  3670. return date.tm_wday;
  3671. },
  3672. '%W': function(date) {
  3673. // Replaced by the week number of the year as a decimal number [00,53].
  3674. // The first Monday of January is the first day of week 1;
  3675. // days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday]
  3676. var janFirst = new Date(date.tm_year, 0, 1);
  3677. var firstMonday = janFirst.getDay() === 1 ? janFirst : __addDays(janFirst, janFirst.getDay() === 0 ? 1 : 7-janFirst.getDay()+1);
  3678. var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);
  3679. // is target date after the first Monday?
  3680. if (compareByDay(firstMonday, endDate) < 0) {
  3681. var februaryFirstUntilEndMonth = __arraySum(__isLeapYear(endDate.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, endDate.getMonth()-1)-31;
  3682. var firstMondayUntilEndJanuary = 31-firstMonday.getDate();
  3683. var days = firstMondayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();
  3684. return leadingNulls(Math.ceil(days/7), 2);
  3685. }
  3686. return compareByDay(firstMonday, janFirst) === 0 ? '01': '00';
  3687. },
  3688. '%y': function(date) {
  3689. // Replaced by the last two digits of the year as a decimal number [00,99]. [ tm_year]
  3690. return (date.tm_year+1900).toString().substring(2);
  3691. },
  3692. '%Y': function(date) {
  3693. // Replaced by the year as a decimal number (for example, 1997). [ tm_year]
  3694. return date.tm_year+1900;
  3695. },
  3696. '%z': function(date) {
  3697. // Replaced by the offset from UTC in the ISO 8601:2000 standard format ( +hhmm or -hhmm ).
  3698. // For example, "-0430" means 4 hours 30 minutes behind UTC (west of Greenwich).
  3699. var off = date.tm_gmtoff;
  3700. var ahead = off >= 0;
  3701. off = Math.abs(off) / 60;
  3702. // convert from minutes into hhmm format (which means 60 minutes = 100 units)
  3703. off = (off / 60)*100 + (off % 60);
  3704. return (ahead ? '+' : '-') + String("0000" + off).slice(-4);
  3705. },
  3706. '%Z': function(date) {
  3707. return date.tm_zone;
  3708. },
  3709. '%%': function() {
  3710. return '%';
  3711. }
  3712. };
  3713. for (var rule in EXPANSION_RULES_2) {
  3714. if (pattern.includes(rule)) {
  3715. pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_2[rule](date));
  3716. }
  3717. }
  3718. var bytes = intArrayFromString(pattern, false);
  3719. if (bytes.length > maxsize) {
  3720. return 0;
  3721. }
  3722. writeArrayToMemory(bytes, s);
  3723. return bytes.length-1;
  3724. }
  3725. function _strftime_l(s, maxsize, format, tm) {
  3726. return _strftime(s, maxsize, format, tm); // no locale support yet
  3727. }
  3728. function _time(ptr) {
  3729. ;
  3730. var ret = (Date.now()/1000)|0;
  3731. if (ptr) {
  3732. HEAP32[((ptr)>>2)] = ret;
  3733. }
  3734. return ret;
  3735. }
  3736. InternalError = Module['InternalError'] = extendError(Error, 'InternalError');;
  3737. embind_init_charCodes();
  3738. BindingError = Module['BindingError'] = extendError(Error, 'BindingError');;
  3739. init_ClassHandle();
  3740. init_RegisteredPointer();
  3741. init_embind();;
  3742. UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');;
  3743. init_emval();;
  3744. var ASSERTIONS = false;
  3745. /** @type {function(string, boolean=, number=)} */
  3746. function intArrayFromString(stringy, dontAddNull, length) {
  3747. var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
  3748. var u8array = new Array(len);
  3749. var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
  3750. if (dontAddNull) u8array.length = numBytesWritten;
  3751. return u8array;
  3752. }
  3753. function intArrayToString(array) {
  3754. var ret = [];
  3755. for (var i = 0; i < array.length; i++) {
  3756. var chr = array[i];
  3757. if (chr > 0xFF) {
  3758. if (ASSERTIONS) {
  3759. assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.');
  3760. }
  3761. chr &= 0xFF;
  3762. }
  3763. ret.push(String.fromCharCode(chr));
  3764. }
  3765. return ret.join('');
  3766. }
  3767. var asmLibraryArg = {
  3768. "__asyncjs__wasm_ffmpeg_fopen_sync": __asyncjs__wasm_ffmpeg_fopen_sync,
  3769. "__asyncjs__wasm_ffmpeg_fread_sync": __asyncjs__wasm_ffmpeg_fread_sync,
  3770. "__cxa_allocate_exception": ___cxa_allocate_exception,
  3771. "__cxa_atexit": ___cxa_atexit,
  3772. "__cxa_throw": ___cxa_throw,
  3773. "__gmtime_r": ___gmtime_r,
  3774. "__localtime_r": ___localtime_r,
  3775. "__syscall__newselect": ___syscall__newselect,
  3776. "__syscall_fcntl64": ___syscall_fcntl64,
  3777. "__syscall_ioctl": ___syscall_ioctl,
  3778. "__syscall_mkdir": ___syscall_mkdir,
  3779. "__syscall_open": ___syscall_open,
  3780. "__syscall_rmdir": ___syscall_rmdir,
  3781. "__syscall_unlink": ___syscall_unlink,
  3782. "_embind_finalize_value_object": __embind_finalize_value_object,
  3783. "_embind_register_bigint": __embind_register_bigint,
  3784. "_embind_register_bool": __embind_register_bool,
  3785. "_embind_register_class": __embind_register_class,
  3786. "_embind_register_class_constructor": __embind_register_class_constructor,
  3787. "_embind_register_class_function": __embind_register_class_function,
  3788. "_embind_register_emval": __embind_register_emval,
  3789. "_embind_register_float": __embind_register_float,
  3790. "_embind_register_function": __embind_register_function,
  3791. "_embind_register_integer": __embind_register_integer,
  3792. "_embind_register_memory_view": __embind_register_memory_view,
  3793. "_embind_register_std_string": __embind_register_std_string,
  3794. "_embind_register_std_wstring": __embind_register_std_wstring,
  3795. "_embind_register_value_object": __embind_register_value_object,
  3796. "_embind_register_value_object_field": __embind_register_value_object_field,
  3797. "_embind_register_void": __embind_register_void,
  3798. "abort": _abort,
  3799. "clock": _clock,
  3800. "clock_gettime": _clock_gettime,
  3801. "emscripten_asm_const_int": _emscripten_asm_const_int,
  3802. "emscripten_get_now": _emscripten_get_now,
  3803. "emscripten_memcpy_big": _emscripten_memcpy_big,
  3804. "emscripten_resize_heap": _emscripten_resize_heap,
  3805. "environ_get": _environ_get,
  3806. "environ_sizes_get": _environ_sizes_get,
  3807. "exit": _exit,
  3808. "fd_close": _fd_close,
  3809. "fd_fdstat_get": _fd_fdstat_get,
  3810. "fd_read": _fd_read,
  3811. "fd_seek": _fd_seek,
  3812. "fd_write": _fd_write,
  3813. "gettimeofday": _gettimeofday,
  3814. "gmtime_r": _gmtime_r,
  3815. "localtime_r": _localtime_r,
  3816. "mktime": _mktime,
  3817. "setTempRet0": _setTempRet0,
  3818. "strftime": _strftime,
  3819. "strftime_l": _strftime_l,
  3820. "time": _time
  3821. };
  3822. // var asm = createWasm();
  3823. // console.log("isaac64: ", Module["WxIsaac64"])
  3824. // console.log("Module:", Module)
  3825. /** @type {function(...*):?} */
  3826. var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function() {
  3827. return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["__wasm_call_ctors"]).apply(null, arguments);
  3828. };
  3829. /** @type {function(...*):?} */
  3830. var ___getTypeName = Module["___getTypeName"] = function() {
  3831. return (___getTypeName = Module["___getTypeName"] = Module["asm"]["__getTypeName"]).apply(null, arguments);
  3832. };
  3833. /** @type {function(...*):?} */
  3834. var ___embind_register_native_and_builtin_types = Module["___embind_register_native_and_builtin_types"] = function() {
  3835. 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);
  3836. };
  3837. /** @type {function(...*):?} */
  3838. var _free = Module["_free"] = function() {
  3839. return (_free = Module["_free"] = Module["asm"]["free"]).apply(null, arguments);
  3840. };
  3841. /** @type {function(...*):?} */
  3842. var _malloc = Module["_malloc"] = function() {
  3843. return (_malloc = Module["_malloc"] = Module["asm"]["malloc"]).apply(null, arguments);
  3844. };
  3845. /** @type {function(...*):?} */
  3846. var ___errno_location = Module["___errno_location"] = function() {
  3847. return (___errno_location = Module["___errno_location"] = Module["asm"]["__errno_location"]).apply(null, arguments);
  3848. };
  3849. /** @type {function(...*):?} */
  3850. var __get_tzname = Module["__get_tzname"] = function() {
  3851. return (__get_tzname = Module["__get_tzname"] = Module["asm"]["_get_tzname"]).apply(null, arguments);
  3852. };
  3853. /** @type {function(...*):?} */
  3854. var __get_daylight = Module["__get_daylight"] = function() {
  3855. return (__get_daylight = Module["__get_daylight"] = Module["asm"]["_get_daylight"]).apply(null, arguments);
  3856. };
  3857. /** @type {function(...*):?} */
  3858. var __get_timezone = Module["__get_timezone"] = function() {
  3859. return (__get_timezone = Module["__get_timezone"] = Module["asm"]["_get_timezone"]).apply(null, arguments);
  3860. };
  3861. /** @type {function(...*):?} */
  3862. var stackSave = Module["stackSave"] = function() {
  3863. return (stackSave = Module["stackSave"] = Module["asm"]["stackSave"]).apply(null, arguments);
  3864. };
  3865. /** @type {function(...*):?} */
  3866. var stackRestore = Module["stackRestore"] = function() {
  3867. return (stackRestore = Module["stackRestore"] = Module["asm"]["stackRestore"]).apply(null, arguments);
  3868. };
  3869. /** @type {function(...*):?} */
  3870. var stackAlloc = Module["stackAlloc"] = function() {
  3871. return (stackAlloc = Module["stackAlloc"] = Module["asm"]["stackAlloc"]).apply(null, arguments);
  3872. };
  3873. /** @type {function(...*):?} */
  3874. var _emscripten_stack_set_limits = Module["_emscripten_stack_set_limits"] = function() {
  3875. return (_emscripten_stack_set_limits = Module["_emscripten_stack_set_limits"] = Module["asm"]["emscripten_stack_set_limits"]).apply(null, arguments);
  3876. };
  3877. /** @type {function(...*):?} */
  3878. var _emscripten_stack_get_base = Module["_emscripten_stack_get_base"] = function() {
  3879. return (_emscripten_stack_get_base = Module["_emscripten_stack_get_base"] = Module["asm"]["emscripten_stack_get_base"]).apply(null, arguments);
  3880. };
  3881. /** @type {function(...*):?} */
  3882. var _emscripten_stack_get_end = Module["_emscripten_stack_get_end"] = function() {
  3883. return (_emscripten_stack_get_end = Module["_emscripten_stack_get_end"] = Module["asm"]["emscripten_stack_get_end"]).apply(null, arguments);
  3884. };
  3885. /** @type {function(...*):?} */
  3886. var _memalign = Module["_memalign"] = function() {
  3887. return (_memalign = Module["_memalign"] = Module["asm"]["memalign"]).apply(null, arguments);
  3888. };
  3889. /** @type {function(...*):?} */
  3890. var dynCall_vi = Module["dynCall_vi"] = function() {
  3891. return (dynCall_vi = Module["dynCall_vi"] = Module["asm"]["dynCall_vi"]).apply(null, arguments);
  3892. };
  3893. /** @type {function(...*):?} */
  3894. var dynCall_ii = Module["dynCall_ii"] = function() {
  3895. return (dynCall_ii = Module["dynCall_ii"] = Module["asm"]["dynCall_ii"]).apply(null, arguments);
  3896. };
  3897. /** @type {function(...*):?} */
  3898. var dynCall_viiii = Module["dynCall_viiii"] = function() {
  3899. return (dynCall_viiii = Module["dynCall_viiii"] = Module["asm"]["dynCall_viiii"]).apply(null, arguments);
  3900. };
  3901. /** @type {function(...*):?} */
  3902. var dynCall_iiii = Module["dynCall_iiii"] = function() {
  3903. return (dynCall_iiii = Module["dynCall_iiii"] = Module["asm"]["dynCall_iiii"]).apply(null, arguments);
  3904. };
  3905. /** @type {function(...*):?} */
  3906. var dynCall_iii = Module["dynCall_iii"] = function() {
  3907. return (dynCall_iii = Module["dynCall_iii"] = Module["asm"]["dynCall_iii"]).apply(null, arguments);
  3908. };
  3909. /** @type {function(...*):?} */
  3910. var dynCall_vii = Module["dynCall_vii"] = function() {
  3911. return (dynCall_vii = Module["dynCall_vii"] = Module["asm"]["dynCall_vii"]).apply(null, arguments);
  3912. };
  3913. /** @type {function(...*):?} */
  3914. var dynCall_viiiiifiii = Module["dynCall_viiiiifiii"] = function() {
  3915. return (dynCall_viiiiifiii = Module["dynCall_viiiiifiii"] = Module["asm"]["dynCall_viiiiifiii"]).apply(null, arguments);
  3916. };
  3917. /** @type {function(...*):?} */
  3918. var dynCall_i = Module["dynCall_i"] = function() {
  3919. return (dynCall_i = Module["dynCall_i"] = Module["asm"]["dynCall_i"]).apply(null, arguments);
  3920. };
  3921. /** @type {function(...*):?} */
  3922. var dynCall_viii = Module["dynCall_viii"] = function() {
  3923. return (dynCall_viii = Module["dynCall_viii"] = Module["asm"]["dynCall_viii"]).apply(null, arguments);
  3924. };
  3925. /** @type {function(...*):?} */
  3926. var dynCall_iiiiiifiii = Module["dynCall_iiiiiifiii"] = function() {
  3927. return (dynCall_iiiiiifiii = Module["dynCall_iiiiiifiii"] = Module["asm"]["dynCall_iiiiiifiii"]).apply(null, arguments);
  3928. };
  3929. /** @type {function(...*):?} */
  3930. var dynCall_v = Module["dynCall_v"] = function() {
  3931. return (dynCall_v = Module["dynCall_v"] = Module["asm"]["dynCall_v"]).apply(null, arguments);
  3932. };
  3933. /** @type {function(...*):?} */
  3934. var dynCall_iiiiii = Module["dynCall_iiiiii"] = function() {
  3935. return (dynCall_iiiiii = Module["dynCall_iiiiii"] = Module["asm"]["dynCall_iiiiii"]).apply(null, arguments);
  3936. };
  3937. /** @type {function(...*):?} */
  3938. var dynCall_iiiiiii = Module["dynCall_iiiiiii"] = function() {
  3939. return (dynCall_iiiiiii = Module["dynCall_iiiiiii"] = Module["asm"]["dynCall_iiiiiii"]).apply(null, arguments);
  3940. };
  3941. /** @type {function(...*):?} */
  3942. var dynCall_ijiii = Module["dynCall_ijiii"] = function() {
  3943. return (dynCall_ijiii = Module["dynCall_ijiii"] = Module["asm"]["dynCall_ijiii"]).apply(null, arguments);
  3944. };
  3945. /** @type {function(...*):?} */
  3946. var dynCall_jiji = Module["dynCall_jiji"] = function() {
  3947. return (dynCall_jiji = Module["dynCall_jiji"] = Module["asm"]["dynCall_jiji"]).apply(null, arguments);
  3948. };
  3949. /** @type {function(...*):?} */
  3950. var dynCall_iiiji = Module["dynCall_iiiji"] = function() {
  3951. return (dynCall_iiiji = Module["dynCall_iiiji"] = Module["asm"]["dynCall_iiiji"]).apply(null, arguments);
  3952. };
  3953. /** @type {function(...*):?} */
  3954. var dynCall_viiiiii = Module["dynCall_viiiiii"] = function() {
  3955. return (dynCall_viiiiii = Module["dynCall_viiiiii"] = Module["asm"]["dynCall_viiiiii"]).apply(null, arguments);
  3956. };
  3957. /** @type {function(...*):?} */
  3958. var dynCall_iiiii = Module["dynCall_iiiii"] = function() {
  3959. return (dynCall_iiiii = Module["dynCall_iiiii"] = Module["asm"]["dynCall_iiiii"]).apply(null, arguments);
  3960. };
  3961. /** @type {function(...*):?} */
  3962. var dynCall_dd = Module["dynCall_dd"] = function() {
  3963. return (dynCall_dd = Module["dynCall_dd"] = Module["asm"]["dynCall_dd"]).apply(null, arguments);
  3964. };
  3965. /** @type {function(...*):?} */
  3966. var dynCall_iidiiii = Module["dynCall_iidiiii"] = function() {
  3967. return (dynCall_iidiiii = Module["dynCall_iidiiii"] = Module["asm"]["dynCall_iidiiii"]).apply(null, arguments);
  3968. };
  3969. /** @type {function(...*):?} */
  3970. var dynCall_viijii = Module["dynCall_viijii"] = function() {
  3971. return (dynCall_viijii = Module["dynCall_viijii"] = Module["asm"]["dynCall_viijii"]).apply(null, arguments);
  3972. };
  3973. /** @type {function(...*):?} */
  3974. var dynCall_iiiiiiiii = Module["dynCall_iiiiiiiii"] = function() {
  3975. return (dynCall_iiiiiiiii = Module["dynCall_iiiiiiiii"] = Module["asm"]["dynCall_iiiiiiiii"]).apply(null, arguments);
  3976. };
  3977. /** @type {function(...*):?} */
  3978. var dynCall_iiiiij = Module["dynCall_iiiiij"] = function() {
  3979. return (dynCall_iiiiij = Module["dynCall_iiiiij"] = Module["asm"]["dynCall_iiiiij"]).apply(null, arguments);
  3980. };
  3981. /** @type {function(...*):?} */
  3982. var dynCall_iiiiid = Module["dynCall_iiiiid"] = function() {
  3983. return (dynCall_iiiiid = Module["dynCall_iiiiid"] = Module["asm"]["dynCall_iiiiid"]).apply(null, arguments);
  3984. };
  3985. /** @type {function(...*):?} */
  3986. var dynCall_iiiiijj = Module["dynCall_iiiiijj"] = function() {
  3987. return (dynCall_iiiiijj = Module["dynCall_iiiiijj"] = Module["asm"]["dynCall_iiiiijj"]).apply(null, arguments);
  3988. };
  3989. /** @type {function(...*):?} */
  3990. var dynCall_iiiiiiii = Module["dynCall_iiiiiiii"] = function() {
  3991. return (dynCall_iiiiiiii = Module["dynCall_iiiiiiii"] = Module["asm"]["dynCall_iiiiiiii"]).apply(null, arguments);
  3992. };
  3993. /** @type {function(...*):?} */
  3994. var dynCall_iiiiiijj = Module["dynCall_iiiiiijj"] = function() {
  3995. return (dynCall_iiiiiijj = Module["dynCall_iiiiiijj"] = Module["asm"]["dynCall_iiiiiijj"]).apply(null, arguments);
  3996. };
  3997. /** @type {function(...*):?} */
  3998. var dynCall_viiiii = Module["dynCall_viiiii"] = function() {
  3999. return (dynCall_viiiii = Module["dynCall_viiiii"] = Module["asm"]["dynCall_viiiii"]).apply(null, arguments);
  4000. };
  4001. /** @type {function(...*):?} */
  4002. var _asyncify_start_unwind = Module["_asyncify_start_unwind"] = function() {
  4003. return (_asyncify_start_unwind = Module["_asyncify_start_unwind"] = Module["asm"]["asyncify_start_unwind"]).apply(null, arguments);
  4004. };
  4005. /** @type {function(...*):?} */
  4006. var _asyncify_stop_unwind = Module["_asyncify_stop_unwind"] = function() {
  4007. return (_asyncify_stop_unwind = Module["_asyncify_stop_unwind"] = Module["asm"]["asyncify_stop_unwind"]).apply(null, arguments);
  4008. };
  4009. /** @type {function(...*):?} */
  4010. var _asyncify_start_rewind = Module["_asyncify_start_rewind"] = function() {
  4011. return (_asyncify_start_rewind = Module["_asyncify_start_rewind"] = Module["asm"]["asyncify_start_rewind"]).apply(null, arguments);
  4012. };
  4013. /** @type {function(...*):?} */
  4014. var _asyncify_stop_rewind = Module["_asyncify_stop_rewind"] = function() {
  4015. return (_asyncify_stop_rewind = Module["_asyncify_stop_rewind"] = Module["asm"]["asyncify_stop_rewind"]).apply(null, arguments);
  4016. };
  4017. // === Auto-generated postamble setup entry stuff ===
  4018. Module["ccall"] = ccall;
  4019. Module["cwrap"] = cwrap;
  4020. var calledRun;
  4021. /**
  4022. * @constructor
  4023. * @this {ExitStatus}
  4024. */
  4025. function ExitStatus(status) {
  4026. this.name = "ExitStatus";
  4027. this.message = "Program terminated with exit(" + status + ")";
  4028. this.status = status;
  4029. }
  4030. var calledMain = false;
  4031. dependenciesFulfilled = function runCaller() {
  4032. // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
  4033. if (!calledRun) run();
  4034. if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
  4035. };
  4036. /** @type {function(Array=)} */
  4037. function run(args) {
  4038. args = args || arguments_;
  4039. if (runDependencies > 0) {
  4040. return;
  4041. }
  4042. preRun();
  4043. // a preRun added a dependency, run will be called later
  4044. if (runDependencies > 0) {
  4045. return;
  4046. }
  4047. function doRun() {
  4048. // run may have just been called through dependencies being fulfilled just in this very frame,
  4049. // or while the async setStatus time below was happening
  4050. if (calledRun) return;
  4051. calledRun = true;
  4052. Module['calledRun'] = true;
  4053. if (ABORT) return;
  4054. initRuntime();
  4055. if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();
  4056. postRun();
  4057. }
  4058. if (Module['setStatus']) {
  4059. Module['setStatus']('Running...');
  4060. setTimeout(function() {
  4061. setTimeout(function() {
  4062. Module['setStatus']('');
  4063. }, 1);
  4064. doRun();
  4065. }, 1);
  4066. } else
  4067. {
  4068. doRun();
  4069. }
  4070. }
  4071. Module['run'] = run;
  4072. /** @param {boolean|number=} implicit */
  4073. function exit(status, implicit) {
  4074. EXITSTATUS = status;
  4075. if (keepRuntimeAlive()) {
  4076. } else {
  4077. exitRuntime();
  4078. }
  4079. procExit(status);
  4080. }
  4081. function procExit(code) {
  4082. EXITSTATUS = code;
  4083. if (!keepRuntimeAlive()) {
  4084. if (Module['onExit']) Module['onExit'](code);
  4085. ABORT = true;
  4086. }
  4087. quit_(code, new ExitStatus(code));
  4088. }
  4089. var p = {
  4090. };
  4091. var wasm_isaac_generate = function(t, e){
  4092. p.decryptor_array = new Uint8Array(e);
  4093. var r = new Uint8Array(Module.HEAPU8.buffer,t,e);
  4094. p.decryptor_array.set(r.reverse())
  4095. }
  4096. // console.log(Module);
  4097. // var asm = createWasm();
  4098. module.exports = {createWasm, p, wasm_isaac_generate};