diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 7f4ecab03..8f1c84622 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -346,7 +346,6 @@ public struct BridgeJSLink { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -361,8 +360,6 @@ public struct BridgeJSLink { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) @@ -487,7 +484,7 @@ public struct BridgeJSLink { "let \(JSGlueVariableScope.reservedDecodeString);", "let \(JSGlueVariableScope.reservedDecodeUTF8);", "const \(JSGlueVariableScope.reservedImmortalStrings) = new Map();", - "const \(JSGlueVariableScope.reservedTextDecoder) = new TextDecoder(\"utf-8\");", + "const \(JSGlueVariableScope.reservedTextDecoder) = new TextDecoder(\"utf-8\", { ignoreBOM: true });", "const \(JSGlueVariableScope.reservedTextEncoder) = new TextEncoder(\"utf-8\");", "let \(JSGlueVariableScope.reservedStorageToReturnString);", "let \(JSGlueVariableScope.reservedStorageToReturnBytes);", diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/StringDecoderTests.mjs b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/StringDecoderTests.mjs index 2aa88cf5d..73299ddc0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/StringDecoderTests.mjs +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/StringDecoderTests.mjs @@ -6,7 +6,6 @@ const source = await readFile(process.argv[2] ?? new URL('../__Snapshots__/Bridg const shared = process.argv[3] === 'shared'; const { createInstantiator } = await import(`data:text/javascript;base64,${Buffer.from(source).toString('base64')}`); const encoder = new TextEncoder(); -const decoder = new TextDecoder(); const swift = { memory: { heap: [], retain: (value) => value } }; const bridge = await createInstantiator({ getImports: () => ({}) }, swift); const imports = {}; @@ -35,21 +34,27 @@ function large(value, immortal = false, ptr = 64) { } const values = ['', 'div', 'abcdefgh', 'abcdefghi', 'abcdefghij', 'abcdefé', 'abcdefgé', 'abcdefghé', 'abcdefghié', 'abc€', 'abcdefg€', 'abc😄', 'abcdef😄', 'abcdefg😄', - 'a\0b', '\ufeff', '\ufeffx', 'x\ufeff', '\ufeff\ufeffx', '\ufeffabcdefghijk', - 'abc\ufeffdefghijk', '\ufeff\ufeffabcdefghijk']; -for (const value of values) { - const expected = decoder.decode(encoder.encode(value)); + '😄😄', 'éééé', 'a\0b', '\ufeff', '\ufeffx', '\ufeffabcde', '\ufeffabcdef', + 'x\ufeff', '\ufeff\ufeffx', '\ufeffabcdefghijk', + 'abc\ufeffdefghijk', '\ufeff\ufeffabcdefghijk', + // UTF-8 widths, the surrogate gap, and supplementary-plane boundaries. + '\u0080', '\u07ff', '\u0800', '\ud7ff', '\ue000', '\uffff', '\u{10000}', '\u{10ffff}']; +for (const [index, value] of values.entries()) { if (encoder.encode(value).length <= 8) { words = small(value); - assert.equal(exports.checkString(), expected); + assert.equal(exports.checkString(), value); + } + for (const immortal of [false, true]) { + // Distinct locations keep immortal cache entries faithful to Swift literals. + words = large(value, immortal, 64 + index * 64); + assert.equal(exports.checkString(), value); + assert.equal(exports.checkString(), value); } - words = large(value); - assert.equal(exports.checkString(), expected); } // Alternate full and short inputs: bytes outside count must never leak into the result. for (const value of ['abcd😄', 'é', 'abcde€', '\ufeff', 'abcdefgh', '', 'x\0', '€', '\ufeff\ufeff']) { words = small(value); - assert.equal(exports.checkString(), decoder.decode(encoder.encode(value))); + assert.equal(exports.checkString(), value); } // Every ASCII byte, including NUL, at every small-string length. for (let byte = 0; byte < 128; byte++) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js index 422e26dd9..b434d4e5e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js @@ -17,7 +17,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -706,7 +706,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -721,8 +720,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js index 5a7dc255e..d4174627e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -318,7 +318,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -333,8 +332,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js index bb61c4fb5..f4c519fe9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js @@ -24,7 +24,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -768,7 +768,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -783,8 +782,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js index b657a2188..33c4ff195 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js @@ -21,7 +21,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -752,7 +752,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -767,8 +766,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.js index d16d071b7..099a0756e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.js @@ -18,7 +18,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -398,7 +398,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -413,8 +412,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js index cc7b29f42..5b2a085ac 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -530,7 +530,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -545,8 +544,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js index 406c5da24..7a265486b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -426,7 +426,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -441,8 +440,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ClassWithNestedTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ClassWithNestedTypes.js index 3d0a66cc3..1d7ebeabf 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ClassWithNestedTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ClassWithNestedTypes.js @@ -16,7 +16,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -267,7 +267,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -282,8 +281,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index 35417c66b..03afa8031 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -17,7 +17,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -645,7 +645,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -660,8 +659,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js index 1b796f0de..10f84209a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -620,7 +620,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -635,8 +634,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.js index 0dae550a8..902f06ff9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.js @@ -17,7 +17,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -284,7 +284,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -299,8 +298,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js index 897f9e772..3ff888129 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -243,7 +243,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -258,8 +257,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js index afe2e8ac7..3f0c005f2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js @@ -92,7 +92,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -1205,7 +1205,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -1220,8 +1219,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.js index 4b71ac219..0d770ed41 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.js @@ -18,7 +18,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -329,7 +329,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -344,8 +343,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js index e87881f55..999d1847f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js @@ -35,7 +35,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -259,7 +259,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -274,8 +273,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCaseImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCaseImport.js index c816b3bf0..3a78dd143 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCaseImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCaseImport.js @@ -16,7 +16,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -267,7 +267,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -282,8 +281,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js index f744a43f3..b838f4c96 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js @@ -55,7 +55,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -299,7 +299,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -314,8 +313,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js index e43b2bcb9..929f55c86 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js @@ -36,7 +36,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -280,7 +280,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -295,8 +294,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js index fd3640162..ce8d4ed42 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js @@ -86,7 +86,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -673,7 +673,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -688,8 +687,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionNestedTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionNestedTypes.js index 53690ed6a..1b54d416e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionNestedTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionNestedTypes.js @@ -27,7 +27,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -328,7 +328,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -343,8 +342,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionOrderIndependence.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionOrderIndependence.js index e5a43fdc2..cda13ba4c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionOrderIndependence.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionOrderIndependence.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -270,7 +270,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -285,8 +284,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionScopeParity.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionScopeParity.js index 5312f0fbd..d0d1ea8bd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionScopeParity.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ExtensionScopeParity.js @@ -15,7 +15,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -270,7 +270,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -285,8 +284,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js index af7fa150c..50d25d09b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -308,7 +308,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -323,8 +322,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GenericImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GenericImports.js index e2f71f878..49aaa5798 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GenericImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GenericImports.js @@ -27,7 +27,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -966,7 +966,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -981,8 +980,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js index 77dcf0f7a..1d299cab4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -253,7 +253,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -268,8 +267,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js index c5c7221d0..8c3f0b5b4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -278,7 +278,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -293,8 +292,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js index f33437e89..cc70a978a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -250,7 +250,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -265,8 +264,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js index 43901d4a2..b9b854e52 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -250,7 +250,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -265,8 +264,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js index 43901d4a2..b9b854e52 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -250,7 +250,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -265,8 +264,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js index 893402b07..a3e0fd6d3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -603,7 +603,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -618,8 +617,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js index 69a851251..4bfce3e14 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -615,7 +615,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -630,8 +629,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js index 8909352ce..edcedc1b7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -416,7 +416,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -431,8 +430,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js index 0c0f030f7..cbec50c8f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -315,7 +315,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -330,8 +329,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js index f730efb98..9cbaf2a3e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -298,7 +298,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -313,8 +312,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportBareModule.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportBareModule.js index 23a5b1635..50ed98d9a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportBareModule.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportBareModule.js @@ -17,7 +17,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -323,7 +323,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -338,8 +337,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportBareModuleFallback.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportBareModuleFallback.js index 55ef14aa6..ca94e5a13 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportBareModuleFallback.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportBareModuleFallback.js @@ -14,7 +14,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -267,7 +267,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -282,8 +281,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportModule.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportModule.js index 589f570cf..af4273cc3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportModule.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSImportModule.js @@ -14,7 +14,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -307,7 +307,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -322,8 +321,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSNameOverride.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSNameOverride.js index 16219c83c..0190b9c65 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSNameOverride.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSNameOverride.js @@ -16,7 +16,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -272,7 +272,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -287,8 +286,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSNameTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSNameTypes.js index ad3e9096e..107f497fc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSNameTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSNameTypes.js @@ -16,7 +16,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -248,7 +248,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -263,8 +262,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSTypedArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSTypedArrayTypes.js index f1ffa766f..9d03440f5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSTypedArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSTypedArrayTypes.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -234,7 +234,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -249,8 +248,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js index 99742f97b..07d7ba167 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -591,7 +591,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -606,8 +605,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js index bed72152c..964b97e3a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -242,7 +242,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -257,8 +256,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js index 75697b834..d8eee50de 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -250,7 +250,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -265,8 +264,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js index c6f2fdffa..359f5ddd9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -242,7 +242,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -257,8 +256,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NamespacedClassSignature.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NamespacedClassSignature.js index 79519e8f1..1d6b6c343 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NamespacedClassSignature.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NamespacedClassSignature.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -294,7 +294,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -309,8 +308,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js index 2e2667caa..a5f6d34f4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -589,7 +589,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -604,8 +603,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js index 33d18909a..b13010601 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -589,7 +589,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -604,8 +603,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js index f46e610cd..82710d04b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -286,7 +286,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -301,8 +300,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedTypeNameCollision.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedTypeNameCollision.js index 332fc4e42..541ad55df 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedTypeNameCollision.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedTypeNameCollision.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -270,7 +270,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -285,8 +284,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js index 57c49fd4c..fb8018c44 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -871,7 +871,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -886,8 +885,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js index a25de5e29..3b8c9adbc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -243,7 +243,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -258,8 +257,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js index 2a92af613..1177dc82b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -254,7 +254,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -269,8 +268,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js index 39677e821..44eab0d15 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -242,7 +242,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -257,8 +256,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js index 192e93d8e..96f132fda 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js @@ -35,7 +35,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -941,7 +941,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -956,8 +955,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js index aab8103f5..d6fa6f143 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -388,7 +388,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -403,8 +402,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/RelativeQualifiedTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/RelativeQualifiedTypes.js index a1b8f290c..06af75757 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/RelativeQualifiedTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/RelativeQualifiedTypes.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -325,7 +325,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -340,8 +339,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js index 338cf237d..4cc10e4b9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js @@ -22,7 +22,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -287,7 +287,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -302,8 +301,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js index e474c82a6..b9c8414b0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js @@ -22,7 +22,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -287,7 +287,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -302,8 +301,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js index eb1b2d2ef..7eff82661 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js @@ -16,7 +16,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -248,7 +248,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -263,8 +262,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js index 95470ed56..f8aa35927 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js @@ -16,7 +16,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -248,7 +248,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -263,8 +262,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js index c76381468..6dc173b63 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -252,7 +252,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -267,8 +266,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js index 0a0fc1650..eb4e4c37b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -245,7 +245,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -260,8 +259,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StructWithNestedTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StructWithNestedTypes.js index 7c189df7e..f9b50f9f8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StructWithNestedTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StructWithNestedTypes.js @@ -26,7 +26,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -322,7 +322,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -337,8 +336,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js index 293ea56da..e171064a6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -270,7 +270,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -285,8 +284,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index dabb7595f..928cc44a0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -41,7 +41,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -1587,7 +1587,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -1602,8 +1601,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js index 0a6690be9..c47a65b6b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -509,7 +509,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -524,8 +523,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js index e336f8911..54aa63d69 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js @@ -16,7 +16,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -804,7 +804,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -819,8 +818,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js index ff953c9a3..2ebef1501 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -607,7 +607,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -622,8 +621,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftTypedClosureAccess.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftTypedClosureAccess.js index 8cec87d6e..80e2a1984 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftTypedClosureAccess.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftTypedClosureAccess.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -352,7 +352,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -367,8 +366,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js index 40bf7e8c2..5a575ffed 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -234,7 +234,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -249,8 +248,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js index 435415b0f..ef00d53a6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -259,7 +259,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -274,8 +273,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js index ce27ff522..5abfccc3f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js @@ -11,7 +11,7 @@ export async function createInstantiator(options, swift) { let decodeString; let decodeUTF8; const immortalStrings = new Map(); - const textDecoder = new TextDecoder("utf-8"); + const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); const textEncoder = new TextEncoder("utf-8"); let tmpRetString; let tmpRetBytes; @@ -243,7 +243,6 @@ export async function createInstantiator(options, swift) { u6 = 0, u7 = 0; while (byteIndex < count) { - const start = byteIndex; const b0 = byteAt(word0, word1, byteIndex++); let codePoint; if (b0 < 128) codePoint = b0; @@ -258,8 +257,6 @@ export async function createInstantiator(options, swift) { b3 = byteAt(word0, word1, byteIndex++); codePoint = ((b0 & 7) << 18) | ((b1 & 63) << 12) | ((b2 & 63) << 6) | (b3 & 63); } - // Match TextDecoder: consume exactly one leading UTF-8 BOM. - if (start === 0 && codePoint === 0xfeff) continue; const supplementary = codePoint > 0xffff; const codeUnit = supplementary ? 0xd800 + ((codePoint - 0x10000) >>> 10) diff --git a/Tests/BridgeJSRuntimeTests/JavaScript/StringABITests.mjs b/Tests/BridgeJSRuntimeTests/JavaScript/StringABITests.mjs index 8468e1faf..1ff321261 100644 --- a/Tests/BridgeJSRuntimeTests/JavaScript/StringABITests.mjs +++ b/Tests/BridgeJSRuntimeTests/JavaScript/StringABITests.mjs @@ -38,16 +38,15 @@ export function runJsStringABITests(rootExports) { assert.equal(exports.immortalSubstring(), immortal.slice(10)); assert.equal(exports.optionalNone(), null); assert.equal(exports.optionalSome(), immortal); - const expected = samples.map((s) => s.startsWith("\ufeff") ? s.slice(1) : s); for (let i = 0; i < samples.length; i++) { - assert.equal(exports.echo(samples[i]), expected[i]); - assert.equal(exports.echoOptional(samples[i]), expected[i]); + assert.equal(exports.echo(samples[i]), samples[i]); + assert.equal(exports.echoOptional(samples[i]), samples[i]); } - assert.deepEqual(exports.echoArray(samples), expected); + assert.deepEqual(exports.echoArray(samples), samples); } const samples = [ "abcdefé", "abcdefgé", "abcdefghé", "abcdefghié", "abc€", "abcdefg€", - "abc😄", "abcdef😄", "abcdefg😄", "a\0b", "\ufeffx", "x\ufeff", + "abc😄", "abcdef😄", "abcdefg😄", "a\0b", "\ufeff", "\ufeffx", "\ufeffabcde", "\ufeffabcdef", "x\ufeff", "\ufeff\ufeffx", "\ufeffabcdefghijk", "abc\ufeffdefghijk", "\ufeff\ufeffabcdefghijk", ]; diff --git a/Tests/BridgeJSRuntimeTests/StringABITests.swift b/Tests/BridgeJSRuntimeTests/StringABITests.swift index c3f424011..5d2cae9b0 100644 --- a/Tests/BridgeJSRuntimeTests/StringABITests.swift +++ b/Tests/BridgeJSRuntimeTests/StringABITests.swift @@ -43,15 +43,14 @@ final class StringABITests: XCTestCase { let samples = [ "abcdefé", "abcdefgé", "abcdefghé", "abcdefghié", "abc€", "abcdefg€", "abc😄", "abcdef😄", "abcdefg😄", "a\0b", - "\u{FEFF}x", "x\u{FEFF}", "\u{FEFF}\u{FEFF}x", + "\u{FEFF}", "\u{FEFF}x", "\u{FEFF}abcde", "\u{FEFF}abcdef", "x\u{FEFF}", "\u{FEFF}\u{FEFF}x", "\u{FEFF}abcdefghijk", "abc\u{FEFF}defghijk", "\u{FEFF}\u{FEFF}abcdefghijk", ] - let expected = samples.map { $0.first == "\u{FEFF}" ? String($0.dropFirst()) : $0 } - for (input, output) in zip(samples, expected) { - try XCTAssertEqual(StringABIImports.jsEcho(input), output) - try XCTAssertEqual(StringABIImports.jsEchoOptional(input), output) + for input in samples { + try XCTAssertEqual(StringABIImports.jsEcho(input), input) + try XCTAssertEqual(StringABIImports.jsEchoOptional(input), input) } - try XCTAssertEqual(StringABIImports.jsEchoArray(samples), expected) + try XCTAssertEqual(StringABIImports.jsEchoArray(samples), samples) } func testImportEchoesSmallStrings() throws {