From f4502a506a504fc3d596bf10a2b0d4f2e9fc108e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 1 Apr 2024 16:32:42 -0700 Subject: [PATCH] Fix closure warnings in JS library code For some reason closure doesn't report these real issues in the current configuration but they show up in the `MODULARIZE_INSTANCE` configuration that I'm working on. Most of these issues consist of adding default parameters to functions declared on objects such as `FS`. In addition there are a couple of other changes that are all real fixes: - ErrnoError unified between old FS and wasm FS. This should have been done as part of #21149 - Default initializer for `canvasResizedCallbackTargetThread` removed since `JSEvents.getTargetThreadForEventCallback()` will always return undefined when called with no arguments - Extra arguments to copyIndexedColorData removed in library_sdl.js since it only ever called with one arg. - Sorting callback for JSEvents.deferredCalls.sort updated to correctly return number rather than a boolean. This change is basically code size neutral with a few tests coming in a byte or two heavier and others a byte or two lighter. --- src/library_browser.js | 7 ++- src/library_fs.js | 59 +++++-------------- src/library_fs_shared.js | 32 +++++++++- src/library_glemu.js | 5 +- src/library_html5.js | 16 +++-- src/library_nodefs.js | 8 +-- src/library_openal.js | 2 +- src/library_sdl.js | 22 ++++--- src/library_sockfs.js | 2 +- src/library_syscall.js | 8 +-- src/library_wasmfs.js | 29 +++------ src/library_webgpu.js | 8 +-- src/shell.js | 4 +- test/other/embind_tsgen_ignore_1.d.ts | 2 +- .../metadce/test_metadce_cxx_ctors1.gzsize | 2 +- .../metadce/test_metadce_cxx_ctors1.jssize | 2 +- .../metadce/test_metadce_cxx_ctors2.gzsize | 2 +- .../metadce/test_metadce_cxx_ctors2.jssize | 2 +- .../metadce/test_metadce_cxx_except.gzsize | 2 +- .../metadce/test_metadce_cxx_except.jssize | 2 +- .../test_metadce_cxx_except_wasm.gzsize | 2 +- .../test_metadce_cxx_except_wasm.jssize | 2 +- .../metadce/test_metadce_cxx_mangle.gzsize | 2 +- .../metadce/test_metadce_cxx_mangle.jssize | 2 +- .../metadce/test_metadce_cxx_noexcept.gzsize | 2 +- .../metadce/test_metadce_cxx_noexcept.jssize | 2 +- .../metadce/test_metadce_files_js_fs.jssize | 2 +- 27 files changed, 110 insertions(+), 120 deletions(-) diff --git a/src/library_browser.js b/src/library_browser.js index 8b2d84c1b39d..661ad9a21094 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -54,6 +54,9 @@ var LibraryBrowser = { timingValue: 0, currentFrameNumber: 0, queue: [], +#if USE_CLOSURE_COMPILER + expectedBlockers: 0, +#endif pause() { Browser.mainLoop.scheduler = null; // Incrementing this signals the previous main loop that it's now become old, and it must return. @@ -628,7 +631,7 @@ var LibraryBrowser = { Browser.resizeListeners.forEach((listener) => listener(canvas.width, canvas.height)); }, - setCanvasSize(width, height, noUpdates) { + setCanvasSize(width, height, noUpdates = false) { var canvas = Module['canvas']; Browser.updateCanvasDimensions(canvas, width, height); if (!noUpdates) Browser.updateResizeListeners(); @@ -658,7 +661,7 @@ var LibraryBrowser = { Browser.updateResizeListeners(); }, - updateCanvasDimensions(canvas, wNative, hNative) { + updateCanvasDimensions(canvas, wNative = 0, hNative = 0) { if (wNative && hNative) { canvas.widthNative = wNative; canvas.heightNative = hNative; diff --git a/src/library_fs.js b/src/library_fs.js index 20a724a0afcb..b8e91e3c0807 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -51,7 +51,6 @@ FS.staticInit();` + devices: {}, streams: [], nextInode: 1, - nameTable: null, currentPath: '/', initialized: false, // Whether we are currently ignoring permissions. Useful when preparing the @@ -62,40 +61,10 @@ FS.staticInit();` + #if FS_DEBUG trackingDelegate: {}, #endif - ErrnoError: null, // set during init genericErrors: {}, filesystems: null, syncFSRequests: 0, // we warn if there are multiple in flight at once - -#if ASSERTIONS - ErrnoError: class extends Error { -#else - ErrnoError: class { -#endif - // We set the `name` property to be able to identify `FS.ErrnoError` - // - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway. - // - when using PROXYFS, an error can come from an underlying FS - // as different FS objects have their own FS.ErrnoError each, - // the test `err instanceof FS.ErrnoError` won't detect an error coming from another filesystem, causing bugs. - // we'll use the reliable test `err.name == "ErrnoError"` instead - constructor(errno) { -#if ASSERTIONS - super(ERRNO_MESSAGES[errno]); -#endif - // TODO(sbc): Use the inline member declaration syntax once we - // support it in acorn and closure. - this.name = 'ErrnoError'; - this.errno = errno; -#if ASSERTIONS - for (var key in ERRNO_CODES) { - if (ERRNO_CODES[key] === errno) { - this.code = key; - break; - } - } -#endif - } - }, + ErrnoError: ErrnoError, FSStream: class { constructor() { @@ -304,7 +273,7 @@ FS.staticInit();` + // if we failed to find it in the cache, call into the VFS return FS.lookup(parent, name); }, - createNode(parent, name, mode, rdev) { + createNode(parent, name, mode, rdev = 0) { #if ASSERTIONS assert(typeof parent == 'object') #endif @@ -670,13 +639,13 @@ FS.staticInit();` + return parent.node_ops.mknod(parent, name, mode, dev); }, // helpers to create specific types of nodes - create(path, mode) { + create(path, mode = undefined) { mode = mode !== undefined ? mode : 438 /* 0666 */; mode &= {{{ cDefs.S_IALLUGO }}}; mode |= {{{ cDefs.S_IFREG }}}; return FS.mknod(path, mode, 0); }, - mkdir(path, mode) { + mkdir(path, mode = undefined) { mode = mode !== undefined ? mode : 511 /* 0777 */; mode &= {{{ cDefs.S_IRWXUGO }}} | {{{ cDefs.S_ISVTX }}}; mode |= {{{ cDefs.S_IFDIR }}}; @@ -688,7 +657,7 @@ FS.staticInit();` + return FS.mknod(path, mode, 0); }, // Creates a whole directory tree chain if it doesn't yet exist - mkdirTree(path, mode) { + mkdirTree(path, mode = undefined) { var dirs = path.split('/'); var d = ''; for (var i = 0; i < dirs.length; ++i) { @@ -701,7 +670,7 @@ FS.staticInit();` + } } }, - mkdev(path, mode, dev) { + mkdev(path, mode, dev = undefined) { if (typeof dev == 'undefined') { dev = mode; mode = 438 /* 0666 */; @@ -906,7 +875,7 @@ FS.staticInit();` + } return PATH_FS.resolve(FS.getPath(link.parent), link.node_ops.readlink(link)); }, - stat(path, dontFollow) { + stat(path, dontFollow = false) { var lookup = FS.lookupPath(path, { follow: !dontFollow }); var node = lookup.node; if (!node) { @@ -920,7 +889,7 @@ FS.staticInit();` + lstat(path) { return FS.stat(path, true); }, - chmod(path, mode, dontFollow) { + chmod(path, mode, dontFollow = false) { var node; if (typeof path == 'string') { var lookup = FS.lookupPath(path, { follow: !dontFollow }); @@ -943,7 +912,7 @@ FS.staticInit();` + var stream = FS.getStreamChecked(fd); FS.chmod(stream.node, mode); }, - chown(path, uid, gid, dontFollow) { + chown(path, uid, gid, dontFollow = false) { var node; if (typeof path == 'string') { var lookup = FS.lookupPath(path, { follow: !dontFollow }); @@ -1009,7 +978,7 @@ FS.staticInit();` + timestamp: Math.max(atime, mtime) }); }, - open(path, flags, mode) { + open(path, flags, mode = undefined) { if (path === "") { throw new FS.ErrnoError({{{ cDefs.ENOENT }}}); } @@ -1187,7 +1156,7 @@ FS.staticInit();` + #endif return bytesRead; }, - write(stream, buffer, offset, length, position, canOwn) { + write(stream, buffer, offset, length, position = undefined, canOwn = false) { #if ASSERTIONS assert(offset >= 0); #endif @@ -1460,7 +1429,7 @@ FS.staticInit();` + #endif }; }, - init(input, output, error) { + init(input = undefined, output = undefined, error = undefined) { #if ASSERTIONS assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)'); #endif @@ -1499,7 +1468,7 @@ FS.staticInit();` + } return ret.object; }, - analyzePath(path, dontResolveLastLink) { + analyzePath(path, dontResolveLastLink = false) { // operate from within the context of the symlink's target try { var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink }); @@ -1570,7 +1539,7 @@ FS.staticInit();` + FS.chmod(node, mode); } }, - createDevice(parent, name, input, output) { + createDevice(parent, name, input, output = undefined) { var path = PATH.join2(typeof parent == 'string' ? parent : FS.getPath(parent), name); var mode = FS_getMode(!!input, !!output); if (!FS.createDevice.major) FS.createDevice.major = 64; diff --git a/src/library_fs_shared.js b/src/library_fs_shared.js index 2bd91f44bb11..58293b052aa7 100644 --- a/src/library_fs_shared.js +++ b/src/library_fs_shared.js @@ -4,6 +4,36 @@ * SPDX-License-Identifier: MIT */ +#if ASSERTIONS +class ErrnoError extends Error { +#else +class ErrnoError { +#endif + // We set the `name` property to be able to identify `FS.ErrnoError` + // - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway. + // - when using PROXYFS, an error can come from an underlying FS + // as different FS objects have their own FS.ErrnoError each, + // the test `err instanceof FS.ErrnoError` won't detect an error coming from another filesystem, causing bugs. + // we'll use the reliable test `err.name == "ErrnoError"` instead + constructor(errno) { +#if ASSERTIONS + super(ERRNO_MESSAGES[errno]); +#endif + // TODO(sbc): Use the inline member declaration syntax once we + // support it in acorn and closure. + this.name = 'ErrnoError'; + this.errno = errno; +#if ASSERTIONS + for (var key in ERRNO_CODES) { + if (ERRNO_CODES[key] === errno) { + this.code = key; + break; + } + } +#endif + } +} + addToLibrary({ $preloadPlugins: "{{{ makeModuleReceiveExpr('preloadPlugins', '[]') }}}", @@ -50,7 +80,7 @@ addToLibrary({ '$FS_handledByPreloadPlugin', #endif ], - $FS_createPreloadedFile: (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => { + $FS_createPreloadedFile: (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn = false, preFinish = undefined) => { // TODO we should allow people to just pass in a complete filename instead // of parent and name being that we just join them anyways var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent; diff --git a/src/library_glemu.js b/src/library_glemu.js index 8d0b63a5ee61..cc08307158a5 100644 --- a/src/library_glemu.js +++ b/src/library_glemu.js @@ -69,7 +69,6 @@ var LibraryGLEmulation = { fogStart: 0, fogEnd: 1, fogDensity: 1.0, - fogColor: null, fogMode: 0x800, // GL_EXP fogEnabled: false, @@ -2127,7 +2126,7 @@ var LibraryGLEmulation = { return renderer; }, - createRenderer(renderer) { + createRenderer() { var useCurrProgram = !!GL.currProgram; var hasTextures = false; for (var i = 0; i < GLImmediate.MAX_TEXTURES; i++) { @@ -2995,7 +2994,7 @@ var LibraryGLEmulation = { } }, - flush(numProvidedIndexes, startIndex = 0, ptr = 0) { + flush(numProvidedIndexes = 0, startIndex = 0, ptr = 0) { #if ASSERTIONS assert(numProvidedIndexes >= 0 || !numProvidedIndexes); #endif diff --git a/src/library_html5.js b/src/library_html5.js index edacdcba59e9..147621e82502 100644 --- a/src/library_html5.js +++ b/src/library_html5.js @@ -94,8 +94,7 @@ var LibraryHTML5 = { return true; } // Test if the given call was already queued, and if so, don't add it again. - for (var i in JSEvents.deferredCalls) { - var call = JSEvents.deferredCalls[i]; + for (var call of JSEvents.deferredCalls) { if (call.targetFunction == targetFunction && arraysHaveEqualContent(call.argsList, argsList)) { return; } @@ -106,7 +105,10 @@ var LibraryHTML5 = { argsList }); - JSEvents.deferredCalls.sort((x,y) => x.precedence < y.precedence); + // sortcallback(x, y): + // A negative value indicates that x should come before y. + // A positive value indicates that x should come after y. + JSEvents.deferredCalls.sort((x,y) => y.precedence - x.precedence); }, // Erases all deferred calls to the given target function from the queue list. @@ -151,10 +153,9 @@ var LibraryHTML5 = { // Removes all event handlers on the given DOM element of the given type. // Pass in eventTypeString == undefined/null to remove all event handlers // regardless of the type. - removeAllHandlersOnTarget: (target, eventTypeString) => { + removeAllHandlersOnTarget: (target) => { for (var i = 0; i < JSEvents.eventHandlers.length; ++i) { - if (JSEvents.eventHandlers[i].target == target && - (!eventTypeString || eventTypeString == JSEvents.eventHandlers[i].eventTypeString)) { + if (JSEvents.eventHandlers[i].target) { JSEvents._removeHandler(i--); } } @@ -1512,9 +1513,6 @@ var LibraryHTML5 = { filteringMode: {{{ makeGetValue('fullscreenStrategy', C_STRUCTS.EmscriptenFullscreenStrategy.filteringMode, 'i32') }}}, canvasResizedCallback: {{{ makeGetValue('fullscreenStrategy', C_STRUCTS.EmscriptenFullscreenStrategy.canvasResizedCallback, 'i32') }}}, canvasResizedCallbackUserData: {{{ makeGetValue('fullscreenStrategy', C_STRUCTS.EmscriptenFullscreenStrategy.canvasResizedCallbackUserData, 'i32') }}}, -#if PTHREADS - canvasResizedCallbackTargetThread: JSEvents.getTargetThreadForEventCallback(), -#endif target, softFullscreen: true }; diff --git a/src/library_nodefs.js b/src/library_nodefs.js index ace50458c9c4..7eea1ce78436 100644 --- a/src/library_nodefs.js +++ b/src/library_nodefs.js @@ -53,9 +53,9 @@ addToLibrary({ #if ASSERTIONS assert(ENVIRONMENT_IS_NODE); #endif - return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0); + return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root)); }, - createNode(parent, name, mode, dev) { + createNode(parent, name, mode) { if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) { throw new FS.ErrnoError({{{ cDefs.EINVAL }}}); } @@ -169,7 +169,7 @@ addToLibrary({ return NODEFS.createNode(parent, name, mode); }, mknod(parent, name, mode, dev) { - var node = NODEFS.createNode(parent, name, mode, dev); + var node = NODEFS.createNode(parent, name, mode); // create the backing node for this in the fs root as well var path = NODEFS.realPath(node); try { @@ -320,7 +320,7 @@ addToLibrary({ return { ptr, allocated: true }; }, msync(stream, buffer, offset, length, mmapFlags) { - NODEFS.stream_ops.write(stream, buffer, 0, length, offset, false); + NODEFS.stream_ops.write(stream, buffer, 0, length, offset); // should we check if bytesWritten and length are the same? return 0; } diff --git a/src/library_openal.js b/src/library_openal.js index b39961cf3b78..33931d20180d 100644 --- a/src/library_openal.js +++ b/src/library_openal.js @@ -103,7 +103,7 @@ var LibraryOpenAL = { // represents the queue of buffers scheduled for physical playback. These two queues are // distinct because of the differing semantics of OpenAL and web audio. Some changes // to OpenAL parameters, such as pitch, may require the web audio queue to be flushed and rescheduled. - scheduleSourceAudio: (src, lookahead) => { + scheduleSourceAudio: (src, lookahead = false) => { // See comment on scheduleContextAudio above. if (Browser.mainLoop.timingMode === {{{ cDefs.EM_TIMING_RAF }}} && document['visibilityState'] != 'visible') { return; diff --git a/src/library_sdl.js b/src/library_sdl.js index 6a6563ecc9dd..5f7429ae99bd 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -106,18 +106,22 @@ var LibrarySDL = { audio: null, startTime: null, - initFlags: 0, // The flags passed to SDL_Init buttonState: 0, modState: 0, DOMButtons: [0, 0, 0], DOMEventToSDLEvent: {}, - TOUCH_DEFAULT_ID: 0, // Our default deviceID for touch events (we get nothing from the browser) + // Our default deviceID for touch events (we get nothing from the browser) + TOUCH_DEFAULT_ID: 0, +#if USE_CLOSURE_COMPILER eventHandler: null, - eventHandlerContext: null, + // The flags passed to SDL_Init + initFlags: 0, + eventHandlerContext: 0, eventHandlerTemp: 0, +#endif // DOM code ==> SDL code. See // https://developer.mozilla.org/en/Document_Object_Model_%28DOM%29/KeyboardEvent @@ -346,7 +350,7 @@ var LibrarySDL = { translateRGBAToColor: (r, g, b, a) => r | g << 8 | b << 16 | a << 24, - makeSurface(width, height, flags, usePageCanvas, source, rmask, gmask, bmask, amask) { + makeSurface(width, height, flags, usePageCanvas, source = 0, rmask = 0, gmask = 0, bmask = 0, amask = 0) { var is_SDL_HWSURFACE = flags & 0x00000001; var is_SDL_HWPALETTE = flags & 0x00200000; var is_SDL_OPENGL = flags & 0x04000000; @@ -438,7 +442,7 @@ var LibrarySDL = { // Copy data from the C++-accessible storage to the canvas backing // for surface with HWPALETTE flag(8bpp depth) - copyIndexedColorData(surfData, rX, rY, rW, rH) { + copyIndexedColorData(surfData) { // HWPALETTE works with palette // set by SDL_SetColors if (!surfData.colors) { @@ -448,10 +452,10 @@ var LibrarySDL = { var fullWidth = Module['canvas'].width; var fullHeight = Module['canvas'].height; - var startX = rX || 0; - var startY = rY || 0; - var endX = (rW || (fullWidth - startX)) + startX; - var endY = (rH || (fullHeight - startY)) + startY; + var startX = 0; + var startY = 0; + var endX = (fullWidth - startX) + startX; + var endY = (fullHeight - startY) + startY; var buffer = surfData.buffer; diff --git a/src/library_sockfs.js b/src/library_sockfs.js index 6565b04878fb..d6cd1e7d4d23 100644 --- a/src/library_sockfs.js +++ b/src/library_sockfs.js @@ -140,7 +140,7 @@ addToLibrary({ // these functions aren't actually sock_ops members, but we're // abusing the namespace to organize them // - createPeer(sock, addr, port) { + createPeer(sock, addr, port = undefined) { var ws; if (typeof addr == 'object') { diff --git a/src/library_syscall.js b/src/library_syscall.js index 7b29e7962fb1..81610940f8ee 100644 --- a/src/library_syscall.js +++ b/src/library_syscall.js @@ -20,7 +20,7 @@ var SyscallsLibrary = { DEFAULT_POLLMASK: {{{ cDefs.POLLIN }}} | {{{ cDefs.POLLOUT }}}, // shared utilities - calculateAt(dirfd, path, allowEmpty) { + calculateAt(dirfd, path, allowEmpty = false) { if (PATH.isAbs(path)) { return path; } @@ -98,7 +98,7 @@ var SyscallsLibrary = { $syscallGetVarargI__internal: true, $syscallGetVarargI: function() { -#if ASSERTIONS +#if ASSERTIONS && !USE_CLOSURE_COMPILER assert(SYSCALLS.varargs != undefined); #endif // the `+` prepended here is necessary to convince the JSCompiler that varargs is indeed a number. @@ -113,7 +113,7 @@ var SyscallsLibrary = { $syscallGetVarargP__internal: true, #if MEMORY64 $syscallGetVarargP: function() { -#if ASSERTIONS +#if ASSERTIONS && !USE_CLOSURE_COMPILER assert(SYSCALLS.varargs != undefined); #endif var ret = {{{ makeGetValue('SYSCALLS.varargs', 0, '*') }}}; @@ -847,7 +847,7 @@ var SyscallsLibrary = { // we want to create b in the context of this function path = PATH.normalize(path); if (path[path.length-1] === '/') path = path.substr(0, path.length-1); - FS.mkdir(path, mode, 0); + FS.mkdir(path, mode); return 0; }, __syscall_mknodat: (dirfd, path, mode, dev) => { diff --git a/src/library_wasmfs.js b/src/library_wasmfs.js index 7d303c8c7893..5da4e4eaa07f 100644 --- a/src/library_wasmfs.js +++ b/src/library_wasmfs.js @@ -21,9 +21,6 @@ addToLibrary({ $wasmFSDevices: {}, $wasmFSDeviceStreams: {}, - $FS__postset: ` -FS.init(); -`, $FS__deps: [ '$MEMFS', '$wasmFSPreloadedFiles', @@ -70,14 +67,14 @@ FS.init(); 'wasmfs_create_jsimpl_backend', '$wasmFS$backends', '$wasmFSDevices', - '$wasmFSDeviceStreams' + '$wasmFSDeviceStreams', +#endif +#if ASSERTIONS + '$ERRNO_MESSAGES', '$ERRNO_CODES', #endif ], $FS : { - init() { - FS.ensureErrnoError(); - }, - ErrnoError: null, + ErrnoError: ErrnoError, handleError(returnValue) { // Assume errors correspond to negative returnValues // since some functions like _wasmfs_open() return positive @@ -88,16 +85,6 @@ FS.init(); return returnValue; }, - ensureErrnoError() { - if (FS.ErrnoError) return; - FS.ErrnoError = /** @this{Object} */ function ErrnoError(code) { - this.errno = code; - this.message = 'FS error'; - this.name = "ErrnoError"; - } - FS.ErrnoError.prototype = new Error(); - FS.ErrnoError.prototype.constructor = FS.ErrnoError; - }, createDataFile(parent, name, fileData, canRead, canWrite, canOwn) { FS_createDataFile(parent, name, fileData, canRead, canWrite, canOwn); }, @@ -118,7 +105,7 @@ FS.init(); return current; }, - createPreloadedFile(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) { + createPreloadedFile(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn = 0, preFinish = undefined) { return FS_createPreloadedFile(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish); }, @@ -171,8 +158,8 @@ FS.init(); // libc methods - mkdir: (path, mode) => FS_mkdir(path, mode), - mkdirTree: (path, mode) => FS_mkdirTree(path, mode), + mkdir: (path, mode = undefined) => FS_mkdir(path, mode), + mkdirTree: (path, mode = undefined) => FS_mkdirTree(path, mode), rmdir: (path) => FS.handleError( withStackSave(() => __wasmfs_rmdir(stringToUTF8OnStack(path))) ), diff --git a/src/library_webgpu.js b/src/library_webgpu.js index c1cc344ffde1..7fe4d0c6c8f9 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -956,8 +956,8 @@ var LibraryWebGPU = { if (viewFormatCount) { var viewFormatsPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUTextureDescriptor.viewFormats, '*') }}}; // viewFormatsPtr pointer to an array of TextureFormat which is an enum of size uint32_t - desc["viewFormats"] = Array.from({{{ makeHEAPView('32', 'viewFormatsPtr', `viewFormatsPtr + viewFormatCount * 4`) }}}, - function(format) { return WebGPU.TextureFormat[format]; }); + var heapView = {{{ makeHEAPView('32', 'viewFormatsPtr', `viewFormatsPtr + viewFormatCount * 4`) }}}; + desc["viewFormats"] = Array.from(heapView, /** @suppress {checkTypes} */ (format) => WebGPU.TextureFormat[format]); } var device = WebGPU.mgrDevice.get(deviceId); @@ -2556,8 +2556,8 @@ var LibraryWebGPU = { var requiredFeatureCount = {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUDeviceDescriptor.requiredFeatureCount) }}}; if (requiredFeatureCount) { var requiredFeaturesPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUDeviceDescriptor.requiredFeatures, '*') }}}; - desc["requiredFeatures"] = Array.from({{{ makeHEAPView('32', 'requiredFeaturesPtr', `requiredFeaturesPtr + requiredFeatureCount * ${POINTER_SIZE}`) }}}, - (feature) => WebGPU.FeatureName[feature]); + var heapView = {{{ makeHEAPView('32', 'requiredFeaturesPtr', `requiredFeaturesPtr + requiredFeatureCount * ${POINTER_SIZE}`) }}}; + desc["requiredFeatures"] = Array.from(heapView, /** @suppress {checkTypes} */ (feature) => WebGPU.FeatureName[feature]); } var requiredLimitsPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUDeviceDescriptor.requiredLimits, '*') }}}; if (requiredLimitsPtr) { diff --git a/src/shell.js b/src/shell.js index 4dd7f24f888d..bb6e217660c0 100644 --- a/src/shell.js +++ b/src/shell.js @@ -311,8 +311,8 @@ if (ENVIRONMENT_IS_SHELL) { if (typeof scriptArgs != 'undefined') { arguments_ = scriptArgs; - } else if (typeof arguments != 'undefined') { - arguments_ = arguments; + } else if (typeof globalThis.arguments != 'undefined') { + arguments_ = globalThis.arguments; } if (typeof quit == 'function') { diff --git a/test/other/embind_tsgen_ignore_1.d.ts b/test/other/embind_tsgen_ignore_1.d.ts index 7fcba5f9b77c..48667bc56816 100644 --- a/test/other/embind_tsgen_ignore_1.d.ts +++ b/test/other/embind_tsgen_ignore_1.d.ts @@ -16,7 +16,7 @@ declare namespace RuntimeExports { let wasmMemory: any; let FS_createPath: any; function FS_createDataFile(parent: any, name: any, fileData: any, canRead: any, canWrite: any, canOwn: any): void; - function FS_createPreloadedFile(parent: any, name: any, url: any, canRead: any, canWrite: any, onload: any, onerror: any, dontCreateFile: any, canOwn: any, preFinish: any): void; + function FS_createPreloadedFile(parent: any, name: any, url: any, canRead: any, canWrite: any, onload: any, onerror: any, dontCreateFile: any, canOwn?: boolean, preFinish?: any): void; function FS_unlink(path: any): any; let FS_createLazyFile: any; let FS_createDevice: any; diff --git a/test/other/metadce/test_metadce_cxx_ctors1.gzsize b/test/other/metadce/test_metadce_cxx_ctors1.gzsize index 7d2aaf9f2cc4..53e2a94d5e88 100644 --- a/test/other/metadce/test_metadce_cxx_ctors1.gzsize +++ b/test/other/metadce/test_metadce_cxx_ctors1.gzsize @@ -1 +1 @@ -9855 +9856 diff --git a/test/other/metadce/test_metadce_cxx_ctors1.jssize b/test/other/metadce/test_metadce_cxx_ctors1.jssize index 06e1e1e8978b..9da24a411ba0 100644 --- a/test/other/metadce/test_metadce_cxx_ctors1.jssize +++ b/test/other/metadce/test_metadce_cxx_ctors1.jssize @@ -1 +1 @@ -24244 +24237 diff --git a/test/other/metadce/test_metadce_cxx_ctors2.gzsize b/test/other/metadce/test_metadce_cxx_ctors2.gzsize index 2bb71e12ba7e..31f974893fba 100644 --- a/test/other/metadce/test_metadce_cxx_ctors2.gzsize +++ b/test/other/metadce/test_metadce_cxx_ctors2.gzsize @@ -1 +1 @@ -9838 +9837 diff --git a/test/other/metadce/test_metadce_cxx_ctors2.jssize b/test/other/metadce/test_metadce_cxx_ctors2.jssize index 6ab96b56d1de..b737c612b32d 100644 --- a/test/other/metadce/test_metadce_cxx_ctors2.jssize +++ b/test/other/metadce/test_metadce_cxx_ctors2.jssize @@ -1 +1 @@ -24212 +24205 diff --git a/test/other/metadce/test_metadce_cxx_except.gzsize b/test/other/metadce/test_metadce_cxx_except.gzsize index e7b3d68c69b4..06a735b30864 100644 --- a/test/other/metadce/test_metadce_cxx_except.gzsize +++ b/test/other/metadce/test_metadce_cxx_except.gzsize @@ -1 +1 @@ -10945 +10946 diff --git a/test/other/metadce/test_metadce_cxx_except.jssize b/test/other/metadce/test_metadce_cxx_except.jssize index e26dc13eee8d..2cec056681ce 100644 --- a/test/other/metadce/test_metadce_cxx_except.jssize +++ b/test/other/metadce/test_metadce_cxx_except.jssize @@ -1 +1 @@ -28161 +28154 diff --git a/test/other/metadce/test_metadce_cxx_except_wasm.gzsize b/test/other/metadce/test_metadce_cxx_except_wasm.gzsize index 42d6a508c8cf..41b38bd140db 100644 --- a/test/other/metadce/test_metadce_cxx_except_wasm.gzsize +++ b/test/other/metadce/test_metadce_cxx_except_wasm.gzsize @@ -1 +1 @@ -9821 +9820 diff --git a/test/other/metadce/test_metadce_cxx_except_wasm.jssize b/test/other/metadce/test_metadce_cxx_except_wasm.jssize index 52c95eb3c3d2..dd031a00cad7 100644 --- a/test/other/metadce/test_metadce_cxx_except_wasm.jssize +++ b/test/other/metadce/test_metadce_cxx_except_wasm.jssize @@ -1 +1 @@ -24137 +24130 diff --git a/test/other/metadce/test_metadce_cxx_mangle.gzsize b/test/other/metadce/test_metadce_cxx_mangle.gzsize index 8f245665baa3..447bb3cd380d 100644 --- a/test/other/metadce/test_metadce_cxx_mangle.gzsize +++ b/test/other/metadce/test_metadce_cxx_mangle.gzsize @@ -1 +1 @@ -10954 +10956 diff --git a/test/other/metadce/test_metadce_cxx_mangle.jssize b/test/other/metadce/test_metadce_cxx_mangle.jssize index 59e3f17690f9..da96945d601f 100644 --- a/test/other/metadce/test_metadce_cxx_mangle.jssize +++ b/test/other/metadce/test_metadce_cxx_mangle.jssize @@ -1 +1 @@ -28162 +28155 diff --git a/test/other/metadce/test_metadce_cxx_noexcept.gzsize b/test/other/metadce/test_metadce_cxx_noexcept.gzsize index 7d2aaf9f2cc4..53e2a94d5e88 100644 --- a/test/other/metadce/test_metadce_cxx_noexcept.gzsize +++ b/test/other/metadce/test_metadce_cxx_noexcept.gzsize @@ -1 +1 @@ -9855 +9856 diff --git a/test/other/metadce/test_metadce_cxx_noexcept.jssize b/test/other/metadce/test_metadce_cxx_noexcept.jssize index 06e1e1e8978b..9da24a411ba0 100644 --- a/test/other/metadce/test_metadce_cxx_noexcept.jssize +++ b/test/other/metadce/test_metadce_cxx_noexcept.jssize @@ -1 +1 @@ -24244 +24237 diff --git a/test/other/metadce/test_metadce_files_js_fs.jssize b/test/other/metadce/test_metadce_files_js_fs.jssize index cf9094240295..a4fbe6d90354 100644 --- a/test/other/metadce/test_metadce_files_js_fs.jssize +++ b/test/other/metadce/test_metadce_files_js_fs.jssize @@ -1 +1 @@ -19271 +19264