Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use single quotes in JS code where possible. NFC
Browse files Browse the repository at this point in the history
sbc100 committed Jan 22, 2024
1 parent dcdbc8a commit a8fac76
Showing 7 changed files with 22 additions and 19 deletions.
3 changes: 3 additions & 0 deletions src/jsifier.js
Original file line number Diff line number Diff line change
@@ -461,6 +461,9 @@ function(${args}) {
}
}
} else if (typeof snippet == 'object') {
if (typeof snippet == 'object') {
console.error(snippet);
}
snippet = stringifyWithFunctions(snippet);
addImplicitDeps(snippet, deps);
} else if (typeof snippet == 'function') {
6 changes: 3 additions & 3 deletions src/library.js
Original file line number Diff line number Diff line change
@@ -2187,9 +2187,9 @@ addToLibrary({
#endif // ENVIRONMENT_MAY_BE_NODE
// we couldn't find a proper implementation, as Math.random() is not suitable for /dev/random, see emscripten-core/emscripten/pull/7096
#if ASSERTIONS
abort("no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: (array) => { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };");
abort('no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: (array) => { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };');
#else
abort("initRandomDevice");
abort('initRandomDevice');
#endif
},

@@ -3198,7 +3198,7 @@ addToLibrary({
#endif
}
#if ASSERTIONS && ASYNCIFY != 2 // With JSPI the function stored in the table will be a wrapper.
assert(wasmTable.get(funcPtr) == func, "JavaScript-side Wasm function table mirror is out of date!");
assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
#endif
return func;
},
2 changes: 1 addition & 1 deletion src/library_fs.js
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ addToLibrary({
$FS__postset: function() {
// TODO: do we need noFSInit?
addAtInit(`
if (!Module["noFSInit"] && !FS.init.initialized)
if (!Module['noFSInit'] && !FS.init.initialized)
FS.init();
FS.ignorePermissions = false;
`)
14 changes: 7 additions & 7 deletions src/preamble.js
Original file line number Diff line number Diff line change
@@ -95,13 +95,13 @@ function assert(condition, text) {
// builds with assertions.
#if !hasExportedSymbol('malloc')
function _malloc() {
abort("malloc() called but not included in the build - add '_malloc' to EXPORTED_FUNCTIONS");
abort('malloc() called but not included in the build - add `_malloc` to EXPORTED_FUNCTIONS');
}
#endif // malloc
#if !hasExportedSymbol('free')
function _free() {
// Show a helpful error since we used to include free by default in the past.
abort("free() called but not included in the build - add '_free' to EXPORTED_FUNCTIONS");
abort('free() called but not included in the build - add `_free` to EXPORTED_FUNCTIONS');
}
#endif // free
#endif // ASSERTIONS
@@ -641,9 +641,9 @@ function getBinarySync(file) {
return readBinary(file);
}
#if WASM_ASYNC_COMPILATION
throw "both async and sync fetching of the wasm failed";
throw 'both async and sync fetching of the wasm failed';
#else
throw "sync fetching of the wasm failed: you can preload it to Module['wasmBinary'] manually, or emcc.py will do that for you when generating HTML (but not JS)";
throw 'sync fetching of the wasm failed: you can preload it to Module["wasmBinary"] manually, or emcc.py will do that for you when generating HTML (but not JS)';
#endif
}

@@ -666,7 +666,7 @@ function getBinaryPromise(binaryFile) {
) {
return fetch(binaryFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}).then((response) => {
if (!response['ok']) {
throw "failed to load wasm binary file at '" + binaryFile + "'";
throw `failed to load wasm binary file at '${binaryFile}'`;
}
return response['arrayBuffer']();
}).catch(() => getBinarySync(binaryFile));
@@ -982,7 +982,7 @@ function createWasm() {
wasmMemory = wasmExports['memory'];
{{{ receivedSymbol('wasmMemory') }}}
#if ASSERTIONS
assert(wasmMemory, "memory not found in wasm exports");
assert(wasmMemory, 'memory not found in wasm exports');
// This assertion doesn't hold when emscripten is run in --post-link
// mode.
// TODO(sbc): Read INITIAL_MEMORY out of the wasm file in post-link mode.
@@ -998,7 +998,7 @@ function createWasm() {
wasmTable = wasmExports['__indirect_function_table'];
{{{ receivedSymbol('wasmTable') }}}
#if ASSERTIONS && !PURE_WASI
assert(wasmTable, "table not found in wasm exports");
assert(wasmTable, 'table not found in wasm exports');
#endif

#if AUDIO_WORKLET
10 changes: 5 additions & 5 deletions src/shell.js
Original file line number Diff line number Diff line change
@@ -382,7 +382,7 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
if (scriptDirectory.startsWith('blob:')) {
scriptDirectory = '';
} else {
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/')+1);
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, '').lastIndexOf('/')+1);
}

#if ENVIRONMENT && ASSERTIONS
@@ -492,19 +492,19 @@ assert(
#endif // PTHREADS

#if !ENVIRONMENT_MAY_BE_WEB
assert(!ENVIRONMENT_IS_WEB, "web environment detected but not enabled at build time. Add 'web' to `-sENVIRONMENT` to enable.");
assert(!ENVIRONMENT_IS_WEB, 'web environment detected but not enabled at build time. Add `web` to `-sENVIRONMENT` to enable.');
#endif

#if !ENVIRONMENT_MAY_BE_WORKER
assert(!ENVIRONMENT_IS_WORKER, "worker environment detected but not enabled at build time. Add 'worker' to `-sENVIRONMENT` to enable.");
assert(!ENVIRONMENT_IS_WORKER, 'worker environment detected but not enabled at build time. Add `worker` to `-sENVIRONMENT` to enable.');
#endif

#if !ENVIRONMENT_MAY_BE_NODE
assert(!ENVIRONMENT_IS_NODE, "node environment detected but not enabled at build time. Add 'node' to `-sENVIRONMENT` to enable.");
assert(!ENVIRONMENT_IS_NODE, 'node environment detected but not enabled at build time. Add `node` to `-sENVIRONMENT` to enable.');
#endif

#if !ENVIRONMENT_MAY_BE_SHELL
assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");
assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.');
#endif

#endif // ASSERTIONS
4 changes: 2 additions & 2 deletions test/test_other.py
Original file line number Diff line number Diff line change
@@ -12087,8 +12087,8 @@ def test_missing_malloc_export(self):
}
''')
self.do_runf('unincluded_malloc.c', (
"malloc() called but not included in the build - add '_malloc' to EXPORTED_FUNCTIONS",
"free() called but not included in the build - add '_free' to EXPORTED_FUNCTIONS"))
'malloc() called but not included in the build - add `_malloc` to EXPORTED_FUNCTIONS',
'free() called but not included in the build - add `_free` to EXPORTED_FUNCTIONS'), assert_all=True)

def test_getrusage(self):
self.do_runf('other/test_getrusage.c')
2 changes: 1 addition & 1 deletion tools/emscripten.py
Original file line number Diff line number Diff line change
@@ -801,7 +801,7 @@ def install_wrapper(sym):
args = ', '.join(args)
wrapper += f"({args}) => ({mangled} = {exported}wasmExports['{name}'])({args});"
else:
wrapper += 'wasmExports["%s"]' % name
wrapper += f"wasmExports['{name}']"

wrappers.append(wrapper)
return wrappers

0 comments on commit a8fac76

Please sign in to comment.