Skip to content

Commit 7dd0263

Browse files
BridgeJS: Use shared decodeString for JSTypedClosure error path (swiftwasm#696)
1 parent ba66ff1 commit 7dd0263

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ public struct BridgeJSLink {
660660
helperPrinter.write("let length = 0;")
661661
helperPrinter.write("while (bytes[length] !== 0) { length += 1; }")
662662
helperPrinter.write(
663-
"const fileID = \(JSGlueVariableScope.reservedTextDecoder).decode(bytes.subarray(0, length));"
663+
"const fileID = \(JSGlueVariableScope.reservedDecodeString)(state.file, length);"
664664
)
665665
helperPrinter.write(
666666
"throw new Error(`Attempted to call a released JSTypedClosure created at ${fileID}:${state.line}`);"

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export async function createInstantiator(options, swift) {
7070
const bytes = new Uint8Array(memory.buffer, state.file);
7171
let length = 0;
7272
while (bytes[length] !== 0) { length += 1; }
73-
const fileID = textDecoder.decode(bytes.subarray(0, length));
73+
const fileID = decodeString(state.file, length);
7474
throw new Error(`Attempted to call a released JSTypedClosure created at ${fileID}:${state.line}`);
7575
}
7676
return func(...args);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function createInstantiator(options, swift) {
4040
const bytes = new Uint8Array(memory.buffer, state.file);
4141
let length = 0;
4242
while (bytes[length] !== 0) { length += 1; }
43-
const fileID = textDecoder.decode(bytes.subarray(0, length));
43+
const fileID = decodeString(state.file, length);
4444
throw new Error(`Attempted to call a released JSTypedClosure created at ${fileID}:${state.line}`);
4545
}
4646
return func(...args);

0 commit comments

Comments
 (0)