Skip to content
Open
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/Fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
if (!fetchAttrSynchronous) xhr.timeout = timeoutMsecs; // XHR timeout field is only accessible in async XHRs, and must be set after .open() but before .send().
xhr.url_ = url_; // Save the url for debugging purposes (and for comparing to the responseURL that server side advertised)
#if ASSERTIONS && !FETCH_STREAMING
assert(!fetchAttrStreamData, 'Streaming is only supported when FETCH_STREAMING is enabled.');
assert(!fetchAttrStreamData, 'streaming is only supported when FETCH_STREAMING is enabled');
#endif
xhr.responseType = 'arraybuffer';

Expand Down Expand Up @@ -667,7 +667,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
dbg(`fetch: allocating ${ptrLen} bytes in Emscripten heap for xhr data`);
#endif
#if ASSERTIONS
assert(onprogress, 'When doing a streaming fetch, you should have an onprogress handler registered to receive the chunks!');
assert(onprogress, 'streaming fetch requires an onprogress handler');
#endif
// The data pointer malloc()ed here has the same lifetime as the emscripten_fetch_t structure itself has, and is
// freed when emscripten_fetch_close() is called.
Expand Down
4 changes: 2 additions & 2 deletions src/jsifier.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ ${body}
snippet,
(args, body) => `
function(${args}) {
assert(!ENVIRONMENT_IS_WASM_WORKER, "Attempted to call proxied function '${mangled}' in a Wasm Worker, but in Wasm Worker enabled builds, proxied function architecture is not available!");
assert(!ENVIRONMENT_IS_WASM_WORKER, "attempt to call proxied function '${mangled}' from a Wasm Worker (where proxying is not possible)");
${body}
}\n`,
);
Expand Down Expand Up @@ -871,7 +871,7 @@ function(${args}) {
orderedPostSets[j] = temp;
i--;
limit--;
assert(limit > 0, 'Could not sort postsets!');
assert(limit > 0, 'could not sort postsets');
break;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/libasync.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ addToLibrary({

whenDone() {
#if ASSERTIONS
assert(Asyncify.currData, 'Tried to wait for an async operation when none is in progress.');
assert(!Asyncify.asyncPromiseHandlers, 'Cannot have multiple async operations in flight at once');
assert(Asyncify.currData, 'tried to wait for an async operation when none is in progress');
assert(!Asyncify.asyncPromiseHandlers, 'cannot have multiple async operations in flight at once');
#endif
return new Promise((resolve, reject) => {
Asyncify.asyncPromiseHandlers = { resolve, reject };
Expand Down Expand Up @@ -330,7 +330,7 @@ addToLibrary({
// and other async methods for simple examples of usage.
handleSleep(startAsync) {
#if ASSERTIONS
assert(Asyncify.state !== Asyncify.State.Disabled, 'Asyncify cannot be done during or after the runtime exits');
assert(Asyncify.state !== Asyncify.State.Disabled, 'handleSleep called after Asyncify was shut down');
#endif
if (ABORT) return;
#if ASYNCIFY_DEBUG
Expand Down Expand Up @@ -361,7 +361,7 @@ addToLibrary({
// as it might break later operations (we can rewind ok now, but if
// we unwind again, we would unwind through the extra compiled code
// too).
assert(!Asyncify.exportCallStack.length, 'Waking up (starting to rewind) must be done from JS, without compiled code on the stack.');
assert(!Asyncify.exportCallStack.length, 'waking up (starting to rewind) must be done from JS, without compiled code on the stack');
#endif
#if ASYNCIFY_DEBUG
dbg(`ASYNCIFY: start rewind ${Asyncify.currData}`);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ var LibraryBrowser = {
var scrollX = ((typeof window.scrollX != 'undefined') ? window.scrollX : window.pageXOffset);
var scrollY = ((typeof window.scrollY != 'undefined') ? window.scrollY : window.pageYOffset);
#if ASSERTIONS
// If this assert lands, it's likely because the browser doesn't support scrollX or pageXOffset
// If this assert fires, it's likely because the browser doesn't support scrollX or pageXOffset
// and we have no viable fallback.
assert((typeof scrollX != 'undefined') && (typeof scrollY != 'undefined'), 'Unable to retrieve scroll position, mouse positions likely broken.');
assert((typeof scrollX != 'undefined') && (typeof scrollY != 'undefined'), 'unable to retrieve scroll position, mouse positions likely broken');
#endif
var adjustedX = pageX - (scrollX + rect.left);
var adjustedY = pageY - (scrollY + rect.top);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libc_preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ addToLibrary({
function classifyChar(str, idx) {
var cc = str.charCodeAt(idx);
#if ASSERTIONS
assert(!(cc > 127), "Only 7-bit ASCII can be used in preprocessor #if/#ifdef/#define statements!");
assert(!(cc > 127), "only 7-bit ASCII can be used in preprocessor #if/#ifdef/#define statements");
#endif
if (cc > 32) {
if (cc < 48) return 1; // an operator symbol, any of !"#$%&'()*+,-./
Expand Down Expand Up @@ -221,7 +221,7 @@ addToLibrary({
}
// else a number:
#if ASSERTIONS
assert(tokens[i] !== ')', 'Parsing failure, mismatched parentheses in parsing!' + tokens.toString());
assert(tokens[i] !== ')', 'parse failure, mismatched parentheses in parsing' + tokens.toString());
assert(operatorAndPriority == -1);
#endif
var num = Number(tokens[i]);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libccall.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ addToLibrary({
var cArgs = [];
var stack = 0;
#if ASSERTIONS
assert(returnType !== 'array', 'Return type should not be "array".');
assert(returnType !== 'array', 'return type should not be "array"');
#endif
if (args) {
for (var i = 0; i < args.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -1884,7 +1884,7 @@ addToLibrary({
}
#if ASSERTIONS && ASYNCIFY != 2 // With JSPI the function stored in the table will be a wrapper.
/** @suppress {checkTypes} */
assert(wasmTable.get({{{ toIndexType('funcPtr') }}}) == func, 'JavaScript-side Wasm function table mirror is out of date!');
assert(wasmTable.get({{{ toIndexType('funcPtr') }}}) == func, 'table mirror is out of date');
#endif
return func;
},
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libdylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ var LibraryDylink = {
if (dso) {
// the library is being loaded or has been loaded already.
#if ASSERTIONS
assert(dso.exports !== 'loading', `Attempt to load '${libName}' twice before the first load completed`);
assert(dso.exports !== 'loading', `attempt to load '${libName}' a second time, before the first load completed`);
#endif
if (!flags.global) {
if (localScope) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libembind.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ var LibraryEmbind = {
}

#if ASSERTIONS && ASYNCIFY != 2
assert(!isAsync, 'Async bindings are only supported with JSPI.');
assert(!isAsync, 'async bindings are only supported with JSPI');
#endif
var isClassMethodFunc = (argTypes[1] !== null && classType !== null);

Expand Down Expand Up @@ -821,7 +821,7 @@ var LibraryEmbind = {
],
$embind__requireFunction: (signature, rawFunction, isAsync = false) => {
#if ASSERTIONS && ASYNCIFY != 2
assert(!isAsync, 'Async bindings are only supported with JSPI.');
assert(!isAsync, 'async bindings are only supported with JSPI');
#endif

signature = AsciiToString(signature);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libemval.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var LibraryEmVal = {
_emval_decref: (handle) => {
if (handle > {{{ EMVAL_LAST_RESERVED_HANDLE }}} && 0 === --emval_handles[handle + 1]) {
#if ASSERTIONS
assert(emval_handles[handle] !== undefined, `Decref for unallocated handle.`);
assert(emval_handles[handle] !== undefined, `decref for unallocated handle`);
#endif
var value = emval_handles[handle];
emval_handles[handle] = undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libeventloop.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ LibraryJSEventLoop = {
*/`,
$setMainLoop: (iterFunc, fps, simulateInfiniteLoop, arg, noSetTiming) => {
#if ASSERTIONS
assert(!MainLoop.func, 'emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters.');
assert(!MainLoop.func, 'emscripten_set_main_loop: there can only be one main loop function at once')
#endif
MainLoop.func = iterFunc;
MainLoop.arg = arg;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libglfw.js
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ var LibraryGLFW = {
#if ASSERTIONS
// If this assert lands, it's likely because the browser doesn't support scrollX or pageXOffset
// and we have no viable fallback.
assert((typeof scrollX != 'undefined') && (typeof scrollY != 'undefined'), 'Unable to retrieve scroll position, mouse positions likely broken.');
assert((typeof scrollX != 'undefined') && (typeof scrollY != 'undefined'), 'unable to retrieve scroll position, mouse positions likely broken');
#endif
var adjustedX = pageX - (scrollX + rect.left);
var adjustedY = pageY - (scrollY + rect.top);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libhtml5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,7 @@ var LibraryHTML5 = {
emscripten_get_num_gamepads__deps: ['$JSEvents'],
emscripten_get_num_gamepads: () => {
#if ASSERTIONS
assert(JSEvents.lastGamepadState, 'emscripten_get_num_gamepads() can only be called after having first called emscripten_sample_gamepad_data() and that function has returned EMSCRIPTEN_RESULT_SUCCESS!');
assert(JSEvents.lastGamepadState, 'emscripten_get_num_gamepads() called before emscripten_sample_gamepad_data()');
#endif
// N.B. Do not call emscripten_get_num_gamepads() unless having first called emscripten_sample_gamepad_data(), and that has returned EMSCRIPTEN_RESULT_SUCCESS.
// Otherwise the following line will throw an exception.
Expand All @@ -2013,7 +2013,7 @@ var LibraryHTML5 = {
emscripten_get_gamepad_status__deps: ['$JSEvents', '$fillGamepadEventData'],
emscripten_get_gamepad_status: (index, gamepadState) => {
#if ASSERTIONS
assert(JSEvents.lastGamepadState, 'emscripten_get_gamepad_status() can only be called after having first called emscripten_sample_gamepad_data() and that function has returned EMSCRIPTEN_RESULT_SUCCESS!');
assert(JSEvents.lastGamepadState, 'emscripten_get_gamepad_status() called before emscripten_sample_gamepad_data()');
#endif
// INVALID_PARAM is returned on a Gamepad index that never was there.
if (index < 0 || index >= JSEvents.lastGamepadState.length) return {{{ cDefs.EMSCRIPTEN_RESULT_INVALID_PARAM }}};
Expand Down
22 changes: 11 additions & 11 deletions src/lib/libpthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ var LibraryPThread = {

terminateAllThreads: () => {
#if ASSERTIONS
assert(!ENVIRONMENT_IS_PTHREAD, 'Internal Error! terminateAllThreads() can only ever be called from main application thread!');
assert(!ENVIRONMENT_IS_PTHREAD, 'terminateAllThreads() should only be called from the main thread');
#endif
#if PTHREADS_DEBUG
dbg('terminateAllThreads');
Expand All @@ -196,7 +196,7 @@ var LibraryPThread = {

terminateRuntime: () => {
#if ASSERTIONS
assert(!ENVIRONMENT_IS_PTHREAD, 'terminateRuntime() can only ever be called from main application thread!');
assert(!ENVIRONMENT_IS_PTHREAD, 'terminateRuntime() should only be called from the main thread');
#endif
PThread.terminateAllThreads();
var pthread_ptr = _pthread_self();
Expand Down Expand Up @@ -280,7 +280,7 @@ var LibraryPThread = {
if (targetWorker) {
targetWorker.postMessage(d, d.transferList);
} else {
err(`Internal error! Worker sent a message "${cmd}" to target pthread ${d.targetThread}, but that thread no longer exists!`);
err(`worker sent message (${cmd}) to pthread (${d.targetThread}) that no longer exists`);
}
return;
}
Expand Down Expand Up @@ -357,9 +357,9 @@ var LibraryPThread = {
#endif

#if ASSERTIONS
assert(wasmMemory instanceof WebAssembly.Memory, 'WebAssembly memory should have been loaded by now!');
assert(wasmMemory instanceof WebAssembly.Memory, 'wasmMemory should have been loaded by now');
#if !WASM_ESM_INTEGRATION
assert(wasmModule instanceof WebAssembly.Module, 'WebAssembly Module should have been loaded by now!');
assert(wasmModule instanceof WebAssembly.Module, 'wasmModule should have been loaded by now');
#endif
#endif

Expand Down Expand Up @@ -617,8 +617,8 @@ var LibraryPThread = {
dbg(`cleanupThread: ${ptrToString(pthread_ptr)}`)
#endif
#if ASSERTIONS
assert(!ENVIRONMENT_IS_PTHREAD, 'Internal Error! cleanupThread() can only ever be called from main application thread!');
assert(pthread_ptr, 'Internal Error! Null pthread_ptr in cleanupThread!');
assert(!ENVIRONMENT_IS_PTHREAD, 'cleanupThread() should only be called from the main thread');
assert(pthread_ptr, 'null pthread_ptr passed to cleanupThread');
#endif
var worker = PThread.pthreads[pthread_ptr];
#if MAIN_MODULE
Expand Down Expand Up @@ -675,8 +675,8 @@ var LibraryPThread = {

$spawnThread: (threadParams) => {
#if ASSERTIONS
assert(!ENVIRONMENT_IS_PTHREAD, 'Internal Error! spawnThread() can only ever be called from main application thread!');
assert(threadParams.pthread_ptr, 'Internal error, no pthread ptr!');
assert(!ENVIRONMENT_IS_PTHREAD, 'spawnThread() should only be called from the main thread');
assert(threadParams.pthread_ptr, 'spawnThread called with null pthread ptr');
#endif

var worker = PThread.getNewWorker();
Expand All @@ -685,7 +685,7 @@ var LibraryPThread = {
return {{{ cDefs.EAGAIN }}};
}
#if ASSERTIONS
assert(!worker.pthread_ptr, 'Internal error!');
assert(!worker.pthread_ptr);
#endif

PThread.runningWorkers.push(worker);
Expand Down Expand Up @@ -1206,7 +1206,7 @@ var LibraryPThread = {
dbg("dlsyncThreadsAsync caller=" + ptrToString(caller));
#endif
#if ASSERTIONS
assert(!ENVIRONMENT_IS_PTHREAD, 'Internal Error! dlsyncThreadsAsync() can only ever be called from main thread');
assert(!ENVIRONMENT_IS_PTHREAD, 'dlsyncThreadsAsync() should only be called from the main thread');
assert(Object.keys(PThread.outstandingPromises).length === 0);
#endif

Expand Down
14 changes: 7 additions & 7 deletions src/lib/libstrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ addToLibrary({
$stringToUTF8__deps: ['$stringToUTF8Array'],
$stringToUTF8: (str, outPtr, maxBytesToWrite) => {
#if ASSERTIONS
assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
assert(typeof maxBytesToWrite == 'number', 'stringToUTF8 requires a third parameter that specifies the length of the output buffer');
#endif
return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
},
Expand Down Expand Up @@ -313,7 +313,7 @@ addToLibrary({
$UTF16ToString__deps: ['$UTF16Decoder', '$findStringEnd'],
$UTF16ToString: (ptr, maxBytesToRead, ignoreNul) => {
#if ASSERTIONS
assert(ptr % 2 == 0, 'Pointer passed to UTF16ToString must be aligned to two bytes!');
assert(ptr % 2 == 0, 'pointer passed to UTF16ToString must be 2-byte aligned');
#endif
var idx = {{{ getHeapOffset('ptr', 'u16') }}};
var endIdx = findStringEnd(HEAPU16, idx, maxBytesToRead / 2, ignoreNul);
Expand Down Expand Up @@ -359,10 +359,10 @@ addToLibrary({
// Returns the number of bytes written, EXCLUDING the null terminator.
$stringToUTF16: (str, outPtr, maxBytesToWrite) => {
#if ASSERTIONS
assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!');
assert(outPtr % 2 == 0, 'pointer passed to stringToUTF16 must be 2-byte aligned');
#endif
#if ASSERTIONS
assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
assert(typeof maxBytesToWrite == 'number', 'stringToUTF16 requires a third parameter that specifies the length of the output buffer');
#endif
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
maxBytesToWrite ??= 0x7FFFFFFF;
Expand All @@ -387,7 +387,7 @@ addToLibrary({

$UTF32ToString: (ptr, maxBytesToRead, ignoreNul) => {
#if ASSERTIONS
assert(ptr % 4 == 0, 'Pointer passed to UTF32ToString must be aligned to four bytes!');
assert(ptr % 4 == 0, 'pointer passed to UTF32ToString must be 2-byte aligned');
#endif
var str = '';
var startIdx = {{{ getHeapOffset('ptr', 'u32') }}};
Expand Down Expand Up @@ -421,10 +421,10 @@ addToLibrary({
outPtr >>>= 0;
#endif
#if ASSERTIONS
assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!');
assert(outPtr % 4 == 0, 'pointer passed to stringToUTF32 must be 4-byte aligned');
#endif
#if ASSERTIONS
assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
assert(typeof maxBytesToWrite == 'number', 'stringToUTF32 requires a third parameter that specifies the length of the output buffer');
#endif
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
maxBytesToWrite ??= 0x7FFFFFFF;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/libwasm_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ if (ENVIRONMENT_IS_WASM_WORKER

emscripten_terminate_wasm_worker: (id) => {
#if ASSERTIONS
assert(id != 0, 'emscripten_terminate_wasm_worker() cannot be called with id=0!');
assert(id != 0, 'emscripten_terminate_wasm_worker() cannot be called with id=0');
#endif
if (_wasmWorkers[id]) {
_wasmWorkers[id].terminate();
Expand All @@ -244,7 +244,7 @@ if (ENVIRONMENT_IS_WASM_WORKER

emscripten_terminate_all_wasm_workers: () => {
#if ASSERTIONS
assert(!ENVIRONMENT_IS_WASM_WORKER, 'emscripten_terminate_all_wasm_workers() cannot be called from a Wasm Worker: only the main browser thread has visibility to terminate all Workers!');
assert(!ENVIRONMENT_IS_WASM_WORKER, 'emscripten_terminate_all_wasm_workers() should only be called from the main thread');
#endif
Object.values(_wasmWorkers).forEach((worker) => worker.terminate());
_wasmWorkers = {};
Expand Down Expand Up @@ -282,7 +282,7 @@ if (ENVIRONMENT_IS_WASM_WORKER
assert(id >= 0);
assert(funcPtr);
assert(sigPtr);
assert(UTF8ToString(sigPtr)[0] != 'v', 'Do NOT specify the return argument in the signature string for a call to emscripten_wasm_worker_post_function_sig(), just pass the function arguments.');
assert(UTF8ToString(sigPtr)[0] != 'v', 'emscripten_wasm_worker_post_function_sig() supports only void return type');
assert(varargs);
#endif
_wasmWorkers[id].postMessage({'_wsc': funcPtr, 'x': readEmAsmArgs(sigPtr, varargs) });
Expand Down
Loading
Loading