From 516fb9d452057ae0083541df346bb9d21e1c47a0 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 5 Feb 2026 19:00:44 +0900 Subject: [PATCH] BridgeJS: Make Stack ABI storage direction agnostic --- .../Sources/BridgeJSLink/BridgeJSLink.swift | 36 +- .../Sources/BridgeJSLink/JSGlueGen.swift | 160 ++++---- .../BridgeJSLinkTests/ArrayTypes.js | 328 ++++++++------- .../__Snapshots__/BridgeJSLinkTests/Async.js | 36 +- .../BridgeJSLinkTests/DefaultParameters.js | 104 +++-- .../BridgeJSLinkTests/EnumAssociatedValue.js | 378 +++++++++--------- .../BridgeJSLinkTests/EnumCase.js | 36 +- .../BridgeJSLinkTests/EnumNamespace.Global.js | 36 +- .../BridgeJSLinkTests/EnumNamespace.js | 36 +- .../BridgeJSLinkTests/EnumRawType.js | 36 +- .../BridgeJSLinkTests/GlobalGetter.js | 36 +- .../BridgeJSLinkTests/GlobalThisImports.js | 36 +- .../BridgeJSLinkTests/ImportArray.js | 48 +-- .../ImportedTypeInExportedInterface.js | 72 ++-- .../BridgeJSLinkTests/InvalidPropertyNames.js | 36 +- .../BridgeJSLinkTests/JSClass.js | 36 +- .../JSClassStaticFunctions.js | 36 +- .../BridgeJSLinkTests/JSValue.js | 134 +++---- .../BridgeJSLinkTests/MixedGlobal.js | 36 +- .../BridgeJSLinkTests/MixedModules.js | 36 +- .../BridgeJSLinkTests/MixedPrivate.js | 36 +- .../BridgeJSLinkTests/Namespaces.Global.js | 36 +- .../BridgeJSLinkTests/Namespaces.js | 36 +- .../BridgeJSLinkTests/Optionals.js | 36 +- .../BridgeJSLinkTests/PrimitiveParameters.js | 36 +- .../BridgeJSLinkTests/PrimitiveReturn.js | 36 +- .../BridgeJSLinkTests/PropertyTypes.js | 36 +- .../BridgeJSLinkTests/Protocol.js | 66 ++- .../StaticFunctions.Global.js | 48 +-- .../BridgeJSLinkTests/StaticFunctions.js | 48 +-- .../StaticProperties.Global.js | 36 +- .../BridgeJSLinkTests/StaticProperties.js | 36 +- .../BridgeJSLinkTests/StringParameter.js | 36 +- .../BridgeJSLinkTests/StringReturn.js | 36 +- .../BridgeJSLinkTests/SwiftClass.js | 36 +- .../BridgeJSLinkTests/SwiftClosure.js | 58 ++- .../BridgeJSLinkTests/SwiftClosureImports.js | 36 +- .../BridgeJSLinkTests/SwiftStruct.js | 156 ++++---- .../BridgeJSLinkTests/SwiftStructImports.js | 44 +- .../__Snapshots__/BridgeJSLinkTests/Throws.js | 36 +- .../BridgeJSLinkTests/UnsafePointer.js | 56 ++- .../VoidParameterVoidReturn.js | 36 +- 42 files changed, 1268 insertions(+), 1440 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index af6961711..9689f708d 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -246,16 +246,12 @@ public struct BridgeJSLink { "let \(JSGlueVariableScope.reservedStorageToReturnOptionalFloat);", "let \(JSGlueVariableScope.reservedStorageToReturnOptionalDouble);", "let \(JSGlueVariableScope.reservedStorageToReturnOptionalHeapObject);", - "let \(JSGlueVariableScope.reservedTmpRetTag) = [];", - "let \(JSGlueVariableScope.reservedTmpRetStrings) = [];", - "let \(JSGlueVariableScope.reservedTmpRetInts) = [];", - "let \(JSGlueVariableScope.reservedTmpRetF32s) = [];", - "let \(JSGlueVariableScope.reservedTmpRetF64s) = [];", - "let \(JSGlueVariableScope.reservedTmpParamInts) = [];", - "let \(JSGlueVariableScope.reservedTmpParamF32s) = [];", - "let \(JSGlueVariableScope.reservedTmpParamF64s) = [];", - "let \(JSGlueVariableScope.reservedTmpRetPointers) = [];", - "let \(JSGlueVariableScope.reservedTmpParamPointers) = [];", + "let \(JSGlueVariableScope.reservedTagStack) = [];", + "let \(JSGlueVariableScope.reservedStringStack) = [];", + "let \(JSGlueVariableScope.reservedI32Stack) = [];", + "let \(JSGlueVariableScope.reservedF32Stack) = [];", + "let \(JSGlueVariableScope.reservedF64Stack) = [];", + "let \(JSGlueVariableScope.reservedPointerStack) = [];", "let \(JSGlueVariableScope.reservedTmpStructCleanups) = [];", "const \(JSGlueVariableScope.reservedEnumHelpers) = {};", "const \(JSGlueVariableScope.reservedStructHelpers) = {};", @@ -388,22 +384,22 @@ public struct BridgeJSLink { printer.write("}") printer.write("bjs[\"swift_js_push_tag\"] = function(tag) {") printer.indent { - printer.write("\(JSGlueVariableScope.reservedTmpRetTag).push(tag);") + printer.write("\(JSGlueVariableScope.reservedTagStack).push(tag);") } printer.write("}") printer.write("bjs[\"swift_js_push_i32\"] = function(v) {") printer.indent { - printer.write("\(JSGlueVariableScope.reservedTmpRetInts).push(v | 0);") + printer.write("\(JSGlueVariableScope.reservedI32Stack).push(v | 0);") } printer.write("}") printer.write("bjs[\"swift_js_push_f32\"] = function(v) {") printer.indent { - printer.write("\(JSGlueVariableScope.reservedTmpRetF32s).push(Math.fround(v));") + printer.write("\(JSGlueVariableScope.reservedF32Stack).push(Math.fround(v));") } printer.write("}") printer.write("bjs[\"swift_js_push_f64\"] = function(v) {") printer.indent { - printer.write("\(JSGlueVariableScope.reservedTmpRetF64s).push(v);") + printer.write("\(JSGlueVariableScope.reservedF64Stack).push(v);") } printer.write("}") printer.write("bjs[\"swift_js_push_string\"] = function(ptr, len) {") @@ -412,32 +408,32 @@ public struct BridgeJSLink { "const bytes = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, ptr, len)\(sharedMemory ? ".slice()" : "");" ) printer.write("const value = \(JSGlueVariableScope.reservedTextDecoder).decode(bytes);") - printer.write("\(JSGlueVariableScope.reservedTmpRetStrings).push(value);") + printer.write("\(JSGlueVariableScope.reservedStringStack).push(value);") } printer.write("}") printer.write("bjs[\"swift_js_pop_i32\"] = function() {") printer.indent { - printer.write("return \(JSGlueVariableScope.reservedTmpParamInts).pop();") + printer.write("return \(JSGlueVariableScope.reservedI32Stack).pop();") } printer.write("}") printer.write("bjs[\"swift_js_pop_f32\"] = function() {") printer.indent { - printer.write("return \(JSGlueVariableScope.reservedTmpParamF32s).pop();") + printer.write("return \(JSGlueVariableScope.reservedF32Stack).pop();") } printer.write("}") printer.write("bjs[\"swift_js_pop_f64\"] = function() {") printer.indent { - printer.write("return \(JSGlueVariableScope.reservedTmpParamF64s).pop();") + printer.write("return \(JSGlueVariableScope.reservedF64Stack).pop();") } printer.write("}") printer.write("bjs[\"swift_js_push_pointer\"] = function(pointer) {") printer.indent { - printer.write("\(JSGlueVariableScope.reservedTmpRetPointers).push(pointer);") + printer.write("\(JSGlueVariableScope.reservedPointerStack).push(pointer);") } printer.write("}") printer.write("bjs[\"swift_js_pop_pointer\"] = function() {") printer.indent { - printer.write("return \(JSGlueVariableScope.reservedTmpParamPointers).pop();") + printer.write("return \(JSGlueVariableScope.reservedPointerStack).pop();") } printer.write("}") printer.write("bjs[\"swift_js_struct_cleanup\"] = function(cleanupId) {") diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift index ff0343fd3..ae595d656 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift @@ -20,16 +20,12 @@ final class JSGlueVariableScope { static let reservedStorageToReturnOptionalHeapObject = "tmpRetOptionalHeapObject" static let reservedTextEncoder = "textEncoder" static let reservedTextDecoder = "textDecoder" - static let reservedTmpRetTag = "tmpRetTag" - static let reservedTmpRetStrings = "tmpRetStrings" - static let reservedTmpRetInts = "tmpRetInts" - static let reservedTmpRetF32s = "tmpRetF32s" - static let reservedTmpRetF64s = "tmpRetF64s" - static let reservedTmpParamInts = "tmpParamInts" - static let reservedTmpParamF32s = "tmpParamF32s" - static let reservedTmpParamF64s = "tmpParamF64s" - static let reservedTmpRetPointers = "tmpRetPointers" - static let reservedTmpParamPointers = "tmpParamPointers" + static let reservedTagStack = "tagStack" + static let reservedStringStack = "strStack" + static let reservedI32Stack = "i32Stack" + static let reservedF32Stack = "f32Stack" + static let reservedF64Stack = "f64Stack" + static let reservedPointerStack = "ptrStack" static let reservedTmpStructCleanups = "tmpStructCleanups" static let reservedEnumHelpers = "enumHelpers" static let reservedStructHelpers = "structHelpers" @@ -51,16 +47,12 @@ final class JSGlueVariableScope { reservedStorageToReturnOptionalHeapObject, reservedTextEncoder, reservedTextDecoder, - reservedTmpRetTag, - reservedTmpRetStrings, - reservedTmpRetInts, - reservedTmpRetF32s, - reservedTmpRetF64s, - reservedTmpParamInts, - reservedTmpParamF32s, - reservedTmpParamF64s, - reservedTmpRetPointers, - reservedTmpParamPointers, + reservedTagStack, + reservedStringStack, + reservedI32Stack, + reservedF32Stack, + reservedF64Stack, + reservedPointerStack, reservedTmpStructCleanups, reservedEnumHelpers, reservedStructHelpers, @@ -100,46 +92,46 @@ extension JSGlueVariableScope { // MARK: Parameter func emitPushI32Parameter(_ value: String, printer: CodeFragmentPrinter) { - printer.write("\(JSGlueVariableScope.reservedTmpParamInts).push(\(value));") + printer.write("\(JSGlueVariableScope.reservedI32Stack).push(\(value));") } func emitPushF64Parameter(_ value: String, printer: CodeFragmentPrinter) { - printer.write("\(JSGlueVariableScope.reservedTmpParamF64s).push(\(value));") + printer.write("\(JSGlueVariableScope.reservedF64Stack).push(\(value));") } func emitPushF32Parameter(_ value: String, printer: CodeFragmentPrinter) { - printer.write("\(JSGlueVariableScope.reservedTmpParamF32s).push(\(value));") + printer.write("\(JSGlueVariableScope.reservedF32Stack).push(\(value));") } func emitPushPointerParameter(_ value: String, printer: CodeFragmentPrinter) { - printer.write("\(JSGlueVariableScope.reservedTmpParamPointers).push(\(value));") + printer.write("\(JSGlueVariableScope.reservedPointerStack).push(\(value));") } // MARK: Return func emitPushI32Return(_ value: String, printer: CodeFragmentPrinter) { - printer.write("\(JSGlueVariableScope.reservedTmpRetInts).push(\(value));") + printer.write("\(JSGlueVariableScope.reservedI32Stack).push(\(value));") } func emitPushF64Return(_ value: String, printer: CodeFragmentPrinter) { - printer.write("\(JSGlueVariableScope.reservedTmpRetF64s).push(\(value));") + printer.write("\(JSGlueVariableScope.reservedF64Stack).push(\(value));") } func emitPushPointerReturn(_ value: String, printer: CodeFragmentPrinter) { - printer.write("\(JSGlueVariableScope.reservedTmpRetPointers).push(\(value));") + printer.write("\(JSGlueVariableScope.reservedPointerStack).push(\(value));") } - func popTagReturn() -> String { - return "\(JSGlueVariableScope.reservedTmpRetTag).pop()" + func popTag() -> String { + return "\(JSGlueVariableScope.reservedTagStack).pop()" } - func popStringReturn() -> String { - return "\(JSGlueVariableScope.reservedTmpRetStrings).pop()" + func popString() -> String { + return "\(JSGlueVariableScope.reservedStringStack).pop()" } - func popI32Return() -> String { - return "\(JSGlueVariableScope.reservedTmpRetInts).pop()" + func popI32() -> String { + return "\(JSGlueVariableScope.reservedI32Stack).pop()" } - func popF64Return() -> String { - return "\(JSGlueVariableScope.reservedTmpRetF64s).pop()" + func popF64() -> String { + return "\(JSGlueVariableScope.reservedF64Stack).pop()" } - func popF32Return() -> String { - return "\(JSGlueVariableScope.reservedTmpRetF32s).pop()" + func popF32() -> String { + return "\(JSGlueVariableScope.reservedF32Stack).pop()" } - func popPointerReturn() -> String { - return "\(JSGlueVariableScope.reservedTmpRetPointers).pop()" + func popPointer() -> String { + return "\(JSGlueVariableScope.reservedPointerStack).pop()" } } @@ -544,9 +536,9 @@ struct IntrinsicJSFragment: Sendable { let payload2 = scope.variable("jsValuePayload2") let payload1 = scope.variable("jsValuePayload1") let kind = scope.variable("jsValueKind") - printer.write("const \(payload2) = \(scope.popF64Return());") - printer.write("const \(payload1) = \(scope.popI32Return());") - printer.write("const \(kind) = \(scope.popI32Return());") + printer.write("const \(payload2) = \(scope.popF64());") + printer.write("const \(payload1) = \(scope.popI32());") + printer.write("const \(kind) = \(scope.popI32());") let resultVar = scope.variable("jsValue") registerJSValueHelpers(scope: scope) printer.write( @@ -618,7 +610,7 @@ struct IntrinsicJSFragment: Sendable { printCode: { _, scope, printer, _ in let retName = scope.variable("ret") printer.write( - "const \(retName) = \(JSGlueVariableScope.reservedEnumHelpers).\(enumBase).lift(\(scope.popTagReturn()));" + "const \(retName) = \(JSGlueVariableScope.reservedEnumHelpers).\(enumBase).lift(\(scope.popTag()));" ) return [retName] } @@ -933,7 +925,7 @@ struct IntrinsicJSFragment: Sendable { case .associatedValueEnum(let fullName): let base = fullName.components(separatedBy: ".").last ?? fullName let tagVar = scope.variable("tag") - printer.write("const \(tagVar) = \(scope.popTagReturn());") + printer.write("const \(tagVar) = \(scope.popTag());") let isNullVar = scope.variable("isNull") printer.write("const \(isNullVar) = (\(tagVar) === -1);") printer.write("let \(resultVar);") @@ -951,7 +943,7 @@ struct IntrinsicJSFragment: Sendable { case .swiftStruct(let fullName): let base = fullName.components(separatedBy: ".").last ?? fullName let isSomeVar = scope.variable("isSome") - printer.write("const \(isSomeVar) = \(scope.popI32Return());") + printer.write("const \(isSomeVar) = \(scope.popI32());") printer.write("let \(resultVar);") printer.write("if (\(isSomeVar)) {") printer.indent { @@ -966,7 +958,7 @@ struct IntrinsicJSFragment: Sendable { printer.write("}") case .array(let elementType): let isSomeVar = scope.variable("isSome") - printer.write("const \(isSomeVar) = \(scope.popI32Return());") + printer.write("const \(isSomeVar) = \(scope.popI32());") printer.write("let \(resultVar);") printer.write("if (\(isSomeVar)) {") printer.indent { @@ -983,7 +975,7 @@ struct IntrinsicJSFragment: Sendable { printer.write("}") case .jsValue: let isSomeVar = scope.variable("isSome") - printer.write("const \(isSomeVar) = \(scope.popI32Return());") + printer.write("const \(isSomeVar) = \(scope.popI32());") printer.write("let \(resultVar);") printer.write("if (\(isSomeVar)) {") printer.indent { @@ -1682,7 +1674,7 @@ struct IntrinsicJSFragment: Sendable { let base = fullName.components(separatedBy: ".").last ?? fullName let resultVar = scope.variable("result") printer.write( - "const \(resultVar) = \(JSGlueVariableScope.reservedEnumHelpers).\(base).lift(\(scope.popTagReturn()));" + "const \(resultVar) = \(JSGlueVariableScope.reservedEnumHelpers).\(base).lift(\(scope.popTag()));" ) printer.write("return \(resultVar);") return [] @@ -2494,16 +2486,16 @@ struct IntrinsicJSFragment: Sendable { let optVar = scope.variable("optional") let isSomeVar = scope.variable("isSome") - printer.write("const \(isSomeVar) = \(scope.popI32Return());") + printer.write("const \(isSomeVar) = \(scope.popI32());") printer.write("let \(optVar);") printer.write("if (\(isSomeVar)) {") printer.indent { // For optional associated value enums, Swift uses bridgeJSLowerParameter() - // which pushes caseId to tmpRetInts (not tmpRetTag like bridgeJSLowerReturn()). + // which pushes caseId to i32Stack (not tagStack like bridgeJSLowerReturn()). if case .associatedValueEnum(let fullName) = wrappedType { let base = fullName.components(separatedBy: ".").last ?? fullName let caseIdVar = scope.variable("caseId") - printer.write("const \(caseIdVar) = \(scope.popI32Return());") + printer.write("const \(caseIdVar) = \(scope.popI32());") printer.write( "\(optVar) = \(JSGlueVariableScope.reservedEnumHelpers).\(base).lift(\(caseIdVar));" ) @@ -2616,7 +2608,7 @@ struct IntrinsicJSFragment: Sendable { let lenVar = scope.variable("arrayLen") let iVar = scope.variable("i") - printer.write("const \(lenVar) = \(scope.popI32Return());") + printer.write("const \(lenVar) = \(scope.popI32());") printer.write("const \(resultVar) = [];") printer.write("for (let \(iVar) = 0; \(iVar) < \(lenVar); \(iVar)++) {") printer.indent { @@ -2643,9 +2635,9 @@ struct IntrinsicJSFragment: Sendable { let payload2Var = scope.variable("jsValuePayload2") let payload1Var = scope.variable("jsValuePayload1") let kindVar = scope.variable("jsValueKind") - printer.write("const \(payload2Var) = \(scope.popF64Return());") - printer.write("const \(payload1Var) = \(scope.popI32Return());") - printer.write("const \(kindVar) = \(scope.popI32Return());") + printer.write("const \(payload2Var) = \(scope.popF64());") + printer.write("const \(payload1Var) = \(scope.popI32());") + printer.write("const \(kindVar) = \(scope.popI32());") let resultVar = scope.variable("jsValue") printer.write( "const \(resultVar) = \(jsValueLiftHelperName)(\(kindVar), \(payload1Var), \(payload2Var));" @@ -2658,7 +2650,7 @@ struct IntrinsicJSFragment: Sendable { parameters: [], printCode: { arguments, scope, printer, cleanup in let strVar = scope.variable("string") - printer.write("const \(strVar) = \(scope.popStringReturn());") + printer.write("const \(strVar) = \(scope.popString());") return [strVar] } ) @@ -2667,7 +2659,7 @@ struct IntrinsicJSFragment: Sendable { parameters: [], printCode: { arguments, scope, printer, cleanup in let bVar = scope.variable("bool") - printer.write("const \(bVar) = \(scope.popI32Return()) !== 0;") + printer.write("const \(bVar) = \(scope.popI32()) !== 0;") return [bVar] } ) @@ -2676,7 +2668,7 @@ struct IntrinsicJSFragment: Sendable { parameters: [], printCode: { arguments, scope, printer, cleanup in let iVar = scope.variable("int") - printer.write("const \(iVar) = \(scope.popI32Return());") + printer.write("const \(iVar) = \(scope.popI32());") return [iVar] } ) @@ -2685,7 +2677,7 @@ struct IntrinsicJSFragment: Sendable { parameters: [], printCode: { arguments, scope, printer, cleanup in let fVar = scope.variable("f32") - printer.write("const \(fVar) = \(scope.popF32Return());") + printer.write("const \(fVar) = \(scope.popF32());") return [fVar] } ) @@ -2694,7 +2686,7 @@ struct IntrinsicJSFragment: Sendable { parameters: [], printCode: { arguments, scope, printer, cleanup in let dVar = scope.variable("f64") - printer.write("const \(dVar) = \(scope.popF64Return());") + printer.write("const \(dVar) = \(scope.popF64());") return [dVar] } ) @@ -2715,7 +2707,7 @@ struct IntrinsicJSFragment: Sendable { parameters: [], printCode: { arguments, scope, printer, cleanup in let varName = scope.variable("caseId") - printer.write("const \(varName) = \(scope.popI32Return());") + printer.write("const \(varName) = \(scope.popI32());") return [varName] } ) @@ -2726,7 +2718,7 @@ struct IntrinsicJSFragment: Sendable { parameters: [], printCode: { arguments, scope, printer, cleanup in let varName = scope.variable("rawValue") - printer.write("const \(varName) = \(scope.popStringReturn());") + printer.write("const \(varName) = \(scope.popString());") return [varName] } ) @@ -2735,7 +2727,7 @@ struct IntrinsicJSFragment: Sendable { parameters: [], printCode: { arguments, scope, printer, cleanup in let varName = scope.variable("rawValue") - printer.write("const \(varName) = \(scope.popF32Return());") + printer.write("const \(varName) = \(scope.popF32());") return [varName] } ) @@ -2744,7 +2736,7 @@ struct IntrinsicJSFragment: Sendable { parameters: [], printCode: { arguments, scope, printer, cleanup in let varName = scope.variable("rawValue") - printer.write("const \(varName) = \(scope.popF64Return());") + printer.write("const \(varName) = \(scope.popF64());") return [varName] } ) @@ -2753,7 +2745,7 @@ struct IntrinsicJSFragment: Sendable { parameters: [], printCode: { arguments, scope, printer, cleanup in let varName = scope.variable("rawValue") - printer.write("const \(varName) = \(scope.popI32Return());") + printer.write("const \(varName) = \(scope.popI32());") return [varName] } ) @@ -2765,7 +2757,7 @@ struct IntrinsicJSFragment: Sendable { printCode: { arguments, scope, printer, cleanup in let resultVar = scope.variable("enumValue") printer.write( - "const \(resultVar) = \(JSGlueVariableScope.reservedEnumHelpers).\(base).lift(\(scope.popTagReturn()), );" + "const \(resultVar) = \(JSGlueVariableScope.reservedEnumHelpers).\(base).lift(\(scope.popTag()), );" ) return [resultVar] } @@ -2776,7 +2768,7 @@ struct IntrinsicJSFragment: Sendable { printCode: { arguments, scope, printer, cleanup in let ptrVar = scope.variable("ptr") let objVar = scope.variable("obj") - printer.write("const \(ptrVar) = \(scope.popPointerReturn());") + printer.write("const \(ptrVar) = \(scope.popPointer());") printer.write("const \(objVar) = _exports['\(className)'].__construct(\(ptrVar));") return [objVar] } @@ -2787,7 +2779,7 @@ struct IntrinsicJSFragment: Sendable { printCode: { arguments, scope, printer, cleanup in let idVar = scope.variable("objId") let objVar = scope.variable("obj") - printer.write("const \(idVar) = \(scope.popI32Return());") + printer.write("const \(idVar) = \(scope.popI32());") printer.write("const \(objVar) = \(JSGlueVariableScope.reservedSwift).memory.getObject(\(idVar));") printer.write("\(JSGlueVariableScope.reservedSwift).memory.release(\(idVar));") return [objVar] @@ -2802,7 +2794,7 @@ struct IntrinsicJSFragment: Sendable { parameters: [], printCode: { arguments, scope, printer, cleanup in let pVar = scope.variable("pointer") - printer.write("const \(pVar) = \(scope.popPointerReturn());") + printer.write("const \(pVar) = \(scope.popPointer());") return [pVar] } ) @@ -3021,7 +3013,7 @@ struct IntrinsicJSFragment: Sendable { let isSomeVar = scope.variable("isSome") let resultVar = scope.variable("optValue") - printer.write("const \(isSomeVar) = \(scope.popI32Return());") + printer.write("const \(isSomeVar) = \(scope.popI32());") printer.write("let \(resultVar);") printer.write("if (\(isSomeVar) === 0) {") printer.indent { @@ -3477,7 +3469,7 @@ struct IntrinsicJSFragment: Sendable { pushOptionalPrimitive( value: value, isSomeVar: isSomeVar, - stack: .tmpParamInts, + stack: .i32Stack, convert: "| 0", zeroValue: "0", printer: printer, @@ -3487,7 +3479,7 @@ struct IntrinsicJSFragment: Sendable { pushOptionalPrimitive( value: value, isSomeVar: isSomeVar, - stack: .tmpParamInts, + stack: .i32Stack, convert: "? 1 : 0", zeroValue: "0", printer: printer, @@ -3497,7 +3489,7 @@ struct IntrinsicJSFragment: Sendable { pushOptionalPrimitive( value: value, isSomeVar: isSomeVar, - stack: .tmpParamF32s, + stack: .f32Stack, convert: "Math.fround", zeroValue: "0.0", printer: printer, @@ -3507,7 +3499,7 @@ struct IntrinsicJSFragment: Sendable { pushOptionalPrimitive( value: value, isSomeVar: isSomeVar, - stack: .tmpParamF64s, + stack: .f64Stack, convert: nil, zeroValue: "0.0", printer: printer, @@ -3622,9 +3614,9 @@ struct IntrinsicJSFragment: Sendable { ) { let stackName: String switch stack { - case .tmpParamInts: stackName = JSGlueVariableScope.reservedTmpParamInts - case .tmpParamF32s: stackName = JSGlueVariableScope.reservedTmpParamF32s - case .tmpParamF64s: stackName = JSGlueVariableScope.reservedTmpParamF64s + case .i32Stack: stackName = JSGlueVariableScope.reservedI32Stack + case .f32Stack: stackName = JSGlueVariableScope.reservedF32Stack + case .f64Stack: stackName = JSGlueVariableScope.reservedF64Stack } printer.write("if (\(isSomeVar)) {") @@ -3650,9 +3642,9 @@ struct IntrinsicJSFragment: Sendable { } private enum StackType { - case tmpParamInts - case tmpParamF32s - case tmpParamF64s + case i32Stack + case f32Stack + case f64Stack } private static func structFieldLiftFragment( @@ -3668,15 +3660,15 @@ struct IntrinsicJSFragment: Sendable { printCode: { arguments, scope, printer, cleanup in let isSomeVar = scope.variable("isSome") let optVar = scope.variable("optional") - printer.write("const \(isSomeVar) = \(scope.popI32Return());") + printer.write("const \(isSomeVar) = \(scope.popI32());") printer.write("let \(optVar);") printer.write("if (\(isSomeVar)) {") printer.indent { - // Special handling for associated value enum - in struct fields, case ID is pushed to tmpRetInts + // Special handling for associated value enum - in struct fields, case ID is pushed to i32Stack if case .associatedValueEnum(let enumName) = wrappedType { let base = enumName.components(separatedBy: ".").last ?? enumName let caseIdVar = scope.variable("enumCaseId") - printer.write("const \(caseIdVar) = \(scope.popI32Return());") + printer.write("const \(caseIdVar) = \(scope.popI32());") printer.write( "\(optVar) = \(JSGlueVariableScope.reservedEnumHelpers).\(base).lift(\(caseIdVar), );" ) @@ -3723,7 +3715,7 @@ struct IntrinsicJSFragment: Sendable { printCode: { arguments, scope, printer, cleanup in let objectIdVar = scope.variable("objectId") let varName = scope.variable("value") - printer.write("const \(objectIdVar) = \(scope.popI32Return());") + printer.write("const \(objectIdVar) = \(scope.popI32());") printer.write("let \(varName);") printer.write("if (\(objectIdVar) !== 0) {") printer.indent { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js index 7093fe417..5b8c451e2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js @@ -31,16 +31,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -50,13 +46,13 @@ export async function createInstantiator(options, swift) { const __bjs_createPointHelpers = () => { return () => ({ lower: (value) => { - tmpParamF64s.push(value.x); - tmpParamF64s.push(value.y); + f64Stack.push(value.x); + f64Stack.push(value.y); return { cleanup: undefined }; }, lift: () => { - const f64 = tmpRetF64s.pop(); - const f641 = tmpRetF64s.pop(); + const f64 = f64Stack.pop(); + const f641 = f64Stack.pop(); return { x: f641, y: f64 }; } }); @@ -98,36 +94,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } @@ -265,10 +261,10 @@ export async function createInstantiator(options, swift) { } TestModule["bjs_importProcessNumbers"] = function bjs_importProcessNumbers() { try { - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const f64 = tmpRetF64s.pop(); + const f64 = f64Stack.pop(); arrayResult.push(f64); } arrayResult.reverse(); @@ -282,38 +278,38 @@ export async function createInstantiator(options, swift) { let ret = imports.importGetNumbers(); const arrayCleanups = []; for (const elem of ret) { - tmpParamF64s.push(elem); + f64Stack.push(elem); } - tmpParamInts.push(ret.length); + i32Stack.push(ret.length); } catch (error) { setException(error); } } TestModule["bjs_importTransformNumbers"] = function bjs_importTransformNumbers() { try { - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const f64 = tmpRetF64s.pop(); + const f64 = f64Stack.pop(); arrayResult.push(f64); } arrayResult.reverse(); let ret = imports.importTransformNumbers(arrayResult); const arrayCleanups = []; for (const elem of ret) { - tmpParamF64s.push(elem); + f64Stack.push(elem); } - tmpParamInts.push(ret.length); + i32Stack.push(ret.length); } catch (error) { setException(error); } } TestModule["bjs_importProcessStrings"] = function bjs_importProcessStrings() { try { - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); arrayResult.push(string); } arrayResult.reverse(); @@ -322,32 +318,32 @@ export async function createInstantiator(options, swift) { for (const elem of ret) { const bytes = textEncoder.encode(elem); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); arrayCleanups.push(() => { swift.memory.release(id); }); } - tmpParamInts.push(ret.length); + i32Stack.push(ret.length); } catch (error) { setException(error); } } TestModule["bjs_importProcessBooleans"] = function bjs_importProcessBooleans() { try { - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const bool = tmpRetInts.pop() !== 0; + const bool = i32Stack.pop() !== 0; arrayResult.push(bool); } arrayResult.reverse(); let ret = imports.importProcessBooleans(arrayResult); const arrayCleanups = []; for (const elem of ret) { - tmpParamInts.push(elem ? 1 : 0); + i32Stack.push(elem ? 1 : 0); } - tmpParamInts.push(ret.length); + i32Stack.push(ret.length); } catch (error) { setException(error); } @@ -397,14 +393,14 @@ export async function createInstantiator(options, swift) { processIntArray: function bjs_processIntArray(values) { const arrayCleanups = []; for (const elem of values) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_processIntArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); arrayResult.push(int); } arrayResult.reverse(); @@ -416,18 +412,18 @@ export async function createInstantiator(options, swift) { for (const elem of values) { const bytes = textEncoder.encode(elem); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); arrayCleanups.push(() => { swift.memory.release(id); }); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_processStringArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); arrayResult.push(string); } arrayResult.reverse(); @@ -437,14 +433,14 @@ export async function createInstantiator(options, swift) { processDoubleArray: function bjs_processDoubleArray(values) { const arrayCleanups = []; for (const elem of values) { - tmpParamF64s.push(elem); + f64Stack.push(elem); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_processDoubleArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const f64 = tmpRetF64s.pop(); + const f64 = f64Stack.pop(); arrayResult.push(f64); } arrayResult.reverse(); @@ -454,14 +450,14 @@ export async function createInstantiator(options, swift) { processBoolArray: function bjs_processBoolArray(values) { const arrayCleanups = []; for (const elem of values) { - tmpParamInts.push(elem ? 1 : 0); + i32Stack.push(elem ? 1 : 0); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_processBoolArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const bool = tmpRetInts.pop() !== 0; + const bool = i32Stack.pop() !== 0; arrayResult.push(bool); } arrayResult.reverse(); @@ -476,9 +472,9 @@ export async function createInstantiator(options, swift) { if (structCleanup) { structCleanup(); } }); } - tmpParamInts.push(points.length); + i32Stack.push(points.length); instance.exports.bjs_processPointArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { const struct = structHelpers.Point.lift(); @@ -491,14 +487,14 @@ export async function createInstantiator(options, swift) { processDirectionArray: function bjs_processDirectionArray(directions) { const arrayCleanups = []; for (const elem of directions) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } - tmpParamInts.push(directions.length); + i32Stack.push(directions.length); instance.exports.bjs_processDirectionArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const caseId = tmpRetInts.pop(); + const caseId = i32Stack.pop(); arrayResult.push(caseId); } arrayResult.reverse(); @@ -508,14 +504,14 @@ export async function createInstantiator(options, swift) { processStatusArray: function bjs_processStatusArray(statuses) { const arrayCleanups = []; for (const elem of statuses) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } - tmpParamInts.push(statuses.length); + i32Stack.push(statuses.length); instance.exports.bjs_processStatusArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const rawValue = tmpRetInts.pop(); + const rawValue = i32Stack.pop(); arrayResult.push(rawValue); } arrayResult.reverse(); @@ -525,9 +521,9 @@ export async function createInstantiator(options, swift) { sumIntArray: function bjs_sumIntArray(values) { const arrayCleanups = []; for (const elem of values) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); const ret = instance.exports.bjs_sumIntArray(); for (const cleanup of arrayCleanups) { cleanup(); } return ret; @@ -540,7 +536,7 @@ export async function createInstantiator(options, swift) { if (structCleanup) { structCleanup(); } }); } - tmpParamInts.push(points.length); + i32Stack.push(points.length); const matchingBytes = textEncoder.encode(matching); const matchingId = swift.memory.retain(matchingBytes); instance.exports.bjs_findFirstPoint(matchingId, matchingBytes.length); @@ -552,14 +548,14 @@ export async function createInstantiator(options, swift) { processUnsafeRawPointerArray: function bjs_processUnsafeRawPointerArray(values) { const arrayCleanups = []; for (const elem of values) { - tmpParamPointers.push((elem | 0)); + ptrStack.push((elem | 0)); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_processUnsafeRawPointerArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const pointer = tmpRetPointers.pop(); + const pointer = ptrStack.pop(); arrayResult.push(pointer); } arrayResult.reverse(); @@ -569,14 +565,14 @@ export async function createInstantiator(options, swift) { processUnsafeMutableRawPointerArray: function bjs_processUnsafeMutableRawPointerArray(values) { const arrayCleanups = []; for (const elem of values) { - tmpParamPointers.push((elem | 0)); + ptrStack.push((elem | 0)); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_processUnsafeMutableRawPointerArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const pointer = tmpRetPointers.pop(); + const pointer = ptrStack.pop(); arrayResult.push(pointer); } arrayResult.reverse(); @@ -586,14 +582,14 @@ export async function createInstantiator(options, swift) { processOpaquePointerArray: function bjs_processOpaquePointerArray(values) { const arrayCleanups = []; for (const elem of values) { - tmpParamPointers.push((elem | 0)); + ptrStack.push((elem | 0)); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_processOpaquePointerArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const pointer = tmpRetPointers.pop(); + const pointer = ptrStack.pop(); arrayResult.push(pointer); } arrayResult.reverse(); @@ -605,23 +601,23 @@ export async function createInstantiator(options, swift) { for (const elem of values) { const isSome = elem != null ? 1 : 0; if (isSome) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } else { - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome); + i32Stack.push(isSome); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_processOptionalIntArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optValue; if (isSome1 === 0) { optValue = null; } else { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); optValue = int; } arrayResult.push(optValue); @@ -637,26 +633,26 @@ export async function createInstantiator(options, swift) { if (isSome) { const bytes = textEncoder.encode(elem); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); arrayCleanups.push(() => { swift.memory.release(id); }); } else { - tmpParamInts.push(0); - tmpParamInts.push(0); + i32Stack.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome); + i32Stack.push(isSome); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_processOptionalStringArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optValue; if (isSome1 === 0) { optValue = null; } else { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); optValue = string; } arrayResult.push(optValue); @@ -671,19 +667,19 @@ export async function createInstantiator(options, swift) { if (isSome) { const arrayCleanups = []; for (const elem of values) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); valuesCleanups.push(() => { for (const cleanup of arrayCleanups) { cleanup(); } }); } instance.exports.bjs_processOptionalArray(+isSome); - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optResult; if (isSome1) { - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); arrayResult.push(int); } arrayResult.reverse(); @@ -703,14 +699,14 @@ export async function createInstantiator(options, swift) { arrayCleanups.push(() => { if (structCleanup) { structCleanup(); } }); } else { } - tmpParamInts.push(isSome); + i32Stack.push(isSome); } - tmpParamInts.push(points.length); + i32Stack.push(points.length); instance.exports.bjs_processOptionalPointArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optValue; if (isSome1 === 0) { optValue = null; @@ -729,23 +725,23 @@ export async function createInstantiator(options, swift) { for (const elem of directions) { const isSome = elem != null ? 1 : 0; if (isSome) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } else { - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome); + i32Stack.push(isSome); } - tmpParamInts.push(directions.length); + i32Stack.push(directions.length); instance.exports.bjs_processOptionalDirectionArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optValue; if (isSome1 === 0) { optValue = null; } else { - const caseId = tmpRetInts.pop(); + const caseId = i32Stack.pop(); optValue = caseId; } arrayResult.push(optValue); @@ -759,23 +755,23 @@ export async function createInstantiator(options, swift) { for (const elem of statuses) { const isSome = elem != null ? 1 : 0; if (isSome) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } else { - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome); + i32Stack.push(isSome); } - tmpParamInts.push(statuses.length); + i32Stack.push(statuses.length); instance.exports.bjs_processOptionalStatusArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optValue; if (isSome1 === 0) { optValue = null; } else { - const rawValue = tmpRetInts.pop(); + const rawValue = i32Stack.pop(); optValue = rawValue; } arrayResult.push(optValue); @@ -789,22 +785,22 @@ export async function createInstantiator(options, swift) { for (const elem of values) { const arrayCleanups1 = []; for (const elem1 of elem) { - tmpParamInts.push((elem1 | 0)); + i32Stack.push((elem1 | 0)); } - tmpParamInts.push(elem.length); + i32Stack.push(elem.length); arrayCleanups.push(() => { for (const cleanup of arrayCleanups1) { cleanup(); } }); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_processNestedIntArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const arrayLen1 = tmpRetInts.pop(); + const arrayLen1 = i32Stack.pop(); const arrayResult1 = []; for (let i1 = 0; i1 < arrayLen1; i1++) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); arrayResult1.push(int); } arrayResult1.reverse(); @@ -821,26 +817,26 @@ export async function createInstantiator(options, swift) { for (const elem1 of elem) { const bytes = textEncoder.encode(elem1); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); arrayCleanups1.push(() => { swift.memory.release(id); }); } - tmpParamInts.push(elem.length); + i32Stack.push(elem.length); arrayCleanups.push(() => { for (const cleanup of arrayCleanups1) { cleanup(); } }); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_processNestedStringArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const arrayLen1 = tmpRetInts.pop(); + const arrayLen1 = i32Stack.pop(); const arrayResult1 = []; for (let i1 = 0; i1 < arrayLen1; i1++) { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); arrayResult1.push(string); } arrayResult1.reverse(); @@ -860,17 +856,17 @@ export async function createInstantiator(options, swift) { if (structCleanup) { structCleanup(); } }); } - tmpParamInts.push(elem.length); + i32Stack.push(elem.length); arrayCleanups.push(() => { for (const cleanup of arrayCleanups1) { cleanup(); } }); } - tmpParamInts.push(points.length); + i32Stack.push(points.length); instance.exports.bjs_processNestedPointArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const arrayLen1 = tmpRetInts.pop(); + const arrayLen1 = i32Stack.pop(); const arrayResult1 = []; for (let i1 = 0; i1 < arrayLen1; i1++) { const struct = structHelpers.Point.lift(); @@ -886,14 +882,14 @@ export async function createInstantiator(options, swift) { processItemArray: function bjs_processItemArray(items) { const arrayCleanups = []; for (const elem of items) { - tmpParamPointers.push(elem.pointer); + ptrStack.push(elem.pointer); } - tmpParamInts.push(items.length); + i32Stack.push(items.length); instance.exports.bjs_processItemArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const ptr = tmpRetPointers.pop(); + const ptr = ptrStack.pop(); const obj = _exports['Item'].__construct(ptr); arrayResult.push(obj); } @@ -906,22 +902,22 @@ export async function createInstantiator(options, swift) { for (const elem of items) { const arrayCleanups1 = []; for (const elem1 of elem) { - tmpParamPointers.push(elem1.pointer); + ptrStack.push(elem1.pointer); } - tmpParamInts.push(elem.length); + i32Stack.push(elem.length); arrayCleanups.push(() => { for (const cleanup of arrayCleanups1) { cleanup(); } }); } - tmpParamInts.push(items.length); + i32Stack.push(items.length); instance.exports.bjs_processNestedItemArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const arrayLen1 = tmpRetInts.pop(); + const arrayLen1 = i32Stack.pop(); const arrayResult1 = []; for (let i1 = 0; i1 < arrayLen1; i1++) { - const ptr = tmpRetPointers.pop(); + const ptr = ptrStack.pop(); const obj = _exports['Item'].__construct(ptr); arrayResult1.push(obj); } @@ -936,14 +932,14 @@ export async function createInstantiator(options, swift) { const arrayCleanups = []; for (const elem of objects) { const objId = swift.memory.retain(elem); - tmpParamInts.push(objId); + i32Stack.push(objId); } - tmpParamInts.push(objects.length); + i32Stack.push(objects.length); instance.exports.bjs_processJSObjectArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const objId1 = tmpRetInts.pop(); + const objId1 = i32Stack.pop(); const obj = swift.memory.getObject(objId1); swift.memory.release(objId1); arrayResult.push(obj); @@ -958,23 +954,23 @@ export async function createInstantiator(options, swift) { const isSome = elem != null ? 1 : 0; if (isSome) { const objId = swift.memory.retain(elem); - tmpParamInts.push(objId); + i32Stack.push(objId); } else { - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome); + i32Stack.push(isSome); } - tmpParamInts.push(objects.length); + i32Stack.push(objects.length); instance.exports.bjs_processOptionalJSObjectArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optValue; if (isSome1 === 0) { optValue = null; } else { - const objId1 = tmpRetInts.pop(); + const objId1 = i32Stack.pop(); const obj = swift.memory.getObject(objId1); swift.memory.release(objId1); optValue = obj; @@ -991,22 +987,22 @@ export async function createInstantiator(options, swift) { const arrayCleanups1 = []; for (const elem1 of elem) { const objId = swift.memory.retain(elem1); - tmpParamInts.push(objId); + i32Stack.push(objId); } - tmpParamInts.push(elem.length); + i32Stack.push(elem.length); arrayCleanups.push(() => { for (const cleanup of arrayCleanups1) { cleanup(); } }); } - tmpParamInts.push(objects.length); + i32Stack.push(objects.length); instance.exports.bjs_processNestedJSObjectArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const arrayLen1 = tmpRetInts.pop(); + const arrayLen1 = i32Stack.pop(); const arrayResult1 = []; for (let i1 = 0; i1 < arrayLen1; i1++) { - const objId1 = tmpRetInts.pop(); + const objId1 = i32Stack.pop(); const obj = swift.memory.getObject(objId1); swift.memory.release(objId1); arrayResult1.push(obj); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js index 0aa9148c1..40ff4884a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -70,36 +66,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index e19eb5fb4..c7b1dc093 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -24,16 +24,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -45,19 +41,19 @@ export async function createInstantiator(options, swift) { lower: (value) => { const bytes = textEncoder.encode(value.name); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); - tmpParamInts.push((value.value | 0)); - tmpParamInts.push(value.enabled ? 1 : 0); + i32Stack.push(bytes.length); + i32Stack.push(id); + i32Stack.push((value.value | 0)); + i32Stack.push(value.enabled ? 1 : 0); const cleanup = () => { swift.memory.release(id); }; return { cleanup }; }, lift: () => { - const bool = tmpRetInts.pop() !== 0; - const int = tmpRetInts.pop(); - const string = tmpRetStrings.pop(); + const bool = i32Stack.pop() !== 0; + const int = i32Stack.pop(); + const string = strStack.pop(); return { name: string, value: int, enabled: bool }; } }); @@ -65,11 +61,11 @@ export async function createInstantiator(options, swift) { const __bjs_createMathOperationsHelpers = () => { return () => ({ lower: (value) => { - tmpParamF64s.push(value.baseValue); + f64Stack.push(value.baseValue); return { cleanup: undefined }; }, lift: () => { - const f64 = tmpRetF64s.pop(); + const f64 = f64Stack.pop(); const instance1 = { baseValue: f64 }; instance1.add = function(a, b = 10.0) { const { cleanup: structCleanup } = structHelpers.MathOperations.lower(this); @@ -123,36 +119,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } @@ -525,7 +521,7 @@ export async function createInstantiator(options, swift) { pointCleanup = structResult.cleanup; } instance.exports.bjs_testOptionalStructDefault(+isSome); - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optResult; if (isSome1) { optResult = structHelpers.Config.lift(); @@ -543,7 +539,7 @@ export async function createInstantiator(options, swift) { pointCleanup = structResult.cleanup; } instance.exports.bjs_testOptionalStructWithValueDefault(+isSome); - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optResult; if (isSome1) { optResult = structHelpers.Config.lift(); @@ -556,14 +552,14 @@ export async function createInstantiator(options, swift) { testIntArrayDefault: function bjs_testIntArrayDefault(values = [1, 2, 3]) { const arrayCleanups = []; for (const elem of values) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_testIntArrayDefault(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); arrayResult.push(int); } arrayResult.reverse(); @@ -575,18 +571,18 @@ export async function createInstantiator(options, swift) { for (const elem of names) { const bytes = textEncoder.encode(elem); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); arrayCleanups.push(() => { swift.memory.release(id); }); } - tmpParamInts.push(names.length); + i32Stack.push(names.length); instance.exports.bjs_testStringArrayDefault(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); arrayResult.push(string); } arrayResult.reverse(); @@ -596,14 +592,14 @@ export async function createInstantiator(options, swift) { testDoubleArrayDefault: function bjs_testDoubleArrayDefault(values = [1.5, 2.5, 3.5]) { const arrayCleanups = []; for (const elem of values) { - tmpParamF64s.push(elem); + f64Stack.push(elem); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_testDoubleArrayDefault(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const f64 = tmpRetF64s.pop(); + const f64 = f64Stack.pop(); arrayResult.push(f64); } arrayResult.reverse(); @@ -613,14 +609,14 @@ export async function createInstantiator(options, swift) { testBoolArrayDefault: function bjs_testBoolArrayDefault(flags = [true, false, true]) { const arrayCleanups = []; for (const elem of flags) { - tmpParamInts.push(elem ? 1 : 0); + i32Stack.push(elem ? 1 : 0); } - tmpParamInts.push(flags.length); + i32Stack.push(flags.length); instance.exports.bjs_testBoolArrayDefault(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const bool = tmpRetInts.pop() !== 0; + const bool = i32Stack.pop() !== 0; arrayResult.push(bool); } arrayResult.reverse(); @@ -630,14 +626,14 @@ export async function createInstantiator(options, swift) { testEmptyArrayDefault: function bjs_testEmptyArrayDefault(items = []) { const arrayCleanups = []; for (const elem of items) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } - tmpParamInts.push(items.length); + i32Stack.push(items.length); instance.exports.bjs_testEmptyArrayDefault(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); arrayResult.push(int); } arrayResult.reverse(); @@ -649,9 +645,9 @@ export async function createInstantiator(options, swift) { const nameId = swift.memory.retain(nameBytes); const arrayCleanups = []; for (const elem of values) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_testMixedWithArrayDefault(nameId, nameBytes.length, enabled); const ret = tmpRetString; tmpRetString = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js index 8491c08a2..f04b464c6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js @@ -99,16 +99,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -118,13 +114,13 @@ export async function createInstantiator(options, swift) { const __bjs_createPointHelpers = () => { return () => ({ lower: (value) => { - tmpParamF64s.push(value.x); - tmpParamF64s.push(value.y); + f64Stack.push(value.x); + f64Stack.push(value.y); return { cleanup: undefined }; }, lift: () => { - const f64 = tmpRetF64s.pop(); - const f641 = tmpRetF64s.pop(); + const f64 = f64Stack.pop(); + const f641 = f64Stack.pop(); return { x: f641, y: f64 }; } }); @@ -137,30 +133,30 @@ export async function createInstantiator(options, swift) { case APIResultValues.Tag.Success: { const bytes = textEncoder.encode(value.param0); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const cleanup = () => { swift.memory.release(id); }; return { caseId: APIResultValues.Tag.Success, cleanup }; } case APIResultValues.Tag.Failure: { - tmpParamInts.push((value.param0 | 0)); + i32Stack.push((value.param0 | 0)); const cleanup = undefined; return { caseId: APIResultValues.Tag.Failure, cleanup }; } case APIResultValues.Tag.Flag: { - tmpParamInts.push(value.param0 ? 1 : 0); + i32Stack.push(value.param0 ? 1 : 0); const cleanup = undefined; return { caseId: APIResultValues.Tag.Flag, cleanup }; } case APIResultValues.Tag.Rate: { - tmpParamF32s.push(Math.fround(value.param0)); + f32Stack.push(Math.fround(value.param0)); const cleanup = undefined; return { caseId: APIResultValues.Tag.Rate, cleanup }; } case APIResultValues.Tag.Precise: { - tmpParamF64s.push(value.param0); + f64Stack.push(value.param0); const cleanup = undefined; return { caseId: APIResultValues.Tag.Precise, cleanup }; } @@ -175,23 +171,23 @@ export async function createInstantiator(options, swift) { tag = tag | 0; switch (tag) { case APIResultValues.Tag.Success: { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); return { tag: APIResultValues.Tag.Success, param0: string }; } case APIResultValues.Tag.Failure: { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); return { tag: APIResultValues.Tag.Failure, param0: int }; } case APIResultValues.Tag.Flag: { - const bool = tmpRetInts.pop() !== 0; + const bool = i32Stack.pop() !== 0; return { tag: APIResultValues.Tag.Flag, param0: bool }; } case APIResultValues.Tag.Rate: { - const f32 = tmpRetF32s.pop(); + const f32 = f32Stack.pop(); return { tag: APIResultValues.Tag.Rate, param0: f32 }; } case APIResultValues.Tag.Precise: { - const f64 = tmpRetF64s.pop(); + const f64 = f64Stack.pop(); return { tag: APIResultValues.Tag.Precise, param0: f64 }; } case APIResultValues.Tag.Info: return { tag: APIResultValues.Tag.Info }; @@ -208,19 +204,19 @@ export async function createInstantiator(options, swift) { case ComplexResultValues.Tag.Success: { const bytes = textEncoder.encode(value.param0); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const cleanup = () => { swift.memory.release(id); }; return { caseId: ComplexResultValues.Tag.Success, cleanup }; } case ComplexResultValues.Tag.Error: { - tmpParamInts.push((value.param1 | 0)); + i32Stack.push((value.param1 | 0)); const bytes = textEncoder.encode(value.param0); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const cleanup = () => { swift.memory.release(id); }; @@ -229,41 +225,41 @@ export async function createInstantiator(options, swift) { case ComplexResultValues.Tag.Status: { const bytes = textEncoder.encode(value.param2); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); - tmpParamInts.push((value.param1 | 0)); - tmpParamInts.push(value.param0 ? 1 : 0); + i32Stack.push(bytes.length); + i32Stack.push(id); + i32Stack.push((value.param1 | 0)); + i32Stack.push(value.param0 ? 1 : 0); const cleanup = () => { swift.memory.release(id); }; return { caseId: ComplexResultValues.Tag.Status, cleanup }; } case ComplexResultValues.Tag.Coordinates: { - tmpParamF64s.push(value.param2); - tmpParamF64s.push(value.param1); - tmpParamF64s.push(value.param0); + f64Stack.push(value.param2); + f64Stack.push(value.param1); + f64Stack.push(value.param0); const cleanup = undefined; return { caseId: ComplexResultValues.Tag.Coordinates, cleanup }; } case ComplexResultValues.Tag.Comprehensive: { const bytes = textEncoder.encode(value.param8); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const bytes1 = textEncoder.encode(value.param7); const id1 = swift.memory.retain(bytes1); - tmpParamInts.push(bytes1.length); - tmpParamInts.push(id1); + i32Stack.push(bytes1.length); + i32Stack.push(id1); const bytes2 = textEncoder.encode(value.param6); const id2 = swift.memory.retain(bytes2); - tmpParamInts.push(bytes2.length); - tmpParamInts.push(id2); - tmpParamF64s.push(value.param5); - tmpParamF64s.push(value.param4); - tmpParamInts.push((value.param3 | 0)); - tmpParamInts.push((value.param2 | 0)); - tmpParamInts.push(value.param1 ? 1 : 0); - tmpParamInts.push(value.param0 ? 1 : 0); + i32Stack.push(bytes2.length); + i32Stack.push(id2); + f64Stack.push(value.param5); + f64Stack.push(value.param4); + i32Stack.push((value.param3 | 0)); + i32Stack.push((value.param2 | 0)); + i32Stack.push(value.param1 ? 1 : 0); + i32Stack.push(value.param0 ? 1 : 0); const cleanup = () => { swift.memory.release(id); swift.memory.release(id1); @@ -282,36 +278,36 @@ export async function createInstantiator(options, swift) { tag = tag | 0; switch (tag) { case ComplexResultValues.Tag.Success: { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); return { tag: ComplexResultValues.Tag.Success, param0: string }; } case ComplexResultValues.Tag.Error: { - const int = tmpRetInts.pop(); - const string = tmpRetStrings.pop(); + const int = i32Stack.pop(); + const string = strStack.pop(); return { tag: ComplexResultValues.Tag.Error, param0: string, param1: int }; } case ComplexResultValues.Tag.Status: { - const string = tmpRetStrings.pop(); - const int = tmpRetInts.pop(); - const bool = tmpRetInts.pop() !== 0; + const string = strStack.pop(); + const int = i32Stack.pop(); + const bool = i32Stack.pop() !== 0; return { tag: ComplexResultValues.Tag.Status, param0: bool, param1: int, param2: string }; } case ComplexResultValues.Tag.Coordinates: { - const f64 = tmpRetF64s.pop(); - const f641 = tmpRetF64s.pop(); - const f642 = tmpRetF64s.pop(); + const f64 = f64Stack.pop(); + const f641 = f64Stack.pop(); + const f642 = f64Stack.pop(); return { tag: ComplexResultValues.Tag.Coordinates, param0: f642, param1: f641, param2: f64 }; } case ComplexResultValues.Tag.Comprehensive: { - const string = tmpRetStrings.pop(); - const string1 = tmpRetStrings.pop(); - const string2 = tmpRetStrings.pop(); - const f64 = tmpRetF64s.pop(); - const f641 = tmpRetF64s.pop(); - const int = tmpRetInts.pop(); - const int1 = tmpRetInts.pop(); - const bool = tmpRetInts.pop() !== 0; - const bool1 = tmpRetInts.pop() !== 0; + const string = strStack.pop(); + const string1 = strStack.pop(); + const string2 = strStack.pop(); + const f64 = f64Stack.pop(); + const f641 = f64Stack.pop(); + const int = i32Stack.pop(); + const int1 = i32Stack.pop(); + const bool = i32Stack.pop() !== 0; + const bool1 = i32Stack.pop() !== 0; return { tag: ComplexResultValues.Tag.Comprehensive, param0: bool1, param1: bool, param2: int1, param3: int, param4: f641, param5: f64, param6: string2, param7: string1, param8: string }; } case ComplexResultValues.Tag.Info: return { tag: ComplexResultValues.Tag.Info }; @@ -328,19 +324,19 @@ export async function createInstantiator(options, swift) { case ResultValues.Tag.Success: { const bytes = textEncoder.encode(value.param0); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const cleanup = () => { swift.memory.release(id); }; return { caseId: ResultValues.Tag.Success, cleanup }; } case ResultValues.Tag.Failure: { - tmpParamInts.push((value.param1 | 0)); + i32Stack.push((value.param1 | 0)); const bytes = textEncoder.encode(value.param0); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const cleanup = () => { swift.memory.release(id); }; @@ -349,10 +345,10 @@ export async function createInstantiator(options, swift) { case ResultValues.Tag.Status: { const bytes = textEncoder.encode(value.param2); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); - tmpParamInts.push((value.param1 | 0)); - tmpParamInts.push(value.param0 ? 1 : 0); + i32Stack.push(bytes.length); + i32Stack.push(id); + i32Stack.push((value.param1 | 0)); + i32Stack.push(value.param0 ? 1 : 0); const cleanup = () => { swift.memory.release(id); }; @@ -365,18 +361,18 @@ export async function createInstantiator(options, swift) { tag = tag | 0; switch (tag) { case ResultValues.Tag.Success: { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); return { tag: ResultValues.Tag.Success, param0: string }; } case ResultValues.Tag.Failure: { - const int = tmpRetInts.pop(); - const string = tmpRetStrings.pop(); + const int = i32Stack.pop(); + const string = strStack.pop(); return { tag: ResultValues.Tag.Failure, param0: string, param1: int }; } case ResultValues.Tag.Status: { - const string = tmpRetStrings.pop(); - const int = tmpRetInts.pop(); - const bool = tmpRetInts.pop() !== 0; + const string = strStack.pop(); + const int = i32Stack.pop(); + const bool = i32Stack.pop() !== 0; return { tag: ResultValues.Tag.Status, param0: bool, param1: int, param2: string }; } default: throw new Error("Unknown ResultValues tag returned from Swift: " + String(tag)); @@ -392,19 +388,19 @@ export async function createInstantiator(options, swift) { case NetworkingResultValues.Tag.Success: { const bytes = textEncoder.encode(value.param0); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const cleanup = () => { swift.memory.release(id); }; return { caseId: NetworkingResultValues.Tag.Success, cleanup }; } case NetworkingResultValues.Tag.Failure: { - tmpParamInts.push((value.param1 | 0)); + i32Stack.push((value.param1 | 0)); const bytes = textEncoder.encode(value.param0); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const cleanup = () => { swift.memory.release(id); }; @@ -417,12 +413,12 @@ export async function createInstantiator(options, swift) { tag = tag | 0; switch (tag) { case NetworkingResultValues.Tag.Success: { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); return { tag: NetworkingResultValues.Tag.Success, param0: string }; } case NetworkingResultValues.Tag.Failure: { - const int = tmpRetInts.pop(); - const string = tmpRetStrings.pop(); + const int = i32Stack.pop(); + const string = strStack.pop(); return { tag: NetworkingResultValues.Tag.Failure, param0: string, param1: int }; } default: throw new Error("Unknown NetworkingResultValues tag returned from Swift: " + String(tag)); @@ -441,13 +437,13 @@ export async function createInstantiator(options, swift) { if (isSome) { let bytes = textEncoder.encode(value.param0); id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); } else { - tmpParamInts.push(0); - tmpParamInts.push(0); + i32Stack.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const cleanup = () => { if(id) { swift.memory.release(id); @@ -457,11 +453,11 @@ export async function createInstantiator(options, swift) { } case APIOptionalResultValues.Tag.Failure: { const isSome = value.param1 != null; - tmpParamInts.push(isSome ? (value.param1 ? 1 : 0) : 0); - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? (value.param1 ? 1 : 0) : 0); + i32Stack.push(isSome ? 1 : 0); const isSome1 = value.param0 != null; - tmpParamInts.push(isSome1 ? (value.param0 | 0) : 0); - tmpParamInts.push(isSome1 ? 1 : 0); + i32Stack.push(isSome1 ? (value.param0 | 0) : 0); + i32Stack.push(isSome1 ? 1 : 0); const cleanup = undefined; return { caseId: APIOptionalResultValues.Tag.Failure, cleanup }; } @@ -471,19 +467,19 @@ export async function createInstantiator(options, swift) { if (isSome) { let bytes = textEncoder.encode(value.param2); id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); } else { - tmpParamInts.push(0); - tmpParamInts.push(0); + i32Stack.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const isSome1 = value.param1 != null; - tmpParamInts.push(isSome1 ? (value.param1 | 0) : 0); - tmpParamInts.push(isSome1 ? 1 : 0); + i32Stack.push(isSome1 ? (value.param1 | 0) : 0); + i32Stack.push(isSome1 ? 1 : 0); const isSome2 = value.param0 != null; - tmpParamInts.push(isSome2 ? (value.param0 ? 1 : 0) : 0); - tmpParamInts.push(isSome2 ? 1 : 0); + i32Stack.push(isSome2 ? (value.param0 ? 1 : 0) : 0); + i32Stack.push(isSome2 ? 1 : 0); const cleanup = () => { if(id) { swift.memory.release(id); @@ -498,10 +494,10 @@ export async function createInstantiator(options, swift) { tag = tag | 0; switch (tag) { case APIOptionalResultValues.Tag.Success: { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); optional = string; } else { optional = null; @@ -509,18 +505,18 @@ export async function createInstantiator(options, swift) { return { tag: APIOptionalResultValues.Tag.Success, param0: optional }; } case APIOptionalResultValues.Tag.Failure: { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const bool = tmpRetInts.pop() !== 0; + const bool = i32Stack.pop() !== 0; optional = bool; } else { optional = null; } - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optional1; if (isSome1) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); optional1 = int; } else { optional1 = null; @@ -528,26 +524,26 @@ export async function createInstantiator(options, swift) { return { tag: APIOptionalResultValues.Tag.Failure, param0: optional1, param1: optional }; } case APIOptionalResultValues.Tag.Status: { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); optional = string; } else { optional = null; } - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optional1; if (isSome1) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); optional1 = int; } else { optional1 = null; } - const isSome2 = tmpRetInts.pop(); + const isSome2 = i32Stack.pop(); let optional2; if (isSome2) { - const bool = tmpRetInts.pop() !== 0; + const bool = i32Stack.pop() !== 0; optional2 = bool; } else { optional2 = null; @@ -565,26 +561,26 @@ export async function createInstantiator(options, swift) { const enumTag = value.tag; switch (enumTag) { case TypedPayloadResultValues.Tag.Precision: { - tmpParamF32s.push(Math.fround(value.param0)); + f32Stack.push(Math.fround(value.param0)); const cleanup = undefined; return { caseId: TypedPayloadResultValues.Tag.Precision, cleanup }; } case TypedPayloadResultValues.Tag.Direction: { - tmpParamInts.push((value.param0 | 0)); + i32Stack.push((value.param0 | 0)); const cleanup = undefined; return { caseId: TypedPayloadResultValues.Tag.Direction, cleanup }; } case TypedPayloadResultValues.Tag.OptPrecision: { const isSome = value.param0 != null; - tmpParamF32s.push(isSome ? Math.fround(value.param0) : 0.0); - tmpParamInts.push(isSome ? 1 : 0); + f32Stack.push(isSome ? Math.fround(value.param0) : 0.0); + i32Stack.push(isSome ? 1 : 0); const cleanup = undefined; return { caseId: TypedPayloadResultValues.Tag.OptPrecision, cleanup }; } case TypedPayloadResultValues.Tag.OptDirection: { const isSome = value.param0 != null; - tmpParamInts.push(isSome ? (value.param0 | 0) : 0); - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? (value.param0 | 0) : 0); + i32Stack.push(isSome ? 1 : 0); const cleanup = undefined; return { caseId: TypedPayloadResultValues.Tag.OptDirection, cleanup }; } @@ -599,18 +595,18 @@ export async function createInstantiator(options, swift) { tag = tag | 0; switch (tag) { case TypedPayloadResultValues.Tag.Precision: { - const rawValue = tmpRetF32s.pop(); + const rawValue = f32Stack.pop(); return { tag: TypedPayloadResultValues.Tag.Precision, param0: rawValue }; } case TypedPayloadResultValues.Tag.Direction: { - const caseId = tmpRetInts.pop(); + const caseId = i32Stack.pop(); return { tag: TypedPayloadResultValues.Tag.Direction, param0: caseId }; } case TypedPayloadResultValues.Tag.OptPrecision: { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const rawValue = tmpRetF32s.pop(); + const rawValue = f32Stack.pop(); optional = rawValue; } else { optional = null; @@ -618,10 +614,10 @@ export async function createInstantiator(options, swift) { return { tag: TypedPayloadResultValues.Tag.OptPrecision, param0: optional }; } case TypedPayloadResultValues.Tag.OptDirection: { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const caseId = tmpRetInts.pop(); + const caseId = i32Stack.pop(); optional = caseId; } else { optional = null; @@ -647,19 +643,19 @@ export async function createInstantiator(options, swift) { return { caseId: AllTypesResultValues.Tag.StructPayload, cleanup }; } case AllTypesResultValues.Tag.ClassPayload: { - tmpParamPointers.push(value.param0.pointer); + ptrStack.push(value.param0.pointer); const cleanup = undefined; return { caseId: AllTypesResultValues.Tag.ClassPayload, cleanup }; } case AllTypesResultValues.Tag.JsObjectPayload: { const objId = swift.memory.retain(value.param0); - tmpParamInts.push(objId); + i32Stack.push(objId); const cleanup = undefined; return { caseId: AllTypesResultValues.Tag.JsObjectPayload, cleanup }; } case AllTypesResultValues.Tag.NestedEnum: { const { caseId: caseId, cleanup: enumCleanup } = enumHelpers.APIResult.lower(value.param0); - tmpParamInts.push(caseId); + i32Stack.push(caseId); const cleanup = () => { if (enumCleanup) { enumCleanup(); } }; @@ -668,9 +664,9 @@ export async function createInstantiator(options, swift) { case AllTypesResultValues.Tag.ArrayPayload: { const arrayCleanups = []; for (const elem of value.param0) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } - tmpParamInts.push(value.param0.length); + i32Stack.push(value.param0.length); const cleanup = () => { for (const cleanup of arrayCleanups) { cleanup(); } }; @@ -691,25 +687,25 @@ export async function createInstantiator(options, swift) { return { tag: AllTypesResultValues.Tag.StructPayload, param0: struct }; } case AllTypesResultValues.Tag.ClassPayload: { - const ptr = tmpRetPointers.pop(); + const ptr = ptrStack.pop(); const obj = _exports['User'].__construct(ptr); return { tag: AllTypesResultValues.Tag.ClassPayload, param0: obj }; } case AllTypesResultValues.Tag.JsObjectPayload: { - const objId = tmpRetInts.pop(); + const objId = i32Stack.pop(); const obj = swift.memory.getObject(objId); swift.memory.release(objId); return { tag: AllTypesResultValues.Tag.JsObjectPayload, param0: obj }; } case AllTypesResultValues.Tag.NestedEnum: { - const enumValue = enumHelpers.APIResult.lift(tmpRetTag.pop(), ); + const enumValue = enumHelpers.APIResult.lift(tagStack.pop(), ); return { tag: AllTypesResultValues.Tag.NestedEnum, param0: enumValue }; } case AllTypesResultValues.Tag.ArrayPayload: { - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); arrayResult.push(int); } arrayResult.reverse(); @@ -733,7 +729,7 @@ export async function createInstantiator(options, swift) { const structResult = structHelpers.Point.lower(value.param0); nestedCleanup = structResult.cleanup; } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const cleanup = () => { if (nestedCleanup) { nestedCleanup(); } }; @@ -742,11 +738,11 @@ export async function createInstantiator(options, swift) { case OptionalAllTypesResultValues.Tag.OptClass: { const isSome = value.param0 != null; if (isSome) { - tmpParamPointers.push(value.param0.pointer); + ptrStack.push(value.param0.pointer); } else { - tmpParamPointers.push(0); + ptrStack.push(0); } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const cleanup = undefined; return { caseId: OptionalAllTypesResultValues.Tag.OptClass, cleanup }; } @@ -755,12 +751,12 @@ export async function createInstantiator(options, swift) { let id; if (isSome) { id = swift.memory.retain(value.param0); - tmpParamInts.push(id); + i32Stack.push(id); } else { id = undefined; - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const cleanup = undefined; return { caseId: OptionalAllTypesResultValues.Tag.OptJSObject, cleanup }; } @@ -771,11 +767,11 @@ export async function createInstantiator(options, swift) { const enumResult = enumHelpers.APIResult.lower(value.param0); enumCaseId = enumResult.caseId; enumCleanup = enumResult.cleanup; - tmpParamInts.push(enumCaseId); + i32Stack.push(enumCaseId); } else { - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const cleanup = () => { if (enumCleanup) { enumCleanup(); } }; @@ -787,14 +783,14 @@ export async function createInstantiator(options, swift) { if (isSome) { const arrayCleanups = []; for (const elem of value.param0) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } - tmpParamInts.push(value.param0.length); + i32Stack.push(value.param0.length); arrCleanup = () => { for (const cleanup of arrayCleanups) { cleanup(); } }; } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const cleanup = () => { if (arrCleanup) { arrCleanup(); } }; @@ -811,7 +807,7 @@ export async function createInstantiator(options, swift) { tag = tag | 0; switch (tag) { case OptionalAllTypesResultValues.Tag.OptStruct: { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { const struct = structHelpers.Point.lift(); @@ -822,10 +818,10 @@ export async function createInstantiator(options, swift) { return { tag: OptionalAllTypesResultValues.Tag.OptStruct, param0: optional }; } case OptionalAllTypesResultValues.Tag.OptClass: { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const ptr = tmpRetPointers.pop(); + const ptr = ptrStack.pop(); const obj = _exports['User'].__construct(ptr); optional = obj; } else { @@ -834,10 +830,10 @@ export async function createInstantiator(options, swift) { return { tag: OptionalAllTypesResultValues.Tag.OptClass, param0: optional }; } case OptionalAllTypesResultValues.Tag.OptJSObject: { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const objId = tmpRetInts.pop(); + const objId = i32Stack.pop(); const obj = swift.memory.getObject(objId); swift.memory.release(objId); optional = obj; @@ -847,10 +843,10 @@ export async function createInstantiator(options, swift) { return { tag: OptionalAllTypesResultValues.Tag.OptJSObject, param0: optional }; } case OptionalAllTypesResultValues.Tag.OptNestedEnum: { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const caseId = tmpRetInts.pop(); + const caseId = i32Stack.pop(); optional = enumHelpers.APIResult.lift(caseId); } else { optional = null; @@ -858,13 +854,13 @@ export async function createInstantiator(options, swift) { return { tag: OptionalAllTypesResultValues.Tag.OptNestedEnum, param0: optional }; } case OptionalAllTypesResultValues.Tag.OptArray: { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); arrayResult.push(int); } arrayResult.reverse(); @@ -916,36 +912,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } @@ -1139,13 +1135,13 @@ export async function createInstantiator(options, swift) { }, getResult: function bjs_getResult() { instance.exports.bjs_getResult(); - const ret = enumHelpers.APIResult.lift(tmpRetTag.pop()); + const ret = enumHelpers.APIResult.lift(tagStack.pop()); return ret; }, roundtripAPIResult: function bjs_roundtripAPIResult(result) { const { caseId: resultCaseId, cleanup: resultCleanup } = enumHelpers.APIResult.lower(result); instance.exports.bjs_roundtripAPIResult(resultCaseId); - const ret = enumHelpers.APIResult.lift(tmpRetTag.pop()); + const ret = enumHelpers.APIResult.lift(tagStack.pop()); if (resultCleanup) { resultCleanup(); } return ret; }, @@ -1158,7 +1154,7 @@ export async function createInstantiator(options, swift) { resultCleanup = enumResult.cleanup; } instance.exports.bjs_roundTripOptionalAPIResult(+isSome, isSome ? resultCaseId : 0); - const tag = tmpRetTag.pop(); + const tag = tagStack.pop(); const isNull = (tag === -1); let optResult; if (isNull) { @@ -1176,13 +1172,13 @@ export async function createInstantiator(options, swift) { }, getComplexResult: function bjs_getComplexResult() { instance.exports.bjs_getComplexResult(); - const ret = enumHelpers.ComplexResult.lift(tmpRetTag.pop()); + const ret = enumHelpers.ComplexResult.lift(tagStack.pop()); return ret; }, roundtripComplexResult: function bjs_roundtripComplexResult(result) { const { caseId: resultCaseId, cleanup: resultCleanup } = enumHelpers.ComplexResult.lower(result); instance.exports.bjs_roundtripComplexResult(resultCaseId); - const ret = enumHelpers.ComplexResult.lift(tmpRetTag.pop()); + const ret = enumHelpers.ComplexResult.lift(tagStack.pop()); if (resultCleanup) { resultCleanup(); } return ret; }, @@ -1195,7 +1191,7 @@ export async function createInstantiator(options, swift) { resultCleanup = enumResult.cleanup; } instance.exports.bjs_roundTripOptionalComplexResult(+isSome, isSome ? resultCaseId : 0); - const tag = tmpRetTag.pop(); + const tag = tagStack.pop(); const isNull = (tag === -1); let optResult; if (isNull) { @@ -1215,7 +1211,7 @@ export async function createInstantiator(options, swift) { resultCleanup = enumResult.cleanup; } instance.exports.bjs_roundTripOptionalUtilitiesResult(+isSome, isSome ? resultCaseId : 0); - const tag = tmpRetTag.pop(); + const tag = tagStack.pop(); const isNull = (tag === -1); let optResult; if (isNull) { @@ -1235,7 +1231,7 @@ export async function createInstantiator(options, swift) { resultCleanup = enumResult.cleanup; } instance.exports.bjs_roundTripOptionalNetworkingResult(+isSome, isSome ? resultCaseId : 0); - const tag = tmpRetTag.pop(); + const tag = tagStack.pop(); const isNull = (tag === -1); let optResult; if (isNull) { @@ -1255,7 +1251,7 @@ export async function createInstantiator(options, swift) { resultCleanup = enumResult.cleanup; } instance.exports.bjs_roundTripOptionalAPIOptionalResult(+isSome, isSome ? resultCaseId : 0); - const tag = tmpRetTag.pop(); + const tag = tagStack.pop(); const isNull = (tag === -1); let optResult; if (isNull) { @@ -1282,7 +1278,7 @@ export async function createInstantiator(options, swift) { result2Cleanup = enumResult1.cleanup; } instance.exports.bjs_compareAPIResults(+isSome, isSome ? result1CaseId : 0, +isSome1, isSome1 ? result2CaseId : 0); - const tag = tmpRetTag.pop(); + const tag = tagStack.pop(); const isNull = (tag === -1); let optResult; if (isNull) { @@ -1297,7 +1293,7 @@ export async function createInstantiator(options, swift) { roundTripTypedPayloadResult: function bjs_roundTripTypedPayloadResult(result) { const { caseId: resultCaseId, cleanup: resultCleanup } = enumHelpers.TypedPayloadResult.lower(result); instance.exports.bjs_roundTripTypedPayloadResult(resultCaseId); - const ret = enumHelpers.TypedPayloadResult.lift(tmpRetTag.pop()); + const ret = enumHelpers.TypedPayloadResult.lift(tagStack.pop()); if (resultCleanup) { resultCleanup(); } return ret; }, @@ -1310,7 +1306,7 @@ export async function createInstantiator(options, swift) { resultCleanup = enumResult.cleanup; } instance.exports.bjs_roundTripOptionalTypedPayloadResult(+isSome, isSome ? resultCaseId : 0); - const tag = tmpRetTag.pop(); + const tag = tagStack.pop(); const isNull = (tag === -1); let optResult; if (isNull) { @@ -1324,7 +1320,7 @@ export async function createInstantiator(options, swift) { roundTripAllTypesResult: function bjs_roundTripAllTypesResult(result) { const { caseId: resultCaseId, cleanup: resultCleanup } = enumHelpers.AllTypesResult.lower(result); instance.exports.bjs_roundTripAllTypesResult(resultCaseId); - const ret = enumHelpers.AllTypesResult.lift(tmpRetTag.pop()); + const ret = enumHelpers.AllTypesResult.lift(tagStack.pop()); if (resultCleanup) { resultCleanup(); } return ret; }, @@ -1337,7 +1333,7 @@ export async function createInstantiator(options, swift) { resultCleanup = enumResult.cleanup; } instance.exports.bjs_roundTripOptionalAllTypesResult(+isSome, isSome ? resultCaseId : 0); - const tag = tmpRetTag.pop(); + const tag = tagStack.pop(); const isNull = (tag === -1); let optResult; if (isNull) { @@ -1351,7 +1347,7 @@ export async function createInstantiator(options, swift) { roundTripOptionalPayloadResult: function bjs_roundTripOptionalPayloadResult(result) { const { caseId: resultCaseId, cleanup: resultCleanup } = enumHelpers.OptionalAllTypesResult.lower(result); instance.exports.bjs_roundTripOptionalPayloadResult(resultCaseId); - const ret = enumHelpers.OptionalAllTypesResult.lift(tmpRetTag.pop()); + const ret = enumHelpers.OptionalAllTypesResult.lift(tagStack.pop()); if (resultCleanup) { resultCleanup(); } return ret; }, @@ -1364,7 +1360,7 @@ export async function createInstantiator(options, swift) { resultCleanup = enumResult.cleanup; } instance.exports.bjs_roundTripOptionalPayloadResultOpt(+isSome, isSome ? resultCaseId : 0); - const tag = tmpRetTag.pop(); + const tag = tagStack.pop(); const isNull = (tag === -1); let optResult; if (isNull) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js index 9ca596a6e..0c8eee729 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js @@ -42,16 +42,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -94,36 +90,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js index a7a2c4b98..28cfe9dd9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js @@ -62,16 +62,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -114,36 +110,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js index b195b6945..a933ed735 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js @@ -43,16 +43,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -95,36 +91,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js index c906f27ff..06ebbe269 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js @@ -93,16 +93,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -146,36 +142,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js index ac6170b08..97f34b1bb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js index dc2220715..bc186d4c1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -70,36 +66,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js index daa601aed..3a04c5308 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } @@ -205,29 +201,29 @@ export async function createInstantiator(options, swift) { const TestModule = importObject["TestModule"] = importObject["TestModule"] || {}; TestModule["bjs_roundtrip"] = function bjs_roundtrip() { try { - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); arrayResult.push(int); } arrayResult.reverse(); let ret = imports.roundtrip(arrayResult); const arrayCleanups = []; for (const elem of ret) { - tmpParamInts.push((elem | 0)); + i32Stack.push((elem | 0)); } - tmpParamInts.push(ret.length); + i32Stack.push(ret.length); } catch (error) { setException(error); } } TestModule["bjs_logStrings"] = function bjs_logStrings() { try { - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); arrayResult.push(string); } arrayResult.reverse(); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js index 1e4e1f508..4f3fa39a6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -43,17 +39,17 @@ export async function createInstantiator(options, swift) { } else { id = undefined; } - tmpParamInts.push(id !== undefined ? id : 0); + i32Stack.push(id !== undefined ? id : 0); const isSome = value.optionalFoo != null; let id1; if (isSome) { id1 = swift.memory.retain(value.optionalFoo); - tmpParamInts.push(id1); + i32Stack.push(id1); } else { id1 = undefined; - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const cleanup = () => { if(id !== undefined && id !== 0) { try { @@ -71,10 +67,10 @@ export async function createInstantiator(options, swift) { return { cleanup }; }, lift: () => { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const objectId = tmpRetInts.pop(); + const objectId = i32Stack.pop(); let value; if (objectId !== 0) { value = swift.memory.getObject(objectId); @@ -86,7 +82,7 @@ export async function createInstantiator(options, swift) { } else { optional = null; } - const objectId1 = tmpRetInts.pop(); + const objectId1 = i32Stack.pop(); let value1; if (objectId1 !== 0) { value1 = swift.memory.getObject(objectId1); @@ -135,36 +131,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } @@ -318,14 +314,14 @@ export async function createInstantiator(options, swift) { const arrayCleanups = []; for (const elem of foos) { const objId = swift.memory.retain(elem); - tmpParamInts.push(objId); + i32Stack.push(objId); } - tmpParamInts.push(foos.length); + i32Stack.push(foos.length); instance.exports.bjs_processFooArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const objId1 = tmpRetInts.pop(); + const objId1 = i32Stack.pop(); const obj = swift.memory.getObject(objId1); swift.memory.release(objId1); arrayResult.push(obj); @@ -340,23 +336,23 @@ export async function createInstantiator(options, swift) { const isSome = elem != null ? 1 : 0; if (isSome) { const objId = swift.memory.retain(elem); - tmpParamInts.push(objId); + i32Stack.push(objId); } else { - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome); + i32Stack.push(isSome); } - tmpParamInts.push(foos.length); + i32Stack.push(foos.length); instance.exports.bjs_processOptionalFooArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optValue; if (isSome1 === 0) { optValue = null; } else { - const objId1 = tmpRetInts.pop(); + const objId1 = i32Stack.pop(); const obj = swift.memory.getObject(objId1); swift.memory.release(objId1); optValue = obj; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js index d64ff7e96..d3514253a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js index 096e3a345..2bbddd396 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js index cacaa87a3..c05e4e114 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js index f5c360bb0..754a17e3c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -160,36 +156,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } @@ -305,21 +301,21 @@ export async function createInstantiator(options, swift) { const jsValue = __bjs_jsValueLift(valueKind, valuePayload1, valuePayload2); let ret = imports.jsEchoJSValue(jsValue); const [retKind, retPayload1, retPayload2] = __bjs_jsValueLower(ret); - tmpParamInts.push(retKind); - tmpParamInts.push(retPayload1); - tmpParamF64s.push(retPayload2); + i32Stack.push(retKind); + i32Stack.push(retPayload1); + f64Stack.push(retPayload2); } catch (error) { setException(error); } } TestModule["bjs_jsEchoJSValueArray"] = function bjs_jsEchoJSValueArray() { try { - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const jsValuePayload2 = tmpRetF64s.pop(); - const jsValuePayload1 = tmpRetInts.pop(); - const jsValueKind = tmpRetInts.pop(); + const jsValuePayload2 = f64Stack.pop(); + const jsValuePayload1 = i32Stack.pop(); + const jsValueKind = i32Stack.pop(); const jsValue = __bjs_jsValueLift(jsValueKind, jsValuePayload1, jsValuePayload2); arrayResult.push(jsValue); } @@ -328,11 +324,11 @@ export async function createInstantiator(options, swift) { const arrayCleanups = []; for (const elem of ret) { const [elemKind, elemPayload1, elemPayload2] = __bjs_jsValueLower(elem); - tmpParamInts.push(elemKind); - tmpParamInts.push(elemPayload1); - tmpParamF64s.push(elemPayload2); + i32Stack.push(elemKind); + i32Stack.push(elemPayload1); + f64Stack.push(elemPayload2); } - tmpParamInts.push(ret.length); + i32Stack.push(ret.length); } catch (error) { setException(error); } @@ -389,9 +385,9 @@ export async function createInstantiator(options, swift) { echo(value) { const [valueKind, valuePayload1, valuePayload2] = __bjs_jsValueLower(value); instance.exports.bjs_JSValueHolder_echo(this.pointer, valueKind, valuePayload1, valuePayload2); - const jsValuePayload2 = tmpRetF64s.pop(); - const jsValuePayload1 = tmpRetInts.pop(); - const jsValueKind = tmpRetInts.pop(); + const jsValuePayload2 = f64Stack.pop(); + const jsValuePayload1 = i32Stack.pop(); + const jsValueKind = i32Stack.pop(); const jsValue = __bjs_jsValueLift(jsValueKind, jsValuePayload1, jsValuePayload2); return jsValue; } @@ -399,12 +395,12 @@ export async function createInstantiator(options, swift) { const isSome = value != null; const [valueKind, valuePayload1, valuePayload2] = __bjs_jsValueLower(value); instance.exports.bjs_JSValueHolder_echoOptional(this.pointer, +isSome, valueKind, valuePayload1, valuePayload2); - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optResult; if (isSome1) { - const jsValuePayload2 = tmpRetF64s.pop(); - const jsValuePayload1 = tmpRetInts.pop(); - const jsValueKind = tmpRetInts.pop(); + const jsValuePayload2 = f64Stack.pop(); + const jsValuePayload1 = i32Stack.pop(); + const jsValueKind = i32Stack.pop(); const jsValue = __bjs_jsValueLift(jsValueKind, jsValuePayload1, jsValuePayload2); optResult = jsValue; } else { @@ -414,9 +410,9 @@ export async function createInstantiator(options, swift) { } get value() { instance.exports.bjs_JSValueHolder_value_get(this.pointer); - const jsValuePayload2 = tmpRetF64s.pop(); - const jsValuePayload1 = tmpRetInts.pop(); - const jsValueKind = tmpRetInts.pop(); + const jsValuePayload2 = f64Stack.pop(); + const jsValuePayload1 = i32Stack.pop(); + const jsValueKind = i32Stack.pop(); const jsValue = __bjs_jsValueLift(jsValueKind, jsValuePayload1, jsValuePayload2); return jsValue; } @@ -426,12 +422,12 @@ export async function createInstantiator(options, swift) { } get optionalValue() { instance.exports.bjs_JSValueHolder_optionalValue_get(this.pointer); - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optResult; if (isSome) { - const jsValuePayload2 = tmpRetF64s.pop(); - const jsValuePayload1 = tmpRetInts.pop(); - const jsValueKind = tmpRetInts.pop(); + const jsValuePayload2 = f64Stack.pop(); + const jsValuePayload1 = i32Stack.pop(); + const jsValueKind = i32Stack.pop(); const jsValue = __bjs_jsValueLift(jsValueKind, jsValuePayload1, jsValuePayload2); optResult = jsValue; } else { @@ -450,9 +446,9 @@ export async function createInstantiator(options, swift) { roundTripJSValue: function bjs_roundTripJSValue(value) { const [valueKind, valuePayload1, valuePayload2] = __bjs_jsValueLower(value); instance.exports.bjs_roundTripJSValue(valueKind, valuePayload1, valuePayload2); - const jsValuePayload2 = tmpRetF64s.pop(); - const jsValuePayload1 = tmpRetInts.pop(); - const jsValueKind = tmpRetInts.pop(); + const jsValuePayload2 = f64Stack.pop(); + const jsValuePayload1 = i32Stack.pop(); + const jsValueKind = i32Stack.pop(); const jsValue = __bjs_jsValueLift(jsValueKind, jsValuePayload1, jsValuePayload2); return jsValue; }, @@ -460,12 +456,12 @@ export async function createInstantiator(options, swift) { const isSome = value != null; const [valueKind, valuePayload1, valuePayload2] = __bjs_jsValueLower(value); instance.exports.bjs_roundTripOptionalJSValue(+isSome, valueKind, valuePayload1, valuePayload2); - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optResult; if (isSome1) { - const jsValuePayload2 = tmpRetF64s.pop(); - const jsValuePayload1 = tmpRetInts.pop(); - const jsValueKind = tmpRetInts.pop(); + const jsValuePayload2 = f64Stack.pop(); + const jsValuePayload1 = i32Stack.pop(); + const jsValueKind = i32Stack.pop(); const jsValue = __bjs_jsValueLift(jsValueKind, jsValuePayload1, jsValuePayload2); optResult = jsValue; } else { @@ -477,18 +473,18 @@ export async function createInstantiator(options, swift) { const arrayCleanups = []; for (const elem of values) { const [elemKind, elemPayload1, elemPayload2] = __bjs_jsValueLower(elem); - tmpParamInts.push(elemKind); - tmpParamInts.push(elemPayload1); - tmpParamF64s.push(elemPayload2); + i32Stack.push(elemKind); + i32Stack.push(elemPayload1); + f64Stack.push(elemPayload2); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); instance.exports.bjs_roundTripJSValueArray(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const jsValuePayload2 = tmpRetF64s.pop(); - const jsValuePayload1 = tmpRetInts.pop(); - const jsValueKind = tmpRetInts.pop(); + const jsValuePayload2 = f64Stack.pop(); + const jsValuePayload1 = i32Stack.pop(); + const jsValueKind = i32Stack.pop(); const jsValue = __bjs_jsValueLift(jsValueKind, jsValuePayload1, jsValuePayload2); arrayResult.push(jsValue); } @@ -503,23 +499,23 @@ export async function createInstantiator(options, swift) { const arrayCleanups = []; for (const elem of values) { const [elemKind, elemPayload1, elemPayload2] = __bjs_jsValueLower(elem); - tmpParamInts.push(elemKind); - tmpParamInts.push(elemPayload1); - tmpParamF64s.push(elemPayload2); + i32Stack.push(elemKind); + i32Stack.push(elemPayload1); + f64Stack.push(elemPayload2); } - tmpParamInts.push(values.length); + i32Stack.push(values.length); valuesCleanups.push(() => { for (const cleanup of arrayCleanups) { cleanup(); } }); } instance.exports.bjs_roundTripOptionalJSValueArray(+isSome); - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optResult; if (isSome1) { - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const jsValuePayload2 = tmpRetF64s.pop(); - const jsValuePayload1 = tmpRetInts.pop(); - const jsValueKind = tmpRetInts.pop(); + const jsValuePayload2 = f64Stack.pop(); + const jsValuePayload1 = i32Stack.pop(); + const jsValueKind = i32Stack.pop(); const jsValue = __bjs_jsValueLift(jsValueKind, jsValuePayload1, jsValuePayload2); arrayResult.push(jsValue); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js index 4ac3b11b7..d9521754f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -70,36 +66,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js index 9eb55f30b..907e955b1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -70,36 +66,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js index e81a95669..cbeae41d8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -70,36 +66,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js index c8d0b935e..92aeeae95 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -70,36 +66,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js index bb2c93649..e2f425455 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -70,36 +66,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js index 0d45b2169..923a1f354 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js index 2d754a5c3..e148b94ac 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js index f348869b2..b803936d0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js index 7be6cd924..916d5e1b5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -70,36 +66,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js index 0ed0be7b6..ee1a2345c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js @@ -42,16 +42,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -66,15 +62,15 @@ export async function createInstantiator(options, swift) { case ResultValues.Tag.Success: { const bytes = textEncoder.encode(value.param0); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const cleanup = () => { swift.memory.release(id); }; return { caseId: ResultValues.Tag.Success, cleanup }; } case ResultValues.Tag.Failure: { - tmpParamInts.push((value.param0 | 0)); + i32Stack.push((value.param0 | 0)); const cleanup = undefined; return { caseId: ResultValues.Tag.Failure, cleanup }; } @@ -85,11 +81,11 @@ export async function createInstantiator(options, swift) { tag = tag | 0; switch (tag) { case ResultValues.Tag.Success: { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); return { tag: ResultValues.Tag.Success, param0: string }; } case ResultValues.Tag.Failure: { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); return { tag: ResultValues.Tag.Failure, param0: int }; } default: throw new Error("Unknown ResultValues tag returned from Swift: " + String(tag)); @@ -133,36 +129,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } @@ -689,9 +685,9 @@ export async function createInstantiator(options, swift) { const arrayCleanups = []; for (const elem of delegates) { const objId = swift.memory.retain(elem); - tmpParamInts.push(objId); + i32Stack.push(objId); } - tmpParamInts.push(delegates.length); + i32Stack.push(delegates.length); const ret = instance.exports.bjs_DelegateManager_init(); for (const cleanup of arrayCleanups) { cleanup(); } return DelegateManager.__construct(ret); @@ -701,10 +697,10 @@ export async function createInstantiator(options, swift) { } get delegates() { instance.exports.bjs_DelegateManager_delegates_get(this.pointer); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const objId = tmpRetInts.pop(); + const objId = i32Stack.pop(); const obj = swift.memory.getObject(objId); swift.memory.release(objId); arrayResult.push(obj); @@ -716,9 +712,9 @@ export async function createInstantiator(options, swift) { const arrayCleanups = []; for (const elem of value) { const objId = swift.memory.retain(elem); - tmpParamInts.push(objId); + i32Stack.push(objId); } - tmpParamInts.push(value.length); + i32Stack.push(value.length); instance.exports.bjs_DelegateManager_delegates_set(this.pointer); for (const cleanup of arrayCleanups) { cleanup(); } } @@ -734,14 +730,14 @@ export async function createInstantiator(options, swift) { const arrayCleanups = []; for (const elem of delegates) { const objId = swift.memory.retain(elem); - tmpParamInts.push(objId); + i32Stack.push(objId); } - tmpParamInts.push(delegates.length); + i32Stack.push(delegates.length); instance.exports.bjs_processDelegates(); - const arrayLen = tmpRetInts.pop(); + const arrayLen = i32Stack.pop(); const arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const objId1 = tmpRetInts.pop(); + const objId1 = i32Stack.pop(); const obj = swift.memory.getObject(objId1); swift.memory.release(objId1); arrayResult.push(obj); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js index 7579c72f7..d07af4cdb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js @@ -29,16 +29,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -53,15 +49,15 @@ export async function createInstantiator(options, swift) { case APIResultValues.Tag.Success: { const bytes = textEncoder.encode(value.param0); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const cleanup = () => { swift.memory.release(id); }; return { caseId: APIResultValues.Tag.Success, cleanup }; } case APIResultValues.Tag.Failure: { - tmpParamInts.push((value.param0 | 0)); + i32Stack.push((value.param0 | 0)); const cleanup = undefined; return { caseId: APIResultValues.Tag.Failure, cleanup }; } @@ -72,11 +68,11 @@ export async function createInstantiator(options, swift) { tag = tag | 0; switch (tag) { case APIResultValues.Tag.Success: { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); return { tag: APIResultValues.Tag.Success, param0: string }; } case APIResultValues.Tag.Failure: { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); return { tag: APIResultValues.Tag.Failure, param0: int }; } default: throw new Error("Unknown APIResultValues tag returned from Swift: " + String(tag)); @@ -120,36 +116,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } @@ -335,7 +331,7 @@ export async function createInstantiator(options, swift) { roundtrip: function(value) { const { caseId: valueCaseId, cleanup: valueCleanup } = enumHelpers.APIResult.lower(value); instance.exports.bjs_APIResult_static_roundtrip(valueCaseId); - const ret = enumHelpers.APIResult.lift(tmpRetTag.pop()); + const ret = enumHelpers.APIResult.lift(tagStack.pop()); if (valueCleanup) { valueCleanup(); } return ret; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js index bb3920888..63c5c964b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js @@ -29,16 +29,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -53,15 +49,15 @@ export async function createInstantiator(options, swift) { case APIResultValues.Tag.Success: { const bytes = textEncoder.encode(value.param0); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const cleanup = () => { swift.memory.release(id); }; return { caseId: APIResultValues.Tag.Success, cleanup }; } case APIResultValues.Tag.Failure: { - tmpParamInts.push((value.param0 | 0)); + i32Stack.push((value.param0 | 0)); const cleanup = undefined; return { caseId: APIResultValues.Tag.Failure, cleanup }; } @@ -72,11 +68,11 @@ export async function createInstantiator(options, swift) { tag = tag | 0; switch (tag) { case APIResultValues.Tag.Success: { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); return { tag: APIResultValues.Tag.Success, param0: string }; } case APIResultValues.Tag.Failure: { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); return { tag: APIResultValues.Tag.Failure, param0: int }; } default: throw new Error("Unknown APIResultValues tag returned from Swift: " + String(tag)); @@ -120,36 +116,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } @@ -329,7 +325,7 @@ export async function createInstantiator(options, swift) { roundtrip: function(value) { const { caseId: valueCaseId, cleanup: valueCleanup } = enumHelpers.APIResult.lower(value); instance.exports.bjs_APIResult_static_roundtrip(valueCaseId); - const ret = enumHelpers.APIResult.lift(tmpRetTag.pop()); + const ret = enumHelpers.APIResult.lift(tagStack.pop()); if (valueCleanup) { valueCleanup(); } return ret; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js index 293ae4f7d..c1d59bf69 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js @@ -23,16 +23,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -75,36 +71,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js index 27e3df464..f086f2919 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js @@ -23,16 +23,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -75,36 +71,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js index e57c5153d..20ea91e3c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js index 74d140236..0f002bf31 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js index 27398d2a4..ee4333f03 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -70,36 +66,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index 36b712362..bc0def6f1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -48,16 +48,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -72,30 +68,30 @@ export async function createInstantiator(options, swift) { case APIResultValues.Tag.Success: { const bytes = textEncoder.encode(value.param0); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const cleanup = () => { swift.memory.release(id); }; return { caseId: APIResultValues.Tag.Success, cleanup }; } case APIResultValues.Tag.Failure: { - tmpParamInts.push((value.param0 | 0)); + i32Stack.push((value.param0 | 0)); const cleanup = undefined; return { caseId: APIResultValues.Tag.Failure, cleanup }; } case APIResultValues.Tag.Flag: { - tmpParamInts.push(value.param0 ? 1 : 0); + i32Stack.push(value.param0 ? 1 : 0); const cleanup = undefined; return { caseId: APIResultValues.Tag.Flag, cleanup }; } case APIResultValues.Tag.Rate: { - tmpParamF32s.push(Math.fround(value.param0)); + f32Stack.push(Math.fround(value.param0)); const cleanup = undefined; return { caseId: APIResultValues.Tag.Rate, cleanup }; } case APIResultValues.Tag.Precise: { - tmpParamF64s.push(value.param0); + f64Stack.push(value.param0); const cleanup = undefined; return { caseId: APIResultValues.Tag.Precise, cleanup }; } @@ -110,23 +106,23 @@ export async function createInstantiator(options, swift) { tag = tag | 0; switch (tag) { case APIResultValues.Tag.Success: { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); return { tag: APIResultValues.Tag.Success, param0: string }; } case APIResultValues.Tag.Failure: { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); return { tag: APIResultValues.Tag.Failure, param0: int }; } case APIResultValues.Tag.Flag: { - const bool = tmpRetInts.pop() !== 0; + const bool = i32Stack.pop() !== 0; return { tag: APIResultValues.Tag.Flag, param0: bool }; } case APIResultValues.Tag.Rate: { - const f32 = tmpRetF32s.pop(); + const f32 = f32Stack.pop(); return { tag: APIResultValues.Tag.Rate, param0: f32 }; } case APIResultValues.Tag.Precise: { - const f64 = tmpRetF64s.pop(); + const f64 = f64Stack.pop(); return { tag: APIResultValues.Tag.Precise, param0: f64 }; } case APIResultValues.Tag.Info: return { tag: APIResultValues.Tag.Info }; @@ -171,36 +167,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js index 52e12ef7c..6c1397fff 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js index b22afee4d..b4cf995cb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js @@ -23,16 +23,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -42,51 +38,51 @@ export async function createInstantiator(options, swift) { const __bjs_createDataPointHelpers = () => { return () => ({ lower: (value) => { - tmpParamF64s.push(value.x); - tmpParamF64s.push(value.y); + f64Stack.push(value.x); + f64Stack.push(value.y); const bytes = textEncoder.encode(value.label); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const isSome = value.optCount != null; if (isSome) { - tmpParamInts.push(value.optCount | 0); + i32Stack.push(value.optCount | 0); } else { - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const isSome1 = value.optFlag != null; if (isSome1) { - tmpParamInts.push(value.optFlag ? 1 : 0); + i32Stack.push(value.optFlag ? 1 : 0); } else { - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome1 ? 1 : 0); + i32Stack.push(isSome1 ? 1 : 0); const cleanup = () => { swift.memory.release(id); }; return { cleanup }; }, lift: () => { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const bool = tmpRetInts.pop() !== 0; + const bool = i32Stack.pop() !== 0; optional = bool; } else { optional = null; } - const isSome1 = tmpRetInts.pop(); + const isSome1 = i32Stack.pop(); let optional1; if (isSome1) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); optional1 = int; } else { optional1 = null; } - const string = tmpRetStrings.pop(); - const f64 = tmpRetF64s.pop(); - const f641 = tmpRetF64s.pop(); + const string = strStack.pop(); + const f64 = f64Stack.pop(); + const f641 = f64Stack.pop(); return { x: f641, y: f64, label: string, optCount: optional1, optFlag: optional }; } }); @@ -96,19 +92,19 @@ export async function createInstantiator(options, swift) { lower: (value) => { const bytes = textEncoder.encode(value.street); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); + i32Stack.push(bytes.length); + i32Stack.push(id); const bytes1 = textEncoder.encode(value.city); const id1 = swift.memory.retain(bytes1); - tmpParamInts.push(bytes1.length); - tmpParamInts.push(id1); + i32Stack.push(bytes1.length); + i32Stack.push(id1); const isSome = value.zipCode != null; if (isSome) { - tmpParamInts.push(value.zipCode | 0); + i32Stack.push(value.zipCode | 0); } else { - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const cleanup = () => { swift.memory.release(id); swift.memory.release(id1); @@ -116,16 +112,16 @@ export async function createInstantiator(options, swift) { return { cleanup }; }, lift: () => { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); optional = int; } else { optional = null; } - const string = tmpRetStrings.pop(); - const string1 = tmpRetStrings.pop(); + const string = strStack.pop(); + const string1 = strStack.pop(); return { street: string1, city: string, zipCode: optional }; } }); @@ -135,22 +131,22 @@ export async function createInstantiator(options, swift) { lower: (value) => { const bytes = textEncoder.encode(value.name); const id = swift.memory.retain(bytes); - tmpParamInts.push(bytes.length); - tmpParamInts.push(id); - tmpParamInts.push((value.age | 0)); + i32Stack.push(bytes.length); + i32Stack.push(id); + i32Stack.push((value.age | 0)); const structResult = structHelpers.Address.lower(value.address); const isSome = value.email != null; let id1; if (isSome) { const bytes1 = textEncoder.encode(value.email); id1 = swift.memory.retain(bytes1); - tmpParamInts.push(bytes1.length); - tmpParamInts.push(id1); + i32Stack.push(bytes1.length); + i32Stack.push(id1); } else { - tmpParamInts.push(0); - tmpParamInts.push(0); + i32Stack.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const cleanup = () => { swift.memory.release(id); if (structResult.cleanup) { structResult.cleanup(); } @@ -159,17 +155,17 @@ export async function createInstantiator(options, swift) { return { cleanup }; }, lift: () => { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const string = tmpRetStrings.pop(); + const string = strStack.pop(); optional = string; } else { optional = null; } const struct = structHelpers.Address.lift(); - const int = tmpRetInts.pop(); - const string1 = tmpRetStrings.pop(); + const int = i32Stack.pop(); + const string1 = strStack.pop(); return { name: string1, age: int, address: struct, email: optional }; } }); @@ -177,14 +173,14 @@ export async function createInstantiator(options, swift) { const __bjs_createSessionHelpers = () => { return () => ({ lower: (value) => { - tmpParamInts.push((value.id | 0)); - tmpParamPointers.push(value.owner.pointer); + i32Stack.push((value.id | 0)); + ptrStack.push(value.owner.pointer); return { cleanup: undefined }; }, lift: () => { - const ptr = tmpRetPointers.pop(); + const ptr = ptrStack.pop(); const obj = _exports['Greeter'].__construct(ptr); - const int = tmpRetInts.pop(); + const int = i32Stack.pop(); return { id: int, owner: obj }; } }); @@ -192,28 +188,28 @@ export async function createInstantiator(options, swift) { const __bjs_createMeasurementHelpers = () => { return () => ({ lower: (value) => { - tmpParamF64s.push(value.value); - tmpParamF32s.push(Math.fround(value.precision)); + f64Stack.push(value.value); + f32Stack.push(Math.fround(value.precision)); const isSome = value.optionalPrecision != null; if (isSome) { - tmpParamF32s.push(Math.fround(value.optionalPrecision)); + f32Stack.push(Math.fround(value.optionalPrecision)); } else { - tmpParamF32s.push(0.0); + f32Stack.push(0.0); } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); return { cleanup: undefined }; }, lift: () => { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const rawValue = tmpRetF32s.pop(); + const rawValue = f32Stack.pop(); optional = rawValue; } else { optional = null; } - const rawValue1 = tmpRetF32s.pop(); - const f64 = tmpRetF64s.pop(); + const rawValue1 = f32Stack.pop(); + const f64 = f64Stack.pop(); return { value: f64, precision: rawValue1, optionalPrecision: optional }; } }); @@ -237,17 +233,17 @@ export async function createInstantiator(options, swift) { } else { id = undefined; } - tmpParamInts.push(id !== undefined ? id : 0); + i32Stack.push(id !== undefined ? id : 0); const isSome = value.optionalObject != null; let id1; if (isSome) { id1 = swift.memory.retain(value.optionalObject); - tmpParamInts.push(id1); + i32Stack.push(id1); } else { id1 = undefined; - tmpParamInts.push(0); + i32Stack.push(0); } - tmpParamInts.push(isSome ? 1 : 0); + i32Stack.push(isSome ? 1 : 0); const cleanup = () => { if(id !== undefined && id !== 0) { try { @@ -265,10 +261,10 @@ export async function createInstantiator(options, swift) { return { cleanup }; }, lift: () => { - const isSome = tmpRetInts.pop(); + const isSome = i32Stack.pop(); let optional; if (isSome) { - const objectId = tmpRetInts.pop(); + const objectId = i32Stack.pop(); let value; if (objectId !== 0) { value = swift.memory.getObject(objectId); @@ -280,7 +276,7 @@ export async function createInstantiator(options, swift) { } else { optional = null; } - const objectId1 = tmpRetInts.pop(); + const objectId1 = i32Stack.pop(); let value1; if (objectId1 !== 0) { value1 = swift.memory.getObject(objectId1); @@ -328,36 +324,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js index f6f63ba8d..959572255 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -37,13 +33,13 @@ export async function createInstantiator(options, swift) { const __bjs_createPointHelpers = () => { return () => ({ lower: (value) => { - tmpParamInts.push((value.x | 0)); - tmpParamInts.push((value.y | 0)); + i32Stack.push((value.x | 0)); + i32Stack.push((value.y | 0)); return { cleanup: undefined }; }, lift: () => { - const int = tmpRetInts.pop(); - const int1 = tmpRetInts.pop(); + const int = i32Stack.pop(); + const int1 = i32Stack.pop(); return { x: int1, y: int }; } }); @@ -85,36 +81,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js index 2e2f8bf6a..487645d70 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -70,36 +66,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js index 9d94d5f0a..dc478a642 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -37,19 +33,19 @@ export async function createInstantiator(options, swift) { const __bjs_createPointerFieldsHelpers = () => { return () => ({ lower: (value) => { - tmpParamPointers.push((value.raw | 0)); - tmpParamPointers.push((value.mutRaw | 0)); - tmpParamPointers.push((value.opaque | 0)); - tmpParamPointers.push((value.ptr | 0)); - tmpParamPointers.push((value.mutPtr | 0)); + ptrStack.push((value.raw | 0)); + ptrStack.push((value.mutRaw | 0)); + ptrStack.push((value.opaque | 0)); + ptrStack.push((value.ptr | 0)); + ptrStack.push((value.mutPtr | 0)); return { cleanup: undefined }; }, lift: () => { - const pointer = tmpRetPointers.pop(); - const pointer1 = tmpRetPointers.pop(); - const pointer2 = tmpRetPointers.pop(); - const pointer3 = tmpRetPointers.pop(); - const pointer4 = tmpRetPointers.pop(); + const pointer = ptrStack.pop(); + const pointer1 = ptrStack.pop(); + const pointer2 = ptrStack.pop(); + const pointer3 = ptrStack.pop(); + const pointer4 = ptrStack.pop(); return { raw: pointer4, mutRaw: pointer3, opaque: pointer2, ptr: pointer1, mutPtr: pointer }; } }); @@ -90,36 +86,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js index 45374093b..428c422e0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js @@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) { let tmpRetOptionalFloat; let tmpRetOptionalDouble; let tmpRetOptionalHeapObject; - let tmpRetTag = []; - let tmpRetStrings = []; - let tmpRetInts = []; - let tmpRetF32s = []; - let tmpRetF64s = []; - let tmpParamInts = []; - let tmpParamF32s = []; - let tmpParamF64s = []; - let tmpRetPointers = []; - let tmpParamPointers = []; + let tagStack = []; + let strStack = []; + let i32Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; let tmpStructCleanups = []; const enumHelpers = {}; const structHelpers = {}; @@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) { swift.memory.release(id); } bjs["swift_js_push_tag"] = function(tag) { - tmpRetTag.push(tag); + tagStack.push(tag); } bjs["swift_js_push_i32"] = function(v) { - tmpRetInts.push(v | 0); + i32Stack.push(v | 0); } bjs["swift_js_push_f32"] = function(v) { - tmpRetF32s.push(Math.fround(v)); + f32Stack.push(Math.fround(v)); } bjs["swift_js_push_f64"] = function(v) { - tmpRetF64s.push(v); + f64Stack.push(v); } bjs["swift_js_push_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); const value = textDecoder.decode(bytes); - tmpRetStrings.push(value); + strStack.push(value); } bjs["swift_js_pop_i32"] = function() { - return tmpParamInts.pop(); + return i32Stack.pop(); } bjs["swift_js_pop_f32"] = function() { - return tmpParamF32s.pop(); + return f32Stack.pop(); } bjs["swift_js_pop_f64"] = function() { - return tmpParamF64s.pop(); + return f64Stack.pop(); } bjs["swift_js_push_pointer"] = function(pointer) { - tmpRetPointers.push(pointer); + ptrStack.push(pointer); } bjs["swift_js_pop_pointer"] = function() { - return tmpParamPointers.pop(); + return ptrStack.pop(); } bjs["swift_js_struct_cleanup"] = function(cleanupId) { if (cleanupId === 0) { return; }