Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/libbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ var LibraryBrowser = {
Browser.resizeListeners.forEach((listener) => listener(canvas.width, canvas.height));
},

setCanvasSize(width, height, noUpdates) {
setCanvasSize(width, height, noUpdates = undefined) {
var canvas = Browser.getCanvas();
Browser.updateCanvasDimensions(canvas, width, height);
if (!noUpdates) Browser.updateResizeListeners();
Expand Down Expand Up @@ -455,7 +455,7 @@ var LibraryBrowser = {
Browser.updateResizeListeners();
},

updateCanvasDimensions(canvas, wNative, hNative) {
updateCanvasDimensions(canvas, wNative = undefined, hNative = undefined) {
if (wNative && hNative) {
canvas.widthNative = wNative;
canvas.heightNative = hNative;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libfs_shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ addToLibrary({
},

// Legacy version of FS_preloadFile that uses callback rather than async
$FS_createPreloadedFile: (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => {
$FS_createPreloadedFile: (parent, name, url, canRead = undefined, canWrite = undefined, onload = undefined, onerror = undefined, dontCreateFile = undefined, canOwn = undefined, preFinish = undefined) => {
FS_preloadFile(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish).then(onload).catch(onerror);
},

Expand All @@ -48,7 +48,7 @@ addToLibrary({
// You can also call this with a typed array instead of a url. It will then
// do preloading for the Image/Audio part, as if the typed array were the
// result of an XHR that you did manually.
$FS_preloadFile: async (parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish) => {
$FS_preloadFile: async (parent, name, url, canRead = undefined, canWrite = undefined, dontCreateFile = undefined, canOwn = undefined, 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;
Expand Down
53 changes: 3 additions & 50 deletions src/lib/libglemu.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,47 +27,12 @@ var LibraryGLEmulation = {
// GL emulation: provides misc. functionality not present in OpenGL ES 2.0 or WebGL
$GLEmulation__deps: ['$GLImmediateSetup'],
$GLEmulation__force: true,
$GLEmulation__postset: `
// Forward declare GL functions that are overridden by GLEmulation.
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDrawArrays;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDrawElements;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glActiveTexture;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glEnable;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDisable;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvf;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvi;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvfv;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetIntegerv;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glIsEnabled;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetBooleanv;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetString;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glCreateShader;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glShaderSource;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glCompileShader;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glAttachShader;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDetachShader;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glUseProgram;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDeleteProgram;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glBindAttribLocation;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glLinkProgram;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glBindBuffer;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetFloatv;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glHint;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glEnableVertexAttribArray;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDisableVertexAttribArray;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glVertexAttribPointer;
/**@suppress {duplicate, undefinedVars}*/var _glTexEnvf;
/**@suppress {duplicate, undefinedVars}*/var _glTexEnvi;
/**@suppress {duplicate, undefinedVars}*/var _glTexEnvfv;
/**@suppress {duplicate, undefinedVars}*/var _glGetTexEnviv;
/**@suppress {duplicate, undefinedVars}*/var _glGetTexEnvfv;
GLEmulation.init();`,
$GLEmulation__postset: 'GLEmulation.init();',
$GLEmulation: {
// Fog support. Partial, we assume shaders are used that implement fog. We just pass them uniforms
fogStart: 0,
fogEnd: 1,
fogDensity: 1.0,
fogColor: null,
fogMode: 0x800, // GL_EXP
fogEnabled: false,

Expand Down Expand Up @@ -2135,7 +2100,7 @@ var LibraryGLEmulation = {
return renderer;
},

createRenderer(renderer) {
createRenderer() {
var useCurrProgram = !!GL.currProgram;
var hasTextures = false;
for (var i = 0; i < GLImmediate.MAX_TEXTURES; i++) {
Expand Down Expand Up @@ -2768,30 +2733,18 @@ var LibraryGLEmulation = {
glDisable(cap);
};

var glTexEnvf = (typeof _glTexEnvf !== 'undefined') ? _glTexEnvf : () => {};
/** @suppress {checkTypes} */
_glTexEnvf = _emscripten_glTexEnvf = (target, pname, param) => {
GLImmediate.TexEnvJIT.hook_texEnvf(target, pname, param);
// Don't call old func, since we are the implementor.
//glTexEnvf(target, pname, param);
};

var glTexEnvi = (typeof _glTexEnvi !== 'undefined') ? _glTexEnvi : () => {};
/** @suppress {checkTypes} */
_glTexEnvi = _emscripten_glTexEnvi = (target, pname, param) => {
{{{ fromPtr('param') }}}
GLImmediate.TexEnvJIT.hook_texEnvi(target, pname, param);
// Don't call old func, since we are the implementor.
//glTexEnvi(target, pname, param);
};

var glTexEnvfv = (typeof _glTexEnvfv !== 'undefined') ? _glTexEnvfv : () => {};
/** @suppress {checkTypes} */
_glTexEnvfv = _emscripten_glTexEnvfv = (target, pname, param) => {
{{{ fromPtr('param') }}}
GLImmediate.TexEnvJIT.hook_texEnvfv(target, pname, param);
// Don't call old func, since we are the implementor.
//glTexEnvfv(target, pname, param);
};

_glGetTexEnviv = (target, pname, param) => {
Expand Down Expand Up @@ -2996,7 +2949,7 @@ var LibraryGLEmulation = {
}
},

flush(numProvidedIndexes, startIndex = 0, ptr = 0) {
flush(numProvidedIndexes = undefined, startIndex = 0, ptr = 0) {
#if ASSERTIONS
assert(numProvidedIndexes >= 0 || !numProvidedIndexes);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libglfw.js
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ var LibraryGLFW = {
},

// Overrides Browser.updateCanvasDimensions to account for hi dpi scaling
updateCanvasDimensions(canvas, wNative, hNative) {
updateCanvasDimensions(canvas, wNative = undefined, hNative = undefined) {
const scale = GLFW.getHiDPIScale();

if (wNative && hNative) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libhtml5.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ 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, eventTypeString = undefined) => {
for (var i = 0; i < JSEvents.eventHandlers.length; ++i) {
if (JSEvents.eventHandlers[i].target == target &&
(!eventTypeString || eventTypeString == JSEvents.eventHandlers[i].eventTypeString)) {
Expand Down Expand Up @@ -222,7 +222,7 @@ var LibraryHTML5 = {
},

#if PTHREADS
getTargetThreadForEventCallback(targetThread) {
getTargetThreadForEventCallback(targetThread = undefined) {
switch (targetThread) {
case {{{ cDefs.EM_CALLBACK_THREAD_CONTEXT_MAIN_RUNTIME_THREAD }}}:
// The event callback for the current event should be called on the
Expand Down
2 changes: 1 addition & 1 deletion src/lib/liblz4.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ addToLibrary({
}
}
},
createNode(parent, name, mode, dev, contents, mtime) {
createNode(parent, name, mode, dev = undefined, contents = undefined, mtime = undefined) {
var node = FS.createNode(parent, name, mode);
node.mode = mode;
node.node_ops = LZ4.node_ops;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libopenal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = undefined) => {
// See comment on scheduleContextAudio above.
if (MainLoop.timingMode === {{{ cDefs.EM_TIMING_RAF }}} && document['visibilityState'] != 'visible') {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libproxyfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ addToLibrary({
mount(mount) {
return PROXYFS.createNode(null, '/', mount.opts.fs.lstat(mount.opts.root).mode, 0);
},
createNode(parent, name, mode, dev) {
createNode(parent, name, mode, dev = undefined) {
if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/libsdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ var LibrarySDL = {
translateRGBAToCSSRGBA: (r, g, b, a) =>
'rgba(' + (r&0xff) + ',' + (g&0xff) + ',' + (b&0xff) + ',' + (a&0xff)/255 + ')',

makeSurface(width, height, flags, usePageCanvas, source, rmask, gmask, bmask, amask) {
makeSurface(width, height, flags, usePageCanvas, source = undefined, rmask = undefined, gmask = undefined, bmask = undefined, amask = undefined) {
var is_SDL_HWSURFACE = flags & {{{ cDefs.SDL_HWSURFACE }}};
var is_SDL_HWPALETTE = flags & {{{ cDefs.SDL_HWPALETTE }}};
var is_SDL_OPENGL = flags & {{{ cDefs.SDL_OPENGL }}};
Expand Down Expand Up @@ -429,7 +429,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, rX = undefined, rY = undefined, rW = undefined, rH = undefined) {
// HWPALETTE works with palette
// set by SDL_SetColors
if (!surfData.colors) {
Expand Down Expand Up @@ -2887,7 +2887,7 @@ var LibrarySDL = {
Mix_PlayMusic: (id, loops) => {
// Pause old music if it exists.
if (SDL.music.audio) {
if (!SDL.music.audio.paused) err(`Music is already playing. ${SDL.music.source}`);
if (!SDL.music.audio.paused) err('Music is already playing.');
SDL.music.audio.pause();
}
var info = SDL.audios[id];
Expand Down
26 changes: 13 additions & 13 deletions src/lib/libwasmfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ addToLibrary({

return returnValue;
},
createDataFile(parent, name, fileData, canRead, canWrite, canOwn) {
createDataFile(parent, name, fileData = undefined, canRead = undefined, canWrite = undefined, canOwn = undefined) {
FS_createDataFile(parent, name, fileData, canRead, canWrite, canOwn);
},
createPath(parent, path, canRead, canWrite) {
createPath(parent, path, canRead = undefined, canWrite = undefined) {
// Cache file path directory names.
var parts = path.split('/').reverse();
while (parts.length) {
Expand All @@ -95,11 +95,11 @@ addToLibrary({
return current;
},

createPreloadedFile(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) {
createPreloadedFile(parent, name, url, canRead = undefined, canWrite = undefined, onload = undefined, onerror = undefined, dontCreateFile = undefined, canOwn = undefined, preFinish = undefined) {
return FS_createPreloadedFile(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish);
},

async preloadFile(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish) {
async preloadFile(parent, name, url, canRead = undefined, canWrite = undefined, dontCreateFile = undefined, canOwn = undefined, preFinish = undefined) {
return FS_preloadFile(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish);
},

Expand Down Expand Up @@ -138,8 +138,8 @@ addToLibrary({
#if FORCE_FILESYSTEM || INCLUDE_FULL_LIBRARY // see comment above
// libc methods

mkdir: (path, mode) => FS_mkdir(path, mode),
mkdirTree: (path, mode) => FS_mkdirTree(path, mode),
mkdir: (path, mode = 0o777) => FS_mkdir(path, mode),
mkdirTree: (path, mode = 0o777) => FS_mkdirTree(path, mode),
rmdir: (path) => FS.handleError(
withStackSave(() => __wasmfs_rmdir(stringToUTF8OnStack(path)))
),
Expand All @@ -149,11 +149,11 @@ addToLibrary({
var fd = FS.handleError(__wasmfs_open(buffer, flags, mode));
return { fd : fd };
}),
create: (path, mode) => FS_create(path, mode),
create: (path, mode = 0o666) => FS_create(path, mode),
close: (stream) => FS.handleError(-__wasmfs_close(stream.fd)),
unlink: (path) => FS_unlink(path),
chdir: (path) => withStackSave(() => __wasmfs_chdir(stringToUTF8OnStack(path))),
read(stream, buffer, offset, length, position) {
read(stream, buffer, offset, length, position = undefined) {
var seeking = typeof position !== 'undefined';

var dataBuffer = _malloc(length);
Expand All @@ -172,7 +172,7 @@ addToLibrary({
return FS.handleError(bytesRead);
},
// Note that canOwn is an optimization that we ignore for now in WasmFS.
write(stream, buffer, offset, length, position, canOwn) {
write(stream, buffer, offset, length, position = undefined, canOwn = undefined) {
var seeking = typeof position !== 'undefined';

var dataBuffer = _malloc(length);
Expand Down Expand Up @@ -346,7 +346,7 @@ addToLibrary({
wasmFS$backends[backendPointer] = definedOps;
wasmFSDevices[dev] = backendPointer;
},
createDevice(parent, name, input, output) {
createDevice(parent, name, input = undefined, output = undefined) {
if (typeof parent !== 'string') {
// The old API allowed parents to be objects, which do not exist in WasmFS.
throw new Error('Only string paths are accepted');
Expand Down Expand Up @@ -390,7 +390,7 @@ addToLibrary({
return FS.mkdev(path, mode, dev);
},
// mode is an optional argument, which will be set to 0666 if not passed in.
mkdev(path, mode, dev) {
mkdev(path, mode = undefined, dev = undefined) {
if (typeof dev === 'undefined') {
dev = mode;
mode = 0o666;
Expand Down Expand Up @@ -433,7 +433,7 @@ addToLibrary({
// makes sense there (as almost all that FS object ends up needed anyhow all
// the time).

$FS_createDataFile: (parent, name, fileData, canRead, canWrite, canOwn) => {
$FS_createDataFile: (parent, name, fileData = undefined, canRead = undefined, canWrite = undefined, canOwn = undefined) => {
var pathName = name ? parent + '/' + name : parent;
var mode = FS_getMode(canRead, canWrite);

Expand Down Expand Up @@ -490,7 +490,7 @@ addToLibrary({
* @param {number=} mode Optionally, the mode to create in. Uses mkdir's
* default if not set.
*/`,
$FS_mkdirTree: (path, mode) => {
$FS_mkdirTree: (path, mode = 0o777) => {
var dirs = path.split('/');
var d = '';
for (var dir of dirs) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libwebgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ var LibraryGL = {
$miniTempWebGLFloatBuffers: [],
$miniTempWebGLFloatBuffers__postset: `var miniTempWebGLFloatBuffersStorage = new Float32Array({{{ GL_POOL_TEMP_BUFFERS_SIZE }}});
// Create GL_POOL_TEMP_BUFFERS_SIZE+1 temporary buffers, for uploads of size 0 through GL_POOL_TEMP_BUFFERS_SIZE inclusive
for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; ++i) {
for (let i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; ++i) {
miniTempWebGLFloatBuffers[i] = miniTempWebGLFloatBuffersStorage.subarray(0, i);
}`,

$miniTempWebGLIntBuffers: [],
$miniTempWebGLIntBuffers__postset: `var miniTempWebGLIntBuffersStorage = new Int32Array({{{ GL_POOL_TEMP_BUFFERS_SIZE }}});
// Create GL_POOL_TEMP_BUFFERS_SIZE+1 temporary buffers, for uploads of size 0 through GL_POOL_TEMP_BUFFERS_SIZE inclusive
for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; ++i) {
for (let i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; ++i) {
miniTempWebGLIntBuffers[i] = miniTempWebGLIntBuffersStorage.subarray(0, i);
}`,

Expand Down
2 changes: 1 addition & 1 deletion src/lib/libworkerfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ addToLibrary({
}
return root;
},
createNode(parent, name, mode, dev, contents, mtime) {
createNode(parent, name, mode, dev = undefined, contents = undefined, mtime = undefined) {
var node = FS.createNode(parent, name, mode);
node.mode = mode;
node.node_ops = WORKERFS.node_ops;
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_file_preload.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ var asyncLoad = async url => {

var getUniqueRunDependency = id => id;

var FS_preloadFile = async (parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish) => {
var FS_preloadFile = async (parent, name, url, canRead = undefined, canWrite = undefined, dontCreateFile = undefined, canOwn = undefined, 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;
Expand All @@ -659,7 +659,7 @@ var FS_preloadFile = async (parent, name, url, canRead, canWrite, dontCreateFile
}
};

var FS_createPreloadedFile = (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => {
var FS_createPreloadedFile = (parent, name, url, canRead = undefined, canWrite = undefined, onload = undefined, onerror = undefined, dontCreateFile = undefined, canOwn = undefined, preFinish = undefined) => {
FS_preloadFile(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish).then(onload).catch(onerror);
};

Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a.out.js": 272934,
"a.out.js": 272917,
"a.out.nodebug.wasm": 589443,
"total": 862377,
"total": 862360,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
2 changes: 1 addition & 1 deletion test/other/embind_tsgen_ignore_1.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
declare var RuntimeExports: {
FS_createPath: (...args: any[]) => any;
FS_createDataFile: (...args: any[]) => any;
FS_preloadFile: (parent: any, name: any, url: any, canRead: any, canWrite: any, dontCreateFile: any, canOwn: any, preFinish: any) => Promise<void>;
FS_preloadFile: (parent: any, name: any, url: any, canRead?: undefined, canWrite?: undefined, dontCreateFile?: undefined, canOwn?: undefined, preFinish?: undefined) => Promise<void>;
FS_unlink: (...args: any[]) => any;
FS_createLazyFile: (...args: any[]) => any;
FS_createDevice: (...args: any[]) => any;
Expand Down
Loading
Loading