From f16f0651bcf3642b7ac52fbc90dd5f9e9db064e7 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Fri, 17 Apr 2026 11:17:58 +0200 Subject: [PATCH 01/18] feat: Add opt-in identityMode pointer for SwiftHeapObject wrapper identity caching Add identityMode: "pointer" option to BridgeJS instantiation. When enabled, a WeakRef-based identity cache keyed by pointer ensures the same Swift heap pointer returns the same JS wrapper (=== equality). Each class gets its own FinalizationRegistry and identity cache stored on the deinit function. Off by default, zero overhead when not enabled. --- .../Sources/BridgeJSLink/BridgeJSLink.swift | 81 +++++++++++-- .../BridgeJSToolTests/BridgeJSLinkTests.swift | 28 +++++ .../BridgeJSLinkTests/ArrayTypes.d.ts | 1 + .../BridgeJSLinkTests/ArrayTypes.js | 68 +++++++++-- .../BridgeJSLinkTests/Async.d.ts | 1 + .../__Snapshots__/BridgeJSLinkTests/Async.js | 2 + .../BridgeJSLinkTests/AsyncImport.d.ts | 1 + .../BridgeJSLinkTests/AsyncImport.js | 2 + .../BridgeJSLinkTests/AsyncStaticImport.d.ts | 1 + .../BridgeJSLinkTests/AsyncStaticImport.js | 2 + .../BridgeJSLinkTests/DefaultParameters.d.ts | 1 + .../BridgeJSLinkTests/DefaultParameters.js | 68 +++++++++-- .../BridgeJSLinkTests/DictionaryTypes.d.ts | 1 + .../BridgeJSLinkTests/DictionaryTypes.js | 68 +++++++++-- .../EnumAssociatedValue.d.ts | 1 + .../BridgeJSLinkTests/EnumAssociatedValue.js | 68 +++++++++-- .../BridgeJSLinkTests/EnumCase.d.ts | 1 + .../BridgeJSLinkTests/EnumCase.js | 2 + .../EnumNamespace.Global.d.ts | 1 + .../BridgeJSLinkTests/EnumNamespace.Global.js | 68 +++++++++-- .../BridgeJSLinkTests/EnumNamespace.d.ts | 1 + .../BridgeJSLinkTests/EnumNamespace.js | 68 +++++++++-- .../BridgeJSLinkTests/EnumRawType.d.ts | 1 + .../BridgeJSLinkTests/EnumRawType.js | 2 + .../BridgeJSLinkTests/FixedWidthIntegers.d.ts | 1 + .../BridgeJSLinkTests/FixedWidthIntegers.js | 2 + .../BridgeJSLinkTests/GlobalGetter.d.ts | 1 + .../BridgeJSLinkTests/GlobalGetter.js | 2 + .../BridgeJSLinkTests/GlobalThisImports.d.ts | 1 + .../BridgeJSLinkTests/GlobalThisImports.js | 2 + .../BridgeJSLinkTests/ImportArray.d.ts | 1 + .../BridgeJSLinkTests/ImportArray.js | 2 + .../ImportedTypeInExportedInterface.d.ts | 1 + .../ImportedTypeInExportedInterface.js | 2 + .../InvalidPropertyNames.d.ts | 1 + .../BridgeJSLinkTests/InvalidPropertyNames.js | 2 + .../BridgeJSLinkTests/JSClass.d.ts | 1 + .../BridgeJSLinkTests/JSClass.js | 2 + .../JSClassStaticFunctions.d.ts | 1 + .../JSClassStaticFunctions.js | 2 + .../BridgeJSLinkTests/JSValue.d.ts | 1 + .../BridgeJSLinkTests/JSValue.js | 68 +++++++++-- .../BridgeJSLinkTests/MixedGlobal.d.ts | 1 + .../BridgeJSLinkTests/MixedGlobal.js | 68 +++++++++-- .../BridgeJSLinkTests/MixedModules.d.ts | 1 + .../BridgeJSLinkTests/MixedModules.js | 68 +++++++++-- .../BridgeJSLinkTests/MixedPrivate.d.ts | 1 + .../BridgeJSLinkTests/MixedPrivate.js | 68 +++++++++-- .../BridgeJSLinkTests/Namespaces.Global.d.ts | 1 + .../BridgeJSLinkTests/Namespaces.Global.js | 68 +++++++++-- .../BridgeJSLinkTests/Namespaces.d.ts | 1 + .../BridgeJSLinkTests/Namespaces.js | 68 +++++++++-- .../BridgeJSLinkTests/Optionals.d.ts | 1 + .../BridgeJSLinkTests/Optionals.js | 68 +++++++++-- .../PrimitiveParameters.d.ts | 1 + .../BridgeJSLinkTests/PrimitiveParameters.js | 2 + .../BridgeJSLinkTests/PrimitiveReturn.d.ts | 1 + .../BridgeJSLinkTests/PrimitiveReturn.js | 2 + .../BridgeJSLinkTests/PropertyTypes.d.ts | 1 + .../BridgeJSLinkTests/PropertyTypes.js | 68 +++++++++-- .../BridgeJSLinkTests/Protocol.d.ts | 1 + .../BridgeJSLinkTests/Protocol.js | 68 +++++++++-- .../BridgeJSLinkTests/ProtocolInClosure.d.ts | 1 + .../BridgeJSLinkTests/ProtocolInClosure.js | 68 +++++++++-- .../StaticFunctions.Global.d.ts | 1 + .../StaticFunctions.Global.js | 68 +++++++++-- .../BridgeJSLinkTests/StaticFunctions.d.ts | 1 + .../BridgeJSLinkTests/StaticFunctions.js | 68 +++++++++-- .../StaticProperties.Global.d.ts | 1 + .../StaticProperties.Global.js | 68 +++++++++-- .../BridgeJSLinkTests/StaticProperties.d.ts | 1 + .../BridgeJSLinkTests/StaticProperties.js | 68 +++++++++-- .../BridgeJSLinkTests/StringParameter.d.ts | 1 + .../BridgeJSLinkTests/StringParameter.js | 2 + .../BridgeJSLinkTests/StringReturn.d.ts | 1 + .../BridgeJSLinkTests/StringReturn.js | 2 + .../BridgeJSLinkTests/SwiftClass.d.ts | 1 + .../BridgeJSLinkTests/SwiftClass.js | 68 +++++++++-- .../BridgeJSLinkTests/SwiftClosure.d.ts | 1 + .../BridgeJSLinkTests/SwiftClosure.js | 68 +++++++++-- .../SwiftClosureImports.d.ts | 1 + .../BridgeJSLinkTests/SwiftClosureImports.js | 2 + .../BridgeJSLinkTests/SwiftStruct.d.ts | 1 + .../BridgeJSLinkTests/SwiftStruct.js | 68 +++++++++-- .../BridgeJSLinkTests/SwiftStructImports.d.ts | 1 + .../BridgeJSLinkTests/SwiftStructImports.js | 2 + .../BridgeJSLinkTests/Throws.d.ts | 1 + .../__Snapshots__/BridgeJSLinkTests/Throws.js | 2 + .../BridgeJSLinkTests/UnsafePointer.d.ts | 1 + .../BridgeJSLinkTests/UnsafePointer.js | 2 + .../VoidParameterVoidReturn.d.ts | 1 + .../VoidParameterVoidReturn.js | 2 + Plugins/PackageToJS/Templates/index.d.ts | 28 +++-- Plugins/PackageToJS/Templates/index.js | 6 + .../PackageToJS/Templates/instantiate.d.ts | 114 ++++++++++-------- 95 files changed, 1658 insertions(+), 252 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 60b34ff16..d4a7d2497 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -74,7 +74,7 @@ public struct BridgeJSLink { output += lifetimeTrackingClassJs + "\n" } output += """ - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { """ if enableLifetimeTracking { @@ -90,26 +90,81 @@ public struct BridgeJSLink { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + + """ + if enableLifetimeTracking { + output += " TRACKING.finalization(state);\n" + } + output += """ + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; """ if enableLifetimeTracking { - output += " TRACKING.wrap(pointer, deinit, prototype, state);\n" + output += " TRACKING.wrap(pointer, deinit, prototype, state);\n" } output += """ - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { """ if enableLifetimeTracking { - output += " TRACKING.release(this);\n" + output += " TRACKING.release(this);\n" } output += """ const state = this.__swiftHeapObjectState; @@ -117,7 +172,8 @@ public struct BridgeJSLink { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } @@ -915,6 +971,7 @@ public struct BridgeJSLink { printer.write("export function createInstantiator(options: {") printer.indent { printer.write("imports: Imports;") + printer.write("identityMode?: \"none\" | \"pointer\";") } printer.write("}, swift: any): Promise<{") printer.indent { @@ -960,6 +1017,10 @@ public struct BridgeJSLink { try printer.indent { printer.write(lines: generateVariableDeclarations()) + printer.write("const identityMode = options.identityMode === \"pointer\" ? \"pointer\" : \"none\";") + printer.write( + "const shouldUseIdentityMap = identityMode === \"pointer\" && typeof WeakRef !== \"undefined\" && typeof FinalizationRegistry !== \"undefined\";" + ) let bodyPrinter = CodeFragmentPrinter() let allStructs = exportedSkeletons.flatMap { $0.structs } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift index 711b04512..2c78b5ef3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift @@ -105,4 +105,32 @@ import Testing ) try snapshot(bridgeJSLink: bridgeJSLink, name: "MixedModules") } + + @Test + func emitsIdentityModeOptionAndRuntimeScaffolding() throws { + let url = Self.inputsDirectory.appendingPathComponent("SwiftClass.swift") + let sourceFile = Parser.parse(source: try String(contentsOf: url, encoding: .utf8)) + let swiftAPI = SwiftToSkeleton(progress: .silent, moduleName: "TestModule", exposeToGlobal: false) + swiftAPI.addSourceFile(sourceFile, inputFilePath: "SwiftClass.swift") + let outputSkeleton = try swiftAPI.finalize() + let bridgeJSLink = BridgeJSLink( + skeletons: [ + outputSkeleton + ], + sharedMemory: false + ) + + let (outputJs, outputDts) = try bridgeJSLink.link() + + #expect(outputDts.contains("identityMode?: \"none\" | \"pointer\";")) + #expect( + outputJs.contains("const identityMode = options.identityMode === \"pointer\" ? \"pointer\" : \"none\";") + ) + #expect( + outputJs.contains( + "const shouldUseIdentityMap = identityMode === \"pointer\" && typeof WeakRef !== \"undefined\" && typeof FinalizationRegistry !== \"undefined\";" + ) + ) + #expect(outputJs.contains("if (!shouldUseIdentityMap) {")) + } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts index 255249eef..cf51c51f3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts @@ -88,6 +88,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js index 85e9c749a..5ada0b63e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js @@ -43,6 +43,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointHelpers = () => ({ lower: (value) => { f64Stack.push(value.x); @@ -343,7 +345,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -353,13 +355,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -368,7 +419,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.d.ts index aecab090e..29236eb44 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.d.ts @@ -17,6 +17,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js index bf368738e..f5b100887 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.d.ts index e612ae1e1..46e521365 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.d.ts @@ -16,6 +16,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js index 89ab29827..c28de41ea 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; function __bjs_jsValueLower(value) { let kind; let payload1; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.d.ts index 491a66795..e93f46d69 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.d.ts @@ -16,6 +16,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js index 7fd6a0d6b..87e957112 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; function __bjs_jsValueLower(value) { let kind; let payload1; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts index ac5658eb3..dca39489e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts @@ -158,6 +158,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index 004320e4b..25815ac33 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -36,6 +36,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createConfigHelpers = () => ({ lower: (value) => { const bytes = textEncoder.encode(value.name); @@ -274,7 +276,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -284,13 +286,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -299,7 +350,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts index f14b29aa4..d31cf3d66 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts @@ -32,6 +32,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js index b6cf2c253..3a0fae306 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createCountersHelpers = () => ({ lower: (value) => { const bytes = textEncoder.encode(value.name); @@ -283,7 +285,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -293,13 +295,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -308,7 +359,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts index 13f77ae08..eeb0cf428 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts @@ -192,6 +192,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js index eb474d3b0..57391ae89 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js @@ -111,6 +111,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointHelpers = () => ({ lower: (value) => { f64Stack.push(value.x); @@ -950,7 +952,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -960,13 +962,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -975,7 +1026,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.d.ts index 5581df31e..c403d38b4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.d.ts @@ -53,6 +53,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js index fe94c046f..4b1afa60d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js @@ -54,6 +54,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts index b78f0cecd..9fafb6f01 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts @@ -151,6 +151,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js index 948039cf9..182d88415 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js @@ -74,6 +74,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -266,7 +268,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -276,13 +278,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -291,7 +342,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts index 23d872d27..d8a145e3b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts @@ -112,6 +112,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js index 5201350b2..1477579db 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js @@ -55,6 +55,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -247,7 +249,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -257,13 +259,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -272,7 +323,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.d.ts index fbd5ad637..92f043b9d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.d.ts @@ -166,6 +166,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js index 7e5334811..2e3abb637 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js @@ -105,6 +105,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.d.ts index d6ab5aa8f..88ff36752 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.d.ts @@ -26,6 +26,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js index 53ddd7301..32ee37347 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.d.ts index 312f56786..d138fcdde 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.d.ts @@ -14,6 +14,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js index 346b74eac..ec1237f66 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.d.ts index ae1152016..12ac7a310 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.d.ts @@ -16,6 +16,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js index f74095374..be7deb1ea 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.d.ts index 5d1e2c4dc..7b36ca3d8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.d.ts @@ -12,6 +12,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js index 06cf6550e..ecb8cb821 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.d.ts index 22b4e6a1c..a1067c2ef 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.d.ts @@ -23,6 +23,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js index c469fcb58..4dc2da4f5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createFooContainerHelpers = () => ({ lower: (value) => { let id; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.d.ts index ac0e05a91..af7e3ab7d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.d.ts @@ -30,6 +30,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js index 952197c2a..846e08788 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.d.ts index aaf227cf7..80531f880 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.d.ts @@ -24,6 +24,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js index 88a5adb38..622285468 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.d.ts index 3b2b5de99..ab40d43c4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.d.ts @@ -25,6 +25,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js index 10fafb7a0..19b2aa1d6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts index f4c13c610..2b74659a9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts @@ -33,6 +33,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js index 08675da6a..b3604ab74 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; function __bjs_jsValueLower(value) { let kind; let payload1; @@ -337,7 +339,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -347,13 +349,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -362,7 +413,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts index 7b4cc95e6..b093041e7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts @@ -26,6 +26,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js index f4fe4dd61..c2fe2968a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -210,7 +212,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -220,13 +222,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -235,7 +286,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts index 88485232e..c0b6b13bd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts @@ -48,6 +48,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js index 4ce318f40..bb2cccf4c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -218,7 +220,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -228,13 +230,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -243,7 +294,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts index 193857072..169a25c84 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts @@ -26,6 +26,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js index 025a6fc8a..0d83959af 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -210,7 +212,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -220,13 +222,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -235,7 +286,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts index 1353220bc..242c11285 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts @@ -100,6 +100,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js index f4596dba7..91ef6a5a1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -222,7 +224,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -232,13 +234,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -247,7 +298,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts index 6b2d65cd8..62a62b273 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts @@ -59,6 +59,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js index 92ce69cbb..8e4a700a7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -222,7 +224,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -232,13 +234,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -247,7 +298,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts index a5a6e16fb..4b2944157 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts @@ -75,6 +75,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js index 37408a42d..7fe0e9fd0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -466,7 +468,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -476,13 +478,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -491,7 +542,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.d.ts index 961f97635..2adda19be 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.d.ts @@ -12,6 +12,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js index 490f2b4e2..21ae7a2b1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.d.ts index 77e269d16..b524c9666 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.d.ts @@ -17,6 +17,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js index bec07b959..95b23250a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts index 8f65849ab..f7ffa5b66 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts @@ -41,6 +41,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js index 658702a39..25c4c63f3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -210,7 +212,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -220,13 +222,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -235,7 +286,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts index 27cd9212b..1a8178c4f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts @@ -116,6 +116,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js index f82e41703..5d6e3e767 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js @@ -54,6 +54,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createResultValuesHelpers = () => ({ lower: (value) => { const enumTag = value.tag; @@ -570,7 +572,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -580,13 +582,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -595,7 +646,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts index 6b7a9d28d..133982a77 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts @@ -31,6 +31,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js index 13070a3cc..7b8445b4a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.unregistered) { return; } instance?.exports?.bjs_release_swift_closure(state.pointer); @@ -356,7 +358,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -366,13 +368,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -381,7 +432,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts index 5916e1648..6d1f908f8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts @@ -70,6 +70,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js index 42e25545e..c5b83ff23 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js @@ -41,6 +41,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createAPIResultValuesHelpers = () => ({ lower: (value) => { const enumTag = value.tag; @@ -254,7 +256,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -264,13 +266,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -279,7 +330,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts index c9cb26910..a49010973 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts @@ -60,6 +60,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js index 4cf9615fb..b2979b54a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js @@ -41,6 +41,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createAPIResultValuesHelpers = () => ({ lower: (value) => { const enumTag = value.tag; @@ -254,7 +256,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -264,13 +266,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -279,7 +330,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.d.ts index fea3c4b59..336f5589d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.d.ts @@ -65,6 +65,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js index 9928804eb..97d4ff183 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js @@ -35,6 +35,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -215,7 +217,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -225,13 +227,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -240,7 +291,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts index 4ce689edb..2972749cf 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts @@ -51,6 +51,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js index f82ac20df..4a102867c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js @@ -35,6 +35,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -215,7 +217,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -225,13 +227,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -240,7 +291,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.d.ts index 5e45162a1..8e3a8f98f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.d.ts @@ -14,6 +14,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js index 033f08cd2..1ca98a411 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.d.ts index b43ff062c..98ed8ce88 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.d.ts @@ -12,6 +12,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js index 8187b9e92..14c34605b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts index 6d590950c..a450bf30f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts @@ -40,6 +40,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js index cf9faa707..6ab3d427b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -238,7 +240,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -248,13 +250,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -263,7 +314,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts index ccc95eb3b..73635c41d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts @@ -97,6 +97,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index 7e90c9415..101505de1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -60,6 +60,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.unregistered) { return; } instance?.exports?.bjs_release_swift_closure(state.pointer); @@ -897,7 +899,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -907,13 +909,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -922,7 +973,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts index ebf493910..f08b5ac48 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts @@ -12,6 +12,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js index d9df868ec..ac13ec16c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.unregistered) { return; } instance?.exports?.bjs_release_swift_closure(state.pointer); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts index bf4ebc71f..0880baf02 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts @@ -86,6 +86,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js index a60615686..f3e29bf21 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js @@ -35,6 +35,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createDataPointHelpers = () => ({ lower: (value) => { f64Stack.push(value.x); @@ -479,7 +481,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -489,13 +491,62 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { + static identityCacheByDeinit = new WeakMap(); + static finalizerByDeinit = new WeakMap(); + + static __getFinalizer(deinit) { + let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); + if (finalizer) { + return finalizer; + } + + const created = new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + SwiftHeapObject.finalizerByDeinit.set(deinit, created); + return created; + } + static __wrap(pointer, deinit, prototype) { - const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false }; - obj.pointer = pointer; - obj.__swiftHeapObjectState = state; - swiftHeapObjectFinalizationRegistry.register(obj, state, state); - return obj; + const makeFresh = (identityMap, finalizer) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + if (finalizer) { + finalizer.register(obj, state, state); + } + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!shouldUseIdentityMap) { + return makeFresh(null, swiftHeapObjectFinalizationRegistry); + } + + let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); + if (!identityMap) { + identityMap = new Map(); + SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); + } + + const cached = identityMap.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + return cached; + } + if (!cached) { + identityMap.delete(pointer); + } + + const finalizer = SwiftHeapObject.__getFinalizer(deinit); + return makeFresh(identityMap, finalizer); } release() { @@ -504,7 +555,8 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - swiftHeapObjectFinalizationRegistry.unregister(state); + state.finalizer?.unregister(state); + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.d.ts index 3677f1e44..cc963fe97 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.d.ts @@ -15,6 +15,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js index d4f1160f3..f73ecfc2d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointHelpers = () => ({ lower: (value) => { i32Stack.push((value.x | 0)); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.d.ts index 9199ad1ae..1b9223753 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.d.ts @@ -11,6 +11,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js index b2c381a03..acd2d4566 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts index 4f9aa4e4a..ac1c9b771 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts @@ -31,6 +31,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js index ef81ef69e..f61606e02 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointerFieldsHelpers = () => ({ lower: (value) => { ptrStack.push((value.raw | 0)); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.d.ts index 7acba67a0..63276ca35 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.d.ts @@ -12,6 +12,7 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; + identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js index 97948b286..d2b58d2da 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js @@ -30,6 +30,8 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/PackageToJS/Templates/index.d.ts b/Plugins/PackageToJS/Templates/index.d.ts index fb063f0ab..780d30845 100644 --- a/Plugins/PackageToJS/Templates/index.d.ts +++ b/Plugins/PackageToJS/Templates/index.d.ts @@ -1,21 +1,27 @@ -import type { Exports, Imports, ModuleSource } from './instantiate.js' +import type { Exports, Imports, ModuleSource } from "./instantiate.js"; export type Options = { -/* #if TARGET_DEFAULT_PLATFORM_BROWSER */ + /* #if TARGET_DEFAULT_PLATFORM_BROWSER */ /** * The WebAssembly module to instantiate * * If not provided, the module will be fetched from the default path. */ - module?: ModuleSource -/* #endif */ -/* #if HAS_IMPORTS */ + module?: ModuleSource; + /* #endif */ + /* #if HAS_IMPORTS */ /** * The imports to use for the module */ - getImports: () => Imports -/* #endif */ -} + getImports: () => Imports; + /* #endif */ + /** + * Controls whether exported Swift class instances use pointer-based identity mapping. + * When set to "pointer", the same Swift heap pointer will always return the same JS wrapper object. + * Defaults to "none". + */ + identityMode?: "none" | "pointer"; +}; /** * Instantiate and initialize the module @@ -24,6 +30,6 @@ export type Options = { * If you need a more flexible API, see `instantiate`. */ export declare function init(options?: Options): Promise<{ - instance: WebAssembly.Instance, - exports: Exports -}> + instance: WebAssembly.Instance; + exports: Exports; +}>; diff --git a/Plugins/PackageToJS/Templates/index.js b/Plugins/PackageToJS/Templates/index.js index 7cde8edc9..d7636c115 100644 --- a/Plugins/PackageToJS/Templates/index.js +++ b/Plugins/PackageToJS/Templates/index.js @@ -17,6 +17,9 @@ async function initNode(_options) { /* #endif */ }; const instantiateOptions = await defaultNodeSetup(options); + if (_options?.identityMode) { + instantiateOptions.identityMode = _options.identityMode; + } return await instantiate(instantiateOptions); } @@ -44,6 +47,9 @@ async function initBrowser(_options) { spawnWorker: createDefaultWorkerFactoryForBrowser() /* #endif */ }) + if (options?.identityMode) { + instantiateOptions.identityMode = options.identityMode; + } return await instantiate(instantiateOptions); } diff --git a/Plugins/PackageToJS/Templates/instantiate.d.ts b/Plugins/PackageToJS/Templates/instantiate.d.ts index 9074d8d2b..ca515b345 100644 --- a/Plugins/PackageToJS/Templates/instantiate.d.ts +++ b/Plugins/PackageToJS/Templates/instantiate.d.ts @@ -6,8 +6,8 @@ import type { SwiftRuntimeThreadChannel } from "./runtime.js"; export type { Imports, Exports } from "./bridge-js.js"; import type { Imports, Exports } from "./bridge-js.js"; /* #else */ -export type Imports = {} -export type Exports = {} +export type Imports = {}; +export type Exports = {}; /* #endif */ /** @@ -20,45 +20,50 @@ export declare const MODULE_PATH: string; * The type of the WebAssembly memory imported by the module */ export declare const MEMORY_TYPE: { - initial: number, - maximum: number, - shared: boolean -} + initial: number; + maximum: number; + shared: boolean; +}; /* #endif */ export interface WASI { /** * The WASI Preview 1 import object */ - wasiImport: WebAssembly.ModuleImports + wasiImport: WebAssembly.ModuleImports; /** * Initialize the WASI reactor instance * * @param instance - The instance of the WebAssembly module */ - initialize(instance: WebAssembly.Instance): void + initialize(instance: WebAssembly.Instance): void; /** * Set a new instance of the WebAssembly module to the WASI context * Typically used when instantiating a WebAssembly module for a thread * * @param instance - The instance of the WebAssembly module */ - setInstance(instance: WebAssembly.Instance): void + setInstance(instance: WebAssembly.Instance): void; /** * Extract a file from the WASI filesystem * * @param path - The path to the file to extract * @returns The data of the file if it was extracted, undefined otherwise */ - extractFile?(path: string): Uint8Array | undefined + extractFile?(path: string): Uint8Array | undefined; } export type SwiftRuntime = { - UnsafeEventLoopYield: { [Symbol.hasInstance]: (value: unknown) => boolean } + UnsafeEventLoopYield: { [Symbol.hasInstance]: (value: unknown) => boolean }; main(): void; startThread(tid: number, startArg: number): void; -} +}; -export type ModuleSource = WebAssembly.Module | ArrayBufferView | ArrayBuffer | Response | PromiseLike +export type ModuleSource = + | WebAssembly.Module + | ArrayBufferView + | ArrayBuffer + | Response + | PromiseLike; /** * The options for instantiating a WebAssembly module @@ -68,40 +73,44 @@ export type InstantiateOptions = { * The WebAssembly namespace to use for instantiation. * Defaults to the globalThis.WebAssembly object. */ - WebAssembly?: typeof globalThis.WebAssembly, + WebAssembly?: typeof globalThis.WebAssembly; /** * The WebAssembly module to instantiate */ - module: ModuleSource, -/* #if HAS_IMPORTS */ + module: ModuleSource; + /* #if HAS_IMPORTS */ /** * The function to get the imports provided by the embedder */ getImports: (importsContext: { - getInstance: () => WebAssembly.Instance | null, - getExports: () => Exports | null, - _swift: SwiftRuntime, - }) => Imports, -/* #endif */ -/* #if IS_WASI */ + getInstance: () => WebAssembly.Instance | null; + getExports: () => Exports | null; + _swift: SwiftRuntime; + }) => Imports; + /* #endif */ + /* #if IS_WASI */ /** * The WASI implementation to use */ - wasi: WASI, -/* #endif */ -/* #if USE_SHARED_MEMORY */ + wasi: WASI; + /* #endif */ + /* #if USE_SHARED_MEMORY */ /** * The WebAssembly memory to use (must be 'shared') */ - memory: WebAssembly.Memory + memory: WebAssembly.Memory; /** * The thread channel is a set of functions that are used to communicate * between the main thread and the worker thread. */ threadChannel: SwiftRuntimeThreadChannel & { - spawnThread: (module: WebAssembly.Module, memory: WebAssembly.Memory, startArg: any) => number; - } -/* #endif */ + spawnThread: ( + module: WebAssembly.Module, + memory: WebAssembly.Memory, + startArg: any, + ) => number; + }; + /* #endif */ /** * Add imports to the WebAssembly import object * @param imports - The imports to add @@ -110,11 +119,11 @@ export type InstantiateOptions = { addToCoreImports?: ( imports: WebAssembly.Imports, context: { - getInstance: () => WebAssembly.Instance | null, - getExports: () => Exports | null, - _swift: SwiftRuntime, - } - ) => void + getInstance: () => WebAssembly.Instance | null; + getExports: () => Exports | null; + _swift: SwiftRuntime; + }, + ) => void; /** * Instrument the WebAssembly instance @@ -126,25 +135,36 @@ export type InstantiateOptions = { instrumentInstance?: ( instance: WebAssembly.Instance, context: { - _swift: SwiftRuntime - } - ) => WebAssembly.Instance -} + _swift: SwiftRuntime; + }, + ) => WebAssembly.Instance; + + /** + * Controls whether exported Swift class instances use pointer-based identity mapping. + * When set to "pointer", the same Swift heap pointer will always return the same JS wrapper object. + * Defaults to "none". + */ + identityMode?: "none" | "pointer"; +}; /** * Instantiate the given WebAssembly module */ export declare function instantiate(options: InstantiateOptions): Promise<{ - instance: WebAssembly.Instance, - swift: SwiftRuntime, - exports: Exports -}> + instance: WebAssembly.Instance; + swift: SwiftRuntime; + exports: Exports; +}>; /** * Instantiate the given WebAssembly module for a thread */ -export declare function instantiateForThread(tid: number, startArg: number, options: InstantiateOptions): Promise<{ - instance: WebAssembly.Instance, - swift: SwiftRuntime, - exports: Exports -}> +export declare function instantiateForThread( + tid: number, + startArg: number, + options: InstantiateOptions, +): Promise<{ + instance: WebAssembly.Instance; + swift: SwiftRuntime; + exports: Exports; +}>; From 2518e090fa492b65667804c1bdf8ab8e1d23f4ab Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Fri, 17 Apr 2026 11:17:58 +0200 Subject: [PATCH 02/18] refactor: Simplify pointer identity wrapping and class cache generation Replace per-class FinalizationRegistry instances with a single shared registry at module level. Move identity cache from deinit function property to per-class static __identityCache field. Cleaner codegen, fewer allocations, easier to inspect in DevTools. --- .../Sources/BridgeJSLink/BridgeJSLink.swift | 47 +++------------- .../BridgeJSToolTests/BridgeJSLinkTests.swift | 13 +++++ .../BridgeJSLinkTests/ArrayTypes.js | 45 ++++------------ .../BridgeJSLinkTests/DefaultParameters.js | 49 +++++------------ .../BridgeJSLinkTests/DictionaryTypes.js | 41 +++----------- .../BridgeJSLinkTests/EnumAssociatedValue.js | 41 +++----------- .../BridgeJSLinkTests/EnumNamespace.Global.js | 53 ++++++------------- .../BridgeJSLinkTests/EnumNamespace.js | 53 ++++++------------- .../BridgeJSLinkTests/JSValue.js | 41 +++----------- .../BridgeJSLinkTests/MixedGlobal.js | 41 +++----------- .../BridgeJSLinkTests/MixedModules.js | 45 ++++------------ .../BridgeJSLinkTests/MixedPrivate.js | 41 +++----------- .../BridgeJSLinkTests/Namespaces.Global.js | 53 ++++++------------- .../BridgeJSLinkTests/Namespaces.js | 53 ++++++------------- .../BridgeJSLinkTests/Optionals.js | 45 ++++------------ .../BridgeJSLinkTests/PropertyTypes.js | 41 +++----------- .../BridgeJSLinkTests/Protocol.js | 49 +++++------------ .../BridgeJSLinkTests/ProtocolInClosure.js | 41 +++----------- .../StaticFunctions.Global.js | 41 +++----------- .../BridgeJSLinkTests/StaticFunctions.js | 41 +++----------- .../StaticProperties.Global.js | 41 +++----------- .../BridgeJSLinkTests/StaticProperties.js | 41 +++----------- .../BridgeJSLinkTests/SwiftClass.js | 49 +++++------------ .../BridgeJSLinkTests/SwiftClosure.js | 45 ++++------------ .../BridgeJSLinkTests/SwiftStruct.js | 41 +++----------- 25 files changed, 271 insertions(+), 820 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index d4a7d2497..c176664cc 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -85,39 +85,13 @@ public struct BridgeJSLink { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - - """ - if enableLifetimeTracking { - output += " TRACKING.finalization(state);\n" - } - output += """ - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -142,22 +116,15 @@ public struct BridgeJSLink { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -2028,10 +1995,12 @@ extension BridgeJSLink { // Always add __construct and constructor methods for all classes jsPrinter.indent { + jsPrinter.write("static __identityCache = new Map();") + jsPrinter.nextLine() jsPrinter.write("static __construct(ptr) {") jsPrinter.indent { jsPrinter.write( - "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_\(klass.abiName)_deinit, \(klass.name).prototype);" + "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_\(klass.name)_deinit, \(klass.name).prototype, \(klass.name).__identityCache);" ) } jsPrinter.write("}") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift index 2c78b5ef3..877afe323 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift @@ -132,5 +132,18 @@ import Testing ) ) #expect(outputJs.contains("if (!shouldUseIdentityMap) {")) + #expect(outputJs.contains("state.identityMap?.delete(state.pointer);")) + #expect(!outputJs.contains("static finalizerByDeinit")) + #expect(!outputJs.contains("static __getFinalizer")) + #expect(!outputJs.contains("static identityCache = new Map();")) + #expect(!outputJs.contains("identityCacheByDeinit")) + #expect(!outputJs.contains("identityCache ??")) + #expect(outputJs.contains("static __wrap(pointer, deinit, prototype, identityCache)")) + #expect(outputJs.contains("static __identityCache = new Map();")) + #expect( + outputJs.contains( + "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache);" + ) + ) } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js index 5ada0b63e..4f30e2593 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js @@ -350,33 +350,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -395,22 +375,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -425,14 +398,18 @@ export async function createInstantiator(options, swift) { } } class Item extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Item_deinit, Item.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Item_deinit, Item.prototype, Item.__identityCache); } } class MultiArrayContainer extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MultiArrayContainer_deinit, MultiArrayContainer.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MultiArrayContainer_deinit, MultiArrayContainer.prototype, MultiArrayContainer.__identityCache); } constructor(nums, strs) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index 25815ac33..7b97b6608 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -281,33 +281,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -326,22 +306,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -356,8 +329,10 @@ export async function createInstantiator(options, swift) { } } class DefaultGreeter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_DefaultGreeter_deinit, DefaultGreeter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_DefaultGreeter_deinit, DefaultGreeter.prototype, DefaultGreeter.__identityCache); } constructor(name) { @@ -379,8 +354,10 @@ export async function createInstantiator(options, swift) { } } class EmptyGreeter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_EmptyGreeter_deinit, EmptyGreeter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_EmptyGreeter_deinit, EmptyGreeter.prototype, EmptyGreeter.__identityCache); } constructor() { @@ -389,8 +366,10 @@ export async function createInstantiator(options, swift) { } } class ConstructorDefaults extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_ConstructorDefaults_deinit, ConstructorDefaults.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_ConstructorDefaults_deinit, ConstructorDefaults.prototype, ConstructorDefaults.__identityCache); } constructor(name = "Default", count = 42, enabled = true, status = StatusValues.Active, tag = null) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js index 3a0fae306..d6529e0fa 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js @@ -290,33 +290,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -335,22 +315,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -365,8 +338,10 @@ export async function createInstantiator(options, swift) { } } class Box extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Box_deinit, Box.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Box_deinit, Box.prototype, Box.__identityCache); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js index 57391ae89..4c48ed4f5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js @@ -957,33 +957,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -1002,22 +982,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -1032,8 +1005,10 @@ export async function createInstantiator(options, swift) { } } class User extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_User_deinit, User.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_User_deinit, User.prototype, User.__identityCache); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js index 182d88415..6dc03d882 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js @@ -273,33 +273,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -318,22 +298,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -348,8 +321,10 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converter_deinit, Converter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { @@ -371,8 +346,10 @@ export async function createInstantiator(options, swift) { } } class HTTPServer extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_API_HTTPServer_deinit, HTTPServer.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_HTTPServer_deinit, HTTPServer.prototype, HTTPServer.__identityCache); } constructor() { @@ -384,8 +361,10 @@ export async function createInstantiator(options, swift) { } } class TestServer extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_APIV2_Internal_TestServer_deinit, TestServer.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_TestServer_deinit, TestServer.prototype, TestServer.__identityCache); } constructor() { @@ -397,8 +376,10 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Formatting_Converter_deinit, Converter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js index 1477579db..58071b2b1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js @@ -254,33 +254,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -299,22 +279,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -329,8 +302,10 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converter_deinit, Converter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { @@ -352,8 +327,10 @@ export async function createInstantiator(options, swift) { } } class HTTPServer extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_API_HTTPServer_deinit, HTTPServer.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_HTTPServer_deinit, HTTPServer.prototype, HTTPServer.__identityCache); } constructor() { @@ -365,8 +342,10 @@ export async function createInstantiator(options, swift) { } } class TestServer extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_APIV2_Internal_TestServer_deinit, TestServer.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_TestServer_deinit, TestServer.prototype, TestServer.__identityCache); } constructor() { @@ -378,8 +357,10 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Formatting_Converter_deinit, Converter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js index b3604ab74..61ac8dc3a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js @@ -344,33 +344,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -389,22 +369,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -419,8 +392,10 @@ export async function createInstantiator(options, swift) { } } class JSValueHolder extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_JSValueHolder_deinit, JSValueHolder.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_JSValueHolder_deinit, JSValueHolder.prototype, JSValueHolder.__identityCache); } constructor(value, optionalValue) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js index c2fe2968a..9a96fa6b3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js @@ -217,33 +217,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -262,22 +242,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -292,8 +265,10 @@ export async function createInstantiator(options, swift) { } } class GlobalClass extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalAPI_GlobalClass_deinit, GlobalClass.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalClass_deinit, GlobalClass.prototype, GlobalClass.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js index bb2cccf4c..f87d56d13 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js @@ -225,33 +225,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -270,22 +250,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -300,8 +273,10 @@ export async function createInstantiator(options, swift) { } } class GlobalClass extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalAPI_GlobalClass_deinit, GlobalClass.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalClass_deinit, GlobalClass.prototype, GlobalClass.__identityCache); } constructor() { @@ -316,8 +291,10 @@ export async function createInstantiator(options, swift) { } } class PrivateClass extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateAPI_PrivateClass_deinit, PrivateClass.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateClass_deinit, PrivateClass.prototype, PrivateClass.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js index 0d83959af..cd9530dc1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js @@ -217,33 +217,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -262,22 +242,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -292,8 +265,10 @@ export async function createInstantiator(options, swift) { } } class PrivateClass extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateAPI_PrivateClass_deinit, PrivateClass.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateClass_deinit, PrivateClass.prototype, PrivateClass.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js index 91ef6a5a1..a2291e6f3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js @@ -229,33 +229,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -274,22 +254,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -304,8 +277,10 @@ export async function createInstantiator(options, swift) { } } class Greeter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_Greeter_deinit, Greeter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); } constructor(name) { @@ -332,8 +307,10 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converters_Converter_deinit, Converter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { @@ -348,8 +325,10 @@ export async function createInstantiator(options, swift) { } } class UUID extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_UUID_deinit, UUID.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_UUID_deinit, UUID.prototype, UUID.__identityCache); } uuidString() { @@ -360,8 +339,10 @@ export async function createInstantiator(options, swift) { } } class Container extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Collections_Container_deinit, Container.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Container_deinit, Container.prototype, Container.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js index 8e4a700a7..feb2a7eef 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js @@ -229,33 +229,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -274,22 +254,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -304,8 +277,10 @@ export async function createInstantiator(options, swift) { } } class Greeter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_Greeter_deinit, Greeter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); } constructor(name) { @@ -332,8 +307,10 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converters_Converter_deinit, Converter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { @@ -348,8 +325,10 @@ export async function createInstantiator(options, swift) { } } class UUID extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_UUID_deinit, UUID.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_UUID_deinit, UUID.prototype, UUID.__identityCache); } uuidString() { @@ -360,8 +339,10 @@ export async function createInstantiator(options, swift) { } } class Container extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Collections_Container_deinit, Container.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Container_deinit, Container.prototype, Container.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js index 7fe0e9fd0..788ff2a66 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js @@ -473,33 +473,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -518,22 +498,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -548,8 +521,10 @@ export async function createInstantiator(options, swift) { } } class Greeter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); } constructor(name) { @@ -609,8 +584,10 @@ export async function createInstantiator(options, swift) { } } class OptionalPropertyHolder extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_OptionalPropertyHolder_deinit, OptionalPropertyHolder.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_OptionalPropertyHolder_deinit, OptionalPropertyHolder.prototype, OptionalPropertyHolder.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js index 25c4c63f3..0d0906823 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js @@ -217,33 +217,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -262,22 +242,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -292,8 +265,10 @@ export async function createInstantiator(options, swift) { } } class PropertyHolder extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyHolder_deinit, PropertyHolder.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyHolder_deinit, PropertyHolder.prototype, PropertyHolder.__identityCache); } constructor(intValue, floatValue, doubleValue, boolValue, stringValue, jsObject) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js index 5d6e3e767..5e72210bc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js @@ -577,33 +577,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -622,22 +602,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -652,8 +625,10 @@ export async function createInstantiator(options, swift) { } } class Helper extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Helper_deinit, Helper.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Helper_deinit, Helper.prototype, Helper.__identityCache); } constructor(value) { @@ -672,8 +647,10 @@ export async function createInstantiator(options, swift) { } } class MyViewController extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MyViewController_deinit, MyViewController.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MyViewController_deinit, MyViewController.prototype, MyViewController.__identityCache); } constructor(delegate) { @@ -733,8 +710,10 @@ export async function createInstantiator(options, swift) { } } class DelegateManager extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_DelegateManager_deinit, DelegateManager.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_DelegateManager_deinit, DelegateManager.prototype, DelegateManager.__identityCache); } constructor(delegates) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js index 7b8445b4a..92d2fef78 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js @@ -363,33 +363,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -408,22 +388,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -438,8 +411,10 @@ export async function createInstantiator(options, swift) { } } class Widget extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Widget_deinit, Widget.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Widget_deinit, Widget.prototype, Widget.__identityCache); } constructor(name) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js index c5b83ff23..416f78ebe 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js @@ -261,33 +261,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -306,22 +286,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -336,8 +309,10 @@ export async function createInstantiator(options, swift) { } } class MathUtils extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MathUtils_deinit, MathUtils.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MathUtils_deinit, MathUtils.prototype, MathUtils.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js index b2979b54a..b50063334 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js @@ -261,33 +261,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -306,22 +286,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -336,8 +309,10 @@ export async function createInstantiator(options, swift) { } } class MathUtils extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MathUtils_deinit, MathUtils.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MathUtils_deinit, MathUtils.prototype, MathUtils.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js index 97d4ff183..aa412ae57 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js @@ -222,33 +222,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -267,22 +247,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -297,8 +270,10 @@ export async function createInstantiator(options, swift) { } } class PropertyClass extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyClass_deinit, PropertyClass.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyClass_deinit, PropertyClass.prototype, PropertyClass.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js index 4a102867c..a1db038ef 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js @@ -222,33 +222,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -267,22 +247,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -297,8 +270,10 @@ export async function createInstantiator(options, swift) { } } class PropertyClass extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyClass_deinit, PropertyClass.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyClass_deinit, PropertyClass.prototype, PropertyClass.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js index 6ab3d427b..e464f547b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js @@ -245,33 +245,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -290,22 +270,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -320,8 +293,10 @@ export async function createInstantiator(options, swift) { } } class Greeter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); } constructor(name) { @@ -376,14 +351,18 @@ export async function createInstantiator(options, swift) { } } class PublicGreeter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PublicGreeter_deinit, PublicGreeter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PublicGreeter_deinit, PublicGreeter.prototype, PublicGreeter.__identityCache); } } class PackageGreeter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PackageGreeter_deinit, PackageGreeter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PackageGreeter_deinit, PackageGreeter.prototype, PackageGreeter.__identityCache); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index 101505de1..a2590c4fa 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -904,33 +904,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -949,22 +929,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -979,8 +952,10 @@ export async function createInstantiator(options, swift) { } } class Person extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Person_deinit, Person.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Person_deinit, Person.prototype, Person.__identityCache); } constructor(name) { @@ -991,8 +966,10 @@ export async function createInstantiator(options, swift) { } } class TestProcessor extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_TestProcessor_deinit, TestProcessor.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_TestProcessor_deinit, TestProcessor.prototype, TestProcessor.__identityCache); } constructor(transform) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js index f3e29bf21..0bd0ec578 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js @@ -486,33 +486,13 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; + state.identityMap?.delete(state.pointer); state.deinit(state.pointer); }); /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { - static identityCacheByDeinit = new WeakMap(); - static finalizerByDeinit = new WeakMap(); - - static __getFinalizer(deinit) { - let finalizer = SwiftHeapObject.finalizerByDeinit.get(deinit); - if (finalizer) { - return finalizer; - } - - const created = new FinalizationRegistry((state) => { - if (state.hasReleased) { - return; - } - state.hasReleased = true; - state.identityMap?.delete(state.pointer); - state.deinit(state.pointer); - }); - SwiftHeapObject.finalizerByDeinit.set(deinit, created); - return created; - } - - static __wrap(pointer, deinit, prototype) { + static __wrap(pointer, deinit, prototype, identityCache) { const makeFresh = (identityMap, finalizer) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; @@ -531,22 +511,15 @@ export async function createInstantiator(options, swift) { return makeFresh(null, swiftHeapObjectFinalizationRegistry); } - let identityMap = SwiftHeapObject.identityCacheByDeinit.get(deinit); - if (!identityMap) { - identityMap = new Map(); - SwiftHeapObject.identityCacheByDeinit.set(deinit, identityMap); - } - - const cached = identityMap.get(pointer)?.deref(); + const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { return cached; } if (!cached) { - identityMap.delete(pointer); + identityCache.delete(pointer); } - const finalizer = SwiftHeapObject.__getFinalizer(deinit); - return makeFresh(identityMap, finalizer); + return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); } release() { @@ -561,8 +534,10 @@ export async function createInstantiator(options, swift) { } } class Greeter extends SwiftHeapObject { + static __identityCache = new Map(); + static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); } constructor(name) { From 6189043fc11493dc8462577aa02a7f908f3e77eb Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Fri, 17 Apr 2026 11:17:58 +0200 Subject: [PATCH 03/18] fix: Fix retain leak on identity cache hit and namespace deinit reference Each boundary crossing calls passRetained on the Swift side. On cache hit, the wrapper is returned without creating a new FinalizationRegistry entry, leaving the retain unbalanced. Call deinit(pointer) on cache hit to immediately release the extra retain. Also fix deinit reference for namespaced classes to use abiName instead of short class name. --- Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift | 3 ++- .../__Snapshots__/BridgeJSLinkTests/ArrayTypes.js | 1 + .../__Snapshots__/BridgeJSLinkTests/DefaultParameters.js | 1 + .../__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js | 1 + .../BridgeJSLinkTests/EnumAssociatedValue.js | 1 + .../BridgeJSLinkTests/EnumNamespace.Global.js | 9 +++++---- .../__Snapshots__/BridgeJSLinkTests/EnumNamespace.js | 9 +++++---- .../__Snapshots__/BridgeJSLinkTests/JSValue.js | 1 + .../__Snapshots__/BridgeJSLinkTests/MixedGlobal.js | 3 ++- .../__Snapshots__/BridgeJSLinkTests/MixedModules.js | 5 +++-- .../__Snapshots__/BridgeJSLinkTests/MixedPrivate.js | 3 ++- .../__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js | 9 +++++---- .../__Snapshots__/BridgeJSLinkTests/Namespaces.js | 9 +++++---- .../__Snapshots__/BridgeJSLinkTests/Optionals.js | 1 + .../__Snapshots__/BridgeJSLinkTests/PropertyTypes.js | 1 + .../__Snapshots__/BridgeJSLinkTests/Protocol.js | 1 + .../__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js | 1 + .../BridgeJSLinkTests/StaticFunctions.Global.js | 1 + .../__Snapshots__/BridgeJSLinkTests/StaticFunctions.js | 1 + .../BridgeJSLinkTests/StaticProperties.Global.js | 1 + .../__Snapshots__/BridgeJSLinkTests/StaticProperties.js | 1 + .../__Snapshots__/BridgeJSLinkTests/SwiftClass.js | 1 + .../__Snapshots__/BridgeJSLinkTests/SwiftClosure.js | 1 + .../__Snapshots__/BridgeJSLinkTests/SwiftStruct.js | 1 + 24 files changed, 45 insertions(+), 21 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index c176664cc..e9cde70f5 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -118,6 +118,7 @@ public struct BridgeJSLink { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { @@ -2000,7 +2001,7 @@ extension BridgeJSLink { jsPrinter.write("static __construct(ptr) {") jsPrinter.indent { jsPrinter.write( - "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_\(klass.name)_deinit, \(klass.name).prototype, \(klass.name).__identityCache);" + "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_\(klass.abiName)_deinit, \(klass.name).prototype, \(klass.name).__identityCache);" ) } jsPrinter.write("}") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js index 4f30e2593..16ce6f57f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js @@ -377,6 +377,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index 7b97b6608..92aee1923 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -308,6 +308,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js index d6529e0fa..2001e8317 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js @@ -317,6 +317,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js index 4c48ed4f5..09f2cb7d0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js @@ -984,6 +984,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js index 6dc03d882..57d3474ef 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js @@ -300,6 +300,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { @@ -324,7 +325,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { @@ -349,7 +350,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_HTTPServer_deinit, HTTPServer.prototype, HTTPServer.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_API_HTTPServer_deinit, HTTPServer.prototype, HTTPServer.__identityCache); } constructor() { @@ -364,7 +365,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_TestServer_deinit, TestServer.prototype, TestServer.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_APIV2_Internal_TestServer_deinit, TestServer.prototype, TestServer.__identityCache); } constructor() { @@ -379,7 +380,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Formatting_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js index 58071b2b1..958cf0eea 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js @@ -281,6 +281,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { @@ -305,7 +306,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { @@ -330,7 +331,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_HTTPServer_deinit, HTTPServer.prototype, HTTPServer.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_API_HTTPServer_deinit, HTTPServer.prototype, HTTPServer.__identityCache); } constructor() { @@ -345,7 +346,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_TestServer_deinit, TestServer.prototype, TestServer.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_APIV2_Internal_TestServer_deinit, TestServer.prototype, TestServer.__identityCache); } constructor() { @@ -360,7 +361,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Formatting_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js index 61ac8dc3a..d5ea77cdd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js @@ -371,6 +371,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js index 9a96fa6b3..08682d8f8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js @@ -244,6 +244,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { @@ -268,7 +269,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalClass_deinit, GlobalClass.prototype, GlobalClass.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalAPI_GlobalClass_deinit, GlobalClass.prototype, GlobalClass.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js index f87d56d13..9d8ee95f3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js @@ -252,6 +252,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { @@ -276,7 +277,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalClass_deinit, GlobalClass.prototype, GlobalClass.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalAPI_GlobalClass_deinit, GlobalClass.prototype, GlobalClass.__identityCache); } constructor() { @@ -294,7 +295,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateClass_deinit, PrivateClass.prototype, PrivateClass.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateAPI_PrivateClass_deinit, PrivateClass.prototype, PrivateClass.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js index cd9530dc1..fd889531a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js @@ -244,6 +244,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { @@ -268,7 +269,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateClass_deinit, PrivateClass.prototype, PrivateClass.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateAPI_PrivateClass_deinit, PrivateClass.prototype, PrivateClass.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js index a2291e6f3..2942770ac 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js @@ -256,6 +256,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { @@ -280,7 +281,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); } constructor(name) { @@ -310,7 +311,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converters_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { @@ -328,7 +329,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_UUID_deinit, UUID.prototype, UUID.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_UUID_deinit, UUID.prototype, UUID.__identityCache); } uuidString() { @@ -342,7 +343,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Container_deinit, Container.prototype, Container.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Collections_Container_deinit, Container.prototype, Container.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js index feb2a7eef..332f9599d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js @@ -256,6 +256,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { @@ -280,7 +281,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); } constructor(name) { @@ -310,7 +311,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converters_Converter_deinit, Converter.prototype, Converter.__identityCache); } constructor() { @@ -328,7 +329,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_UUID_deinit, UUID.prototype, UUID.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_UUID_deinit, UUID.prototype, UUID.__identityCache); } uuidString() { @@ -342,7 +343,7 @@ export async function createInstantiator(options, swift) { static __identityCache = new Map(); static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Container_deinit, Container.prototype, Container.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Collections_Container_deinit, Container.prototype, Container.__identityCache); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js index 788ff2a66..a0577033c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js @@ -500,6 +500,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js index 0d0906823..240065d49 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js @@ -244,6 +244,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js index 5e72210bc..0f41bb817 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js @@ -604,6 +604,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js index 92d2fef78..4fbbea982 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js @@ -390,6 +390,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js index 416f78ebe..58c31e8e1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js @@ -288,6 +288,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js index b50063334..74ebb41dd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js @@ -288,6 +288,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js index aa412ae57..9224ec13d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js @@ -249,6 +249,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js index a1db038ef..4e6b8e81c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js @@ -249,6 +249,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js index e464f547b..2b268c50d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js @@ -272,6 +272,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index a2590c4fa..b4ad8ea58 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -931,6 +931,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js index 0bd0ec578..84330e359 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js @@ -513,6 +513,7 @@ export async function createInstantiator(options, swift) { const cached = identityCache.get(pointer)?.deref(); if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); return cached; } if (!cached) { From a865a008eddc002661433e584624d6215cc543d5 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Fri, 17 Apr 2026 11:17:58 +0200 Subject: [PATCH 04/18] test: Add identity mode E2E tests with dual-mode assertions Add Tests/BridgeJSRuntimeTests/IdentityModeSupportTests module covering: - Wrapper identity for shared Swift objects - Cache invalidation on release - Different classes don't collide on same pointer - Retain leak regression test for cache hits - Array identity preservation Wire IDENTITY_MODE env var through prelude.mjs to toggle instantiateOptions. Add unittest-pointer Makefile target for running tests with identityMode: "pointer". --- Makefile | 12 + .../Generated/BridgeJS.swift | 345 ++++++++++++++ .../Generated/JavaScript/BridgeJS.json | 423 ++++++++++++++++++ .../IdentityModeSupportTests.swift | 113 +++++ .../JavaScript/IdentityModeSupportTests.mjs | 239 ++++++++++ Tests/prelude.mjs | 5 + 6 files changed, 1137 insertions(+) create mode 100644 Tests/BridgeJSRuntimeTests/IdentityModeSupportTests.swift create mode 100644 Tests/BridgeJSRuntimeTests/JavaScript/IdentityModeSupportTests.mjs diff --git a/Makefile b/Makefile index 270eb9b36..df9aeb010 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,18 @@ unittest: --disable-sandbox \ js test --prelude ./Tests/prelude.mjs -Xnode --expose-gc +.PHONY: unittest-pointer +unittest-pointer: + @echo Running unit tests with identityMode=pointer + @test -n "$(SWIFT_SDK_ID)" || { \ + echo "SWIFT_SDK_ID is not set. Run 'swift sdk list' and pass a matching SDK, e.g. 'make unittest-pointer SWIFT_SDK_ID='."; \ + exit 2; \ + } + IDENTITY_MODE=pointer swift package --swift-sdk "$(SWIFT_SDK_ID)" \ + $(TRACING_ARGS) \ + --disable-sandbox \ + js test --prelude ./Tests/prelude.mjs -Xnode --expose-gc + .PHONY: regenerate_swiftpm_resources regenerate_swiftpm_resources: npm run build diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift index a37a7e4c5..d28b05055 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift @@ -7656,6 +7656,132 @@ public func _bjs_makeAdder(_ base: Int32) -> Int32 { #endif } +@_expose(wasm, "bjs_getSharedSubject") +@_cdecl("bjs_getSharedSubject") +public func _bjs_getSharedSubject() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = getSharedSubject() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetSharedSubject") +@_cdecl("bjs_resetSharedSubject") +public func _bjs_resetSharedSubject() -> Void { + #if arch(wasm32) + resetSharedSubject() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getRetainLeakSubject") +@_cdecl("bjs_getRetainLeakSubject") +public func _bjs_getRetainLeakSubject() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = getRetainLeakSubject() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetRetainLeakSubject") +@_cdecl("bjs_resetRetainLeakSubject") +public func _bjs_resetRetainLeakSubject() -> Void { + #if arch(wasm32) + resetRetainLeakSubject() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getRetainLeakDeinits") +@_cdecl("bjs_getRetainLeakDeinits") +public func _bjs_getRetainLeakDeinits() -> Int32 { + #if arch(wasm32) + let ret = getRetainLeakDeinits() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetRetainLeakDeinits") +@_cdecl("bjs_resetRetainLeakDeinits") +public func _bjs_resetRetainLeakDeinits() -> Void { + #if arch(wasm32) + resetRetainLeakDeinits() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_setupArrayPool") +@_cdecl("bjs_setupArrayPool") +public func _bjs_setupArrayPool(_ count: Int32) -> Void { + #if arch(wasm32) + setupArrayPool(_: Int.bridgeJSLiftParameter(count)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getArrayPool") +@_cdecl("bjs_getArrayPool") +public func _bjs_getArrayPool() -> Void { + #if arch(wasm32) + let ret = getArrayPool() + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getArrayPoolElement") +@_cdecl("bjs_getArrayPoolElement") +public func _bjs_getArrayPoolElement(_ index: Int32) -> Void { + #if arch(wasm32) + let ret = getArrayPoolElement(_: Int.bridgeJSLiftParameter(index)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getArrayPoolDeinits") +@_cdecl("bjs_getArrayPoolDeinits") +public func _bjs_getArrayPoolDeinits() -> Int32 { + #if arch(wasm32) + let ret = getArrayPoolDeinits() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetArrayPoolDeinits") +@_cdecl("bjs_resetArrayPoolDeinits") +public func _bjs_resetArrayPoolDeinits() -> Void { + #if arch(wasm32) + resetArrayPoolDeinits() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_clearArrayPool") +@_cdecl("bjs_clearArrayPool") +public func _bjs_clearArrayPool() -> Void { + #if arch(wasm32) + clearArrayPool() + #else + fatalError("Only available on WebAssembly") + #endif +} + @_expose(wasm, "bjs_roundTripPointerFields") @_cdecl("bjs_roundTripPointerFields") public func _bjs_roundTripPointerFields() -> Void { @@ -10472,6 +10598,206 @@ fileprivate func _bjs_TextProcessor_wrap_extern(_ pointer: UnsafeMutableRawPoint return _bjs_TextProcessor_wrap_extern(pointer) } +@_expose(wasm, "bjs_IdentityTestSubject_init") +@_cdecl("bjs_IdentityTestSubject_init") +public func _bjs_IdentityTestSubject_init(_ value: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = IdentityTestSubject(value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityTestSubject_value_get") +@_cdecl("bjs_IdentityTestSubject_value_get") +public func _bjs_IdentityTestSubject_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = IdentityTestSubject.bridgeJSLiftParameter(_self).value + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityTestSubject_value_set") +@_cdecl("bjs_IdentityTestSubject_value_set") +public func _bjs_IdentityTestSubject_value_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + IdentityTestSubject.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityTestSubject_currentValue_get") +@_cdecl("bjs_IdentityTestSubject_currentValue_get") +public func _bjs_IdentityTestSubject_currentValue_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = IdentityTestSubject.bridgeJSLiftParameter(_self).currentValue + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityTestSubject_deinit") +@_cdecl("bjs_IdentityTestSubject_deinit") +public func _bjs_IdentityTestSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension IdentityTestSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_IdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_IdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IdentityTestSubject_wrap") +fileprivate func _bjs_IdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_IdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_IdentityTestSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_IdentityTestSubject_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_RetainLeakSubject_init") +@_cdecl("bjs_RetainLeakSubject_init") +public func _bjs_RetainLeakSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = RetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_RetainLeakSubject_tag_get") +@_cdecl("bjs_RetainLeakSubject_tag_get") +public func _bjs_RetainLeakSubject_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = RetainLeakSubject.bridgeJSLiftParameter(_self).tag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_RetainLeakSubject_tag_set") +@_cdecl("bjs_RetainLeakSubject_tag_set") +public func _bjs_RetainLeakSubject_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + RetainLeakSubject.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_RetainLeakSubject_deinit") +@_cdecl("bjs_RetainLeakSubject_deinit") +public func _bjs_RetainLeakSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension RetainLeakSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_RetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_RetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_RetainLeakSubject_wrap") +fileprivate func _bjs_RetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_RetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_RetainLeakSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_RetainLeakSubject_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_ArrayIdentityElement_init") +@_cdecl("bjs_ArrayIdentityElement_init") +public func _bjs_ArrayIdentityElement_init(_ tag: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ArrayIdentityElement(tag: Int.bridgeJSLiftParameter(tag)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArrayIdentityElement_tag_get") +@_cdecl("bjs_ArrayIdentityElement_tag_get") +public func _bjs_ArrayIdentityElement_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = ArrayIdentityElement.bridgeJSLiftParameter(_self).tag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArrayIdentityElement_tag_set") +@_cdecl("bjs_ArrayIdentityElement_tag_set") +public func _bjs_ArrayIdentityElement_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + ArrayIdentityElement.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArrayIdentityElement_deinit") +@_cdecl("bjs_ArrayIdentityElement_deinit") +public func _bjs_ArrayIdentityElement_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ArrayIdentityElement: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ArrayIdentityElement_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ArrayIdentityElement_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayIdentityElement_wrap") +fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ArrayIdentityElement_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ArrayIdentityElement_wrap_extern(pointer) +} + @_expose(wasm, "bjs_OptionalHolder_init") @_cdecl("bjs_OptionalHolder_init") public func _bjs_OptionalHolder_init(_ nullableGreeterIsSome: Int32, _ nullableGreeterValue: UnsafeMutableRawPointer, _ undefinedNumberIsSome: Int32, _ undefinedNumberValue: Float64) -> UnsafeMutableRawPointer { @@ -12945,6 +13271,25 @@ func _$Animal_getIsCat(_ self: JSObject) throws(JSException) -> Bool { return Bool.bridgeJSLiftReturn(ret) } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static") +fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() -> Void +#else +fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static() -> Void { + return bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() +} + +func _$IdentityModeSupportImports_runJsIdentityModeSupportTests() throws(JSException) -> Void { + bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static() + if let error = _swift_js_take_exception() { + throw error + } +} + #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsTranslatePoint") fileprivate func bjs_jsTranslatePoint_extern(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 diff --git a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json index dd4362fc1..76ed6dea0 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json @@ -4067,6 +4067,151 @@ ], "swiftCallName" : "TextProcessor" }, + { + "constructor" : { + "abiName" : "bjs_IdentityTestSubject_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "IdentityTestSubject", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "currentValue", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "IdentityTestSubject" + }, + { + "constructor" : { + "abiName" : "bjs_RetainLeakSubject_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "tag", + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "RetainLeakSubject", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "RetainLeakSubject" + }, + { + "constructor" : { + "abiName" : "bjs_ArrayIdentityElement_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "tag", + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "ArrayIdentityElement", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "ArrayIdentityElement" + }, { "constructor" : { "abiName" : "bjs_OptionalHolder_init", @@ -13798,6 +13943,247 @@ } } }, + { + "abiName" : "bjs_getSharedSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getSharedSubject", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "IdentityTestSubject" + } + } + }, + { + "abiName" : "bjs_resetSharedSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetSharedSubject", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getRetainLeakSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getRetainLeakSubject", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "RetainLeakSubject" + } + } + }, + { + "abiName" : "bjs_resetRetainLeakSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetRetainLeakSubject", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getRetainLeakDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getRetainLeakDeinits", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_resetRetainLeakDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetRetainLeakDeinits", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_setupArrayPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setupArrayPool", + "parameters" : [ + { + "label" : "_", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getArrayPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getArrayPool", + "parameters" : [ + + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "ArrayIdentityElement" + } + } + } + } + }, + { + "abiName" : "bjs_getArrayPoolElement", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getArrayPoolElement", + "parameters" : [ + { + "label" : "_", + "name" : "index", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "ArrayIdentityElement" + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_getArrayPoolDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getArrayPoolDeinits", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_resetArrayPoolDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetArrayPoolDeinits", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_clearArrayPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "clearArrayPool", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, { "abiName" : "bjs_roundTripPointerFields", "effects" : { @@ -19174,6 +19560,43 @@ } ] }, + { + "functions" : [ + + ], + "types" : [ + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "IdentityModeSupportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsIdentityModeSupportTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + }, { "functions" : [ { diff --git a/Tests/BridgeJSRuntimeTests/IdentityModeSupportTests.swift b/Tests/BridgeJSRuntimeTests/IdentityModeSupportTests.swift new file mode 100644 index 000000000..a7c41035e --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/IdentityModeSupportTests.swift @@ -0,0 +1,113 @@ +import XCTest +import JavaScriptKit + +@JSClass struct IdentityModeSupportImports { + @JSFunction static func runJsIdentityModeSupportTests() throws(JSException) +} + +final class IdentityModeSupportTests: XCTestCase { + func testRunJsIdentityModeSupportTests() throws { + try IdentityModeSupportImports.runJsIdentityModeSupportTests() + } +} + +@JS class IdentityTestSubject { + @JS var value: Int + + @JS init(value: Int) { + self.value = value + } + + @JS var currentValue: Int { value } +} + +nonisolated(unsafe) private var _sharedSubject: IdentityTestSubject? + +@JS func getSharedSubject() -> IdentityTestSubject { + if _sharedSubject == nil { + _sharedSubject = IdentityTestSubject(value: 42) + } + return _sharedSubject! +} + +@JS func resetSharedSubject() { + _sharedSubject = nil +} + +@JS class RetainLeakSubject { + nonisolated(unsafe) static var deinits: Int = 0 + + @JS var tag: Int + + @JS init(tag: Int) { + self.tag = tag + } + + deinit { + Self.deinits += 1 + } +} + +nonisolated(unsafe) private var _retainLeakSubject: RetainLeakSubject? + +@JS func getRetainLeakSubject() -> RetainLeakSubject { + if _retainLeakSubject == nil { + _retainLeakSubject = RetainLeakSubject(tag: 1) + } + return _retainLeakSubject! +} + +@JS func resetRetainLeakSubject() { + _retainLeakSubject = nil +} + +@JS func getRetainLeakDeinits() -> Int { + RetainLeakSubject.deinits +} + +@JS func resetRetainLeakDeinits() { + RetainLeakSubject.deinits = 0 +} + +// MARK: - Array identity tests + +@JS class ArrayIdentityElement { + nonisolated(unsafe) static var deinits: Int = 0 + + @JS var tag: Int + + @JS init(tag: Int) { + self.tag = tag + } + + deinit { + Self.deinits += 1 + } +} + +nonisolated(unsafe) private var _arrayPool: [ArrayIdentityElement] = [] + +@JS func setupArrayPool(_ count: Int) { + _arrayPool = (0.. [ArrayIdentityElement] { + return _arrayPool +} + +@JS func getArrayPoolElement(_ index: Int) -> ArrayIdentityElement? { + guard index >= 0, index < _arrayPool.count else { return nil } + return _arrayPool[index] +} + +@JS func getArrayPoolDeinits() -> Int { + ArrayIdentityElement.deinits +} + +@JS func resetArrayPoolDeinits() { + ArrayIdentityElement.deinits = 0 +} + +@JS func clearArrayPool() { + _arrayPool = [] +} diff --git a/Tests/BridgeJSRuntimeTests/JavaScript/IdentityModeSupportTests.mjs b/Tests/BridgeJSRuntimeTests/JavaScript/IdentityModeSupportTests.mjs new file mode 100644 index 000000000..a17a9b1c7 --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/JavaScript/IdentityModeSupportTests.mjs @@ -0,0 +1,239 @@ +// @ts-check + +import assert from "node:assert"; + +/** + * @returns {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Imports["IdentityModeSupportImports"]} + */ +export function getImports(importsContext) { + return { + runJsIdentityModeSupportTests: () => { + const exports = importsContext.getExports(); + if (!exports) { + throw new Error("No exports!?"); + } + runIdentityModeTests(exports); + }, + }; +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runIdentityModeTests(exports) { + const identityMode = process.env.IDENTITY_MODE || undefined; + + testWrapperIdentity(exports, identityMode); + testCacheInvalidationOnRelease(exports, identityMode); + testDifferentClassesDontCollide(exports); + testRetainLeakOnCacheHit(exports, identityMode); + testArrayElementIdentity(exports, identityMode); + testArrayElementMatchesSingleGetter(exports, identityMode); + testArrayRetainLeak(exports, identityMode); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + * @param {string | undefined} identityMode + */ +function testWrapperIdentity(exports, identityMode) { + exports.resetSharedSubject(); + const a = exports.getSharedSubject(); + const b = exports.getSharedSubject(); + + if (identityMode === "pointer") { + assert.strictEqual( + a, + b, + "In pointer mode, same Swift object should return identical JS wrapper", + ); + } else { + assert.notStrictEqual( + a, + b, + "In default mode, same Swift object should return different JS wrappers", + ); + } + + assert.equal(a.currentValue, 42); + assert.equal(b.currentValue, 42); + + a.release(); + if (a !== b) { + b.release(); + } + exports.resetSharedSubject(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + * @param {string | undefined} identityMode + */ +function testCacheInvalidationOnRelease(exports, identityMode) { + exports.resetSharedSubject(); + const first = exports.getSharedSubject(); + first.release(); + + exports.resetSharedSubject(); + const second = exports.getSharedSubject(); + + assert.notStrictEqual( + first, + second, + "After release + reset, should get a different wrapper", + ); + assert.equal(second.currentValue, 42); + + second.release(); + exports.resetSharedSubject(); +} + +/** + * Verifies that repeated boundary crossings of the same Swift object don't leak + * retain counts. In pointer mode, each cache hit triggers passRetained on the + * Swift side. Without the balancing deinit(pointer) call on cache hit, each + * crossing leaks +1 retain and the object is never deallocated. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + * @param {string | undefined} identityMode + */ +function testRetainLeakOnCacheHit(exports, identityMode) { + if (identityMode !== "pointer") return; + + exports.resetRetainLeakDeinits(); + exports.resetRetainLeakSubject(); + + const wrappers = []; + for (let i = 0; i < 10; i++) { + wrappers.push(exports.getRetainLeakSubject()); + } + + for (let i = 1; i < wrappers.length; i++) { + assert.strictEqual( + wrappers[0], + wrappers[i], + "All should be the same cached wrapper", + ); + } + + wrappers[0].release(); + exports.resetRetainLeakSubject(); + + assert.strictEqual( + exports.getRetainLeakDeinits(), + 1, + "Object should be deallocated after release + reset. " + + "If deinits == 0, retain leak from unbalanced passRetained on cache hits.", + ); +} + +/** + * Verifies that elements at the same index across repeated array returns are === + * in pointer mode. Without pointer mode, they should be different wrappers. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + * @param {string | undefined} identityMode + */ +function testArrayElementIdentity(exports, identityMode) { + if (identityMode !== "pointer") return; + + exports.setupArrayPool(10); + const arr1 = exports.getArrayPool(); + const arr2 = exports.getArrayPool(); + + assert.equal(arr1.length, 10, "First array should have 10 elements"); + assert.equal(arr2.length, 10, "Second array should have 10 elements"); + + for (let i = 0; i < 10; i++) { + assert.strictEqual( + arr1[i], + arr2[i], + `Array element at index ${i} should be === across calls in pointer mode`, + ); + assert.equal(arr1[i].tag, i, `Element ${i} should have correct tag`); + } + + for (const elem of arr1) { + elem.release(); + } + exports.clearArrayPool(); +} + +/** + * Verifies that an array element is === to the same object returned via + * a single-element getter. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + * @param {string | undefined} identityMode + */ +function testArrayElementMatchesSingleGetter(exports, identityMode) { + if (identityMode !== "pointer") return; + + exports.setupArrayPool(5); + const arr = exports.getArrayPool(); + const single = exports.getArrayPoolElement(2); + + assert.strictEqual( + arr[2], + single, + "Array element and single getter should return the same wrapper in pointer mode", + ); + assert.equal(single.tag, 2); + + for (const elem of arr) { + elem.release(); + } + exports.clearArrayPool(); +} + +/** + * Verifies that returning an array of N objects M times doesn't leak retains. + * After releasing all wrappers and clearing the pool, all objects should be + * deallocated. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + * @param {string | undefined} identityMode + */ +function testArrayRetainLeak(exports, identityMode) { + if (identityMode !== "pointer") return; + + exports.resetArrayPoolDeinits(); + exports.setupArrayPool(5); + + for (let round = 0; round < 10; round++) { + exports.getArrayPool(); + } + + const arr = exports.getArrayPool(); + for (const elem of arr) { + elem.release(); + } + + exports.clearArrayPool(); + + assert.strictEqual( + exports.getArrayPoolDeinits(), + 5, + "All 5 pool objects should be deallocated after release + clear. " + + "If deinits < 5, retain leak from unbalanced passRetained in array returns.", + ); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testDifferentClassesDontCollide(exports) { + const greeter = new exports.Greeter("IdentityTest"); + const subject = new exports.IdentityTestSubject(99); + + assert.notStrictEqual( + greeter, + subject, + "Instances of different classes should never be ===", + ); + assert.equal(greeter.name, "IdentityTest"); + assert.equal(subject.currentValue, 99); + + greeter.release(); + subject.release(); +} diff --git a/Tests/prelude.mjs b/Tests/prelude.mjs index 0af033226..a3a9048f7 100644 --- a/Tests/prelude.mjs +++ b/Tests/prelude.mjs @@ -14,12 +14,15 @@ import { getImports as getDefaultArgumentImports } from './BridgeJSRuntimeTests/ import { getImports as getJSClassSupportImports, JSClassWithArrayMembers } from './BridgeJSRuntimeTests/JavaScript/JSClassSupportTests.mjs'; import { getImports as getIntegerTypesSupportImports } from './BridgeJSRuntimeTests/JavaScript/IntegerTypesSupportTests.mjs'; import { getImports as getAsyncImportImports, runAsyncWorksTests } from './BridgeJSRuntimeTests/JavaScript/AsyncImportTests.mjs'; +import { getImports as getIdentityModeSupportImports } from './BridgeJSRuntimeTests/JavaScript/IdentityModeSupportTests.mjs'; /** @type {import('../.build/plugins/PackageToJS/outputs/PackageTests/test.d.ts').SetupOptionsFn} */ export async function setupOptions(options, context) { Error.stackTraceLimit = 100; setupTestGlobals(globalThis); + const identityMode = process.env.IDENTITY_MODE || undefined; + class StaticBox { constructor(value) { this._value = value; @@ -43,6 +46,7 @@ export async function setupOptions(options, context) { return { ...options, + ...(identityMode ? { instantiateOptions: { identityMode } } : {}), getImports: (importsContext) => { return { "jsRoundTripVoid": () => { @@ -155,6 +159,7 @@ export async function setupOptions(options, context) { DefaultArgumentImports: getDefaultArgumentImports(importsContext), JSClassSupportImports: getJSClassSupportImports(importsContext), IntegerTypesSupportImports: getIntegerTypesSupportImports(importsContext), + IdentityModeSupportImports: getIdentityModeSupportImports(importsContext), }; }, addToCoreImports(importObject, importsContext) { From df960e6014c5b4aa2c28aee65bfba8e01100fc31 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Fri, 17 Apr 2026 11:25:40 +0200 Subject: [PATCH 05/18] fix: Restore FinalizationRegistry polyfill and clean up formatting noise Restore the no-op polyfill pattern for environments without FinalizationRegistry instead of null, matching the upstream convention. Remove finalizer parameter from makeFresh since the polyfill is always callable. Use has() guard before stale WeakRef cleanup. Remove formatting-only changes from instantiate.d.ts. --- .../Sources/BridgeJSLink/BridgeJSLink.swift | 18 ++- .../BridgeJSLinkTests/ArrayTypes.js | 18 ++- .../BridgeJSLinkTests/DefaultParameters.js | 18 ++- .../BridgeJSLinkTests/DictionaryTypes.js | 18 ++- .../BridgeJSLinkTests/EnumAssociatedValue.js | 18 ++- .../BridgeJSLinkTests/EnumNamespace.Global.js | 18 ++- .../BridgeJSLinkTests/EnumNamespace.js | 18 ++- .../BridgeJSLinkTests/JSValue.js | 18 ++- .../BridgeJSLinkTests/MixedGlobal.js | 18 ++- .../BridgeJSLinkTests/MixedModules.js | 18 ++- .../BridgeJSLinkTests/MixedPrivate.js | 18 ++- .../BridgeJSLinkTests/Namespaces.Global.js | 18 ++- .../BridgeJSLinkTests/Namespaces.js | 18 ++- .../BridgeJSLinkTests/Optionals.js | 18 ++- .../BridgeJSLinkTests/PropertyTypes.js | 18 ++- .../BridgeJSLinkTests/Protocol.js | 18 ++- .../BridgeJSLinkTests/ProtocolInClosure.js | 18 ++- .../StaticFunctions.Global.js | 18 ++- .../BridgeJSLinkTests/StaticFunctions.js | 18 ++- .../StaticProperties.Global.js | 18 ++- .../BridgeJSLinkTests/StaticProperties.js | 18 ++- .../BridgeJSLinkTests/SwiftClass.js | 18 ++- .../BridgeJSLinkTests/SwiftClosure.js | 18 ++- .../BridgeJSLinkTests/SwiftStruct.js | 18 ++- .../PackageToJS/Templates/instantiate.d.ts | 110 ++++++++---------- 25 files changed, 240 insertions(+), 302 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index e9cde70f5..717c13c5c 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -74,7 +74,7 @@ public struct BridgeJSLink { output += lifetimeTrackingClassJs + "\n" } output += """ - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { """ if enableLifetimeTracking { @@ -92,9 +92,9 @@ public struct BridgeJSLink { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; """ if enableLifetimeTracking { @@ -103,9 +103,7 @@ public struct BridgeJSLink { output += """ obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -113,7 +111,7 @@ public struct BridgeJSLink { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -121,11 +119,11 @@ public struct BridgeJSLink { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -140,7 +138,7 @@ public struct BridgeJSLink { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js index 16ce6f57f..f89c0e10b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js @@ -345,7 +345,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -357,14 +357,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -372,7 +370,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -380,11 +378,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -393,7 +391,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index 92aee1923..336784fb7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -276,7 +276,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -288,14 +288,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -303,7 +301,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -311,11 +309,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -324,7 +322,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js index 2001e8317..f11c1cdd8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js @@ -285,7 +285,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -297,14 +297,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -312,7 +310,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -320,11 +318,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -333,7 +331,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js index 09f2cb7d0..3fa45ef40 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js @@ -952,7 +952,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -964,14 +964,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -979,7 +977,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -987,11 +985,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -1000,7 +998,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js index 57d3474ef..7b21cd65d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js @@ -268,7 +268,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -280,14 +280,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -295,7 +293,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -303,11 +301,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -316,7 +314,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js index 958cf0eea..ae42a0f26 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js @@ -249,7 +249,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -261,14 +261,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -276,7 +274,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -284,11 +282,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -297,7 +295,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js index d5ea77cdd..2239dcab2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js @@ -339,7 +339,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -351,14 +351,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -366,7 +364,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -374,11 +372,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -387,7 +385,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js index 08682d8f8..f6f722c12 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js @@ -212,7 +212,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -224,14 +224,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -239,7 +237,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -247,11 +245,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -260,7 +258,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js index 9d8ee95f3..5e7d75d83 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js @@ -220,7 +220,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -232,14 +232,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -247,7 +245,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -255,11 +253,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -268,7 +266,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js index fd889531a..98415fa7f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js @@ -212,7 +212,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -224,14 +224,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -239,7 +237,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -247,11 +245,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -260,7 +258,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js index 2942770ac..55647f15a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js @@ -224,7 +224,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -236,14 +236,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -251,7 +249,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -259,11 +257,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -272,7 +270,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js index 332f9599d..f6cce62a3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js @@ -224,7 +224,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -236,14 +236,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -251,7 +249,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -259,11 +257,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -272,7 +270,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js index a0577033c..29c57aed0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js @@ -468,7 +468,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -480,14 +480,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -495,7 +493,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -503,11 +501,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -516,7 +514,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js index 240065d49..0c5c474f2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js @@ -212,7 +212,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -224,14 +224,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -239,7 +237,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -247,11 +245,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -260,7 +258,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js index 0f41bb817..c24822037 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js @@ -572,7 +572,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -584,14 +584,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -599,7 +597,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -607,11 +605,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -620,7 +618,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js index 4fbbea982..7ac906b8b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js @@ -358,7 +358,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -370,14 +370,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -385,7 +383,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -393,11 +391,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -406,7 +404,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js index 58c31e8e1..2ba1ef696 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js @@ -256,7 +256,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -268,14 +268,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -283,7 +281,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -291,11 +289,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -304,7 +302,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js index 74ebb41dd..8b2299a60 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js @@ -256,7 +256,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -268,14 +268,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -283,7 +281,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -291,11 +289,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -304,7 +302,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js index 9224ec13d..90c09bf01 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js @@ -217,7 +217,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -229,14 +229,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -244,7 +242,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -252,11 +250,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -265,7 +263,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js index 4e6b8e81c..f45a58b7c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js @@ -217,7 +217,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -229,14 +229,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -244,7 +242,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -252,11 +250,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -265,7 +263,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js index 2b268c50d..7be26f087 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js @@ -240,7 +240,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -252,14 +252,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -267,7 +265,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -275,11 +273,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -288,7 +286,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index b4ad8ea58..ac4ee8dad 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -899,7 +899,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -911,14 +911,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -926,7 +924,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -934,11 +932,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -947,7 +945,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js index 84330e359..4cde888c7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js @@ -481,7 +481,7 @@ export async function createInstantiator(options, swift) { /** @param {WebAssembly.Instance} instance */ createExports: (instance) => { const js = swift.memory.heap; - const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? null : new FinalizationRegistry((state) => { + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.hasReleased) { return; } @@ -493,14 +493,12 @@ export async function createInstantiator(options, swift) { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { - const makeFresh = (identityMap, finalizer) => { + const makeFresh = (identityMap) => { const obj = Object.create(prototype); - const state = { pointer, deinit, hasReleased: false, identityMap, finalizer }; + const state = { pointer, deinit, hasReleased: false, identityMap }; obj.pointer = pointer; obj.__swiftHeapObjectState = state; - if (finalizer) { - finalizer.register(obj, state, state); - } + swiftHeapObjectFinalizationRegistry.register(obj, state, state); if (identityMap) { identityMap.set(pointer, new WeakRef(obj)); } @@ -508,7 +506,7 @@ export async function createInstantiator(options, swift) { }; if (!shouldUseIdentityMap) { - return makeFresh(null, swiftHeapObjectFinalizationRegistry); + return makeFresh(null); } const cached = identityCache.get(pointer)?.deref(); @@ -516,11 +514,11 @@ export async function createInstantiator(options, swift) { deinit(pointer); return cached; } - if (!cached) { + if (identityCache.has(pointer)) { identityCache.delete(pointer); } - return makeFresh(identityCache, swiftHeapObjectFinalizationRegistry); + return makeFresh(identityCache); } release() { @@ -529,7 +527,7 @@ export async function createInstantiator(options, swift) { return; } state.hasReleased = true; - state.finalizer?.unregister(state); + swiftHeapObjectFinalizationRegistry.unregister(state); state.identityMap?.delete(state.pointer); state.deinit(state.pointer); } diff --git a/Plugins/PackageToJS/Templates/instantiate.d.ts b/Plugins/PackageToJS/Templates/instantiate.d.ts index ca515b345..0caf328dc 100644 --- a/Plugins/PackageToJS/Templates/instantiate.d.ts +++ b/Plugins/PackageToJS/Templates/instantiate.d.ts @@ -6,8 +6,8 @@ import type { SwiftRuntimeThreadChannel } from "./runtime.js"; export type { Imports, Exports } from "./bridge-js.js"; import type { Imports, Exports } from "./bridge-js.js"; /* #else */ -export type Imports = {}; -export type Exports = {}; +export type Imports = {} +export type Exports = {} /* #endif */ /** @@ -20,50 +20,45 @@ export declare const MODULE_PATH: string; * The type of the WebAssembly memory imported by the module */ export declare const MEMORY_TYPE: { - initial: number; - maximum: number; - shared: boolean; -}; + initial: number, + maximum: number, + shared: boolean +} /* #endif */ export interface WASI { /** * The WASI Preview 1 import object */ - wasiImport: WebAssembly.ModuleImports; + wasiImport: WebAssembly.ModuleImports /** * Initialize the WASI reactor instance * * @param instance - The instance of the WebAssembly module */ - initialize(instance: WebAssembly.Instance): void; + initialize(instance: WebAssembly.Instance): void /** * Set a new instance of the WebAssembly module to the WASI context * Typically used when instantiating a WebAssembly module for a thread * * @param instance - The instance of the WebAssembly module */ - setInstance(instance: WebAssembly.Instance): void; + setInstance(instance: WebAssembly.Instance): void /** * Extract a file from the WASI filesystem * * @param path - The path to the file to extract * @returns The data of the file if it was extracted, undefined otherwise */ - extractFile?(path: string): Uint8Array | undefined; + extractFile?(path: string): Uint8Array | undefined } export type SwiftRuntime = { - UnsafeEventLoopYield: { [Symbol.hasInstance]: (value: unknown) => boolean }; + UnsafeEventLoopYield: { [Symbol.hasInstance]: (value: unknown) => boolean } main(): void; startThread(tid: number, startArg: number): void; -}; +} -export type ModuleSource = - | WebAssembly.Module - | ArrayBufferView - | ArrayBuffer - | Response - | PromiseLike; +export type ModuleSource = WebAssembly.Module | ArrayBufferView | ArrayBuffer | Response | PromiseLike /** * The options for instantiating a WebAssembly module @@ -73,44 +68,40 @@ export type InstantiateOptions = { * The WebAssembly namespace to use for instantiation. * Defaults to the globalThis.WebAssembly object. */ - WebAssembly?: typeof globalThis.WebAssembly; + WebAssembly?: typeof globalThis.WebAssembly, /** * The WebAssembly module to instantiate */ - module: ModuleSource; - /* #if HAS_IMPORTS */ + module: ModuleSource, +/* #if HAS_IMPORTS */ /** * The function to get the imports provided by the embedder */ getImports: (importsContext: { - getInstance: () => WebAssembly.Instance | null; - getExports: () => Exports | null; - _swift: SwiftRuntime; - }) => Imports; - /* #endif */ - /* #if IS_WASI */ + getInstance: () => WebAssembly.Instance | null, + getExports: () => Exports | null, + _swift: SwiftRuntime, + }) => Imports, +/* #endif */ +/* #if IS_WASI */ /** * The WASI implementation to use */ - wasi: WASI; - /* #endif */ - /* #if USE_SHARED_MEMORY */ + wasi: WASI, +/* #endif */ +/* #if USE_SHARED_MEMORY */ /** * The WebAssembly memory to use (must be 'shared') */ - memory: WebAssembly.Memory; + memory: WebAssembly.Memory /** * The thread channel is a set of functions that are used to communicate * between the main thread and the worker thread. */ threadChannel: SwiftRuntimeThreadChannel & { - spawnThread: ( - module: WebAssembly.Module, - memory: WebAssembly.Memory, - startArg: any, - ) => number; - }; - /* #endif */ + spawnThread: (module: WebAssembly.Module, memory: WebAssembly.Memory, startArg: any) => number; + } +/* #endif */ /** * Add imports to the WebAssembly import object * @param imports - The imports to add @@ -119,11 +110,11 @@ export type InstantiateOptions = { addToCoreImports?: ( imports: WebAssembly.Imports, context: { - getInstance: () => WebAssembly.Instance | null; - getExports: () => Exports | null; - _swift: SwiftRuntime; - }, - ) => void; + getInstance: () => WebAssembly.Instance | null, + getExports: () => Exports | null, + _swift: SwiftRuntime, + } + ) => void /** * Instrument the WebAssembly instance @@ -135,36 +126,31 @@ export type InstantiateOptions = { instrumentInstance?: ( instance: WebAssembly.Instance, context: { - _swift: SwiftRuntime; - }, - ) => WebAssembly.Instance; + _swift: SwiftRuntime + } + ) => WebAssembly.Instance /** * Controls whether exported Swift class instances use pointer-based identity mapping. * When set to "pointer", the same Swift heap pointer will always return the same JS wrapper object. - * Defaults to "none". */ - identityMode?: "none" | "pointer"; -}; + identityMode?: "none" | "pointer" +} /** * Instantiate the given WebAssembly module */ export declare function instantiate(options: InstantiateOptions): Promise<{ - instance: WebAssembly.Instance; - swift: SwiftRuntime; - exports: Exports; -}>; + instance: WebAssembly.Instance, + swift: SwiftRuntime, + exports: Exports +}> /** * Instantiate the given WebAssembly module for a thread */ -export declare function instantiateForThread( - tid: number, - startArg: number, - options: InstantiateOptions, -): Promise<{ - instance: WebAssembly.Instance; - swift: SwiftRuntime; - exports: Exports; -}>; +export declare function instantiateForThread(tid: number, startArg: number, options: InstantiateOptions): Promise<{ + instance: WebAssembly.Instance, + swift: SwiftRuntime, + exports: Exports +}> From 89deed08fff50972f0dca83bc566a8f6d912bfee Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Fri, 17 Apr 2026 11:43:51 +0200 Subject: [PATCH 06/18] refactor: Move identityMode to bridge-js.config.json following exposeToGlobal pattern Add identityMode field to BridgeJSConfig, flow through SwiftToSkeleton and ExportedSkeleton to BridgeJSLink. Generated JS uses config value as default with runtime option as override via nullish coalescing. Create dedicated BridgeJSIdentityTests target with identityMode: pointer in its bridge-js.config.json. Remove IDENTITY_MODE env var, instantiateOptions spread from prelude.mjs, and unittest-pointer Makefile target. Identity tests now run as part of the normal test suite. --- Makefile | 12 - Package.swift | 12 + Package@swift-6.1.swift | 12 + .../BridgeJS/Sources/BridgeJSCore/Misc.swift | 17 +- .../BridgeJSCore/SwiftToSkeleton.swift | 6 +- .../Sources/BridgeJSLink/BridgeJSLink.swift | 3 +- .../BridgeJSSkeleton/BridgeJSSkeleton.swift | 11 +- .../Sources/BridgeJSTool/BridgeJSTool.swift | 3 +- .../BridgeJSToolTests/BridgeJSLinkTests.swift | 2 +- .../BridgeJSLinkTests/ArrayTypes.js | 2 +- .../__Snapshots__/BridgeJSLinkTests/Async.js | 2 +- .../BridgeJSLinkTests/AsyncImport.js | 2 +- .../BridgeJSLinkTests/AsyncStaticImport.js | 2 +- .../BridgeJSLinkTests/DefaultParameters.js | 2 +- .../BridgeJSLinkTests/DictionaryTypes.js | 2 +- .../BridgeJSLinkTests/EnumAssociatedValue.js | 2 +- .../BridgeJSLinkTests/EnumCase.js | 2 +- .../BridgeJSLinkTests/EnumNamespace.Global.js | 2 +- .../BridgeJSLinkTests/EnumNamespace.js | 2 +- .../BridgeJSLinkTests/EnumRawType.js | 2 +- .../BridgeJSLinkTests/FixedWidthIntegers.js | 2 +- .../BridgeJSLinkTests/GlobalGetter.js | 2 +- .../BridgeJSLinkTests/GlobalThisImports.js | 2 +- .../BridgeJSLinkTests/ImportArray.js | 2 +- .../ImportedTypeInExportedInterface.js | 2 +- .../BridgeJSLinkTests/InvalidPropertyNames.js | 2 +- .../BridgeJSLinkTests/JSClass.js | 2 +- .../JSClassStaticFunctions.js | 2 +- .../BridgeJSLinkTests/JSValue.js | 2 +- .../BridgeJSLinkTests/MixedGlobal.js | 2 +- .../BridgeJSLinkTests/MixedModules.js | 2 +- .../BridgeJSLinkTests/MixedPrivate.js | 2 +- .../BridgeJSLinkTests/Namespaces.Global.js | 2 +- .../BridgeJSLinkTests/Namespaces.js | 2 +- .../BridgeJSLinkTests/Optionals.js | 2 +- .../BridgeJSLinkTests/PrimitiveParameters.js | 2 +- .../BridgeJSLinkTests/PrimitiveReturn.js | 2 +- .../BridgeJSLinkTests/PropertyTypes.js | 2 +- .../BridgeJSLinkTests/Protocol.js | 2 +- .../BridgeJSLinkTests/ProtocolInClosure.js | 2 +- .../StaticFunctions.Global.js | 2 +- .../BridgeJSLinkTests/StaticFunctions.js | 2 +- .../StaticProperties.Global.js | 2 +- .../BridgeJSLinkTests/StaticProperties.js | 2 +- .../BridgeJSLinkTests/StringParameter.js | 2 +- .../BridgeJSLinkTests/StringReturn.js | 2 +- .../BridgeJSLinkTests/SwiftClass.js | 2 +- .../BridgeJSLinkTests/SwiftClosure.js | 2 +- .../BridgeJSLinkTests/SwiftClosureImports.js | 2 +- .../BridgeJSLinkTests/SwiftStruct.js | 2 +- .../BridgeJSLinkTests/SwiftStructImports.js | 2 +- .../__Snapshots__/BridgeJSLinkTests/Throws.js | 2 +- .../BridgeJSLinkTests/UnsafePointer.js | 2 +- .../VoidParameterVoidReturn.js | 2 +- .../Generated/BridgeJS.swift | 14203 +++++++++++ .../Generated/JavaScript/BridgeJS.json | 20907 ++++++++++++++++ .../IdentityModeTests.swift} | 10 +- .../JavaScript/IdentityModeTests.mjs} | 111 +- .../bridge-js.config.json | 3 + .../Generated/BridgeJS.swift | 345 - .../Generated/JavaScript/BridgeJS.json | 423 - Tests/prelude.mjs | 6 +- 62 files changed, 35259 insertions(+), 917 deletions(-) create mode 100644 Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift create mode 100644 Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json rename Tests/{BridgeJSRuntimeTests/IdentityModeSupportTests.swift => BridgeJSIdentityTests/IdentityModeTests.swift} (87%) rename Tests/{BridgeJSRuntimeTests/JavaScript/IdentityModeSupportTests.mjs => BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs} (58%) create mode 100644 Tests/BridgeJSIdentityTests/bridge-js.config.json diff --git a/Makefile b/Makefile index df9aeb010..270eb9b36 100644 --- a/Makefile +++ b/Makefile @@ -21,18 +21,6 @@ unittest: --disable-sandbox \ js test --prelude ./Tests/prelude.mjs -Xnode --expose-gc -.PHONY: unittest-pointer -unittest-pointer: - @echo Running unit tests with identityMode=pointer - @test -n "$(SWIFT_SDK_ID)" || { \ - echo "SWIFT_SDK_ID is not set. Run 'swift sdk list' and pass a matching SDK, e.g. 'make unittest-pointer SWIFT_SDK_ID='."; \ - exit 2; \ - } - IDENTITY_MODE=pointer swift package --swift-sdk "$(SWIFT_SDK_ID)" \ - $(TRACING_ARGS) \ - --disable-sandbox \ - js test --prelude ./Tests/prelude.mjs -Xnode --expose-gc - .PHONY: regenerate_swiftpm_resources regenerate_swiftpm_resources: npm run build diff --git a/Package.swift b/Package.swift index 820524177..3d0f1e943 100644 --- a/Package.swift +++ b/Package.swift @@ -217,5 +217,17 @@ let package = Package( ], linkerSettings: testingLinkerFlags ), + .testTarget( + name: "BridgeJSIdentityTests", + dependencies: ["JavaScriptKit", "JavaScriptEventLoop"], + exclude: [ + "bridge-js.config.json", + "Generated/JavaScript", + ], + swiftSettings: [ + .enableExperimentalFeature("Extern") + ], + linkerSettings: testingLinkerFlags + ), ] ) diff --git a/Package@swift-6.1.swift b/Package@swift-6.1.swift index 60adb7a5f..fe98ec529 100644 --- a/Package@swift-6.1.swift +++ b/Package@swift-6.1.swift @@ -206,5 +206,17 @@ let package = Package( ], linkerSettings: testingLinkerFlags ), + .testTarget( + name: "BridgeJSIdentityTests", + dependencies: ["JavaScriptKit", "JavaScriptEventLoop"], + exclude: [ + "bridge-js.config.json", + "Generated/JavaScript", + ], + swiftSettings: [ + .enableExperimentalFeature("Extern") + ], + linkerSettings: testingLinkerFlags + ), ] ) diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift index 06fb422a9..37040d7a6 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift @@ -342,20 +342,32 @@ public struct BridgeJSConfig: Codable { /// Default: `false` public var exposeToGlobal: Bool - public init(tools: [String: String]? = nil, exposeToGlobal: Bool = false) { + /// The identity mode to use for exported Swift heap objects. + /// + /// When `"pointer"`, Swift heap objects are tracked by pointer identity, + /// enabling identity-based caching. When `"none"` or `nil`, no identity + /// tracking is performed. + /// + /// Default: `nil` (treated as `"none"`) + public var identityMode: String? + + public init(tools: [String: String]? = nil, exposeToGlobal: Bool = false, identityMode: String? = nil) { self.tools = tools self.exposeToGlobal = exposeToGlobal + self.identityMode = identityMode } enum CodingKeys: String, CodingKey { case tools case exposeToGlobal + case identityMode } public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) tools = try container.decodeIfPresent([String: String].self, forKey: .tools) exposeToGlobal = try container.decodeIfPresent(Bool.self, forKey: .exposeToGlobal) ?? false + identityMode = try container.decodeIfPresent(String.self, forKey: .identityMode) } /// Load the configuration file from the SwiftPM package target directory. @@ -398,7 +410,8 @@ public struct BridgeJSConfig: Codable { func merging(overrides: BridgeJSConfig) -> BridgeJSConfig { return BridgeJSConfig( tools: (tools ?? [:]).merging(overrides.tools ?? [:], uniquingKeysWith: { $1 }), - exposeToGlobal: overrides.exposeToGlobal + exposeToGlobal: overrides.exposeToGlobal, + identityMode: overrides.identityMode ?? identityMode ) } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index 7b7c6ca30..369c75e72 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -16,14 +16,16 @@ public final class SwiftToSkeleton { public let progress: ProgressReporting public let moduleName: String public let exposeToGlobal: Bool + public let identityMode: String? private var sourceFiles: [(sourceFile: SourceFileSyntax, inputFilePath: String)] = [] let typeDeclResolver: TypeDeclResolver - public init(progress: ProgressReporting, moduleName: String, exposeToGlobal: Bool) { + public init(progress: ProgressReporting, moduleName: String, exposeToGlobal: Bool, identityMode: String? = nil) { self.progress = progress self.moduleName = moduleName self.exposeToGlobal = exposeToGlobal + self.identityMode = identityMode self.typeDeclResolver = TypeDeclResolver() // Index known types provided by JavaScriptKit @@ -42,7 +44,7 @@ public final class SwiftToSkeleton { public func finalize() throws -> BridgeJSSkeleton { var perSourceErrors: [(inputFilePath: String, errors: [DiagnosticError])] = [] var importedFiles: [ImportedFileSkeleton] = [] - var exported = ExportedSkeleton(functions: [], classes: [], enums: [], exposeToGlobal: exposeToGlobal) + var exported = ExportedSkeleton(functions: [], classes: [], enums: [], exposeToGlobal: exposeToGlobal, identityMode: identityMode) var exportCollectors: [ExportSwiftAPICollector] = [] for (sourceFile, inputFilePath) in sourceFiles { diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 717c13c5c..50d2a4317 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -983,7 +983,8 @@ public struct BridgeJSLink { try printer.indent { printer.write(lines: generateVariableDeclarations()) - printer.write("const identityMode = options.identityMode === \"pointer\" ? \"pointer\" : \"none\";") + let configIdentityMode = skeletons.compactMap(\.exported).first?.identityMode ?? "none" + printer.write("const identityMode = options.identityMode ?? \"\(configIdentityMode)\";") printer.write( "const shouldUseIdentityMap = identityMode === \"pointer\" && typeof WeakRef !== \"undefined\" && typeof FinalizationRegistry !== \"undefined\";" ) diff --git a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift index c5672c79c..f77b66043 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift @@ -890,13 +890,20 @@ public struct ExportedSkeleton: Codable { /// through the exports object. public var exposeToGlobal: Bool + /// The identity mode for exported Swift heap objects. + /// + /// When `"pointer"`, Swift heap objects are tracked by pointer identity. + /// When `"none"` or `nil`, no identity tracking is performed. + public var identityMode: String? + public init( functions: [ExportedFunction], classes: [ExportedClass], enums: [ExportedEnum], structs: [ExportedStruct] = [], protocols: [ExportedProtocol] = [], - exposeToGlobal: Bool + exposeToGlobal: Bool, + identityMode: String? = nil ) { self.functions = functions self.classes = classes @@ -904,6 +911,7 @@ public struct ExportedSkeleton: Codable { self.structs = structs self.protocols = protocols self.exposeToGlobal = exposeToGlobal + self.identityMode = identityMode } public mutating func append(_ other: ExportedSkeleton) { @@ -913,6 +921,7 @@ public struct ExportedSkeleton: Codable { self.structs.append(contentsOf: other.structs) self.protocols.append(contentsOf: other.protocols) assert(self.exposeToGlobal == other.exposeToGlobal) + assert(self.identityMode == other.identityMode) } public var isEmpty: Bool { diff --git a/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift b/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift index a71aaee44..3e3f27ea1 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift @@ -165,7 +165,8 @@ import BridgeJSUtilities let swiftToSkeleton = SwiftToSkeleton( progress: progress, moduleName: moduleName, - exposeToGlobal: config.exposeToGlobal + exposeToGlobal: config.exposeToGlobal, + identityMode: config.identityMode ) for inputFile in inputFiles.sorted() { try withSpan("Parsing \(inputFile)") { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift index 877afe323..8906cdeb3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift @@ -124,7 +124,7 @@ import Testing #expect(outputDts.contains("identityMode?: \"none\" | \"pointer\";")) #expect( - outputJs.contains("const identityMode = options.identityMode === \"pointer\" ? \"pointer\" : \"none\";") + outputJs.contains("const identityMode = options.identityMode ?? \"none\";") ) #expect( outputJs.contains( diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js index f89c0e10b..32d9126fc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js @@ -43,7 +43,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointHelpers = () => ({ lower: (value) => { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js index f5b100887..c3a2a2e53 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js index c28de41ea..8f2a26d9b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; function __bjs_jsValueLower(value) { let kind; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js index 87e957112..4dec1f812 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; function __bjs_jsValueLower(value) { let kind; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index 336784fb7..3064e18a9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -36,7 +36,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createConfigHelpers = () => ({ lower: (value) => { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js index f11c1cdd8..100550c7e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createCountersHelpers = () => ({ lower: (value) => { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js index 3fa45ef40..375493923 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js @@ -111,7 +111,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointHelpers = () => ({ lower: (value) => { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js index 4b1afa60d..481a198db 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js @@ -54,7 +54,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js index 7b21cd65d..21dbd3c55 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js @@ -74,7 +74,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js index ae42a0f26..7e7627d32 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js @@ -55,7 +55,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js index 2e3abb637..f47ae00ce 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js @@ -105,7 +105,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js index 32ee37347..18cb1d34d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js index ec1237f66..4f7732d63 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js index be7deb1ea..aff235d10 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js index ecb8cb821..9971930a4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js index 4dc2da4f5..041822b7f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createFooContainerHelpers = () => ({ lower: (value) => { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js index 846e08788..b49a8922c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js index 622285468..56b7a70e6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js index 19b2aa1d6..03b1a3cb8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js index 2239dcab2..1626f7c50 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; function __bjs_jsValueLower(value) { let kind; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js index f6f722c12..4dabe1466 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js index 5e7d75d83..35133ca32 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js index 98415fa7f..81a878053 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js index 55647f15a..f18eaf4d5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js index f6cce62a3..ef0f69b5e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js index 29c57aed0..c01c54626 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js index 21ae7a2b1..abb362ce7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js index 95b23250a..a2f0d3e4c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js index 0c5c474f2..dc3416dc8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js index c24822037..f0d2a2a06 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js @@ -54,7 +54,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createResultValuesHelpers = () => ({ lower: (value) => { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js index 7ac906b8b..2d98e6115 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.unregistered) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js index 2ba1ef696..2bdc3596a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js @@ -41,7 +41,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createAPIResultValuesHelpers = () => ({ lower: (value) => { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js index 8b2299a60..d497f84f0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js @@ -41,7 +41,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createAPIResultValuesHelpers = () => ({ lower: (value) => { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js index 90c09bf01..d1090525d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js @@ -35,7 +35,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js index f45a58b7c..81e15106d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js @@ -35,7 +35,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js index 1ca98a411..239206e95 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js index 14c34605b..2f8d3dd22 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js index 7be26f087..47b6bc560 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index ac4ee8dad..7020ab4ec 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -60,7 +60,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.unregistered) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js index ac13ec16c..2724a6322 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.unregistered) { return; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js index 4cde888c7..525093444 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js @@ -35,7 +35,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createDataPointHelpers = () => ({ lower: (value) => { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js index f73ecfc2d..092a49f9b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointHelpers = () => ({ lower: (value) => { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js index acd2d4566..5b07dae16 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js index f61606e02..181cc29a9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointerFieldsHelpers = () => ({ lower: (value) => { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js index d2b58d2da..901732e48 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js @@ -30,7 +30,7 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode === "pointer" ? "pointer" : "none"; + const identityMode = options.identityMode ?? "none"; const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { diff --git a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift new file mode 100644 index 000000000..9a92a00b5 --- /dev/null +++ b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift @@ -0,0 +1,14203 @@ +// bridge-js: skip +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(BridgeJS) import JavaScriptKit + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si(_ callback: Int32, _ param0: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests10HttpStatusO_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (HttpStatus) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si(callbackValue, param0Value) + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (HttpStatus) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (HttpStatus) -> Int) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(HttpStatus) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(HttpStatus.bridgeJSLiftParameter(param0)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(_ callback: Int32, _ param0: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(_ callback: Int32, _ param0: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP(_ callback: Int32, _ param0: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP { + static func bridgeJSLift(_ callbackId: Int32) -> (any DataProcessor) -> any DataProcessor { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0ObjectId = (param0 as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP(callbackValue, param0ObjectId) + return AnyDataProcessor.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (any DataProcessor) -> any DataProcessor { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (any DataProcessor) -> any DataProcessor) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(any DataProcessor) -> any DataProcessor>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(AnyDataProcessor.bridgeJSLiftParameter(param0)) + return (result as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS(_ callback: Int32, _ param0: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests13DataProcessorP_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (any DataProcessor) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0ObjectId = (param0 as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS(callbackValue, param0ObjectId) + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (any DataProcessor) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (any DataProcessor) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(any DataProcessor) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(AnyDataProcessor.bridgeJSLiftParameter(param0)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests5ThemeO_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Theme) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS(callbackValue, param0Bytes, param0Length) + return ret + } + let ret = ret0 + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Theme) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Theme) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Theme) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Theme.bridgeJSLiftParameter(param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests5ThemeO_Sb { + static func bridgeJSLift(_ callbackId: Int32) -> (Theme) -> Bool { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb(callbackValue, param0Bytes, param0Length) + return ret + } + let ret = ret0 + return Bool.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Theme) -> Bool { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Theme) -> Bool) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Theme) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Theme.bridgeJSLiftParameter(param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests7GreeterC_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Greeter) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Pointer = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS(callbackValue, param0Pointer) + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Greeter) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Greeter) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Greeter) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Greeter.bridgeJSLiftParameter(param0)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(_ callback: Int32, _ param0: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(_ callback: Int32, _ param0: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC(_ callback: Int32, _ param0: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC { + static func bridgeJSLift(_ callbackId: Int32) -> (JSObject) -> JSObject { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC(callbackValue, param0Value) + return JSObject.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (JSObject) -> JSObject { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (JSObject) -> JSObject) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(JSObject) -> JSObject>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(JSObject.bridgeJSLiftParameter(param0)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS(_ callback: Int32, _ param0: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests9APIResultO_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (APIResult) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0CaseId = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS(callbackValue, param0CaseId) + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (APIResult) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (APIResult) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(APIResult) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(APIResult.bridgeJSLiftParameter(param0)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS(_ callback: Int32, _ param0: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests9DirectionO_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Direction) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS(callbackValue, param0Value) + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Direction) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Direction) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Direction) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Direction.bridgeJSLiftParameter(param0)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(_ callback: Int32, _ param0: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(_ callback: Int32, _ param0: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb(_ callback: Int32, _ param0: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTests9DirectionO_Sb { + static func bridgeJSLift(_ callbackId: Int32) -> (Direction) -> Bool { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb(callbackValue, param0Value) + return Bool.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Direction) -> Bool { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Direction) -> Bool) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Direction) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Direction.bridgeJSLiftParameter(param0)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> UnsafeMutableRawPointer +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> UnsafeMutableRawPointer { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> UnsafeMutableRawPointer { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSS_7GreeterC { + static func bridgeJSLift(_ callbackId: Int32) -> (String) -> Greeter { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC(callbackValue, param0Bytes, param0Length) + return ret + } + let ret = ret0 + return Greeter.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) -> Greeter { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) -> Greeter) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) -> Greeter>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSS_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (String) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS(callbackValue, param0Bytes, param0Length) + return ret + } + let ret = ret0 + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(_ callback: Int32, _ param0: Float64) -> Float64 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(_ callback: Int32, _ param0: Float64) -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd(_ callback: Int32, _ param0: Float64) -> Float64 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSd_Sd { + static func bridgeJSLift(_ callbackId: Int32) -> (Double) -> Double { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd(callbackValue, param0Value) + return Double.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Double) -> Double { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Double) -> Double) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd(_ boxPtr: UnsafeMutableRawPointer, _ param0: Float64) -> Float64 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Double) -> Double>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Double.bridgeJSLiftParameter(param0)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(_ callback: Int32, _ param0: Int32, _ param1Bytes: Int32, _ param1Length: Int32, _ param2: Float64) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(_ callback: Int32, _ param0: Int32, _ param1Bytes: Int32, _ param1Length: Int32, _ param2: Float64) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS(_ callback: Int32, _ param0: Int32, _ param1Bytes: Int32, _ param1Length: Int32, _ param2: Float64) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(callback, param0, param1Bytes, param1Length, param2) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSiSSSd_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Int, String, Double) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0, param1, param2) in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + let ret0 = param1.bridgeJSWithLoweredParameter { (param1Bytes, param1Length) in + let param2Value = param2.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS(callbackValue, param0Value, param1Bytes, param1Length, param2Value) + return ret + } + let ret = ret0 + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Int, String, Double) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Int, String, Double) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32, _ param1Bytes: Int32, _ param1Length: Int32, _ param2: Float64) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Int, String, Double) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Int.bridgeJSLiftParameter(param0), String.bridgeJSLiftParameter(param1Bytes, param1Length), Double.bridgeJSLiftParameter(param2)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(_ callback: Int32, _ param0: Int32, _ param1: Int32, _ param2: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(_ callback: Int32, _ param0: Int32, _ param1: Int32, _ param2: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si(_ callback: Int32, _ param0: Int32, _ param1: Int32, _ param2: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(callback, param0, param1, param2) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSiSiSi_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (Int, Int, Int) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0, param1, param2) in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + let param1Value = param1.bridgeJSLowerParameter() + let param2Value = param2.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si(callbackValue, param0Value, param1Value, param2Value) + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Int, Int, Int) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Int, Int, Int) -> Int) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32, _ param1: Int32, _ param2: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Int, Int, Int) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Int.bridgeJSLiftParameter(param0), Int.bridgeJSLiftParameter(param1), Int.bridgeJSLiftParameter(param2)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(_ callback: Int32, _ param0: Int32, _ param1: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(_ callback: Int32, _ param0: Int32, _ param1: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si(_ callback: Int32, _ param0: Int32, _ param1: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(callback, param0, param1) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSiSi_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (Int, Int) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0, param1) in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + let param1Value = param1.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si(callbackValue, param0Value, param1Value) + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Int, Int) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Int, Int) -> Int) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32, _ param1: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Int, Int) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Int.bridgeJSLiftParameter(param0), Int.bridgeJSLiftParameter(param1)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si(_ callback: Int32, _ param0: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSi_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (Int) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si(callbackValue, param0Value) + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Int) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Int) -> Int) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Int) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Int.bridgeJSLiftParameter(param0)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSi_y { + static func bridgeJSLift(_ callbackId: Int32) -> (Int) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y(callbackValue, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Int) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Int) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Int) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(Int.bridgeJSLiftParameter(param0)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0ObjectId: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0ObjectId: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0ObjectId: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(callback, param0IsSome, param0ObjectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSq13DataProcessorP_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0ObjectId): (Int32, Int32) + if let param0 { + (param0IsSome, param0ObjectId) = (1, (param0 as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) + } else { + (param0IsSome, param0ObjectId) = (0, 0) + } + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS(callbackValue, param0IsSome, param0ObjectId) + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(callback, param0IsSome, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSq5ThemeO_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0IsSome, param0Bytes, param0Length) in + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(callbackValue, param0IsSome, param0Bytes, param0Length) + return ret + } + let ret = ret0 + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(callback, param0IsSome, param0Pointer) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSq7GreeterC_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0Pointer) = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(callbackValue, param0IsSome, param0Pointer) + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(callback, param0IsSome, param0Pointer) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0Pointer) = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC(callbackValue, param0IsSome, param0Pointer) + return Optional.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(callback, param0IsSome, param0CaseId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSq9APIResultO_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0CaseId) = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS(callbackValue, param0IsSome, param0CaseId) + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0CaseId)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(callback, param0IsSome, param0Value) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSq9DirectionO_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS(callbackValue, param0IsSome, param0Value) + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(callback, param0IsSome, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSqSS_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0IsSome, param0Bytes, param0Length) in + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS(callbackValue, param0IsSome, param0Bytes, param0Length) + return ret + } + let ret = ret0 + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(callback, param0IsSome, param0Value) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsSqSi_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS(callbackValue, param0IsSome, param0Value) + return String.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Optional) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestss11FeatureFlagO_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending FeatureFlag) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(callbackValue, param0Bytes, param0Length) + } + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending FeatureFlag) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending FeatureFlag) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending FeatureFlag) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(FeatureFlag.bridgeJSLiftParameter(param0Bytes, param0Length)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestss11WeatherDataC_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending WeatherData) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(callbackValue, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending WeatherData) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending WeatherData) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending WeatherData) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(WeatherData.bridgeJSLiftParameter(param0)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(callback, param0Kind, param0Payload1, param0Payload2) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestss7JSValueV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending JSValue) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0Kind, param0Payload1, param0Payload2) = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y(callbackValue, param0Kind, param0Payload1, param0Payload2) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending JSValue) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending JSValue) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y(_ boxPtr: UnsafeMutableRawPointer, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending JSValue) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(JSValue.bridgeJSLiftParameter(param0Kind, param0Payload1, param0Payload2)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestssSS_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending String) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(callbackValue, param0Bytes, param0Length) + } + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending String) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending String) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending String) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(_ callback: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(_ callback: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(_ callback: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSS_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending [String]) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(callbackValue) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending [String]) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending [String]) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending [String]) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure([String].bridgeJSLiftParameter()) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(_ callback: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(_ callback: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y(_ callback: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSb_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending [Bool]) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y(callbackValue) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending [Bool]) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending [Bool]) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending [Bool]) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure([Bool].bridgeJSLiftParameter()) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(_ callback: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(_ callback: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y(_ callback: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSd_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending [Double]) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y(callbackValue) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending [Double]) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending [Double]) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending [Double]) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure([Double].bridgeJSLiftParameter()) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestssSb_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending Bool) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y(callbackValue, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending Bool) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Bool) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Bool) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(Bool.bridgeJSLiftParameter(param0)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(_ callback: Int32, _ param0: Float64) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(_ callback: Int32, _ param0: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y(_ callback: Int32, _ param0: Float64) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestssSd_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending Double) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y(callbackValue, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending Double) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Double) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Float64) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Double) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(Double.bridgeJSLiftParameter(param0)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(callback, param0IsSome, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestssSqSS_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending Optional) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0IsSome, param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y(callbackValue, param0IsSome, param0Bytes, param0Length) + } + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending Optional) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Optional) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Optional) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float64) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float64) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(callback, param0IsSome, param0Value) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestssSqSd_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending Optional) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y(callbackValue, param0IsSome, param0Value) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending Optional) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Optional) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Float64) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Optional) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ callback: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ callback: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP(_ callback: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsy_13DataProcessorP { + static func bridgeJSLift(_ callbackId: Int32) -> () -> any DataProcessor { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP(callbackValue) + return AnyDataProcessor.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == () -> any DataProcessor { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> any DataProcessor) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP(_ boxPtr: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<() -> any DataProcessor>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure() + return (result as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(_ callback: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(_ callback: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb(_ callback: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsy_Sb { + static func bridgeJSLift(_ callbackId: Int32) -> () -> Bool { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb(callbackValue) + return Bool.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == () -> Bool { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> Bool) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb(_ boxPtr: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<() -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure() + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ callback: Int32) -> UnsafeMutableRawPointer +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ callback: Int32) -> UnsafeMutableRawPointer { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC(_ callback: Int32) -> UnsafeMutableRawPointer { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsy_Sq7GreeterC { + static func bridgeJSLift(_ callbackId: Int32) -> () -> Optional { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC(callbackValue) + return Optional.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == () -> Optional { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> Optional) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC(_ boxPtr: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<() -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure() + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(_ callback: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(_ callback: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y(_ callback: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsy_y { + static func bridgeJSLift(_ callbackId: Int32) -> () -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y(callbackValue) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == () -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<() -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure() + #else + fatalError("Only available on WebAssembly") + #endif +} + +struct AnyArrayElementProtocol: ArrayElementProtocol, _BridgedSwiftProtocolWrapper { + let jsObject: JSObject + + var value: Int { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_ArrayElementProtocol_value_get(jsObjectValue) + return Int.bridgeJSLiftReturn(ret) + } + set { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_ArrayElementProtocol_value_set(jsObjectValue, newValueValue) + } + } + + static func bridgeJSLiftParameter(_ value: Int32) -> Self { + return AnyArrayElementProtocol(jsObject: JSObject(id: UInt32(bitPattern: value))) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayElementProtocol_value_get") +fileprivate func bjs_ArrayElementProtocol_value_get_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func bjs_ArrayElementProtocol_value_get_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArrayElementProtocol_value_get(_ jsObject: Int32) -> Int32 { + return bjs_ArrayElementProtocol_value_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayElementProtocol_value_set") +fileprivate func bjs_ArrayElementProtocol_value_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void +#else +fileprivate func bjs_ArrayElementProtocol_value_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArrayElementProtocol_value_set(_ jsObject: Int32, _ newValue: Int32) -> Void { + return bjs_ArrayElementProtocol_value_set_extern(jsObject, newValue) +} + +struct AnyDataProcessor: DataProcessor, _BridgedSwiftProtocolWrapper { + let jsObject: JSObject + + func increment(by amount: Int) -> Void { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let amountValue = amount.bridgeJSLowerParameter() + _extern_increment(jsObjectValue, amountValue) + } + + func getValue() -> Int { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = _extern_getValue(jsObjectValue) + return Int.bridgeJSLiftReturn(ret) + } + + func setLabelElements(_ labelPrefix: String, _ labelSuffix: String) -> Void { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + labelPrefix.bridgeJSWithLoweredParameter { (labelPrefixBytes, labelPrefixLength) in + labelSuffix.bridgeJSWithLoweredParameter { (labelSuffixBytes, labelSuffixLength) in + _extern_setLabelElements(jsObjectValue, labelPrefixBytes, labelPrefixLength, labelSuffixBytes, labelSuffixLength) + } + } + } + + func getLabel() -> String { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = _extern_getLabel(jsObjectValue) + return String.bridgeJSLiftReturn(ret) + } + + func isEven() -> Bool { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = _extern_isEven(jsObjectValue) + return Bool.bridgeJSLiftReturn(ret) + } + + func processGreeter(_ greeter: Greeter) -> String { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let greeterPointer = greeter.bridgeJSLowerParameter() + let ret = _extern_processGreeter(jsObjectValue, greeterPointer) + return String.bridgeJSLiftReturn(ret) + } + + func createGreeter() -> Greeter { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = _extern_createGreeter(jsObjectValue) + return Greeter.bridgeJSLiftReturn(ret) + } + + func processOptionalGreeter(_ greeter: Optional) -> String { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let (greeterIsSome, greeterPointer) = greeter.bridgeJSLowerParameter() + let ret = _extern_processOptionalGreeter(jsObjectValue, greeterIsSome, greeterPointer) + return String.bridgeJSLiftReturn(ret) + } + + func createOptionalGreeter() -> Optional { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = _extern_createOptionalGreeter(jsObjectValue) + return Optional.bridgeJSLiftReturn(ret) + } + + func handleAPIResult(_ result: Optional) -> Void { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let (resultIsSome, resultCaseId) = result.bridgeJSLowerParameter() + _extern_handleAPIResult(jsObjectValue, resultIsSome, resultCaseId) + } + + func getAPIResult() -> Optional { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = _extern_getAPIResult(jsObjectValue) + return Optional.bridgeJSLiftReturn(ret) + } + + var count: Int { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_DataProcessor_count_get(jsObjectValue) + return Int.bridgeJSLiftReturn(ret) + } + set { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_DataProcessor_count_set(jsObjectValue, newValueValue) + } + } + + var name: String { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_DataProcessor_name_get(jsObjectValue) + return String.bridgeJSLiftReturn(ret) + } + } + + var optionalTag: Optional { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_DataProcessor_optionalTag_get(jsObjectValue) + return Optional.bridgeJSLiftReturnFromSideChannel() + } + set { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + newValue.bridgeJSWithLoweredParameter { (newValueIsSome, newValueBytes, newValueLength) in + bjs_DataProcessor_optionalTag_set(jsObjectValue, newValueIsSome, newValueBytes, newValueLength) + } + } + } + + var optionalCount: Optional { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_DataProcessor_optionalCount_get(jsObjectValue) + return Optional.bridgeJSLiftReturnFromSideChannel() + } + set { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let (newValueIsSome, newValueValue) = newValue.bridgeJSLowerParameter() + bjs_DataProcessor_optionalCount_set(jsObjectValue, newValueIsSome, newValueValue) + } + } + + var direction: Optional { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_DataProcessor_direction_get(jsObjectValue) + return Optional.bridgeJSLiftReturn(ret) + } + set { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let (newValueIsSome, newValueValue) = newValue.bridgeJSLowerParameter() + bjs_DataProcessor_direction_set(jsObjectValue, newValueIsSome, newValueValue) + } + } + + var optionalTheme: Optional { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_DataProcessor_optionalTheme_get(jsObjectValue) + return Optional.bridgeJSLiftReturnFromSideChannel() + } + set { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + newValue.bridgeJSWithLoweredParameter { (newValueIsSome, newValueBytes, newValueLength) in + bjs_DataProcessor_optionalTheme_set(jsObjectValue, newValueIsSome, newValueBytes, newValueLength) + } + } + } + + var httpStatus: Optional { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_DataProcessor_httpStatus_get(jsObjectValue) + return Optional.bridgeJSLiftReturnFromSideChannel() + } + set { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let (newValueIsSome, newValueValue) = newValue.bridgeJSLowerParameter() + bjs_DataProcessor_httpStatus_set(jsObjectValue, newValueIsSome, newValueValue) + } + } + + var apiResult: Optional { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_DataProcessor_apiResult_get(jsObjectValue) + return Optional.bridgeJSLiftReturn(ret) + } + set { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let (newValueIsSome, newValueCaseId) = newValue.bridgeJSLowerParameter() + bjs_DataProcessor_apiResult_set(jsObjectValue, newValueIsSome, newValueCaseId) + } + } + + var helper: Greeter { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_DataProcessor_helper_get(jsObjectValue) + return Greeter.bridgeJSLiftReturn(ret) + } + set { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let newValuePointer = newValue.bridgeJSLowerParameter() + bjs_DataProcessor_helper_set(jsObjectValue, newValuePointer) + } + } + + var optionalHelper: Optional { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_DataProcessor_optionalHelper_get(jsObjectValue) + return Optional.bridgeJSLiftReturn(ret) + } + set { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let (newValueIsSome, newValuePointer) = newValue.bridgeJSLowerParameter() + bjs_DataProcessor_optionalHelper_set(jsObjectValue, newValueIsSome, newValuePointer) + } + } + + static func bridgeJSLiftParameter(_ value: Int32) -> Self { + return AnyDataProcessor(jsObject: JSObject(id: UInt32(bitPattern: value))) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_increment") +fileprivate func _extern_increment_extern(_ jsObject: Int32, _ amount: Int32) -> Void +#else +fileprivate func _extern_increment_extern(_ jsObject: Int32, _ amount: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_increment(_ jsObject: Int32, _ amount: Int32) -> Void { + return _extern_increment_extern(jsObject, amount) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_getValue") +fileprivate func _extern_getValue_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func _extern_getValue_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_getValue(_ jsObject: Int32) -> Int32 { + return _extern_getValue_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_setLabelElements") +fileprivate func _extern_setLabelElements_extern(_ jsObject: Int32, _ labelPrefixBytes: Int32, _ labelPrefixLength: Int32, _ labelSuffixBytes: Int32, _ labelSuffixLength: Int32) -> Void +#else +fileprivate func _extern_setLabelElements_extern(_ jsObject: Int32, _ labelPrefixBytes: Int32, _ labelPrefixLength: Int32, _ labelSuffixBytes: Int32, _ labelSuffixLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_setLabelElements(_ jsObject: Int32, _ labelPrefixBytes: Int32, _ labelPrefixLength: Int32, _ labelSuffixBytes: Int32, _ labelSuffixLength: Int32) -> Void { + return _extern_setLabelElements_extern(jsObject, labelPrefixBytes, labelPrefixLength, labelSuffixBytes, labelSuffixLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_getLabel") +fileprivate func _extern_getLabel_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func _extern_getLabel_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_getLabel(_ jsObject: Int32) -> Int32 { + return _extern_getLabel_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_isEven") +fileprivate func _extern_isEven_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func _extern_isEven_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_isEven(_ jsObject: Int32) -> Int32 { + return _extern_isEven_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_processGreeter") +fileprivate func _extern_processGreeter_extern(_ jsObject: Int32, _ greeter: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _extern_processGreeter_extern(_ jsObject: Int32, _ greeter: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_processGreeter(_ jsObject: Int32, _ greeter: UnsafeMutableRawPointer) -> Int32 { + return _extern_processGreeter_extern(jsObject, greeter) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_createGreeter") +fileprivate func _extern_createGreeter_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer +#else +fileprivate func _extern_createGreeter_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_createGreeter(_ jsObject: Int32) -> UnsafeMutableRawPointer { + return _extern_createGreeter_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_processOptionalGreeter") +fileprivate func _extern_processOptionalGreeter_extern(_ jsObject: Int32, _ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _extern_processOptionalGreeter_extern(_ jsObject: Int32, _ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_processOptionalGreeter(_ jsObject: Int32, _ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> Int32 { + return _extern_processOptionalGreeter_extern(jsObject, greeterIsSome, greeterPointer) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_createOptionalGreeter") +fileprivate func _extern_createOptionalGreeter_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer +#else +fileprivate func _extern_createOptionalGreeter_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_createOptionalGreeter(_ jsObject: Int32) -> UnsafeMutableRawPointer { + return _extern_createOptionalGreeter_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_handleAPIResult") +fileprivate func _extern_handleAPIResult_extern(_ jsObject: Int32, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void +#else +fileprivate func _extern_handleAPIResult_extern(_ jsObject: Int32, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_handleAPIResult(_ jsObject: Int32, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void { + return _extern_handleAPIResult_extern(jsObject, resultIsSome, resultCaseId) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_getAPIResult") +fileprivate func _extern_getAPIResult_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func _extern_getAPIResult_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_getAPIResult(_ jsObject: Int32) -> Int32 { + return _extern_getAPIResult_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_count_get") +fileprivate func bjs_DataProcessor_count_get_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func bjs_DataProcessor_count_get_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_count_get(_ jsObject: Int32) -> Int32 { + return bjs_DataProcessor_count_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_count_set") +fileprivate func bjs_DataProcessor_count_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void +#else +fileprivate func bjs_DataProcessor_count_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_count_set(_ jsObject: Int32, _ newValue: Int32) -> Void { + return bjs_DataProcessor_count_set_extern(jsObject, newValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_name_get") +fileprivate func bjs_DataProcessor_name_get_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func bjs_DataProcessor_name_get_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_name_get(_ jsObject: Int32) -> Int32 { + return bjs_DataProcessor_name_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalTag_get") +fileprivate func bjs_DataProcessor_optionalTag_get_extern(_ jsObject: Int32) -> Void +#else +fileprivate func bjs_DataProcessor_optionalTag_get_extern(_ jsObject: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_optionalTag_get(_ jsObject: Int32) -> Void { + return bjs_DataProcessor_optionalTag_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalTag_set") +fileprivate func bjs_DataProcessor_optionalTag_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void +#else +fileprivate func bjs_DataProcessor_optionalTag_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_optionalTag_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { + return bjs_DataProcessor_optionalTag_set_extern(jsObject, newValueIsSome, newValueBytes, newValueLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalCount_get") +fileprivate func bjs_DataProcessor_optionalCount_get_extern(_ jsObject: Int32) -> Void +#else +fileprivate func bjs_DataProcessor_optionalCount_get_extern(_ jsObject: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_optionalCount_get(_ jsObject: Int32) -> Void { + return bjs_DataProcessor_optionalCount_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalCount_set") +fileprivate func bjs_DataProcessor_optionalCount_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void +#else +fileprivate func bjs_DataProcessor_optionalCount_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_optionalCount_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { + return bjs_DataProcessor_optionalCount_set_extern(jsObject, newValueIsSome, newValueValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_direction_get") +fileprivate func bjs_DataProcessor_direction_get_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func bjs_DataProcessor_direction_get_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_direction_get(_ jsObject: Int32) -> Int32 { + return bjs_DataProcessor_direction_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_direction_set") +fileprivate func bjs_DataProcessor_direction_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void +#else +fileprivate func bjs_DataProcessor_direction_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_direction_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { + return bjs_DataProcessor_direction_set_extern(jsObject, newValueIsSome, newValueValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalTheme_get") +fileprivate func bjs_DataProcessor_optionalTheme_get_extern(_ jsObject: Int32) -> Void +#else +fileprivate func bjs_DataProcessor_optionalTheme_get_extern(_ jsObject: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_optionalTheme_get(_ jsObject: Int32) -> Void { + return bjs_DataProcessor_optionalTheme_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalTheme_set") +fileprivate func bjs_DataProcessor_optionalTheme_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void +#else +fileprivate func bjs_DataProcessor_optionalTheme_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_optionalTheme_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { + return bjs_DataProcessor_optionalTheme_set_extern(jsObject, newValueIsSome, newValueBytes, newValueLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_httpStatus_get") +fileprivate func bjs_DataProcessor_httpStatus_get_extern(_ jsObject: Int32) -> Void +#else +fileprivate func bjs_DataProcessor_httpStatus_get_extern(_ jsObject: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_httpStatus_get(_ jsObject: Int32) -> Void { + return bjs_DataProcessor_httpStatus_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_httpStatus_set") +fileprivate func bjs_DataProcessor_httpStatus_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void +#else +fileprivate func bjs_DataProcessor_httpStatus_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_httpStatus_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { + return bjs_DataProcessor_httpStatus_set_extern(jsObject, newValueIsSome, newValueValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_apiResult_get") +fileprivate func bjs_DataProcessor_apiResult_get_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func bjs_DataProcessor_apiResult_get_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_apiResult_get(_ jsObject: Int32) -> Int32 { + return bjs_DataProcessor_apiResult_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_apiResult_set") +fileprivate func bjs_DataProcessor_apiResult_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueCaseId: Int32) -> Void +#else +fileprivate func bjs_DataProcessor_apiResult_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueCaseId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_apiResult_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueCaseId: Int32) -> Void { + return bjs_DataProcessor_apiResult_set_extern(jsObject, newValueIsSome, newValueCaseId) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_helper_get") +fileprivate func bjs_DataProcessor_helper_get_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer +#else +fileprivate func bjs_DataProcessor_helper_get_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_helper_get(_ jsObject: Int32) -> UnsafeMutableRawPointer { + return bjs_DataProcessor_helper_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_helper_set") +fileprivate func bjs_DataProcessor_helper_set_extern(_ jsObject: Int32, _ newValue: UnsafeMutableRawPointer) -> Void +#else +fileprivate func bjs_DataProcessor_helper_set_extern(_ jsObject: Int32, _ newValue: UnsafeMutableRawPointer) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_helper_set(_ jsObject: Int32, _ newValue: UnsafeMutableRawPointer) -> Void { + return bjs_DataProcessor_helper_set_extern(jsObject, newValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalHelper_get") +fileprivate func bjs_DataProcessor_optionalHelper_get_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer +#else +fileprivate func bjs_DataProcessor_optionalHelper_get_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_optionalHelper_get(_ jsObject: Int32) -> UnsafeMutableRawPointer { + return bjs_DataProcessor_optionalHelper_get_extern(jsObject) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalHelper_set") +fileprivate func bjs_DataProcessor_optionalHelper_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValuePointer: UnsafeMutableRawPointer) -> Void +#else +fileprivate func bjs_DataProcessor_optionalHelper_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValuePointer: UnsafeMutableRawPointer) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DataProcessor_optionalHelper_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValuePointer: UnsafeMutableRawPointer) -> Void { + return bjs_DataProcessor_optionalHelper_set_extern(jsObject, newValueIsSome, newValuePointer) +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripIntArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripIntArray") +public func _bjs_ArraySupportExports_static_roundTripIntArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripIntArray(_: [Int].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripStringArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripStringArray") +public func _bjs_ArraySupportExports_static_roundTripStringArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripStringArray(_: [String].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripDoubleArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripDoubleArray") +public func _bjs_ArraySupportExports_static_roundTripDoubleArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripDoubleArray(_: [Double].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripBoolArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripBoolArray") +public func _bjs_ArraySupportExports_static_roundTripBoolArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripBoolArray(_: [Bool].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripUnsafeRawPointerArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripUnsafeRawPointerArray") +public func _bjs_ArraySupportExports_static_roundTripUnsafeRawPointerArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripUnsafeRawPointerArray(_: [UnsafeRawPointer].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripUnsafeMutableRawPointerArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripUnsafeMutableRawPointerArray") +public func _bjs_ArraySupportExports_static_roundTripUnsafeMutableRawPointerArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripUnsafeMutableRawPointerArray(_: [UnsafeMutableRawPointer].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOpaquePointerArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOpaquePointerArray") +public func _bjs_ArraySupportExports_static_roundTripOpaquePointerArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOpaquePointerArray(_: [OpaquePointer].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripUnsafePointerArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripUnsafePointerArray") +public func _bjs_ArraySupportExports_static_roundTripUnsafePointerArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripUnsafePointerArray(_: [UnsafePointer].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripUnsafeMutablePointerArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripUnsafeMutablePointerArray") +public func _bjs_ArraySupportExports_static_roundTripUnsafeMutablePointerArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripUnsafeMutablePointerArray(_: [UnsafeMutablePointer].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripJSValueArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripJSValueArray") +public func _bjs_ArraySupportExports_static_roundTripJSValueArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripJSValueArray(_: [JSValue].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripJSObjectArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripJSObjectArray") +public func _bjs_ArraySupportExports_static_roundTripJSObjectArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripJSObjectArray(_: [JSObject].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripCaseEnumArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripCaseEnumArray") +public func _bjs_ArraySupportExports_static_roundTripCaseEnumArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripCaseEnumArray(_: [Direction].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripStringRawValueEnumArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripStringRawValueEnumArray") +public func _bjs_ArraySupportExports_static_roundTripStringRawValueEnumArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripStringRawValueEnumArray(_: [Theme].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripIntRawValueEnumArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripIntRawValueEnumArray") +public func _bjs_ArraySupportExports_static_roundTripIntRawValueEnumArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripIntRawValueEnumArray(_: [HttpStatus].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripInt64RawValueEnumArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripInt64RawValueEnumArray") +public func _bjs_ArraySupportExports_static_roundTripInt64RawValueEnumArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripInt64RawValueEnumArray(_: [FileSize].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripUInt64RawValueEnumArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripUInt64RawValueEnumArray") +public func _bjs_ArraySupportExports_static_roundTripUInt64RawValueEnumArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripUInt64RawValueEnumArray(_: [SessionId].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripStructArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripStructArray") +public func _bjs_ArraySupportExports_static_roundTripStructArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripStructArray(_: [DataPoint].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripSwiftClassArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripSwiftClassArray") +public func _bjs_ArraySupportExports_static_roundTripSwiftClassArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripSwiftClassArray(_: [Greeter].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNamespacedSwiftClassArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripNamespacedSwiftClassArray") +public func _bjs_ArraySupportExports_static_roundTripNamespacedSwiftClassArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripNamespacedSwiftClassArray(_: [Utils.Converter].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripProtocolArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripProtocolArray") +public func _bjs_ArraySupportExports_static_roundTripProtocolArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripProtocolArray(_: [AnyArrayElementProtocol].bridgeJSStackPop()) + for __bjs_elem_ret in ret { + _swift_js_push_i32((__bjs_elem_ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) + } + _swift_js_push_i32(Int32(ret.count)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripJSClassArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripJSClassArray") +public func _bjs_ArraySupportExports_static_roundTripJSClassArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripJSClassArray(_: [ArrayElementObject].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalIntArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalIntArray") +public func _bjs_ArraySupportExports_static_roundTripOptionalIntArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOptionalIntArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalStringArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalStringArray") +public func _bjs_ArraySupportExports_static_roundTripOptionalStringArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOptionalStringArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalJSObjectArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalJSObjectArray") +public func _bjs_ArraySupportExports_static_roundTripOptionalJSObjectArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOptionalJSObjectArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalCaseEnumArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalCaseEnumArray") +public func _bjs_ArraySupportExports_static_roundTripOptionalCaseEnumArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOptionalCaseEnumArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalStringRawValueEnumArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalStringRawValueEnumArray") +public func _bjs_ArraySupportExports_static_roundTripOptionalStringRawValueEnumArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOptionalStringRawValueEnumArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalIntRawValueEnumArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalIntRawValueEnumArray") +public func _bjs_ArraySupportExports_static_roundTripOptionalIntRawValueEnumArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOptionalIntRawValueEnumArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalInt64RawValueEnumArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalInt64RawValueEnumArray") +public func _bjs_ArraySupportExports_static_roundTripOptionalInt64RawValueEnumArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOptionalInt64RawValueEnumArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalUInt64RawValueEnumArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalUInt64RawValueEnumArray") +public func _bjs_ArraySupportExports_static_roundTripOptionalUInt64RawValueEnumArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOptionalUInt64RawValueEnumArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalStructArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalStructArray") +public func _bjs_ArraySupportExports_static_roundTripOptionalStructArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOptionalStructArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalSwiftClassArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalSwiftClassArray") +public func _bjs_ArraySupportExports_static_roundTripOptionalSwiftClassArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOptionalSwiftClassArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalJSClassArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalJSClassArray") +public func _bjs_ArraySupportExports_static_roundTripOptionalJSClassArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripOptionalJSClassArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedIntArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripNestedIntArray") +public func _bjs_ArraySupportExports_static_roundTripNestedIntArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripNestedIntArray(_: [[Int]].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedStringArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripNestedStringArray") +public func _bjs_ArraySupportExports_static_roundTripNestedStringArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripNestedStringArray(_: [[String]].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedDoubleArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripNestedDoubleArray") +public func _bjs_ArraySupportExports_static_roundTripNestedDoubleArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripNestedDoubleArray(_: [[Double]].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedBoolArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripNestedBoolArray") +public func _bjs_ArraySupportExports_static_roundTripNestedBoolArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripNestedBoolArray(_: [[Bool]].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedStructArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripNestedStructArray") +public func _bjs_ArraySupportExports_static_roundTripNestedStructArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripNestedStructArray(_: [[DataPoint]].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedCaseEnumArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripNestedCaseEnumArray") +public func _bjs_ArraySupportExports_static_roundTripNestedCaseEnumArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripNestedCaseEnumArray(_: [[Direction]].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedSwiftClassArray") +@_cdecl("bjs_ArraySupportExports_static_roundTripNestedSwiftClassArray") +public func _bjs_ArraySupportExports_static_roundTripNestedSwiftClassArray() -> Void { + #if arch(wasm32) + let ret = ArraySupportExports.roundTripNestedSwiftClassArray(_: [[Greeter]].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_multiArrayFirst") +@_cdecl("bjs_ArraySupportExports_static_multiArrayFirst") +public func _bjs_ArraySupportExports_static_multiArrayFirst() -> Void { + #if arch(wasm32) + let _tmp_b = [String].bridgeJSStackPop() + let _tmp_a = [Int].bridgeJSStackPop() + let ret = ArraySupportExports.multiArrayFirst(_: _tmp_a, _: _tmp_b) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_multiArraySecond") +@_cdecl("bjs_ArraySupportExports_static_multiArraySecond") +public func _bjs_ArraySupportExports_static_multiArraySecond() -> Void { + #if arch(wasm32) + let _tmp_b = [String].bridgeJSStackPop() + let _tmp_a = [Int].bridgeJSStackPop() + let ret = ArraySupportExports.multiArraySecond(_: _tmp_a, _: _tmp_b) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_multiOptionalArrayFirst") +@_cdecl("bjs_ArraySupportExports_static_multiOptionalArrayFirst") +public func _bjs_ArraySupportExports_static_multiOptionalArrayFirst() -> Void { + #if arch(wasm32) + let _tmp_b = Optional<[String]>.bridgeJSLiftParameter() + let _tmp_a = Optional<[Int]>.bridgeJSLiftParameter() + let ret = ArraySupportExports.multiOptionalArrayFirst(_: _tmp_a, _: _tmp_b) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArraySupportExports_static_multiOptionalArraySecond") +@_cdecl("bjs_ArraySupportExports_static_multiOptionalArraySecond") +public func _bjs_ArraySupportExports_static_multiOptionalArraySecond() -> Void { + #if arch(wasm32) + let _tmp_b = Optional<[String]>.bridgeJSLiftParameter() + let _tmp_a = Optional<[Int]>.bridgeJSLiftParameter() + let ret = ArraySupportExports.multiOptionalArraySecond(_: _tmp_a, _: _tmp_b) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_testStringDefault") +@_cdecl("bjs_DefaultArgumentExports_static_testStringDefault") +public func _bjs_DefaultArgumentExports_static_testStringDefault(_ messageBytes: Int32, _ messageLength: Int32) -> Void { + #if arch(wasm32) + let ret = DefaultArgumentExports.testStringDefault(message: String.bridgeJSLiftParameter(messageBytes, messageLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_testIntDefault") +@_cdecl("bjs_DefaultArgumentExports_static_testIntDefault") +public func _bjs_DefaultArgumentExports_static_testIntDefault(_ count: Int32) -> Int32 { + #if arch(wasm32) + let ret = DefaultArgumentExports.testIntDefault(count: Int.bridgeJSLiftParameter(count)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_testBoolDefault") +@_cdecl("bjs_DefaultArgumentExports_static_testBoolDefault") +public func _bjs_DefaultArgumentExports_static_testBoolDefault(_ flag: Int32) -> Int32 { + #if arch(wasm32) + let ret = DefaultArgumentExports.testBoolDefault(flag: Bool.bridgeJSLiftParameter(flag)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_testOptionalDefault") +@_cdecl("bjs_DefaultArgumentExports_static_testOptionalDefault") +public func _bjs_DefaultArgumentExports_static_testOptionalDefault(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { + #if arch(wasm32) + let ret = DefaultArgumentExports.testOptionalDefault(name: Optional.bridgeJSLiftParameter(nameIsSome, nameBytes, nameLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_testMultipleDefaults") +@_cdecl("bjs_DefaultArgumentExports_static_testMultipleDefaults") +public func _bjs_DefaultArgumentExports_static_testMultipleDefaults(_ titleBytes: Int32, _ titleLength: Int32, _ count: Int32, _ enabled: Int32) -> Void { + #if arch(wasm32) + let ret = DefaultArgumentExports.testMultipleDefaults(title: String.bridgeJSLiftParameter(titleBytes, titleLength), count: Int.bridgeJSLiftParameter(count), enabled: Bool.bridgeJSLiftParameter(enabled)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_testSimpleEnumDefault") +@_cdecl("bjs_DefaultArgumentExports_static_testSimpleEnumDefault") +public func _bjs_DefaultArgumentExports_static_testSimpleEnumDefault(_ status: Int32) -> Int32 { + #if arch(wasm32) + let ret = DefaultArgumentExports.testSimpleEnumDefault(status: Status.bridgeJSLiftParameter(status)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_testDirectionDefault") +@_cdecl("bjs_DefaultArgumentExports_static_testDirectionDefault") +public func _bjs_DefaultArgumentExports_static_testDirectionDefault(_ direction: Int32) -> Int32 { + #if arch(wasm32) + let ret = DefaultArgumentExports.testDirectionDefault(direction: Direction.bridgeJSLiftParameter(direction)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_testRawStringEnumDefault") +@_cdecl("bjs_DefaultArgumentExports_static_testRawStringEnumDefault") +public func _bjs_DefaultArgumentExports_static_testRawStringEnumDefault(_ themeBytes: Int32, _ themeLength: Int32) -> Void { + #if arch(wasm32) + let ret = DefaultArgumentExports.testRawStringEnumDefault(theme: Theme.bridgeJSLiftParameter(themeBytes, themeLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_testComplexInit") +@_cdecl("bjs_DefaultArgumentExports_static_testComplexInit") +public func _bjs_DefaultArgumentExports_static_testComplexInit(_ greeter: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DefaultArgumentExports.testComplexInit(greeter: Greeter.bridgeJSLiftParameter(greeter)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_testEmptyInit") +@_cdecl("bjs_DefaultArgumentExports_static_testEmptyInit") +public func _bjs_DefaultArgumentExports_static_testEmptyInit(_ object: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = DefaultArgumentExports.testEmptyInit(_: StaticPropertyHolder.bridgeJSLiftParameter(object)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_createConstructorDefaults") +@_cdecl("bjs_DefaultArgumentExports_static_createConstructorDefaults") +public func _bjs_DefaultArgumentExports_static_createConstructorDefaults(_ nameBytes: Int32, _ nameLength: Int32, _ count: Int32, _ enabled: Int32, _ status: Int32, _ tagIsSome: Int32, _ tagBytes: Int32, _ tagLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = DefaultArgumentExports.createConstructorDefaults(name: String.bridgeJSLiftParameter(nameBytes, nameLength), count: Int.bridgeJSLiftParameter(count), enabled: Bool.bridgeJSLiftParameter(enabled), status: Status.bridgeJSLiftParameter(status), tag: Optional.bridgeJSLiftParameter(tagIsSome, tagBytes, tagLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_describeConstructorDefaults") +@_cdecl("bjs_DefaultArgumentExports_static_describeConstructorDefaults") +public func _bjs_DefaultArgumentExports_static_describeConstructorDefaults(_ value: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DefaultArgumentExports.describeConstructorDefaults(_: DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_arrayWithDefault") +@_cdecl("bjs_DefaultArgumentExports_static_arrayWithDefault") +public func _bjs_DefaultArgumentExports_static_arrayWithDefault() -> Int32 { + #if arch(wasm32) + let ret = DefaultArgumentExports.arrayWithDefault(_: [Int].bridgeJSStackPop()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_arrayWithOptionalDefault") +@_cdecl("bjs_DefaultArgumentExports_static_arrayWithOptionalDefault") +public func _bjs_DefaultArgumentExports_static_arrayWithOptionalDefault() -> Int32 { + #if arch(wasm32) + let ret = DefaultArgumentExports.arrayWithOptionalDefault(_: Optional<[Int]>.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentExports_static_arrayMixedDefaults") +@_cdecl("bjs_DefaultArgumentExports_static_arrayMixedDefaults") +public func _bjs_DefaultArgumentExports_static_arrayMixedDefaults(_ prefixBytes: Int32, _ prefixLength: Int32, _ suffixBytes: Int32, _ suffixLength: Int32) -> Void { + #if arch(wasm32) + let ret = DefaultArgumentExports.arrayMixedDefaults(prefix: String.bridgeJSLiftParameter(prefixBytes, prefixLength), values: [Int].bridgeJSStackPop(), suffix: String.bridgeJSLiftParameter(suffixBytes, suffixLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Direction: _BridgedSwiftCaseEnum { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { + return bridgeJSRawValue + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Direction { + return bridgeJSLiftParameter(value) + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Direction { + return Direction(bridgeJSRawValue: value)! + } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { + return bridgeJSLowerParameter() + } + + private init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .north + case 1: + self = .south + case 2: + self = .east + case 3: + self = .west + default: + return nil + } + } + + private var bridgeJSRawValue: Int32 { + switch self { + case .north: + return 0 + case .south: + return 1 + case .east: + return 2 + case .west: + return 3 + } + } +} + +extension Status: _BridgedSwiftCaseEnum { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { + return bridgeJSRawValue + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Status { + return bridgeJSLiftParameter(value) + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Status { + return Status(bridgeJSRawValue: value)! + } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { + return bridgeJSLowerParameter() + } + + private init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .loading + case 1: + self = .success + case 2: + self = .error + default: + return nil + } + } + + private var bridgeJSRawValue: Int32 { + switch self { + case .loading: + return 0 + case .success: + return 1 + case .error: + return 2 + } + } +} + +extension Theme: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension HttpStatus: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension FileSize: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension SessionId: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension Precision: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension Ratio: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension TSDirection: _BridgedSwiftCaseEnum { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { + return bridgeJSRawValue + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> TSDirection { + return bridgeJSLiftParameter(value) + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> TSDirection { + return TSDirection(bridgeJSRawValue: value)! + } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { + return bridgeJSLowerParameter() + } + + private init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .north + case 1: + self = .south + case 2: + self = .east + case 3: + self = .west + default: + return nil + } + } + + private var bridgeJSRawValue: Int32 { + switch self { + case .north: + return 0 + case .south: + return 1 + case .east: + return 2 + case .west: + return 3 + } + } +} + +extension TSTheme: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +@_expose(wasm, "bjs_Utils_StringUtils_static_uppercase") +@_cdecl("bjs_Utils_StringUtils_static_uppercase") +public func _bjs_Utils_StringUtils_static_uppercase(_ textBytes: Int32, _ textLength: Int32) -> Void { + #if arch(wasm32) + let ret = Utils.StringUtils.uppercase(_: String.bridgeJSLiftParameter(textBytes, textLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Utils_StringUtils_static_lowercase") +@_cdecl("bjs_Utils_StringUtils_static_lowercase") +public func _bjs_Utils_StringUtils_static_lowercase(_ textBytes: Int32, _ textLength: Int32) -> Void { + #if arch(wasm32) + let ret = Utils.StringUtils.lowercase(_: String.bridgeJSLiftParameter(textBytes, textLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Networking.API.Method: _BridgedSwiftCaseEnum { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { + return bridgeJSRawValue + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Networking.API.Method { + return bridgeJSLiftParameter(value) + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Networking.API.Method { + return Networking.API.Method(bridgeJSRawValue: value)! + } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { + return bridgeJSLowerParameter() + } + + private init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .get + case 1: + self = .post + case 2: + self = .put + case 3: + self = .delete + default: + return nil + } + } + + private var bridgeJSRawValue: Int32 { + switch self { + case .get: + return 0 + case .post: + return 1 + case .put: + return 2 + case .delete: + return 3 + } + } +} + +extension Configuration.LogLevel: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension Configuration.Port: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension Internal.SupportedMethod: _BridgedSwiftCaseEnum { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { + return bridgeJSRawValue + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Internal.SupportedMethod { + return bridgeJSLiftParameter(value) + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Internal.SupportedMethod { + return Internal.SupportedMethod(bridgeJSRawValue: value)! + } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { + return bridgeJSLowerParameter() + } + + private init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .get + case 1: + self = .post + default: + return nil + } + } + + private var bridgeJSRawValue: Int32 { + switch self { + case .get: + return 0 + case .post: + return 1 + } + } +} + +extension APIResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> APIResult { + switch caseId { + case 0: + return .success(String.bridgeJSStackPop()) + case 1: + return .failure(Int.bridgeJSStackPop()) + case 2: + return .flag(Bool.bridgeJSStackPop()) + case 3: + return .rate(Float.bridgeJSStackPop()) + case 4: + return .precise(Double.bridgeJSStackPop()) + case 5: + return .info + default: + fatalError("Unknown APIResult case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .success(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .failure(let param0): + param0.bridgeJSStackPush() + return Int32(1) + case .flag(let param0): + param0.bridgeJSStackPush() + return Int32(2) + case .rate(let param0): + param0.bridgeJSStackPush() + return Int32(3) + case .precise(let param0): + param0.bridgeJSStackPush() + return Int32(4) + case .info: + return Int32(5) + } + } +} + +extension ComplexResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> ComplexResult { + switch caseId { + case 0: + return .success(String.bridgeJSStackPop()) + case 1: + return .error(String.bridgeJSStackPop(), Int.bridgeJSStackPop()) + case 2: + return .location(Double.bridgeJSStackPop(), Double.bridgeJSStackPop(), String.bridgeJSStackPop()) + case 3: + return .status(Bool.bridgeJSStackPop(), Int.bridgeJSStackPop(), String.bridgeJSStackPop()) + case 4: + return .coordinates(Double.bridgeJSStackPop(), Double.bridgeJSStackPop(), Double.bridgeJSStackPop()) + case 5: + return .comprehensive(Bool.bridgeJSStackPop(), Bool.bridgeJSStackPop(), Int.bridgeJSStackPop(), Int.bridgeJSStackPop(), Double.bridgeJSStackPop(), Double.bridgeJSStackPop(), String.bridgeJSStackPop(), String.bridgeJSStackPop(), String.bridgeJSStackPop()) + case 6: + return .info + default: + fatalError("Unknown ComplexResult case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .success(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .error(let param0, let param1): + param0.bridgeJSStackPush() + param1.bridgeJSStackPush() + return Int32(1) + case .location(let param0, let param1, let param2): + param0.bridgeJSStackPush() + param1.bridgeJSStackPush() + param2.bridgeJSStackPush() + return Int32(2) + case .status(let param0, let param1, let param2): + param0.bridgeJSStackPush() + param1.bridgeJSStackPush() + param2.bridgeJSStackPush() + return Int32(3) + case .coordinates(let param0, let param1, let param2): + param0.bridgeJSStackPush() + param1.bridgeJSStackPush() + param2.bridgeJSStackPush() + return Int32(4) + case .comprehensive(let param0, let param1, let param2, let param3, let param4, let param5, let param6, let param7, let param8): + param0.bridgeJSStackPush() + param1.bridgeJSStackPush() + param2.bridgeJSStackPush() + param3.bridgeJSStackPush() + param4.bridgeJSStackPush() + param5.bridgeJSStackPush() + param6.bridgeJSStackPush() + param7.bridgeJSStackPush() + param8.bridgeJSStackPush() + return Int32(5) + case .info: + return Int32(6) + } + } +} + +extension Utilities.Result: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> Utilities.Result { + switch caseId { + case 0: + return .success(String.bridgeJSStackPop()) + case 1: + return .failure(String.bridgeJSStackPop(), Int.bridgeJSStackPop()) + case 2: + return .status(Bool.bridgeJSStackPop(), Int.bridgeJSStackPop(), String.bridgeJSStackPop()) + default: + fatalError("Unknown Utilities.Result case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .success(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .failure(let param0, let param1): + param0.bridgeJSStackPush() + param1.bridgeJSStackPush() + return Int32(1) + case .status(let param0, let param1, let param2): + param0.bridgeJSStackPush() + param1.bridgeJSStackPush() + param2.bridgeJSStackPush() + return Int32(2) + } + } +} + +extension API.NetworkingResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> API.NetworkingResult { + switch caseId { + case 0: + return .success(String.bridgeJSStackPop()) + case 1: + return .failure(String.bridgeJSStackPop(), Int.bridgeJSStackPop()) + default: + fatalError("Unknown API.NetworkingResult case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .success(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .failure(let param0, let param1): + param0.bridgeJSStackPush() + param1.bridgeJSStackPush() + return Int32(1) + } + } +} + +extension AllTypesResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> AllTypesResult { + switch caseId { + case 0: + return .structPayload(Address.bridgeJSStackPop()) + case 1: + return .classPayload(Greeter.bridgeJSStackPop()) + case 2: + return .jsObjectPayload(JSObject.bridgeJSStackPop()) + case 3: + return .nestedEnum(APIResult.bridgeJSStackPop()) + case 4: + return .arrayPayload([Int].bridgeJSStackPop()) + case 5: + return .jsClassPayload(Foo(unsafelyWrapping: JSObject.bridgeJSStackPop())) + case 6: + return .empty + default: + fatalError("Unknown AllTypesResult case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .structPayload(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .classPayload(let param0): + param0.bridgeJSStackPush() + return Int32(1) + case .jsObjectPayload(let param0): + param0.bridgeJSStackPush() + return Int32(2) + case .nestedEnum(let param0): + param0.bridgeJSStackPush() + return Int32(3) + case .arrayPayload(let param0): + param0.bridgeJSStackPush() + return Int32(4) + case .jsClassPayload(let param0): + param0.jsObject.bridgeJSStackPush() + return Int32(5) + case .empty: + return Int32(6) + } + } +} + +extension TypedPayloadResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> TypedPayloadResult { + switch caseId { + case 0: + return .precision(Precision.bridgeJSStackPop()) + case 1: + return .direction(Direction.bridgeJSStackPop()) + case 2: + return .optPrecision(Optional.bridgeJSStackPop()) + case 3: + return .optDirection(Optional.bridgeJSStackPop()) + case 4: + return .empty + default: + fatalError("Unknown TypedPayloadResult case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .precision(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .direction(let param0): + param0.bridgeJSStackPush() + return Int32(1) + case .optPrecision(let param0): + param0.bridgeJSStackPush() + return Int32(2) + case .optDirection(let param0): + param0.bridgeJSStackPush() + return Int32(3) + case .empty: + return Int32(4) + } + } +} + +extension StaticCalculator: _BridgedSwiftCaseEnum { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { + return bridgeJSRawValue + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> StaticCalculator { + return bridgeJSLiftParameter(value) + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> StaticCalculator { + return StaticCalculator(bridgeJSRawValue: value)! + } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { + return bridgeJSLowerParameter() + } + + private init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .scientific + case 1: + self = .basic + default: + return nil + } + } + + private var bridgeJSRawValue: Int32 { + switch self { + case .scientific: + return 0 + case .basic: + return 1 + } + } +} + +@_expose(wasm, "bjs_StaticCalculator_static_roundtrip") +@_cdecl("bjs_StaticCalculator_static_roundtrip") +public func _bjs_StaticCalculator_static_roundtrip(_ value: Int32) -> Int32 { + #if arch(wasm32) + let ret = StaticCalculator.roundtrip(_: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticCalculator_static_doubleValue") +@_cdecl("bjs_StaticCalculator_static_doubleValue") +public func _bjs_StaticCalculator_static_doubleValue(_ value: Int32) -> Int32 { + #if arch(wasm32) + let ret = StaticCalculator.doubleValue(_: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticCalculator_static_version_get") +@_cdecl("bjs_StaticCalculator_static_version_get") +public func _bjs_StaticCalculator_static_version_get() -> Void { + #if arch(wasm32) + let ret = StaticCalculator.version + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticUtils_Nested_static_roundtrip") +@_cdecl("bjs_StaticUtils_Nested_static_roundtrip") +public func _bjs_StaticUtils_Nested_static_roundtrip(_ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + let ret = StaticUtils.Nested.roundtrip(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Services_Graph_GraphOperations_static_createGraph") +@_cdecl("bjs_Services_Graph_GraphOperations_static_createGraph") +public func _bjs_Services_Graph_GraphOperations_static_createGraph(_ rootId: Int32) -> Int32 { + #if arch(wasm32) + let ret = GraphOperations.createGraph(rootId: Int.bridgeJSLiftParameter(rootId)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Services_Graph_GraphOperations_static_nodeCount") +@_cdecl("bjs_Services_Graph_GraphOperations_static_nodeCount") +public func _bjs_Services_Graph_GraphOperations_static_nodeCount(_ graphId: Int32) -> Int32 { + #if arch(wasm32) + let ret = GraphOperations.nodeCount(graphId: Int.bridgeJSLiftParameter(graphId)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension StaticPropertyEnum: _BridgedSwiftCaseEnum { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { + return bridgeJSRawValue + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> StaticPropertyEnum { + return bridgeJSLiftParameter(value) + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> StaticPropertyEnum { + return StaticPropertyEnum(bridgeJSRawValue: value)! + } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { + return bridgeJSLowerParameter() + } + + private init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .option1 + case 1: + self = .option2 + default: + return nil + } + } + + private var bridgeJSRawValue: Int32 { + switch self { + case .option1: + return 0 + case .option2: + return 1 + } + } +} + +@_expose(wasm, "bjs_StaticPropertyEnum_static_enumProperty_get") +@_cdecl("bjs_StaticPropertyEnum_static_enumProperty_get") +public func _bjs_StaticPropertyEnum_static_enumProperty_get() -> Void { + #if arch(wasm32) + let ret = StaticPropertyEnum.enumProperty + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyEnum_static_enumProperty_set") +@_cdecl("bjs_StaticPropertyEnum_static_enumProperty_set") +public func _bjs_StaticPropertyEnum_static_enumProperty_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + StaticPropertyEnum.enumProperty = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyEnum_static_enumConstant_get") +@_cdecl("bjs_StaticPropertyEnum_static_enumConstant_get") +public func _bjs_StaticPropertyEnum_static_enumConstant_get() -> Int32 { + #if arch(wasm32) + let ret = StaticPropertyEnum.enumConstant + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyEnum_static_enumBool_get") +@_cdecl("bjs_StaticPropertyEnum_static_enumBool_get") +public func _bjs_StaticPropertyEnum_static_enumBool_get() -> Int32 { + #if arch(wasm32) + let ret = StaticPropertyEnum.enumBool + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyEnum_static_enumBool_set") +@_cdecl("bjs_StaticPropertyEnum_static_enumBool_set") +public func _bjs_StaticPropertyEnum_static_enumBool_set(_ value: Int32) -> Void { + #if arch(wasm32) + StaticPropertyEnum.enumBool = Bool.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyEnum_static_enumVariable_get") +@_cdecl("bjs_StaticPropertyEnum_static_enumVariable_get") +public func _bjs_StaticPropertyEnum_static_enumVariable_get() -> Int32 { + #if arch(wasm32) + let ret = StaticPropertyEnum.enumVariable + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyEnum_static_enumVariable_set") +@_cdecl("bjs_StaticPropertyEnum_static_enumVariable_set") +public func _bjs_StaticPropertyEnum_static_enumVariable_set(_ value: Int32) -> Void { + #if arch(wasm32) + StaticPropertyEnum.enumVariable = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyEnum_static_computedReadonly_get") +@_cdecl("bjs_StaticPropertyEnum_static_computedReadonly_get") +public func _bjs_StaticPropertyEnum_static_computedReadonly_get() -> Int32 { + #if arch(wasm32) + let ret = StaticPropertyEnum.computedReadonly + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyEnum_static_computedReadWrite_get") +@_cdecl("bjs_StaticPropertyEnum_static_computedReadWrite_get") +public func _bjs_StaticPropertyEnum_static_computedReadWrite_get() -> Void { + #if arch(wasm32) + let ret = StaticPropertyEnum.computedReadWrite + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyEnum_static_computedReadWrite_set") +@_cdecl("bjs_StaticPropertyEnum_static_computedReadWrite_set") +public func _bjs_StaticPropertyEnum_static_computedReadWrite_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + StaticPropertyEnum.computedReadWrite = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyNamespace_static_namespaceProperty_get") +@_cdecl("bjs_StaticPropertyNamespace_static_namespaceProperty_get") +public func _bjs_StaticPropertyNamespace_static_namespaceProperty_get() -> Void { + #if arch(wasm32) + let ret = StaticPropertyNamespace.namespaceProperty + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyNamespace_static_namespaceProperty_set") +@_cdecl("bjs_StaticPropertyNamespace_static_namespaceProperty_set") +public func _bjs_StaticPropertyNamespace_static_namespaceProperty_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + StaticPropertyNamespace.namespaceProperty = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyNamespace_static_namespaceConstant_get") +@_cdecl("bjs_StaticPropertyNamespace_static_namespaceConstant_get") +public func _bjs_StaticPropertyNamespace_static_namespaceConstant_get() -> Void { + #if arch(wasm32) + let ret = StaticPropertyNamespace.namespaceConstant + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_get") +@_cdecl("bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_get") +public func _bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_get() -> Int32 { + #if arch(wasm32) + let ret = StaticPropertyNamespace.NestedProperties.nestedProperty + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_set") +@_cdecl("bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_set") +public func _bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_set(_ value: Int32) -> Void { + #if arch(wasm32) + StaticPropertyNamespace.NestedProperties.nestedProperty = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyNamespace_NestedProperties_static_nestedConstant_get") +@_cdecl("bjs_StaticPropertyNamespace_NestedProperties_static_nestedConstant_get") +public func _bjs_StaticPropertyNamespace_NestedProperties_static_nestedConstant_get() -> Void { + #if arch(wasm32) + let ret = StaticPropertyNamespace.NestedProperties.nestedConstant + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_get") +@_cdecl("bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_get") +public func _bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_get() -> Float64 { + #if arch(wasm32) + let ret = StaticPropertyNamespace.NestedProperties.nestedDouble + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_set") +@_cdecl("bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_set") +public func _bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_set(_ value: Float64) -> Void { + #if arch(wasm32) + StaticPropertyNamespace.NestedProperties.nestedDouble = Double.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt") +@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt") +public func _bjs_IntegerTypesSupportExports_static_roundTripInt(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = IntegerTypesSupportExports.roundTripInt(_: Int.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripUInt") +@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripUInt") +public func _bjs_IntegerTypesSupportExports_static_roundTripUInt(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = IntegerTypesSupportExports.roundTripUInt(_: UInt.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt8") +@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt8") +public func _bjs_IntegerTypesSupportExports_static_roundTripInt8(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = IntegerTypesSupportExports.roundTripInt8(_: Int8.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripUInt8") +@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripUInt8") +public func _bjs_IntegerTypesSupportExports_static_roundTripUInt8(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = IntegerTypesSupportExports.roundTripUInt8(_: UInt8.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt16") +@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt16") +public func _bjs_IntegerTypesSupportExports_static_roundTripInt16(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = IntegerTypesSupportExports.roundTripInt16(_: Int16.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripUInt16") +@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripUInt16") +public func _bjs_IntegerTypesSupportExports_static_roundTripUInt16(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = IntegerTypesSupportExports.roundTripUInt16(_: UInt16.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt32") +@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt32") +public func _bjs_IntegerTypesSupportExports_static_roundTripInt32(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = IntegerTypesSupportExports.roundTripInt32(_: Int32.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripUInt32") +@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripUInt32") +public func _bjs_IntegerTypesSupportExports_static_roundTripUInt32(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = IntegerTypesSupportExports.roundTripUInt32(_: UInt32.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt64") +@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt64") +public func _bjs_IntegerTypesSupportExports_static_roundTripInt64(_ v: Int64) -> Int64 { + #if arch(wasm32) + let ret = IntegerTypesSupportExports.roundTripInt64(_: Int64.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripUInt64") +@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripUInt64") +public func _bjs_IntegerTypesSupportExports_static_roundTripUInt64(_ v: Int64) -> Int64 { + #if arch(wasm32) + let ret = IntegerTypesSupportExports.roundTripUInt64(_: UInt64.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalString") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalString") +public func _bjs_OptionalSupportExports_static_roundTripOptionalString(_ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalString(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalInt") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalInt") +public func _bjs_OptionalSupportExports_static_roundTripOptionalInt(_ vIsSome: Int32, _ vValue: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalInt(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalBool") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalBool") +public func _bjs_OptionalSupportExports_static_roundTripOptionalBool(_ vIsSome: Int32, _ vValue: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalBool(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalFloat") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalFloat") +public func _bjs_OptionalSupportExports_static_roundTripOptionalFloat(_ vIsSome: Int32, _ vValue: Float32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalFloat(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalDouble") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalDouble") +public func _bjs_OptionalSupportExports_static_roundTripOptionalDouble(_ vIsSome: Int32, _ vValue: Float64) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalDouble(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalSyntax") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalSyntax") +public func _bjs_OptionalSupportExports_static_roundTripOptionalSyntax(_ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalSyntax(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalCaseEnum") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalCaseEnum") +public func _bjs_OptionalSupportExports_static_roundTripOptionalCaseEnum(_ vIsSome: Int32, _ vValue: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalCaseEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalStringRawValueEnum") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalStringRawValueEnum") +public func _bjs_OptionalSupportExports_static_roundTripOptionalStringRawValueEnum(_ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalStringRawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalIntRawValueEnum") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalIntRawValueEnum") +public func _bjs_OptionalSupportExports_static_roundTripOptionalIntRawValueEnum(_ vIsSome: Int32, _ vValue: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalIntRawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalInt64RawValueEnum") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalInt64RawValueEnum") +public func _bjs_OptionalSupportExports_static_roundTripOptionalInt64RawValueEnum(_ vIsSome: Int32, _ vValue: Int64) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalInt64RawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalUInt64RawValueEnum") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalUInt64RawValueEnum") +public func _bjs_OptionalSupportExports_static_roundTripOptionalUInt64RawValueEnum(_ vIsSome: Int32, _ vValue: Int64) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalUInt64RawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalTSEnum") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalTSEnum") +public func _bjs_OptionalSupportExports_static_roundTripOptionalTSEnum(_ vIsSome: Int32, _ vValue: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalTSEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalTSStringEnum") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalTSStringEnum") +public func _bjs_OptionalSupportExports_static_roundTripOptionalTSStringEnum(_ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalTSStringEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalNamespacedEnum") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalNamespacedEnum") +public func _bjs_OptionalSupportExports_static_roundTripOptionalNamespacedEnum(_ vIsSome: Int32, _ vValue: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalNamespacedEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalSwiftClass") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalSwiftClass") +public func _bjs_OptionalSupportExports_static_roundTripOptionalSwiftClass(_ vIsSome: Int32, _ vValue: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalSwiftClass(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalIntArray") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalIntArray") +public func _bjs_OptionalSupportExports_static_roundTripOptionalIntArray() -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalIntArray(_: Optional<[Int]>.bridgeJSLiftParameter()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalStringArray") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalStringArray") +public func _bjs_OptionalSupportExports_static_roundTripOptionalStringArray() -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalStringArray(_: Optional<[String]>.bridgeJSLiftParameter()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalSwiftClassArray") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalSwiftClassArray") +public func _bjs_OptionalSupportExports_static_roundTripOptionalSwiftClassArray() -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalSwiftClassArray(_: Optional<[Greeter]>.bridgeJSLiftParameter()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalAPIResult") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalAPIResult") +public func _bjs_OptionalSupportExports_static_roundTripOptionalAPIResult(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalAPIResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalTypedPayloadResult") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalTypedPayloadResult") +public func _bjs_OptionalSupportExports_static_roundTripOptionalTypedPayloadResult(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalTypedPayloadResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalComplexResult") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalComplexResult") +public func _bjs_OptionalSupportExports_static_roundTripOptionalComplexResult(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalComplexResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalAllTypesResult") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalAllTypesResult") +public func _bjs_OptionalSupportExports_static_roundTripOptionalAllTypesResult(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalAllTypesResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalPayloadResult") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalPayloadResult") +public func _bjs_OptionalSupportExports_static_roundTripOptionalPayloadResult(_ v: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalPayloadResult(_: OptionalAllTypesResult.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalPayloadResultOpt") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalPayloadResultOpt") +public func _bjs_OptionalSupportExports_static_roundTripOptionalPayloadResultOpt(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalPayloadResultOpt(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalAPIOptionalResult") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalAPIOptionalResult") +public func _bjs_OptionalSupportExports_static_roundTripOptionalAPIOptionalResult(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.roundTripOptionalAPIOptionalResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_takeOptionalJSObject") +@_cdecl("bjs_OptionalSupportExports_static_takeOptionalJSObject") +public func _bjs_OptionalSupportExports_static_takeOptionalJSObject(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { + #if arch(wasm32) + OptionalSupportExports.takeOptionalJSObject(_: Optional.bridgeJSLiftParameter(valueIsSome, valueValue)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_applyOptionalGreeter") +@_cdecl("bjs_OptionalSupportExports_static_applyOptionalGreeter") +public func _bjs_OptionalSupportExports_static_applyOptionalGreeter(_ valueIsSome: Int32, _ valueValue: UnsafeMutableRawPointer, _ transform: Int32) -> Void { + #if arch(wasm32) + let ret = OptionalSupportExports.applyOptionalGreeter(_: Optional.bridgeJSLiftParameter(valueIsSome, valueValue), _: _BJS_Closure_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC.bridgeJSLift(transform)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_makeOptionalHolder") +@_cdecl("bjs_OptionalSupportExports_static_makeOptionalHolder") +public func _bjs_OptionalSupportExports_static_makeOptionalHolder(_ nullableGreeterIsSome: Int32, _ nullableGreeterValue: UnsafeMutableRawPointer, _ undefinedNumberIsSome: Int32, _ undefinedNumberValue: Float64) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = OptionalSupportExports.makeOptionalHolder(nullableGreeter: Optional.bridgeJSLiftParameter(nullableGreeterIsSome, nullableGreeterValue), undefinedNumber: JSUndefinedOr.bridgeJSLiftParameter(undefinedNumberIsSome, undefinedNumberValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalSupportExports_static_compareAPIResults") +@_cdecl("bjs_OptionalSupportExports_static_compareAPIResults") +public func _bjs_OptionalSupportExports_static_compareAPIResults(_ r1IsSome: Int32, _ r1CaseId: Int32, _ r2IsSome: Int32, _ r2CaseId: Int32) -> Void { + #if arch(wasm32) + let _tmp_r2 = Optional.bridgeJSLiftParameter(r2IsSome, r2CaseId) + let _tmp_r1 = Optional.bridgeJSLiftParameter(r1IsSome, r1CaseId) + let ret = OptionalSupportExports.compareAPIResults(_: _tmp_r1, _: _tmp_r2) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> OptionalAllTypesResult { + switch caseId { + case 0: + return .optStruct(Optional
.bridgeJSStackPop()) + case 1: + return .optClass(Optional.bridgeJSStackPop()) + case 2: + return .optJSObject(Optional.bridgeJSStackPop()) + case 3: + return .optNestedEnum(Optional.bridgeJSStackPop()) + case 4: + return .optArray(Optional<[Int]>.bridgeJSStackPop()) + case 5: + return .optJsClass(Optional.bridgeJSStackPop().map { Foo(unsafelyWrapping: $0) }) + case 6: + return .empty + default: + fatalError("Unknown OptionalAllTypesResult case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .optStruct(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .optClass(let param0): + param0.bridgeJSStackPush() + return Int32(1) + case .optJSObject(let param0): + param0.bridgeJSStackPush() + return Int32(2) + case .optNestedEnum(let param0): + param0.bridgeJSStackPush() + return Int32(3) + case .optArray(let param0): + param0.bridgeJSStackPush() + return Int32(4) + case .optJsClass(let param0): + param0.bridgeJSStackPush() + return Int32(5) + case .empty: + return Int32(6) + } + } +} + +extension APIOptionalResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> APIOptionalResult { + switch caseId { + case 0: + return .success(Optional.bridgeJSStackPop()) + case 1: + return .failure(Optional.bridgeJSStackPop(), Optional.bridgeJSStackPop()) + case 2: + return .status(Optional.bridgeJSStackPop(), Optional.bridgeJSStackPop(), Optional.bridgeJSStackPop()) + default: + fatalError("Unknown APIOptionalResult case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .success(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .failure(let param0, let param1): + param0.bridgeJSStackPush() + param1.bridgeJSStackPush() + return Int32(1) + case .status(let param0, let param1, let param2): + param0.bridgeJSStackPush() + param1.bridgeJSStackPush() + param2.bridgeJSStackPush() + return Int32(2) + } + } +} + +extension Point: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Point { + let y = Int.bridgeJSStackPop() + let x = Int.bridgeJSStackPop() + return Point(x: x, y: y) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.x.bridgeJSStackPush() + self.y.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Point())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Point") +fileprivate func _bjs_struct_lower_Point_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Point_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Point_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Point") +fileprivate func _bjs_struct_lift_Point_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Point_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Point() -> Int32 { + return _bjs_struct_lift_Point_extern() +} + +extension PointerFields: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> PointerFields { + let mutPtr = UnsafeMutablePointer.bridgeJSStackPop() + let ptr = UnsafePointer.bridgeJSStackPop() + let opaque = OpaquePointer.bridgeJSStackPop() + let mutRaw = UnsafeMutableRawPointer.bridgeJSStackPop() + let raw = UnsafeRawPointer.bridgeJSStackPop() + return PointerFields(raw: raw, mutRaw: mutRaw, opaque: opaque, ptr: ptr, mutPtr: mutPtr) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.raw.bridgeJSStackPush() + self.mutRaw.bridgeJSStackPush() + self.opaque.bridgeJSStackPush() + self.ptr.bridgeJSStackPush() + self.mutPtr.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_PointerFields(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_PointerFields())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_PointerFields") +fileprivate func _bjs_struct_lower_PointerFields_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_PointerFields_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_PointerFields(_ objectId: Int32) -> Void { + return _bjs_struct_lower_PointerFields_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_PointerFields") +fileprivate func _bjs_struct_lift_PointerFields_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_PointerFields_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_PointerFields() -> Int32 { + return _bjs_struct_lift_PointerFields_extern() +} + +@_expose(wasm, "bjs_PointerFields_init") +@_cdecl("bjs_PointerFields_init") +public func _bjs_PointerFields_init(_ raw: UnsafeMutableRawPointer, _ mutRaw: UnsafeMutableRawPointer, _ opaque: UnsafeMutableRawPointer, _ ptr: UnsafeMutableRawPointer, _ mutPtr: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = PointerFields(raw: UnsafeRawPointer.bridgeJSLiftParameter(raw), mutRaw: UnsafeMutableRawPointer.bridgeJSLiftParameter(mutRaw), opaque: OpaquePointer.bridgeJSLiftParameter(opaque), ptr: UnsafePointer.bridgeJSLiftParameter(ptr), mutPtr: UnsafeMutablePointer.bridgeJSLiftParameter(mutPtr)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension DataPoint: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> DataPoint { + let optFlag = Optional.bridgeJSStackPop() + let optCount = Optional.bridgeJSStackPop() + let label = String.bridgeJSStackPop() + let y = Double.bridgeJSStackPop() + let x = Double.bridgeJSStackPop() + return DataPoint(x: x, y: y, label: label, optCount: optCount, optFlag: optFlag) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.x.bridgeJSStackPush() + self.y.bridgeJSStackPush() + self.label.bridgeJSStackPush() + self.optCount.bridgeJSStackPush() + self.optFlag.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_DataPoint(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_DataPoint())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_DataPoint") +fileprivate func _bjs_struct_lower_DataPoint_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_DataPoint_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_DataPoint(_ objectId: Int32) -> Void { + return _bjs_struct_lower_DataPoint_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_DataPoint") +fileprivate func _bjs_struct_lift_DataPoint_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_DataPoint_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_DataPoint() -> Int32 { + return _bjs_struct_lift_DataPoint_extern() +} + +@_expose(wasm, "bjs_DataPoint_init") +@_cdecl("bjs_DataPoint_init") +public func _bjs_DataPoint_init(_ x: Float64, _ y: Float64, _ labelBytes: Int32, _ labelLength: Int32, _ optCountIsSome: Int32, _ optCountValue: Int32, _ optFlagIsSome: Int32, _ optFlagValue: Int32) -> Void { + #if arch(wasm32) + let ret = DataPoint(x: Double.bridgeJSLiftParameter(x), y: Double.bridgeJSLiftParameter(y), label: String.bridgeJSLiftParameter(labelBytes, labelLength), optCount: Optional.bridgeJSLiftParameter(optCountIsSome, optCountValue), optFlag: Optional.bridgeJSLiftParameter(optFlagIsSome, optFlagValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataPoint_static_dimensions_get") +@_cdecl("bjs_DataPoint_static_dimensions_get") +public func _bjs_DataPoint_static_dimensions_get() -> Int32 { + #if arch(wasm32) + let ret = DataPoint.dimensions + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataPoint_static_origin") +@_cdecl("bjs_DataPoint_static_origin") +public func _bjs_DataPoint_static_origin() -> Void { + #if arch(wasm32) + let ret = DataPoint.origin() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension PublicPoint: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> PublicPoint { + let y = Int.bridgeJSStackPop() + let x = Int.bridgeJSStackPop() + return PublicPoint(x: x, y: y) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.x.bridgeJSStackPush() + self.y.bridgeJSStackPush() + } + + public init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_PublicPoint(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + public func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_PublicPoint())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_PublicPoint") +fileprivate func _bjs_struct_lower_PublicPoint_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_PublicPoint_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_PublicPoint(_ objectId: Int32) -> Void { + return _bjs_struct_lower_PublicPoint_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_PublicPoint") +fileprivate func _bjs_struct_lift_PublicPoint_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_PublicPoint_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_PublicPoint() -> Int32 { + return _bjs_struct_lift_PublicPoint_extern() +} + +@_expose(wasm, "bjs_PublicPoint_init") +@_cdecl("bjs_PublicPoint_init") +public func _bjs_PublicPoint_init(_ x: Int32, _ y: Int32) -> Void { + #if arch(wasm32) + let ret = PublicPoint(x: Int.bridgeJSLiftParameter(x), y: Int.bridgeJSLiftParameter(y)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Address: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Address { + let zipCode = Optional.bridgeJSStackPop() + let city = String.bridgeJSStackPop() + let street = String.bridgeJSStackPop() + return Address(street: street, city: city, zipCode: zipCode) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.street.bridgeJSStackPush() + self.city.bridgeJSStackPush() + self.zipCode.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Address(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Address())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Address") +fileprivate func _bjs_struct_lower_Address_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Address_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Address(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Address_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Address") +fileprivate func _bjs_struct_lift_Address_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Address_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Address() -> Int32 { + return _bjs_struct_lift_Address_extern() +} + +extension Contact: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Contact { + let secondaryAddress = Optional
.bridgeJSStackPop() + let email = Optional.bridgeJSStackPop() + let address = Address.bridgeJSStackPop() + let age = Int.bridgeJSStackPop() + let name = String.bridgeJSStackPop() + return Contact(name: name, age: age, address: address, email: email, secondaryAddress: secondaryAddress) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.name.bridgeJSStackPush() + self.age.bridgeJSStackPush() + self.address.bridgeJSStackPush() + self.email.bridgeJSStackPush() + self.secondaryAddress.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Contact(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Contact())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Contact") +fileprivate func _bjs_struct_lower_Contact_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Contact_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Contact(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Contact_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Contact") +fileprivate func _bjs_struct_lift_Contact_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Contact_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Contact() -> Int32 { + return _bjs_struct_lift_Contact_extern() +} + +extension Config: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Config { + let status = Status.bridgeJSStackPop() + let direction = Optional.bridgeJSStackPop() + let theme = Optional.bridgeJSStackPop() + let name = String.bridgeJSStackPop() + return Config(name: name, theme: theme, direction: direction, status: status) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.name.bridgeJSStackPush() + self.theme.bridgeJSStackPush() + self.direction.bridgeJSStackPush() + self.status.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Config(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Config())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Config") +fileprivate func _bjs_struct_lower_Config_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Config_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Config(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Config_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Config") +fileprivate func _bjs_struct_lift_Config_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Config_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Config() -> Int32 { + return _bjs_struct_lift_Config_extern() +} + +extension SessionData: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> SessionData { + let owner = Optional.bridgeJSStackPop() + let id = Int.bridgeJSStackPop() + return SessionData(id: id, owner: owner) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.id.bridgeJSStackPush() + self.owner.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_SessionData(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_SessionData())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_SessionData") +fileprivate func _bjs_struct_lower_SessionData_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_SessionData_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_SessionData(_ objectId: Int32) -> Void { + return _bjs_struct_lower_SessionData_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_SessionData") +fileprivate func _bjs_struct_lift_SessionData_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_SessionData_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_SessionData() -> Int32 { + return _bjs_struct_lift_SessionData_extern() +} + +extension ValidationReport: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> ValidationReport { + let outcome = Optional.bridgeJSStackPop() + let status = Optional.bridgeJSStackPop() + let result = APIResult.bridgeJSStackPop() + let id = Int.bridgeJSStackPop() + return ValidationReport(id: id, result: result, status: status, outcome: outcome) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.id.bridgeJSStackPush() + self.result.bridgeJSStackPush() + self.status.bridgeJSStackPush() + self.outcome.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_ValidationReport(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_ValidationReport())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_ValidationReport") +fileprivate func _bjs_struct_lower_ValidationReport_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_ValidationReport_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_ValidationReport(_ objectId: Int32) -> Void { + return _bjs_struct_lower_ValidationReport_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_ValidationReport") +fileprivate func _bjs_struct_lift_ValidationReport_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_ValidationReport_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_ValidationReport() -> Int32 { + return _bjs_struct_lift_ValidationReport_extern() +} + +extension AdvancedConfig: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> AdvancedConfig { + let overrideDefaults = Optional.bridgeJSStackPop() + let defaults = ConfigStruct.bridgeJSStackPop() + let location = Optional.bridgeJSStackPop() + let metadata = Optional.bridgeJSStackPop() + let result = Optional.bridgeJSStackPop() + let status = Status.bridgeJSStackPop() + let theme = Theme.bridgeJSStackPop() + let enabled = Bool.bridgeJSStackPop() + let title = String.bridgeJSStackPop() + let id = Int.bridgeJSStackPop() + return AdvancedConfig(id: id, title: title, enabled: enabled, theme: theme, status: status, result: result, metadata: metadata, location: location, defaults: defaults, overrideDefaults: overrideDefaults) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.id.bridgeJSStackPush() + self.title.bridgeJSStackPush() + self.enabled.bridgeJSStackPush() + self.theme.bridgeJSStackPush() + self.status.bridgeJSStackPush() + self.result.bridgeJSStackPush() + self.metadata.bridgeJSStackPush() + self.location.bridgeJSStackPush() + self.defaults.bridgeJSStackPush() + self.overrideDefaults.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_AdvancedConfig(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_AdvancedConfig())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_AdvancedConfig") +fileprivate func _bjs_struct_lower_AdvancedConfig_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_AdvancedConfig_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_AdvancedConfig(_ objectId: Int32) -> Void { + return _bjs_struct_lower_AdvancedConfig_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_AdvancedConfig") +fileprivate func _bjs_struct_lift_AdvancedConfig_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_AdvancedConfig_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_AdvancedConfig() -> Int32 { + return _bjs_struct_lift_AdvancedConfig_extern() +} + +extension MeasurementConfig: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> MeasurementConfig { + let optionalRatio = Optional.bridgeJSStackPop() + let optionalPrecision = Optional.bridgeJSStackPop() + let ratio = Ratio.bridgeJSStackPop() + let precision = Precision.bridgeJSStackPop() + return MeasurementConfig(precision: precision, ratio: ratio, optionalPrecision: optionalPrecision, optionalRatio: optionalRatio) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.precision.bridgeJSStackPush() + self.ratio.bridgeJSStackPush() + self.optionalPrecision.bridgeJSStackPush() + self.optionalRatio.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_MeasurementConfig(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_MeasurementConfig())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_MeasurementConfig") +fileprivate func _bjs_struct_lower_MeasurementConfig_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_MeasurementConfig_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_MeasurementConfig(_ objectId: Int32) -> Void { + return _bjs_struct_lower_MeasurementConfig_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_MeasurementConfig") +fileprivate func _bjs_struct_lift_MeasurementConfig_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_MeasurementConfig_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_MeasurementConfig() -> Int32 { + return _bjs_struct_lift_MeasurementConfig_extern() +} + +extension MathOperations: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> MathOperations { + let baseValue = Double.bridgeJSStackPop() + return MathOperations(baseValue: baseValue) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.baseValue.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_MathOperations(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_MathOperations())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_MathOperations") +fileprivate func _bjs_struct_lower_MathOperations_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_MathOperations_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_MathOperations(_ objectId: Int32) -> Void { + return _bjs_struct_lower_MathOperations_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_MathOperations") +fileprivate func _bjs_struct_lift_MathOperations_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_MathOperations_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_MathOperations() -> Int32 { + return _bjs_struct_lift_MathOperations_extern() +} + +@_expose(wasm, "bjs_MathOperations_init") +@_cdecl("bjs_MathOperations_init") +public func _bjs_MathOperations_init(_ baseValue: Float64) -> Void { + #if arch(wasm32) + let ret = MathOperations(baseValue: Double.bridgeJSLiftParameter(baseValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_MathOperations_add") +@_cdecl("bjs_MathOperations_add") +public func _bjs_MathOperations_add(_ a: Float64, _ b: Float64) -> Float64 { + #if arch(wasm32) + let ret = MathOperations.bridgeJSLiftParameter().add(a: Double.bridgeJSLiftParameter(a), b: Double.bridgeJSLiftParameter(b)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_MathOperations_multiply") +@_cdecl("bjs_MathOperations_multiply") +public func _bjs_MathOperations_multiply(_ a: Float64, _ b: Float64) -> Float64 { + #if arch(wasm32) + let ret = MathOperations.bridgeJSLiftParameter().multiply(a: Double.bridgeJSLiftParameter(a), b: Double.bridgeJSLiftParameter(b)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_MathOperations_static_subtract") +@_cdecl("bjs_MathOperations_static_subtract") +public func _bjs_MathOperations_static_subtract(_ a: Float64, _ b: Float64) -> Float64 { + #if arch(wasm32) + let ret = MathOperations.subtract(a: Double.bridgeJSLiftParameter(a), b: Double.bridgeJSLiftParameter(b)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension CopyableCart: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> CopyableCart { + let note = Optional.bridgeJSStackPop() + let x = Int.bridgeJSStackPop() + return CopyableCart(x: x, note: note) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.x.bridgeJSStackPush() + self.note.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_CopyableCart(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_CopyableCart())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_CopyableCart") +fileprivate func _bjs_struct_lower_CopyableCart_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_CopyableCart_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_CopyableCart(_ objectId: Int32) -> Void { + return _bjs_struct_lower_CopyableCart_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_CopyableCart") +fileprivate func _bjs_struct_lift_CopyableCart_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_CopyableCart_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_CopyableCart() -> Int32 { + return _bjs_struct_lift_CopyableCart_extern() +} + +@_expose(wasm, "bjs_CopyableCart_static_fromJSObject") +@_cdecl("bjs_CopyableCart_static_fromJSObject") +public func _bjs_CopyableCart_static_fromJSObject(_ object: Int32) -> Void { + #if arch(wasm32) + let ret = CopyableCart.fromJSObject(_: JSObject.bridgeJSLiftParameter(object)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension CopyableCartItem: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> CopyableCartItem { + let quantity = Int.bridgeJSStackPop() + let sku = String.bridgeJSStackPop() + return CopyableCartItem(sku: sku, quantity: quantity) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.sku.bridgeJSStackPush() + self.quantity.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_CopyableCartItem(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_CopyableCartItem())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_CopyableCartItem") +fileprivate func _bjs_struct_lower_CopyableCartItem_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_CopyableCartItem_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_CopyableCartItem(_ objectId: Int32) -> Void { + return _bjs_struct_lower_CopyableCartItem_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_CopyableCartItem") +fileprivate func _bjs_struct_lift_CopyableCartItem_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_CopyableCartItem_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_CopyableCartItem() -> Int32 { + return _bjs_struct_lift_CopyableCartItem_extern() +} + +extension CopyableNestedCart: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> CopyableNestedCart { + let shippingAddress = Optional
.bridgeJSStackPop() + let item = CopyableCartItem.bridgeJSStackPop() + let id = Int.bridgeJSStackPop() + return CopyableNestedCart(id: id, item: item, shippingAddress: shippingAddress) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.id.bridgeJSStackPush() + self.item.bridgeJSStackPush() + self.shippingAddress.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_CopyableNestedCart(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_CopyableNestedCart())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_CopyableNestedCart") +fileprivate func _bjs_struct_lower_CopyableNestedCart_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_CopyableNestedCart_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_CopyableNestedCart(_ objectId: Int32) -> Void { + return _bjs_struct_lower_CopyableNestedCart_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_CopyableNestedCart") +fileprivate func _bjs_struct_lift_CopyableNestedCart_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_CopyableNestedCart_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_CopyableNestedCart() -> Int32 { + return _bjs_struct_lift_CopyableNestedCart_extern() +} + +@_expose(wasm, "bjs_CopyableNestedCart_static_fromJSObject") +@_cdecl("bjs_CopyableNestedCart_static_fromJSObject") +public func _bjs_CopyableNestedCart_static_fromJSObject(_ object: Int32) -> Void { + #if arch(wasm32) + let ret = CopyableNestedCart.fromJSObject(_: JSObject.bridgeJSLiftParameter(object)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ConfigStruct: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> ConfigStruct { + let value = Int.bridgeJSStackPop() + let name = String.bridgeJSStackPop() + return ConfigStruct(name: name, value: value) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.name.bridgeJSStackPush() + self.value.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_ConfigStruct(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_ConfigStruct())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_ConfigStruct") +fileprivate func _bjs_struct_lower_ConfigStruct_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_ConfigStruct_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_ConfigStruct(_ objectId: Int32) -> Void { + return _bjs_struct_lower_ConfigStruct_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_ConfigStruct") +fileprivate func _bjs_struct_lift_ConfigStruct_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_ConfigStruct_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_ConfigStruct() -> Int32 { + return _bjs_struct_lift_ConfigStruct_extern() +} + +@_expose(wasm, "bjs_ConfigStruct_static_defaultConfig_get") +@_cdecl("bjs_ConfigStruct_static_defaultConfig_get") +public func _bjs_ConfigStruct_static_defaultConfig_get() -> Void { + #if arch(wasm32) + let ret = ConfigStruct.defaultConfig + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigStruct_static_defaultConfig_set") +@_cdecl("bjs_ConfigStruct_static_defaultConfig_set") +public func _bjs_ConfigStruct_static_defaultConfig_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + ConfigStruct.defaultConfig = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigStruct_static_maxRetries_get") +@_cdecl("bjs_ConfigStruct_static_maxRetries_get") +public func _bjs_ConfigStruct_static_maxRetries_get() -> Int32 { + #if arch(wasm32) + let ret = ConfigStruct.maxRetries + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigStruct_static_timeout_get") +@_cdecl("bjs_ConfigStruct_static_timeout_get") +public func _bjs_ConfigStruct_static_timeout_get() -> Float64 { + #if arch(wasm32) + let ret = ConfigStruct.timeout + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigStruct_static_timeout_set") +@_cdecl("bjs_ConfigStruct_static_timeout_set") +public func _bjs_ConfigStruct_static_timeout_set(_ value: Float64) -> Void { + #if arch(wasm32) + ConfigStruct.timeout = Double.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigStruct_static_computedSetting_get") +@_cdecl("bjs_ConfigStruct_static_computedSetting_get") +public func _bjs_ConfigStruct_static_computedSetting_get() -> Void { + #if arch(wasm32) + let ret = ConfigStruct.computedSetting + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Vector2D: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Vector2D { + let dy = Double.bridgeJSStackPop() + let dx = Double.bridgeJSStackPop() + return Vector2D(dx: dx, dy: dy) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.dx.bridgeJSStackPush() + self.dy.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Vector2D(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Vector2D())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Vector2D") +fileprivate func _bjs_struct_lower_Vector2D_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Vector2D_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Vector2D(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Vector2D_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Vector2D") +fileprivate func _bjs_struct_lift_Vector2D_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Vector2D_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Vector2D() -> Int32 { + return _bjs_struct_lift_Vector2D_extern() +} + +@_expose(wasm, "bjs_Vector2D_init") +@_cdecl("bjs_Vector2D_init") +public func _bjs_Vector2D_init(_ dx: Float64, _ dy: Float64) -> Void { + #if arch(wasm32) + let ret = Vector2D(dx: Double.bridgeJSLiftParameter(dx), dy: Double.bridgeJSLiftParameter(dy)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Vector2D_magnitude") +@_cdecl("bjs_Vector2D_magnitude") +public func _bjs_Vector2D_magnitude() -> Float64 { + #if arch(wasm32) + let ret = Vector2D.bridgeJSLiftParameter().magnitude() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Vector2D_scaled") +@_cdecl("bjs_Vector2D_scaled") +public func _bjs_Vector2D_scaled(_ factor: Float64) -> Void { + #if arch(wasm32) + let ret = Vector2D.bridgeJSLiftParameter().scaled(by: Double.bridgeJSLiftParameter(factor)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension JSObjectContainer: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> JSObjectContainer { + let optionalObject = Optional.bridgeJSStackPop() + let object = JSObject.bridgeJSStackPop() + return JSObjectContainer(object: object, optionalObject: optionalObject) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.object.bridgeJSStackPush() + self.optionalObject.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_JSObjectContainer(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_JSObjectContainer())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_JSObjectContainer") +fileprivate func _bjs_struct_lower_JSObjectContainer_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_JSObjectContainer_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_JSObjectContainer(_ objectId: Int32) -> Void { + return _bjs_struct_lower_JSObjectContainer_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_JSObjectContainer") +fileprivate func _bjs_struct_lift_JSObjectContainer_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_JSObjectContainer_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_JSObjectContainer() -> Int32 { + return _bjs_struct_lift_JSObjectContainer_extern() +} + +extension FooContainer: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> FooContainer { + let optionalFoo = Optional.bridgeJSStackPop().map { Foo(unsafelyWrapping: $0) } + let foo = Foo(unsafelyWrapping: JSObject.bridgeJSStackPop()) + return FooContainer(foo: foo, optionalFoo: optionalFoo) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.foo.jsObject.bridgeJSStackPush() + self.optionalFoo.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_FooContainer(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_FooContainer())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_FooContainer") +fileprivate func _bjs_struct_lower_FooContainer_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_FooContainer_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_FooContainer(_ objectId: Int32) -> Void { + return _bjs_struct_lower_FooContainer_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_FooContainer") +fileprivate func _bjs_struct_lift_FooContainer_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_FooContainer_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_FooContainer() -> Int32 { + return _bjs_struct_lift_FooContainer_extern() +} + +extension ArrayMembers: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> ArrayMembers { + let optStrings = Optional<[String]>.bridgeJSStackPop() + let ints = [Int].bridgeJSStackPop() + return ArrayMembers(ints: ints, optStrings: optStrings) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.ints.bridgeJSStackPush() + self.optStrings.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_ArrayMembers(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_ArrayMembers())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_ArrayMembers") +fileprivate func _bjs_struct_lower_ArrayMembers_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_ArrayMembers_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_ArrayMembers(_ objectId: Int32) -> Void { + return _bjs_struct_lower_ArrayMembers_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_ArrayMembers") +fileprivate func _bjs_struct_lift_ArrayMembers_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_ArrayMembers_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_ArrayMembers() -> Int32 { + return _bjs_struct_lift_ArrayMembers_extern() +} + +@_expose(wasm, "bjs_ArrayMembers_sumValues") +@_cdecl("bjs_ArrayMembers_sumValues") +public func _bjs_ArrayMembers_sumValues() -> Int32 { + #if arch(wasm32) + let ret = ArrayMembers.bridgeJSLiftParameter().sumValues(_: [Int].bridgeJSStackPop()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArrayMembers_firstString") +@_cdecl("bjs_ArrayMembers_firstString") +public func _bjs_ArrayMembers_firstString() -> Void { + #if arch(wasm32) + let ret = ArrayMembers.bridgeJSLiftParameter().firstString(_: [String].bridgeJSStackPop()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripVoid") +@_cdecl("bjs_roundTripVoid") +public func _bjs_roundTripVoid() -> Void { + #if arch(wasm32) + roundTripVoid() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripFloat") +@_cdecl("bjs_roundTripFloat") +public func _bjs_roundTripFloat(_ v: Float32) -> Float32 { + #if arch(wasm32) + let ret = roundTripFloat(v: Float.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripDouble") +@_cdecl("bjs_roundTripDouble") +public func _bjs_roundTripDouble(_ v: Float64) -> Float64 { + #if arch(wasm32) + let ret = roundTripDouble(v: Double.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripBool") +@_cdecl("bjs_roundTripBool") +public func _bjs_roundTripBool(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = roundTripBool(v: Bool.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripString") +@_cdecl("bjs_roundTripString") +public func _bjs_roundTripString(_ vBytes: Int32, _ vLength: Int32) -> Void { + #if arch(wasm32) + let ret = roundTripString(v: String.bridgeJSLiftParameter(vBytes, vLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripSwiftHeapObject") +@_cdecl("bjs_roundTripSwiftHeapObject") +public func _bjs_roundTripSwiftHeapObject(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundTripSwiftHeapObject(v: Greeter.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripUnsafeRawPointer") +@_cdecl("bjs_roundTripUnsafeRawPointer") +public func _bjs_roundTripUnsafeRawPointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundTripUnsafeRawPointer(v: UnsafeRawPointer.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripUnsafeMutableRawPointer") +@_cdecl("bjs_roundTripUnsafeMutableRawPointer") +public func _bjs_roundTripUnsafeMutableRawPointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundTripUnsafeMutableRawPointer(v: UnsafeMutableRawPointer.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripOpaquePointer") +@_cdecl("bjs_roundTripOpaquePointer") +public func _bjs_roundTripOpaquePointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundTripOpaquePointer(v: OpaquePointer.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripUnsafePointer") +@_cdecl("bjs_roundTripUnsafePointer") +public func _bjs_roundTripUnsafePointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundTripUnsafePointer(v: UnsafePointer.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripUnsafeMutablePointer") +@_cdecl("bjs_roundTripUnsafeMutablePointer") +public func _bjs_roundTripUnsafeMutablePointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundTripUnsafeMutablePointer(v: UnsafeMutablePointer.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripJSObject") +@_cdecl("bjs_roundTripJSObject") +public func _bjs_roundTripJSObject(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = roundTripJSObject(v: JSObject.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripDictionaryExport") +@_cdecl("bjs_roundTripDictionaryExport") +public func _bjs_roundTripDictionaryExport() -> Void { + #if arch(wasm32) + let ret = roundTripDictionaryExport(v: [String: Int].bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripOptionalDictionaryExport") +@_cdecl("bjs_roundTripOptionalDictionaryExport") +public func _bjs_roundTripOptionalDictionaryExport() -> Void { + #if arch(wasm32) + let ret = roundTripOptionalDictionaryExport(v: Optional<[String: String]>.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripJSValue") +@_cdecl("bjs_roundTripJSValue") +public func _bjs_roundTripJSValue(_ vKind: Int32, _ vPayload1: Int32, _ vPayload2: Float64) -> Void { + #if arch(wasm32) + let ret = roundTripJSValue(v: JSValue.bridgeJSLiftParameter(vKind, vPayload1, vPayload2)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripOptionalJSValue") +@_cdecl("bjs_roundTripOptionalJSValue") +public func _bjs_roundTripOptionalJSValue(_ vIsSome: Int32, _ vKind: Int32, _ vPayload1: Int32, _ vPayload2: Float64) -> Void { + #if arch(wasm32) + let ret = roundTripOptionalJSValue(v: Optional.bridgeJSLiftParameter(vIsSome, vKind, vPayload1, vPayload2)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripOptionalJSValueArray") +@_cdecl("bjs_roundTripOptionalJSValueArray") +public func _bjs_roundTripOptionalJSValueArray() -> Void { + #if arch(wasm32) + let ret = roundTripOptionalJSValueArray(v: Optional<[JSValue]>.bridgeJSLiftParameter()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeImportedFoo") +@_cdecl("bjs_makeImportedFoo") +public func _bjs_makeImportedFoo(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 { + #if arch(wasm32) + do { + let ret = try makeImportedFoo(value: String.bridgeJSLiftParameter(valueBytes, valueLength)) + return ret.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: String(describing: error)) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_throwsSwiftError") +@_cdecl("bjs_throwsSwiftError") +public func _bjs_throwsSwiftError(_ shouldThrow: Int32) -> Void { + #if arch(wasm32) + do { + try throwsSwiftError(shouldThrow: Bool.bridgeJSLiftParameter(shouldThrow)) + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: String(describing: error)) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_throwsWithIntResult") +@_cdecl("bjs_throwsWithIntResult") +public func _bjs_throwsWithIntResult() -> Int32 { + #if arch(wasm32) + do { + let ret = try throwsWithIntResult() + return ret.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: String(describing: error)) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_throwsWithStringResult") +@_cdecl("bjs_throwsWithStringResult") +public func _bjs_throwsWithStringResult() -> Void { + #if arch(wasm32) + do { + let ret = try throwsWithStringResult() + return ret.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: String(describing: error)) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_throwsWithBoolResult") +@_cdecl("bjs_throwsWithBoolResult") +public func _bjs_throwsWithBoolResult() -> Int32 { + #if arch(wasm32) + do { + let ret = try throwsWithBoolResult() + return ret.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: String(describing: error)) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_throwsWithFloatResult") +@_cdecl("bjs_throwsWithFloatResult") +public func _bjs_throwsWithFloatResult() -> Float32 { + #if arch(wasm32) + do { + let ret = try throwsWithFloatResult() + return ret.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: String(describing: error)) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0.0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_throwsWithDoubleResult") +@_cdecl("bjs_throwsWithDoubleResult") +public func _bjs_throwsWithDoubleResult() -> Float64 { + #if arch(wasm32) + do { + let ret = try throwsWithDoubleResult() + return ret.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: String(describing: error)) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0.0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_throwsWithSwiftHeapObjectResult") +@_cdecl("bjs_throwsWithSwiftHeapObjectResult") +public func _bjs_throwsWithSwiftHeapObjectResult() -> UnsafeMutableRawPointer { + #if arch(wasm32) + do { + let ret = try throwsWithSwiftHeapObjectResult() + return ret.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: String(describing: error)) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return UnsafeMutableRawPointer(bitPattern: -1).unsafelyUnwrapped + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_throwsWithJSObjectResult") +@_cdecl("bjs_throwsWithJSObjectResult") +public func _bjs_throwsWithJSObjectResult() -> Int32 { + #if arch(wasm32) + do { + let ret = try throwsWithJSObjectResult() + return ret.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: String(describing: error)) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripVoid") +@_cdecl("bjs_asyncRoundTripVoid") +public func _bjs_asyncRoundTripVoid() -> Int32 { + #if arch(wasm32) + let ret = JSPromise.async { + await asyncRoundTripVoid() + }.jsObject + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripInt") +@_cdecl("bjs_asyncRoundTripInt") +public func _bjs_asyncRoundTripInt(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = JSPromise.async { + return await asyncRoundTripInt(v: Int.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripFloat") +@_cdecl("bjs_asyncRoundTripFloat") +public func _bjs_asyncRoundTripFloat(_ v: Float32) -> Int32 { + #if arch(wasm32) + let ret = JSPromise.async { + return await asyncRoundTripFloat(v: Float.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripDouble") +@_cdecl("bjs_asyncRoundTripDouble") +public func _bjs_asyncRoundTripDouble(_ v: Float64) -> Int32 { + #if arch(wasm32) + let ret = JSPromise.async { + return await asyncRoundTripDouble(v: Double.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripBool") +@_cdecl("bjs_asyncRoundTripBool") +public func _bjs_asyncRoundTripBool(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = JSPromise.async { + return await asyncRoundTripBool(v: Bool.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripString") +@_cdecl("bjs_asyncRoundTripString") +public func _bjs_asyncRoundTripString(_ vBytes: Int32, _ vLength: Int32) -> Int32 { + #if arch(wasm32) + let ret = JSPromise.async { + return await asyncRoundTripString(v: String.bridgeJSLiftParameter(vBytes, vLength)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripSwiftHeapObject") +@_cdecl("bjs_asyncRoundTripSwiftHeapObject") +public func _bjs_asyncRoundTripSwiftHeapObject(_ v: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = JSPromise.async { + return await asyncRoundTripSwiftHeapObject(v: Greeter.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripJSObject") +@_cdecl("bjs_asyncRoundTripJSObject") +public func _bjs_asyncRoundTripJSObject(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = JSPromise.async { + return await asyncRoundTripJSObject(v: JSObject.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_takeGreeter") +@_cdecl("bjs_takeGreeter") +public func _bjs_takeGreeter(_ g: UnsafeMutableRawPointer, _ nameBytes: Int32, _ nameLength: Int32) -> Void { + #if arch(wasm32) + takeGreeter(g: Greeter.bridgeJSLiftParameter(g), name: String.bridgeJSLiftParameter(nameBytes, nameLength)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_createCalculator") +@_cdecl("bjs_createCalculator") +public func _bjs_createCalculator() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = createCalculator() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_useCalculator") +@_cdecl("bjs_useCalculator") +public func _bjs_useCalculator(_ calc: UnsafeMutableRawPointer, _ x: Int32, _ y: Int32) -> Int32 { + #if arch(wasm32) + let ret = useCalculator(calc: Calculator.bridgeJSLiftParameter(calc), x: Int.bridgeJSLiftParameter(x), y: Int.bridgeJSLiftParameter(y)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_testGreeterToJSValue") +@_cdecl("bjs_testGreeterToJSValue") +public func _bjs_testGreeterToJSValue() -> Int32 { + #if arch(wasm32) + let ret = testGreeterToJSValue() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_testCalculatorToJSValue") +@_cdecl("bjs_testCalculatorToJSValue") +public func _bjs_testCalculatorToJSValue() -> Int32 { + #if arch(wasm32) + let ret = testCalculatorToJSValue() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_testSwiftClassAsJSValue") +@_cdecl("bjs_testSwiftClassAsJSValue") +public func _bjs_testSwiftClassAsJSValue(_ greeter: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = testSwiftClassAsJSValue(greeter: Greeter.bridgeJSLiftParameter(greeter)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_setDirection") +@_cdecl("bjs_setDirection") +public func _bjs_setDirection(_ direction: Int32) -> Int32 { + #if arch(wasm32) + let ret = setDirection(_: Direction.bridgeJSLiftParameter(direction)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getDirection") +@_cdecl("bjs_getDirection") +public func _bjs_getDirection() -> Int32 { + #if arch(wasm32) + let ret = getDirection() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_processDirection") +@_cdecl("bjs_processDirection") +public func _bjs_processDirection(_ input: Int32) -> Int32 { + #if arch(wasm32) + let ret = processDirection(_: Direction.bridgeJSLiftParameter(input)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_setTheme") +@_cdecl("bjs_setTheme") +public func _bjs_setTheme(_ themeBytes: Int32, _ themeLength: Int32) -> Void { + #if arch(wasm32) + let ret = setTheme(_: Theme.bridgeJSLiftParameter(themeBytes, themeLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getTheme") +@_cdecl("bjs_getTheme") +public func _bjs_getTheme() -> Void { + #if arch(wasm32) + let ret = getTheme() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_setHttpStatus") +@_cdecl("bjs_setHttpStatus") +public func _bjs_setHttpStatus(_ status: Int32) -> Int32 { + #if arch(wasm32) + let ret = setHttpStatus(_: HttpStatus.bridgeJSLiftParameter(status)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getHttpStatus") +@_cdecl("bjs_getHttpStatus") +public func _bjs_getHttpStatus() -> Int32 { + #if arch(wasm32) + let ret = getHttpStatus() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_setFileSize") +@_cdecl("bjs_setFileSize") +public func _bjs_setFileSize(_ size: Int64) -> Int64 { + #if arch(wasm32) + let ret = setFileSize(_: FileSize.bridgeJSLiftParameter(size)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getFileSize") +@_cdecl("bjs_getFileSize") +public func _bjs_getFileSize() -> Int64 { + #if arch(wasm32) + let ret = getFileSize() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_setSessionId") +@_cdecl("bjs_setSessionId") +public func _bjs_setSessionId(_ session: Int64) -> Int64 { + #if arch(wasm32) + let ret = setSessionId(_: SessionId.bridgeJSLiftParameter(session)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getSessionId") +@_cdecl("bjs_getSessionId") +public func _bjs_getSessionId() -> Int64 { + #if arch(wasm32) + let ret = getSessionId() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_processTheme") +@_cdecl("bjs_processTheme") +public func _bjs_processTheme(_ themeBytes: Int32, _ themeLength: Int32) -> Int32 { + #if arch(wasm32) + let ret = processTheme(_: Theme.bridgeJSLiftParameter(themeBytes, themeLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_setTSDirection") +@_cdecl("bjs_setTSDirection") +public func _bjs_setTSDirection(_ direction: Int32) -> Int32 { + #if arch(wasm32) + let ret = setTSDirection(_: TSDirection.bridgeJSLiftParameter(direction)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getTSDirection") +@_cdecl("bjs_getTSDirection") +public func _bjs_getTSDirection() -> Int32 { + #if arch(wasm32) + let ret = getTSDirection() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_setTSTheme") +@_cdecl("bjs_setTSTheme") +public func _bjs_setTSTheme(_ themeBytes: Int32, _ themeLength: Int32) -> Void { + #if arch(wasm32) + let ret = setTSTheme(_: TSTheme.bridgeJSLiftParameter(themeBytes, themeLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getTSTheme") +@_cdecl("bjs_getTSTheme") +public func _bjs_getTSTheme() -> Void { + #if arch(wasm32) + let ret = getTSTheme() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_createConverter") +@_cdecl("bjs_createConverter") +public func _bjs_createConverter() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = createConverter() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_useConverter") +@_cdecl("bjs_useConverter") +public func _bjs_useConverter(_ converter: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + let ret = useConverter(converter: Utils.Converter.bridgeJSLiftParameter(converter), value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripConverterArray") +@_cdecl("bjs_roundTripConverterArray") +public func _bjs_roundTripConverterArray() -> Void { + #if arch(wasm32) + let ret = roundTripConverterArray(_: [Utils.Converter].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_createHTTPServer") +@_cdecl("bjs_createHTTPServer") +public func _bjs_createHTTPServer() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = createHTTPServer() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_createUUID") +@_cdecl("bjs_createUUID") +public func _bjs_createUUID(_ valueBytes: Int32, _ valueLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = createUUID(value: String.bridgeJSLiftParameter(valueBytes, valueLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripUUID") +@_cdecl("bjs_roundTripUUID") +public func _bjs_roundTripUUID(_ uuid: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundTripUUID(_: UUID.bridgeJSLiftParameter(uuid)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundtripNetworkingAPIMethod") +@_cdecl("bjs_roundtripNetworkingAPIMethod") +public func _bjs_roundtripNetworkingAPIMethod(_ method: Int32) -> Int32 { + #if arch(wasm32) + let ret = roundtripNetworkingAPIMethod(_: Networking.API.Method.bridgeJSLiftParameter(method)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundtripConfigurationLogLevel") +@_cdecl("bjs_roundtripConfigurationLogLevel") +public func _bjs_roundtripConfigurationLogLevel(_ levelBytes: Int32, _ levelLength: Int32) -> Void { + #if arch(wasm32) + let ret = roundtripConfigurationLogLevel(_: Configuration.LogLevel.bridgeJSLiftParameter(levelBytes, levelLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundtripConfigurationPort") +@_cdecl("bjs_roundtripConfigurationPort") +public func _bjs_roundtripConfigurationPort(_ port: Int32) -> Int32 { + #if arch(wasm32) + let ret = roundtripConfigurationPort(_: Configuration.Port.bridgeJSLiftParameter(port)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_processConfigurationLogLevel") +@_cdecl("bjs_processConfigurationLogLevel") +public func _bjs_processConfigurationLogLevel(_ levelBytes: Int32, _ levelLength: Int32) -> Int32 { + #if arch(wasm32) + let ret = processConfigurationLogLevel(_: Configuration.LogLevel.bridgeJSLiftParameter(levelBytes, levelLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundtripInternalSupportedMethod") +@_cdecl("bjs_roundtripInternalSupportedMethod") +public func _bjs_roundtripInternalSupportedMethod(_ method: Int32) -> Int32 { + #if arch(wasm32) + let ret = roundtripInternalSupportedMethod(_: Internal.SupportedMethod.bridgeJSLiftParameter(method)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundtripAPIResult") +@_cdecl("bjs_roundtripAPIResult") +public func _bjs_roundtripAPIResult(_ result: Int32) -> Void { + #if arch(wasm32) + let ret = roundtripAPIResult(result: APIResult.bridgeJSLiftParameter(result)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAPIResultSuccess") +@_cdecl("bjs_makeAPIResultSuccess") +public func _bjs_makeAPIResultSuccess(_ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + let ret = makeAPIResultSuccess(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAPIResultFailure") +@_cdecl("bjs_makeAPIResultFailure") +public func _bjs_makeAPIResultFailure(_ value: Int32) -> Void { + #if arch(wasm32) + let ret = makeAPIResultFailure(_: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAPIResultInfo") +@_cdecl("bjs_makeAPIResultInfo") +public func _bjs_makeAPIResultInfo() -> Void { + #if arch(wasm32) + let ret = makeAPIResultInfo() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAPIResultFlag") +@_cdecl("bjs_makeAPIResultFlag") +public func _bjs_makeAPIResultFlag(_ value: Int32) -> Void { + #if arch(wasm32) + let ret = makeAPIResultFlag(_: Bool.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAPIResultRate") +@_cdecl("bjs_makeAPIResultRate") +public func _bjs_makeAPIResultRate(_ value: Float32) -> Void { + #if arch(wasm32) + let ret = makeAPIResultRate(_: Float.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAPIResultPrecise") +@_cdecl("bjs_makeAPIResultPrecise") +public func _bjs_makeAPIResultPrecise(_ value: Float64) -> Void { + #if arch(wasm32) + let ret = makeAPIResultPrecise(_: Double.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundtripComplexResult") +@_cdecl("bjs_roundtripComplexResult") +public func _bjs_roundtripComplexResult(_ result: Int32) -> Void { + #if arch(wasm32) + let ret = roundtripComplexResult(_: ComplexResult.bridgeJSLiftParameter(result)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeComplexResultSuccess") +@_cdecl("bjs_makeComplexResultSuccess") +public func _bjs_makeComplexResultSuccess(_ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + let ret = makeComplexResultSuccess(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeComplexResultError") +@_cdecl("bjs_makeComplexResultError") +public func _bjs_makeComplexResultError(_ messageBytes: Int32, _ messageLength: Int32, _ code: Int32) -> Void { + #if arch(wasm32) + let ret = makeComplexResultError(_: String.bridgeJSLiftParameter(messageBytes, messageLength), _: Int.bridgeJSLiftParameter(code)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeComplexResultLocation") +@_cdecl("bjs_makeComplexResultLocation") +public func _bjs_makeComplexResultLocation(_ lat: Float64, _ lng: Float64, _ nameBytes: Int32, _ nameLength: Int32) -> Void { + #if arch(wasm32) + let ret = makeComplexResultLocation(_: Double.bridgeJSLiftParameter(lat), _: Double.bridgeJSLiftParameter(lng), _: String.bridgeJSLiftParameter(nameBytes, nameLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeComplexResultStatus") +@_cdecl("bjs_makeComplexResultStatus") +public func _bjs_makeComplexResultStatus(_ active: Int32, _ code: Int32, _ messageBytes: Int32, _ messageLength: Int32) -> Void { + #if arch(wasm32) + let ret = makeComplexResultStatus(_: Bool.bridgeJSLiftParameter(active), _: Int.bridgeJSLiftParameter(code), _: String.bridgeJSLiftParameter(messageBytes, messageLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeComplexResultCoordinates") +@_cdecl("bjs_makeComplexResultCoordinates") +public func _bjs_makeComplexResultCoordinates(_ x: Float64, _ y: Float64, _ z: Float64) -> Void { + #if arch(wasm32) + let ret = makeComplexResultCoordinates(_: Double.bridgeJSLiftParameter(x), _: Double.bridgeJSLiftParameter(y), _: Double.bridgeJSLiftParameter(z)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeComplexResultComprehensive") +@_cdecl("bjs_makeComplexResultComprehensive") +public func _bjs_makeComplexResultComprehensive(_ flag1: Int32, _ flag2: Int32, _ count1: Int32, _ count2: Int32, _ value1: Float64, _ value2: Float64, _ text1Bytes: Int32, _ text1Length: Int32, _ text2Bytes: Int32, _ text2Length: Int32, _ text3Bytes: Int32, _ text3Length: Int32) -> Void { + #if arch(wasm32) + let ret = makeComplexResultComprehensive(_: Bool.bridgeJSLiftParameter(flag1), _: Bool.bridgeJSLiftParameter(flag2), _: Int.bridgeJSLiftParameter(count1), _: Int.bridgeJSLiftParameter(count2), _: Double.bridgeJSLiftParameter(value1), _: Double.bridgeJSLiftParameter(value2), _: String.bridgeJSLiftParameter(text1Bytes, text1Length), _: String.bridgeJSLiftParameter(text2Bytes, text2Length), _: String.bridgeJSLiftParameter(text3Bytes, text3Length)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeComplexResultInfo") +@_cdecl("bjs_makeComplexResultInfo") +public func _bjs_makeComplexResultInfo() -> Void { + #if arch(wasm32) + let ret = makeComplexResultInfo() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeUtilitiesResultSuccess") +@_cdecl("bjs_makeUtilitiesResultSuccess") +public func _bjs_makeUtilitiesResultSuccess(_ messageBytes: Int32, _ messageLength: Int32) -> Void { + #if arch(wasm32) + let ret = makeUtilitiesResultSuccess(_: String.bridgeJSLiftParameter(messageBytes, messageLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeUtilitiesResultFailure") +@_cdecl("bjs_makeUtilitiesResultFailure") +public func _bjs_makeUtilitiesResultFailure(_ errorBytes: Int32, _ errorLength: Int32, _ code: Int32) -> Void { + #if arch(wasm32) + let ret = makeUtilitiesResultFailure(_: String.bridgeJSLiftParameter(errorBytes, errorLength), _: Int.bridgeJSLiftParameter(code)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeUtilitiesResultStatus") +@_cdecl("bjs_makeUtilitiesResultStatus") +public func _bjs_makeUtilitiesResultStatus(_ active: Int32, _ code: Int32, _ messageBytes: Int32, _ messageLength: Int32) -> Void { + #if arch(wasm32) + let ret = makeUtilitiesResultStatus(_: Bool.bridgeJSLiftParameter(active), _: Int.bridgeJSLiftParameter(code), _: String.bridgeJSLiftParameter(messageBytes, messageLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAPINetworkingResultSuccess") +@_cdecl("bjs_makeAPINetworkingResultSuccess") +public func _bjs_makeAPINetworkingResultSuccess(_ messageBytes: Int32, _ messageLength: Int32) -> Void { + #if arch(wasm32) + let ret = makeAPINetworkingResultSuccess(_: String.bridgeJSLiftParameter(messageBytes, messageLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAPINetworkingResultFailure") +@_cdecl("bjs_makeAPINetworkingResultFailure") +public func _bjs_makeAPINetworkingResultFailure(_ errorBytes: Int32, _ errorLength: Int32, _ code: Int32) -> Void { + #if arch(wasm32) + let ret = makeAPINetworkingResultFailure(_: String.bridgeJSLiftParameter(errorBytes, errorLength), _: Int.bridgeJSLiftParameter(code)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundtripUtilitiesResult") +@_cdecl("bjs_roundtripUtilitiesResult") +public func _bjs_roundtripUtilitiesResult(_ result: Int32) -> Void { + #if arch(wasm32) + let ret = roundtripUtilitiesResult(_: Utilities.Result.bridgeJSLiftParameter(result)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundtripAPINetworkingResult") +@_cdecl("bjs_roundtripAPINetworkingResult") +public func _bjs_roundtripAPINetworkingResult(_ result: Int32) -> Void { + #if arch(wasm32) + let ret = roundtripAPINetworkingResult(_: API.NetworkingResult.bridgeJSLiftParameter(result)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripAllTypesResult") +@_cdecl("bjs_roundTripAllTypesResult") +public func _bjs_roundTripAllTypesResult(_ result: Int32) -> Void { + #if arch(wasm32) + let ret = roundTripAllTypesResult(_: AllTypesResult.bridgeJSLiftParameter(result)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripTypedPayloadResult") +@_cdecl("bjs_roundTripTypedPayloadResult") +public func _bjs_roundTripTypedPayloadResult(_ result: Int32) -> Void { + #if arch(wasm32) + let ret = roundTripTypedPayloadResult(_: TypedPayloadResult.bridgeJSLiftParameter(result)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_createPropertyHolder") +@_cdecl("bjs_createPropertyHolder") +public func _bjs_createPropertyHolder(_ intValue: Int32, _ floatValue: Float32, _ doubleValue: Float64, _ boolValue: Int32, _ stringValueBytes: Int32, _ stringValueLength: Int32, _ jsObject: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = createPropertyHolder(intValue: Int.bridgeJSLiftParameter(intValue), floatValue: Float.bridgeJSLiftParameter(floatValue), doubleValue: Double.bridgeJSLiftParameter(doubleValue), boolValue: Bool.bridgeJSLiftParameter(boolValue), stringValue: String.bridgeJSLiftParameter(stringValueBytes, stringValueLength), jsObject: JSObject.bridgeJSLiftParameter(jsObject)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_testPropertyHolder") +@_cdecl("bjs_testPropertyHolder") +public func _bjs_testPropertyHolder(_ holder: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = testPropertyHolder(holder: PropertyHolder.bridgeJSLiftParameter(holder)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetObserverCounts") +@_cdecl("bjs_resetObserverCounts") +public func _bjs_resetObserverCounts() -> Void { + #if arch(wasm32) + resetObserverCounts() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getObserverStats") +@_cdecl("bjs_getObserverStats") +public func _bjs_getObserverStats() -> Void { + #if arch(wasm32) + let ret = getObserverStats() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_formatName") +@_cdecl("bjs_formatName") +public func _bjs_formatName(_ nameBytes: Int32, _ nameLength: Int32, _ transform: Int32) -> Void { + #if arch(wasm32) + let ret = formatName(_: String.bridgeJSLiftParameter(nameBytes, nameLength), transform: _BJS_Closure_20BridgeJSRuntimeTestsSS_SS.bridgeJSLift(transform)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeFormatter") +@_cdecl("bjs_makeFormatter") +public func _bjs_makeFormatter(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { + #if arch(wasm32) + let ret = makeFormatter(prefix: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAdder") +@_cdecl("bjs_makeAdder") +public func _bjs_makeAdder(_ base: Int32) -> Int32 { + #if arch(wasm32) + let ret = makeAdder(base: Int.bridgeJSLiftParameter(base)) + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getSharedSubject") +@_cdecl("bjs_getSharedSubject") +public func _bjs_getSharedSubject() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = getSharedSubject() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetSharedSubject") +@_cdecl("bjs_resetSharedSubject") +public func _bjs_resetSharedSubject() -> Void { + #if arch(wasm32) + resetSharedSubject() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getRetainLeakSubject") +@_cdecl("bjs_getRetainLeakSubject") +public func _bjs_getRetainLeakSubject() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = getRetainLeakSubject() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetRetainLeakSubject") +@_cdecl("bjs_resetRetainLeakSubject") +public func _bjs_resetRetainLeakSubject() -> Void { + #if arch(wasm32) + resetRetainLeakSubject() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getRetainLeakDeinits") +@_cdecl("bjs_getRetainLeakDeinits") +public func _bjs_getRetainLeakDeinits() -> Int32 { + #if arch(wasm32) + let ret = getRetainLeakDeinits() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetRetainLeakDeinits") +@_cdecl("bjs_resetRetainLeakDeinits") +public func _bjs_resetRetainLeakDeinits() -> Void { + #if arch(wasm32) + resetRetainLeakDeinits() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_setupArrayPool") +@_cdecl("bjs_setupArrayPool") +public func _bjs_setupArrayPool(_ count: Int32) -> Void { + #if arch(wasm32) + setupArrayPool(_: Int.bridgeJSLiftParameter(count)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getArrayPool") +@_cdecl("bjs_getArrayPool") +public func _bjs_getArrayPool() -> Void { + #if arch(wasm32) + let ret = getArrayPool() + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getArrayPoolElement") +@_cdecl("bjs_getArrayPoolElement") +public func _bjs_getArrayPoolElement(_ index: Int32) -> Void { + #if arch(wasm32) + let ret = getArrayPoolElement(_: Int.bridgeJSLiftParameter(index)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getArrayPoolDeinits") +@_cdecl("bjs_getArrayPoolDeinits") +public func _bjs_getArrayPoolDeinits() -> Int32 { + #if arch(wasm32) + let ret = getArrayPoolDeinits() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetArrayPoolDeinits") +@_cdecl("bjs_resetArrayPoolDeinits") +public func _bjs_resetArrayPoolDeinits() -> Void { + #if arch(wasm32) + resetArrayPoolDeinits() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_clearArrayPool") +@_cdecl("bjs_clearArrayPool") +public func _bjs_clearArrayPool() -> Void { + #if arch(wasm32) + clearArrayPool() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripPointerFields") +@_cdecl("bjs_roundTripPointerFields") +public func _bjs_roundTripPointerFields() -> Void { + #if arch(wasm32) + let ret = roundTripPointerFields(_: PointerFields.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_testStructDefault") +@_cdecl("bjs_testStructDefault") +public func _bjs_testStructDefault() -> Void { + #if arch(wasm32) + let ret = testStructDefault(point: DataPoint.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_cartToJSObject") +@_cdecl("bjs_cartToJSObject") +public func _bjs_cartToJSObject() -> Int32 { + #if arch(wasm32) + let ret = cartToJSObject(_: CopyableCart.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_nestedCartToJSObject") +@_cdecl("bjs_nestedCartToJSObject") +public func _bjs_nestedCartToJSObject() -> Int32 { + #if arch(wasm32) + let ret = nestedCartToJSObject(_: CopyableNestedCart.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripDataPoint") +@_cdecl("bjs_roundTripDataPoint") +public func _bjs_roundTripDataPoint() -> Void { + #if arch(wasm32) + let ret = roundTripDataPoint(_: DataPoint.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripPublicPoint") +@_cdecl("bjs_roundTripPublicPoint") +public func _bjs_roundTripPublicPoint() -> Void { + #if arch(wasm32) + let ret = roundTripPublicPoint(_: PublicPoint.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripContact") +@_cdecl("bjs_roundTripContact") +public func _bjs_roundTripContact() -> Void { + #if arch(wasm32) + let ret = roundTripContact(_: Contact.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripConfig") +@_cdecl("bjs_roundTripConfig") +public func _bjs_roundTripConfig() -> Void { + #if arch(wasm32) + let ret = roundTripConfig(_: Config.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripSessionData") +@_cdecl("bjs_roundTripSessionData") +public func _bjs_roundTripSessionData() -> Void { + #if arch(wasm32) + let ret = roundTripSessionData(_: SessionData.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripValidationReport") +@_cdecl("bjs_roundTripValidationReport") +public func _bjs_roundTripValidationReport() -> Void { + #if arch(wasm32) + let ret = roundTripValidationReport(_: ValidationReport.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripAdvancedConfig") +@_cdecl("bjs_roundTripAdvancedConfig") +public func _bjs_roundTripAdvancedConfig() -> Void { + #if arch(wasm32) + let ret = roundTripAdvancedConfig(_: AdvancedConfig.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripMeasurementConfig") +@_cdecl("bjs_roundTripMeasurementConfig") +public func _bjs_roundTripMeasurementConfig() -> Void { + #if arch(wasm32) + let ret = roundTripMeasurementConfig(_: MeasurementConfig.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_updateValidationReport") +@_cdecl("bjs_updateValidationReport") +public func _bjs_updateValidationReport(_ newResultIsSome: Int32, _ newResultCaseId: Int32) -> Void { + #if arch(wasm32) + let _tmp_report = ValidationReport.bridgeJSLiftParameter() + let _tmp_newResult = Optional.bridgeJSLiftParameter(newResultIsSome, newResultCaseId) + let ret = updateValidationReport(_: _tmp_newResult, _: _tmp_report) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_testContainerWithStruct") +@_cdecl("bjs_testContainerWithStruct") +public func _bjs_testContainerWithStruct() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = testContainerWithStruct(_: DataPoint.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripJSObjectContainer") +@_cdecl("bjs_roundTripJSObjectContainer") +public func _bjs_roundTripJSObjectContainer() -> Void { + #if arch(wasm32) + let ret = roundTripJSObjectContainer(_: JSObjectContainer.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripFooContainer") +@_cdecl("bjs_roundTripFooContainer") +public func _bjs_roundTripFooContainer() -> Void { + #if arch(wasm32) + let ret = roundTripFooContainer(_: FooContainer.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripArrayMembers") +@_cdecl("bjs_roundTripArrayMembers") +public func _bjs_roundTripArrayMembers() -> Void { + #if arch(wasm32) + let ret = roundTripArrayMembers(_: ArrayMembers.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_arrayMembersSum") +@_cdecl("bjs_arrayMembersSum") +public func _bjs_arrayMembersSum() -> Int32 { + #if arch(wasm32) + let _tmp_values = [Int].bridgeJSStackPop() + let _tmp_value = ArrayMembers.bridgeJSLiftParameter() + let ret = arrayMembersSum(_: _tmp_value, _: _tmp_values) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_arrayMembersFirst") +@_cdecl("bjs_arrayMembersFirst") +public func _bjs_arrayMembersFirst() -> Void { + #if arch(wasm32) + let _tmp_values = [String].bridgeJSStackPop() + let _tmp_value = ArrayMembers.bridgeJSLiftParameter() + let ret = arrayMembersFirst(_: _tmp_value, _: _tmp_values) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClosureSupportExports_static_makeIntToInt") +@_cdecl("bjs_ClosureSupportExports_static_makeIntToInt") +public func _bjs_ClosureSupportExports_static_makeIntToInt(_ base: Int32) -> Int32 { + #if arch(wasm32) + let ret = ClosureSupportExports.makeIntToInt(_: Int.bridgeJSLiftParameter(base)) + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClosureSupportExports_static_makeDoubleToDouble") +@_cdecl("bjs_ClosureSupportExports_static_makeDoubleToDouble") +public func _bjs_ClosureSupportExports_static_makeDoubleToDouble(_ base: Float64) -> Int32 { + #if arch(wasm32) + let ret = ClosureSupportExports.makeDoubleToDouble(_: Double.bridgeJSLiftParameter(base)) + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClosureSupportExports_static_makeStringToString") +@_cdecl("bjs_ClosureSupportExports_static_makeStringToString") +public func _bjs_ClosureSupportExports_static_makeStringToString(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { + #if arch(wasm32) + let ret = ClosureSupportExports.makeStringToString(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClosureSupportExports_static_makeJSIntToInt") +@_cdecl("bjs_ClosureSupportExports_static_makeJSIntToInt") +public func _bjs_ClosureSupportExports_static_makeJSIntToInt(_ base: Int32) -> Int32 { + #if arch(wasm32) + let ret = ClosureSupportExports.makeJSIntToInt(_: Int.bridgeJSLiftParameter(base)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClosureSupportExports_static_makeJSDoubleToDouble") +@_cdecl("bjs_ClosureSupportExports_static_makeJSDoubleToDouble") +public func _bjs_ClosureSupportExports_static_makeJSDoubleToDouble(_ base: Float64) -> Int32 { + #if arch(wasm32) + let ret = ClosureSupportExports.makeJSDoubleToDouble(_: Double.bridgeJSLiftParameter(base)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClosureSupportExports_static_makeJSStringToString") +@_cdecl("bjs_ClosureSupportExports_static_makeJSStringToString") +public func _bjs_ClosureSupportExports_static_makeJSStringToString(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { + #if arch(wasm32) + let ret = ClosureSupportExports.makeJSStringToString(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClosureSupportExports_deinit") +@_cdecl("bjs_ClosureSupportExports_deinit") +public func _bjs_ClosureSupportExports_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ClosureSupportExports: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ClosureSupportExports_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ClosureSupportExports_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportExports_wrap") +fileprivate func _bjs_ClosureSupportExports_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ClosureSupportExports_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ClosureSupportExports_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ClosureSupportExports_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_init") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_init") +public func _bjs_DefaultArgumentConstructorDefaults_init(_ nameBytes: Int32, _ nameLength: Int32, _ count: Int32, _ enabled: Int32, _ status: Int32, _ tagIsSome: Int32, _ tagBytes: Int32, _ tagLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = DefaultArgumentConstructorDefaults(name: String.bridgeJSLiftParameter(nameBytes, nameLength), count: Int.bridgeJSLiftParameter(count), enabled: Bool.bridgeJSLiftParameter(enabled), status: Status.bridgeJSLiftParameter(status), tag: Optional.bridgeJSLiftParameter(tagIsSome, tagBytes, tagLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_describe") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_describe") +public func _bjs_DefaultArgumentConstructorDefaults_describe(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).describe() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_name_get") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_name_get") +public func _bjs_DefaultArgumentConstructorDefaults_name_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).name + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_name_set") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_name_set") +public func _bjs_DefaultArgumentConstructorDefaults_name_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_count_get") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_count_get") +public func _bjs_DefaultArgumentConstructorDefaults_count_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).count + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_count_set") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_count_set") +public func _bjs_DefaultArgumentConstructorDefaults_count_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).count = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_enabled_get") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_enabled_get") +public func _bjs_DefaultArgumentConstructorDefaults_enabled_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).enabled + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_enabled_set") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_enabled_set") +public func _bjs_DefaultArgumentConstructorDefaults_enabled_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).enabled = Bool.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_status_get") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_status_get") +public func _bjs_DefaultArgumentConstructorDefaults_status_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).status + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_status_set") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_status_set") +public func _bjs_DefaultArgumentConstructorDefaults_status_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).status = Status.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_tag_get") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_tag_get") +public func _bjs_DefaultArgumentConstructorDefaults_tag_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).tag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_tag_set") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_tag_set") +public func _bjs_DefaultArgumentConstructorDefaults_tag_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).tag = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_deinit") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_deinit") +public func _bjs_DefaultArgumentConstructorDefaults_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension DefaultArgumentConstructorDefaults: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_DefaultArgumentConstructorDefaults_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_DefaultArgumentConstructorDefaults_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DefaultArgumentConstructorDefaults_wrap") +fileprivate func _bjs_DefaultArgumentConstructorDefaults_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_DefaultArgumentConstructorDefaults_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_DefaultArgumentConstructorDefaults_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_DefaultArgumentConstructorDefaults_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_Greeter_init") +@_cdecl("bjs_Greeter_init") +public func _bjs_Greeter_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = Greeter(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_greet") +@_cdecl("bjs_Greeter_greet") +public func _bjs_Greeter_greet(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = Greeter.bridgeJSLiftParameter(_self).greet() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_changeName") +@_cdecl("bjs_Greeter_changeName") +public func _bjs_Greeter_changeName(_ _self: UnsafeMutableRawPointer, _ nameBytes: Int32, _ nameLength: Int32) -> Void { + #if arch(wasm32) + Greeter.bridgeJSLiftParameter(_self).changeName(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_greetWith") +@_cdecl("bjs_Greeter_greetWith") +public func _bjs_Greeter_greetWith(_ _self: UnsafeMutableRawPointer, _ greeter: UnsafeMutableRawPointer, _ customGreeting: Int32) -> Void { + #if arch(wasm32) + let ret = Greeter.bridgeJSLiftParameter(_self).greetWith(greeter: Greeter.bridgeJSLiftParameter(greeter), customGreeting: _BJS_Closure_20BridgeJSRuntimeTests7GreeterC_SS.bridgeJSLift(customGreeting)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_makeFormatter") +@_cdecl("bjs_Greeter_makeFormatter") +public func _bjs_Greeter_makeFormatter(_ _self: UnsafeMutableRawPointer, _ suffixBytes: Int32, _ suffixLength: Int32) -> Int32 { + #if arch(wasm32) + let ret = Greeter.bridgeJSLiftParameter(_self).makeFormatter(suffix: String.bridgeJSLiftParameter(suffixBytes, suffixLength)) + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_static_makeCreator") +@_cdecl("bjs_Greeter_static_makeCreator") +public func _bjs_Greeter_static_makeCreator(_ defaultNameBytes: Int32, _ defaultNameLength: Int32) -> Int32 { + #if arch(wasm32) + let ret = Greeter.makeCreator(defaultName: String.bridgeJSLiftParameter(defaultNameBytes, defaultNameLength)) + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_makeCustomGreeter") +@_cdecl("bjs_Greeter_makeCustomGreeter") +public func _bjs_Greeter_makeCustomGreeter(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = Greeter.bridgeJSLiftParameter(_self).makeCustomGreeter() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_greetEnthusiastically") +@_cdecl("bjs_Greeter_greetEnthusiastically") +public func _bjs_Greeter_greetEnthusiastically(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = Greeter.bridgeJSLiftParameter(_self).greetEnthusiastically() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_static_greetAnonymously") +@_cdecl("bjs_Greeter_static_greetAnonymously") +public func _bjs_Greeter_static_greetAnonymously() -> Void { + #if arch(wasm32) + let ret = Greeter.greetAnonymously() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_name_get") +@_cdecl("bjs_Greeter_name_get") +public func _bjs_Greeter_name_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = Greeter.bridgeJSLiftParameter(_self).name + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_name_set") +@_cdecl("bjs_Greeter_name_set") +public func _bjs_Greeter_name_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + Greeter.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_prefix_get") +@_cdecl("bjs_Greeter_prefix_get") +public func _bjs_Greeter_prefix_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = Greeter.bridgeJSLiftParameter(_self).prefix + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_nameCount_get") +@_cdecl("bjs_Greeter_nameCount_get") +public func _bjs_Greeter_nameCount_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = Greeter.bridgeJSLiftParameter(_self).nameCount + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_static_defaultGreeting_get") +@_cdecl("bjs_Greeter_static_defaultGreeting_get") +public func _bjs_Greeter_static_defaultGreeting_get() -> Void { + #if arch(wasm32) + let ret = Greeter.defaultGreeting + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Greeter_deinit") +@_cdecl("bjs_Greeter_deinit") +public func _bjs_Greeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Greeter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + public var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Greeter_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + public consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_Greeter_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Greeter_wrap") +fileprivate func _bjs_Greeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_Greeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_Greeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Greeter_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_Calculator_square") +@_cdecl("bjs_Calculator_square") +public func _bjs_Calculator_square(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Int32 { + #if arch(wasm32) + let ret = Calculator.bridgeJSLiftParameter(_self).square(value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Calculator_add") +@_cdecl("bjs_Calculator_add") +public func _bjs_Calculator_add(_ _self: UnsafeMutableRawPointer, _ a: Int32, _ b: Int32) -> Int32 { + #if arch(wasm32) + let ret = Calculator.bridgeJSLiftParameter(_self).add(a: Int.bridgeJSLiftParameter(a), b: Int.bridgeJSLiftParameter(b)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Calculator_deinit") +@_cdecl("bjs_Calculator_deinit") +public func _bjs_Calculator_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Calculator: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Calculator_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_Calculator_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Calculator_wrap") +fileprivate func _bjs_Calculator_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_Calculator_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_Calculator_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Calculator_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_InternalGreeter_deinit") +@_cdecl("bjs_InternalGreeter_deinit") +public func _bjs_InternalGreeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension InternalGreeter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + internal var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_InternalGreeter_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + internal consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_InternalGreeter_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_InternalGreeter_wrap") +fileprivate func _bjs_InternalGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_InternalGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_InternalGreeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_InternalGreeter_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_PublicGreeter_deinit") +@_cdecl("bjs_PublicGreeter_deinit") +public func _bjs_PublicGreeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension PublicGreeter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + public var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_PublicGreeter_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + public consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_PublicGreeter_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PublicGreeter_wrap") +fileprivate func _bjs_PublicGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_PublicGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_PublicGreeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_PublicGreeter_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_PackageGreeter_deinit") +@_cdecl("bjs_PackageGreeter_deinit") +public func _bjs_PackageGreeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension PackageGreeter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + package var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_PackageGreeter_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + package consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_PackageGreeter_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PackageGreeter_wrap") +fileprivate func _bjs_PackageGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_PackageGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_PackageGreeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_PackageGreeter_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_Utils_Converter_init") +@_cdecl("bjs_Utils_Converter_init") +public func _bjs_Utils_Converter_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = Utils.Converter() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Utils_Converter_toString") +@_cdecl("bjs_Utils_Converter_toString") +public func _bjs_Utils_Converter_toString(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + let ret = Utils.Converter.bridgeJSLiftParameter(_self).toString(value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Utils_Converter_precision_get") +@_cdecl("bjs_Utils_Converter_precision_get") +public func _bjs_Utils_Converter_precision_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = Utils.Converter.bridgeJSLiftParameter(_self).precision + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Utils_Converter_precision_set") +@_cdecl("bjs_Utils_Converter_precision_set") +public func _bjs_Utils_Converter_precision_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + Utils.Converter.bridgeJSLiftParameter(_self).precision = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Utils_Converter_deinit") +@_cdecl("bjs_Utils_Converter_deinit") +public func _bjs_Utils_Converter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Utils.Converter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Utils_Converter_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_Utils_Converter_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Utils_Converter_wrap") +fileprivate func _bjs_Utils_Converter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_Utils_Converter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_Utils_Converter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Utils_Converter_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_Networking_API_HTTPServer_init") +@_cdecl("bjs_Networking_API_HTTPServer_init") +public func _bjs_Networking_API_HTTPServer_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = Networking.API.HTTPServer() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Networking_API_HTTPServer_call") +@_cdecl("bjs_Networking_API_HTTPServer_call") +public func _bjs_Networking_API_HTTPServer_call(_ _self: UnsafeMutableRawPointer, _ method: Int32) -> Void { + #if arch(wasm32) + Networking.API.HTTPServer.bridgeJSLiftParameter(_self).call(_: Networking.API.Method.bridgeJSLiftParameter(method)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Networking_API_HTTPServer_deinit") +@_cdecl("bjs_Networking_API_HTTPServer_deinit") +public func _bjs_Networking_API_HTTPServer_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Networking.API.HTTPServer: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Networking_API_HTTPServer_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_Networking_API_HTTPServer_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Networking_API_HTTPServer_wrap") +fileprivate func _bjs_Networking_API_HTTPServer_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_Networking_API_HTTPServer_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_Networking_API_HTTPServer_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Networking_API_HTTPServer_wrap_extern(pointer) +} + +@_expose(wasm, "bjs___Swift_Foundation_UUID_init") +@_cdecl("bjs___Swift_Foundation_UUID_init") +public func _bjs___Swift_Foundation_UUID_init(_ valueBytes: Int32, _ valueLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = UUID(value: String.bridgeJSLiftParameter(valueBytes, valueLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs___Swift_Foundation_UUID_uuidString") +@_cdecl("bjs___Swift_Foundation_UUID_uuidString") +public func _bjs___Swift_Foundation_UUID_uuidString(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = UUID.bridgeJSLiftParameter(_self).uuidString() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs___Swift_Foundation_UUID_static_fromValue") +@_cdecl("bjs___Swift_Foundation_UUID_static_fromValue") +public func _bjs___Swift_Foundation_UUID_static_fromValue(_ valueBytes: Int32, _ valueLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = UUID.fromValue(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs___Swift_Foundation_UUID_static_placeholder_get") +@_cdecl("bjs___Swift_Foundation_UUID_static_placeholder_get") +public func _bjs___Swift_Foundation_UUID_static_placeholder_get() -> Void { + #if arch(wasm32) + let ret = UUID.placeholder + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs___Swift_Foundation_UUID_deinit") +@_cdecl("bjs___Swift_Foundation_UUID_deinit") +public func _bjs___Swift_Foundation_UUID_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension UUID: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs___Swift_Foundation_UUID_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs___Swift_Foundation_UUID_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs___Swift_Foundation_UUID_wrap") +fileprivate func _bjs___Swift_Foundation_UUID_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs___Swift_Foundation_UUID_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs___Swift_Foundation_UUID_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs___Swift_Foundation_UUID_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_Networking_APIV2_Internal_TestServer_init") +@_cdecl("bjs_Networking_APIV2_Internal_TestServer_init") +public func _bjs_Networking_APIV2_Internal_TestServer_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = Internal.TestServer() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Networking_APIV2_Internal_TestServer_call") +@_cdecl("bjs_Networking_APIV2_Internal_TestServer_call") +public func _bjs_Networking_APIV2_Internal_TestServer_call(_ _self: UnsafeMutableRawPointer, _ method: Int32) -> Void { + #if arch(wasm32) + Internal.TestServer.bridgeJSLiftParameter(_self).call(_: Internal.SupportedMethod.bridgeJSLiftParameter(method)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Networking_APIV2_Internal_TestServer_deinit") +@_cdecl("bjs_Networking_APIV2_Internal_TestServer_deinit") +public func _bjs_Networking_APIV2_Internal_TestServer_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Internal.TestServer: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Networking_APIV2_Internal_TestServer_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_Networking_APIV2_Internal_TestServer_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Networking_APIV2_Internal_TestServer_wrap") +fileprivate func _bjs_Networking_APIV2_Internal_TestServer_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_Networking_APIV2_Internal_TestServer_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_Networking_APIV2_Internal_TestServer_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Networking_APIV2_Internal_TestServer_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_SimplePropertyHolder_init") +@_cdecl("bjs_SimplePropertyHolder_init") +public func _bjs_SimplePropertyHolder_init(_ value: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = SimplePropertyHolder(value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimplePropertyHolder_value_get") +@_cdecl("bjs_SimplePropertyHolder_value_get") +public func _bjs_SimplePropertyHolder_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SimplePropertyHolder.bridgeJSLiftParameter(_self).value + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimplePropertyHolder_value_set") +@_cdecl("bjs_SimplePropertyHolder_value_set") +public func _bjs_SimplePropertyHolder_value_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + SimplePropertyHolder.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimplePropertyHolder_deinit") +@_cdecl("bjs_SimplePropertyHolder_deinit") +public func _bjs_SimplePropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension SimplePropertyHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_SimplePropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_SimplePropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SimplePropertyHolder_wrap") +fileprivate func _bjs_SimplePropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_SimplePropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_SimplePropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_SimplePropertyHolder_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_PropertyHolder_init") +@_cdecl("bjs_PropertyHolder_init") +public func _bjs_PropertyHolder_init(_ intValue: Int32, _ floatValue: Float32, _ doubleValue: Float64, _ boolValue: Int32, _ stringValueBytes: Int32, _ stringValueLength: Int32, _ jsObject: Int32, _ sibling: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = PropertyHolder(intValue: Int.bridgeJSLiftParameter(intValue), floatValue: Float.bridgeJSLiftParameter(floatValue), doubleValue: Double.bridgeJSLiftParameter(doubleValue), boolValue: Bool.bridgeJSLiftParameter(boolValue), stringValue: String.bridgeJSLiftParameter(stringValueBytes, stringValueLength), jsObject: JSObject.bridgeJSLiftParameter(jsObject), sibling: SimplePropertyHolder.bridgeJSLiftParameter(sibling)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_getAllValues") +@_cdecl("bjs_PropertyHolder_getAllValues") +public func _bjs_PropertyHolder_getAllValues(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).getAllValues() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_intValue_get") +@_cdecl("bjs_PropertyHolder_intValue_get") +public func _bjs_PropertyHolder_intValue_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).intValue + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_intValue_set") +@_cdecl("bjs_PropertyHolder_intValue_set") +public func _bjs_PropertyHolder_intValue_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + PropertyHolder.bridgeJSLiftParameter(_self).intValue = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_floatValue_get") +@_cdecl("bjs_PropertyHolder_floatValue_get") +public func _bjs_PropertyHolder_floatValue_get(_ _self: UnsafeMutableRawPointer) -> Float32 { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).floatValue + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_floatValue_set") +@_cdecl("bjs_PropertyHolder_floatValue_set") +public func _bjs_PropertyHolder_floatValue_set(_ _self: UnsafeMutableRawPointer, _ value: Float32) -> Void { + #if arch(wasm32) + PropertyHolder.bridgeJSLiftParameter(_self).floatValue = Float.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_doubleValue_get") +@_cdecl("bjs_PropertyHolder_doubleValue_get") +public func _bjs_PropertyHolder_doubleValue_get(_ _self: UnsafeMutableRawPointer) -> Float64 { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).doubleValue + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_doubleValue_set") +@_cdecl("bjs_PropertyHolder_doubleValue_set") +public func _bjs_PropertyHolder_doubleValue_set(_ _self: UnsafeMutableRawPointer, _ value: Float64) -> Void { + #if arch(wasm32) + PropertyHolder.bridgeJSLiftParameter(_self).doubleValue = Double.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_boolValue_get") +@_cdecl("bjs_PropertyHolder_boolValue_get") +public func _bjs_PropertyHolder_boolValue_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).boolValue + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_boolValue_set") +@_cdecl("bjs_PropertyHolder_boolValue_set") +public func _bjs_PropertyHolder_boolValue_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + PropertyHolder.bridgeJSLiftParameter(_self).boolValue = Bool.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_stringValue_get") +@_cdecl("bjs_PropertyHolder_stringValue_get") +public func _bjs_PropertyHolder_stringValue_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).stringValue + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_stringValue_set") +@_cdecl("bjs_PropertyHolder_stringValue_set") +public func _bjs_PropertyHolder_stringValue_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + PropertyHolder.bridgeJSLiftParameter(_self).stringValue = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_readonlyInt_get") +@_cdecl("bjs_PropertyHolder_readonlyInt_get") +public func _bjs_PropertyHolder_readonlyInt_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyInt + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_readonlyFloat_get") +@_cdecl("bjs_PropertyHolder_readonlyFloat_get") +public func _bjs_PropertyHolder_readonlyFloat_get(_ _self: UnsafeMutableRawPointer) -> Float32 { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyFloat + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_readonlyDouble_get") +@_cdecl("bjs_PropertyHolder_readonlyDouble_get") +public func _bjs_PropertyHolder_readonlyDouble_get(_ _self: UnsafeMutableRawPointer) -> Float64 { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyDouble + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_readonlyBool_get") +@_cdecl("bjs_PropertyHolder_readonlyBool_get") +public func _bjs_PropertyHolder_readonlyBool_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyBool + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_readonlyString_get") +@_cdecl("bjs_PropertyHolder_readonlyString_get") +public func _bjs_PropertyHolder_readonlyString_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyString + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_jsObject_get") +@_cdecl("bjs_PropertyHolder_jsObject_get") +public func _bjs_PropertyHolder_jsObject_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).jsObject + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_jsObject_set") +@_cdecl("bjs_PropertyHolder_jsObject_set") +public func _bjs_PropertyHolder_jsObject_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + PropertyHolder.bridgeJSLiftParameter(_self).jsObject = JSObject.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_sibling_get") +@_cdecl("bjs_PropertyHolder_sibling_get") +public func _bjs_PropertyHolder_sibling_get(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).sibling + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_sibling_set") +@_cdecl("bjs_PropertyHolder_sibling_set") +public func _bjs_PropertyHolder_sibling_set(_ _self: UnsafeMutableRawPointer, _ value: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + PropertyHolder.bridgeJSLiftParameter(_self).sibling = SimplePropertyHolder.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_lazyValue_get") +@_cdecl("bjs_PropertyHolder_lazyValue_get") +public func _bjs_PropertyHolder_lazyValue_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).lazyValue + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_lazyValue_set") +@_cdecl("bjs_PropertyHolder_lazyValue_set") +public func _bjs_PropertyHolder_lazyValue_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + PropertyHolder.bridgeJSLiftParameter(_self).lazyValue = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_computedReadonly_get") +@_cdecl("bjs_PropertyHolder_computedReadonly_get") +public func _bjs_PropertyHolder_computedReadonly_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).computedReadonly + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_computedReadWrite_get") +@_cdecl("bjs_PropertyHolder_computedReadWrite_get") +public func _bjs_PropertyHolder_computedReadWrite_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).computedReadWrite + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_computedReadWrite_set") +@_cdecl("bjs_PropertyHolder_computedReadWrite_set") +public func _bjs_PropertyHolder_computedReadWrite_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + PropertyHolder.bridgeJSLiftParameter(_self).computedReadWrite = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_observedProperty_get") +@_cdecl("bjs_PropertyHolder_observedProperty_get") +public func _bjs_PropertyHolder_observedProperty_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).observedProperty + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_observedProperty_set") +@_cdecl("bjs_PropertyHolder_observedProperty_set") +public func _bjs_PropertyHolder_observedProperty_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + PropertyHolder.bridgeJSLiftParameter(_self).observedProperty = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PropertyHolder_deinit") +@_cdecl("bjs_PropertyHolder_deinit") +public func _bjs_PropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension PropertyHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_PropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_PropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PropertyHolder_wrap") +fileprivate func _bjs_PropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_PropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_PropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_PropertyHolder_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_MathUtils_static_add") +@_cdecl("bjs_MathUtils_static_add") +public func _bjs_MathUtils_static_add(_ a: Int32, _ b: Int32) -> Int32 { + #if arch(wasm32) + let ret = MathUtils.add(a: Int.bridgeJSLiftParameter(a), b: Int.bridgeJSLiftParameter(b)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_MathUtils_static_substract") +@_cdecl("bjs_MathUtils_static_substract") +public func _bjs_MathUtils_static_substract(_ a: Int32, _ b: Int32) -> Int32 { + #if arch(wasm32) + let ret = MathUtils.substract(a: Int.bridgeJSLiftParameter(a), b: Int.bridgeJSLiftParameter(b)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_MathUtils_deinit") +@_cdecl("bjs_MathUtils_deinit") +public func _bjs_MathUtils_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension MathUtils: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_MathUtils_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_MathUtils_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_MathUtils_wrap") +fileprivate func _bjs_MathUtils_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_MathUtils_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_MathUtils_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_MathUtils_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_StaticPropertyHolder_init") +@_cdecl("bjs_StaticPropertyHolder_init") +public func _bjs_StaticPropertyHolder_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = StaticPropertyHolder() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_staticConstant_get") +@_cdecl("bjs_StaticPropertyHolder_static_staticConstant_get") +public func _bjs_StaticPropertyHolder_static_staticConstant_get() -> Void { + #if arch(wasm32) + let ret = StaticPropertyHolder.staticConstant + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_staticVariable_get") +@_cdecl("bjs_StaticPropertyHolder_static_staticVariable_get") +public func _bjs_StaticPropertyHolder_static_staticVariable_get() -> Int32 { + #if arch(wasm32) + let ret = StaticPropertyHolder.staticVariable + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_staticVariable_set") +@_cdecl("bjs_StaticPropertyHolder_static_staticVariable_set") +public func _bjs_StaticPropertyHolder_static_staticVariable_set(_ value: Int32) -> Void { + #if arch(wasm32) + StaticPropertyHolder.staticVariable = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_staticString_get") +@_cdecl("bjs_StaticPropertyHolder_static_staticString_get") +public func _bjs_StaticPropertyHolder_static_staticString_get() -> Void { + #if arch(wasm32) + let ret = StaticPropertyHolder.staticString + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_staticString_set") +@_cdecl("bjs_StaticPropertyHolder_static_staticString_set") +public func _bjs_StaticPropertyHolder_static_staticString_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + StaticPropertyHolder.staticString = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_staticBool_get") +@_cdecl("bjs_StaticPropertyHolder_static_staticBool_get") +public func _bjs_StaticPropertyHolder_static_staticBool_get() -> Int32 { + #if arch(wasm32) + let ret = StaticPropertyHolder.staticBool + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_staticBool_set") +@_cdecl("bjs_StaticPropertyHolder_static_staticBool_set") +public func _bjs_StaticPropertyHolder_static_staticBool_set(_ value: Int32) -> Void { + #if arch(wasm32) + StaticPropertyHolder.staticBool = Bool.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_staticFloat_get") +@_cdecl("bjs_StaticPropertyHolder_static_staticFloat_get") +public func _bjs_StaticPropertyHolder_static_staticFloat_get() -> Float32 { + #if arch(wasm32) + let ret = StaticPropertyHolder.staticFloat + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_staticFloat_set") +@_cdecl("bjs_StaticPropertyHolder_static_staticFloat_set") +public func _bjs_StaticPropertyHolder_static_staticFloat_set(_ value: Float32) -> Void { + #if arch(wasm32) + StaticPropertyHolder.staticFloat = Float.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_staticDouble_get") +@_cdecl("bjs_StaticPropertyHolder_static_staticDouble_get") +public func _bjs_StaticPropertyHolder_static_staticDouble_get() -> Float64 { + #if arch(wasm32) + let ret = StaticPropertyHolder.staticDouble + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_staticDouble_set") +@_cdecl("bjs_StaticPropertyHolder_static_staticDouble_set") +public func _bjs_StaticPropertyHolder_static_staticDouble_set(_ value: Float64) -> Void { + #if arch(wasm32) + StaticPropertyHolder.staticDouble = Double.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_computedProperty_get") +@_cdecl("bjs_StaticPropertyHolder_static_computedProperty_get") +public func _bjs_StaticPropertyHolder_static_computedProperty_get() -> Void { + #if arch(wasm32) + let ret = StaticPropertyHolder.computedProperty + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_computedProperty_set") +@_cdecl("bjs_StaticPropertyHolder_static_computedProperty_set") +public func _bjs_StaticPropertyHolder_static_computedProperty_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + StaticPropertyHolder.computedProperty = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_readOnlyComputed_get") +@_cdecl("bjs_StaticPropertyHolder_static_readOnlyComputed_get") +public func _bjs_StaticPropertyHolder_static_readOnlyComputed_get() -> Int32 { + #if arch(wasm32) + let ret = StaticPropertyHolder.readOnlyComputed + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_optionalString_get") +@_cdecl("bjs_StaticPropertyHolder_static_optionalString_get") +public func _bjs_StaticPropertyHolder_static_optionalString_get() -> Void { + #if arch(wasm32) + let ret = StaticPropertyHolder.optionalString + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_optionalString_set") +@_cdecl("bjs_StaticPropertyHolder_static_optionalString_set") +public func _bjs_StaticPropertyHolder_static_optionalString_set(_ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + StaticPropertyHolder.optionalString = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_optionalInt_get") +@_cdecl("bjs_StaticPropertyHolder_static_optionalInt_get") +public func _bjs_StaticPropertyHolder_static_optionalInt_get() -> Void { + #if arch(wasm32) + let ret = StaticPropertyHolder.optionalInt + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_optionalInt_set") +@_cdecl("bjs_StaticPropertyHolder_static_optionalInt_set") +public func _bjs_StaticPropertyHolder_static_optionalInt_set(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { + #if arch(wasm32) + StaticPropertyHolder.optionalInt = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_jsObjectProperty_get") +@_cdecl("bjs_StaticPropertyHolder_static_jsObjectProperty_get") +public func _bjs_StaticPropertyHolder_static_jsObjectProperty_get() -> Int32 { + #if arch(wasm32) + let ret = StaticPropertyHolder.jsObjectProperty + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_static_jsObjectProperty_set") +@_cdecl("bjs_StaticPropertyHolder_static_jsObjectProperty_set") +public func _bjs_StaticPropertyHolder_static_jsObjectProperty_set(_ value: Int32) -> Void { + #if arch(wasm32) + StaticPropertyHolder.jsObjectProperty = JSObject.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_StaticPropertyHolder_deinit") +@_cdecl("bjs_StaticPropertyHolder_deinit") +public func _bjs_StaticPropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension StaticPropertyHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_StaticPropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_StaticPropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticPropertyHolder_wrap") +fileprivate func _bjs_StaticPropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_StaticPropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_StaticPropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_StaticPropertyHolder_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_DataProcessorManager_init") +@_cdecl("bjs_DataProcessorManager_init") +public func _bjs_DataProcessorManager_init(_ processor: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = DataProcessorManager(processor: AnyDataProcessor.bridgeJSLiftParameter(processor)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_incrementByAmount") +@_cdecl("bjs_DataProcessorManager_incrementByAmount") +public func _bjs_DataProcessorManager_incrementByAmount(_ _self: UnsafeMutableRawPointer, _ amount: Int32) -> Void { + #if arch(wasm32) + DataProcessorManager.bridgeJSLiftParameter(_self).incrementByAmount(_: Int.bridgeJSLiftParameter(amount)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_setProcessorLabel") +@_cdecl("bjs_DataProcessorManager_setProcessorLabel") +public func _bjs_DataProcessorManager_setProcessorLabel(_ _self: UnsafeMutableRawPointer, _ prefixBytes: Int32, _ prefixLength: Int32, _ suffixBytes: Int32, _ suffixLength: Int32) -> Void { + #if arch(wasm32) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorLabel(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength), _: String.bridgeJSLiftParameter(suffixBytes, suffixLength)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_isProcessorEven") +@_cdecl("bjs_DataProcessorManager_isProcessorEven") +public func _bjs_DataProcessorManager_isProcessorEven(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).isProcessorEven() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_getProcessorLabel") +@_cdecl("bjs_DataProcessorManager_getProcessorLabel") +public func _bjs_DataProcessorManager_getProcessorLabel(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorLabel() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_getCurrentValue") +@_cdecl("bjs_DataProcessorManager_getCurrentValue") +public func _bjs_DataProcessorManager_getCurrentValue(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getCurrentValue() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_incrementBoth") +@_cdecl("bjs_DataProcessorManager_incrementBoth") +public func _bjs_DataProcessorManager_incrementBoth(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + DataProcessorManager.bridgeJSLiftParameter(_self).incrementBoth() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_getBackupValue") +@_cdecl("bjs_DataProcessorManager_getBackupValue") +public func _bjs_DataProcessorManager_getBackupValue(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getBackupValue() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_hasBackup") +@_cdecl("bjs_DataProcessorManager_hasBackup") +public func _bjs_DataProcessorManager_hasBackup(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).hasBackup() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_getProcessorOptionalTag") +@_cdecl("bjs_DataProcessorManager_getProcessorOptionalTag") +public func _bjs_DataProcessorManager_getProcessorOptionalTag(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorOptionalTag() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_setProcessorOptionalTag") +@_cdecl("bjs_DataProcessorManager_setProcessorOptionalTag") +public func _bjs_DataProcessorManager_setProcessorOptionalTag(_ _self: UnsafeMutableRawPointer, _ tagIsSome: Int32, _ tagBytes: Int32, _ tagLength: Int32) -> Void { + #if arch(wasm32) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorOptionalTag(_: Optional.bridgeJSLiftParameter(tagIsSome, tagBytes, tagLength)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_getProcessorOptionalCount") +@_cdecl("bjs_DataProcessorManager_getProcessorOptionalCount") +public func _bjs_DataProcessorManager_getProcessorOptionalCount(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorOptionalCount() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_setProcessorOptionalCount") +@_cdecl("bjs_DataProcessorManager_setProcessorOptionalCount") +public func _bjs_DataProcessorManager_setProcessorOptionalCount(_ _self: UnsafeMutableRawPointer, _ countIsSome: Int32, _ countValue: Int32) -> Void { + #if arch(wasm32) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorOptionalCount(_: Optional.bridgeJSLiftParameter(countIsSome, countValue)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_getProcessorDirection") +@_cdecl("bjs_DataProcessorManager_getProcessorDirection") +public func _bjs_DataProcessorManager_getProcessorDirection(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorDirection() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_setProcessorDirection") +@_cdecl("bjs_DataProcessorManager_setProcessorDirection") +public func _bjs_DataProcessorManager_setProcessorDirection(_ _self: UnsafeMutableRawPointer, _ directionIsSome: Int32, _ directionValue: Int32) -> Void { + #if arch(wasm32) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorDirection(_: Optional.bridgeJSLiftParameter(directionIsSome, directionValue)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_getProcessorTheme") +@_cdecl("bjs_DataProcessorManager_getProcessorTheme") +public func _bjs_DataProcessorManager_getProcessorTheme(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorTheme() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_setProcessorTheme") +@_cdecl("bjs_DataProcessorManager_setProcessorTheme") +public func _bjs_DataProcessorManager_setProcessorTheme(_ _self: UnsafeMutableRawPointer, _ themeIsSome: Int32, _ themeBytes: Int32, _ themeLength: Int32) -> Void { + #if arch(wasm32) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorTheme(_: Optional.bridgeJSLiftParameter(themeIsSome, themeBytes, themeLength)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_getProcessorHttpStatus") +@_cdecl("bjs_DataProcessorManager_getProcessorHttpStatus") +public func _bjs_DataProcessorManager_getProcessorHttpStatus(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorHttpStatus() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_setProcessorHttpStatus") +@_cdecl("bjs_DataProcessorManager_setProcessorHttpStatus") +public func _bjs_DataProcessorManager_setProcessorHttpStatus(_ _self: UnsafeMutableRawPointer, _ statusIsSome: Int32, _ statusValue: Int32) -> Void { + #if arch(wasm32) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorHttpStatus(_: Optional.bridgeJSLiftParameter(statusIsSome, statusValue)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_getProcessorAPIResult") +@_cdecl("bjs_DataProcessorManager_getProcessorAPIResult") +public func _bjs_DataProcessorManager_getProcessorAPIResult(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorAPIResult() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_setProcessorAPIResult") +@_cdecl("bjs_DataProcessorManager_setProcessorAPIResult") +public func _bjs_DataProcessorManager_setProcessorAPIResult(_ _self: UnsafeMutableRawPointer, _ apiResultIsSome: Int32, _ apiResultCaseId: Int32) -> Void { + #if arch(wasm32) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorAPIResult(_: Optional.bridgeJSLiftParameter(apiResultIsSome, apiResultCaseId)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_processor_get") +@_cdecl("bjs_DataProcessorManager_processor_get") +public func _bjs_DataProcessorManager_processor_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).processor as! _BridgedSwiftProtocolExportable + return ret.bridgeJSLowerAsProtocolReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_processor_set") +@_cdecl("bjs_DataProcessorManager_processor_set") +public func _bjs_DataProcessorManager_processor_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + DataProcessorManager.bridgeJSLiftParameter(_self).processor = AnyDataProcessor.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_backupProcessor_get") +@_cdecl("bjs_DataProcessorManager_backupProcessor_get") +public func _bjs_DataProcessorManager_backupProcessor_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).backupProcessor + if let ret { + _swift_js_return_optional_object(1, (ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) + } else { + _swift_js_return_optional_object(0, 0) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_backupProcessor_set") +@_cdecl("bjs_DataProcessorManager_backupProcessor_set") +public func _bjs_DataProcessorManager_backupProcessor_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { + #if arch(wasm32) + DataProcessorManager.bridgeJSLiftParameter(_self).backupProcessor = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_DataProcessorManager_deinit") +@_cdecl("bjs_DataProcessorManager_deinit") +public func _bjs_DataProcessorManager_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension DataProcessorManager: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_DataProcessorManager_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_DataProcessorManager_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessorManager_wrap") +fileprivate func _bjs_DataProcessorManager_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_DataProcessorManager_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_DataProcessorManager_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_DataProcessorManager_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_SwiftDataProcessor_init") +@_cdecl("bjs_SwiftDataProcessor_init") +public func _bjs_SwiftDataProcessor_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = SwiftDataProcessor() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_increment") +@_cdecl("bjs_SwiftDataProcessor_increment") +public func _bjs_SwiftDataProcessor_increment(_ _self: UnsafeMutableRawPointer, _ amount: Int32) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).increment(by: Int.bridgeJSLiftParameter(amount)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_getValue") +@_cdecl("bjs_SwiftDataProcessor_getValue") +public func _bjs_SwiftDataProcessor_getValue(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).getValue() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_setLabelElements") +@_cdecl("bjs_SwiftDataProcessor_setLabelElements") +public func _bjs_SwiftDataProcessor_setLabelElements(_ _self: UnsafeMutableRawPointer, _ labelPrefixBytes: Int32, _ labelPrefixLength: Int32, _ labelSuffixBytes: Int32, _ labelSuffixLength: Int32) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).setLabelElements(_: String.bridgeJSLiftParameter(labelPrefixBytes, labelPrefixLength), _: String.bridgeJSLiftParameter(labelSuffixBytes, labelSuffixLength)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_getLabel") +@_cdecl("bjs_SwiftDataProcessor_getLabel") +public func _bjs_SwiftDataProcessor_getLabel(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).getLabel() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_isEven") +@_cdecl("bjs_SwiftDataProcessor_isEven") +public func _bjs_SwiftDataProcessor_isEven(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).isEven() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_processGreeter") +@_cdecl("bjs_SwiftDataProcessor_processGreeter") +public func _bjs_SwiftDataProcessor_processGreeter(_ _self: UnsafeMutableRawPointer, _ greeter: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).processGreeter(_: Greeter.bridgeJSLiftParameter(greeter)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_createGreeter") +@_cdecl("bjs_SwiftDataProcessor_createGreeter") +public func _bjs_SwiftDataProcessor_createGreeter(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).createGreeter() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_processOptionalGreeter") +@_cdecl("bjs_SwiftDataProcessor_processOptionalGreeter") +public func _bjs_SwiftDataProcessor_processOptionalGreeter(_ _self: UnsafeMutableRawPointer, _ greeterIsSome: Int32, _ greeterValue: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).processOptionalGreeter(_: Optional.bridgeJSLiftParameter(greeterIsSome, greeterValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_createOptionalGreeter") +@_cdecl("bjs_SwiftDataProcessor_createOptionalGreeter") +public func _bjs_SwiftDataProcessor_createOptionalGreeter(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).createOptionalGreeter() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_handleAPIResult") +@_cdecl("bjs_SwiftDataProcessor_handleAPIResult") +public func _bjs_SwiftDataProcessor_handleAPIResult(_ _self: UnsafeMutableRawPointer, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).handleAPIResult(_: Optional.bridgeJSLiftParameter(resultIsSome, resultCaseId)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_getAPIResult") +@_cdecl("bjs_SwiftDataProcessor_getAPIResult") +public func _bjs_SwiftDataProcessor_getAPIResult(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).getAPIResult() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_count_get") +@_cdecl("bjs_SwiftDataProcessor_count_get") +public func _bjs_SwiftDataProcessor_count_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).count + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_count_set") +@_cdecl("bjs_SwiftDataProcessor_count_set") +public func _bjs_SwiftDataProcessor_count_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).count = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_name_get") +@_cdecl("bjs_SwiftDataProcessor_name_get") +public func _bjs_SwiftDataProcessor_name_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).name + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_optionalTag_get") +@_cdecl("bjs_SwiftDataProcessor_optionalTag_get") +public func _bjs_SwiftDataProcessor_optionalTag_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_optionalTag_set") +@_cdecl("bjs_SwiftDataProcessor_optionalTag_set") +public func _bjs_SwiftDataProcessor_optionalTag_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTag = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_optionalCount_get") +@_cdecl("bjs_SwiftDataProcessor_optionalCount_get") +public func _bjs_SwiftDataProcessor_optionalCount_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalCount + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_optionalCount_set") +@_cdecl("bjs_SwiftDataProcessor_optionalCount_set") +public func _bjs_SwiftDataProcessor_optionalCount_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalCount = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_direction_get") +@_cdecl("bjs_SwiftDataProcessor_direction_get") +public func _bjs_SwiftDataProcessor_direction_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).direction + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_direction_set") +@_cdecl("bjs_SwiftDataProcessor_direction_set") +public func _bjs_SwiftDataProcessor_direction_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).direction = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_optionalTheme_get") +@_cdecl("bjs_SwiftDataProcessor_optionalTheme_get") +public func _bjs_SwiftDataProcessor_optionalTheme_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTheme + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_optionalTheme_set") +@_cdecl("bjs_SwiftDataProcessor_optionalTheme_set") +public func _bjs_SwiftDataProcessor_optionalTheme_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTheme = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_httpStatus_get") +@_cdecl("bjs_SwiftDataProcessor_httpStatus_get") +public func _bjs_SwiftDataProcessor_httpStatus_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).httpStatus + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_httpStatus_set") +@_cdecl("bjs_SwiftDataProcessor_httpStatus_set") +public func _bjs_SwiftDataProcessor_httpStatus_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).httpStatus = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_apiResult_get") +@_cdecl("bjs_SwiftDataProcessor_apiResult_get") +public func _bjs_SwiftDataProcessor_apiResult_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).apiResult + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_apiResult_set") +@_cdecl("bjs_SwiftDataProcessor_apiResult_set") +public func _bjs_SwiftDataProcessor_apiResult_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).apiResult = Optional.bridgeJSLiftParameter(valueIsSome, valueCaseId) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_helper_get") +@_cdecl("bjs_SwiftDataProcessor_helper_get") +public func _bjs_SwiftDataProcessor_helper_get(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).helper + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_helper_set") +@_cdecl("bjs_SwiftDataProcessor_helper_set") +public func _bjs_SwiftDataProcessor_helper_set(_ _self: UnsafeMutableRawPointer, _ value: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).helper = Greeter.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_optionalHelper_get") +@_cdecl("bjs_SwiftDataProcessor_optionalHelper_get") +public func _bjs_SwiftDataProcessor_optionalHelper_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalHelper + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_optionalHelper_set") +@_cdecl("bjs_SwiftDataProcessor_optionalHelper_set") +public func _bjs_SwiftDataProcessor_optionalHelper_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalHelper = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftDataProcessor_deinit") +@_cdecl("bjs_SwiftDataProcessor_deinit") +public func _bjs_SwiftDataProcessor_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension SwiftDataProcessor: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_SwiftDataProcessor_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_SwiftDataProcessor_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftDataProcessor_wrap") +fileprivate func _bjs_SwiftDataProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_SwiftDataProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_SwiftDataProcessor_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_SwiftDataProcessor_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessor") +@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessor") +public func _bjs_ProtocolReturnTests_static_createNativeProcessor() -> Int32 { + #if arch(wasm32) + let ret = ProtocolReturnTests.createNativeProcessor() as! _BridgedSwiftProtocolExportable + return ret.bridgeJSLowerAsProtocolReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessorOptional") +@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessorOptional") +public func _bjs_ProtocolReturnTests_static_createNativeProcessorOptional() -> Void { + #if arch(wasm32) + let ret = ProtocolReturnTests.createNativeProcessorOptional() + if let ret { + _swift_js_return_optional_object(1, (ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) + } else { + _swift_js_return_optional_object(0, 0) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessorNil") +@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessorNil") +public func _bjs_ProtocolReturnTests_static_createNativeProcessorNil() -> Void { + #if arch(wasm32) + let ret = ProtocolReturnTests.createNativeProcessorNil() + if let ret { + _swift_js_return_optional_object(1, (ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) + } else { + _swift_js_return_optional_object(0, 0) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessorArray") +@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessorArray") +public func _bjs_ProtocolReturnTests_static_createNativeProcessorArray() -> Void { + #if arch(wasm32) + let ret = ProtocolReturnTests.createNativeProcessorArray() + for __bjs_elem_ret in ret { + _swift_js_push_i32((__bjs_elem_ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) + } + _swift_js_push_i32(Int32(ret.count)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessorDictionary") +@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessorDictionary") +public func _bjs_ProtocolReturnTests_static_createNativeProcessorDictionary() -> Void { + #if arch(wasm32) + let ret = ProtocolReturnTests.createNativeProcessorDictionary() + for __bjs_kv_ret in ret { + __bjs_kv_ret.key.bridgeJSStackPush() + _swift_js_push_i32((__bjs_kv_ret.value as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) + } + _swift_js_push_i32(Int32(ret.count)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ProtocolReturnTests_deinit") +@_cdecl("bjs_ProtocolReturnTests_deinit") +public func _bjs_ProtocolReturnTests_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ProtocolReturnTests: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ProtocolReturnTests_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ProtocolReturnTests_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ProtocolReturnTests_wrap") +fileprivate func _bjs_ProtocolReturnTests_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ProtocolReturnTests_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ProtocolReturnTests_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ProtocolReturnTests_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_TextProcessor_init") +@_cdecl("bjs_TextProcessor_init") +public func _bjs_TextProcessor_init(_ transform: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = TextProcessor(transform: _BJS_Closure_20BridgeJSRuntimeTestsSS_SS.bridgeJSLift(transform)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_process") +@_cdecl("bjs_TextProcessor_process") +public func _bjs_TextProcessor_process(_ _self: UnsafeMutableRawPointer, _ textBytes: Int32, _ textLength: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).process(_: String.bridgeJSLiftParameter(textBytes, textLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processWithCustom") +@_cdecl("bjs_TextProcessor_processWithCustom") +public func _bjs_TextProcessor_processWithCustom(_ _self: UnsafeMutableRawPointer, _ textBytes: Int32, _ textLength: Int32, _ customTransform: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processWithCustom(_: String.bridgeJSLiftParameter(textBytes, textLength), customTransform: _BJS_Closure_20BridgeJSRuntimeTestsSiSSSd_SS.bridgeJSLift(customTransform)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_getTransform") +@_cdecl("bjs_TextProcessor_getTransform") +public func _bjs_TextProcessor_getTransform(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).getTransform() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processOptionalString") +@_cdecl("bjs_TextProcessor_processOptionalString") +public func _bjs_TextProcessor_processOptionalString(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalString(_: _BJS_Closure_20BridgeJSRuntimeTestsSqSS_SS.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processOptionalInt") +@_cdecl("bjs_TextProcessor_processOptionalInt") +public func _bjs_TextProcessor_processOptionalInt(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalInt(_: _BJS_Closure_20BridgeJSRuntimeTestsSqSi_SS.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processOptionalGreeter") +@_cdecl("bjs_TextProcessor_processOptionalGreeter") +public func _bjs_TextProcessor_processOptionalGreeter(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalGreeter(_: _BJS_Closure_20BridgeJSRuntimeTestsSq7GreeterC_SS.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_makeOptionalStringFormatter") +@_cdecl("bjs_TextProcessor_makeOptionalStringFormatter") +public func _bjs_TextProcessor_makeOptionalStringFormatter(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeOptionalStringFormatter() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_makeOptionalGreeterCreator") +@_cdecl("bjs_TextProcessor_makeOptionalGreeterCreator") +public func _bjs_TextProcessor_makeOptionalGreeterCreator(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeOptionalGreeterCreator() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processDirection") +@_cdecl("bjs_TextProcessor_processDirection") +public func _bjs_TextProcessor_processDirection(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processDirection(_: _BJS_Closure_20BridgeJSRuntimeTests9DirectionO_SS.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processTheme") +@_cdecl("bjs_TextProcessor_processTheme") +public func _bjs_TextProcessor_processTheme(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processTheme(_: _BJS_Closure_20BridgeJSRuntimeTests5ThemeO_SS.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processHttpStatus") +@_cdecl("bjs_TextProcessor_processHttpStatus") +public func _bjs_TextProcessor_processHttpStatus(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Int32 { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processHttpStatus(_: _BJS_Closure_20BridgeJSRuntimeTests10HttpStatusO_Si.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processAPIResult") +@_cdecl("bjs_TextProcessor_processAPIResult") +public func _bjs_TextProcessor_processAPIResult(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processAPIResult(_: _BJS_Closure_20BridgeJSRuntimeTests9APIResultO_SS.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_makeDirectionChecker") +@_cdecl("bjs_TextProcessor_makeDirectionChecker") +public func _bjs_TextProcessor_makeDirectionChecker(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeDirectionChecker() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_makeThemeValidator") +@_cdecl("bjs_TextProcessor_makeThemeValidator") +public func _bjs_TextProcessor_makeThemeValidator(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeThemeValidator() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_makeStatusCodeExtractor") +@_cdecl("bjs_TextProcessor_makeStatusCodeExtractor") +public func _bjs_TextProcessor_makeStatusCodeExtractor(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeStatusCodeExtractor() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_makeAPIResultHandler") +@_cdecl("bjs_TextProcessor_makeAPIResultHandler") +public func _bjs_TextProcessor_makeAPIResultHandler(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeAPIResultHandler() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processOptionalDirection") +@_cdecl("bjs_TextProcessor_processOptionalDirection") +public func _bjs_TextProcessor_processOptionalDirection(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalDirection(_: _BJS_Closure_20BridgeJSRuntimeTestsSq9DirectionO_SS.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processOptionalTheme") +@_cdecl("bjs_TextProcessor_processOptionalTheme") +public func _bjs_TextProcessor_processOptionalTheme(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalTheme(_: _BJS_Closure_20BridgeJSRuntimeTestsSq5ThemeO_SS.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processOptionalAPIResult") +@_cdecl("bjs_TextProcessor_processOptionalAPIResult") +public func _bjs_TextProcessor_processOptionalAPIResult(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalAPIResult(_: _BJS_Closure_20BridgeJSRuntimeTestsSq9APIResultO_SS.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_makeOptionalDirectionFormatter") +@_cdecl("bjs_TextProcessor_makeOptionalDirectionFormatter") +public func _bjs_TextProcessor_makeOptionalDirectionFormatter(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeOptionalDirectionFormatter() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processDataProcessor") +@_cdecl("bjs_TextProcessor_processDataProcessor") +public func _bjs_TextProcessor_processDataProcessor(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processDataProcessor(_: _BJS_Closure_20BridgeJSRuntimeTests13DataProcessorP_SS.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_makeDataProcessorFactory") +@_cdecl("bjs_TextProcessor_makeDataProcessorFactory") +public func _bjs_TextProcessor_makeDataProcessorFactory(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeDataProcessorFactory() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_roundtripDataProcessor") +@_cdecl("bjs_TextProcessor_roundtripDataProcessor") +public func _bjs_TextProcessor_roundtripDataProcessor(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Int32 { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).roundtripDataProcessor(_: _BJS_Closure_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP.bridgeJSLift(callback)) + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_processOptionalDataProcessor") +@_cdecl("bjs_TextProcessor_processOptionalDataProcessor") +public func _bjs_TextProcessor_processOptionalDataProcessor(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { + #if arch(wasm32) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalDataProcessor(_: _BJS_Closure_20BridgeJSRuntimeTestsSq13DataProcessorP_SS.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TextProcessor_deinit") +@_cdecl("bjs_TextProcessor_deinit") +public func _bjs_TextProcessor_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension TextProcessor: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_TextProcessor_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_TextProcessor_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TextProcessor_wrap") +fileprivate func _bjs_TextProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_TextProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_TextProcessor_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_TextProcessor_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_IdentityTestSubject_init") +@_cdecl("bjs_IdentityTestSubject_init") +public func _bjs_IdentityTestSubject_init(_ value: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = IdentityTestSubject(value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityTestSubject_value_get") +@_cdecl("bjs_IdentityTestSubject_value_get") +public func _bjs_IdentityTestSubject_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = IdentityTestSubject.bridgeJSLiftParameter(_self).value + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityTestSubject_value_set") +@_cdecl("bjs_IdentityTestSubject_value_set") +public func _bjs_IdentityTestSubject_value_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + IdentityTestSubject.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityTestSubject_currentValue_get") +@_cdecl("bjs_IdentityTestSubject_currentValue_get") +public func _bjs_IdentityTestSubject_currentValue_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = IdentityTestSubject.bridgeJSLiftParameter(_self).currentValue + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityTestSubject_deinit") +@_cdecl("bjs_IdentityTestSubject_deinit") +public func _bjs_IdentityTestSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension IdentityTestSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_IdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_IdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IdentityTestSubject_wrap") +fileprivate func _bjs_IdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_IdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_IdentityTestSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_IdentityTestSubject_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_RetainLeakSubject_init") +@_cdecl("bjs_RetainLeakSubject_init") +public func _bjs_RetainLeakSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = RetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_RetainLeakSubject_tag_get") +@_cdecl("bjs_RetainLeakSubject_tag_get") +public func _bjs_RetainLeakSubject_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = RetainLeakSubject.bridgeJSLiftParameter(_self).tag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_RetainLeakSubject_tag_set") +@_cdecl("bjs_RetainLeakSubject_tag_set") +public func _bjs_RetainLeakSubject_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + RetainLeakSubject.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_RetainLeakSubject_deinit") +@_cdecl("bjs_RetainLeakSubject_deinit") +public func _bjs_RetainLeakSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension RetainLeakSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_RetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_RetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_RetainLeakSubject_wrap") +fileprivate func _bjs_RetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_RetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_RetainLeakSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_RetainLeakSubject_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_ArrayIdentityElement_init") +@_cdecl("bjs_ArrayIdentityElement_init") +public func _bjs_ArrayIdentityElement_init(_ tag: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ArrayIdentityElement(tag: Int.bridgeJSLiftParameter(tag)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArrayIdentityElement_tag_get") +@_cdecl("bjs_ArrayIdentityElement_tag_get") +public func _bjs_ArrayIdentityElement_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = ArrayIdentityElement.bridgeJSLiftParameter(_self).tag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArrayIdentityElement_tag_set") +@_cdecl("bjs_ArrayIdentityElement_tag_set") +public func _bjs_ArrayIdentityElement_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + ArrayIdentityElement.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ArrayIdentityElement_deinit") +@_cdecl("bjs_ArrayIdentityElement_deinit") +public func _bjs_ArrayIdentityElement_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ArrayIdentityElement: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ArrayIdentityElement_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ArrayIdentityElement_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayIdentityElement_wrap") +fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ArrayIdentityElement_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ArrayIdentityElement_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_OptionalHolder_init") +@_cdecl("bjs_OptionalHolder_init") +public func _bjs_OptionalHolder_init(_ nullableGreeterIsSome: Int32, _ nullableGreeterValue: UnsafeMutableRawPointer, _ undefinedNumberIsSome: Int32, _ undefinedNumberValue: Float64) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = OptionalHolder(nullableGreeter: Optional.bridgeJSLiftParameter(nullableGreeterIsSome, nullableGreeterValue), undefinedNumber: JSUndefinedOr.bridgeJSLiftParameter(undefinedNumberIsSome, undefinedNumberValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalHolder_nullableGreeter_get") +@_cdecl("bjs_OptionalHolder_nullableGreeter_get") +public func _bjs_OptionalHolder_nullableGreeter_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = OptionalHolder.bridgeJSLiftParameter(_self).nullableGreeter + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalHolder_nullableGreeter_set") +@_cdecl("bjs_OptionalHolder_nullableGreeter_set") +public func _bjs_OptionalHolder_nullableGreeter_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + OptionalHolder.bridgeJSLiftParameter(_self).nullableGreeter = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalHolder_undefinedNumber_get") +@_cdecl("bjs_OptionalHolder_undefinedNumber_get") +public func _bjs_OptionalHolder_undefinedNumber_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = OptionalHolder.bridgeJSLiftParameter(_self).undefinedNumber + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalHolder_undefinedNumber_set") +@_cdecl("bjs_OptionalHolder_undefinedNumber_set") +public func _bjs_OptionalHolder_undefinedNumber_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Float64) -> Void { + #if arch(wasm32) + OptionalHolder.bridgeJSLiftParameter(_self).undefinedNumber = JSUndefinedOr.bridgeJSLiftParameter(valueIsSome, valueValue) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalHolder_deinit") +@_cdecl("bjs_OptionalHolder_deinit") +public func _bjs_OptionalHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension OptionalHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_OptionalHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_OptionalHolder_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalHolder_wrap") +fileprivate func _bjs_OptionalHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_OptionalHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_OptionalHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_OptionalHolder_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_OptionalPropertyHolder_init") +@_cdecl("bjs_OptionalPropertyHolder_init") +public func _bjs_OptionalPropertyHolder_init(_ optionalNameIsSome: Int32, _ optionalNameBytes: Int32, _ optionalNameLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = OptionalPropertyHolder(optionalName: Optional.bridgeJSLiftParameter(optionalNameIsSome, optionalNameBytes, optionalNameLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalPropertyHolder_optionalName_get") +@_cdecl("bjs_OptionalPropertyHolder_optionalName_get") +public func _bjs_OptionalPropertyHolder_optionalName_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalName + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalPropertyHolder_optionalName_set") +@_cdecl("bjs_OptionalPropertyHolder_optionalName_set") +public func _bjs_OptionalPropertyHolder_optionalName_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalName = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalPropertyHolder_optionalAge_get") +@_cdecl("bjs_OptionalPropertyHolder_optionalAge_get") +public func _bjs_OptionalPropertyHolder_optionalAge_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalAge + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalPropertyHolder_optionalAge_set") +@_cdecl("bjs_OptionalPropertyHolder_optionalAge_set") +public func _bjs_OptionalPropertyHolder_optionalAge_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { + #if arch(wasm32) + OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalAge = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalPropertyHolder_optionalGreeter_get") +@_cdecl("bjs_OptionalPropertyHolder_optionalGreeter_get") +public func _bjs_OptionalPropertyHolder_optionalGreeter_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalGreeter + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalPropertyHolder_optionalGreeter_set") +@_cdecl("bjs_OptionalPropertyHolder_optionalGreeter_set") +public func _bjs_OptionalPropertyHolder_optionalGreeter_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalGreeter = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_OptionalPropertyHolder_deinit") +@_cdecl("bjs_OptionalPropertyHolder_deinit") +public func _bjs_OptionalPropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension OptionalPropertyHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_OptionalPropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_OptionalPropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalPropertyHolder_wrap") +fileprivate func _bjs_OptionalPropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_OptionalPropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_OptionalPropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_OptionalPropertyHolder_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_Container_init") +@_cdecl("bjs_Container_init") +public func _bjs_Container_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let _tmp_config = Optional.bridgeJSLiftParameter() + let _tmp_location = DataPoint.bridgeJSLiftParameter() + let ret = Container(location: _tmp_location, config: _tmp_config) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Container_location_get") +@_cdecl("bjs_Container_location_get") +public func _bjs_Container_location_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = Container.bridgeJSLiftParameter(_self).location + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Container_location_set") +@_cdecl("bjs_Container_location_set") +public func _bjs_Container_location_set(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Container.bridgeJSLiftParameter(_self).location = DataPoint.bridgeJSLiftParameter() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Container_config_get") +@_cdecl("bjs_Container_config_get") +public func _bjs_Container_config_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = Container.bridgeJSLiftParameter(_self).config + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Container_config_set") +@_cdecl("bjs_Container_config_set") +public func _bjs_Container_config_set(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Container.bridgeJSLiftParameter(_self).config = Optional.bridgeJSLiftParameter() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Container_deinit") +@_cdecl("bjs_Container_deinit") +public func _bjs_Container_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Container: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Container_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_Container_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Container_wrap") +fileprivate func _bjs_Container_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_Container_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_Container_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Container_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_LeakCheck_init") +@_cdecl("bjs_LeakCheck_init") +public func _bjs_LeakCheck_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = LeakCheck() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_LeakCheck_deinit") +@_cdecl("bjs_LeakCheck_deinit") +public func _bjs_LeakCheck_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension LeakCheck: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + public var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_LeakCheck_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + public consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_LeakCheck_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_LeakCheck_wrap") +fileprivate func _bjs_LeakCheck_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_LeakCheck_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_LeakCheck_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_LeakCheck_wrap_extern(pointer) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayElementObject_init") +fileprivate func bjs_ArrayElementObject_init_extern(_ idBytes: Int32, _ idLength: Int32) -> Int32 +#else +fileprivate func bjs_ArrayElementObject_init_extern(_ idBytes: Int32, _ idLength: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArrayElementObject_init(_ idBytes: Int32, _ idLength: Int32) -> Int32 { + return bjs_ArrayElementObject_init_extern(idBytes, idLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayElementObject_id_get") +fileprivate func bjs_ArrayElementObject_id_get_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_ArrayElementObject_id_get_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArrayElementObject_id_get(_ self: Int32) -> Int32 { + return bjs_ArrayElementObject_id_get_extern(self) +} + +func _$ArrayElementObject_init(_ id: String) throws(JSException) -> JSObject { + let ret0 = id.bridgeJSWithLoweredParameter { (idBytes, idLength) in + let ret = bjs_ArrayElementObject_init(idBytes, idLength) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$ArrayElementObject_id_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_ArrayElementObject_id_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsIntArrayLength_static") +fileprivate func bjs_ArraySupportImports_jsIntArrayLength_static_extern() -> Int32 +#else +fileprivate func bjs_ArraySupportImports_jsIntArrayLength_static_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsIntArrayLength_static() -> Int32 { + return bjs_ArraySupportImports_jsIntArrayLength_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripIntArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripIntArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripIntArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripIntArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripIntArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripNumberArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripNumberArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripNumberArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripNumberArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripNumberArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripStringArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripStringArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripStringArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripStringArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripStringArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripBoolArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripBoolArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripBoolArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripBoolArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripBoolArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripJSValueArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripJSValueArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripJSValueArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripJSValueArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripJSValueArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripJSObjectArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripJSObjectArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripJSObjectArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripJSObjectArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripJSObjectArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripJSClassArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripJSClassArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripJSClassArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripJSClassArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripJSClassArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static") +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static() -> Void { + return bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsSumNumberArray_static") +fileprivate func bjs_ArraySupportImports_jsSumNumberArray_static_extern() -> Float64 +#else +fileprivate func bjs_ArraySupportImports_jsSumNumberArray_static_extern() -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsSumNumberArray_static() -> Float64 { + return bjs_ArraySupportImports_jsSumNumberArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsCreateNumberArray_static") +fileprivate func bjs_ArraySupportImports_jsCreateNumberArray_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_jsCreateNumberArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_jsCreateNumberArray_static() -> Void { + return bjs_ArraySupportImports_jsCreateNumberArray_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_runJsArraySupportTests_static") +fileprivate func bjs_ArraySupportImports_runJsArraySupportTests_static_extern() -> Void +#else +fileprivate func bjs_ArraySupportImports_runJsArraySupportTests_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ArraySupportImports_runJsArraySupportTests_static() -> Void { + return bjs_ArraySupportImports_runJsArraySupportTests_static_extern() +} + +func _$ArraySupportImports_jsIntArrayLength(_ items: [Int]) throws(JSException) -> Int { + let _ = items.bridgeJSLowerParameter() + let ret = bjs_ArraySupportImports_jsIntArrayLength_static() + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$ArraySupportImports_jsRoundTripIntArray(_ items: [Int]) throws(JSException) -> [Int] { + let _ = items.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripIntArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [Int].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripNumberArray(_ values: [Double]) throws(JSException) -> [Double] { + let _ = values.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripNumberArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [Double].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripStringArray(_ values: [String]) throws(JSException) -> [String] { + let _ = values.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripStringArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [String].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripBoolArray(_ values: [Bool]) throws(JSException) -> [Bool] { + let _ = values.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripBoolArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [Bool].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripJSValueArray(_ v: [JSValue]) throws(JSException) -> [JSValue] { + let _ = v.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripJSValueArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [JSValue].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripJSObjectArray(_ values: [JSObject]) throws(JSException) -> [JSObject] { + let _ = values.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripJSObjectArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [JSObject].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripJSClassArray(_ values: [ArrayElementObject]) throws(JSException) -> [ArrayElementObject] { + let _ = values.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripJSClassArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [ArrayElementObject].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripOptionalIntArray(_ values: [Optional]) throws(JSException) -> [Optional] { + let _ = values.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [Optional].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripOptionalStringArray(_ values: [Optional]) throws(JSException) -> [Optional] { + let _ = values.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [Optional].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripOptionalBoolArray(_ values: [Optional]) throws(JSException) -> [Optional] { + let _ = values.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [Optional].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripOptionalJSValueArray(_ values: [Optional]) throws(JSException) -> [Optional] { + let _ = values.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [Optional].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripOptionalJSObjectArray(_ values: [Optional]) throws(JSException) -> [Optional] { + let _ = values.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [Optional].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsRoundTripOptionalJSClassArray(_ values: [Optional]) throws(JSException) -> [Optional] { + let _ = values.bridgeJSLowerParameter() + bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [Optional].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_jsSumNumberArray(_ values: [Double]) throws(JSException) -> Double { + let _ = values.bridgeJSLowerParameter() + let ret = bjs_ArraySupportImports_jsSumNumberArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +func _$ArraySupportImports_jsCreateNumberArray() throws(JSException) -> [Double] { + bjs_ArraySupportImports_jsCreateNumberArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [Double].bridgeJSLiftReturn() +} + +func _$ArraySupportImports_runJsArraySupportTests() throws(JSException) -> Void { + bjs_ArraySupportImports_runJsArraySupportTests_static() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripVoid_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripVoid_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripVoid_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripVoid_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripVoid_static_extern(resolveRef, rejectRef) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripNumber_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripNumber_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Float64) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripNumber_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripNumber_static(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Float64) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripNumber_static_extern(resolveRef, rejectRef, v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripBool_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBool_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBool_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBool_static(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripBool_static_extern(resolveRef, rejectRef, v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripString_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripString_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripString_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripString_static(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripString_static_extern(resolveRef, rejectRef, vBytes, vLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static_extern(resolveRef, rejectRef, vIsSome, vBytes, vLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vValue: Float64) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vValue: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vValue: Float64) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static_extern(resolveRef, rejectRef, vIsSome, vValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static_extern(resolveRef, rejectRef) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static_extern(resolveRef, rejectRef) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static_extern(resolveRef, rejectRef) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_extern(resolveRef, rejectRef, vBytes, vLength) +} + +func _$AsyncImportImports_jsAsyncRoundTripVoid() async throws(JSException) -> Void { + try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<() -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + bjs_AsyncImportImports_jsAsyncRoundTripVoid_static(resolveRef, rejectRef) + } +} + +func _$AsyncImportImports_jsAsyncRoundTripNumber(_ v: Double) async throws(JSException) -> Double { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending Double) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let vValue = v.bridgeJSLowerParameter() + bjs_AsyncImportImports_jsAsyncRoundTripNumber_static(resolveRef, rejectRef, vValue) + } + return resolved +} + +func _$AsyncImportImports_jsAsyncRoundTripBool(_ v: Bool) async throws(JSException) -> Bool { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending Bool) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let vValue = v.bridgeJSLowerParameter() + bjs_AsyncImportImports_jsAsyncRoundTripBool_static(resolveRef, rejectRef, vValue) + } + return resolved +} + +func _$AsyncImportImports_jsAsyncRoundTripString(_ v: String) async throws(JSException) -> String { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending String) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + v.bridgeJSWithLoweredParameter { (vBytes, vLength) in + bjs_AsyncImportImports_jsAsyncRoundTripString_static(resolveRef, rejectRef, vBytes, vLength) + } + } + return resolved +} + +func _$AsyncImportImports_jsAsyncRoundTripOptionalString(_ v: Optional) async throws(JSException) -> Optional { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending Optional) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + v.bridgeJSWithLoweredParameter { (vIsSome, vBytes, vLength) in + bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static(resolveRef, rejectRef, vIsSome, vBytes, vLength) + } + } + return resolved +} + +func _$AsyncImportImports_jsAsyncRoundTripOptionalNumber(_ v: Optional) async throws(JSException) -> Optional { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending Optional) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let (vIsSome, vValue) = v.bridgeJSLowerParameter() + bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static(resolveRef, rejectRef, vIsSome, vValue) + } + return resolved +} + +func _$AsyncImportImports_jsAsyncRoundTripBoolArray(_ values: [Bool]) async throws(JSException) -> [Bool] { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending [Bool]) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let _ = values.bridgeJSLowerParameter() + bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static(resolveRef, rejectRef) + } + return resolved +} + +func _$AsyncImportImports_jsAsyncRoundTripIntArray(_ values: [Double]) async throws(JSException) -> [Double] { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending [Double]) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let _ = values.bridgeJSLowerParameter() + bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static(resolveRef, rejectRef) + } + return resolved +} + +func _$AsyncImportImports_jsAsyncRoundTripStringArray(_ values: [String]) async throws(JSException) -> [String] { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending [String]) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let _ = values.bridgeJSLowerParameter() + bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static(resolveRef, rejectRef) + } + return resolved +} + +func _$AsyncImportImports_jsAsyncRoundTripFeatureFlag(_ v: FeatureFlag) async throws(JSException) -> FeatureFlag { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending FeatureFlag) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + v.bridgeJSWithLoweredParameter { (vBytes, vLength) in + bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static(resolveRef, rejectRef, vBytes, vLength) + } + } + return resolved +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyVoid_static") +fileprivate func bjs_ClosureSupportImports_jsApplyVoid_static_extern(_ callback: Int32) -> Void +#else +fileprivate func bjs_ClosureSupportImports_jsApplyVoid_static_extern(_ callback: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyVoid_static(_ callback: Int32) -> Void { + return bjs_ClosureSupportImports_jsApplyVoid_static_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyBool_static") +fileprivate func bjs_ClosureSupportImports_jsApplyBool_static_extern(_ callback: Int32) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsApplyBool_static_extern(_ callback: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyBool_static(_ callback: Int32) -> Int32 { + return bjs_ClosureSupportImports_jsApplyBool_static_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyInt_static") +fileprivate func bjs_ClosureSupportImports_jsApplyInt_static_extern(_ value: Int32, _ transform: Int32) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsApplyInt_static_extern(_ value: Int32, _ transform: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyInt_static(_ value: Int32, _ transform: Int32) -> Int32 { + return bjs_ClosureSupportImports_jsApplyInt_static_extern(value, transform) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyDouble_static") +fileprivate func bjs_ClosureSupportImports_jsApplyDouble_static_extern(_ value: Float64, _ transform: Int32) -> Float64 +#else +fileprivate func bjs_ClosureSupportImports_jsApplyDouble_static_extern(_ value: Float64, _ transform: Int32) -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyDouble_static(_ value: Float64, _ transform: Int32) -> Float64 { + return bjs_ClosureSupportImports_jsApplyDouble_static_extern(value, transform) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyString_static") +fileprivate func bjs_ClosureSupportImports_jsApplyString_static_extern(_ valueBytes: Int32, _ valueLength: Int32, _ transform: Int32) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsApplyString_static_extern(_ valueBytes: Int32, _ valueLength: Int32, _ transform: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyString_static(_ valueBytes: Int32, _ valueLength: Int32, _ transform: Int32) -> Int32 { + return bjs_ClosureSupportImports_jsApplyString_static_extern(valueBytes, valueLength, transform) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyJSObject_static") +fileprivate func bjs_ClosureSupportImports_jsApplyJSObject_static_extern(_ value: Int32, _ transform: Int32) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsApplyJSObject_static_extern(_ value: Int32, _ transform: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyJSObject_static(_ value: Int32, _ transform: Int32) -> Int32 { + return bjs_ClosureSupportImports_jsApplyJSObject_static_extern(value, transform) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsMakeIntToInt_static") +fileprivate func bjs_ClosureSupportImports_jsMakeIntToInt_static_extern(_ base: Int32) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsMakeIntToInt_static_extern(_ base: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsMakeIntToInt_static(_ base: Int32) -> Int32 { + return bjs_ClosureSupportImports_jsMakeIntToInt_static_extern(base) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsMakeDoubleToDouble_static") +fileprivate func bjs_ClosureSupportImports_jsMakeDoubleToDouble_static_extern(_ base: Float64) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsMakeDoubleToDouble_static_extern(_ base: Float64) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsMakeDoubleToDouble_static(_ base: Float64) -> Int32 { + return bjs_ClosureSupportImports_jsMakeDoubleToDouble_static_extern(base) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsMakeStringToString_static") +fileprivate func bjs_ClosureSupportImports_jsMakeStringToString_static_extern(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsMakeStringToString_static_extern(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsMakeStringToString_static(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { + return bjs_ClosureSupportImports_jsMakeStringToString_static_extern(prefixBytes, prefixLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsCallTwice_static") +fileprivate func bjs_ClosureSupportImports_jsCallTwice_static_extern(_ value: Int32, _ callback: Int32) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsCallTwice_static_extern(_ value: Int32, _ callback: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsCallTwice_static(_ value: Int32, _ callback: Int32) -> Int32 { + return bjs_ClosureSupportImports_jsCallTwice_static_extern(value, callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsCallBinary_static") +fileprivate func bjs_ClosureSupportImports_jsCallBinary_static_extern(_ callback: Int32) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsCallBinary_static_extern(_ callback: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsCallBinary_static(_ callback: Int32) -> Int32 { + return bjs_ClosureSupportImports_jsCallBinary_static_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsCallTriple_static") +fileprivate func bjs_ClosureSupportImports_jsCallTriple_static_extern(_ callback: Int32) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsCallTriple_static_extern(_ callback: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsCallTriple_static(_ callback: Int32) -> Int32 { + return bjs_ClosureSupportImports_jsCallTriple_static_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsCallAfterRelease_static") +fileprivate func bjs_ClosureSupportImports_jsCallAfterRelease_static_extern(_ callback: Int32) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsCallAfterRelease_static_extern(_ callback: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsCallAfterRelease_static(_ callback: Int32) -> Int32 { + return bjs_ClosureSupportImports_jsCallAfterRelease_static_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsOptionalInvoke_static") +fileprivate func bjs_ClosureSupportImports_jsOptionalInvoke_static_extern(_ callbackIsSome: Int32, _ callbackFuncRef: Int32) -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsOptionalInvoke_static_extern(_ callbackIsSome: Int32, _ callbackFuncRef: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsOptionalInvoke_static(_ callbackIsSome: Int32, _ callbackFuncRef: Int32) -> Int32 { + return bjs_ClosureSupportImports_jsOptionalInvoke_static_extern(callbackIsSome, callbackFuncRef) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsStoreClosure_static") +fileprivate func bjs_ClosureSupportImports_jsStoreClosure_static_extern(_ callback: Int32) -> Void +#else +fileprivate func bjs_ClosureSupportImports_jsStoreClosure_static_extern(_ callback: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsStoreClosure_static(_ callback: Int32) -> Void { + return bjs_ClosureSupportImports_jsStoreClosure_static_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsCallStoredClosure_static") +fileprivate func bjs_ClosureSupportImports_jsCallStoredClosure_static_extern() -> Void +#else +fileprivate func bjs_ClosureSupportImports_jsCallStoredClosure_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsCallStoredClosure_static() -> Void { + return bjs_ClosureSupportImports_jsCallStoredClosure_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsHeapCount_static") +fileprivate func bjs_ClosureSupportImports_jsHeapCount_static_extern() -> Int32 +#else +fileprivate func bjs_ClosureSupportImports_jsHeapCount_static_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_jsHeapCount_static() -> Int32 { + return bjs_ClosureSupportImports_jsHeapCount_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_runJsClosureSupportTests_static") +fileprivate func bjs_ClosureSupportImports_runJsClosureSupportTests_static_extern() -> Void +#else +fileprivate func bjs_ClosureSupportImports_runJsClosureSupportTests_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureSupportImports_runJsClosureSupportTests_static() -> Void { + return bjs_ClosureSupportImports_runJsClosureSupportTests_static_extern() +} + +func _$ClosureSupportImports_jsApplyVoid(_ callback: JSTypedClosure<() -> Void>) throws(JSException) -> Void { + let callbackFuncRef = callback.bridgeJSLowerParameter() + bjs_ClosureSupportImports_jsApplyVoid_static(callbackFuncRef) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$ClosureSupportImports_jsApplyBool(_ callback: JSTypedClosure<() -> Bool>) throws(JSException) -> Bool { + let callbackFuncRef = callback.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsApplyBool_static(callbackFuncRef) + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) +} + +func _$ClosureSupportImports_jsApplyInt(_ value: Int, _ transform: JSTypedClosure<(Int) -> Int>) throws(JSException) -> Int { + let valueValue = value.bridgeJSLowerParameter() + let transformFuncRef = transform.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsApplyInt_static(valueValue, transformFuncRef) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$ClosureSupportImports_jsApplyDouble(_ value: Double, _ transform: JSTypedClosure<(Double) -> Double>) throws(JSException) -> Double { + let valueValue = value.bridgeJSLowerParameter() + let transformFuncRef = transform.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsApplyDouble_static(valueValue, transformFuncRef) + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +func _$ClosureSupportImports_jsApplyString(_ value: String, _ transform: JSTypedClosure<(String) -> String>) throws(JSException) -> String { + let ret0 = value.bridgeJSWithLoweredParameter { (valueBytes, valueLength) in + let transformFuncRef = transform.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsApplyString_static(valueBytes, valueLength, transformFuncRef) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$ClosureSupportImports_jsApplyJSObject(_ value: JSObject, _ transform: JSTypedClosure<(JSObject) -> JSObject>) throws(JSException) -> JSObject { + let valueValue = value.bridgeJSLowerParameter() + let transformFuncRef = transform.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsApplyJSObject_static(valueValue, transformFuncRef) + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$ClosureSupportImports_jsMakeIntToInt(_ base: Int) throws(JSException) -> (Int) -> Int { + let baseValue = base.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsMakeIntToInt_static(baseValue) + if let error = _swift_js_take_exception() { + throw error + } + return _BJS_Closure_20BridgeJSRuntimeTestsSi_Si.bridgeJSLift(ret) +} + +func _$ClosureSupportImports_jsMakeDoubleToDouble(_ base: Double) throws(JSException) -> (Double) -> Double { + let baseValue = base.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsMakeDoubleToDouble_static(baseValue) + if let error = _swift_js_take_exception() { + throw error + } + return _BJS_Closure_20BridgeJSRuntimeTestsSd_Sd.bridgeJSLift(ret) +} + +func _$ClosureSupportImports_jsMakeStringToString(_ prefix: String) throws(JSException) -> (String) -> String { + let ret0 = prefix.bridgeJSWithLoweredParameter { (prefixBytes, prefixLength) in + let ret = bjs_ClosureSupportImports_jsMakeStringToString_static(prefixBytes, prefixLength) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return _BJS_Closure_20BridgeJSRuntimeTestsSS_SS.bridgeJSLift(ret) +} + +func _$ClosureSupportImports_jsCallTwice(_ value: Int, _ callback: JSTypedClosure<(Int) -> Void>) throws(JSException) -> Int { + let valueValue = value.bridgeJSLowerParameter() + let callbackFuncRef = callback.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsCallTwice_static(valueValue, callbackFuncRef) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$ClosureSupportImports_jsCallBinary(_ callback: JSTypedClosure<(Int, Int) -> Int>) throws(JSException) -> Int { + let callbackFuncRef = callback.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsCallBinary_static(callbackFuncRef) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$ClosureSupportImports_jsCallTriple(_ callback: JSTypedClosure<(Int, Int, Int) -> Int>) throws(JSException) -> Int { + let callbackFuncRef = callback.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsCallTriple_static(callbackFuncRef) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$ClosureSupportImports_jsCallAfterRelease(_ callback: JSTypedClosure<() -> Void>) throws(JSException) -> String { + let callbackFuncRef = callback.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsCallAfterRelease_static(callbackFuncRef) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$ClosureSupportImports_jsOptionalInvoke(_ callback: Optional Bool>>) throws(JSException) -> Bool { + let (callbackIsSome, callbackFuncRef) = callback.bridgeJSLowerParameter() + let ret = bjs_ClosureSupportImports_jsOptionalInvoke_static(callbackIsSome, callbackFuncRef) + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) +} + +func _$ClosureSupportImports_jsStoreClosure(_ callback: JSTypedClosure<() -> Void>) throws(JSException) -> Void { + let callbackFuncRef = callback.bridgeJSLowerParameter() + bjs_ClosureSupportImports_jsStoreClosure_static(callbackFuncRef) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$ClosureSupportImports_jsCallStoredClosure() throws(JSException) -> Void { + bjs_ClosureSupportImports_jsCallStoredClosure_static() + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$ClosureSupportImports_jsHeapCount() throws(JSException) -> Int { + let ret = bjs_ClosureSupportImports_jsHeapCount_static() + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$ClosureSupportImports_runJsClosureSupportTests() throws(JSException) -> Void { + bjs_ClosureSupportImports_runJsClosureSupportTests_static() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static") +fileprivate func bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static_extern() -> Void +#else +fileprivate func bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static() -> Void { + return bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static_extern() +} + +func _$DefaultArgumentImports_runJsDefaultArgumentTests() throws(JSException) -> Void { + bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static") +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static_extern() -> Void +#else +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static() -> Void { + return bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static") +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static_extern() -> Void +#else +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static() -> Void { + return bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static") +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static_extern() -> Void +#else +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static() -> Void { + return bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static") +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static_extern() -> Void +#else +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static() -> Void { + return bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static") +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static_extern() -> Void +#else +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static() -> Void { + return bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static") +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static_extern() -> Void +#else +fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static() -> Void { + return bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static_extern() +} + +func _$DictionarySupportImports_jsRoundTripDictionaryInt(_ values: [String: Int]) throws(JSException) -> [String: Int] { + let _ = values.bridgeJSLowerParameter() + bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static() + if let error = _swift_js_take_exception() { + throw error + } + return [String: Int].bridgeJSLiftReturn() +} + +func _$DictionarySupportImports_jsRoundTripDictionaryBool(_ values: [String: Bool]) throws(JSException) -> [String: Bool] { + let _ = values.bridgeJSLowerParameter() + bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static() + if let error = _swift_js_take_exception() { + throw error + } + return [String: Bool].bridgeJSLiftReturn() +} + +func _$DictionarySupportImports_jsRoundTripDictionaryDouble(_ values: [String: Double]) throws(JSException) -> [String: Double] { + let _ = values.bridgeJSLowerParameter() + bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static() + if let error = _swift_js_take_exception() { + throw error + } + return [String: Double].bridgeJSLiftReturn() +} + +func _$DictionarySupportImports_jsRoundTripDictionaryJSObject(_ values: [String: JSObject]) throws(JSException) -> [String: JSObject] { + let _ = values.bridgeJSLowerParameter() + bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static() + if let error = _swift_js_take_exception() { + throw error + } + return [String: JSObject].bridgeJSLiftReturn() +} + +func _$DictionarySupportImports_jsRoundTripDictionaryJSValue(_ values: [String: JSValue]) throws(JSException) -> [String: JSValue] { + let _ = values.bridgeJSLowerParameter() + bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static() + if let error = _swift_js_take_exception() { + throw error + } + return [String: JSValue].bridgeJSLiftReturn() +} + +func _$DictionarySupportImports_jsRoundTripDictionaryDoubleArray(_ values: [String: [Double]]) throws(JSException) -> [String: [Double]] { + let _ = values.bridgeJSLowerParameter() + bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static() + if let error = _swift_js_take_exception() { + throw error + } + return [String: [Double]].bridgeJSLiftReturn() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Foo_init") +fileprivate func bjs_Foo_init_extern(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 +#else +fileprivate func bjs_Foo_init_extern(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Foo_init(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 { + return bjs_Foo_init_extern(valueBytes, valueLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Foo_value_get") +fileprivate func bjs_Foo_value_get_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_Foo_value_get_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Foo_value_get(_ self: Int32) -> Int32 { + return bjs_Foo_value_get_extern(self) +} + +func _$Foo_init(_ value: String) throws(JSException) -> JSObject { + let ret0 = value.bridgeJSWithLoweredParameter { (valueBytes, valueLength) in + let ret = bjs_Foo_init(valueBytes, valueLength) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$Foo_value_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Foo_value_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_globalObject1_get") +fileprivate func bjs_globalObject1_get_extern() -> Void +#else +fileprivate func bjs_globalObject1_get_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_globalObject1_get() -> Void { + return bjs_globalObject1_get_extern() +} + +func _$globalObject1_get() throws(JSException) -> JSValue { + bjs_globalObject1_get() + if let error = _swift_js_take_exception() { + throw error + } + return JSValue.bridgeJSLiftReturn() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripVoid") +fileprivate func bjs_jsRoundTripVoid_extern() -> Void +#else +fileprivate func bjs_jsRoundTripVoid_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripVoid() -> Void { + return bjs_jsRoundTripVoid_extern() +} + +func _$jsRoundTripVoid() throws(JSException) -> Void { + bjs_jsRoundTripVoid() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripNumber") +fileprivate func bjs_jsRoundTripNumber_extern(_ v: Float64) -> Float64 +#else +fileprivate func bjs_jsRoundTripNumber_extern(_ v: Float64) -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripNumber(_ v: Float64) -> Float64 { + return bjs_jsRoundTripNumber_extern(v) +} + +func _$jsRoundTripNumber(_ v: Double) throws(JSException) -> Double { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_jsRoundTripNumber(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripBool") +fileprivate func bjs_jsRoundTripBool_extern(_ v: Int32) -> Int32 +#else +fileprivate func bjs_jsRoundTripBool_extern(_ v: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripBool(_ v: Int32) -> Int32 { + return bjs_jsRoundTripBool_extern(v) +} + +func _$jsRoundTripBool(_ v: Bool) throws(JSException) -> Bool { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_jsRoundTripBool(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripString") +fileprivate func bjs_jsRoundTripString_extern(_ vBytes: Int32, _ vLength: Int32) -> Int32 +#else +fileprivate func bjs_jsRoundTripString_extern(_ vBytes: Int32, _ vLength: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripString(_ vBytes: Int32, _ vLength: Int32) -> Int32 { + return bjs_jsRoundTripString_extern(vBytes, vLength) +} + +func _$jsRoundTripString(_ v: String) throws(JSException) -> String { + let ret0 = v.bridgeJSWithLoweredParameter { (vBytes, vLength) in + let ret = bjs_jsRoundTripString(vBytes, vLength) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripJSValue") +fileprivate func bjs_jsRoundTripJSValue_extern(_ vKind: Int32, _ vPayload1: Int32, _ vPayload2: Float64) -> Void +#else +fileprivate func bjs_jsRoundTripJSValue_extern(_ vKind: Int32, _ vPayload1: Int32, _ vPayload2: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripJSValue(_ vKind: Int32, _ vPayload1: Int32, _ vPayload2: Float64) -> Void { + return bjs_jsRoundTripJSValue_extern(vKind, vPayload1, vPayload2) +} + +func _$jsRoundTripJSValue(_ v: JSValue) throws(JSException) -> JSValue { + let (vKind, vPayload1, vPayload2) = v.bridgeJSLowerParameter() + bjs_jsRoundTripJSValue(vKind, vPayload1, vPayload2) + if let error = _swift_js_take_exception() { + throw error + } + return JSValue.bridgeJSLiftReturn() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrVoid") +fileprivate func bjs_jsThrowOrVoid_extern(_ shouldThrow: Int32) -> Void +#else +fileprivate func bjs_jsThrowOrVoid_extern(_ shouldThrow: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsThrowOrVoid(_ shouldThrow: Int32) -> Void { + return bjs_jsThrowOrVoid_extern(shouldThrow) +} + +func _$jsThrowOrVoid(_ shouldThrow: Bool) throws(JSException) -> Void { + let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() + bjs_jsThrowOrVoid(shouldThrowValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrNumber") +fileprivate func bjs_jsThrowOrNumber_extern(_ shouldThrow: Int32) -> Float64 +#else +fileprivate func bjs_jsThrowOrNumber_extern(_ shouldThrow: Int32) -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsThrowOrNumber(_ shouldThrow: Int32) -> Float64 { + return bjs_jsThrowOrNumber_extern(shouldThrow) +} + +func _$jsThrowOrNumber(_ shouldThrow: Bool) throws(JSException) -> Double { + let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() + let ret = bjs_jsThrowOrNumber(shouldThrowValue) + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrBool") +fileprivate func bjs_jsThrowOrBool_extern(_ shouldThrow: Int32) -> Int32 +#else +fileprivate func bjs_jsThrowOrBool_extern(_ shouldThrow: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsThrowOrBool(_ shouldThrow: Int32) -> Int32 { + return bjs_jsThrowOrBool_extern(shouldThrow) +} + +func _$jsThrowOrBool(_ shouldThrow: Bool) throws(JSException) -> Bool { + let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() + let ret = bjs_jsThrowOrBool(shouldThrowValue) + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrString") +fileprivate func bjs_jsThrowOrString_extern(_ shouldThrow: Int32) -> Int32 +#else +fileprivate func bjs_jsThrowOrString_extern(_ shouldThrow: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsThrowOrString(_ shouldThrow: Int32) -> Int32 { + return bjs_jsThrowOrString_extern(shouldThrow) +} + +func _$jsThrowOrString(_ shouldThrow: Bool) throws(JSException) -> String { + let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() + let ret = bjs_jsThrowOrString(shouldThrowValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripFeatureFlag") +fileprivate func bjs_jsRoundTripFeatureFlag_extern(_ flagBytes: Int32, _ flagLength: Int32) -> Int32 +#else +fileprivate func bjs_jsRoundTripFeatureFlag_extern(_ flagBytes: Int32, _ flagLength: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripFeatureFlag(_ flagBytes: Int32, _ flagLength: Int32) -> Int32 { + return bjs_jsRoundTripFeatureFlag_extern(flagBytes, flagLength) +} + +func _$jsRoundTripFeatureFlag(_ flag: FeatureFlag) throws(JSException) -> FeatureFlag { + let ret0 = flag.bridgeJSWithLoweredParameter { (flagBytes, flagLength) in + let ret = bjs_jsRoundTripFeatureFlag(flagBytes, flagLength) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return FeatureFlag.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_runAsyncWorks") +fileprivate func bjs_runAsyncWorks_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void +#else +fileprivate func bjs_runAsyncWorks_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_runAsyncWorks(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + return bjs_runAsyncWorks_extern(resolveRef, rejectRef) +} + +func _$runAsyncWorks() async throws(JSException) -> Void { + try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<() -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + bjs_runAsyncWorks(resolveRef, rejectRef) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_fetchWeatherData") +fileprivate func bjs_fetchWeatherData_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ cityBytes: Int32, _ cityLength: Int32) -> Void +#else +fileprivate func bjs_fetchWeatherData_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ cityBytes: Int32, _ cityLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_fetchWeatherData(_ resolveRef: Int32, _ rejectRef: Int32, _ cityBytes: Int32, _ cityLength: Int32) -> Void { + return bjs_fetchWeatherData_extern(resolveRef, rejectRef, cityBytes, cityLength) +} + +func _$fetchWeatherData(_ city: String) async throws(JSException) -> WeatherData { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending WeatherData) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + city.bridgeJSWithLoweredParameter { (cityBytes, cityLength) in + bjs_fetchWeatherData(resolveRef, rejectRef, cityBytes, cityLength) + } + } + return resolved +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs__jsWeirdFunction") +fileprivate func bjs__jsWeirdFunction_extern() -> Float64 +#else +fileprivate func bjs__jsWeirdFunction_extern() -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs__jsWeirdFunction() -> Float64 { + return bjs__jsWeirdFunction_extern() +} + +func _$_jsWeirdFunction() throws(JSException) -> Double { + let ret = bjs__jsWeirdFunction() + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_parseInt") +fileprivate func bjs_parseInt_extern(_ stringBytes: Int32, _ stringLength: Int32) -> Float64 +#else +fileprivate func bjs_parseInt_extern(_ stringBytes: Int32, _ stringLength: Int32) -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_parseInt(_ stringBytes: Int32, _ stringLength: Int32) -> Float64 { + return bjs_parseInt_extern(stringBytes, stringLength) +} + +func _$parseInt(_ string: String) throws(JSException) -> Double { + let ret0 = string.bridgeJSWithLoweredParameter { (stringBytes, stringLength) in + let ret = bjs_parseInt(stringBytes, stringLength) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_init") +fileprivate func bjs_JsGreeter_init_extern(_ nameBytes: Int32, _ nameLength: Int32, _ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 +#else +fileprivate func bjs_JsGreeter_init_extern(_ nameBytes: Int32, _ nameLength: Int32, _ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JsGreeter_init(_ nameBytes: Int32, _ nameLength: Int32, _ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { + return bjs_JsGreeter_init_extern(nameBytes, nameLength, prefixBytes, prefixLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_name_get") +fileprivate func bjs_JsGreeter_name_get_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_JsGreeter_name_get_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JsGreeter_name_get(_ self: Int32) -> Int32 { + return bjs_JsGreeter_name_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_prefix_get") +fileprivate func bjs_JsGreeter_prefix_get_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_JsGreeter_prefix_get_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JsGreeter_prefix_get(_ self: Int32) -> Int32 { + return bjs_JsGreeter_prefix_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_name_set") +fileprivate func bjs_JsGreeter_name_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void +#else +fileprivate func bjs_JsGreeter_name_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JsGreeter_name_set(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { + return bjs_JsGreeter_name_set_extern(self, newValueBytes, newValueLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_greet") +fileprivate func bjs_JsGreeter_greet_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_JsGreeter_greet_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JsGreeter_greet(_ self: Int32) -> Int32 { + return bjs_JsGreeter_greet_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_changeName") +fileprivate func bjs_JsGreeter_changeName_extern(_ self: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void +#else +fileprivate func bjs_JsGreeter_changeName_extern(_ self: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JsGreeter_changeName(_ self: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { + return bjs_JsGreeter_changeName_extern(self, nameBytes, nameLength) +} + +func _$JsGreeter_init(_ name: String, _ prefix: String) throws(JSException) -> JSObject { + let ret0 = name.bridgeJSWithLoweredParameter { (nameBytes, nameLength) in + let ret1 = prefix.bridgeJSWithLoweredParameter { (prefixBytes, prefixLength) in + let ret = bjs_JsGreeter_init(nameBytes, nameLength, prefixBytes, prefixLength) + return ret + } + return ret1 + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$JsGreeter_name_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_JsGreeter_name_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$JsGreeter_prefix_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_JsGreeter_prefix_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$JsGreeter_name_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + newValue.bridgeJSWithLoweredParameter { (newValueBytes, newValueLength) in + bjs_JsGreeter_name_set(selfValue, newValueBytes, newValueLength) + } + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$JsGreeter_greet(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_JsGreeter_greet(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$JsGreeter_changeName(_ self: JSObject, _ name: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + name.bridgeJSWithLoweredParameter { (nameBytes, nameLength) in + bjs_JsGreeter_changeName(selfValue, nameBytes, nameLength) + } + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_temperature_get") +fileprivate func bjs_WeatherData_temperature_get_extern(_ self: Int32) -> Float64 +#else +fileprivate func bjs_WeatherData_temperature_get_extern(_ self: Int32) -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_WeatherData_temperature_get(_ self: Int32) -> Float64 { + return bjs_WeatherData_temperature_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_description_get") +fileprivate func bjs_WeatherData_description_get_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_WeatherData_description_get_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_WeatherData_description_get(_ self: Int32) -> Int32 { + return bjs_WeatherData_description_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_humidity_get") +fileprivate func bjs_WeatherData_humidity_get_extern(_ self: Int32) -> Float64 +#else +fileprivate func bjs_WeatherData_humidity_get_extern(_ self: Int32) -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_WeatherData_humidity_get(_ self: Int32) -> Float64 { + return bjs_WeatherData_humidity_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_temperature_set") +fileprivate func bjs_WeatherData_temperature_set_extern(_ self: Int32, _ newValue: Float64) -> Void +#else +fileprivate func bjs_WeatherData_temperature_set_extern(_ self: Int32, _ newValue: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_WeatherData_temperature_set(_ self: Int32, _ newValue: Float64) -> Void { + return bjs_WeatherData_temperature_set_extern(self, newValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_description_set") +fileprivate func bjs_WeatherData_description_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void +#else +fileprivate func bjs_WeatherData_description_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_WeatherData_description_set(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { + return bjs_WeatherData_description_set_extern(self, newValueBytes, newValueLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_humidity_set") +fileprivate func bjs_WeatherData_humidity_set_extern(_ self: Int32, _ newValue: Float64) -> Void +#else +fileprivate func bjs_WeatherData_humidity_set_extern(_ self: Int32, _ newValue: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_WeatherData_humidity_set(_ self: Int32, _ newValue: Float64) -> Void { + return bjs_WeatherData_humidity_set_extern(self, newValue) +} + +func _$WeatherData_temperature_get(_ self: JSObject) throws(JSException) -> Double { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_WeatherData_temperature_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +func _$WeatherData_description_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_WeatherData_description_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$WeatherData_humidity_get(_ self: JSObject) throws(JSException) -> Double { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_WeatherData_humidity_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +func _$WeatherData_temperature_set(_ self: JSObject, _ newValue: Double) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_WeatherData_temperature_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$WeatherData_description_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + newValue.bridgeJSWithLoweredParameter { (newValueBytes, newValueLength) in + bjs_WeatherData_description_set(selfValue, newValueBytes, newValueLength) + } + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$WeatherData_humidity_set(_ self: JSObject, _ newValue: Double) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_WeatherData_humidity_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs__WeirdClass_init") +fileprivate func bjs__WeirdClass_init_extern() -> Int32 +#else +fileprivate func bjs__WeirdClass_init_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs__WeirdClass_init() -> Int32 { + return bjs__WeirdClass_init_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs__WeirdClass_method_with_dashes") +fileprivate func bjs__WeirdClass_method_with_dashes_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs__WeirdClass_method_with_dashes_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs__WeirdClass_method_with_dashes(_ self: Int32) -> Int32 { + return bjs__WeirdClass_method_with_dashes_extern(self) +} + +func _$_WeirdClass_init() throws(JSException) -> JSObject { + let ret = bjs__WeirdClass_init() + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$_WeirdClass_method_with_dashes(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs__WeirdClass_method_with_dashes(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_init") +fileprivate func bjs_StaticBox_init_extern(_ value: Float64) -> Int32 +#else +fileprivate func bjs_StaticBox_init_extern(_ value: Float64) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_StaticBox_init(_ value: Float64) -> Int32 { + return bjs_StaticBox_init_extern(value) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_create_static") +fileprivate func bjs_StaticBox_create_static_extern(_ value: Float64) -> Int32 +#else +fileprivate func bjs_StaticBox_create_static_extern(_ value: Float64) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_StaticBox_create_static(_ value: Float64) -> Int32 { + return bjs_StaticBox_create_static_extern(value) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_value_static") +fileprivate func bjs_StaticBox_value_static_extern() -> Float64 +#else +fileprivate func bjs_StaticBox_value_static_extern() -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_StaticBox_value_static() -> Float64 { + return bjs_StaticBox_value_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_makeDefault_static") +fileprivate func bjs_StaticBox_makeDefault_static_extern() -> Int32 +#else +fileprivate func bjs_StaticBox_makeDefault_static_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_StaticBox_makeDefault_static() -> Int32 { + return bjs_StaticBox_makeDefault_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_with_dashes_static") +fileprivate func bjs_StaticBox_with_dashes_static_extern() -> Int32 +#else +fileprivate func bjs_StaticBox_with_dashes_static_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_StaticBox_with_dashes_static() -> Int32 { + return bjs_StaticBox_with_dashes_static_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_value") +fileprivate func bjs_StaticBox_value_extern(_ self: Int32) -> Float64 +#else +fileprivate func bjs_StaticBox_value_extern(_ self: Int32) -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_StaticBox_value(_ self: Int32) -> Float64 { + return bjs_StaticBox_value_extern(self) +} + +func _$StaticBox_init(_ value: Double) throws(JSException) -> JSObject { + let valueValue = value.bridgeJSLowerParameter() + let ret = bjs_StaticBox_init(valueValue) + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$StaticBox_create(_ value: Double) throws(JSException) -> StaticBox { + let valueValue = value.bridgeJSLowerParameter() + let ret = bjs_StaticBox_create_static(valueValue) + if let error = _swift_js_take_exception() { + throw error + } + return StaticBox.bridgeJSLiftReturn(ret) +} + +func _$StaticBox_value() throws(JSException) -> Double { + let ret = bjs_StaticBox_value_static() + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +func _$StaticBox_makeDefault() throws(JSException) -> StaticBox { + let ret = bjs_StaticBox_makeDefault_static() + if let error = _swift_js_take_exception() { + throw error + } + return StaticBox.bridgeJSLiftReturn(ret) +} + +func _$StaticBox_with_dashes() throws(JSException) -> StaticBox { + let ret = bjs_StaticBox_with_dashes_static() + if let error = _swift_js_take_exception() { + throw error + } + return StaticBox.bridgeJSLiftReturn(ret) +} + +func _$StaticBox_value(_ self: JSObject) throws(JSException) -> Double { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_StaticBox_value(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_init") +fileprivate func bjs_Animal_init_extern(_ nameBytes: Int32, _ nameLength: Int32, _ age: Float64, _ isCat: Int32) -> Int32 +#else +fileprivate func bjs_Animal_init_extern(_ nameBytes: Int32, _ nameLength: Int32, _ age: Float64, _ isCat: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Animal_init(_ nameBytes: Int32, _ nameLength: Int32, _ age: Float64, _ isCat: Int32) -> Int32 { + return bjs_Animal_init_extern(nameBytes, nameLength, age, isCat) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_name_get") +fileprivate func bjs_Animal_name_get_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_Animal_name_get_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Animal_name_get(_ self: Int32) -> Int32 { + return bjs_Animal_name_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_age_get") +fileprivate func bjs_Animal_age_get_extern(_ self: Int32) -> Float64 +#else +fileprivate func bjs_Animal_age_get_extern(_ self: Int32) -> Float64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Animal_age_get(_ self: Int32) -> Float64 { + return bjs_Animal_age_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_isCat_get") +fileprivate func bjs_Animal_isCat_get_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_Animal_isCat_get_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Animal_isCat_get(_ self: Int32) -> Int32 { + return bjs_Animal_isCat_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_name_set") +fileprivate func bjs_Animal_name_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void +#else +fileprivate func bjs_Animal_name_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Animal_name_set(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { + return bjs_Animal_name_set_extern(self, newValueBytes, newValueLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_age_set") +fileprivate func bjs_Animal_age_set_extern(_ self: Int32, _ newValue: Float64) -> Void +#else +fileprivate func bjs_Animal_age_set_extern(_ self: Int32, _ newValue: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Animal_age_set(_ self: Int32, _ newValue: Float64) -> Void { + return bjs_Animal_age_set_extern(self, newValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_isCat_set") +fileprivate func bjs_Animal_isCat_set_extern(_ self: Int32, _ newValue: Int32) -> Void +#else +fileprivate func bjs_Animal_isCat_set_extern(_ self: Int32, _ newValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Animal_isCat_set(_ self: Int32, _ newValue: Int32) -> Void { + return bjs_Animal_isCat_set_extern(self, newValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_bark") +fileprivate func bjs_Animal_bark_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_Animal_bark_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Animal_bark(_ self: Int32) -> Int32 { + return bjs_Animal_bark_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_getIsCat") +fileprivate func bjs_Animal_getIsCat_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_Animal_getIsCat_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Animal_getIsCat(_ self: Int32) -> Int32 { + return bjs_Animal_getIsCat_extern(self) +} + +func _$Animal_init(_ name: String, _ age: Double, _ isCat: Bool) throws(JSException) -> JSObject { + let ret0 = name.bridgeJSWithLoweredParameter { (nameBytes, nameLength) in + let ageValue = age.bridgeJSLowerParameter() + let isCatValue = isCat.bridgeJSLowerParameter() + let ret = bjs_Animal_init(nameBytes, nameLength, ageValue, isCatValue) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$Animal_name_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Animal_name_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$Animal_age_get(_ self: JSObject) throws(JSException) -> Double { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Animal_age_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Double.bridgeJSLiftReturn(ret) +} + +func _$Animal_isCat_get(_ self: JSObject) throws(JSException) -> Bool { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Animal_isCat_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) +} + +func _$Animal_name_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + newValue.bridgeJSWithLoweredParameter { (newValueBytes, newValueLength) in + bjs_Animal_name_set(selfValue, newValueBytes, newValueLength) + } + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$Animal_age_set(_ self: JSObject, _ newValue: Double) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_Animal_age_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$Animal_isCat_set(_ self: JSObject, _ newValue: Bool) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let newValueValue = newValue.bridgeJSLowerParameter() + bjs_Animal_isCat_set(selfValue, newValueValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$Animal_bark(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Animal_bark(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +func _$Animal_getIsCat(_ self: JSObject) throws(JSException) -> Bool { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Animal_getIsCat(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static") +fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() -> Void +#else +fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static() -> Void { + return bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() +} + +func _$IdentityModeSupportImports_runJsIdentityModeSupportTests() throws(JSException) -> Void { + bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsTranslatePoint") +fileprivate func bjs_jsTranslatePoint_extern(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 +#else +fileprivate func bjs_jsTranslatePoint_extern(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsTranslatePoint(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 { + return bjs_jsTranslatePoint_extern(point, dx, dy) +} + +func _$jsTranslatePoint(_ point: Point, _ dx: Int, _ dy: Int) throws(JSException) -> Point { + let pointObjectId = point.bridgeJSLowerParameter() + let dxValue = dx.bridgeJSLowerParameter() + let dyValue = dy.bridgeJSLowerParameter() + let ret = bjs_jsTranslatePoint(pointObjectId, dxValue, dyValue) + if let error = _swift_js_take_exception() { + throw error + } + return Point.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt_static") +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt_static_extern(_ v: Int32) -> Int32 +#else +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt_static_extern(_ v: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt_static(_ v: Int32) -> Int32 { + return bjs_IntegerTypesSupportImports_jsRoundTripInt_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripUInt_static") +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt_static_extern(_ v: Int32) -> Int32 +#else +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt_static_extern(_ v: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt_static(_ v: Int32) -> Int32 { + return bjs_IntegerTypesSupportImports_jsRoundTripUInt_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt8_static") +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt8_static_extern(_ v: Int32) -> Int32 +#else +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt8_static_extern(_ v: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt8_static(_ v: Int32) -> Int32 { + return bjs_IntegerTypesSupportImports_jsRoundTripInt8_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static") +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static_extern(_ v: Int32) -> Int32 +#else +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static_extern(_ v: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static(_ v: Int32) -> Int32 { + return bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt16_static") +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt16_static_extern(_ v: Int32) -> Int32 +#else +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt16_static_extern(_ v: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt16_static(_ v: Int32) -> Int32 { + return bjs_IntegerTypesSupportImports_jsRoundTripInt16_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static") +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static_extern(_ v: Int32) -> Int32 +#else +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static_extern(_ v: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static(_ v: Int32) -> Int32 { + return bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt32_static") +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt32_static_extern(_ v: Int32) -> Int32 +#else +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt32_static_extern(_ v: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt32_static(_ v: Int32) -> Int32 { + return bjs_IntegerTypesSupportImports_jsRoundTripInt32_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static") +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static_extern(_ v: Int32) -> Int32 +#else +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static_extern(_ v: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static(_ v: Int32) -> Int32 { + return bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt64_static") +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt64_static_extern(_ v: Int64) -> Int64 +#else +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt64_static_extern(_ v: Int64) -> Int64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt64_static(_ v: Int64) -> Int64 { + return bjs_IntegerTypesSupportImports_jsRoundTripInt64_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static") +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static_extern(_ v: Int64) -> Int64 +#else +fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static_extern(_ v: Int64) -> Int64 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static(_ v: Int64) -> Int64 { + return bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static") +fileprivate func bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static_extern() -> Void +#else +fileprivate func bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static() -> Void { + return bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static_extern() +} + +func _$IntegerTypesSupportImports_jsRoundTripInt(_ v: Int) throws(JSException) -> Int { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_IntegerTypesSupportImports_jsRoundTripInt_static(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) +} + +func _$IntegerTypesSupportImports_jsRoundTripUInt(_ v: UInt) throws(JSException) -> UInt { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_IntegerTypesSupportImports_jsRoundTripUInt_static(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return UInt.bridgeJSLiftReturn(ret) +} + +func _$IntegerTypesSupportImports_jsRoundTripInt8(_ v: Int8) throws(JSException) -> Int8 { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_IntegerTypesSupportImports_jsRoundTripInt8_static(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int8.bridgeJSLiftReturn(ret) +} + +func _$IntegerTypesSupportImports_jsRoundTripUInt8(_ v: UInt8) throws(JSException) -> UInt8 { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return UInt8.bridgeJSLiftReturn(ret) +} + +func _$IntegerTypesSupportImports_jsRoundTripInt16(_ v: Int16) throws(JSException) -> Int16 { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_IntegerTypesSupportImports_jsRoundTripInt16_static(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int16.bridgeJSLiftReturn(ret) +} + +func _$IntegerTypesSupportImports_jsRoundTripUInt16(_ v: UInt16) throws(JSException) -> UInt16 { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return UInt16.bridgeJSLiftReturn(ret) +} + +func _$IntegerTypesSupportImports_jsRoundTripInt32(_ v: Int32) throws(JSException) -> Int32 { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_IntegerTypesSupportImports_jsRoundTripInt32_static(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int32.bridgeJSLiftReturn(ret) +} + +func _$IntegerTypesSupportImports_jsRoundTripUInt32(_ v: UInt32) throws(JSException) -> UInt32 { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return UInt32.bridgeJSLiftReturn(ret) +} + +func _$IntegerTypesSupportImports_jsRoundTripInt64(_ v: Int64) throws(JSException) -> Int64 { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_IntegerTypesSupportImports_jsRoundTripInt64_static(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return Int64.bridgeJSLiftReturn(ret) +} + +func _$IntegerTypesSupportImports_jsRoundTripUInt64(_ v: UInt64) throws(JSException) -> UInt64 { + let vValue = v.bridgeJSLowerParameter() + let ret = bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static(vValue) + if let error = _swift_js_take_exception() { + throw error + } + return UInt64.bridgeJSLiftReturn(ret) +} + +func _$IntegerTypesSupportImports_runJsIntegerTypesSupportTests() throws(JSException) -> Void { + bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_init") +fileprivate func bjs_JSClassWithArrayMembers_init_extern() -> Int32 +#else +fileprivate func bjs_JSClassWithArrayMembers_init_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JSClassWithArrayMembers_init() -> Int32 { + return bjs_JSClassWithArrayMembers_init_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_numbers_get") +fileprivate func bjs_JSClassWithArrayMembers_numbers_get_extern(_ self: Int32) -> Void +#else +fileprivate func bjs_JSClassWithArrayMembers_numbers_get_extern(_ self: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JSClassWithArrayMembers_numbers_get(_ self: Int32) -> Void { + return bjs_JSClassWithArrayMembers_numbers_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_labels_get") +fileprivate func bjs_JSClassWithArrayMembers_labels_get_extern(_ self: Int32) -> Void +#else +fileprivate func bjs_JSClassWithArrayMembers_labels_get_extern(_ self: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JSClassWithArrayMembers_labels_get(_ self: Int32) -> Void { + return bjs_JSClassWithArrayMembers_labels_get_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_numbers_set") +fileprivate func bjs_JSClassWithArrayMembers_numbers_set_extern(_ self: Int32) -> Void +#else +fileprivate func bjs_JSClassWithArrayMembers_numbers_set_extern(_ self: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JSClassWithArrayMembers_numbers_set(_ self: Int32) -> Void { + return bjs_JSClassWithArrayMembers_numbers_set_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_labels_set") +fileprivate func bjs_JSClassWithArrayMembers_labels_set_extern(_ self: Int32) -> Void +#else +fileprivate func bjs_JSClassWithArrayMembers_labels_set_extern(_ self: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JSClassWithArrayMembers_labels_set(_ self: Int32) -> Void { + return bjs_JSClassWithArrayMembers_labels_set_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_concatNumbers") +fileprivate func bjs_JSClassWithArrayMembers_concatNumbers_extern(_ self: Int32) -> Void +#else +fileprivate func bjs_JSClassWithArrayMembers_concatNumbers_extern(_ self: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JSClassWithArrayMembers_concatNumbers(_ self: Int32) -> Void { + return bjs_JSClassWithArrayMembers_concatNumbers_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_concatLabels") +fileprivate func bjs_JSClassWithArrayMembers_concatLabels_extern(_ self: Int32) -> Void +#else +fileprivate func bjs_JSClassWithArrayMembers_concatLabels_extern(_ self: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JSClassWithArrayMembers_concatLabels(_ self: Int32) -> Void { + return bjs_JSClassWithArrayMembers_concatLabels_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_firstLabel") +fileprivate func bjs_JSClassWithArrayMembers_firstLabel_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_JSClassWithArrayMembers_firstLabel_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JSClassWithArrayMembers_firstLabel(_ self: Int32) -> Int32 { + return bjs_JSClassWithArrayMembers_firstLabel_extern(self) +} + +func _$JSClassWithArrayMembers_init(_ numbers: [Int], _ labels: [String]) throws(JSException) -> JSObject { + let _ = labels.bridgeJSLowerParameter() + let _ = numbers.bridgeJSLowerParameter() + let ret = bjs_JSClassWithArrayMembers_init() + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$JSClassWithArrayMembers_numbers_get(_ self: JSObject) throws(JSException) -> [Int] { + let selfValue = self.bridgeJSLowerParameter() + bjs_JSClassWithArrayMembers_numbers_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return [Int].bridgeJSLiftReturn() +} + +func _$JSClassWithArrayMembers_labels_get(_ self: JSObject) throws(JSException) -> [String] { + let selfValue = self.bridgeJSLowerParameter() + bjs_JSClassWithArrayMembers_labels_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return [String].bridgeJSLiftReturn() +} + +func _$JSClassWithArrayMembers_numbers_set(_ self: JSObject, _ newValue: [Int]) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let _ = newValue.bridgeJSLowerParameter() + bjs_JSClassWithArrayMembers_numbers_set(selfValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$JSClassWithArrayMembers_labels_set(_ self: JSObject, _ newValue: [String]) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let _ = newValue.bridgeJSLowerParameter() + bjs_JSClassWithArrayMembers_labels_set(selfValue) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$JSClassWithArrayMembers_concatNumbers(_ self: JSObject, _ values: [Int]) throws(JSException) -> [Int] { + let selfValue = self.bridgeJSLowerParameter() + let _ = values.bridgeJSLowerParameter() + bjs_JSClassWithArrayMembers_concatNumbers(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return [Int].bridgeJSLiftReturn() +} + +func _$JSClassWithArrayMembers_concatLabels(_ self: JSObject, _ values: [String]) throws(JSException) -> [String] { + let selfValue = self.bridgeJSLowerParameter() + let _ = values.bridgeJSLowerParameter() + bjs_JSClassWithArrayMembers_concatLabels(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return [String].bridgeJSLiftReturn() +} + +func _$JSClassWithArrayMembers_firstLabel(_ self: JSObject, _ values: [String]) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let _ = values.bridgeJSLowerParameter() + let ret = bjs_JSClassWithArrayMembers_firstLabel(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static") +fileprivate func bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static_extern() -> Int32 +#else +fileprivate func bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static() -> Int32 { + return bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static_extern() +} + +func _$JSClassSupportImports_makeJSClassWithArrayMembers(_ numbers: [Int], _ labels: [String]) throws(JSException) -> JSClassWithArrayMembers { + let _ = labels.bridgeJSLowerParameter() + let _ = numbers.bridgeJSLowerParameter() + let ret = bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static() + if let error = _swift_js_take_exception() { + throw error + } + return JSClassWithArrayMembers.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_MyJSClassInternal_init") +fileprivate func bjs_MyJSClassInternal_init_extern() -> Int32 +#else +fileprivate func bjs_MyJSClassInternal_init_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_MyJSClassInternal_init() -> Int32 { + return bjs_MyJSClassInternal_init_extern() +} + +func _$MyJSClassInternal_init() throws(JSException) -> JSObject { + let ret = bjs_MyJSClassInternal_init() + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_MyJSClassPublic_init") +fileprivate func bjs_MyJSClassPublic_init_extern() -> Int32 +#else +fileprivate func bjs_MyJSClassPublic_init_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_MyJSClassPublic_init() -> Int32 { + return bjs_MyJSClassPublic_init_extern() +} + +func _$MyJSClassPublic_init() throws(JSException) -> JSObject { + let ret = bjs_MyJSClassPublic_init() + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_MyJSClassPackage_init") +fileprivate func bjs_MyJSClassPackage_init_extern() -> Int32 +#else +fileprivate func bjs_MyJSClassPackage_init_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_MyJSClassPackage_init() -> Int32 { + return bjs_MyJSClassPackage_init_extern() +} + +func _$MyJSClassPackage_init() throws(JSException) -> JSObject { + let ret = bjs_MyJSClassPackage_init() + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsFunctionWithPackageAccess") +fileprivate func bjs_jsFunctionWithPackageAccess_extern() -> Void +#else +fileprivate func bjs_jsFunctionWithPackageAccess_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsFunctionWithPackageAccess() -> Void { + return bjs_jsFunctionWithPackageAccess_extern() +} + +func _$jsFunctionWithPackageAccess() throws(JSException) -> Void { + bjs_jsFunctionWithPackageAccess() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsFunctionWithPublicAccess") +fileprivate func bjs_jsFunctionWithPublicAccess_extern() -> Void +#else +fileprivate func bjs_jsFunctionWithPublicAccess_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsFunctionWithPublicAccess() -> Void { + return bjs_jsFunctionWithPublicAccess_extern() +} + +func _$jsFunctionWithPublicAccess() throws(JSException) -> Void { + bjs_jsFunctionWithPublicAccess() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsFunctionWithInternalAccess") +fileprivate func bjs_jsFunctionWithInternalAccess_extern() -> Void +#else +fileprivate func bjs_jsFunctionWithInternalAccess_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsFunctionWithInternalAccess() -> Void { + return bjs_jsFunctionWithInternalAccess_extern() +} + +func _$jsFunctionWithInternalAccess() throws(JSException) -> Void { + bjs_jsFunctionWithInternalAccess() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsFunctionWithFilePrivateAccess") +fileprivate func bjs_jsFunctionWithFilePrivateAccess_extern() -> Void +#else +fileprivate func bjs_jsFunctionWithFilePrivateAccess_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsFunctionWithFilePrivateAccess() -> Void { + return bjs_jsFunctionWithFilePrivateAccess_extern() +} + +func _$jsFunctionWithFilePrivateAccess() throws(JSException) -> Void { + bjs_jsFunctionWithFilePrivateAccess() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsFunctionWithPrivateAccess") +fileprivate func bjs_jsFunctionWithPrivateAccess_extern() -> Void +#else +fileprivate func bjs_jsFunctionWithPrivateAccess_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsFunctionWithPrivateAccess() -> Void { + return bjs_jsFunctionWithPrivateAccess_extern() +} + +func _$jsFunctionWithPrivateAccess() throws(JSException) -> Void { + bjs_jsFunctionWithPrivateAccess() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static") +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void +#else +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { + return bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static_extern(valueIsSome, valueValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static") +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void +#else +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { + return bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static_extern(valueIsSome, valueValue) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static") +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static_extern(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void +#else +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static_extern(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { + return bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static_extern(nameIsSome, nameBytes, nameLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static") +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static_extern(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void +#else +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static_extern(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { + return bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static_extern(nameIsSome, nameBytes, nameLength) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static") +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static_extern(_ v: Int32) -> Void +#else +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static_extern(_ v: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static(_ v: Int32) -> Void { + return bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static") +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static_extern(_ v: Int32) -> Void +#else +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static_extern(_ v: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static(_ v: Int32) -> Void { + return bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static") +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static_extern(_ v: Int32) -> Void +#else +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static_extern(_ v: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static(_ v: Int32) -> Void { + return bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static") +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static_extern(_ v: Int32) -> Void +#else +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static_extern(_ v: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static(_ v: Int32) -> Void { + return bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static_extern(v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_runJsOptionalSupportTests_static") +fileprivate func bjs_OptionalSupportImports_runJsOptionalSupportTests_static_extern() -> Void +#else +fileprivate func bjs_OptionalSupportImports_runJsOptionalSupportTests_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_OptionalSupportImports_runJsOptionalSupportTests_static() -> Void { + return bjs_OptionalSupportImports_runJsOptionalSupportTests_static_extern() +} + +func _$OptionalSupportImports_jsRoundTripOptionalNumberNull(_ value: Optional) throws(JSException) -> Optional { + let (valueIsSome, valueValue) = value.bridgeJSLowerParameter() + bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static(valueIsSome, valueValue) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturnFromSideChannel() +} + +func _$OptionalSupportImports_jsRoundTripOptionalNumberUndefined(_ value: JSUndefinedOr) throws(JSException) -> JSUndefinedOr { + let (valueIsSome, valueValue) = value.bridgeJSLowerParameter() + bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static(valueIsSome, valueValue) + if let error = _swift_js_take_exception() { + throw error + } + return JSUndefinedOr.bridgeJSLiftReturnFromSideChannel() +} + +func _$OptionalSupportImports_jsRoundTripOptionalStringNull(_ name: Optional) throws(JSException) -> Optional { + name.bridgeJSWithLoweredParameter { (nameIsSome, nameBytes, nameLength) in + bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static(nameIsSome, nameBytes, nameLength) + } + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturnFromSideChannel() +} + +func _$OptionalSupportImports_jsRoundTripOptionalStringUndefined(_ name: JSUndefinedOr) throws(JSException) -> JSUndefinedOr { + name.bridgeJSWithLoweredParameter { (nameIsSome, nameBytes, nameLength) in + bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static(nameIsSome, nameBytes, nameLength) + } + if let error = _swift_js_take_exception() { + throw error + } + return JSUndefinedOr.bridgeJSLiftReturnFromSideChannel() +} + +func _$OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull(_ v: Optional<[JSValue]>) throws(JSException) -> Optional<[JSValue]> { + let vIsSome = v.bridgeJSLowerParameter() + bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static(vIsSome) + if let error = _swift_js_take_exception() { + throw error + } + return Optional<[JSValue]>.bridgeJSLiftReturn() +} + +func _$OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined(_ v: JSUndefinedOr<[JSValue]>) throws(JSException) -> JSUndefinedOr<[JSValue]> { + let vIsSome = v.bridgeJSLowerParameter() + bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static(vIsSome) + if let error = _swift_js_take_exception() { + throw error + } + return JSUndefinedOr<[JSValue]>.bridgeJSLiftReturn() +} + +func _$OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull(_ v: Optional<[String: String]>) throws(JSException) -> Optional<[String: String]> { + let vIsSome = v.bridgeJSLowerParameter() + bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static(vIsSome) + if let error = _swift_js_take_exception() { + throw error + } + return Optional<[String: String]>.bridgeJSLiftReturn() +} + +func _$OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined(_ v: JSUndefinedOr<[String: String]>) throws(JSException) -> JSUndefinedOr<[String: String]> { + let vIsSome = v.bridgeJSLowerParameter() + bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static(vIsSome) + if let error = _swift_js_take_exception() { + throw error + } + return JSUndefinedOr<[String: String]>.bridgeJSLiftReturn() +} + +func _$OptionalSupportImports_runJsOptionalSupportTests() throws(JSException) -> Void { + bjs_OptionalSupportImports_runJsOptionalSupportTests_static() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_gc") +fileprivate func bjs_gc_extern() -> Void +#else +fileprivate func bjs_gc_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_gc() -> Void { + return bjs_gc_extern() +} + +func _$gc() throws(JSException) -> Void { + bjs_gc() + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftClassSupportImports_jsRoundTripGreeter_static") +fileprivate func bjs_SwiftClassSupportImports_jsRoundTripGreeter_static_extern(_ greeter: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer +#else +fileprivate func bjs_SwiftClassSupportImports_jsRoundTripGreeter_static_extern(_ greeter: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_SwiftClassSupportImports_jsRoundTripGreeter_static(_ greeter: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + return bjs_SwiftClassSupportImports_jsRoundTripGreeter_static_extern(greeter) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftClassSupportImports_jsRoundTripUUID_static") +fileprivate func bjs_SwiftClassSupportImports_jsRoundTripUUID_static_extern(_ uuid: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer +#else +fileprivate func bjs_SwiftClassSupportImports_jsRoundTripUUID_static_extern(_ uuid: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_SwiftClassSupportImports_jsRoundTripUUID_static(_ uuid: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + return bjs_SwiftClassSupportImports_jsRoundTripUUID_static_extern(uuid) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static") +fileprivate func bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static_extern(_ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer +#else +fileprivate func bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static_extern(_ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static(_ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + return bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static_extern(greeterIsSome, greeterPointer) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static") +fileprivate func bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static_extern(_ value: UnsafeMutableRawPointer) -> Void +#else +fileprivate func bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static_extern(_ value: UnsafeMutableRawPointer) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static(_ value: UnsafeMutableRawPointer) -> Void { + return bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static_extern(value) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static") +fileprivate func bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static_extern(_ valueIsSome: Int32, _ valuePointer: UnsafeMutableRawPointer) -> Void +#else +fileprivate func bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static_extern(_ valueIsSome: Int32, _ valuePointer: UnsafeMutableRawPointer) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static(_ valueIsSome: Int32, _ valuePointer: UnsafeMutableRawPointer) -> Void { + return bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static_extern(valueIsSome, valuePointer) +} + +func _$SwiftClassSupportImports_jsRoundTripGreeter(_ greeter: Greeter) throws(JSException) -> Greeter { + let greeterPointer = greeter.bridgeJSLowerParameter() + let ret = bjs_SwiftClassSupportImports_jsRoundTripGreeter_static(greeterPointer) + if let error = _swift_js_take_exception() { + throw error + } + return Greeter.bridgeJSLiftReturn(ret) +} + +func _$SwiftClassSupportImports_jsRoundTripUUID(_ uuid: UUID) throws(JSException) -> UUID { + let uuidPointer = uuid.bridgeJSLowerParameter() + let ret = bjs_SwiftClassSupportImports_jsRoundTripUUID_static(uuidPointer) + if let error = _swift_js_take_exception() { + throw error + } + return UUID.bridgeJSLiftReturn(ret) +} + +func _$SwiftClassSupportImports_jsRoundTripOptionalGreeter(_ greeter: Optional) throws(JSException) -> Optional { + let (greeterIsSome, greeterPointer) = greeter.bridgeJSLowerParameter() + let ret = bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static(greeterIsSome, greeterPointer) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn(ret) +} + +func _$SwiftClassSupportImports_jsConsumeLeakCheck(_ value: LeakCheck) throws(JSException) -> Void { + let valuePointer = value.bridgeJSLowerParameter() + bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static(valuePointer) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$SwiftClassSupportImports_jsConsumeOptionalLeakCheck(_ value: Optional) throws(JSException) -> Void { + let (valueIsSome, valuePointer) = value.bridgeJSLowerParameter() + bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static(valueIsSome, valuePointer) + if let error = _swift_js_take_exception() { + throw error + } +} \ No newline at end of file diff --git a/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json new file mode 100644 index 000000000..ccca68ceb --- /dev/null +++ b/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json @@ -0,0 +1,20907 @@ +{ + "exported" : { + "classes" : [ + { + "methods" : [ + { + "abiName" : "bjs_ClosureSupportExports_static_makeIntToInt", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "makeIntToInt", + "parameters" : [ + { + "label" : "_", + "name" : "base", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + }, + "staticContext" : { + "className" : { + "_0" : "ClosureSupportExports" + } + } + }, + { + "abiName" : "bjs_ClosureSupportExports_static_makeDoubleToDouble", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "makeDoubleToDouble", + "parameters" : [ + { + "label" : "_", + "name" : "base", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "double" : { + + } + } + ], + "returnType" : { + "double" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + }, + "staticContext" : { + "className" : { + "_0" : "ClosureSupportExports" + } + } + }, + { + "abiName" : "bjs_ClosureSupportExports_static_makeStringToString", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "makeStringToString", + "parameters" : [ + { + "label" : "_", + "name" : "prefix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + }, + "staticContext" : { + "className" : { + "_0" : "ClosureSupportExports" + } + } + }, + { + "abiName" : "bjs_ClosureSupportExports_static_makeJSIntToInt", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "makeJSIntToInt", + "parameters" : [ + { + "label" : "_", + "name" : "base", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + }, + "staticContext" : { + "className" : { + "_0" : "ClosureSupportExports" + } + } + }, + { + "abiName" : "bjs_ClosureSupportExports_static_makeJSDoubleToDouble", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "makeJSDoubleToDouble", + "parameters" : [ + { + "label" : "_", + "name" : "base", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "double" : { + + } + } + ], + "returnType" : { + "double" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + }, + "staticContext" : { + "className" : { + "_0" : "ClosureSupportExports" + } + } + }, + { + "abiName" : "bjs_ClosureSupportExports_static_makeJSStringToString", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "makeJSStringToString", + "parameters" : [ + { + "label" : "_", + "name" : "prefix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + }, + "staticContext" : { + "className" : { + "_0" : "ClosureSupportExports" + } + } + } + ], + "name" : "ClosureSupportExports", + "properties" : [ + + ], + "swiftCallName" : "ClosureSupportExports" + }, + { + "constructor" : { + "abiName" : "bjs_DefaultArgumentConstructorDefaults_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "defaultValue" : { + "string" : { + "_0" : "Default" + } + }, + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "defaultValue" : { + "int" : { + "_0" : 42 + } + }, + "label" : "count", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "defaultValue" : { + "bool" : { + "_0" : true + } + }, + "label" : "enabled", + "name" : "enabled", + "type" : { + "bool" : { + + } + } + }, + { + "defaultValue" : { + "enumCase" : { + "_0" : "Status", + "_1" : "success" + } + }, + "label" : "status", + "name" : "status", + "type" : { + "caseEnum" : { + "_0" : "Status" + } + } + }, + { + "defaultValue" : { + "null" : { + + } + }, + "label" : "tag", + "name" : "tag", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_DefaultArgumentConstructorDefaults_describe", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "describe", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "DefaultArgumentConstructorDefaults", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "enabled", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "status", + "type" : { + "caseEnum" : { + "_0" : "Status" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "DefaultArgumentConstructorDefaults" + }, + { + "constructor" : { + "abiName" : "bjs_Greeter_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ] + }, + "explicitAccessControl" : "public", + "methods" : [ + { + "abiName" : "bjs_Greeter_greet", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "greet", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_Greeter_changeName", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "changeName", + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_Greeter_greetWith", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "greetWith", + "parameters" : [ + { + "label" : "greeter", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "label" : "customGreeting", + "name" : "customGreeting", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests7GreeterC_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_Greeter_makeFormatter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeFormatter", + "parameters" : [ + { + "label" : "suffix", + "name" : "suffix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_Greeter_static_makeCreator", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "makeCreator", + "parameters" : [ + { + "label" : "defaultName", + "name" : "defaultName", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_7GreeterC", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + }, + "staticContext" : { + "className" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_Greeter_makeCustomGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeCustomGreeter", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests7GreeterC_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_Greeter_greetEnthusiastically", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "greetEnthusiastically", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_Greeter_static_greetAnonymously", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "greetAnonymously", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "className" : { + "_0" : "Greeter" + } + } + } + ], + "name" : "Greeter", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "prefix", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "nameCount", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "defaultGreeting", + "staticContext" : { + "className" : { + "_0" : "Greeter" + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "Greeter" + }, + { + "methods" : [ + { + "abiName" : "bjs_Calculator_square", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "square", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_Calculator_add", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "add", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "b", + "name" : "b", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "Calculator", + "properties" : [ + + ], + "swiftCallName" : "Calculator" + }, + { + "explicitAccessControl" : "internal", + "methods" : [ + + ], + "name" : "InternalGreeter", + "properties" : [ + + ], + "swiftCallName" : "InternalGreeter" + }, + { + "explicitAccessControl" : "public", + "methods" : [ + + ], + "name" : "PublicGreeter", + "properties" : [ + + ], + "swiftCallName" : "PublicGreeter" + }, + { + "explicitAccessControl" : "package", + "methods" : [ + + ], + "name" : "PackageGreeter", + "properties" : [ + + ], + "swiftCallName" : "PackageGreeter" + }, + { + "constructor" : { + "abiName" : "bjs_Utils_Converter_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_Utils_Converter_toString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "toString", + "namespace" : [ + "Utils" + ], + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "Converter", + "namespace" : [ + "Utils" + ], + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "precision", + "namespace" : [ + "Utils" + ], + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "Utils.Converter" + }, + { + "constructor" : { + "abiName" : "bjs_Networking_API_HTTPServer_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_Networking_API_HTTPServer_call", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "call", + "namespace" : [ + "Networking", + "API" + ], + "parameters" : [ + { + "label" : "_", + "name" : "method", + "type" : { + "caseEnum" : { + "_0" : "Networking.API.Method" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "HTTPServer", + "namespace" : [ + "Networking", + "API" + ], + "properties" : [ + + ], + "swiftCallName" : "Networking.API.HTTPServer" + }, + { + "constructor" : { + "abiName" : "bjs___Swift_Foundation_UUID_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs___Swift_Foundation_UUID_uuidString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "uuidString", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs___Swift_Foundation_UUID_static_fromValue", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "fromValue", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "UUID" + } + }, + "staticContext" : { + "className" : { + "_0" : "__Swift_Foundation_UUID" + } + } + } + ], + "name" : "UUID", + "namespace" : [ + "__Swift", + "Foundation" + ], + "properties" : [ + { + "isReadonly" : true, + "isStatic" : true, + "name" : "placeholder", + "staticContext" : { + "className" : { + "_0" : "__Swift_Foundation_UUID" + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "UUID" + }, + { + "constructor" : { + "abiName" : "bjs_Networking_APIV2_Internal_TestServer_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_Networking_APIV2_Internal_TestServer_call", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "call", + "namespace" : [ + "Networking", + "APIV2", + "Internal" + ], + "parameters" : [ + { + "label" : "_", + "name" : "method", + "type" : { + "caseEnum" : { + "_0" : "Internal.SupportedMethod" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "TestServer", + "namespace" : [ + "Networking", + "APIV2", + "Internal" + ], + "properties" : [ + + ], + "swiftCallName" : "Internal.TestServer" + }, + { + "constructor" : { + "abiName" : "bjs_SimplePropertyHolder_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "SimplePropertyHolder", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "SimplePropertyHolder" + }, + { + "constructor" : { + "abiName" : "bjs_PropertyHolder_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "intValue", + "name" : "intValue", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "floatValue", + "name" : "floatValue", + "type" : { + "float" : { + + } + } + }, + { + "label" : "doubleValue", + "name" : "doubleValue", + "type" : { + "double" : { + + } + } + }, + { + "label" : "boolValue", + "name" : "boolValue", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "stringValue", + "name" : "stringValue", + "type" : { + "string" : { + + } + } + }, + { + "label" : "jsObject", + "name" : "jsObject", + "type" : { + "jsObject" : { + + } + } + }, + { + "label" : "sibling", + "name" : "sibling", + "type" : { + "swiftHeapObject" : { + "_0" : "SimplePropertyHolder" + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_PropertyHolder_getAllValues", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getAllValues", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "PropertyHolder", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "intValue", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "floatValue", + "type" : { + "float" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "doubleValue", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "boolValue", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "stringValue", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "readonlyInt", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "readonlyFloat", + "type" : { + "float" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "readonlyDouble", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "readonlyBool", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "readonlyString", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "jsObject", + "type" : { + "jsObject" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "sibling", + "type" : { + "swiftHeapObject" : { + "_0" : "SimplePropertyHolder" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "lazyValue", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "computedReadonly", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "computedReadWrite", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "observedProperty", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "PropertyHolder" + }, + { + "methods" : [ + { + "abiName" : "bjs_MathUtils_static_add", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "add", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "b", + "name" : "b", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "staticContext" : { + "className" : { + "_0" : "MathUtils" + } + } + }, + { + "abiName" : "bjs_MathUtils_static_substract", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "substract", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "b", + "name" : "b", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "staticContext" : { + "className" : { + "_0" : "MathUtils" + } + } + } + ], + "name" : "MathUtils", + "properties" : [ + + ], + "swiftCallName" : "MathUtils" + }, + { + "constructor" : { + "abiName" : "bjs_StaticPropertyHolder_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + + ], + "name" : "StaticPropertyHolder", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : true, + "name" : "staticConstant", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "staticVariable", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "staticString", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "staticBool", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "staticFloat", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "float" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "staticDouble", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "computedProperty", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "readOnlyComputed", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "optionalString", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "optionalInt", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "jsObjectProperty", + "staticContext" : { + "className" : { + "_0" : "StaticPropertyHolder" + } + }, + "type" : { + "jsObject" : { + + } + } + } + ], + "swiftCallName" : "StaticPropertyHolder" + }, + { + "constructor" : { + "abiName" : "bjs_DataProcessorManager_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "processor", + "name" : "processor", + "type" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_DataProcessorManager_incrementByAmount", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "incrementByAmount", + "parameters" : [ + { + "label" : "_", + "name" : "amount", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorLabel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorLabel", + "parameters" : [ + { + "label" : "_", + "name" : "prefix", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "suffix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_isProcessorEven", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "isProcessorEven", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorLabel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorLabel", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getCurrentValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getCurrentValue", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_incrementBoth", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "incrementBoth", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getBackupValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getBackupValue", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_hasBackup", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "hasBackup", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorOptionalTag", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorOptionalTag", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorOptionalTag", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorOptionalTag", + "parameters" : [ + { + "label" : "_", + "name" : "tag", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorOptionalCount", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorOptionalCount", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorOptionalCount", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorOptionalCount", + "parameters" : [ + { + "label" : "_", + "name" : "count", + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorDirection", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorDirection", + "parameters" : [ + { + "label" : "_", + "name" : "direction", + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorTheme", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorTheme", + "parameters" : [ + { + "label" : "_", + "name" : "theme", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorHttpStatus", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorHttpStatus", + "parameters" : [ + { + "label" : "_", + "name" : "status", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_getProcessorAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getProcessorAPIResult", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_DataProcessorManager_setProcessorAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setProcessorAPIResult", + "parameters" : [ + { + "label" : "_", + "name" : "apiResult", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "DataProcessorManager", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "processor", + "type" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "backupProcessor", + "type" : { + "nullable" : { + "_0" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "DataProcessorManager" + }, + { + "constructor" : { + "abiName" : "bjs_SwiftDataProcessor_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_SwiftDataProcessor_increment", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "increment", + "parameters" : [ + { + "label" : "by", + "name" : "amount", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_getValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getValue", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_setLabelElements", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setLabelElements", + "parameters" : [ + { + "label" : "_", + "name" : "labelPrefix", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "labelSuffix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_getLabel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getLabel", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_isEven", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "isEven", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_processGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_createGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createGreeter", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_processOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "greeter", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_createOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createOptionalGreeter", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_handleAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "handleAPIResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_SwiftDataProcessor_getAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getAPIResult", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + } + ], + "name" : "SwiftDataProcessor", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalTag", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalCount", + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "direction", + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalTheme", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "httpStatus", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "apiResult", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "helper", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalHelper", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "SwiftDataProcessor" + }, + { + "methods" : [ + { + "abiName" : "bjs_ProtocolReturnTests_static_createNativeProcessor", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "createNativeProcessor", + "parameters" : [ + + ], + "returnType" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + }, + "staticContext" : { + "className" : { + "_0" : "ProtocolReturnTests" + } + } + }, + { + "abiName" : "bjs_ProtocolReturnTests_static_createNativeProcessorOptional", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "createNativeProcessorOptional", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "className" : { + "_0" : "ProtocolReturnTests" + } + } + }, + { + "abiName" : "bjs_ProtocolReturnTests_static_createNativeProcessorNil", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "createNativeProcessorNil", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "className" : { + "_0" : "ProtocolReturnTests" + } + } + }, + { + "abiName" : "bjs_ProtocolReturnTests_static_createNativeProcessorArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "createNativeProcessorArray", + "parameters" : [ + + ], + "returnType" : { + "array" : { + "_0" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + } + } + }, + "staticContext" : { + "className" : { + "_0" : "ProtocolReturnTests" + } + } + }, + { + "abiName" : "bjs_ProtocolReturnTests_static_createNativeProcessorDictionary", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "createNativeProcessorDictionary", + "parameters" : [ + + ], + "returnType" : { + "dictionary" : { + "_0" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + } + } + }, + "staticContext" : { + "className" : { + "_0" : "ProtocolReturnTests" + } + } + } + ], + "name" : "ProtocolReturnTests", + "properties" : [ + + ], + "swiftCallName" : "ProtocolReturnTests" + }, + { + "constructor" : { + "abiName" : "bjs_TextProcessor_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "transform", + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_TextProcessor_process", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "process", + "parameters" : [ + { + "label" : "_", + "name" : "text", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processWithCustom", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processWithCustom", + "parameters" : [ + { + "label" : "_", + "name" : "text", + "type" : { + "string" : { + + } + } + }, + { + "label" : "customTransform", + "name" : "customTransform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSiSSSd_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + { + "string" : { + + } + }, + { + "double" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_getTransform", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getTransform", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalString", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSqSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalInt", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalInt", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSqSi_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq7GreeterC_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeOptionalStringFormatter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeOptionalStringFormatter", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSqSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeOptionalGreeterCreator", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeOptionalGreeterCreator", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_Sq7GreeterC", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_TextProcessor_processDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processDirection", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests9DirectionO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "caseEnum" : { + "_0" : "Direction" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processTheme", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests5ThemeO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processHttpStatus", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests10HttpStatusO_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_TextProcessor_processAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processAPIResult", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests9APIResultO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeDirectionChecker", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeDirectionChecker", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests9DirectionO_Sb", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "caseEnum" : { + "_0" : "Direction" + } + } + ], + "returnType" : { + "bool" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeThemeValidator", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeThemeValidator", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests5ThemeO_Sb", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + ], + "returnType" : { + "bool" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeStatusCodeExtractor", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeStatusCodeExtractor", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests10HttpStatusO_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeAPIResultHandler", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultHandler", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests9APIResultO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalDirection", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq9DirectionO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalTheme", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq5ThemeO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalAPIResult", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq9APIResultO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeOptionalDirectionFormatter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeOptionalDirectionFormatter", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq9DirectionO_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_TextProcessor_processDataProcessor", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processDataProcessor", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests13DataProcessorP_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_TextProcessor_makeDataProcessorFactory", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeDataProcessorFactory", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_13DataProcessorP", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_TextProcessor_roundtripDataProcessor", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripDataProcessor", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + } + ], + "returnType" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + } + ], + "returnType" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_TextProcessor_processOptionalDataProcessor", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalDataProcessor", + "parameters" : [ + { + "label" : "_", + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq13DataProcessorP_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "swiftProtocol" : { + "_0" : "DataProcessor" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "TextProcessor", + "properties" : [ + + ], + "swiftCallName" : "TextProcessor" + }, + { + "constructor" : { + "abiName" : "bjs_IdentityTestSubject_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "IdentityTestSubject", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "currentValue", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "IdentityTestSubject" + }, + { + "constructor" : { + "abiName" : "bjs_RetainLeakSubject_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "tag", + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "RetainLeakSubject", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "RetainLeakSubject" + }, + { + "constructor" : { + "abiName" : "bjs_ArrayIdentityElement_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "tag", + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "ArrayIdentityElement", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "ArrayIdentityElement" + }, + { + "constructor" : { + "abiName" : "bjs_OptionalHolder_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "nullableGreeter", + "name" : "nullableGreeter", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + }, + { + "label" : "undefinedNumber", + "name" : "undefinedNumber", + "type" : { + "nullable" : { + "_0" : { + "double" : { + + } + }, + "_1" : "undefined" + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "OptionalHolder", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "nullableGreeter", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "undefinedNumber", + "type" : { + "nullable" : { + "_0" : { + "double" : { + + } + }, + "_1" : "undefined" + } + } + } + ], + "swiftCallName" : "OptionalHolder" + }, + { + "constructor" : { + "abiName" : "bjs_OptionalPropertyHolder_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "optionalName", + "name" : "optionalName", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "OptionalPropertyHolder", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalName", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalAge", + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "optionalGreeter", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "OptionalPropertyHolder" + }, + { + "constructor" : { + "abiName" : "bjs_Container_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "location", + "name" : "location", + "type" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + }, + { + "label" : "config", + "name" : "config", + "type" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "Config" + } + }, + "_1" : "null" + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "Container", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "location", + "type" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "config", + "type" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "Config" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "Container" + }, + { + "constructor" : { + "abiName" : "bjs_LeakCheck_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "explicitAccessControl" : "public", + "methods" : [ + + ], + "name" : "LeakCheck", + "properties" : [ + + ], + "swiftCallName" : "LeakCheck" + } + ], + "enums" : [ + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "ArraySupportExports", + "staticMethods" : [ + { + "abiName" : "bjs_ArraySupportExports_static_roundTripIntArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripIntArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripStringArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripStringArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripDoubleArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripDoubleArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripBoolArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripBoolArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripUnsafeRawPointerArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripUnsafeRawPointerArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeRawPointer" + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeRawPointer" + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripUnsafeMutableRawPointerArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripUnsafeMutableRawPointerArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutableRawPointer" + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutableRawPointer" + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOpaquePointerArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOpaquePointerArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "unsafePointer" : { + "_0" : { + "kind" : "opaquePointer" + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "unsafePointer" : { + "_0" : { + "kind" : "opaquePointer" + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripUnsafePointerArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripUnsafePointerArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafePointer", + "pointee" : "UInt8" + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafePointer", + "pointee" : "UInt8" + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripUnsafeMutablePointerArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripUnsafeMutablePointerArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutablePointer", + "pointee" : "UInt8" + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutablePointer", + "pointee" : "UInt8" + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripJSValueArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripJSValueArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripJSObjectArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripJSObjectArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "jsObject" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsObject" : { + + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripCaseEnumArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripCaseEnumArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripStringRawValueEnumArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripStringRawValueEnumArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripIntRawValueEnumArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripIntRawValueEnumArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripInt64RawValueEnumArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripInt64RawValueEnumArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripUInt64RawValueEnumArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripUInt64RawValueEnumArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "rawValueEnum" : { + "_0" : "SessionId", + "_1" : "UInt64" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "rawValueEnum" : { + "_0" : "SessionId", + "_1" : "UInt64" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripStructArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripStructArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripSwiftClassArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripSwiftClassArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripNamespacedSwiftClassArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripNamespacedSwiftClassArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Utils.Converter" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Utils.Converter" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripProtocolArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripProtocolArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "swiftProtocol" : { + "_0" : "ArrayElementProtocol" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "swiftProtocol" : { + "_0" : "ArrayElementProtocol" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripJSClassArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripJSClassArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalIntArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalIntArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalStringArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalStringArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalJSObjectArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalJSObjectArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalCaseEnumArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalCaseEnumArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalStringRawValueEnumArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalStringRawValueEnumArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalIntRawValueEnumArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalIntRawValueEnumArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalInt64RawValueEnumArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalInt64RawValueEnumArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + }, + "_1" : "null" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalUInt64RawValueEnumArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalUInt64RawValueEnumArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "SessionId", + "_1" : "UInt64" + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "SessionId", + "_1" : "UInt64" + } + }, + "_1" : "null" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalStructArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalStructArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + }, + "_1" : "null" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalSwiftClassArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalSwiftClassArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalJSClassArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalJSClassArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + }, + "_1" : "null" + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripNestedIntArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripNestedIntArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripNestedStringArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripNestedStringArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripNestedDoubleArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripNestedDoubleArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripNestedBoolArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripNestedBoolArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripNestedStructArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripNestedStructArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripNestedCaseEnumArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripNestedCaseEnumArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_roundTripNestedSwiftClassArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripNestedSwiftClassArray", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_multiArrayFirst", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "multiArrayFirst", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "a", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "label" : "_", + "name" : "b", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_multiArraySecond", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "multiArraySecond", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "a", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "label" : "_", + "name" : "b", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_multiOptionalArrayFirst", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "multiOptionalArrayFirst", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "a", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" + } + } + }, + { + "label" : "_", + "name" : "b", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + }, + { + "abiName" : "bjs_ArraySupportExports_static_multiOptionalArraySecond", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "multiOptionalArraySecond", + "namespace" : [ + "ArraySupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "a", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" + } + } + }, + { + "label" : "_", + "name" : "b", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "ArraySupportExports" + } + } + } + ], + "staticProperties" : [ + + ], + "swiftCallName" : "ArraySupportExports", + "tsFullPath" : "ArraySupportExports" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "DefaultArgumentExports", + "staticMethods" : [ + { + "abiName" : "bjs_DefaultArgumentExports_static_testStringDefault", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "testStringDefault", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "string" : { + "_0" : "Hello World" + } + }, + "label" : "message", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_testIntDefault", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "testIntDefault", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "int" : { + "_0" : 42 + } + }, + "label" : "count", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_testBoolDefault", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "testBoolDefault", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "bool" : { + "_0" : true + } + }, + "label" : "flag", + "name" : "flag", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_testOptionalDefault", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "testOptionalDefault", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "null" : { + + } + }, + "label" : "name", + "name" : "name", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_testMultipleDefaults", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "testMultipleDefaults", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "string" : { + "_0" : "Default Title" + } + }, + "label" : "title", + "name" : "title", + "type" : { + "string" : { + + } + } + }, + { + "defaultValue" : { + "int" : { + "_0" : -10 + } + }, + "label" : "count", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "defaultValue" : { + "bool" : { + "_0" : false + } + }, + "label" : "enabled", + "name" : "enabled", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_testSimpleEnumDefault", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "testSimpleEnumDefault", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "enumCase" : { + "_0" : "Status", + "_1" : "success" + } + }, + "label" : "status", + "name" : "status", + "type" : { + "caseEnum" : { + "_0" : "Status" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Status" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_testDirectionDefault", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "testDirectionDefault", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "enumCase" : { + "_0" : "Direction", + "_1" : "north" + } + }, + "label" : "direction", + "name" : "direction", + "type" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_testRawStringEnumDefault", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "testRawStringEnumDefault", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "enumCase" : { + "_0" : "Theme", + "_1" : "light" + } + }, + "label" : "theme", + "name" : "theme", + "type" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_testComplexInit", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "testComplexInit", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "objectWithArguments" : { + "_0" : "Greeter", + "_1" : [ + { + "string" : { + "_0" : "DefaultGreeter" + } + } + ] + } + }, + "label" : "greeter", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_testEmptyInit", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "testEmptyInit", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "object" : { + "_0" : "StaticPropertyHolder" + } + }, + "label" : "_", + "name" : "object", + "type" : { + "swiftHeapObject" : { + "_0" : "StaticPropertyHolder" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "StaticPropertyHolder" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_createConstructorDefaults", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "createConstructorDefaults", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "string" : { + "_0" : "Default" + } + }, + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "defaultValue" : { + "int" : { + "_0" : 42 + } + }, + "label" : "count", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "defaultValue" : { + "bool" : { + "_0" : true + } + }, + "label" : "enabled", + "name" : "enabled", + "type" : { + "bool" : { + + } + } + }, + { + "defaultValue" : { + "enumCase" : { + "_0" : "Status", + "_1" : "success" + } + }, + "label" : "status", + "name" : "status", + "type" : { + "caseEnum" : { + "_0" : "Status" + } + } + }, + { + "defaultValue" : { + "null" : { + + } + }, + "label" : "tag", + "name" : "tag", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "DefaultArgumentConstructorDefaults" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_describeConstructorDefaults", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "describeConstructorDefaults", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftHeapObject" : { + "_0" : "DefaultArgumentConstructorDefaults" + } + } + } + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_arrayWithDefault", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "arrayWithDefault", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "array" : { + "_0" : [ + { + "int" : { + "_0" : 1 + } + }, + { + "int" : { + "_0" : 2 + } + }, + { + "int" : { + "_0" : 3 + } + } + ] + } + }, + "label" : "_", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_arrayWithOptionalDefault", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "arrayWithOptionalDefault", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "null" : { + + } + }, + "label" : "_", + "name" : "values", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + }, + { + "abiName" : "bjs_DefaultArgumentExports_static_arrayMixedDefaults", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "arrayMixedDefaults", + "namespace" : [ + "DefaultArgumentExports" + ], + "parameters" : [ + { + "defaultValue" : { + "string" : { + "_0" : "Sum" + } + }, + "label" : "prefix", + "name" : "prefix", + "type" : { + "string" : { + + } + } + }, + { + "defaultValue" : { + "array" : { + "_0" : [ + { + "int" : { + "_0" : 10 + } + }, + { + "int" : { + "_0" : 20 + } + } + ] + } + }, + "label" : "values", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "defaultValue" : { + "string" : { + "_0" : "!" + } + }, + "label" : "suffix", + "name" : "suffix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "DefaultArgumentExports" + } + } + } + ], + "staticProperties" : [ + + ], + "swiftCallName" : "DefaultArgumentExports", + "tsFullPath" : "DefaultArgumentExports" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "north" + }, + { + "associatedValues" : [ + + ], + "name" : "south" + }, + { + "associatedValues" : [ + + ], + "name" : "east" + }, + { + "associatedValues" : [ + + ], + "name" : "west" + } + ], + "emitStyle" : "const", + "name" : "Direction", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Direction", + "tsFullPath" : "Direction" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "loading" + }, + { + "associatedValues" : [ + + ], + "name" : "success" + }, + { + "associatedValues" : [ + + ], + "name" : "error" + } + ], + "emitStyle" : "const", + "name" : "Status", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Status", + "tsFullPath" : "Status" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "light", + "rawValue" : "light" + }, + { + "associatedValues" : [ + + ], + "name" : "dark", + "rawValue" : "dark" + }, + { + "associatedValues" : [ + + ], + "name" : "auto", + "rawValue" : "auto" + } + ], + "emitStyle" : "const", + "name" : "Theme", + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Theme", + "tsFullPath" : "Theme" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "ok", + "rawValue" : "200" + }, + { + "associatedValues" : [ + + ], + "name" : "notFound", + "rawValue" : "404" + }, + { + "associatedValues" : [ + + ], + "name" : "serverError", + "rawValue" : "500" + }, + { + "associatedValues" : [ + + ], + "name" : "unknown", + "rawValue" : "-1" + } + ], + "emitStyle" : "const", + "name" : "HttpStatus", + "rawType" : "Int", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "HttpStatus", + "tsFullPath" : "HttpStatus" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "tiny", + "rawValue" : "1024" + }, + { + "associatedValues" : [ + + ], + "name" : "small", + "rawValue" : "10240" + }, + { + "associatedValues" : [ + + ], + "name" : "medium", + "rawValue" : "102400" + }, + { + "associatedValues" : [ + + ], + "name" : "large", + "rawValue" : "1048576" + } + ], + "emitStyle" : "const", + "name" : "FileSize", + "rawType" : "Int64", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "FileSize", + "tsFullPath" : "FileSize" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "none", + "rawValue" : "0" + }, + { + "associatedValues" : [ + + ], + "name" : "active", + "rawValue" : "9876543210" + }, + { + "associatedValues" : [ + + ], + "name" : "expired", + "rawValue" : "1234567890" + } + ], + "emitStyle" : "const", + "name" : "SessionId", + "rawType" : "UInt64", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "SessionId", + "tsFullPath" : "SessionId" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "rough", + "rawValue" : "0.1" + }, + { + "associatedValues" : [ + + ], + "name" : "normal", + "rawValue" : "0.01" + }, + { + "associatedValues" : [ + + ], + "name" : "fine", + "rawValue" : "0.001" + } + ], + "emitStyle" : "const", + "name" : "Precision", + "rawType" : "Float", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Precision", + "tsFullPath" : "Precision" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "quarter", + "rawValue" : "0.25" + }, + { + "associatedValues" : [ + + ], + "name" : "half", + "rawValue" : "0.5" + }, + { + "associatedValues" : [ + + ], + "name" : "golden", + "rawValue" : "1.618" + } + ], + "emitStyle" : "const", + "name" : "Ratio", + "rawType" : "Double", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Ratio", + "tsFullPath" : "Ratio" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "north" + }, + { + "associatedValues" : [ + + ], + "name" : "south" + }, + { + "associatedValues" : [ + + ], + "name" : "east" + }, + { + "associatedValues" : [ + + ], + "name" : "west" + } + ], + "emitStyle" : "tsEnum", + "name" : "TSDirection", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "TSDirection", + "tsFullPath" : "TSDirection" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "light", + "rawValue" : "light" + }, + { + "associatedValues" : [ + + ], + "name" : "dark", + "rawValue" : "dark" + }, + { + "associatedValues" : [ + + ], + "name" : "auto", + "rawValue" : "auto" + } + ], + "emitStyle" : "tsEnum", + "name" : "TSTheme", + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "TSTheme", + "tsFullPath" : "TSTheme" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Utils", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Utils", + "tsFullPath" : "Utils" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "StringUtils", + "namespace" : [ + "Utils" + ], + "staticMethods" : [ + { + "abiName" : "bjs_Utils_StringUtils_static_uppercase", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "uppercase", + "namespace" : [ + "Utils", + "StringUtils" + ], + "parameters" : [ + { + "label" : "_", + "name" : "text", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "Utils.StringUtils" + } + } + }, + { + "abiName" : "bjs_Utils_StringUtils_static_lowercase", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "lowercase", + "namespace" : [ + "Utils", + "StringUtils" + ], + "parameters" : [ + { + "label" : "_", + "name" : "text", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "Utils.StringUtils" + } + } + } + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Utils.StringUtils", + "tsFullPath" : "Utils.StringUtils" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Networking", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Networking", + "tsFullPath" : "Networking" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "API", + "namespace" : [ + "Networking" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Networking.API", + "tsFullPath" : "Networking.API" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "get" + }, + { + "associatedValues" : [ + + ], + "name" : "post" + }, + { + "associatedValues" : [ + + ], + "name" : "put" + }, + { + "associatedValues" : [ + + ], + "name" : "delete" + } + ], + "emitStyle" : "const", + "name" : "Method", + "namespace" : [ + "Networking", + "API" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Networking.API.Method", + "tsFullPath" : "Networking.API.Method" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Configuration", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Configuration", + "tsFullPath" : "Configuration" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "debug", + "rawValue" : "debug" + }, + { + "associatedValues" : [ + + ], + "name" : "info", + "rawValue" : "info" + }, + { + "associatedValues" : [ + + ], + "name" : "warning", + "rawValue" : "warning" + }, + { + "associatedValues" : [ + + ], + "name" : "error", + "rawValue" : "error" + } + ], + "emitStyle" : "const", + "name" : "LogLevel", + "namespace" : [ + "Configuration" + ], + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Configuration.LogLevel", + "tsFullPath" : "Configuration.LogLevel" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "http", + "rawValue" : "80" + }, + { + "associatedValues" : [ + + ], + "name" : "https", + "rawValue" : "443" + }, + { + "associatedValues" : [ + + ], + "name" : "development", + "rawValue" : "3000" + } + ], + "emitStyle" : "const", + "name" : "Port", + "namespace" : [ + "Configuration" + ], + "rawType" : "Int", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Configuration.Port", + "tsFullPath" : "Configuration.Port" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Internal", + "namespace" : [ + "Networking", + "APIV2" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Internal", + "tsFullPath" : "Networking.APIV2.Internal" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "get" + }, + { + "associatedValues" : [ + + ], + "name" : "post" + } + ], + "emitStyle" : "const", + "name" : "SupportedMethod", + "namespace" : [ + "Networking", + "APIV2", + "Internal" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Internal.SupportedMethod", + "tsFullPath" : "Networking.APIV2.Internal.SupportedMethod" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + { + "type" : { + "bool" : { + + } + } + } + ], + "name" : "flag" + }, + { + "associatedValues" : [ + { + "type" : { + "float" : { + + } + } + } + ], + "name" : "rate" + }, + { + "associatedValues" : [ + { + "type" : { + "double" : { + + } + } + } + ], + "name" : "precise" + }, + { + "associatedValues" : [ + + ], + "name" : "info" + } + ], + "emitStyle" : "const", + "name" : "APIResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "APIResult", + "tsFullPath" : "APIResult" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "error" + }, + { + "associatedValues" : [ + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "location" + }, + { + "associatedValues" : [ + { + "type" : { + "bool" : { + + } + } + }, + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "status" + }, + { + "associatedValues" : [ + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + } + ], + "name" : "coordinates" + }, + { + "associatedValues" : [ + { + "type" : { + "bool" : { + + } + } + }, + { + "type" : { + "bool" : { + + } + } + }, + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "double" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "comprehensive" + }, + { + "associatedValues" : [ + + ], + "name" : "info" + } + ], + "emitStyle" : "const", + "name" : "ComplexResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "ComplexResult", + "tsFullPath" : "ComplexResult" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Utilities", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Utilities", + "tsFullPath" : "Utilities" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + { + "type" : { + "bool" : { + + } + } + }, + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "status" + } + ], + "emitStyle" : "const", + "name" : "Result", + "namespace" : [ + "Utilities" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Utilities.Result", + "tsFullPath" : "Utilities.Result" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "API", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "API", + "tsFullPath" : "API" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + }, + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "failure" + } + ], + "emitStyle" : "const", + "name" : "NetworkingResult", + "namespace" : [ + "API" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "API.NetworkingResult", + "tsFullPath" : "API.NetworkingResult" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "swiftStruct" : { + "_0" : "Address" + } + } + } + ], + "name" : "structPayload" + }, + { + "associatedValues" : [ + { + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "name" : "classPayload" + }, + { + "associatedValues" : [ + { + "type" : { + "jsObject" : { + + } + } + } + ], + "name" : "jsObjectPayload" + }, + { + "associatedValues" : [ + { + "type" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + ], + "name" : "nestedEnum" + }, + { + "associatedValues" : [ + { + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "name" : "arrayPayload" + }, + { + "associatedValues" : [ + { + "type" : { + "jsObject" : { + "_0" : "Foo" + } + } + } + ], + "name" : "jsClassPayload" + }, + { + "associatedValues" : [ + + ], + "name" : "empty" + } + ], + "emitStyle" : "const", + "name" : "AllTypesResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "AllTypesResult", + "tsFullPath" : "AllTypesResult" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "rawValueEnum" : { + "_0" : "Precision", + "_1" : "Float" + } + } + } + ], + "name" : "precision" + }, + { + "associatedValues" : [ + { + "type" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + ], + "name" : "direction" + }, + { + "associatedValues" : [ + { + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Precision", + "_1" : "Float" + } + }, + "_1" : "null" + } + } + } + ], + "name" : "optPrecision" + }, + { + "associatedValues" : [ + { + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + } + ], + "name" : "optDirection" + }, + { + "associatedValues" : [ + + ], + "name" : "empty" + } + ], + "emitStyle" : "const", + "name" : "TypedPayloadResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "TypedPayloadResult", + "tsFullPath" : "TypedPayloadResult" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "scientific" + }, + { + "associatedValues" : [ + + ], + "name" : "basic" + } + ], + "emitStyle" : "const", + "name" : "StaticCalculator", + "staticMethods" : [ + { + "abiName" : "bjs_StaticCalculator_static_roundtrip", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundtrip", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "staticContext" : { + "enumName" : { + "_0" : "StaticCalculator" + } + } + }, + { + "abiName" : "bjs_StaticCalculator_static_doubleValue", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "doubleValue", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "staticContext" : { + "enumName" : { + "_0" : "StaticCalculator" + } + } + } + ], + "staticProperties" : [ + { + "isReadonly" : true, + "isStatic" : true, + "name" : "version", + "staticContext" : { + "enumName" : { + "_0" : "StaticCalculator" + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "StaticCalculator", + "tsFullPath" : "StaticCalculator" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "StaticUtils", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "StaticUtils", + "tsFullPath" : "StaticUtils" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "Nested", + "namespace" : [ + "StaticUtils" + ], + "staticMethods" : [ + { + "abiName" : "bjs_StaticUtils_Nested_static_roundtrip", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundtrip", + "namespace" : [ + "StaticUtils", + "Nested" + ], + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "StaticUtils.Nested" + } + } + } + ], + "staticProperties" : [ + + ], + "swiftCallName" : "StaticUtils.Nested", + "tsFullPath" : "StaticUtils.Nested" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "GraphOperations", + "namespace" : [ + "Services", + "Graph" + ], + "staticMethods" : [ + { + "abiName" : "bjs_Services_Graph_GraphOperations_static_createGraph", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "createGraph", + "namespace" : [ + "Services", + "Graph", + "GraphOperations" + ], + "parameters" : [ + { + "label" : "rootId", + "name" : "rootId", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "GraphOperations" + } + } + }, + { + "abiName" : "bjs_Services_Graph_GraphOperations_static_nodeCount", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "nodeCount", + "namespace" : [ + "Services", + "Graph", + "GraphOperations" + ], + "parameters" : [ + { + "label" : "graphId", + "name" : "graphId", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "GraphOperations" + } + } + } + ], + "staticProperties" : [ + + ], + "swiftCallName" : "GraphOperations", + "tsFullPath" : "Services.Graph.GraphOperations" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "option1" + }, + { + "associatedValues" : [ + + ], + "name" : "option2" + } + ], + "emitStyle" : "const", + "name" : "StaticPropertyEnum", + "staticMethods" : [ + + ], + "staticProperties" : [ + { + "isReadonly" : false, + "isStatic" : true, + "name" : "enumProperty", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "enumConstant", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "enumBool", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "enumVariable", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "computedReadonly", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "computedReadWrite", + "staticContext" : { + "enumName" : { + "_0" : "StaticPropertyEnum" + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "StaticPropertyEnum", + "tsFullPath" : "StaticPropertyEnum" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "StaticPropertyNamespace", + "staticMethods" : [ + + ], + "staticProperties" : [ + { + "isReadonly" : false, + "isStatic" : true, + "name" : "namespaceProperty", + "namespace" : [ + "StaticPropertyNamespace" + ], + "staticContext" : { + "namespaceEnum" : { + "_0" : "StaticPropertyNamespace" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "namespaceConstant", + "namespace" : [ + "StaticPropertyNamespace" + ], + "staticContext" : { + "namespaceEnum" : { + "_0" : "StaticPropertyNamespace" + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "StaticPropertyNamespace", + "tsFullPath" : "StaticPropertyNamespace" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "NestedProperties", + "namespace" : [ + "StaticPropertyNamespace" + ], + "staticMethods" : [ + + ], + "staticProperties" : [ + { + "isReadonly" : false, + "isStatic" : true, + "name" : "nestedProperty", + "namespace" : [ + "StaticPropertyNamespace", + "NestedProperties" + ], + "staticContext" : { + "namespaceEnum" : { + "_0" : "StaticPropertyNamespace.NestedProperties" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "nestedConstant", + "namespace" : [ + "StaticPropertyNamespace", + "NestedProperties" + ], + "staticContext" : { + "namespaceEnum" : { + "_0" : "StaticPropertyNamespace.NestedProperties" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "nestedDouble", + "namespace" : [ + "StaticPropertyNamespace", + "NestedProperties" + ], + "staticContext" : { + "namespaceEnum" : { + "_0" : "StaticPropertyNamespace.NestedProperties" + } + }, + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "StaticPropertyNamespace.NestedProperties", + "tsFullPath" : "StaticPropertyNamespace.NestedProperties" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "IntegerTypesSupportExports", + "staticMethods" : [ + { + "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripInt", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripInt", + "namespace" : [ + "IntegerTypesSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "IntegerTypesSupportExports" + } + } + }, + { + "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripUInt", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripUInt", + "namespace" : [ + "IntegerTypesSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "word" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "IntegerTypesSupportExports" + } + } + }, + { + "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripInt8", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripInt8", + "namespace" : [ + "IntegerTypesSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w8" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w8" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "IntegerTypesSupportExports" + } + } + }, + { + "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripUInt8", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripUInt8", + "namespace" : [ + "IntegerTypesSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w8" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w8" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "IntegerTypesSupportExports" + } + } + }, + { + "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripInt16", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripInt16", + "namespace" : [ + "IntegerTypesSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w16" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w16" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "IntegerTypesSupportExports" + } + } + }, + { + "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripUInt16", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripUInt16", + "namespace" : [ + "IntegerTypesSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w16" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w16" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "IntegerTypesSupportExports" + } + } + }, + { + "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripInt32", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripInt32", + "namespace" : [ + "IntegerTypesSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w32" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w32" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "IntegerTypesSupportExports" + } + } + }, + { + "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripUInt32", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripUInt32", + "namespace" : [ + "IntegerTypesSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w32" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w32" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "IntegerTypesSupportExports" + } + } + }, + { + "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripInt64", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripInt64", + "namespace" : [ + "IntegerTypesSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w64" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w64" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "IntegerTypesSupportExports" + } + } + }, + { + "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripUInt64", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripUInt64", + "namespace" : [ + "IntegerTypesSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w64" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w64" + } + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "IntegerTypesSupportExports" + } + } + } + ], + "staticProperties" : [ + + ], + "swiftCallName" : "IntegerTypesSupportExports", + "tsFullPath" : "IntegerTypesSupportExports" + }, + { + "cases" : [ + + ], + "emitStyle" : "const", + "name" : "OptionalSupportExports", + "staticMethods" : [ + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalString", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalString", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalInt", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalInt", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalBool", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalBool", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "bool" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "bool" : { + + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalFloat", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalFloat", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "float" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "float" : { + + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalDouble", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalDouble", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "double" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "double" : { + + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalSyntax", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalSyntax", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalCaseEnum", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalCaseEnum", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Status" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Status" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalStringRawValueEnum", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalStringRawValueEnum", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalIntRawValueEnum", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalIntRawValueEnum", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalInt64RawValueEnum", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalInt64RawValueEnum", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalUInt64RawValueEnum", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalUInt64RawValueEnum", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "SessionId", + "_1" : "UInt64" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "SessionId", + "_1" : "UInt64" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalTSEnum", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalTSEnum", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "TSDirection" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "TSDirection" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalTSStringEnum", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalTSStringEnum", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "TSTheme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "TSTheme", + "_1" : "String" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalNamespacedEnum", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalNamespacedEnum", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Networking.API.Method" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Networking.API.Method" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalSwiftClass", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalSwiftClass", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalIntArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalIntArray", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalStringArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalStringArray", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalSwiftClassArray", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalSwiftClassArray", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalAPIResult", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalTypedPayloadResult", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalTypedPayloadResult", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "TypedPayloadResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "TypedPayloadResult" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalComplexResult", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalComplexResult", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalAllTypesResult", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalAllTypesResult", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AllTypesResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AllTypesResult" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalPayloadResult", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalPayloadResult", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "associatedValueEnum" : { + "_0" : "OptionalAllTypesResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "OptionalAllTypesResult" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalPayloadResultOpt", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalPayloadResultOpt", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "OptionalAllTypesResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "OptionalAllTypesResult" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalAPIOptionalResult", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "roundTripOptionalAPIOptionalResult", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIOptionalResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIOptionalResult" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_takeOptionalJSObject", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "takeOptionalJSObject", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "void" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_applyOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "applyOptionalGreeter", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + }, + { + "label" : "_", + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_makeOptionalHolder", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "makeOptionalHolder", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "nullableGreeter", + "name" : "nullableGreeter", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + }, + { + "label" : "undefinedNumber", + "name" : "undefinedNumber", + "type" : { + "nullable" : { + "_0" : { + "double" : { + + } + }, + "_1" : "undefined" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "OptionalHolder" + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + }, + { + "abiName" : "bjs_OptionalSupportExports_static_compareAPIResults", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "compareAPIResults", + "namespace" : [ + "OptionalSupportExports" + ], + "parameters" : [ + { + "label" : "_", + "name" : "r1", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + }, + { + "label" : "_", + "name" : "r2", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "namespaceEnum" : { + "_0" : "OptionalSupportExports" + } + } + } + ], + "staticProperties" : [ + + ], + "swiftCallName" : "OptionalSupportExports", + "tsFullPath" : "OptionalSupportExports" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "Address" + } + }, + "_1" : "null" + } + } + } + ], + "name" : "optStruct" + }, + { + "associatedValues" : [ + { + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + ], + "name" : "optClass" + }, + { + "associatedValues" : [ + { + "type" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + } + ], + "name" : "optJSObject" + }, + { + "associatedValues" : [ + { + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + } + ], + "name" : "optNestedEnum" + }, + { + "associatedValues" : [ + { + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" + } + } + } + ], + "name" : "optArray" + }, + { + "associatedValues" : [ + { + "type" : { + "nullable" : { + "_0" : { + "jsObject" : { + "_0" : "Foo" + } + }, + "_1" : "null" + } + } + } + ], + "name" : "optJsClass" + }, + { + "associatedValues" : [ + + ], + "name" : "empty" + } + ], + "emitStyle" : "const", + "name" : "OptionalAllTypesResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "OptionalAllTypesResult", + "tsFullPath" : "OptionalAllTypesResult" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "type" : { + "nullable" : { + "_0" : { + "bool" : { + + } + }, + "_1" : "null" + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + { + "type" : { + "nullable" : { + "_0" : { + "bool" : { + + } + }, + "_1" : "null" + } + } + }, + { + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "name" : "status" + } + ], + "emitStyle" : "const", + "name" : "APIOptionalResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "APIOptionalResult", + "tsFullPath" : "APIOptionalResult" + } + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_roundTripVoid", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripVoid", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_roundTripFloat", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripFloat", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "float" : { + + } + } + } + ], + "returnType" : { + "float" : { + + } + } + }, + { + "abiName" : "bjs_roundTripDouble", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripDouble", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_roundTripBool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripBool", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_roundTripString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripString", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_roundTripSwiftHeapObject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripSwiftHeapObject", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_roundTripUnsafeRawPointer", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripUnsafeRawPointer", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeRawPointer" + } + } + } + } + ], + "returnType" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeRawPointer" + } + } + } + }, + { + "abiName" : "bjs_roundTripUnsafeMutableRawPointer", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripUnsafeMutableRawPointer", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutableRawPointer" + } + } + } + } + ], + "returnType" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutableRawPointer" + } + } + } + }, + { + "abiName" : "bjs_roundTripOpaquePointer", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOpaquePointer", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "opaquePointer" + } + } + } + } + ], + "returnType" : { + "unsafePointer" : { + "_0" : { + "kind" : "opaquePointer" + } + } + } + }, + { + "abiName" : "bjs_roundTripUnsafePointer", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripUnsafePointer", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafePointer", + "pointee" : "UInt8" + } + } + } + } + ], + "returnType" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafePointer", + "pointee" : "UInt8" + } + } + } + }, + { + "abiName" : "bjs_roundTripUnsafeMutablePointer", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripUnsafeMutablePointer", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutablePointer", + "pointee" : "UInt8" + } + } + } + } + ], + "returnType" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutablePointer", + "pointee" : "UInt8" + } + } + } + }, + { + "abiName" : "bjs_roundTripJSObject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripJSObject", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "jsObject" : { + + } + } + } + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_roundTripDictionaryExport", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripDictionaryExport", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "dictionary" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "dictionary" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalDictionaryExport", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalDictionaryExport", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "dictionary" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "dictionary" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_roundTripJSValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripJSValue", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "jsValue" : { + + } + } + } + ], + "returnType" : { + "jsValue" : { + + } + } + }, + { + "abiName" : "bjs_roundTripOptionalJSValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalJSValue", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "jsValue" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "jsValue" : { + + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_roundTripOptionalJSValueArray", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalJSValueArray", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_makeImportedFoo", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "makeImportedFoo", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "jsObject" : { + "_0" : "Foo" + } + } + }, + { + "abiName" : "bjs_throwsSwiftError", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsSwiftError", + "parameters" : [ + { + "label" : "shouldThrow", + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_throwsWithIntResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithIntResult", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_throwsWithStringResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithStringResult", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_throwsWithBoolResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithBoolResult", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_throwsWithFloatResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithFloatResult", + "parameters" : [ + + ], + "returnType" : { + "float" : { + + } + } + }, + { + "abiName" : "bjs_throwsWithDoubleResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithDoubleResult", + "parameters" : [ + + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_throwsWithSwiftHeapObjectResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithSwiftHeapObjectResult", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_throwsWithJSObjectResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithJSObjectResult", + "parameters" : [ + + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripVoid", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripVoid", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripInt", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripInt", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_asyncRoundTripFloat", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripFloat", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "float" : { + + } + } + } + ], + "returnType" : { + "float" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripDouble", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripDouble", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripBool", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripBool", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripString", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripString", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_asyncRoundTripSwiftHeapObject", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripSwiftHeapObject", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_asyncRoundTripJSObject", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripJSObject", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "jsObject" : { + + } + } + } + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_takeGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "takeGreeter", + "parameters" : [ + { + "label" : "g", + "name" : "g", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_createCalculator", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createCalculator", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Calculator" + } + } + }, + { + "abiName" : "bjs_useCalculator", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "useCalculator", + "parameters" : [ + { + "label" : "calc", + "name" : "calc", + "type" : { + "swiftHeapObject" : { + "_0" : "Calculator" + } + } + }, + { + "label" : "x", + "name" : "x", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "y", + "name" : "y", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_testGreeterToJSValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testGreeterToJSValue", + "parameters" : [ + + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_testCalculatorToJSValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testCalculatorToJSValue", + "parameters" : [ + + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_testSwiftClassAsJSValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testSwiftClassAsJSValue", + "parameters" : [ + { + "label" : "greeter", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_setDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setDirection", + "parameters" : [ + { + "label" : "_", + "name" : "direction", + "type" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Direction" + } + } + }, + { + "abiName" : "bjs_getDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getDirection", + "parameters" : [ + + ], + "returnType" : { + "caseEnum" : { + "_0" : "Direction" + } + } + }, + { + "abiName" : "bjs_processDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processDirection", + "parameters" : [ + { + "label" : "_", + "name" : "input", + "type" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Status" + } + } + }, + { + "abiName" : "bjs_setTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setTheme", + "parameters" : [ + { + "label" : "_", + "name" : "theme", + "type" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + }, + { + "abiName" : "bjs_getTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getTheme", + "parameters" : [ + + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + }, + { + "abiName" : "bjs_setHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setHttpStatus", + "parameters" : [ + { + "label" : "_", + "name" : "status", + "type" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + }, + { + "abiName" : "bjs_getHttpStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getHttpStatus", + "parameters" : [ + + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + }, + { + "abiName" : "bjs_setFileSize", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setFileSize", + "parameters" : [ + { + "label" : "_", + "name" : "size", + "type" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + } + }, + { + "abiName" : "bjs_getFileSize", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getFileSize", + "parameters" : [ + + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + } + }, + { + "abiName" : "bjs_setSessionId", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setSessionId", + "parameters" : [ + { + "label" : "_", + "name" : "session", + "type" : { + "rawValueEnum" : { + "_0" : "SessionId", + "_1" : "UInt64" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "SessionId", + "_1" : "UInt64" + } + } + }, + { + "abiName" : "bjs_getSessionId", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getSessionId", + "parameters" : [ + + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "SessionId", + "_1" : "UInt64" + } + } + }, + { + "abiName" : "bjs_processTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processTheme", + "parameters" : [ + { + "label" : "_", + "name" : "theme", + "type" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + } + }, + { + "abiName" : "bjs_setTSDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setTSDirection", + "parameters" : [ + { + "label" : "_", + "name" : "direction", + "type" : { + "caseEnum" : { + "_0" : "TSDirection" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "TSDirection" + } + } + }, + { + "abiName" : "bjs_getTSDirection", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getTSDirection", + "parameters" : [ + + ], + "returnType" : { + "caseEnum" : { + "_0" : "TSDirection" + } + } + }, + { + "abiName" : "bjs_setTSTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setTSTheme", + "parameters" : [ + { + "label" : "_", + "name" : "theme", + "type" : { + "rawValueEnum" : { + "_0" : "TSTheme", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "TSTheme", + "_1" : "String" + } + } + }, + { + "abiName" : "bjs_getTSTheme", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getTSTheme", + "parameters" : [ + + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "TSTheme", + "_1" : "String" + } + } + }, + { + "abiName" : "bjs_createConverter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createConverter", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Utils.Converter" + } + } + }, + { + "abiName" : "bjs_useConverter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "useConverter", + "parameters" : [ + { + "label" : "converter", + "name" : "converter", + "type" : { + "swiftHeapObject" : { + "_0" : "Utils.Converter" + } + } + }, + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_roundTripConverterArray", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripConverterArray", + "parameters" : [ + { + "label" : "_", + "name" : "converters", + "type" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Utils.Converter" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Utils.Converter" + } + } + } + } + }, + { + "abiName" : "bjs_createHTTPServer", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createHTTPServer", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Networking.API.HTTPServer" + } + } + }, + { + "abiName" : "bjs_createUUID", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createUUID", + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "UUID" + } + } + }, + { + "abiName" : "bjs_roundTripUUID", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripUUID", + "parameters" : [ + { + "label" : "_", + "name" : "uuid", + "type" : { + "swiftHeapObject" : { + "_0" : "UUID" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "UUID" + } + } + }, + { + "abiName" : "bjs_roundtripNetworkingAPIMethod", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripNetworkingAPIMethod", + "parameters" : [ + { + "label" : "_", + "name" : "method", + "type" : { + "caseEnum" : { + "_0" : "Networking.API.Method" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Networking.API.Method" + } + } + }, + { + "abiName" : "bjs_roundtripConfigurationLogLevel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripConfigurationLogLevel", + "parameters" : [ + { + "label" : "_", + "name" : "level", + "type" : { + "rawValueEnum" : { + "_0" : "Configuration.LogLevel", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Configuration.LogLevel", + "_1" : "String" + } + } + }, + { + "abiName" : "bjs_roundtripConfigurationPort", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripConfigurationPort", + "parameters" : [ + { + "label" : "_", + "name" : "port", + "type" : { + "rawValueEnum" : { + "_0" : "Configuration.Port", + "_1" : "Int" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Configuration.Port", + "_1" : "Int" + } + } + }, + { + "abiName" : "bjs_processConfigurationLogLevel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processConfigurationLogLevel", + "parameters" : [ + { + "label" : "_", + "name" : "level", + "type" : { + "rawValueEnum" : { + "_0" : "Configuration.LogLevel", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "Configuration.Port", + "_1" : "Int" + } + } + }, + { + "abiName" : "bjs_roundtripInternalSupportedMethod", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripInternalSupportedMethod", + "parameters" : [ + { + "label" : "_", + "name" : "method", + "type" : { + "caseEnum" : { + "_0" : "Internal.SupportedMethod" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "Internal.SupportedMethod" + } + } + }, + { + "abiName" : "bjs_roundtripAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripAPIResult", + "parameters" : [ + { + "label" : "result", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultSuccess", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultSuccess", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultFailure", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultFailure", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultInfo", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultInfo", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultFlag", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultFlag", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultRate", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultRate", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "float" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_makeAPIResultPrecise", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPIResultPrecise", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "abiName" : "bjs_roundtripComplexResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripComplexResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultSuccess", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultSuccess", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultError", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultError", + "parameters" : [ + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "code", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultLocation", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultLocation", + "parameters" : [ + { + "label" : "_", + "name" : "lat", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "lng", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultStatus", + "parameters" : [ + { + "label" : "_", + "name" : "active", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "_", + "name" : "code", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultCoordinates", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultCoordinates", + "parameters" : [ + { + "label" : "_", + "name" : "x", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "y", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "z", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultComprehensive", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultComprehensive", + "parameters" : [ + { + "label" : "_", + "name" : "flag1", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "_", + "name" : "flag2", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "_", + "name" : "count1", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "_", + "name" : "count2", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "_", + "name" : "value1", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "value2", + "type" : { + "double" : { + + } + } + }, + { + "label" : "_", + "name" : "text1", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "text2", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "text3", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeComplexResultInfo", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeComplexResultInfo", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ComplexResult" + } + } + }, + { + "abiName" : "bjs_makeUtilitiesResultSuccess", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeUtilitiesResultSuccess", + "parameters" : [ + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "Utilities.Result" + } + } + }, + { + "abiName" : "bjs_makeUtilitiesResultFailure", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeUtilitiesResultFailure", + "parameters" : [ + { + "label" : "_", + "name" : "error", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "code", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "Utilities.Result" + } + } + }, + { + "abiName" : "bjs_makeUtilitiesResultStatus", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeUtilitiesResultStatus", + "parameters" : [ + { + "label" : "_", + "name" : "active", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "_", + "name" : "code", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "Utilities.Result" + } + } + }, + { + "abiName" : "bjs_makeAPINetworkingResultSuccess", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPINetworkingResultSuccess", + "parameters" : [ + { + "label" : "_", + "name" : "message", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "API.NetworkingResult" + } + } + }, + { + "abiName" : "bjs_makeAPINetworkingResultFailure", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAPINetworkingResultFailure", + "parameters" : [ + { + "label" : "_", + "name" : "error", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "code", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "API.NetworkingResult" + } + } + }, + { + "abiName" : "bjs_roundtripUtilitiesResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripUtilitiesResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "Utilities.Result" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "Utilities.Result" + } + } + }, + { + "abiName" : "bjs_roundtripAPINetworkingResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripAPINetworkingResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "API.NetworkingResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "API.NetworkingResult" + } + } + }, + { + "abiName" : "bjs_roundTripAllTypesResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripAllTypesResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "AllTypesResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "AllTypesResult" + } + } + }, + { + "abiName" : "bjs_roundTripTypedPayloadResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripTypedPayloadResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "TypedPayloadResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "TypedPayloadResult" + } + } + }, + { + "abiName" : "bjs_createPropertyHolder", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createPropertyHolder", + "parameters" : [ + { + "label" : "intValue", + "name" : "intValue", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "floatValue", + "name" : "floatValue", + "type" : { + "float" : { + + } + } + }, + { + "label" : "doubleValue", + "name" : "doubleValue", + "type" : { + "double" : { + + } + } + }, + { + "label" : "boolValue", + "name" : "boolValue", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "stringValue", + "name" : "stringValue", + "type" : { + "string" : { + + } + } + }, + { + "label" : "jsObject", + "name" : "jsObject", + "type" : { + "jsObject" : { + + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "PropertyHolder" + } + } + }, + { + "abiName" : "bjs_testPropertyHolder", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testPropertyHolder", + "parameters" : [ + { + "label" : "holder", + "name" : "holder", + "type" : { + "swiftHeapObject" : { + "_0" : "PropertyHolder" + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_resetObserverCounts", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetObserverCounts", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getObserverStats", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getObserverStats", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_formatName", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "formatName", + "parameters" : [ + { + "label" : "_", + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "label" : "transform", + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_makeFormatter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeFormatter", + "parameters" : [ + { + "label" : "prefix", + "name" : "prefix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_makeAdder", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAdder", + "parameters" : [ + { + "label" : "base", + "name" : "base", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_getSharedSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getSharedSubject", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "IdentityTestSubject" + } + } + }, + { + "abiName" : "bjs_resetSharedSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetSharedSubject", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getRetainLeakSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getRetainLeakSubject", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "RetainLeakSubject" + } + } + }, + { + "abiName" : "bjs_resetRetainLeakSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetRetainLeakSubject", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getRetainLeakDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getRetainLeakDeinits", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_resetRetainLeakDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetRetainLeakDeinits", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_setupArrayPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setupArrayPool", + "parameters" : [ + { + "label" : "_", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getArrayPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getArrayPool", + "parameters" : [ + + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "ArrayIdentityElement" + } + } + } + } + }, + { + "abiName" : "bjs_getArrayPoolElement", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getArrayPoolElement", + "parameters" : [ + { + "label" : "_", + "name" : "index", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "ArrayIdentityElement" + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_getArrayPoolDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getArrayPoolDeinits", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_resetArrayPoolDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetArrayPoolDeinits", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_clearArrayPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "clearArrayPool", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_roundTripPointerFields", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripPointerFields", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "PointerFields" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "PointerFields" + } + } + }, + { + "abiName" : "bjs_testStructDefault", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testStructDefault", + "parameters" : [ + { + "defaultValue" : { + "structLiteral" : { + "_0" : "DataPoint", + "_1" : [ + { + "name" : "x", + "value" : { + "float" : { + "_0" : 1 + } + } + }, + { + "name" : "y", + "value" : { + "float" : { + "_0" : 2 + } + } + }, + { + "name" : "label", + "value" : { + "string" : { + "_0" : "default" + } + } + }, + { + "name" : "optCount", + "value" : { + "null" : { + + } + } + }, + { + "name" : "optFlag", + "value" : { + "null" : { + + } + } + } + ] + } + }, + "label" : "point", + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_cartToJSObject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "cartToJSObject", + "parameters" : [ + { + "label" : "_", + "name" : "cart", + "type" : { + "swiftStruct" : { + "_0" : "CopyableCart" + } + } + } + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_nestedCartToJSObject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "nestedCartToJSObject", + "parameters" : [ + { + "label" : "_", + "name" : "cart", + "type" : { + "swiftStruct" : { + "_0" : "CopyableNestedCart" + } + } + } + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "abiName" : "bjs_roundTripDataPoint", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripDataPoint", + "parameters" : [ + { + "label" : "_", + "name" : "data", + "type" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + }, + { + "abiName" : "bjs_roundTripPublicPoint", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripPublicPoint", + "parameters" : [ + { + "label" : "_", + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + }, + { + "abiName" : "bjs_roundTripContact", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripContact", + "parameters" : [ + { + "label" : "_", + "name" : "contact", + "type" : { + "swiftStruct" : { + "_0" : "Contact" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Contact" + } + } + }, + { + "abiName" : "bjs_roundTripConfig", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripConfig", + "parameters" : [ + { + "label" : "_", + "name" : "config", + "type" : { + "swiftStruct" : { + "_0" : "Config" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Config" + } + } + }, + { + "abiName" : "bjs_roundTripSessionData", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripSessionData", + "parameters" : [ + { + "label" : "_", + "name" : "session", + "type" : { + "swiftStruct" : { + "_0" : "SessionData" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "SessionData" + } + } + }, + { + "abiName" : "bjs_roundTripValidationReport", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripValidationReport", + "parameters" : [ + { + "label" : "_", + "name" : "report", + "type" : { + "swiftStruct" : { + "_0" : "ValidationReport" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "ValidationReport" + } + } + }, + { + "abiName" : "bjs_roundTripAdvancedConfig", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripAdvancedConfig", + "parameters" : [ + { + "label" : "_", + "name" : "config", + "type" : { + "swiftStruct" : { + "_0" : "AdvancedConfig" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "AdvancedConfig" + } + } + }, + { + "abiName" : "bjs_roundTripMeasurementConfig", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripMeasurementConfig", + "parameters" : [ + { + "label" : "_", + "name" : "config", + "type" : { + "swiftStruct" : { + "_0" : "MeasurementConfig" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "MeasurementConfig" + } + } + }, + { + "abiName" : "bjs_updateValidationReport", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "updateValidationReport", + "parameters" : [ + { + "label" : "_", + "name" : "newResult", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + }, + { + "label" : "_", + "name" : "report", + "type" : { + "swiftStruct" : { + "_0" : "ValidationReport" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "ValidationReport" + } + } + }, + { + "abiName" : "bjs_testContainerWithStruct", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "testContainerWithStruct", + "parameters" : [ + { + "label" : "_", + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Container" + } + } + }, + { + "abiName" : "bjs_roundTripJSObjectContainer", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripJSObjectContainer", + "parameters" : [ + { + "label" : "_", + "name" : "container", + "type" : { + "swiftStruct" : { + "_0" : "JSObjectContainer" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "JSObjectContainer" + } + } + }, + { + "abiName" : "bjs_roundTripFooContainer", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripFooContainer", + "parameters" : [ + { + "label" : "_", + "name" : "container", + "type" : { + "swiftStruct" : { + "_0" : "FooContainer" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "FooContainer" + } + } + }, + { + "abiName" : "bjs_roundTripArrayMembers", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripArrayMembers", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "ArrayMembers" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "ArrayMembers" + } + } + }, + { + "abiName" : "bjs_arrayMembersSum", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "arrayMembersSum", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "ArrayMembers" + } + } + }, + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_arrayMembersFirst", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "arrayMembersFirst", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "swiftStruct" : { + "_0" : "ArrayMembers" + } + } + }, + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "protocols" : [ + { + "methods" : [ + + ], + "name" : "ArrayElementProtocol", + "properties" : [ + { + "isReadonly" : false, + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + { + "methods" : [ + { + "abiName" : "bjs_DataProcessor_increment", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "increment", + "parameters" : [ + { + "label" : "by", + "name" : "amount", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_getValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getValue", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_DataProcessor_setLabelElements", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setLabelElements", + "parameters" : [ + { + "label" : "_", + "name" : "labelPrefix", + "type" : { + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "labelSuffix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_getLabel", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getLabel", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_isEven", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "isEven", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_processGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_createGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createGreeter", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "abiName" : "bjs_DataProcessor_processOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "processOptionalGreeter", + "parameters" : [ + { + "label" : "_", + "name" : "greeter", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_createOptionalGreeter", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "createOptionalGreeter", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_DataProcessor_handleAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "handleAPIResult", + "parameters" : [ + { + "label" : "_", + "name" : "result", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_DataProcessor_getAPIResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getAPIResult", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + } + ], + "name" : "DataProcessor", + "properties" : [ + { + "isReadonly" : false, + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "name" : "optionalTag", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "name" : "optionalCount", + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "name" : "direction", + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "name" : "optionalTheme", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "name" : "httpStatus", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "HttpStatus", + "_1" : "Int" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "name" : "apiResult", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : false, + "name" : "helper", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "isReadonly" : false, + "name" : "optionalHelper", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + ] + } + ], + "structs" : [ + { + "methods" : [ + + ], + "name" : "Point", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "x", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "y", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "Point" + }, + { + "constructor" : { + "abiName" : "bjs_PointerFields_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "raw", + "name" : "raw", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeRawPointer" + } + } + } + }, + { + "label" : "mutRaw", + "name" : "mutRaw", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutableRawPointer" + } + } + } + }, + { + "label" : "opaque", + "name" : "opaque", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "opaquePointer" + } + } + } + }, + { + "label" : "ptr", + "name" : "ptr", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafePointer", + "pointee" : "UInt8" + } + } + } + }, + { + "label" : "mutPtr", + "name" : "mutPtr", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutablePointer", + "pointee" : "UInt8" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "PointerFields", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "raw", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeRawPointer" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "mutRaw", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutableRawPointer" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "opaque", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "opaquePointer" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "ptr", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafePointer", + "pointee" : "UInt8" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "mutPtr", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutablePointer", + "pointee" : "UInt8" + } + } + } + } + ], + "swiftCallName" : "PointerFields" + }, + { + "constructor" : { + "abiName" : "bjs_DataPoint_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "x", + "name" : "x", + "type" : { + "double" : { + + } + } + }, + { + "label" : "y", + "name" : "y", + "type" : { + "double" : { + + } + } + }, + { + "label" : "label", + "name" : "label", + "type" : { + "string" : { + + } + } + }, + { + "label" : "optCount", + "name" : "optCount", + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "label" : "optFlag", + "name" : "optFlag", + "type" : { + "nullable" : { + "_0" : { + "bool" : { + + } + }, + "_1" : "null" + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_DataPoint_static_origin", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "origin", + "parameters" : [ + + ], + "returnType" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + }, + "staticContext" : { + "structName" : { + "_0" : "DataPoint" + } + } + } + ], + "name" : "DataPoint", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "x", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "y", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "label", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optCount", + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optFlag", + "type" : { + "nullable" : { + "_0" : { + "bool" : { + + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "dimensions", + "staticContext" : { + "structName" : { + "_0" : "DataPoint" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "DataPoint" + }, + { + "constructor" : { + "abiName" : "bjs_PublicPoint_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "x", + "name" : "x", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "y", + "name" : "y", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "explicitAccessControl" : "public", + "methods" : [ + + ], + "name" : "PublicPoint", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "x", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "y", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "PublicPoint" + }, + { + "methods" : [ + + ], + "name" : "Address", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "street", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "city", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "zipCode", + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "Address" + }, + { + "methods" : [ + + ], + "name" : "Contact", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "age", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "address", + "type" : { + "swiftStruct" : { + "_0" : "Address" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "email", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "secondaryAddress", + "type" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "Address" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "Contact" + }, + { + "methods" : [ + + ], + "name" : "Config", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "theme", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "direction", + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "status", + "type" : { + "caseEnum" : { + "_0" : "Status" + } + } + } + ], + "swiftCallName" : "Config" + }, + { + "methods" : [ + + ], + "name" : "SessionData", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "id", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "owner", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "SessionData" + }, + { + "methods" : [ + + ], + "name" : "ValidationReport", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "id", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "result", + "type" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "status", + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Status" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "outcome", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "ValidationReport" + }, + { + "methods" : [ + + ], + "name" : "AdvancedConfig", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "id", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "title", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "enabled", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "theme", + "type" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "status", + "type" : { + "caseEnum" : { + "_0" : "Status" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "result", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "metadata", + "type" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "location", + "type" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "defaults", + "type" : { + "swiftStruct" : { + "_0" : "ConfigStruct" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "overrideDefaults", + "type" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "ConfigStruct" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "AdvancedConfig" + }, + { + "methods" : [ + + ], + "name" : "MeasurementConfig", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "precision", + "type" : { + "rawValueEnum" : { + "_0" : "Precision", + "_1" : "Float" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "ratio", + "type" : { + "rawValueEnum" : { + "_0" : "Ratio", + "_1" : "Double" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optionalPrecision", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Precision", + "_1" : "Float" + } + }, + "_1" : "null" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optionalRatio", + "type" : { + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Ratio", + "_1" : "Double" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "MeasurementConfig" + }, + { + "constructor" : { + "abiName" : "bjs_MathOperations_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "defaultValue" : { + "double" : { + "_0" : 0 + } + }, + "label" : "baseValue", + "name" : "baseValue", + "type" : { + "double" : { + + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_MathOperations_add", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "add", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "double" : { + + } + } + }, + { + "defaultValue" : { + "double" : { + "_0" : 10 + } + }, + "label" : "b", + "name" : "b", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_MathOperations_multiply", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "multiply", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "double" : { + + } + } + }, + { + "label" : "b", + "name" : "b", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_MathOperations_static_subtract", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "subtract", + "parameters" : [ + { + "label" : "a", + "name" : "a", + "type" : { + "double" : { + + } + } + }, + { + "defaultValue" : { + "double" : { + "_0" : 5 + } + }, + "label" : "b", + "name" : "b", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + }, + "staticContext" : { + "structName" : { + "_0" : "MathOperations" + } + } + } + ], + "name" : "MathOperations", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "baseValue", + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "MathOperations" + }, + { + "methods" : [ + { + "abiName" : "bjs_CopyableCart_static_fromJSObject", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "fromJSObject", + "parameters" : [ + { + "label" : "_", + "name" : "object", + "type" : { + "jsObject" : { + + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "CopyableCart" + } + }, + "staticContext" : { + "structName" : { + "_0" : "CopyableCart" + } + } + } + ], + "name" : "CopyableCart", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "x", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "note", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "CopyableCart" + }, + { + "methods" : [ + + ], + "name" : "CopyableCartItem", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "sku", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "quantity", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "CopyableCartItem" + }, + { + "methods" : [ + { + "abiName" : "bjs_CopyableNestedCart_static_fromJSObject", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "fromJSObject", + "parameters" : [ + { + "label" : "_", + "name" : "object", + "type" : { + "jsObject" : { + + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "CopyableNestedCart" + } + }, + "staticContext" : { + "structName" : { + "_0" : "CopyableNestedCart" + } + } + } + ], + "name" : "CopyableNestedCart", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "id", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "item", + "type" : { + "swiftStruct" : { + "_0" : "CopyableCartItem" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "shippingAddress", + "type" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "Address" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "CopyableNestedCart" + }, + { + "methods" : [ + + ], + "name" : "ConfigStruct", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "defaultConfig", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "maxRetries", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : true, + "name" : "timeout", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "computedSetting", + "staticContext" : { + "structName" : { + "_0" : "ConfigStruct" + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "ConfigStruct" + }, + { + "constructor" : { + "abiName" : "bjs_Vector2D_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "dx", + "name" : "dx", + "type" : { + "double" : { + + } + } + }, + { + "label" : "dy", + "name" : "dy", + "type" : { + "double" : { + + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_Vector2D_magnitude", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "magnitude", + "parameters" : [ + + ], + "returnType" : { + "double" : { + + } + } + }, + { + "abiName" : "bjs_Vector2D_scaled", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "scaled", + "parameters" : [ + { + "label" : "by", + "name" : "factor", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Vector2D" + } + } + } + ], + "name" : "Vector2D", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "dx", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "dy", + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "Vector2D" + }, + { + "methods" : [ + + ], + "name" : "JSObjectContainer", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "object", + "type" : { + "jsObject" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optionalObject", + "type" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "JSObjectContainer" + }, + { + "methods" : [ + + ], + "name" : "FooContainer", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "foo", + "type" : { + "jsObject" : { + "_0" : "Foo" + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optionalFoo", + "type" : { + "nullable" : { + "_0" : { + "jsObject" : { + "_0" : "Foo" + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "FooContainer" + }, + { + "methods" : [ + { + "abiName" : "bjs_ArrayMembers_sumValues", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "sumValues", + "parameters" : [ + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_ArrayMembers_firstString", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "firstString", + "parameters" : [ + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "name" : "ArrayMembers", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "ints", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "optStrings", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + } + } + ], + "swiftCallName" : "ArrayMembers" + } + ] + }, + "imported" : { + "children" : [ + { + "functions" : [ + + ], + "types" : [ + { + "constructor" : { + "parameters" : [ + { + "name" : "id", + "type" : { + "string" : { + + } + } + } + ] + }, + "getters" : [ + { + "name" : "id", + "type" : { + "string" : { + + } + } + } + ], + "methods" : [ + + ], + "name" : "ArrayElementObject", + "setters" : [ + + ], + "staticMethods" : [ + + ] + }, + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "ArraySupportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsIntArrayLength", + "parameters" : [ + { + "name" : "items", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripIntArray", + "parameters" : [ + { + "name" : "items", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripNumberArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripStringArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripBoolArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripJSValueArray", + "parameters" : [ + { + "name" : "v", + "type" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripJSObjectArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "jsObject" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsObject" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripJSClassArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalIntArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalStringArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalBoolArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "bool" : { + + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "bool" : { + + } + }, + "_1" : "null" + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalJSValueArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsValue" : { + + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsValue" : { + + } + }, + "_1" : "null" + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalJSObjectArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalJSClassArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "jsObject" : { + "_0" : "ArrayElementObject" + } + }, + "_1" : "null" + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsSumNumberArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsCreateNumberArray", + "parameters" : [ + + ], + "returnType" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsArraySupportTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "AsyncImportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripVoid", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripNumber", + "parameters" : [ + { + "name" : "v", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripBool", + "parameters" : [ + { + "name" : "v", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripString", + "parameters" : [ + { + "name" : "v", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripOptionalString", + "parameters" : [ + { + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + }, + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripOptionalNumber", + "parameters" : [ + { + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "double" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "double" : { + + } + }, + "_1" : "null" + } + } + }, + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripBoolArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "bool" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripIntArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripStringArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripFeatureFlag", + "parameters" : [ + { + "name" : "v", + "type" : { + "rawValueEnum" : { + "_0" : "FeatureFlag", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "FeatureFlag", + "_1" : "String" + } + } + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "ClosureSupportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyVoid", + "parameters" : [ + { + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyBool", + "parameters" : [ + { + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_Sb", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyInt", + "parameters" : [ + { + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyDouble", + "parameters" : [ + { + "name" : "value", + "type" : { + "double" : { + + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "double" : { + + } + } + ], + "returnType" : { + "double" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyString", + "parameters" : [ + { + "name" : "value", + "type" : { + "string" : { + + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsApplyJSObject", + "parameters" : [ + { + "name" : "value", + "type" : { + "jsObject" : { + + } + } + }, + { + "name" : "transform", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTests8JSObjectC_8JSObjectC", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "jsObject" : { + + } + } + ], + "returnType" : { + "jsObject" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "jsObject" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsMakeIntToInt", + "parameters" : [ + { + "name" : "base", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsMakeDoubleToDouble", + "parameters" : [ + { + "name" : "base", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "double" : { + + } + } + ], + "returnType" : { + "double" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsMakeStringToString", + "parameters" : [ + { + "name" : "prefix", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsCallTwice", + "parameters" : [ + { + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSi_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsCallBinary", + "parameters" : [ + { + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSiSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsCallTriple", + "parameters" : [ + { + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsSiSiSi_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsCallAfterRelease", + "parameters" : [ + { + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsOptionalInvoke", + "parameters" : [ + { + "name" : "callback", + "type" : { + "nullable" : { + "_0" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_Sb", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsStoreClosure", + "parameters" : [ + { + "name" : "callback", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsy_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsCallStoredClosure", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsHeapCount", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsClosureSupportTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "DefaultArgumentImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsDefaultArgumentTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "DictionarySupportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripDictionaryInt", + "parameters" : [ + { + "name" : "values", + "type" : { + "dictionary" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "dictionary" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripDictionaryBool", + "parameters" : [ + { + "name" : "values", + "type" : { + "dictionary" : { + "_0" : { + "bool" : { + + } + } + } + } + } + ], + "returnType" : { + "dictionary" : { + "_0" : { + "bool" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripDictionaryDouble", + "parameters" : [ + { + "name" : "values", + "type" : { + "dictionary" : { + "_0" : { + "double" : { + + } + } + } + } + } + ], + "returnType" : { + "dictionary" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripDictionaryJSObject", + "parameters" : [ + { + "name" : "values", + "type" : { + "dictionary" : { + "_0" : { + "jsObject" : { + + } + } + } + } + } + ], + "returnType" : { + "dictionary" : { + "_0" : { + "jsObject" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripDictionaryJSValue", + "parameters" : [ + { + "name" : "values", + "type" : { + "dictionary" : { + "_0" : { + "jsValue" : { + + } + } + } + } + } + ], + "returnType" : { + "dictionary" : { + "_0" : { + "jsValue" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripDictionaryDoubleArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "dictionary" : { + "_0" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + } + } + } + ], + "returnType" : { + "dictionary" : { + "_0" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + } + } + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "constructor" : { + "parameters" : [ + { + "name" : "value", + "type" : { + "string" : { + + } + } + } + ] + }, + "getters" : [ + { + "name" : "value", + "type" : { + "string" : { + + } + } + } + ], + "methods" : [ + + ], + "name" : "Foo", + "setters" : [ + + ], + "staticMethods" : [ + + ] + } + ] + }, + { + "functions" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripVoid", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripNumber", + "parameters" : [ + { + "name" : "v", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripBool", + "parameters" : [ + { + "name" : "v", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripString", + "parameters" : [ + { + "name" : "v", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripJSValue", + "parameters" : [ + { + "name" : "v", + "type" : { + "jsValue" : { + + } + } + } + ], + "returnType" : { + "jsValue" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsThrowOrVoid", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsThrowOrNumber", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsThrowOrBool", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsThrowOrString", + "parameters" : [ + { + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripFeatureFlag", + "parameters" : [ + { + "name" : "flag", + "type" : { + "rawValueEnum" : { + "_0" : "FeatureFlag", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "FeatureFlag", + "_1" : "String" + } + } + }, + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runAsyncWorks", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "fetchWeatherData", + "parameters" : [ + { + "name" : "city", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "jsObject" : { + "_0" : "WeatherData" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "jsName" : "$jsWeirdFunction", + "name" : "_jsWeirdFunction", + "parameters" : [ + + ], + "returnType" : { + "double" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "from" : "global", + "name" : "parseInt", + "parameters" : [ + { + "name" : "string", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "double" : { + + } + } + } + ], + "globalGetters" : [ + { + "from" : "global", + "name" : "globalObject1", + "type" : { + "jsValue" : { + + } + } + } + ], + "types" : [ + { + "constructor" : { + "parameters" : [ + { + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "name" : "prefix", + "type" : { + "string" : { + + } + } + } + ] + }, + "getters" : [ + { + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "name" : "prefix", + "type" : { + "string" : { + + } + } + } + ], + "methods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "greet", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "changeName", + "parameters" : [ + { + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "JsGreeter", + "setters" : [ + { + "functionName" : "name_set", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "staticMethods" : [ + + ] + }, + { + "getters" : [ + { + "name" : "temperature", + "type" : { + "double" : { + + } + } + }, + { + "name" : "description", + "type" : { + "string" : { + + } + } + }, + { + "name" : "humidity", + "type" : { + "double" : { + + } + } + } + ], + "methods" : [ + + ], + "name" : "WeatherData", + "setters" : [ + { + "functionName" : "temperature_set", + "name" : "temperature", + "type" : { + "double" : { + + } + } + }, + { + "functionName" : "description_set", + "name" : "description", + "type" : { + "string" : { + + } + } + }, + { + "functionName" : "humidity_set", + "name" : "humidity", + "type" : { + "double" : { + + } + } + } + ], + "staticMethods" : [ + + ] + }, + { + "constructor" : { + "parameters" : [ + + ] + }, + "getters" : [ + + ], + "jsName" : "$WeirdClass", + "methods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "jsName" : "method-with-dashes", + "name" : "method_with_dashes", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "_WeirdClass", + "setters" : [ + + ], + "staticMethods" : [ + + ] + }, + { + "constructor" : { + "parameters" : [ + { + "name" : "value", + "type" : { + "double" : { + + } + } + } + ] + }, + "getters" : [ + + ], + "methods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "value", + "parameters" : [ + + ], + "returnType" : { + "double" : { + + } + } + } + ], + "name" : "StaticBox", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "create", + "parameters" : [ + { + "name" : "value", + "type" : { + "double" : { + + } + } + } + ], + "returnType" : { + "jsObject" : { + "_0" : "StaticBox" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "value", + "parameters" : [ + + ], + "returnType" : { + "double" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "makeDefault", + "parameters" : [ + + ], + "returnType" : { + "jsObject" : { + "_0" : "StaticBox" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "jsName" : "with-dashes", + "name" : "with_dashes", + "parameters" : [ + + ], + "returnType" : { + "jsObject" : { + "_0" : "StaticBox" + } + } + } + ] + }, + { + "constructor" : { + "parameters" : [ + { + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "name" : "age", + "type" : { + "double" : { + + } + } + }, + { + "name" : "isCat", + "type" : { + "bool" : { + + } + } + } + ] + }, + "from" : "global", + "getters" : [ + { + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "name" : "age", + "type" : { + "double" : { + + } + } + }, + { + "name" : "isCat", + "type" : { + "bool" : { + + } + } + } + ], + "methods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "bark", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "getIsCat", + "parameters" : [ + + ], + "returnType" : { + "bool" : { + + } + } + } + ], + "name" : "Animal", + "setters" : [ + { + "functionName" : "name_set", + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "functionName" : "age_set", + "name" : "age", + "type" : { + "double" : { + + } + } + }, + { + "functionName" : "isCat_set", + "name" : "isCat", + "type" : { + "bool" : { + + } + } + } + ], + "staticMethods" : [ + + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "IdentityModeSupportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsIdentityModeSupportTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + }, + { + "functions" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsTranslatePoint", + "parameters" : [ + { + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "Point" + } + } + }, + { + "name" : "dx", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "name" : "dy", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Point" + } + } + } + ], + "types" : [ + + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "IntegerTypesSupportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripInt", + "parameters" : [ + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripUInt", + "parameters" : [ + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "word" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripInt8", + "parameters" : [ + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w8" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w8" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripUInt8", + "parameters" : [ + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w8" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w8" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripInt16", + "parameters" : [ + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w16" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w16" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripUInt16", + "parameters" : [ + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w16" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w16" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripInt32", + "parameters" : [ + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w32" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w32" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripUInt32", + "parameters" : [ + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w32" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w32" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripInt64", + "parameters" : [ + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w64" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "w64" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripUInt64", + "parameters" : [ + { + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w64" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : false, + "width" : "w64" + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsIntegerTypesSupportTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "constructor" : { + "parameters" : [ + { + "name" : "numbers", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "name" : "labels", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ] + }, + "getters" : [ + { + "name" : "numbers", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "name" : "labels", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "methods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "concatNumbers", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "concatLabels", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "firstLabel", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "JSClassWithArrayMembers", + "setters" : [ + { + "functionName" : "numbers_set", + "name" : "numbers", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "functionName" : "labels_set", + "name" : "labels", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "staticMethods" : [ + + ] + }, + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "JSClassSupportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "makeJSClassWithArrayMembers", + "parameters" : [ + { + "name" : "numbers", + "type" : { + "array" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "name" : "labels", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "jsObject" : { + "_0" : "JSClassWithArrayMembers" + } + } + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "constructor" : { + "parameters" : [ + + ] + }, + "from" : "global", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "MyJSClassInternal", + "setters" : [ + + ], + "staticMethods" : [ + + ] + }, + { + "constructor" : { + "parameters" : [ + + ] + }, + "from" : "global", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "MyJSClassPublic", + "setters" : [ + + ], + "staticMethods" : [ + + ] + }, + { + "constructor" : { + "parameters" : [ + + ] + }, + "from" : "global", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "MyJSClassPackage", + "setters" : [ + + ], + "staticMethods" : [ + + ] + } + ] + }, + { + "functions" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsFunctionWithPackageAccess", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsFunctionWithPublicAccess", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsFunctionWithInternalAccess", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsFunctionWithFilePrivateAccess", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsFunctionWithPrivateAccess", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ], + "types" : [ + + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "OptionalSupportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalNumberNull", + "parameters" : [ + { + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "null" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalNumberUndefined", + "parameters" : [ + { + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "undefined" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "_1" : "undefined" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalStringNull", + "parameters" : [ + { + "name" : "name", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalStringUndefined", + "parameters" : [ + { + "name" : "name", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "undefined" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "undefined" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalJSValueArrayNull", + "parameters" : [ + { + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + }, + "_1" : "null" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalJSValueArrayUndefined", + "parameters" : [ + { + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + }, + "_1" : "undefined" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsValue" : { + + } + } + } + }, + "_1" : "undefined" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalStringToStringDictionaryNull", + "parameters" : [ + { + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "dictionary" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "dictionary" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalStringToStringDictionaryUndefined", + "parameters" : [ + { + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "dictionary" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "undefined" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "dictionary" : { + "_0" : { + "string" : { + + } + } + } + }, + "_1" : "undefined" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsOptionalSupportTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + }, + { + "functions" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "from" : "global", + "name" : "gc", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ], + "types" : [ + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "SwiftClassSupportImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripGreeter", + "parameters" : [ + { + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripUUID", + "parameters" : [ + { + "name" : "uuid", + "type" : { + "swiftHeapObject" : { + "_0" : "UUID" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "UUID" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalGreeter", + "parameters" : [ + { + "name" : "greeter", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsConsumeLeakCheck", + "parameters" : [ + { + "name" : "value", + "type" : { + "swiftHeapObject" : { + "_0" : "LeakCheck" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsConsumeOptionalLeakCheck", + "parameters" : [ + { + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "LeakCheck" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + } + ] + }, + "moduleName" : "BridgeJSRuntimeTests" +} \ No newline at end of file diff --git a/Tests/BridgeJSRuntimeTests/IdentityModeSupportTests.swift b/Tests/BridgeJSIdentityTests/IdentityModeTests.swift similarity index 87% rename from Tests/BridgeJSRuntimeTests/IdentityModeSupportTests.swift rename to Tests/BridgeJSIdentityTests/IdentityModeTests.swift index a7c41035e..795b0679b 100644 --- a/Tests/BridgeJSRuntimeTests/IdentityModeSupportTests.swift +++ b/Tests/BridgeJSIdentityTests/IdentityModeTests.swift @@ -1,13 +1,13 @@ import XCTest import JavaScriptKit -@JSClass struct IdentityModeSupportImports { - @JSFunction static func runJsIdentityModeSupportTests() throws(JSException) +@JSClass struct IdentityModeTestImports { + @JSFunction static func runJsIdentityModeTests() throws(JSException) } -final class IdentityModeSupportTests: XCTestCase { - func testRunJsIdentityModeSupportTests() throws { - try IdentityModeSupportImports.runJsIdentityModeSupportTests() +final class IdentityModeTests: XCTestCase { + func testRunJsIdentityModeTests() throws { + try IdentityModeTestImports.runJsIdentityModeTests() } } diff --git a/Tests/BridgeJSRuntimeTests/JavaScript/IdentityModeSupportTests.mjs b/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs similarity index 58% rename from Tests/BridgeJSRuntimeTests/JavaScript/IdentityModeSupportTests.mjs rename to Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs index a17a9b1c7..b2ae2187d 100644 --- a/Tests/BridgeJSRuntimeTests/JavaScript/IdentityModeSupportTests.mjs +++ b/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs @@ -3,11 +3,11 @@ import assert from "node:assert"; /** - * @returns {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Imports["IdentityModeSupportImports"]} + * @returns {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Imports["IdentityModeTestImports"]} */ export function getImports(importsContext) { return { - runJsIdentityModeSupportTests: () => { + runJsIdentityModeTests: () => { const exports = importsContext.getExports(); if (!exports) { throw new Error("No exports!?"); @@ -21,55 +21,38 @@ export function getImports(importsContext) { * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ function runIdentityModeTests(exports) { - const identityMode = process.env.IDENTITY_MODE || undefined; - - testWrapperIdentity(exports, identityMode); - testCacheInvalidationOnRelease(exports, identityMode); + testWrapperIdentity(exports); + testCacheInvalidationOnRelease(exports); testDifferentClassesDontCollide(exports); - testRetainLeakOnCacheHit(exports, identityMode); - testArrayElementIdentity(exports, identityMode); - testArrayElementMatchesSingleGetter(exports, identityMode); - testArrayRetainLeak(exports, identityMode); + testRetainLeakOnCacheHit(exports); + testArrayElementIdentity(exports); + testArrayElementMatchesSingleGetter(exports); + testArrayRetainLeak(exports); } /** * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports - * @param {string | undefined} identityMode */ -function testWrapperIdentity(exports, identityMode) { +function testWrapperIdentity(exports) { exports.resetSharedSubject(); const a = exports.getSharedSubject(); const b = exports.getSharedSubject(); - if (identityMode === "pointer") { - assert.strictEqual( - a, - b, - "In pointer mode, same Swift object should return identical JS wrapper", - ); - } else { - assert.notStrictEqual( - a, - b, - "In default mode, same Swift object should return different JS wrappers", - ); - } - + assert.strictEqual( + a, + b, + "Same Swift object should return identical JS wrapper", + ); assert.equal(a.currentValue, 42); - assert.equal(b.currentValue, 42); a.release(); - if (a !== b) { - b.release(); - } exports.resetSharedSubject(); } /** * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports - * @param {string | undefined} identityMode */ -function testCacheInvalidationOnRelease(exports, identityMode) { +function testCacheInvalidationOnRelease(exports) { exports.resetSharedSubject(); const first = exports.getSharedSubject(); first.release(); @@ -90,16 +73,13 @@ function testCacheInvalidationOnRelease(exports, identityMode) { /** * Verifies that repeated boundary crossings of the same Swift object don't leak - * retain counts. In pointer mode, each cache hit triggers passRetained on the - * Swift side. Without the balancing deinit(pointer) call on cache hit, each - * crossing leaks +1 retain and the object is never deallocated. + * retain counts. Each cache hit triggers passRetained on the Swift side. Without + * the balancing deinit(pointer) call on cache hit, each crossing leaks +1 retain + * and the object is never deallocated. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports - * @param {string | undefined} identityMode */ -function testRetainLeakOnCacheHit(exports, identityMode) { - if (identityMode !== "pointer") return; - +function testRetainLeakOnCacheHit(exports) { exports.resetRetainLeakDeinits(); exports.resetRetainLeakSubject(); @@ -128,29 +108,23 @@ function testRetainLeakOnCacheHit(exports, identityMode) { } /** - * Verifies that elements at the same index across repeated array returns are === - * in pointer mode. Without pointer mode, they should be different wrappers. - * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports - * @param {string | undefined} identityMode */ -function testArrayElementIdentity(exports, identityMode) { - if (identityMode !== "pointer") return; - +function testArrayElementIdentity(exports) { exports.setupArrayPool(10); const arr1 = exports.getArrayPool(); const arr2 = exports.getArrayPool(); - assert.equal(arr1.length, 10, "First array should have 10 elements"); - assert.equal(arr2.length, 10, "Second array should have 10 elements"); + assert.equal(arr1.length, 10); + assert.equal(arr2.length, 10); for (let i = 0; i < 10; i++) { assert.strictEqual( arr1[i], arr2[i], - `Array element at index ${i} should be === across calls in pointer mode`, + `Array element at index ${i} should be === across calls`, ); - assert.equal(arr1[i].tag, i, `Element ${i} should have correct tag`); + assert.equal(arr1[i].tag, i); } for (const elem of arr1) { @@ -160,15 +134,9 @@ function testArrayElementIdentity(exports, identityMode) { } /** - * Verifies that an array element is === to the same object returned via - * a single-element getter. - * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports - * @param {string | undefined} identityMode */ -function testArrayElementMatchesSingleGetter(exports, identityMode) { - if (identityMode !== "pointer") return; - +function testArrayElementMatchesSingleGetter(exports) { exports.setupArrayPool(5); const arr = exports.getArrayPool(); const single = exports.getArrayPoolElement(2); @@ -176,7 +144,7 @@ function testArrayElementMatchesSingleGetter(exports, identityMode) { assert.strictEqual( arr[2], single, - "Array element and single getter should return the same wrapper in pointer mode", + "Array element and single getter should return the same wrapper", ); assert.equal(single.tag, 2); @@ -187,16 +155,9 @@ function testArrayElementMatchesSingleGetter(exports, identityMode) { } /** - * Verifies that returning an array of N objects M times doesn't leak retains. - * After releasing all wrappers and clearing the pool, all objects should be - * deallocated. - * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports - * @param {string | undefined} identityMode */ -function testArrayRetainLeak(exports, identityMode) { - if (identityMode !== "pointer") return; - +function testArrayRetainLeak(exports) { exports.resetArrayPoolDeinits(); exports.setupArrayPool(5); @@ -223,17 +184,17 @@ function testArrayRetainLeak(exports, identityMode) { * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ function testDifferentClassesDontCollide(exports) { - const greeter = new exports.Greeter("IdentityTest"); - const subject = new exports.IdentityTestSubject(99); + const subject1 = new exports.IdentityTestSubject(1); + const subject2 = new exports.IdentityTestSubject(2); assert.notStrictEqual( - greeter, - subject, - "Instances of different classes should never be ===", + subject1, + subject2, + "Different instances should not be ===", ); - assert.equal(greeter.name, "IdentityTest"); - assert.equal(subject.currentValue, 99); + assert.equal(subject1.currentValue, 1); + assert.equal(subject2.currentValue, 2); - greeter.release(); - subject.release(); + subject1.release(); + subject2.release(); } diff --git a/Tests/BridgeJSIdentityTests/bridge-js.config.json b/Tests/BridgeJSIdentityTests/bridge-js.config.json new file mode 100644 index 000000000..29884404e --- /dev/null +++ b/Tests/BridgeJSIdentityTests/bridge-js.config.json @@ -0,0 +1,3 @@ +{ + "identityMode": "pointer" +} diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift index d28b05055..a37a7e4c5 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift @@ -7656,132 +7656,6 @@ public func _bjs_makeAdder(_ base: Int32) -> Int32 { #endif } -@_expose(wasm, "bjs_getSharedSubject") -@_cdecl("bjs_getSharedSubject") -public func _bjs_getSharedSubject() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = getSharedSubject() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_resetSharedSubject") -@_cdecl("bjs_resetSharedSubject") -public func _bjs_resetSharedSubject() -> Void { - #if arch(wasm32) - resetSharedSubject() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getRetainLeakSubject") -@_cdecl("bjs_getRetainLeakSubject") -public func _bjs_getRetainLeakSubject() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = getRetainLeakSubject() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_resetRetainLeakSubject") -@_cdecl("bjs_resetRetainLeakSubject") -public func _bjs_resetRetainLeakSubject() -> Void { - #if arch(wasm32) - resetRetainLeakSubject() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getRetainLeakDeinits") -@_cdecl("bjs_getRetainLeakDeinits") -public func _bjs_getRetainLeakDeinits() -> Int32 { - #if arch(wasm32) - let ret = getRetainLeakDeinits() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_resetRetainLeakDeinits") -@_cdecl("bjs_resetRetainLeakDeinits") -public func _bjs_resetRetainLeakDeinits() -> Void { - #if arch(wasm32) - resetRetainLeakDeinits() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_setupArrayPool") -@_cdecl("bjs_setupArrayPool") -public func _bjs_setupArrayPool(_ count: Int32) -> Void { - #if arch(wasm32) - setupArrayPool(_: Int.bridgeJSLiftParameter(count)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getArrayPool") -@_cdecl("bjs_getArrayPool") -public func _bjs_getArrayPool() -> Void { - #if arch(wasm32) - let ret = getArrayPool() - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getArrayPoolElement") -@_cdecl("bjs_getArrayPoolElement") -public func _bjs_getArrayPoolElement(_ index: Int32) -> Void { - #if arch(wasm32) - let ret = getArrayPoolElement(_: Int.bridgeJSLiftParameter(index)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getArrayPoolDeinits") -@_cdecl("bjs_getArrayPoolDeinits") -public func _bjs_getArrayPoolDeinits() -> Int32 { - #if arch(wasm32) - let ret = getArrayPoolDeinits() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_resetArrayPoolDeinits") -@_cdecl("bjs_resetArrayPoolDeinits") -public func _bjs_resetArrayPoolDeinits() -> Void { - #if arch(wasm32) - resetArrayPoolDeinits() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_clearArrayPool") -@_cdecl("bjs_clearArrayPool") -public func _bjs_clearArrayPool() -> Void { - #if arch(wasm32) - clearArrayPool() - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_roundTripPointerFields") @_cdecl("bjs_roundTripPointerFields") public func _bjs_roundTripPointerFields() -> Void { @@ -10598,206 +10472,6 @@ fileprivate func _bjs_TextProcessor_wrap_extern(_ pointer: UnsafeMutableRawPoint return _bjs_TextProcessor_wrap_extern(pointer) } -@_expose(wasm, "bjs_IdentityTestSubject_init") -@_cdecl("bjs_IdentityTestSubject_init") -public func _bjs_IdentityTestSubject_init(_ value: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = IdentityTestSubject(value: Int.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IdentityTestSubject_value_get") -@_cdecl("bjs_IdentityTestSubject_value_get") -public func _bjs_IdentityTestSubject_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = IdentityTestSubject.bridgeJSLiftParameter(_self).value - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IdentityTestSubject_value_set") -@_cdecl("bjs_IdentityTestSubject_value_set") -public func _bjs_IdentityTestSubject_value_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - IdentityTestSubject.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IdentityTestSubject_currentValue_get") -@_cdecl("bjs_IdentityTestSubject_currentValue_get") -public func _bjs_IdentityTestSubject_currentValue_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = IdentityTestSubject.bridgeJSLiftParameter(_self).currentValue - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IdentityTestSubject_deinit") -@_cdecl("bjs_IdentityTestSubject_deinit") -public func _bjs_IdentityTestSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension IdentityTestSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_IdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_IdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IdentityTestSubject_wrap") -fileprivate func _bjs_IdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_IdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_IdentityTestSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_IdentityTestSubject_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_RetainLeakSubject_init") -@_cdecl("bjs_RetainLeakSubject_init") -public func _bjs_RetainLeakSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = RetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_RetainLeakSubject_tag_get") -@_cdecl("bjs_RetainLeakSubject_tag_get") -public func _bjs_RetainLeakSubject_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = RetainLeakSubject.bridgeJSLiftParameter(_self).tag - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_RetainLeakSubject_tag_set") -@_cdecl("bjs_RetainLeakSubject_tag_set") -public func _bjs_RetainLeakSubject_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - RetainLeakSubject.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_RetainLeakSubject_deinit") -@_cdecl("bjs_RetainLeakSubject_deinit") -public func _bjs_RetainLeakSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension RetainLeakSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_RetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_RetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_RetainLeakSubject_wrap") -fileprivate func _bjs_RetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_RetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_RetainLeakSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_RetainLeakSubject_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_ArrayIdentityElement_init") -@_cdecl("bjs_ArrayIdentityElement_init") -public func _bjs_ArrayIdentityElement_init(_ tag: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = ArrayIdentityElement(tag: Int.bridgeJSLiftParameter(tag)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArrayIdentityElement_tag_get") -@_cdecl("bjs_ArrayIdentityElement_tag_get") -public func _bjs_ArrayIdentityElement_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = ArrayIdentityElement.bridgeJSLiftParameter(_self).tag - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArrayIdentityElement_tag_set") -@_cdecl("bjs_ArrayIdentityElement_tag_set") -public func _bjs_ArrayIdentityElement_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - ArrayIdentityElement.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArrayIdentityElement_deinit") -@_cdecl("bjs_ArrayIdentityElement_deinit") -public func _bjs_ArrayIdentityElement_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension ArrayIdentityElement: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_ArrayIdentityElement_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_ArrayIdentityElement_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayIdentityElement_wrap") -fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_ArrayIdentityElement_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_ArrayIdentityElement_wrap_extern(pointer) -} - @_expose(wasm, "bjs_OptionalHolder_init") @_cdecl("bjs_OptionalHolder_init") public func _bjs_OptionalHolder_init(_ nullableGreeterIsSome: Int32, _ nullableGreeterValue: UnsafeMutableRawPointer, _ undefinedNumberIsSome: Int32, _ undefinedNumberValue: Float64) -> UnsafeMutableRawPointer { @@ -13271,25 +12945,6 @@ func _$Animal_getIsCat(_ self: JSObject) throws(JSException) -> Bool { return Bool.bridgeJSLiftReturn(ret) } -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static") -fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() -> Void -#else -fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static() -> Void { - return bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() -} - -func _$IdentityModeSupportImports_runJsIdentityModeSupportTests() throws(JSException) -> Void { - bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static() - if let error = _swift_js_take_exception() { - throw error - } -} - #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsTranslatePoint") fileprivate func bjs_jsTranslatePoint_extern(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 diff --git a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json index 76ed6dea0..dd4362fc1 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json @@ -4067,151 +4067,6 @@ ], "swiftCallName" : "TextProcessor" }, - { - "constructor" : { - "abiName" : "bjs_IdentityTestSubject_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "IdentityTestSubject", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "currentValue", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "IdentityTestSubject" - }, - { - "constructor" : { - "abiName" : "bjs_RetainLeakSubject_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "tag", - "name" : "tag", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "RetainLeakSubject", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "tag", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "RetainLeakSubject" - }, - { - "constructor" : { - "abiName" : "bjs_ArrayIdentityElement_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "tag", - "name" : "tag", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "ArrayIdentityElement", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "tag", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "ArrayIdentityElement" - }, { "constructor" : { "abiName" : "bjs_OptionalHolder_init", @@ -13943,247 +13798,6 @@ } } }, - { - "abiName" : "bjs_getSharedSubject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getSharedSubject", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "IdentityTestSubject" - } - } - }, - { - "abiName" : "bjs_resetSharedSubject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "resetSharedSubject", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_getRetainLeakSubject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getRetainLeakSubject", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "RetainLeakSubject" - } - } - }, - { - "abiName" : "bjs_resetRetainLeakSubject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "resetRetainLeakSubject", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_getRetainLeakDeinits", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getRetainLeakDeinits", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_resetRetainLeakDeinits", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "resetRetainLeakDeinits", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_setupArrayPool", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setupArrayPool", - "parameters" : [ - { - "label" : "_", - "name" : "count", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_getArrayPool", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getArrayPool", - "parameters" : [ - - ], - "returnType" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "ArrayIdentityElement" - } - } - } - } - }, - { - "abiName" : "bjs_getArrayPoolElement", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getArrayPoolElement", - "parameters" : [ - { - "label" : "_", - "name" : "index", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "ArrayIdentityElement" - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_getArrayPoolDeinits", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getArrayPoolDeinits", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_resetArrayPoolDeinits", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "resetArrayPoolDeinits", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_clearArrayPool", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "clearArrayPool", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, { "abiName" : "bjs_roundTripPointerFields", "effects" : { @@ -19560,43 +19174,6 @@ } ] }, - { - "functions" : [ - - ], - "types" : [ - { - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "IdentityModeSupportImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runJsIdentityModeSupportTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - } - ] - } - ] - }, { "functions" : [ { diff --git a/Tests/prelude.mjs b/Tests/prelude.mjs index a3a9048f7..79c0cc740 100644 --- a/Tests/prelude.mjs +++ b/Tests/prelude.mjs @@ -14,14 +14,13 @@ import { getImports as getDefaultArgumentImports } from './BridgeJSRuntimeTests/ import { getImports as getJSClassSupportImports, JSClassWithArrayMembers } from './BridgeJSRuntimeTests/JavaScript/JSClassSupportTests.mjs'; import { getImports as getIntegerTypesSupportImports } from './BridgeJSRuntimeTests/JavaScript/IntegerTypesSupportTests.mjs'; import { getImports as getAsyncImportImports, runAsyncWorksTests } from './BridgeJSRuntimeTests/JavaScript/AsyncImportTests.mjs'; -import { getImports as getIdentityModeSupportImports } from './BridgeJSRuntimeTests/JavaScript/IdentityModeSupportTests.mjs'; +import { getImports as getIdentityModeTestImports } from './BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs'; /** @type {import('../.build/plugins/PackageToJS/outputs/PackageTests/test.d.ts').SetupOptionsFn} */ export async function setupOptions(options, context) { Error.stackTraceLimit = 100; setupTestGlobals(globalThis); - const identityMode = process.env.IDENTITY_MODE || undefined; class StaticBox { constructor(value) { @@ -46,7 +45,6 @@ export async function setupOptions(options, context) { return { ...options, - ...(identityMode ? { instantiateOptions: { identityMode } } : {}), getImports: (importsContext) => { return { "jsRoundTripVoid": () => { @@ -159,7 +157,7 @@ export async function setupOptions(options, context) { DefaultArgumentImports: getDefaultArgumentImports(importsContext), JSClassSupportImports: getJSClassSupportImports(importsContext), IntegerTypesSupportImports: getIntegerTypesSupportImports(importsContext), - IdentityModeSupportImports: getIdentityModeSupportImports(importsContext), + IdentityModeTestImports: getIdentityModeTestImports(importsContext), }; }, addToCoreImports(importObject, importsContext) { From 3d1907da3817a85ca3a11cca559da93fab876548 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Fri, 17 Apr 2026 12:45:17 +0200 Subject: [PATCH 07/18] fix: Exclude identityMode from DefaultNodeSetupOptions spread in index.js TypeScript strict excess property check rejects identityMode in the spread into DefaultNodeSetupOptions. Destructure it out before spreading, since it's already handled separately via the instantiateOptions pass-through. --- Plugins/PackageToJS/Templates/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/PackageToJS/Templates/index.js b/Plugins/PackageToJS/Templates/index.js index d7636c115..1e0db0f53 100644 --- a/Plugins/PackageToJS/Templates/index.js +++ b/Plugins/PackageToJS/Templates/index.js @@ -9,9 +9,10 @@ import { defaultBrowserSetup /* #if USE_SHARED_MEMORY */, createDefaultWorkerFac /* #if TARGET_DEFAULT_PLATFORM_NODE */ /** @type {import('./index.d').init} */ async function initNode(_options) { + const { identityMode: _identityMode, ...rest } = _options || {}; /** @type {import('./platforms/node.d.ts').DefaultNodeSetupOptions} */ const options = { - ...(_options || {}), + ...rest, /* #if USE_SHARED_MEMORY */ spawnWorker: createDefaultWorkerFactoryForNode(), /* #endif */ From 5bf23cdfc96b65a19cef6eb96ba838f7942decf3 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Fri, 17 Apr 2026 13:48:41 +0200 Subject: [PATCH 08/18] fix: Regenerate BridgeJSIdentityTests with correct target and add to generate script The Generated files were incorrectly copied from BridgeJSRuntimeTests, containing types from the wrong module. Regenerate with BridgeJSTool for the BridgeJSIdentityTests target. Add target to bridge-js-generate.sh. Fix SwiftToSkeleton formatting. --- .../BridgeJSCore/SwiftToSkeleton.swift | 8 +- .../Generated/BridgeJS.swift | 14258 +---------- .../Generated/JavaScript/BridgeJS.json | 21012 +--------------- Utilities/bridge-js-generate.sh | 1 + 4 files changed, 488 insertions(+), 34791 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index 369c75e72..404eef634 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -44,7 +44,13 @@ public final class SwiftToSkeleton { public func finalize() throws -> BridgeJSSkeleton { var perSourceErrors: [(inputFilePath: String, errors: [DiagnosticError])] = [] var importedFiles: [ImportedFileSkeleton] = [] - var exported = ExportedSkeleton(functions: [], classes: [], enums: [], exposeToGlobal: exposeToGlobal, identityMode: identityMode) + var exported = ExportedSkeleton( + functions: [], + classes: [], + enums: [], + exposeToGlobal: exposeToGlobal, + identityMode: identityMode + ) var exportCollectors: [ExportSwiftAPICollector] = [] for (sourceFile, inputFilePath) in sourceFiles { diff --git a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift index 9a92a00b5..e25ebeb4c 100644 --- a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift @@ -7,14196 +7,346 @@ @_spi(BridgeJS) import JavaScriptKit -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 { +@_expose(wasm, "bjs_getSharedSubject") +@_cdecl("bjs_getSharedSubject") +public func _bjs_getSharedSubject() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = getSharedSubject() + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si(_ callback: Int32, _ param0: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(callback, param0) + #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +@_expose(wasm, "bjs_resetSharedSubject") +@_cdecl("bjs_resetSharedSubject") +public func _bjs_resetSharedSubject() -> Void { + #if arch(wasm32) + resetSharedSubject() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTests10HttpStatusO_Si { - static func bridgeJSLift(_ callbackId: Int32) -> (HttpStatus) -> Int { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si(callbackValue, param0Value) - return Int.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (HttpStatus) -> Int { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (HttpStatus) -> Int) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si, - body: body, - fileID: fileID, - line: line - ) - } + #endif } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests10HttpStatusO_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { +@_expose(wasm, "bjs_getRetainLeakSubject") +@_cdecl("bjs_getRetainLeakSubject") +public func _bjs_getRetainLeakSubject() -> UnsafeMutableRawPointer { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(HttpStatus) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(HttpStatus.bridgeJSLiftParameter(param0)) - return result.bridgeJSLowerReturn() + let ret = getRetainLeakSubject() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(_ callback: Int32, _ param0: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(_ callback: Int32, _ param0: Int32) -> Int32 { +@_expose(wasm, "bjs_resetRetainLeakSubject") +@_cdecl("bjs_resetRetainLeakSubject") +public func _bjs_resetRetainLeakSubject() -> Void { + #if arch(wasm32) + resetRetainLeakSubject() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP(_ callback: Int32, _ param0: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(callback, param0) + #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +@_expose(wasm, "bjs_getRetainLeakDeinits") +@_cdecl("bjs_getRetainLeakDeinits") +public func _bjs_getRetainLeakDeinits() -> Int32 { + #if arch(wasm32) + let ret = getRetainLeakDeinits() + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP { - static func bridgeJSLift(_ callbackId: Int32) -> (any DataProcessor) -> any DataProcessor { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0ObjectId = (param0 as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP(callbackValue, param0ObjectId) - return AnyDataProcessor.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (any DataProcessor) -> any DataProcessor { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (any DataProcessor) -> any DataProcessor) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP, - body: body, - fileID: fileID, - line: line - ) - } + #endif } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { +@_expose(wasm, "bjs_resetRetainLeakDeinits") +@_cdecl("bjs_resetRetainLeakDeinits") +public func _bjs_resetRetainLeakDeinits() -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(any DataProcessor) -> any DataProcessor>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(AnyDataProcessor.bridgeJSLiftParameter(param0)) - return (result as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn() + resetRetainLeakDeinits() #else fatalError("Only available on WebAssembly") #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 { +@_expose(wasm, "bjs_setupArrayPool") +@_cdecl("bjs_setupArrayPool") +public func _bjs_setupArrayPool(_ count: Int32) -> Void { + #if arch(wasm32) + setupArrayPool(_: Int.bridgeJSLiftParameter(count)) + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS(_ callback: Int32, _ param0: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(callback, param0) + #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +@_expose(wasm, "bjs_getArrayPool") +@_cdecl("bjs_getArrayPool") +public func _bjs_getArrayPool() -> Void { + #if arch(wasm32) + let ret = getArrayPool() + ret.bridgeJSStackPush() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTests13DataProcessorP_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (any DataProcessor) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0ObjectId = (param0 as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS(callbackValue, param0ObjectId) - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (any DataProcessor) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (any DataProcessor) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS, - body: body, - fileID: fileID, - line: line - ) - } + #endif } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests13DataProcessorP_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { +@_expose(wasm, "bjs_getArrayPoolElement") +@_cdecl("bjs_getArrayPoolElement") +public func _bjs_getArrayPoolElement(_ index: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(any DataProcessor) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(AnyDataProcessor.bridgeJSLiftParameter(param0)) - return result.bridgeJSLowerReturn() + let ret = getArrayPoolElement(_: Int.bridgeJSLiftParameter(index)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { +@_expose(wasm, "bjs_getArrayPoolDeinits") +@_cdecl("bjs_getArrayPoolDeinits") +public func _bjs_getArrayPoolDeinits() -> Int32 { + #if arch(wasm32) + let ret = getArrayPoolDeinits() + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(callback, param0Bytes, param0Length) + #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +@_expose(wasm, "bjs_resetArrayPoolDeinits") +@_cdecl("bjs_resetArrayPoolDeinits") +public func _bjs_resetArrayPoolDeinits() -> Void { + #if arch(wasm32) + resetArrayPoolDeinits() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTests5ThemeO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Theme) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS(callbackValue, param0Bytes, param0Length) - return ret - } - let ret = ret0 - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Theme) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Theme) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS, - body: body, - fileID: fileID, - line: line - ) - } + #endif } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +@_expose(wasm, "bjs_clearArrayPool") +@_cdecl("bjs_clearArrayPool") +public func _bjs_clearArrayPool() -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Theme) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Theme.bridgeJSLiftParameter(param0Bytes, param0Length)) - return result.bridgeJSLowerReturn() + clearArrayPool() #else fatalError("Only available on WebAssembly") #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { +@_expose(wasm, "bjs_IdentityTestSubject_init") +@_cdecl("bjs_IdentityTestSubject_init") +public func _bjs_IdentityTestSubject_init(_ value: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = IdentityTestSubject(value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(callback, param0Bytes, param0Length) + #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +@_expose(wasm, "bjs_IdentityTestSubject_value_get") +@_cdecl("bjs_IdentityTestSubject_value_get") +public func _bjs_IdentityTestSubject_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = IdentityTestSubject.bridgeJSLiftParameter(_self).value + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTests5ThemeO_Sb { - static func bridgeJSLift(_ callbackId: Int32) -> (Theme) -> Bool { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb(callbackValue, param0Bytes, param0Length) - return ret - } - let ret = ret0 - return Bool.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } + #endif } -extension JSTypedClosure where Signature == (Theme) -> Bool { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Theme) -> Bool) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb, - body: body, - fileID: fileID, - line: line - ) - } +@_expose(wasm, "bjs_IdentityTestSubject_value_set") +@_cdecl("bjs_IdentityTestSubject_value_set") +public func _bjs_IdentityTestSubject_value_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + IdentityTestSubject.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests5ThemeO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { +@_expose(wasm, "bjs_IdentityTestSubject_currentValue_get") +@_cdecl("bjs_IdentityTestSubject_currentValue_get") +public func _bjs_IdentityTestSubject_currentValue_get(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Theme) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Theme.bridgeJSLiftParameter(param0Bytes, param0Length)) - return result.bridgeJSLowerReturn() + let ret = IdentityTestSubject.bridgeJSLiftParameter(_self).currentValue + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_IdentityTestSubject_deinit") +@_cdecl("bjs_IdentityTestSubject_deinit") +public func _bjs_IdentityTestSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else fatalError("Only available on WebAssembly") + #endif } -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(callback, param0) + +extension IdentityTestSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_IdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_IdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "BridgeJSIdentityTests", name: "bjs_IdentityTestSubject_wrap") +fileprivate func _bjs_IdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func _bjs_IdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS_extern(boxPtr, file, line) +@inline(never) fileprivate func _bjs_IdentityTestSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_IdentityTestSubject_wrap_extern(pointer) } -private enum _BJS_Closure_20BridgeJSRuntimeTests7GreeterC_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Greeter) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Pointer = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS(callbackValue, param0Pointer) - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } +@_expose(wasm, "bjs_RetainLeakSubject_init") +@_cdecl("bjs_RetainLeakSubject_init") +public func _bjs_RetainLeakSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = RetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif } -extension JSTypedClosure where Signature == (Greeter) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Greeter) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS, - body: body, - fileID: fileID, - line: line - ) - } +@_expose(wasm, "bjs_RetainLeakSubject_tag_get") +@_cdecl("bjs_RetainLeakSubject_tag_get") +public func _bjs_RetainLeakSubject_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = RetainLeakSubject.bridgeJSLiftParameter(_self).tag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests7GreeterC_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_RetainLeakSubject_tag_set") +@_cdecl("bjs_RetainLeakSubject_tag_set") +public func _bjs_RetainLeakSubject_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Greeter) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Greeter.bridgeJSLiftParameter(param0)) - return result.bridgeJSLowerReturn() + RetainLeakSubject.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) #else fatalError("Only available on WebAssembly") #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(_ callback: Int32, _ param0: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(_ callback: Int32, _ param0: Int32) -> Int32 { +@_expose(wasm, "bjs_RetainLeakSubject_deinit") +@_cdecl("bjs_RetainLeakSubject_deinit") +public func _bjs_RetainLeakSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else fatalError("Only available on WebAssembly") + #endif } -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC(_ callback: Int32, _ param0: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(callback, param0) + +extension RetainLeakSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_RetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_RetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "BridgeJSIdentityTests", name: "bjs_RetainLeakSubject_wrap") +fileprivate func _bjs_RetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func _bjs_RetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC { - static func bridgeJSLift(_ callbackId: Int32) -> (JSObject) -> JSObject { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC(callbackValue, param0Value) - return JSObject.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (JSObject) -> JSObject { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (JSObject) -> JSObject) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC, - body: body, - fileID: fileID, - line: line - ) - } +@inline(never) fileprivate func _bjs_RetainLeakSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_RetainLeakSubject_wrap_extern(pointer) } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests8JSObjectC_8JSObjectC(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { +@_expose(wasm, "bjs_ArrayIdentityElement_init") +@_cdecl("bjs_ArrayIdentityElement_init") +public func _bjs_ArrayIdentityElement_init(_ tag: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(JSObject) -> JSObject>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(JSObject.bridgeJSLiftParameter(param0)) - return result.bridgeJSLowerReturn() + let ret = ArrayIdentityElement(tag: Int.bridgeJSLiftParameter(tag)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS(_ callback: Int32, _ param0: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(callback, param0) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTests9APIResultO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (APIResult) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0CaseId = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS(callbackValue, param0CaseId) - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (APIResult) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (APIResult) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(APIResult) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(APIResult.bridgeJSLiftParameter(param0)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(_ callback: Int32, _ param0: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS(_ callback: Int32, _ param0: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(callback, param0) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTests9DirectionO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Direction) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS(callbackValue, param0Value) - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Direction) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Direction) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Direction) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Direction.bridgeJSLiftParameter(param0)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(_ callback: Int32, _ param0: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(_ callback: Int32, _ param0: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb(_ callback: Int32, _ param0: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(callback, param0) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTests9DirectionO_Sb { - static func bridgeJSLift(_ callbackId: Int32) -> (Direction) -> Bool { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb(callbackValue, param0Value) - return Bool.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Direction) -> Bool { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Direction) -> Bool) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9DirectionO_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Direction) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Direction.bridgeJSLiftParameter(param0)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> UnsafeMutableRawPointer -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> UnsafeMutableRawPointer { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> UnsafeMutableRawPointer { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(callback, param0Bytes, param0Length) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSS_7GreeterC { - static func bridgeJSLift(_ callbackId: Int32) -> (String) -> Greeter { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC(callbackValue, param0Bytes, param0Length) - return ret - } - let ret = ret0 - return Greeter.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (String) -> Greeter { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) -> Greeter) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_7GreeterC(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) -> Greeter>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(callback, param0Bytes, param0Length) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSS_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (String) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS(callbackValue, param0Bytes, param0Length) - return ret - } - let ret = ret0 - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (String) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(_ callback: Int32, _ param0: Float64) -> Float64 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(_ callback: Int32, _ param0: Float64) -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd(_ callback: Int32, _ param0: Float64) -> Float64 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(callback, param0) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSd_Sd { - static func bridgeJSLift(_ callbackId: Int32) -> (Double) -> Double { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd(callbackValue, param0Value) - return Double.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Double) -> Double { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Double) -> Double) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSd_Sd(_ boxPtr: UnsafeMutableRawPointer, _ param0: Float64) -> Float64 { +@_expose(wasm, "bjs_ArrayIdentityElement_tag_get") +@_cdecl("bjs_ArrayIdentityElement_tag_get") +public func _bjs_ArrayIdentityElement_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Double) -> Double>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Double.bridgeJSLiftParameter(param0)) - return result.bridgeJSLowerReturn() + let ret = ArrayIdentityElement.bridgeJSLiftParameter(_self).tag + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(_ callback: Int32, _ param0: Int32, _ param1Bytes: Int32, _ param1Length: Int32, _ param2: Float64) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(_ callback: Int32, _ param0: Int32, _ param1Bytes: Int32, _ param1Length: Int32, _ param2: Float64) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS(_ callback: Int32, _ param0: Int32, _ param1Bytes: Int32, _ param1Length: Int32, _ param2: Float64) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(callback, param0, param1Bytes, param1Length, param2) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSiSSSd_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Int, String, Double) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] (param0, param1, param2) in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - let ret0 = param1.bridgeJSWithLoweredParameter { (param1Bytes, param1Length) in - let param2Value = param2.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS(callbackValue, param0Value, param1Bytes, param1Length, param2Value) - return ret - } - let ret = ret0 - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Int, String, Double) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Int, String, Double) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSSSd_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32, _ param1Bytes: Int32, _ param1Length: Int32, _ param2: Float64) -> Void { +@_expose(wasm, "bjs_ArrayIdentityElement_tag_set") +@_cdecl("bjs_ArrayIdentityElement_tag_set") +public func _bjs_ArrayIdentityElement_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Int, String, Double) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Int.bridgeJSLiftParameter(param0), String.bridgeJSLiftParameter(param1Bytes, param1Length), Double.bridgeJSLiftParameter(param2)) - return result.bridgeJSLowerReturn() + ArrayIdentityElement.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) #else fatalError("Only available on WebAssembly") #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(_ callback: Int32, _ param0: Int32, _ param1: Int32, _ param2: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(_ callback: Int32, _ param0: Int32, _ param1: Int32, _ param2: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si(_ callback: Int32, _ param0: Int32, _ param1: Int32, _ param2: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(callback, param0, param1, param2) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSiSiSi_Si { - static func bridgeJSLift(_ callbackId: Int32) -> (Int, Int, Int) -> Int { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] (param0, param1, param2) in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - let param1Value = param1.bridgeJSLowerParameter() - let param2Value = param2.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si(callbackValue, param0Value, param1Value, param2Value) - return Int.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Int, Int, Int) -> Int { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Int, Int, Int) -> Int) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSiSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32, _ param1: Int32, _ param2: Int32) -> Int32 { +@_expose(wasm, "bjs_ArrayIdentityElement_deinit") +@_cdecl("bjs_ArrayIdentityElement_deinit") +public func _bjs_ArrayIdentityElement_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Int, Int, Int) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Int.bridgeJSLiftParameter(param0), Int.bridgeJSLiftParameter(param1), Int.bridgeJSLiftParameter(param2)) - return result.bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(_ callback: Int32, _ param0: Int32, _ param1: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(_ callback: Int32, _ param0: Int32, _ param1: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si(_ callback: Int32, _ param0: Int32, _ param1: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(callback, param0, param1) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSiSi_Si { - static func bridgeJSLift(_ callbackId: Int32) -> (Int, Int) -> Int { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] (param0, param1) in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - let param1Value = param1.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si(callbackValue, param0Value, param1Value) - return Int.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } +extension ArrayIdentityElement: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ArrayIdentityElement_wrap(Unmanaged.passRetained(self).toOpaque())))) } -} - -extension JSTypedClosure where Signature == (Int, Int) -> Int { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Int, Int) -> Int) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si, - body: body, - fileID: fileID, - line: line - ) + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ArrayIdentityElement_wrap(Unmanaged.passRetained(self).toOpaque()) } } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSiSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32, _ param1: Int32) -> Int32 { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Int, Int) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Int.bridgeJSLiftParameter(param0), Int.bridgeJSLiftParameter(param1)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si(_ callback: Int32, _ param0: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(callback, param0) -} - #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "BridgeJSIdentityTests", name: "bjs_ArrayIdentityElement_wrap") +fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSi_Si { - static func bridgeJSLift(_ callbackId: Int32) -> (Int) -> Int { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si(callbackValue, param0Value) - return Int.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Int) -> Int { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Int) -> Int) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Int) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Int.bridgeJSLiftParameter(param0)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif +@inline(never) fileprivate func _bjs_ArrayIdentityElement_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ArrayIdentityElement_wrap_extern(pointer) } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(_ callback: Int32, _ param0: Int32) -> Void +@_extern(wasm, module: "BridgeJSIdentityTests", name: "bjs_IdentityModeTestImports_runJsIdentityModeTests_static") +fileprivate func bjs_IdentityModeTestImports_runJsIdentityModeTests_static_extern() -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(_ callback: Int32, _ param0: Int32) -> Void { +fileprivate func bjs_IdentityModeTestImports_runJsIdentityModeTests_static_extern() -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y(_ callback: Int32, _ param0: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(callback, param0) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSi_y { - static func bridgeJSLift(_ callbackId: Int32) -> (Int) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y(callbackValue, param0Value) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Int) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Int) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSi_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Int) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(Int.bridgeJSLiftParameter(param0)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0ObjectId: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0ObjectId: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0ObjectId: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(callback, param0IsSome, param0ObjectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSq13DataProcessorP_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let (param0IsSome, param0ObjectId): (Int32, Int32) - if let param0 { - (param0IsSome, param0ObjectId) = (1, (param0 as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) - } else { - (param0IsSome, param0ObjectId) = (0, 0) - } - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS(callbackValue, param0IsSome, param0ObjectId) - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq13DataProcessorP_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(callback, param0IsSome, param0Bytes, param0Length) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSq5ThemeO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let ret0 = param0.bridgeJSWithLoweredParameter { (param0IsSome, param0Bytes, param0Length) in - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(callbackValue, param0IsSome, param0Bytes, param0Length) - return ret - } - let ret = ret0 - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq5ThemeO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(callback, param0IsSome, param0Pointer) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSq7GreeterC_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let (param0IsSome, param0Pointer) = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(callbackValue, param0IsSome, param0Pointer) - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC(_ callback: Int32, _ param0IsSome: Int32, _ param0Pointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(callback, param0IsSome, param0Pointer) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> Optional { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let (param0IsSome, param0Pointer) = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC(callbackValue, param0IsSome, param0Pointer) - return Optional.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Optional) -> Optional { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> Optional) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(callback, param0IsSome, param0CaseId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSq9APIResultO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let (param0IsSome, param0CaseId) = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS(callbackValue, param0IsSome, param0CaseId) - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9APIResultO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0CaseId)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(callback, param0IsSome, param0Value) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSq9DirectionO_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS(callbackValue, param0IsSome, param0Value) - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSq9DirectionO_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(callback, param0IsSome, param0Bytes, param0Length) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSqSS_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let ret0 = param0.bridgeJSWithLoweredParameter { (param0IsSome, param0Bytes, param0Length) in - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS(callbackValue, param0IsSome, param0Bytes, param0Length) - return ret - } - let ret = ret0 - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(callback, param0IsSome, param0Value) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsSqSi_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS(callbackValue, param0IsSome, param0Value) - return String.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(callback, param0Bytes, param0Length) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestss11FeatureFlagO_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending FeatureFlag) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(callbackValue, param0Bytes, param0Length) - } - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (sending FeatureFlag) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending FeatureFlag) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending FeatureFlag) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(FeatureFlag.bridgeJSLiftParameter(param0Bytes, param0Length)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ callback: Int32, _ param0: Int32) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ callback: Int32, _ param0: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(_ callback: Int32, _ param0: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(callback, param0) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestss11WeatherDataC_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending WeatherData) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(callbackValue, param0Value) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (sending WeatherData) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending WeatherData) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending WeatherData) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(WeatherData.bridgeJSLiftParameter(param0)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(callback, param0Kind, param0Payload1, param0Payload2) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestss7JSValueV_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending JSValue) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let (param0Kind, param0Payload1, param0Payload2) = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y(callbackValue, param0Kind, param0Payload1, param0Payload2) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (sending JSValue) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending JSValue) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y(_ boxPtr: UnsafeMutableRawPointer, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending JSValue) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(JSValue.bridgeJSLiftParameter(param0Kind, param0Payload1, param0Payload2)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(callback, param0Bytes, param0Length) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestssSS_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending String) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(callbackValue, param0Bytes, param0Length) - } - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (sending String) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending String) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending String) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(_ callback: Int32) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(_ callback: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(_ callback: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSS_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending [String]) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let _ = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(callbackValue) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (sending [String]) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending [String]) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending [String]) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure([String].bridgeJSLiftParameter()) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(_ callback: Int32) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(_ callback: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y(_ callback: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSb_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending [Bool]) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let _ = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y(callbackValue) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (sending [Bool]) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending [Bool]) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending [Bool]) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure([Bool].bridgeJSLiftParameter()) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(_ callback: Int32) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(_ callback: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y(_ callback: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSd_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending [Double]) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let _ = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y(callbackValue) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (sending [Double]) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending [Double]) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending [Double]) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure([Double].bridgeJSLiftParameter()) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(_ callback: Int32, _ param0: Int32) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(_ callback: Int32, _ param0: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y(_ callback: Int32, _ param0: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(callback, param0) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestssSb_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending Bool) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y(callbackValue, param0Value) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (sending Bool) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Bool) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Bool) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(Bool.bridgeJSLiftParameter(param0)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(_ callback: Int32, _ param0: Float64) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(_ callback: Int32, _ param0: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y(_ callback: Int32, _ param0: Float64) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(callback, param0) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestssSd_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending Double) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y(callbackValue, param0Value) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (sending Double) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Double) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Float64) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Double) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(Double.bridgeJSLiftParameter(param0)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(callback, param0IsSome, param0Bytes, param0Length) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestssSqSS_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending Optional) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - param0.bridgeJSWithLoweredParameter { (param0IsSome, param0Bytes, param0Length) in - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y(callbackValue, param0IsSome, param0Bytes, param0Length) - } - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (sending Optional) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Optional) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Optional) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float64) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float64) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(callback, param0IsSome, param0Value) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestssSqSd_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending Optional) -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y(callbackValue, param0IsSome, param0Value) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (sending Optional) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Optional) -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0Value: Float64) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Optional) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ callback: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ callback: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP(_ callback: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsy_13DataProcessorP { - static func bridgeJSLift(_ callbackId: Int32) -> () -> any DataProcessor { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP(callbackValue) - return AnyDataProcessor.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == () -> any DataProcessor { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> any DataProcessor) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP(_ boxPtr: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<() -> any DataProcessor>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure() - return (result as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(_ callback: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(_ callback: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb(_ callback: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsy_Sb { - static func bridgeJSLift(_ callbackId: Int32) -> () -> Bool { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb(callbackValue) - return Bool.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == () -> Bool { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> Bool) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb(_ boxPtr: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<() -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure() - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ callback: Int32) -> UnsafeMutableRawPointer -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ callback: Int32) -> UnsafeMutableRawPointer { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC(_ callback: Int32) -> UnsafeMutableRawPointer { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsy_Sq7GreeterC { - static func bridgeJSLift(_ callbackId: Int32) -> () -> Optional { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC(callbackValue) - return Optional.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == () -> Optional { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> Optional) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC(_ boxPtr: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<() -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure() - return result.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(_ callback: Int32) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(_ callback: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y(_ callback: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsy_y { - static func bridgeJSLift(_ callbackId: Int32) -> () -> Void { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y(callbackValue) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == () -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> Void) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<() -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure() - #else - fatalError("Only available on WebAssembly") - #endif -} - -struct AnyArrayElementProtocol: ArrayElementProtocol, _BridgedSwiftProtocolWrapper { - let jsObject: JSObject - - var value: Int { - get { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = bjs_ArrayElementProtocol_value_get(jsObjectValue) - return Int.bridgeJSLiftReturn(ret) - } - set { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let newValueValue = newValue.bridgeJSLowerParameter() - bjs_ArrayElementProtocol_value_set(jsObjectValue, newValueValue) - } - } - - static func bridgeJSLiftParameter(_ value: Int32) -> Self { - return AnyArrayElementProtocol(jsObject: JSObject(id: UInt32(bitPattern: value))) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayElementProtocol_value_get") -fileprivate func bjs_ArrayElementProtocol_value_get_extern(_ jsObject: Int32) -> Int32 -#else -fileprivate func bjs_ArrayElementProtocol_value_get_extern(_ jsObject: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArrayElementProtocol_value_get(_ jsObject: Int32) -> Int32 { - return bjs_ArrayElementProtocol_value_get_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayElementProtocol_value_set") -fileprivate func bjs_ArrayElementProtocol_value_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void -#else -fileprivate func bjs_ArrayElementProtocol_value_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArrayElementProtocol_value_set(_ jsObject: Int32, _ newValue: Int32) -> Void { - return bjs_ArrayElementProtocol_value_set_extern(jsObject, newValue) -} - -struct AnyDataProcessor: DataProcessor, _BridgedSwiftProtocolWrapper { - let jsObject: JSObject - - func increment(by amount: Int) -> Void { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let amountValue = amount.bridgeJSLowerParameter() - _extern_increment(jsObjectValue, amountValue) - } - - func getValue() -> Int { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = _extern_getValue(jsObjectValue) - return Int.bridgeJSLiftReturn(ret) - } - - func setLabelElements(_ labelPrefix: String, _ labelSuffix: String) -> Void { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - labelPrefix.bridgeJSWithLoweredParameter { (labelPrefixBytes, labelPrefixLength) in - labelSuffix.bridgeJSWithLoweredParameter { (labelSuffixBytes, labelSuffixLength) in - _extern_setLabelElements(jsObjectValue, labelPrefixBytes, labelPrefixLength, labelSuffixBytes, labelSuffixLength) - } - } - } - - func getLabel() -> String { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = _extern_getLabel(jsObjectValue) - return String.bridgeJSLiftReturn(ret) - } - - func isEven() -> Bool { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = _extern_isEven(jsObjectValue) - return Bool.bridgeJSLiftReturn(ret) - } - - func processGreeter(_ greeter: Greeter) -> String { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let greeterPointer = greeter.bridgeJSLowerParameter() - let ret = _extern_processGreeter(jsObjectValue, greeterPointer) - return String.bridgeJSLiftReturn(ret) - } - - func createGreeter() -> Greeter { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = _extern_createGreeter(jsObjectValue) - return Greeter.bridgeJSLiftReturn(ret) - } - - func processOptionalGreeter(_ greeter: Optional) -> String { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let (greeterIsSome, greeterPointer) = greeter.bridgeJSLowerParameter() - let ret = _extern_processOptionalGreeter(jsObjectValue, greeterIsSome, greeterPointer) - return String.bridgeJSLiftReturn(ret) - } - - func createOptionalGreeter() -> Optional { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = _extern_createOptionalGreeter(jsObjectValue) - return Optional.bridgeJSLiftReturn(ret) - } - - func handleAPIResult(_ result: Optional) -> Void { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let (resultIsSome, resultCaseId) = result.bridgeJSLowerParameter() - _extern_handleAPIResult(jsObjectValue, resultIsSome, resultCaseId) - } - - func getAPIResult() -> Optional { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = _extern_getAPIResult(jsObjectValue) - return Optional.bridgeJSLiftReturn(ret) - } - - var count: Int { - get { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = bjs_DataProcessor_count_get(jsObjectValue) - return Int.bridgeJSLiftReturn(ret) - } - set { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let newValueValue = newValue.bridgeJSLowerParameter() - bjs_DataProcessor_count_set(jsObjectValue, newValueValue) - } - } - - var name: String { - get { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = bjs_DataProcessor_name_get(jsObjectValue) - return String.bridgeJSLiftReturn(ret) - } - } - - var optionalTag: Optional { - get { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - bjs_DataProcessor_optionalTag_get(jsObjectValue) - return Optional.bridgeJSLiftReturnFromSideChannel() - } - set { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - newValue.bridgeJSWithLoweredParameter { (newValueIsSome, newValueBytes, newValueLength) in - bjs_DataProcessor_optionalTag_set(jsObjectValue, newValueIsSome, newValueBytes, newValueLength) - } - } - } - - var optionalCount: Optional { - get { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - bjs_DataProcessor_optionalCount_get(jsObjectValue) - return Optional.bridgeJSLiftReturnFromSideChannel() - } - set { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let (newValueIsSome, newValueValue) = newValue.bridgeJSLowerParameter() - bjs_DataProcessor_optionalCount_set(jsObjectValue, newValueIsSome, newValueValue) - } - } - - var direction: Optional { - get { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = bjs_DataProcessor_direction_get(jsObjectValue) - return Optional.bridgeJSLiftReturn(ret) - } - set { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let (newValueIsSome, newValueValue) = newValue.bridgeJSLowerParameter() - bjs_DataProcessor_direction_set(jsObjectValue, newValueIsSome, newValueValue) - } - } - - var optionalTheme: Optional { - get { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - bjs_DataProcessor_optionalTheme_get(jsObjectValue) - return Optional.bridgeJSLiftReturnFromSideChannel() - } - set { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - newValue.bridgeJSWithLoweredParameter { (newValueIsSome, newValueBytes, newValueLength) in - bjs_DataProcessor_optionalTheme_set(jsObjectValue, newValueIsSome, newValueBytes, newValueLength) - } - } - } - - var httpStatus: Optional { - get { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - bjs_DataProcessor_httpStatus_get(jsObjectValue) - return Optional.bridgeJSLiftReturnFromSideChannel() - } - set { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let (newValueIsSome, newValueValue) = newValue.bridgeJSLowerParameter() - bjs_DataProcessor_httpStatus_set(jsObjectValue, newValueIsSome, newValueValue) - } - } - - var apiResult: Optional { - get { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = bjs_DataProcessor_apiResult_get(jsObjectValue) - return Optional.bridgeJSLiftReturn(ret) - } - set { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let (newValueIsSome, newValueCaseId) = newValue.bridgeJSLowerParameter() - bjs_DataProcessor_apiResult_set(jsObjectValue, newValueIsSome, newValueCaseId) - } - } - - var helper: Greeter { - get { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = bjs_DataProcessor_helper_get(jsObjectValue) - return Greeter.bridgeJSLiftReturn(ret) - } - set { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let newValuePointer = newValue.bridgeJSLowerParameter() - bjs_DataProcessor_helper_set(jsObjectValue, newValuePointer) - } - } - - var optionalHelper: Optional { - get { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let ret = bjs_DataProcessor_optionalHelper_get(jsObjectValue) - return Optional.bridgeJSLiftReturn(ret) - } - set { - let jsObjectValue = jsObject.bridgeJSLowerParameter() - let (newValueIsSome, newValuePointer) = newValue.bridgeJSLowerParameter() - bjs_DataProcessor_optionalHelper_set(jsObjectValue, newValueIsSome, newValuePointer) - } - } - - static func bridgeJSLiftParameter(_ value: Int32) -> Self { - return AnyDataProcessor(jsObject: JSObject(id: UInt32(bitPattern: value))) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_increment") -fileprivate func _extern_increment_extern(_ jsObject: Int32, _ amount: Int32) -> Void -#else -fileprivate func _extern_increment_extern(_ jsObject: Int32, _ amount: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_increment(_ jsObject: Int32, _ amount: Int32) -> Void { - return _extern_increment_extern(jsObject, amount) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_getValue") -fileprivate func _extern_getValue_extern(_ jsObject: Int32) -> Int32 -#else -fileprivate func _extern_getValue_extern(_ jsObject: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_getValue(_ jsObject: Int32) -> Int32 { - return _extern_getValue_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_setLabelElements") -fileprivate func _extern_setLabelElements_extern(_ jsObject: Int32, _ labelPrefixBytes: Int32, _ labelPrefixLength: Int32, _ labelSuffixBytes: Int32, _ labelSuffixLength: Int32) -> Void -#else -fileprivate func _extern_setLabelElements_extern(_ jsObject: Int32, _ labelPrefixBytes: Int32, _ labelPrefixLength: Int32, _ labelSuffixBytes: Int32, _ labelSuffixLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_setLabelElements(_ jsObject: Int32, _ labelPrefixBytes: Int32, _ labelPrefixLength: Int32, _ labelSuffixBytes: Int32, _ labelSuffixLength: Int32) -> Void { - return _extern_setLabelElements_extern(jsObject, labelPrefixBytes, labelPrefixLength, labelSuffixBytes, labelSuffixLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_getLabel") -fileprivate func _extern_getLabel_extern(_ jsObject: Int32) -> Int32 -#else -fileprivate func _extern_getLabel_extern(_ jsObject: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_getLabel(_ jsObject: Int32) -> Int32 { - return _extern_getLabel_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_isEven") -fileprivate func _extern_isEven_extern(_ jsObject: Int32) -> Int32 -#else -fileprivate func _extern_isEven_extern(_ jsObject: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_isEven(_ jsObject: Int32) -> Int32 { - return _extern_isEven_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_processGreeter") -fileprivate func _extern_processGreeter_extern(_ jsObject: Int32, _ greeter: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _extern_processGreeter_extern(_ jsObject: Int32, _ greeter: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_processGreeter(_ jsObject: Int32, _ greeter: UnsafeMutableRawPointer) -> Int32 { - return _extern_processGreeter_extern(jsObject, greeter) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_createGreeter") -fileprivate func _extern_createGreeter_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer -#else -fileprivate func _extern_createGreeter_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_createGreeter(_ jsObject: Int32) -> UnsafeMutableRawPointer { - return _extern_createGreeter_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_processOptionalGreeter") -fileprivate func _extern_processOptionalGreeter_extern(_ jsObject: Int32, _ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _extern_processOptionalGreeter_extern(_ jsObject: Int32, _ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_processOptionalGreeter(_ jsObject: Int32, _ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> Int32 { - return _extern_processOptionalGreeter_extern(jsObject, greeterIsSome, greeterPointer) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_createOptionalGreeter") -fileprivate func _extern_createOptionalGreeter_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer -#else -fileprivate func _extern_createOptionalGreeter_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_createOptionalGreeter(_ jsObject: Int32) -> UnsafeMutableRawPointer { - return _extern_createOptionalGreeter_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_handleAPIResult") -fileprivate func _extern_handleAPIResult_extern(_ jsObject: Int32, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void -#else -fileprivate func _extern_handleAPIResult_extern(_ jsObject: Int32, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_handleAPIResult(_ jsObject: Int32, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void { - return _extern_handleAPIResult_extern(jsObject, resultIsSome, resultCaseId) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_getAPIResult") -fileprivate func _extern_getAPIResult_extern(_ jsObject: Int32) -> Int32 -#else -fileprivate func _extern_getAPIResult_extern(_ jsObject: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_getAPIResult(_ jsObject: Int32) -> Int32 { - return _extern_getAPIResult_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_count_get") -fileprivate func bjs_DataProcessor_count_get_extern(_ jsObject: Int32) -> Int32 -#else -fileprivate func bjs_DataProcessor_count_get_extern(_ jsObject: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_count_get(_ jsObject: Int32) -> Int32 { - return bjs_DataProcessor_count_get_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_count_set") -fileprivate func bjs_DataProcessor_count_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void -#else -fileprivate func bjs_DataProcessor_count_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_count_set(_ jsObject: Int32, _ newValue: Int32) -> Void { - return bjs_DataProcessor_count_set_extern(jsObject, newValue) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_name_get") -fileprivate func bjs_DataProcessor_name_get_extern(_ jsObject: Int32) -> Int32 -#else -fileprivate func bjs_DataProcessor_name_get_extern(_ jsObject: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_name_get(_ jsObject: Int32) -> Int32 { - return bjs_DataProcessor_name_get_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalTag_get") -fileprivate func bjs_DataProcessor_optionalTag_get_extern(_ jsObject: Int32) -> Void -#else -fileprivate func bjs_DataProcessor_optionalTag_get_extern(_ jsObject: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_optionalTag_get(_ jsObject: Int32) -> Void { - return bjs_DataProcessor_optionalTag_get_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalTag_set") -fileprivate func bjs_DataProcessor_optionalTag_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void -#else -fileprivate func bjs_DataProcessor_optionalTag_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_optionalTag_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { - return bjs_DataProcessor_optionalTag_set_extern(jsObject, newValueIsSome, newValueBytes, newValueLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalCount_get") -fileprivate func bjs_DataProcessor_optionalCount_get_extern(_ jsObject: Int32) -> Void -#else -fileprivate func bjs_DataProcessor_optionalCount_get_extern(_ jsObject: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_optionalCount_get(_ jsObject: Int32) -> Void { - return bjs_DataProcessor_optionalCount_get_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalCount_set") -fileprivate func bjs_DataProcessor_optionalCount_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void -#else -fileprivate func bjs_DataProcessor_optionalCount_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_optionalCount_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { - return bjs_DataProcessor_optionalCount_set_extern(jsObject, newValueIsSome, newValueValue) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_direction_get") -fileprivate func bjs_DataProcessor_direction_get_extern(_ jsObject: Int32) -> Int32 -#else -fileprivate func bjs_DataProcessor_direction_get_extern(_ jsObject: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_direction_get(_ jsObject: Int32) -> Int32 { - return bjs_DataProcessor_direction_get_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_direction_set") -fileprivate func bjs_DataProcessor_direction_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void -#else -fileprivate func bjs_DataProcessor_direction_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_direction_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { - return bjs_DataProcessor_direction_set_extern(jsObject, newValueIsSome, newValueValue) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalTheme_get") -fileprivate func bjs_DataProcessor_optionalTheme_get_extern(_ jsObject: Int32) -> Void -#else -fileprivate func bjs_DataProcessor_optionalTheme_get_extern(_ jsObject: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_optionalTheme_get(_ jsObject: Int32) -> Void { - return bjs_DataProcessor_optionalTheme_get_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalTheme_set") -fileprivate func bjs_DataProcessor_optionalTheme_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void -#else -fileprivate func bjs_DataProcessor_optionalTheme_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_optionalTheme_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { - return bjs_DataProcessor_optionalTheme_set_extern(jsObject, newValueIsSome, newValueBytes, newValueLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_httpStatus_get") -fileprivate func bjs_DataProcessor_httpStatus_get_extern(_ jsObject: Int32) -> Void -#else -fileprivate func bjs_DataProcessor_httpStatus_get_extern(_ jsObject: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_httpStatus_get(_ jsObject: Int32) -> Void { - return bjs_DataProcessor_httpStatus_get_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_httpStatus_set") -fileprivate func bjs_DataProcessor_httpStatus_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void -#else -fileprivate func bjs_DataProcessor_httpStatus_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_httpStatus_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { - return bjs_DataProcessor_httpStatus_set_extern(jsObject, newValueIsSome, newValueValue) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_apiResult_get") -fileprivate func bjs_DataProcessor_apiResult_get_extern(_ jsObject: Int32) -> Int32 -#else -fileprivate func bjs_DataProcessor_apiResult_get_extern(_ jsObject: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_apiResult_get(_ jsObject: Int32) -> Int32 { - return bjs_DataProcessor_apiResult_get_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_apiResult_set") -fileprivate func bjs_DataProcessor_apiResult_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueCaseId: Int32) -> Void -#else -fileprivate func bjs_DataProcessor_apiResult_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueCaseId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_apiResult_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueCaseId: Int32) -> Void { - return bjs_DataProcessor_apiResult_set_extern(jsObject, newValueIsSome, newValueCaseId) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_helper_get") -fileprivate func bjs_DataProcessor_helper_get_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer -#else -fileprivate func bjs_DataProcessor_helper_get_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_helper_get(_ jsObject: Int32) -> UnsafeMutableRawPointer { - return bjs_DataProcessor_helper_get_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_helper_set") -fileprivate func bjs_DataProcessor_helper_set_extern(_ jsObject: Int32, _ newValue: UnsafeMutableRawPointer) -> Void -#else -fileprivate func bjs_DataProcessor_helper_set_extern(_ jsObject: Int32, _ newValue: UnsafeMutableRawPointer) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_helper_set(_ jsObject: Int32, _ newValue: UnsafeMutableRawPointer) -> Void { - return bjs_DataProcessor_helper_set_extern(jsObject, newValue) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalHelper_get") -fileprivate func bjs_DataProcessor_optionalHelper_get_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer -#else -fileprivate func bjs_DataProcessor_optionalHelper_get_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_optionalHelper_get(_ jsObject: Int32) -> UnsafeMutableRawPointer { - return bjs_DataProcessor_optionalHelper_get_extern(jsObject) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalHelper_set") -fileprivate func bjs_DataProcessor_optionalHelper_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValuePointer: UnsafeMutableRawPointer) -> Void -#else -fileprivate func bjs_DataProcessor_optionalHelper_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValuePointer: UnsafeMutableRawPointer) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DataProcessor_optionalHelper_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValuePointer: UnsafeMutableRawPointer) -> Void { - return bjs_DataProcessor_optionalHelper_set_extern(jsObject, newValueIsSome, newValuePointer) -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripIntArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripIntArray") -public func _bjs_ArraySupportExports_static_roundTripIntArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripIntArray(_: [Int].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripStringArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripStringArray") -public func _bjs_ArraySupportExports_static_roundTripStringArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripStringArray(_: [String].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripDoubleArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripDoubleArray") -public func _bjs_ArraySupportExports_static_roundTripDoubleArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripDoubleArray(_: [Double].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripBoolArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripBoolArray") -public func _bjs_ArraySupportExports_static_roundTripBoolArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripBoolArray(_: [Bool].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripUnsafeRawPointerArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripUnsafeRawPointerArray") -public func _bjs_ArraySupportExports_static_roundTripUnsafeRawPointerArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripUnsafeRawPointerArray(_: [UnsafeRawPointer].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripUnsafeMutableRawPointerArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripUnsafeMutableRawPointerArray") -public func _bjs_ArraySupportExports_static_roundTripUnsafeMutableRawPointerArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripUnsafeMutableRawPointerArray(_: [UnsafeMutableRawPointer].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOpaquePointerArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOpaquePointerArray") -public func _bjs_ArraySupportExports_static_roundTripOpaquePointerArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOpaquePointerArray(_: [OpaquePointer].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripUnsafePointerArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripUnsafePointerArray") -public func _bjs_ArraySupportExports_static_roundTripUnsafePointerArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripUnsafePointerArray(_: [UnsafePointer].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripUnsafeMutablePointerArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripUnsafeMutablePointerArray") -public func _bjs_ArraySupportExports_static_roundTripUnsafeMutablePointerArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripUnsafeMutablePointerArray(_: [UnsafeMutablePointer].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripJSValueArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripJSValueArray") -public func _bjs_ArraySupportExports_static_roundTripJSValueArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripJSValueArray(_: [JSValue].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripJSObjectArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripJSObjectArray") -public func _bjs_ArraySupportExports_static_roundTripJSObjectArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripJSObjectArray(_: [JSObject].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripCaseEnumArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripCaseEnumArray") -public func _bjs_ArraySupportExports_static_roundTripCaseEnumArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripCaseEnumArray(_: [Direction].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripStringRawValueEnumArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripStringRawValueEnumArray") -public func _bjs_ArraySupportExports_static_roundTripStringRawValueEnumArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripStringRawValueEnumArray(_: [Theme].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripIntRawValueEnumArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripIntRawValueEnumArray") -public func _bjs_ArraySupportExports_static_roundTripIntRawValueEnumArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripIntRawValueEnumArray(_: [HttpStatus].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripInt64RawValueEnumArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripInt64RawValueEnumArray") -public func _bjs_ArraySupportExports_static_roundTripInt64RawValueEnumArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripInt64RawValueEnumArray(_: [FileSize].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripUInt64RawValueEnumArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripUInt64RawValueEnumArray") -public func _bjs_ArraySupportExports_static_roundTripUInt64RawValueEnumArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripUInt64RawValueEnumArray(_: [SessionId].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripStructArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripStructArray") -public func _bjs_ArraySupportExports_static_roundTripStructArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripStructArray(_: [DataPoint].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripSwiftClassArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripSwiftClassArray") -public func _bjs_ArraySupportExports_static_roundTripSwiftClassArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripSwiftClassArray(_: [Greeter].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNamespacedSwiftClassArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripNamespacedSwiftClassArray") -public func _bjs_ArraySupportExports_static_roundTripNamespacedSwiftClassArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripNamespacedSwiftClassArray(_: [Utils.Converter].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripProtocolArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripProtocolArray") -public func _bjs_ArraySupportExports_static_roundTripProtocolArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripProtocolArray(_: [AnyArrayElementProtocol].bridgeJSStackPop()) - for __bjs_elem_ret in ret { - _swift_js_push_i32((__bjs_elem_ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) - } - _swift_js_push_i32(Int32(ret.count)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripJSClassArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripJSClassArray") -public func _bjs_ArraySupportExports_static_roundTripJSClassArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripJSClassArray(_: [ArrayElementObject].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalIntArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalIntArray") -public func _bjs_ArraySupportExports_static_roundTripOptionalIntArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOptionalIntArray(_: [Optional].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalStringArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalStringArray") -public func _bjs_ArraySupportExports_static_roundTripOptionalStringArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOptionalStringArray(_: [Optional].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalJSObjectArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalJSObjectArray") -public func _bjs_ArraySupportExports_static_roundTripOptionalJSObjectArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOptionalJSObjectArray(_: [Optional].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalCaseEnumArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalCaseEnumArray") -public func _bjs_ArraySupportExports_static_roundTripOptionalCaseEnumArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOptionalCaseEnumArray(_: [Optional].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalStringRawValueEnumArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalStringRawValueEnumArray") -public func _bjs_ArraySupportExports_static_roundTripOptionalStringRawValueEnumArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOptionalStringRawValueEnumArray(_: [Optional].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalIntRawValueEnumArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalIntRawValueEnumArray") -public func _bjs_ArraySupportExports_static_roundTripOptionalIntRawValueEnumArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOptionalIntRawValueEnumArray(_: [Optional].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalInt64RawValueEnumArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalInt64RawValueEnumArray") -public func _bjs_ArraySupportExports_static_roundTripOptionalInt64RawValueEnumArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOptionalInt64RawValueEnumArray(_: [Optional].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalUInt64RawValueEnumArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalUInt64RawValueEnumArray") -public func _bjs_ArraySupportExports_static_roundTripOptionalUInt64RawValueEnumArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOptionalUInt64RawValueEnumArray(_: [Optional].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalStructArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalStructArray") -public func _bjs_ArraySupportExports_static_roundTripOptionalStructArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOptionalStructArray(_: [Optional].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalSwiftClassArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalSwiftClassArray") -public func _bjs_ArraySupportExports_static_roundTripOptionalSwiftClassArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOptionalSwiftClassArray(_: [Optional].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripOptionalJSClassArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripOptionalJSClassArray") -public func _bjs_ArraySupportExports_static_roundTripOptionalJSClassArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripOptionalJSClassArray(_: [Optional].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedIntArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripNestedIntArray") -public func _bjs_ArraySupportExports_static_roundTripNestedIntArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripNestedIntArray(_: [[Int]].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedStringArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripNestedStringArray") -public func _bjs_ArraySupportExports_static_roundTripNestedStringArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripNestedStringArray(_: [[String]].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedDoubleArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripNestedDoubleArray") -public func _bjs_ArraySupportExports_static_roundTripNestedDoubleArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripNestedDoubleArray(_: [[Double]].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedBoolArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripNestedBoolArray") -public func _bjs_ArraySupportExports_static_roundTripNestedBoolArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripNestedBoolArray(_: [[Bool]].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedStructArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripNestedStructArray") -public func _bjs_ArraySupportExports_static_roundTripNestedStructArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripNestedStructArray(_: [[DataPoint]].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedCaseEnumArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripNestedCaseEnumArray") -public func _bjs_ArraySupportExports_static_roundTripNestedCaseEnumArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripNestedCaseEnumArray(_: [[Direction]].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_roundTripNestedSwiftClassArray") -@_cdecl("bjs_ArraySupportExports_static_roundTripNestedSwiftClassArray") -public func _bjs_ArraySupportExports_static_roundTripNestedSwiftClassArray() -> Void { - #if arch(wasm32) - let ret = ArraySupportExports.roundTripNestedSwiftClassArray(_: [[Greeter]].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_multiArrayFirst") -@_cdecl("bjs_ArraySupportExports_static_multiArrayFirst") -public func _bjs_ArraySupportExports_static_multiArrayFirst() -> Void { - #if arch(wasm32) - let _tmp_b = [String].bridgeJSStackPop() - let _tmp_a = [Int].bridgeJSStackPop() - let ret = ArraySupportExports.multiArrayFirst(_: _tmp_a, _: _tmp_b) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_multiArraySecond") -@_cdecl("bjs_ArraySupportExports_static_multiArraySecond") -public func _bjs_ArraySupportExports_static_multiArraySecond() -> Void { - #if arch(wasm32) - let _tmp_b = [String].bridgeJSStackPop() - let _tmp_a = [Int].bridgeJSStackPop() - let ret = ArraySupportExports.multiArraySecond(_: _tmp_a, _: _tmp_b) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_multiOptionalArrayFirst") -@_cdecl("bjs_ArraySupportExports_static_multiOptionalArrayFirst") -public func _bjs_ArraySupportExports_static_multiOptionalArrayFirst() -> Void { - #if arch(wasm32) - let _tmp_b = Optional<[String]>.bridgeJSLiftParameter() - let _tmp_a = Optional<[Int]>.bridgeJSLiftParameter() - let ret = ArraySupportExports.multiOptionalArrayFirst(_: _tmp_a, _: _tmp_b) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArraySupportExports_static_multiOptionalArraySecond") -@_cdecl("bjs_ArraySupportExports_static_multiOptionalArraySecond") -public func _bjs_ArraySupportExports_static_multiOptionalArraySecond() -> Void { - #if arch(wasm32) - let _tmp_b = Optional<[String]>.bridgeJSLiftParameter() - let _tmp_a = Optional<[Int]>.bridgeJSLiftParameter() - let ret = ArraySupportExports.multiOptionalArraySecond(_: _tmp_a, _: _tmp_b) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_testStringDefault") -@_cdecl("bjs_DefaultArgumentExports_static_testStringDefault") -public func _bjs_DefaultArgumentExports_static_testStringDefault(_ messageBytes: Int32, _ messageLength: Int32) -> Void { - #if arch(wasm32) - let ret = DefaultArgumentExports.testStringDefault(message: String.bridgeJSLiftParameter(messageBytes, messageLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_testIntDefault") -@_cdecl("bjs_DefaultArgumentExports_static_testIntDefault") -public func _bjs_DefaultArgumentExports_static_testIntDefault(_ count: Int32) -> Int32 { - #if arch(wasm32) - let ret = DefaultArgumentExports.testIntDefault(count: Int.bridgeJSLiftParameter(count)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_testBoolDefault") -@_cdecl("bjs_DefaultArgumentExports_static_testBoolDefault") -public func _bjs_DefaultArgumentExports_static_testBoolDefault(_ flag: Int32) -> Int32 { - #if arch(wasm32) - let ret = DefaultArgumentExports.testBoolDefault(flag: Bool.bridgeJSLiftParameter(flag)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_testOptionalDefault") -@_cdecl("bjs_DefaultArgumentExports_static_testOptionalDefault") -public func _bjs_DefaultArgumentExports_static_testOptionalDefault(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { - #if arch(wasm32) - let ret = DefaultArgumentExports.testOptionalDefault(name: Optional.bridgeJSLiftParameter(nameIsSome, nameBytes, nameLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_testMultipleDefaults") -@_cdecl("bjs_DefaultArgumentExports_static_testMultipleDefaults") -public func _bjs_DefaultArgumentExports_static_testMultipleDefaults(_ titleBytes: Int32, _ titleLength: Int32, _ count: Int32, _ enabled: Int32) -> Void { - #if arch(wasm32) - let ret = DefaultArgumentExports.testMultipleDefaults(title: String.bridgeJSLiftParameter(titleBytes, titleLength), count: Int.bridgeJSLiftParameter(count), enabled: Bool.bridgeJSLiftParameter(enabled)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_testSimpleEnumDefault") -@_cdecl("bjs_DefaultArgumentExports_static_testSimpleEnumDefault") -public func _bjs_DefaultArgumentExports_static_testSimpleEnumDefault(_ status: Int32) -> Int32 { - #if arch(wasm32) - let ret = DefaultArgumentExports.testSimpleEnumDefault(status: Status.bridgeJSLiftParameter(status)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_testDirectionDefault") -@_cdecl("bjs_DefaultArgumentExports_static_testDirectionDefault") -public func _bjs_DefaultArgumentExports_static_testDirectionDefault(_ direction: Int32) -> Int32 { - #if arch(wasm32) - let ret = DefaultArgumentExports.testDirectionDefault(direction: Direction.bridgeJSLiftParameter(direction)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_testRawStringEnumDefault") -@_cdecl("bjs_DefaultArgumentExports_static_testRawStringEnumDefault") -public func _bjs_DefaultArgumentExports_static_testRawStringEnumDefault(_ themeBytes: Int32, _ themeLength: Int32) -> Void { - #if arch(wasm32) - let ret = DefaultArgumentExports.testRawStringEnumDefault(theme: Theme.bridgeJSLiftParameter(themeBytes, themeLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_testComplexInit") -@_cdecl("bjs_DefaultArgumentExports_static_testComplexInit") -public func _bjs_DefaultArgumentExports_static_testComplexInit(_ greeter: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DefaultArgumentExports.testComplexInit(greeter: Greeter.bridgeJSLiftParameter(greeter)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_testEmptyInit") -@_cdecl("bjs_DefaultArgumentExports_static_testEmptyInit") -public func _bjs_DefaultArgumentExports_static_testEmptyInit(_ object: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = DefaultArgumentExports.testEmptyInit(_: StaticPropertyHolder.bridgeJSLiftParameter(object)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_createConstructorDefaults") -@_cdecl("bjs_DefaultArgumentExports_static_createConstructorDefaults") -public func _bjs_DefaultArgumentExports_static_createConstructorDefaults(_ nameBytes: Int32, _ nameLength: Int32, _ count: Int32, _ enabled: Int32, _ status: Int32, _ tagIsSome: Int32, _ tagBytes: Int32, _ tagLength: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = DefaultArgumentExports.createConstructorDefaults(name: String.bridgeJSLiftParameter(nameBytes, nameLength), count: Int.bridgeJSLiftParameter(count), enabled: Bool.bridgeJSLiftParameter(enabled), status: Status.bridgeJSLiftParameter(status), tag: Optional.bridgeJSLiftParameter(tagIsSome, tagBytes, tagLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_describeConstructorDefaults") -@_cdecl("bjs_DefaultArgumentExports_static_describeConstructorDefaults") -public func _bjs_DefaultArgumentExports_static_describeConstructorDefaults(_ value: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DefaultArgumentExports.describeConstructorDefaults(_: DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_arrayWithDefault") -@_cdecl("bjs_DefaultArgumentExports_static_arrayWithDefault") -public func _bjs_DefaultArgumentExports_static_arrayWithDefault() -> Int32 { - #if arch(wasm32) - let ret = DefaultArgumentExports.arrayWithDefault(_: [Int].bridgeJSStackPop()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_arrayWithOptionalDefault") -@_cdecl("bjs_DefaultArgumentExports_static_arrayWithOptionalDefault") -public func _bjs_DefaultArgumentExports_static_arrayWithOptionalDefault() -> Int32 { - #if arch(wasm32) - let ret = DefaultArgumentExports.arrayWithOptionalDefault(_: Optional<[Int]>.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentExports_static_arrayMixedDefaults") -@_cdecl("bjs_DefaultArgumentExports_static_arrayMixedDefaults") -public func _bjs_DefaultArgumentExports_static_arrayMixedDefaults(_ prefixBytes: Int32, _ prefixLength: Int32, _ suffixBytes: Int32, _ suffixLength: Int32) -> Void { - #if arch(wasm32) - let ret = DefaultArgumentExports.arrayMixedDefaults(prefix: String.bridgeJSLiftParameter(prefixBytes, prefixLength), values: [Int].bridgeJSStackPop(), suffix: String.bridgeJSLiftParameter(suffixBytes, suffixLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension Direction: _BridgedSwiftCaseEnum { - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { - return bridgeJSRawValue - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Direction { - return bridgeJSLiftParameter(value) - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Direction { - return Direction(bridgeJSRawValue: value)! - } - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { - return bridgeJSLowerParameter() - } - - private init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .north - case 1: - self = .south - case 2: - self = .east - case 3: - self = .west - default: - return nil - } - } - - private var bridgeJSRawValue: Int32 { - switch self { - case .north: - return 0 - case .south: - return 1 - case .east: - return 2 - case .west: - return 3 - } - } -} - -extension Status: _BridgedSwiftCaseEnum { - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { - return bridgeJSRawValue - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Status { - return bridgeJSLiftParameter(value) - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Status { - return Status(bridgeJSRawValue: value)! - } - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { - return bridgeJSLowerParameter() - } - - private init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .loading - case 1: - self = .success - case 2: - self = .error - default: - return nil - } - } - - private var bridgeJSRawValue: Int32 { - switch self { - case .loading: - return 0 - case .success: - return 1 - case .error: - return 2 - } - } -} - -extension Theme: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension HttpStatus: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension FileSize: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension SessionId: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension Precision: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension Ratio: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension TSDirection: _BridgedSwiftCaseEnum { - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { - return bridgeJSRawValue - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> TSDirection { - return bridgeJSLiftParameter(value) - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> TSDirection { - return TSDirection(bridgeJSRawValue: value)! - } - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { - return bridgeJSLowerParameter() - } - - private init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .north - case 1: - self = .south - case 2: - self = .east - case 3: - self = .west - default: - return nil - } - } - - private var bridgeJSRawValue: Int32 { - switch self { - case .north: - return 0 - case .south: - return 1 - case .east: - return 2 - case .west: - return 3 - } - } -} - -extension TSTheme: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -@_expose(wasm, "bjs_Utils_StringUtils_static_uppercase") -@_cdecl("bjs_Utils_StringUtils_static_uppercase") -public func _bjs_Utils_StringUtils_static_uppercase(_ textBytes: Int32, _ textLength: Int32) -> Void { - #if arch(wasm32) - let ret = Utils.StringUtils.uppercase(_: String.bridgeJSLiftParameter(textBytes, textLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Utils_StringUtils_static_lowercase") -@_cdecl("bjs_Utils_StringUtils_static_lowercase") -public func _bjs_Utils_StringUtils_static_lowercase(_ textBytes: Int32, _ textLength: Int32) -> Void { - #if arch(wasm32) - let ret = Utils.StringUtils.lowercase(_: String.bridgeJSLiftParameter(textBytes, textLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension Networking.API.Method: _BridgedSwiftCaseEnum { - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { - return bridgeJSRawValue - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Networking.API.Method { - return bridgeJSLiftParameter(value) - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Networking.API.Method { - return Networking.API.Method(bridgeJSRawValue: value)! - } - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { - return bridgeJSLowerParameter() - } - - private init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .get - case 1: - self = .post - case 2: - self = .put - case 3: - self = .delete - default: - return nil - } - } - - private var bridgeJSRawValue: Int32 { - switch self { - case .get: - return 0 - case .post: - return 1 - case .put: - return 2 - case .delete: - return 3 - } - } -} - -extension Configuration.LogLevel: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension Configuration.Port: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension Internal.SupportedMethod: _BridgedSwiftCaseEnum { - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { - return bridgeJSRawValue - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Internal.SupportedMethod { - return bridgeJSLiftParameter(value) - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Internal.SupportedMethod { - return Internal.SupportedMethod(bridgeJSRawValue: value)! - } - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { - return bridgeJSLowerParameter() - } - - private init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .get - case 1: - self = .post - default: - return nil - } - } - - private var bridgeJSRawValue: Int32 { - switch self { - case .get: - return 0 - case .post: - return 1 - } - } -} - -extension APIResult: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> APIResult { - switch caseId { - case 0: - return .success(String.bridgeJSStackPop()) - case 1: - return .failure(Int.bridgeJSStackPop()) - case 2: - return .flag(Bool.bridgeJSStackPop()) - case 3: - return .rate(Float.bridgeJSStackPop()) - case 4: - return .precise(Double.bridgeJSStackPop()) - case 5: - return .info - default: - fatalError("Unknown APIResult case ID: \(caseId)") - } - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { - switch self { - case .success(let param0): - param0.bridgeJSStackPush() - return Int32(0) - case .failure(let param0): - param0.bridgeJSStackPush() - return Int32(1) - case .flag(let param0): - param0.bridgeJSStackPush() - return Int32(2) - case .rate(let param0): - param0.bridgeJSStackPush() - return Int32(3) - case .precise(let param0): - param0.bridgeJSStackPush() - return Int32(4) - case .info: - return Int32(5) - } - } -} - -extension ComplexResult: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> ComplexResult { - switch caseId { - case 0: - return .success(String.bridgeJSStackPop()) - case 1: - return .error(String.bridgeJSStackPop(), Int.bridgeJSStackPop()) - case 2: - return .location(Double.bridgeJSStackPop(), Double.bridgeJSStackPop(), String.bridgeJSStackPop()) - case 3: - return .status(Bool.bridgeJSStackPop(), Int.bridgeJSStackPop(), String.bridgeJSStackPop()) - case 4: - return .coordinates(Double.bridgeJSStackPop(), Double.bridgeJSStackPop(), Double.bridgeJSStackPop()) - case 5: - return .comprehensive(Bool.bridgeJSStackPop(), Bool.bridgeJSStackPop(), Int.bridgeJSStackPop(), Int.bridgeJSStackPop(), Double.bridgeJSStackPop(), Double.bridgeJSStackPop(), String.bridgeJSStackPop(), String.bridgeJSStackPop(), String.bridgeJSStackPop()) - case 6: - return .info - default: - fatalError("Unknown ComplexResult case ID: \(caseId)") - } - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { - switch self { - case .success(let param0): - param0.bridgeJSStackPush() - return Int32(0) - case .error(let param0, let param1): - param0.bridgeJSStackPush() - param1.bridgeJSStackPush() - return Int32(1) - case .location(let param0, let param1, let param2): - param0.bridgeJSStackPush() - param1.bridgeJSStackPush() - param2.bridgeJSStackPush() - return Int32(2) - case .status(let param0, let param1, let param2): - param0.bridgeJSStackPush() - param1.bridgeJSStackPush() - param2.bridgeJSStackPush() - return Int32(3) - case .coordinates(let param0, let param1, let param2): - param0.bridgeJSStackPush() - param1.bridgeJSStackPush() - param2.bridgeJSStackPush() - return Int32(4) - case .comprehensive(let param0, let param1, let param2, let param3, let param4, let param5, let param6, let param7, let param8): - param0.bridgeJSStackPush() - param1.bridgeJSStackPush() - param2.bridgeJSStackPush() - param3.bridgeJSStackPush() - param4.bridgeJSStackPush() - param5.bridgeJSStackPush() - param6.bridgeJSStackPush() - param7.bridgeJSStackPush() - param8.bridgeJSStackPush() - return Int32(5) - case .info: - return Int32(6) - } - } -} - -extension Utilities.Result: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> Utilities.Result { - switch caseId { - case 0: - return .success(String.bridgeJSStackPop()) - case 1: - return .failure(String.bridgeJSStackPop(), Int.bridgeJSStackPop()) - case 2: - return .status(Bool.bridgeJSStackPop(), Int.bridgeJSStackPop(), String.bridgeJSStackPop()) - default: - fatalError("Unknown Utilities.Result case ID: \(caseId)") - } - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { - switch self { - case .success(let param0): - param0.bridgeJSStackPush() - return Int32(0) - case .failure(let param0, let param1): - param0.bridgeJSStackPush() - param1.bridgeJSStackPush() - return Int32(1) - case .status(let param0, let param1, let param2): - param0.bridgeJSStackPush() - param1.bridgeJSStackPush() - param2.bridgeJSStackPush() - return Int32(2) - } - } -} - -extension API.NetworkingResult: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> API.NetworkingResult { - switch caseId { - case 0: - return .success(String.bridgeJSStackPop()) - case 1: - return .failure(String.bridgeJSStackPop(), Int.bridgeJSStackPop()) - default: - fatalError("Unknown API.NetworkingResult case ID: \(caseId)") - } - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { - switch self { - case .success(let param0): - param0.bridgeJSStackPush() - return Int32(0) - case .failure(let param0, let param1): - param0.bridgeJSStackPush() - param1.bridgeJSStackPush() - return Int32(1) - } - } -} - -extension AllTypesResult: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> AllTypesResult { - switch caseId { - case 0: - return .structPayload(Address.bridgeJSStackPop()) - case 1: - return .classPayload(Greeter.bridgeJSStackPop()) - case 2: - return .jsObjectPayload(JSObject.bridgeJSStackPop()) - case 3: - return .nestedEnum(APIResult.bridgeJSStackPop()) - case 4: - return .arrayPayload([Int].bridgeJSStackPop()) - case 5: - return .jsClassPayload(Foo(unsafelyWrapping: JSObject.bridgeJSStackPop())) - case 6: - return .empty - default: - fatalError("Unknown AllTypesResult case ID: \(caseId)") - } - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { - switch self { - case .structPayload(let param0): - param0.bridgeJSStackPush() - return Int32(0) - case .classPayload(let param0): - param0.bridgeJSStackPush() - return Int32(1) - case .jsObjectPayload(let param0): - param0.bridgeJSStackPush() - return Int32(2) - case .nestedEnum(let param0): - param0.bridgeJSStackPush() - return Int32(3) - case .arrayPayload(let param0): - param0.bridgeJSStackPush() - return Int32(4) - case .jsClassPayload(let param0): - param0.jsObject.bridgeJSStackPush() - return Int32(5) - case .empty: - return Int32(6) - } - } -} - -extension TypedPayloadResult: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> TypedPayloadResult { - switch caseId { - case 0: - return .precision(Precision.bridgeJSStackPop()) - case 1: - return .direction(Direction.bridgeJSStackPop()) - case 2: - return .optPrecision(Optional.bridgeJSStackPop()) - case 3: - return .optDirection(Optional.bridgeJSStackPop()) - case 4: - return .empty - default: - fatalError("Unknown TypedPayloadResult case ID: \(caseId)") - } - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { - switch self { - case .precision(let param0): - param0.bridgeJSStackPush() - return Int32(0) - case .direction(let param0): - param0.bridgeJSStackPush() - return Int32(1) - case .optPrecision(let param0): - param0.bridgeJSStackPush() - return Int32(2) - case .optDirection(let param0): - param0.bridgeJSStackPush() - return Int32(3) - case .empty: - return Int32(4) - } - } -} - -extension StaticCalculator: _BridgedSwiftCaseEnum { - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { - return bridgeJSRawValue - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> StaticCalculator { - return bridgeJSLiftParameter(value) - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> StaticCalculator { - return StaticCalculator(bridgeJSRawValue: value)! - } - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { - return bridgeJSLowerParameter() - } - - private init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .scientific - case 1: - self = .basic - default: - return nil - } - } - - private var bridgeJSRawValue: Int32 { - switch self { - case .scientific: - return 0 - case .basic: - return 1 - } - } -} - -@_expose(wasm, "bjs_StaticCalculator_static_roundtrip") -@_cdecl("bjs_StaticCalculator_static_roundtrip") -public func _bjs_StaticCalculator_static_roundtrip(_ value: Int32) -> Int32 { - #if arch(wasm32) - let ret = StaticCalculator.roundtrip(_: Int.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticCalculator_static_doubleValue") -@_cdecl("bjs_StaticCalculator_static_doubleValue") -public func _bjs_StaticCalculator_static_doubleValue(_ value: Int32) -> Int32 { - #if arch(wasm32) - let ret = StaticCalculator.doubleValue(_: Int.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticCalculator_static_version_get") -@_cdecl("bjs_StaticCalculator_static_version_get") -public func _bjs_StaticCalculator_static_version_get() -> Void { - #if arch(wasm32) - let ret = StaticCalculator.version - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticUtils_Nested_static_roundtrip") -@_cdecl("bjs_StaticUtils_Nested_static_roundtrip") -public func _bjs_StaticUtils_Nested_static_roundtrip(_ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - let ret = StaticUtils.Nested.roundtrip(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Services_Graph_GraphOperations_static_createGraph") -@_cdecl("bjs_Services_Graph_GraphOperations_static_createGraph") -public func _bjs_Services_Graph_GraphOperations_static_createGraph(_ rootId: Int32) -> Int32 { - #if arch(wasm32) - let ret = GraphOperations.createGraph(rootId: Int.bridgeJSLiftParameter(rootId)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Services_Graph_GraphOperations_static_nodeCount") -@_cdecl("bjs_Services_Graph_GraphOperations_static_nodeCount") -public func _bjs_Services_Graph_GraphOperations_static_nodeCount(_ graphId: Int32) -> Int32 { - #if arch(wasm32) - let ret = GraphOperations.nodeCount(graphId: Int.bridgeJSLiftParameter(graphId)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension StaticPropertyEnum: _BridgedSwiftCaseEnum { - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { - return bridgeJSRawValue - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> StaticPropertyEnum { - return bridgeJSLiftParameter(value) - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> StaticPropertyEnum { - return StaticPropertyEnum(bridgeJSRawValue: value)! - } - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { - return bridgeJSLowerParameter() - } - - private init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .option1 - case 1: - self = .option2 - default: - return nil - } - } - - private var bridgeJSRawValue: Int32 { - switch self { - case .option1: - return 0 - case .option2: - return 1 - } - } -} - -@_expose(wasm, "bjs_StaticPropertyEnum_static_enumProperty_get") -@_cdecl("bjs_StaticPropertyEnum_static_enumProperty_get") -public func _bjs_StaticPropertyEnum_static_enumProperty_get() -> Void { - #if arch(wasm32) - let ret = StaticPropertyEnum.enumProperty - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyEnum_static_enumProperty_set") -@_cdecl("bjs_StaticPropertyEnum_static_enumProperty_set") -public func _bjs_StaticPropertyEnum_static_enumProperty_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - StaticPropertyEnum.enumProperty = String.bridgeJSLiftParameter(valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyEnum_static_enumConstant_get") -@_cdecl("bjs_StaticPropertyEnum_static_enumConstant_get") -public func _bjs_StaticPropertyEnum_static_enumConstant_get() -> Int32 { - #if arch(wasm32) - let ret = StaticPropertyEnum.enumConstant - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyEnum_static_enumBool_get") -@_cdecl("bjs_StaticPropertyEnum_static_enumBool_get") -public func _bjs_StaticPropertyEnum_static_enumBool_get() -> Int32 { - #if arch(wasm32) - let ret = StaticPropertyEnum.enumBool - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyEnum_static_enumBool_set") -@_cdecl("bjs_StaticPropertyEnum_static_enumBool_set") -public func _bjs_StaticPropertyEnum_static_enumBool_set(_ value: Int32) -> Void { - #if arch(wasm32) - StaticPropertyEnum.enumBool = Bool.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyEnum_static_enumVariable_get") -@_cdecl("bjs_StaticPropertyEnum_static_enumVariable_get") -public func _bjs_StaticPropertyEnum_static_enumVariable_get() -> Int32 { - #if arch(wasm32) - let ret = StaticPropertyEnum.enumVariable - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyEnum_static_enumVariable_set") -@_cdecl("bjs_StaticPropertyEnum_static_enumVariable_set") -public func _bjs_StaticPropertyEnum_static_enumVariable_set(_ value: Int32) -> Void { - #if arch(wasm32) - StaticPropertyEnum.enumVariable = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyEnum_static_computedReadonly_get") -@_cdecl("bjs_StaticPropertyEnum_static_computedReadonly_get") -public func _bjs_StaticPropertyEnum_static_computedReadonly_get() -> Int32 { - #if arch(wasm32) - let ret = StaticPropertyEnum.computedReadonly - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyEnum_static_computedReadWrite_get") -@_cdecl("bjs_StaticPropertyEnum_static_computedReadWrite_get") -public func _bjs_StaticPropertyEnum_static_computedReadWrite_get() -> Void { - #if arch(wasm32) - let ret = StaticPropertyEnum.computedReadWrite - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyEnum_static_computedReadWrite_set") -@_cdecl("bjs_StaticPropertyEnum_static_computedReadWrite_set") -public func _bjs_StaticPropertyEnum_static_computedReadWrite_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - StaticPropertyEnum.computedReadWrite = String.bridgeJSLiftParameter(valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyNamespace_static_namespaceProperty_get") -@_cdecl("bjs_StaticPropertyNamespace_static_namespaceProperty_get") -public func _bjs_StaticPropertyNamespace_static_namespaceProperty_get() -> Void { - #if arch(wasm32) - let ret = StaticPropertyNamespace.namespaceProperty - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyNamespace_static_namespaceProperty_set") -@_cdecl("bjs_StaticPropertyNamespace_static_namespaceProperty_set") -public func _bjs_StaticPropertyNamespace_static_namespaceProperty_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - StaticPropertyNamespace.namespaceProperty = String.bridgeJSLiftParameter(valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyNamespace_static_namespaceConstant_get") -@_cdecl("bjs_StaticPropertyNamespace_static_namespaceConstant_get") -public func _bjs_StaticPropertyNamespace_static_namespaceConstant_get() -> Void { - #if arch(wasm32) - let ret = StaticPropertyNamespace.namespaceConstant - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_get") -@_cdecl("bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_get") -public func _bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_get() -> Int32 { - #if arch(wasm32) - let ret = StaticPropertyNamespace.NestedProperties.nestedProperty - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_set") -@_cdecl("bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_set") -public func _bjs_StaticPropertyNamespace_NestedProperties_static_nestedProperty_set(_ value: Int32) -> Void { - #if arch(wasm32) - StaticPropertyNamespace.NestedProperties.nestedProperty = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyNamespace_NestedProperties_static_nestedConstant_get") -@_cdecl("bjs_StaticPropertyNamespace_NestedProperties_static_nestedConstant_get") -public func _bjs_StaticPropertyNamespace_NestedProperties_static_nestedConstant_get() -> Void { - #if arch(wasm32) - let ret = StaticPropertyNamespace.NestedProperties.nestedConstant - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_get") -@_cdecl("bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_get") -public func _bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_get() -> Float64 { - #if arch(wasm32) - let ret = StaticPropertyNamespace.NestedProperties.nestedDouble - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_set") -@_cdecl("bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_set") -public func _bjs_StaticPropertyNamespace_NestedProperties_static_nestedDouble_set(_ value: Float64) -> Void { - #if arch(wasm32) - StaticPropertyNamespace.NestedProperties.nestedDouble = Double.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt") -public func _bjs_IntegerTypesSupportExports_static_roundTripInt(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = IntegerTypesSupportExports.roundTripInt(_: Int.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripUInt") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripUInt") -public func _bjs_IntegerTypesSupportExports_static_roundTripUInt(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = IntegerTypesSupportExports.roundTripUInt(_: UInt.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt8") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt8") -public func _bjs_IntegerTypesSupportExports_static_roundTripInt8(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = IntegerTypesSupportExports.roundTripInt8(_: Int8.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripUInt8") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripUInt8") -public func _bjs_IntegerTypesSupportExports_static_roundTripUInt8(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = IntegerTypesSupportExports.roundTripUInt8(_: UInt8.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt16") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt16") -public func _bjs_IntegerTypesSupportExports_static_roundTripInt16(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = IntegerTypesSupportExports.roundTripInt16(_: Int16.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripUInt16") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripUInt16") -public func _bjs_IntegerTypesSupportExports_static_roundTripUInt16(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = IntegerTypesSupportExports.roundTripUInt16(_: UInt16.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt32") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt32") -public func _bjs_IntegerTypesSupportExports_static_roundTripInt32(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = IntegerTypesSupportExports.roundTripInt32(_: Int32.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripUInt32") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripUInt32") -public func _bjs_IntegerTypesSupportExports_static_roundTripUInt32(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = IntegerTypesSupportExports.roundTripUInt32(_: UInt32.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt64") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt64") -public func _bjs_IntegerTypesSupportExports_static_roundTripInt64(_ v: Int64) -> Int64 { - #if arch(wasm32) - let ret = IntegerTypesSupportExports.roundTripInt64(_: Int64.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripUInt64") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripUInt64") -public func _bjs_IntegerTypesSupportExports_static_roundTripUInt64(_ v: Int64) -> Int64 { - #if arch(wasm32) - let ret = IntegerTypesSupportExports.roundTripUInt64(_: UInt64.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalString") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalString") -public func _bjs_OptionalSupportExports_static_roundTripOptionalString(_ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalString(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalInt") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalInt") -public func _bjs_OptionalSupportExports_static_roundTripOptionalInt(_ vIsSome: Int32, _ vValue: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalInt(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalBool") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalBool") -public func _bjs_OptionalSupportExports_static_roundTripOptionalBool(_ vIsSome: Int32, _ vValue: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalBool(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalFloat") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalFloat") -public func _bjs_OptionalSupportExports_static_roundTripOptionalFloat(_ vIsSome: Int32, _ vValue: Float32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalFloat(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalDouble") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalDouble") -public func _bjs_OptionalSupportExports_static_roundTripOptionalDouble(_ vIsSome: Int32, _ vValue: Float64) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalDouble(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalSyntax") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalSyntax") -public func _bjs_OptionalSupportExports_static_roundTripOptionalSyntax(_ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalSyntax(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalCaseEnum") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalCaseEnum") -public func _bjs_OptionalSupportExports_static_roundTripOptionalCaseEnum(_ vIsSome: Int32, _ vValue: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalCaseEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalStringRawValueEnum") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalStringRawValueEnum") -public func _bjs_OptionalSupportExports_static_roundTripOptionalStringRawValueEnum(_ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalStringRawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalIntRawValueEnum") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalIntRawValueEnum") -public func _bjs_OptionalSupportExports_static_roundTripOptionalIntRawValueEnum(_ vIsSome: Int32, _ vValue: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalIntRawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalInt64RawValueEnum") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalInt64RawValueEnum") -public func _bjs_OptionalSupportExports_static_roundTripOptionalInt64RawValueEnum(_ vIsSome: Int32, _ vValue: Int64) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalInt64RawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalUInt64RawValueEnum") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalUInt64RawValueEnum") -public func _bjs_OptionalSupportExports_static_roundTripOptionalUInt64RawValueEnum(_ vIsSome: Int32, _ vValue: Int64) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalUInt64RawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalTSEnum") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalTSEnum") -public func _bjs_OptionalSupportExports_static_roundTripOptionalTSEnum(_ vIsSome: Int32, _ vValue: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalTSEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalTSStringEnum") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalTSStringEnum") -public func _bjs_OptionalSupportExports_static_roundTripOptionalTSStringEnum(_ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalTSStringEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalNamespacedEnum") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalNamespacedEnum") -public func _bjs_OptionalSupportExports_static_roundTripOptionalNamespacedEnum(_ vIsSome: Int32, _ vValue: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalNamespacedEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalSwiftClass") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalSwiftClass") -public func _bjs_OptionalSupportExports_static_roundTripOptionalSwiftClass(_ vIsSome: Int32, _ vValue: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalSwiftClass(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalIntArray") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalIntArray") -public func _bjs_OptionalSupportExports_static_roundTripOptionalIntArray() -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalIntArray(_: Optional<[Int]>.bridgeJSLiftParameter()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalStringArray") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalStringArray") -public func _bjs_OptionalSupportExports_static_roundTripOptionalStringArray() -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalStringArray(_: Optional<[String]>.bridgeJSLiftParameter()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalSwiftClassArray") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalSwiftClassArray") -public func _bjs_OptionalSupportExports_static_roundTripOptionalSwiftClassArray() -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalSwiftClassArray(_: Optional<[Greeter]>.bridgeJSLiftParameter()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalAPIResult") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalAPIResult") -public func _bjs_OptionalSupportExports_static_roundTripOptionalAPIResult(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalAPIResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalTypedPayloadResult") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalTypedPayloadResult") -public func _bjs_OptionalSupportExports_static_roundTripOptionalTypedPayloadResult(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalTypedPayloadResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalComplexResult") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalComplexResult") -public func _bjs_OptionalSupportExports_static_roundTripOptionalComplexResult(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalComplexResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalAllTypesResult") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalAllTypesResult") -public func _bjs_OptionalSupportExports_static_roundTripOptionalAllTypesResult(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalAllTypesResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalPayloadResult") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalPayloadResult") -public func _bjs_OptionalSupportExports_static_roundTripOptionalPayloadResult(_ v: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalPayloadResult(_: OptionalAllTypesResult.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalPayloadResultOpt") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalPayloadResultOpt") -public func _bjs_OptionalSupportExports_static_roundTripOptionalPayloadResultOpt(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalPayloadResultOpt(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalAPIOptionalResult") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalAPIOptionalResult") -public func _bjs_OptionalSupportExports_static_roundTripOptionalAPIOptionalResult(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalAPIOptionalResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_takeOptionalJSObject") -@_cdecl("bjs_OptionalSupportExports_static_takeOptionalJSObject") -public func _bjs_OptionalSupportExports_static_takeOptionalJSObject(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { - #if arch(wasm32) - OptionalSupportExports.takeOptionalJSObject(_: Optional.bridgeJSLiftParameter(valueIsSome, valueValue)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_applyOptionalGreeter") -@_cdecl("bjs_OptionalSupportExports_static_applyOptionalGreeter") -public func _bjs_OptionalSupportExports_static_applyOptionalGreeter(_ valueIsSome: Int32, _ valueValue: UnsafeMutableRawPointer, _ transform: Int32) -> Void { - #if arch(wasm32) - let ret = OptionalSupportExports.applyOptionalGreeter(_: Optional.bridgeJSLiftParameter(valueIsSome, valueValue), _: _BJS_Closure_20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC.bridgeJSLift(transform)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_makeOptionalHolder") -@_cdecl("bjs_OptionalSupportExports_static_makeOptionalHolder") -public func _bjs_OptionalSupportExports_static_makeOptionalHolder(_ nullableGreeterIsSome: Int32, _ nullableGreeterValue: UnsafeMutableRawPointer, _ undefinedNumberIsSome: Int32, _ undefinedNumberValue: Float64) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = OptionalSupportExports.makeOptionalHolder(nullableGreeter: Optional.bridgeJSLiftParameter(nullableGreeterIsSome, nullableGreeterValue), undefinedNumber: JSUndefinedOr.bridgeJSLiftParameter(undefinedNumberIsSome, undefinedNumberValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalSupportExports_static_compareAPIResults") -@_cdecl("bjs_OptionalSupportExports_static_compareAPIResults") -public func _bjs_OptionalSupportExports_static_compareAPIResults(_ r1IsSome: Int32, _ r1CaseId: Int32, _ r2IsSome: Int32, _ r2CaseId: Int32) -> Void { - #if arch(wasm32) - let _tmp_r2 = Optional.bridgeJSLiftParameter(r2IsSome, r2CaseId) - let _tmp_r1 = Optional.bridgeJSLiftParameter(r1IsSome, r1CaseId) - let ret = OptionalSupportExports.compareAPIResults(_: _tmp_r1, _: _tmp_r2) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension OptionalAllTypesResult: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> OptionalAllTypesResult { - switch caseId { - case 0: - return .optStruct(Optional
.bridgeJSStackPop()) - case 1: - return .optClass(Optional.bridgeJSStackPop()) - case 2: - return .optJSObject(Optional.bridgeJSStackPop()) - case 3: - return .optNestedEnum(Optional.bridgeJSStackPop()) - case 4: - return .optArray(Optional<[Int]>.bridgeJSStackPop()) - case 5: - return .optJsClass(Optional.bridgeJSStackPop().map { Foo(unsafelyWrapping: $0) }) - case 6: - return .empty - default: - fatalError("Unknown OptionalAllTypesResult case ID: \(caseId)") - } - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { - switch self { - case .optStruct(let param0): - param0.bridgeJSStackPush() - return Int32(0) - case .optClass(let param0): - param0.bridgeJSStackPush() - return Int32(1) - case .optJSObject(let param0): - param0.bridgeJSStackPush() - return Int32(2) - case .optNestedEnum(let param0): - param0.bridgeJSStackPush() - return Int32(3) - case .optArray(let param0): - param0.bridgeJSStackPush() - return Int32(4) - case .optJsClass(let param0): - param0.bridgeJSStackPush() - return Int32(5) - case .empty: - return Int32(6) - } - } -} - -extension APIOptionalResult: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> APIOptionalResult { - switch caseId { - case 0: - return .success(Optional.bridgeJSStackPop()) - case 1: - return .failure(Optional.bridgeJSStackPop(), Optional.bridgeJSStackPop()) - case 2: - return .status(Optional.bridgeJSStackPop(), Optional.bridgeJSStackPop(), Optional.bridgeJSStackPop()) - default: - fatalError("Unknown APIOptionalResult case ID: \(caseId)") - } - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { - switch self { - case .success(let param0): - param0.bridgeJSStackPush() - return Int32(0) - case .failure(let param0, let param1): - param0.bridgeJSStackPush() - param1.bridgeJSStackPush() - return Int32(1) - case .status(let param0, let param1, let param2): - param0.bridgeJSStackPush() - param1.bridgeJSStackPush() - param2.bridgeJSStackPush() - return Int32(2) - } - } -} - -extension Point: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Point { - let y = Int.bridgeJSStackPop() - let x = Int.bridgeJSStackPop() - return Point(x: x, y: y) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.x.bridgeJSStackPush() - self.y.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Point())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Point") -fileprivate func _bjs_struct_lower_Point_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_Point_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void { - return _bjs_struct_lower_Point_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Point") -fileprivate func _bjs_struct_lift_Point_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_Point_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_Point() -> Int32 { - return _bjs_struct_lift_Point_extern() -} - -extension PointerFields: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> PointerFields { - let mutPtr = UnsafeMutablePointer.bridgeJSStackPop() - let ptr = UnsafePointer.bridgeJSStackPop() - let opaque = OpaquePointer.bridgeJSStackPop() - let mutRaw = UnsafeMutableRawPointer.bridgeJSStackPop() - let raw = UnsafeRawPointer.bridgeJSStackPop() - return PointerFields(raw: raw, mutRaw: mutRaw, opaque: opaque, ptr: ptr, mutPtr: mutPtr) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.raw.bridgeJSStackPush() - self.mutRaw.bridgeJSStackPush() - self.opaque.bridgeJSStackPush() - self.ptr.bridgeJSStackPush() - self.mutPtr.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_PointerFields(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_PointerFields())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_PointerFields") -fileprivate func _bjs_struct_lower_PointerFields_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_PointerFields_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_PointerFields(_ objectId: Int32) -> Void { - return _bjs_struct_lower_PointerFields_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_PointerFields") -fileprivate func _bjs_struct_lift_PointerFields_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_PointerFields_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_PointerFields() -> Int32 { - return _bjs_struct_lift_PointerFields_extern() -} - -@_expose(wasm, "bjs_PointerFields_init") -@_cdecl("bjs_PointerFields_init") -public func _bjs_PointerFields_init(_ raw: UnsafeMutableRawPointer, _ mutRaw: UnsafeMutableRawPointer, _ opaque: UnsafeMutableRawPointer, _ ptr: UnsafeMutableRawPointer, _ mutPtr: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = PointerFields(raw: UnsafeRawPointer.bridgeJSLiftParameter(raw), mutRaw: UnsafeMutableRawPointer.bridgeJSLiftParameter(mutRaw), opaque: OpaquePointer.bridgeJSLiftParameter(opaque), ptr: UnsafePointer.bridgeJSLiftParameter(ptr), mutPtr: UnsafeMutablePointer.bridgeJSLiftParameter(mutPtr)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension DataPoint: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> DataPoint { - let optFlag = Optional.bridgeJSStackPop() - let optCount = Optional.bridgeJSStackPop() - let label = String.bridgeJSStackPop() - let y = Double.bridgeJSStackPop() - let x = Double.bridgeJSStackPop() - return DataPoint(x: x, y: y, label: label, optCount: optCount, optFlag: optFlag) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.x.bridgeJSStackPush() - self.y.bridgeJSStackPush() - self.label.bridgeJSStackPush() - self.optCount.bridgeJSStackPush() - self.optFlag.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_DataPoint(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_DataPoint())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_DataPoint") -fileprivate func _bjs_struct_lower_DataPoint_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_DataPoint_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_DataPoint(_ objectId: Int32) -> Void { - return _bjs_struct_lower_DataPoint_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_DataPoint") -fileprivate func _bjs_struct_lift_DataPoint_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_DataPoint_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_DataPoint() -> Int32 { - return _bjs_struct_lift_DataPoint_extern() -} - -@_expose(wasm, "bjs_DataPoint_init") -@_cdecl("bjs_DataPoint_init") -public func _bjs_DataPoint_init(_ x: Float64, _ y: Float64, _ labelBytes: Int32, _ labelLength: Int32, _ optCountIsSome: Int32, _ optCountValue: Int32, _ optFlagIsSome: Int32, _ optFlagValue: Int32) -> Void { - #if arch(wasm32) - let ret = DataPoint(x: Double.bridgeJSLiftParameter(x), y: Double.bridgeJSLiftParameter(y), label: String.bridgeJSLiftParameter(labelBytes, labelLength), optCount: Optional.bridgeJSLiftParameter(optCountIsSome, optCountValue), optFlag: Optional.bridgeJSLiftParameter(optFlagIsSome, optFlagValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataPoint_static_dimensions_get") -@_cdecl("bjs_DataPoint_static_dimensions_get") -public func _bjs_DataPoint_static_dimensions_get() -> Int32 { - #if arch(wasm32) - let ret = DataPoint.dimensions - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataPoint_static_origin") -@_cdecl("bjs_DataPoint_static_origin") -public func _bjs_DataPoint_static_origin() -> Void { - #if arch(wasm32) - let ret = DataPoint.origin() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension PublicPoint: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> PublicPoint { - let y = Int.bridgeJSStackPop() - let x = Int.bridgeJSStackPop() - return PublicPoint(x: x, y: y) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.x.bridgeJSStackPush() - self.y.bridgeJSStackPush() - } - - public init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_PublicPoint(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - public func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_PublicPoint())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_PublicPoint") -fileprivate func _bjs_struct_lower_PublicPoint_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_PublicPoint_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_PublicPoint(_ objectId: Int32) -> Void { - return _bjs_struct_lower_PublicPoint_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_PublicPoint") -fileprivate func _bjs_struct_lift_PublicPoint_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_PublicPoint_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_PublicPoint() -> Int32 { - return _bjs_struct_lift_PublicPoint_extern() -} - -@_expose(wasm, "bjs_PublicPoint_init") -@_cdecl("bjs_PublicPoint_init") -public func _bjs_PublicPoint_init(_ x: Int32, _ y: Int32) -> Void { - #if arch(wasm32) - let ret = PublicPoint(x: Int.bridgeJSLiftParameter(x), y: Int.bridgeJSLiftParameter(y)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension Address: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Address { - let zipCode = Optional.bridgeJSStackPop() - let city = String.bridgeJSStackPop() - let street = String.bridgeJSStackPop() - return Address(street: street, city: city, zipCode: zipCode) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.street.bridgeJSStackPush() - self.city.bridgeJSStackPush() - self.zipCode.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_Address(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Address())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Address") -fileprivate func _bjs_struct_lower_Address_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_Address_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_Address(_ objectId: Int32) -> Void { - return _bjs_struct_lower_Address_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Address") -fileprivate func _bjs_struct_lift_Address_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_Address_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_Address() -> Int32 { - return _bjs_struct_lift_Address_extern() -} - -extension Contact: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Contact { - let secondaryAddress = Optional
.bridgeJSStackPop() - let email = Optional.bridgeJSStackPop() - let address = Address.bridgeJSStackPop() - let age = Int.bridgeJSStackPop() - let name = String.bridgeJSStackPop() - return Contact(name: name, age: age, address: address, email: email, secondaryAddress: secondaryAddress) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.name.bridgeJSStackPush() - self.age.bridgeJSStackPush() - self.address.bridgeJSStackPush() - self.email.bridgeJSStackPush() - self.secondaryAddress.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_Contact(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Contact())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Contact") -fileprivate func _bjs_struct_lower_Contact_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_Contact_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_Contact(_ objectId: Int32) -> Void { - return _bjs_struct_lower_Contact_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Contact") -fileprivate func _bjs_struct_lift_Contact_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_Contact_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_Contact() -> Int32 { - return _bjs_struct_lift_Contact_extern() -} - -extension Config: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Config { - let status = Status.bridgeJSStackPop() - let direction = Optional.bridgeJSStackPop() - let theme = Optional.bridgeJSStackPop() - let name = String.bridgeJSStackPop() - return Config(name: name, theme: theme, direction: direction, status: status) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.name.bridgeJSStackPush() - self.theme.bridgeJSStackPush() - self.direction.bridgeJSStackPush() - self.status.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_Config(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Config())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Config") -fileprivate func _bjs_struct_lower_Config_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_Config_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_Config(_ objectId: Int32) -> Void { - return _bjs_struct_lower_Config_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Config") -fileprivate func _bjs_struct_lift_Config_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_Config_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_Config() -> Int32 { - return _bjs_struct_lift_Config_extern() -} - -extension SessionData: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> SessionData { - let owner = Optional.bridgeJSStackPop() - let id = Int.bridgeJSStackPop() - return SessionData(id: id, owner: owner) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.id.bridgeJSStackPush() - self.owner.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_SessionData(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_SessionData())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_SessionData") -fileprivate func _bjs_struct_lower_SessionData_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_SessionData_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_SessionData(_ objectId: Int32) -> Void { - return _bjs_struct_lower_SessionData_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_SessionData") -fileprivate func _bjs_struct_lift_SessionData_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_SessionData_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_SessionData() -> Int32 { - return _bjs_struct_lift_SessionData_extern() -} - -extension ValidationReport: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> ValidationReport { - let outcome = Optional.bridgeJSStackPop() - let status = Optional.bridgeJSStackPop() - let result = APIResult.bridgeJSStackPop() - let id = Int.bridgeJSStackPop() - return ValidationReport(id: id, result: result, status: status, outcome: outcome) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.id.bridgeJSStackPush() - self.result.bridgeJSStackPush() - self.status.bridgeJSStackPush() - self.outcome.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_ValidationReport(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_ValidationReport())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_ValidationReport") -fileprivate func _bjs_struct_lower_ValidationReport_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_ValidationReport_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_ValidationReport(_ objectId: Int32) -> Void { - return _bjs_struct_lower_ValidationReport_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_ValidationReport") -fileprivate func _bjs_struct_lift_ValidationReport_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_ValidationReport_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_ValidationReport() -> Int32 { - return _bjs_struct_lift_ValidationReport_extern() -} - -extension AdvancedConfig: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> AdvancedConfig { - let overrideDefaults = Optional.bridgeJSStackPop() - let defaults = ConfigStruct.bridgeJSStackPop() - let location = Optional.bridgeJSStackPop() - let metadata = Optional.bridgeJSStackPop() - let result = Optional.bridgeJSStackPop() - let status = Status.bridgeJSStackPop() - let theme = Theme.bridgeJSStackPop() - let enabled = Bool.bridgeJSStackPop() - let title = String.bridgeJSStackPop() - let id = Int.bridgeJSStackPop() - return AdvancedConfig(id: id, title: title, enabled: enabled, theme: theme, status: status, result: result, metadata: metadata, location: location, defaults: defaults, overrideDefaults: overrideDefaults) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.id.bridgeJSStackPush() - self.title.bridgeJSStackPush() - self.enabled.bridgeJSStackPush() - self.theme.bridgeJSStackPush() - self.status.bridgeJSStackPush() - self.result.bridgeJSStackPush() - self.metadata.bridgeJSStackPush() - self.location.bridgeJSStackPush() - self.defaults.bridgeJSStackPush() - self.overrideDefaults.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_AdvancedConfig(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_AdvancedConfig())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_AdvancedConfig") -fileprivate func _bjs_struct_lower_AdvancedConfig_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_AdvancedConfig_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_AdvancedConfig(_ objectId: Int32) -> Void { - return _bjs_struct_lower_AdvancedConfig_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_AdvancedConfig") -fileprivate func _bjs_struct_lift_AdvancedConfig_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_AdvancedConfig_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_AdvancedConfig() -> Int32 { - return _bjs_struct_lift_AdvancedConfig_extern() -} - -extension MeasurementConfig: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> MeasurementConfig { - let optionalRatio = Optional.bridgeJSStackPop() - let optionalPrecision = Optional.bridgeJSStackPop() - let ratio = Ratio.bridgeJSStackPop() - let precision = Precision.bridgeJSStackPop() - return MeasurementConfig(precision: precision, ratio: ratio, optionalPrecision: optionalPrecision, optionalRatio: optionalRatio) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.precision.bridgeJSStackPush() - self.ratio.bridgeJSStackPush() - self.optionalPrecision.bridgeJSStackPush() - self.optionalRatio.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_MeasurementConfig(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_MeasurementConfig())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_MeasurementConfig") -fileprivate func _bjs_struct_lower_MeasurementConfig_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_MeasurementConfig_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_MeasurementConfig(_ objectId: Int32) -> Void { - return _bjs_struct_lower_MeasurementConfig_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_MeasurementConfig") -fileprivate func _bjs_struct_lift_MeasurementConfig_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_MeasurementConfig_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_MeasurementConfig() -> Int32 { - return _bjs_struct_lift_MeasurementConfig_extern() -} - -extension MathOperations: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> MathOperations { - let baseValue = Double.bridgeJSStackPop() - return MathOperations(baseValue: baseValue) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.baseValue.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_MathOperations(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_MathOperations())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_MathOperations") -fileprivate func _bjs_struct_lower_MathOperations_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_MathOperations_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_MathOperations(_ objectId: Int32) -> Void { - return _bjs_struct_lower_MathOperations_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_MathOperations") -fileprivate func _bjs_struct_lift_MathOperations_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_MathOperations_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_MathOperations() -> Int32 { - return _bjs_struct_lift_MathOperations_extern() -} - -@_expose(wasm, "bjs_MathOperations_init") -@_cdecl("bjs_MathOperations_init") -public func _bjs_MathOperations_init(_ baseValue: Float64) -> Void { - #if arch(wasm32) - let ret = MathOperations(baseValue: Double.bridgeJSLiftParameter(baseValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_MathOperations_add") -@_cdecl("bjs_MathOperations_add") -public func _bjs_MathOperations_add(_ a: Float64, _ b: Float64) -> Float64 { - #if arch(wasm32) - let ret = MathOperations.bridgeJSLiftParameter().add(a: Double.bridgeJSLiftParameter(a), b: Double.bridgeJSLiftParameter(b)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_MathOperations_multiply") -@_cdecl("bjs_MathOperations_multiply") -public func _bjs_MathOperations_multiply(_ a: Float64, _ b: Float64) -> Float64 { - #if arch(wasm32) - let ret = MathOperations.bridgeJSLiftParameter().multiply(a: Double.bridgeJSLiftParameter(a), b: Double.bridgeJSLiftParameter(b)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_MathOperations_static_subtract") -@_cdecl("bjs_MathOperations_static_subtract") -public func _bjs_MathOperations_static_subtract(_ a: Float64, _ b: Float64) -> Float64 { - #if arch(wasm32) - let ret = MathOperations.subtract(a: Double.bridgeJSLiftParameter(a), b: Double.bridgeJSLiftParameter(b)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension CopyableCart: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> CopyableCart { - let note = Optional.bridgeJSStackPop() - let x = Int.bridgeJSStackPop() - return CopyableCart(x: x, note: note) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.x.bridgeJSStackPush() - self.note.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_CopyableCart(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_CopyableCart())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_CopyableCart") -fileprivate func _bjs_struct_lower_CopyableCart_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_CopyableCart_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_CopyableCart(_ objectId: Int32) -> Void { - return _bjs_struct_lower_CopyableCart_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_CopyableCart") -fileprivate func _bjs_struct_lift_CopyableCart_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_CopyableCart_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_CopyableCart() -> Int32 { - return _bjs_struct_lift_CopyableCart_extern() -} - -@_expose(wasm, "bjs_CopyableCart_static_fromJSObject") -@_cdecl("bjs_CopyableCart_static_fromJSObject") -public func _bjs_CopyableCart_static_fromJSObject(_ object: Int32) -> Void { - #if arch(wasm32) - let ret = CopyableCart.fromJSObject(_: JSObject.bridgeJSLiftParameter(object)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension CopyableCartItem: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> CopyableCartItem { - let quantity = Int.bridgeJSStackPop() - let sku = String.bridgeJSStackPop() - return CopyableCartItem(sku: sku, quantity: quantity) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.sku.bridgeJSStackPush() - self.quantity.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_CopyableCartItem(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_CopyableCartItem())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_CopyableCartItem") -fileprivate func _bjs_struct_lower_CopyableCartItem_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_CopyableCartItem_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_CopyableCartItem(_ objectId: Int32) -> Void { - return _bjs_struct_lower_CopyableCartItem_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_CopyableCartItem") -fileprivate func _bjs_struct_lift_CopyableCartItem_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_CopyableCartItem_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_CopyableCartItem() -> Int32 { - return _bjs_struct_lift_CopyableCartItem_extern() -} - -extension CopyableNestedCart: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> CopyableNestedCart { - let shippingAddress = Optional
.bridgeJSStackPop() - let item = CopyableCartItem.bridgeJSStackPop() - let id = Int.bridgeJSStackPop() - return CopyableNestedCart(id: id, item: item, shippingAddress: shippingAddress) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.id.bridgeJSStackPush() - self.item.bridgeJSStackPush() - self.shippingAddress.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_CopyableNestedCart(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_CopyableNestedCart())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_CopyableNestedCart") -fileprivate func _bjs_struct_lower_CopyableNestedCart_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_CopyableNestedCart_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_CopyableNestedCart(_ objectId: Int32) -> Void { - return _bjs_struct_lower_CopyableNestedCart_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_CopyableNestedCart") -fileprivate func _bjs_struct_lift_CopyableNestedCart_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_CopyableNestedCart_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_CopyableNestedCart() -> Int32 { - return _bjs_struct_lift_CopyableNestedCart_extern() -} - -@_expose(wasm, "bjs_CopyableNestedCart_static_fromJSObject") -@_cdecl("bjs_CopyableNestedCart_static_fromJSObject") -public func _bjs_CopyableNestedCart_static_fromJSObject(_ object: Int32) -> Void { - #if arch(wasm32) - let ret = CopyableNestedCart.fromJSObject(_: JSObject.bridgeJSLiftParameter(object)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension ConfigStruct: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> ConfigStruct { - let value = Int.bridgeJSStackPop() - let name = String.bridgeJSStackPop() - return ConfigStruct(name: name, value: value) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.name.bridgeJSStackPush() - self.value.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_ConfigStruct(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_ConfigStruct())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_ConfigStruct") -fileprivate func _bjs_struct_lower_ConfigStruct_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_ConfigStruct_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_ConfigStruct(_ objectId: Int32) -> Void { - return _bjs_struct_lower_ConfigStruct_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_ConfigStruct") -fileprivate func _bjs_struct_lift_ConfigStruct_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_ConfigStruct_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_ConfigStruct() -> Int32 { - return _bjs_struct_lift_ConfigStruct_extern() -} - -@_expose(wasm, "bjs_ConfigStruct_static_defaultConfig_get") -@_cdecl("bjs_ConfigStruct_static_defaultConfig_get") -public func _bjs_ConfigStruct_static_defaultConfig_get() -> Void { - #if arch(wasm32) - let ret = ConfigStruct.defaultConfig - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ConfigStruct_static_defaultConfig_set") -@_cdecl("bjs_ConfigStruct_static_defaultConfig_set") -public func _bjs_ConfigStruct_static_defaultConfig_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - ConfigStruct.defaultConfig = String.bridgeJSLiftParameter(valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ConfigStruct_static_maxRetries_get") -@_cdecl("bjs_ConfigStruct_static_maxRetries_get") -public func _bjs_ConfigStruct_static_maxRetries_get() -> Int32 { - #if arch(wasm32) - let ret = ConfigStruct.maxRetries - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ConfigStruct_static_timeout_get") -@_cdecl("bjs_ConfigStruct_static_timeout_get") -public func _bjs_ConfigStruct_static_timeout_get() -> Float64 { - #if arch(wasm32) - let ret = ConfigStruct.timeout - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ConfigStruct_static_timeout_set") -@_cdecl("bjs_ConfigStruct_static_timeout_set") -public func _bjs_ConfigStruct_static_timeout_set(_ value: Float64) -> Void { - #if arch(wasm32) - ConfigStruct.timeout = Double.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ConfigStruct_static_computedSetting_get") -@_cdecl("bjs_ConfigStruct_static_computedSetting_get") -public func _bjs_ConfigStruct_static_computedSetting_get() -> Void { - #if arch(wasm32) - let ret = ConfigStruct.computedSetting - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension Vector2D: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Vector2D { - let dy = Double.bridgeJSStackPop() - let dx = Double.bridgeJSStackPop() - return Vector2D(dx: dx, dy: dy) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.dx.bridgeJSStackPush() - self.dy.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_Vector2D(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Vector2D())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Vector2D") -fileprivate func _bjs_struct_lower_Vector2D_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_Vector2D_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_Vector2D(_ objectId: Int32) -> Void { - return _bjs_struct_lower_Vector2D_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Vector2D") -fileprivate func _bjs_struct_lift_Vector2D_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_Vector2D_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_Vector2D() -> Int32 { - return _bjs_struct_lift_Vector2D_extern() -} - -@_expose(wasm, "bjs_Vector2D_init") -@_cdecl("bjs_Vector2D_init") -public func _bjs_Vector2D_init(_ dx: Float64, _ dy: Float64) -> Void { - #if arch(wasm32) - let ret = Vector2D(dx: Double.bridgeJSLiftParameter(dx), dy: Double.bridgeJSLiftParameter(dy)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Vector2D_magnitude") -@_cdecl("bjs_Vector2D_magnitude") -public func _bjs_Vector2D_magnitude() -> Float64 { - #if arch(wasm32) - let ret = Vector2D.bridgeJSLiftParameter().magnitude() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Vector2D_scaled") -@_cdecl("bjs_Vector2D_scaled") -public func _bjs_Vector2D_scaled(_ factor: Float64) -> Void { - #if arch(wasm32) - let ret = Vector2D.bridgeJSLiftParameter().scaled(by: Double.bridgeJSLiftParameter(factor)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension JSObjectContainer: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> JSObjectContainer { - let optionalObject = Optional.bridgeJSStackPop() - let object = JSObject.bridgeJSStackPop() - return JSObjectContainer(object: object, optionalObject: optionalObject) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.object.bridgeJSStackPush() - self.optionalObject.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_JSObjectContainer(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_JSObjectContainer())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_JSObjectContainer") -fileprivate func _bjs_struct_lower_JSObjectContainer_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_JSObjectContainer_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_JSObjectContainer(_ objectId: Int32) -> Void { - return _bjs_struct_lower_JSObjectContainer_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_JSObjectContainer") -fileprivate func _bjs_struct_lift_JSObjectContainer_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_JSObjectContainer_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_JSObjectContainer() -> Int32 { - return _bjs_struct_lift_JSObjectContainer_extern() -} - -extension FooContainer: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> FooContainer { - let optionalFoo = Optional.bridgeJSStackPop().map { Foo(unsafelyWrapping: $0) } - let foo = Foo(unsafelyWrapping: JSObject.bridgeJSStackPop()) - return FooContainer(foo: foo, optionalFoo: optionalFoo) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.foo.jsObject.bridgeJSStackPush() - self.optionalFoo.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_FooContainer(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_FooContainer())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_FooContainer") -fileprivate func _bjs_struct_lower_FooContainer_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_FooContainer_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_FooContainer(_ objectId: Int32) -> Void { - return _bjs_struct_lower_FooContainer_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_FooContainer") -fileprivate func _bjs_struct_lift_FooContainer_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_FooContainer_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_FooContainer() -> Int32 { - return _bjs_struct_lift_FooContainer_extern() -} - -extension ArrayMembers: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> ArrayMembers { - let optStrings = Optional<[String]>.bridgeJSStackPop() - let ints = [Int].bridgeJSStackPop() - return ArrayMembers(ints: ints, optStrings: optStrings) - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.ints.bridgeJSStackPush() - self.optStrings.bridgeJSStackPush() - } - - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_ArrayMembers(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } - - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_ArrayMembers())) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_ArrayMembers") -fileprivate func _bjs_struct_lower_ArrayMembers_extern(_ objectId: Int32) -> Void -#else -fileprivate func _bjs_struct_lower_ArrayMembers_extern(_ objectId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_ArrayMembers(_ objectId: Int32) -> Void { - return _bjs_struct_lower_ArrayMembers_extern(objectId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_ArrayMembers") -fileprivate func _bjs_struct_lift_ArrayMembers_extern() -> Int32 -#else -fileprivate func _bjs_struct_lift_ArrayMembers_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_ArrayMembers() -> Int32 { - return _bjs_struct_lift_ArrayMembers_extern() -} - -@_expose(wasm, "bjs_ArrayMembers_sumValues") -@_cdecl("bjs_ArrayMembers_sumValues") -public func _bjs_ArrayMembers_sumValues() -> Int32 { - #if arch(wasm32) - let ret = ArrayMembers.bridgeJSLiftParameter().sumValues(_: [Int].bridgeJSStackPop()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArrayMembers_firstString") -@_cdecl("bjs_ArrayMembers_firstString") -public func _bjs_ArrayMembers_firstString() -> Void { - #if arch(wasm32) - let ret = ArrayMembers.bridgeJSLiftParameter().firstString(_: [String].bridgeJSStackPop()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripVoid") -@_cdecl("bjs_roundTripVoid") -public func _bjs_roundTripVoid() -> Void { - #if arch(wasm32) - roundTripVoid() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripFloat") -@_cdecl("bjs_roundTripFloat") -public func _bjs_roundTripFloat(_ v: Float32) -> Float32 { - #if arch(wasm32) - let ret = roundTripFloat(v: Float.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripDouble") -@_cdecl("bjs_roundTripDouble") -public func _bjs_roundTripDouble(_ v: Float64) -> Float64 { - #if arch(wasm32) - let ret = roundTripDouble(v: Double.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripBool") -@_cdecl("bjs_roundTripBool") -public func _bjs_roundTripBool(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = roundTripBool(v: Bool.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripString") -@_cdecl("bjs_roundTripString") -public func _bjs_roundTripString(_ vBytes: Int32, _ vLength: Int32) -> Void { - #if arch(wasm32) - let ret = roundTripString(v: String.bridgeJSLiftParameter(vBytes, vLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripSwiftHeapObject") -@_cdecl("bjs_roundTripSwiftHeapObject") -public func _bjs_roundTripSwiftHeapObject(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = roundTripSwiftHeapObject(v: Greeter.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripUnsafeRawPointer") -@_cdecl("bjs_roundTripUnsafeRawPointer") -public func _bjs_roundTripUnsafeRawPointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = roundTripUnsafeRawPointer(v: UnsafeRawPointer.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripUnsafeMutableRawPointer") -@_cdecl("bjs_roundTripUnsafeMutableRawPointer") -public func _bjs_roundTripUnsafeMutableRawPointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = roundTripUnsafeMutableRawPointer(v: UnsafeMutableRawPointer.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripOpaquePointer") -@_cdecl("bjs_roundTripOpaquePointer") -public func _bjs_roundTripOpaquePointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = roundTripOpaquePointer(v: OpaquePointer.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripUnsafePointer") -@_cdecl("bjs_roundTripUnsafePointer") -public func _bjs_roundTripUnsafePointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = roundTripUnsafePointer(v: UnsafePointer.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripUnsafeMutablePointer") -@_cdecl("bjs_roundTripUnsafeMutablePointer") -public func _bjs_roundTripUnsafeMutablePointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = roundTripUnsafeMutablePointer(v: UnsafeMutablePointer.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripJSObject") -@_cdecl("bjs_roundTripJSObject") -public func _bjs_roundTripJSObject(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = roundTripJSObject(v: JSObject.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripDictionaryExport") -@_cdecl("bjs_roundTripDictionaryExport") -public func _bjs_roundTripDictionaryExport() -> Void { - #if arch(wasm32) - let ret = roundTripDictionaryExport(v: [String: Int].bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripOptionalDictionaryExport") -@_cdecl("bjs_roundTripOptionalDictionaryExport") -public func _bjs_roundTripOptionalDictionaryExport() -> Void { - #if arch(wasm32) - let ret = roundTripOptionalDictionaryExport(v: Optional<[String: String]>.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripJSValue") -@_cdecl("bjs_roundTripJSValue") -public func _bjs_roundTripJSValue(_ vKind: Int32, _ vPayload1: Int32, _ vPayload2: Float64) -> Void { - #if arch(wasm32) - let ret = roundTripJSValue(v: JSValue.bridgeJSLiftParameter(vKind, vPayload1, vPayload2)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripOptionalJSValue") -@_cdecl("bjs_roundTripOptionalJSValue") -public func _bjs_roundTripOptionalJSValue(_ vIsSome: Int32, _ vKind: Int32, _ vPayload1: Int32, _ vPayload2: Float64) -> Void { - #if arch(wasm32) - let ret = roundTripOptionalJSValue(v: Optional.bridgeJSLiftParameter(vIsSome, vKind, vPayload1, vPayload2)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripOptionalJSValueArray") -@_cdecl("bjs_roundTripOptionalJSValueArray") -public func _bjs_roundTripOptionalJSValueArray() -> Void { - #if arch(wasm32) - let ret = roundTripOptionalJSValueArray(v: Optional<[JSValue]>.bridgeJSLiftParameter()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeImportedFoo") -@_cdecl("bjs_makeImportedFoo") -public func _bjs_makeImportedFoo(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 { - #if arch(wasm32) - do { - let ret = try makeImportedFoo(value: String.bridgeJSLiftParameter(valueBytes, valueLength)) - return ret.bridgeJSLowerReturn() - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: String(describing: error)) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return 0 - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_throwsSwiftError") -@_cdecl("bjs_throwsSwiftError") -public func _bjs_throwsSwiftError(_ shouldThrow: Int32) -> Void { - #if arch(wasm32) - do { - try throwsSwiftError(shouldThrow: Bool.bridgeJSLiftParameter(shouldThrow)) - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: String(describing: error)) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_throwsWithIntResult") -@_cdecl("bjs_throwsWithIntResult") -public func _bjs_throwsWithIntResult() -> Int32 { - #if arch(wasm32) - do { - let ret = try throwsWithIntResult() - return ret.bridgeJSLowerReturn() - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: String(describing: error)) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return 0 - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_throwsWithStringResult") -@_cdecl("bjs_throwsWithStringResult") -public func _bjs_throwsWithStringResult() -> Void { - #if arch(wasm32) - do { - let ret = try throwsWithStringResult() - return ret.bridgeJSLowerReturn() - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: String(describing: error)) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_throwsWithBoolResult") -@_cdecl("bjs_throwsWithBoolResult") -public func _bjs_throwsWithBoolResult() -> Int32 { - #if arch(wasm32) - do { - let ret = try throwsWithBoolResult() - return ret.bridgeJSLowerReturn() - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: String(describing: error)) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return 0 - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_throwsWithFloatResult") -@_cdecl("bjs_throwsWithFloatResult") -public func _bjs_throwsWithFloatResult() -> Float32 { - #if arch(wasm32) - do { - let ret = try throwsWithFloatResult() - return ret.bridgeJSLowerReturn() - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: String(describing: error)) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return 0.0 - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_throwsWithDoubleResult") -@_cdecl("bjs_throwsWithDoubleResult") -public func _bjs_throwsWithDoubleResult() -> Float64 { - #if arch(wasm32) - do { - let ret = try throwsWithDoubleResult() - return ret.bridgeJSLowerReturn() - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: String(describing: error)) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return 0.0 - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_throwsWithSwiftHeapObjectResult") -@_cdecl("bjs_throwsWithSwiftHeapObjectResult") -public func _bjs_throwsWithSwiftHeapObjectResult() -> UnsafeMutableRawPointer { - #if arch(wasm32) - do { - let ret = try throwsWithSwiftHeapObjectResult() - return ret.bridgeJSLowerReturn() - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: String(describing: error)) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return UnsafeMutableRawPointer(bitPattern: -1).unsafelyUnwrapped - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_throwsWithJSObjectResult") -@_cdecl("bjs_throwsWithJSObjectResult") -public func _bjs_throwsWithJSObjectResult() -> Int32 { - #if arch(wasm32) - do { - let ret = try throwsWithJSObjectResult() - return ret.bridgeJSLowerReturn() - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: String(describing: error)) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return 0 - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripVoid") -@_cdecl("bjs_asyncRoundTripVoid") -public func _bjs_asyncRoundTripVoid() -> Int32 { - #if arch(wasm32) - let ret = JSPromise.async { - await asyncRoundTripVoid() - }.jsObject - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripInt") -@_cdecl("bjs_asyncRoundTripInt") -public func _bjs_asyncRoundTripInt(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripInt(v: Int.bridgeJSLiftParameter(v)).jsValue - }.jsObject - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripFloat") -@_cdecl("bjs_asyncRoundTripFloat") -public func _bjs_asyncRoundTripFloat(_ v: Float32) -> Int32 { - #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripFloat(v: Float.bridgeJSLiftParameter(v)).jsValue - }.jsObject - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripDouble") -@_cdecl("bjs_asyncRoundTripDouble") -public func _bjs_asyncRoundTripDouble(_ v: Float64) -> Int32 { - #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripDouble(v: Double.bridgeJSLiftParameter(v)).jsValue - }.jsObject - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripBool") -@_cdecl("bjs_asyncRoundTripBool") -public func _bjs_asyncRoundTripBool(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripBool(v: Bool.bridgeJSLiftParameter(v)).jsValue - }.jsObject - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripString") -@_cdecl("bjs_asyncRoundTripString") -public func _bjs_asyncRoundTripString(_ vBytes: Int32, _ vLength: Int32) -> Int32 { - #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripString(v: String.bridgeJSLiftParameter(vBytes, vLength)).jsValue - }.jsObject - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripSwiftHeapObject") -@_cdecl("bjs_asyncRoundTripSwiftHeapObject") -public func _bjs_asyncRoundTripSwiftHeapObject(_ v: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripSwiftHeapObject(v: Greeter.bridgeJSLiftParameter(v)).jsValue - }.jsObject - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripJSObject") -@_cdecl("bjs_asyncRoundTripJSObject") -public func _bjs_asyncRoundTripJSObject(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripJSObject(v: JSObject.bridgeJSLiftParameter(v)).jsValue - }.jsObject - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_takeGreeter") -@_cdecl("bjs_takeGreeter") -public func _bjs_takeGreeter(_ g: UnsafeMutableRawPointer, _ nameBytes: Int32, _ nameLength: Int32) -> Void { - #if arch(wasm32) - takeGreeter(g: Greeter.bridgeJSLiftParameter(g), name: String.bridgeJSLiftParameter(nameBytes, nameLength)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_createCalculator") -@_cdecl("bjs_createCalculator") -public func _bjs_createCalculator() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = createCalculator() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_useCalculator") -@_cdecl("bjs_useCalculator") -public func _bjs_useCalculator(_ calc: UnsafeMutableRawPointer, _ x: Int32, _ y: Int32) -> Int32 { - #if arch(wasm32) - let ret = useCalculator(calc: Calculator.bridgeJSLiftParameter(calc), x: Int.bridgeJSLiftParameter(x), y: Int.bridgeJSLiftParameter(y)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_testGreeterToJSValue") -@_cdecl("bjs_testGreeterToJSValue") -public func _bjs_testGreeterToJSValue() -> Int32 { - #if arch(wasm32) - let ret = testGreeterToJSValue() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_testCalculatorToJSValue") -@_cdecl("bjs_testCalculatorToJSValue") -public func _bjs_testCalculatorToJSValue() -> Int32 { - #if arch(wasm32) - let ret = testCalculatorToJSValue() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_testSwiftClassAsJSValue") -@_cdecl("bjs_testSwiftClassAsJSValue") -public func _bjs_testSwiftClassAsJSValue(_ greeter: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = testSwiftClassAsJSValue(greeter: Greeter.bridgeJSLiftParameter(greeter)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_setDirection") -@_cdecl("bjs_setDirection") -public func _bjs_setDirection(_ direction: Int32) -> Int32 { - #if arch(wasm32) - let ret = setDirection(_: Direction.bridgeJSLiftParameter(direction)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getDirection") -@_cdecl("bjs_getDirection") -public func _bjs_getDirection() -> Int32 { - #if arch(wasm32) - let ret = getDirection() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_processDirection") -@_cdecl("bjs_processDirection") -public func _bjs_processDirection(_ input: Int32) -> Int32 { - #if arch(wasm32) - let ret = processDirection(_: Direction.bridgeJSLiftParameter(input)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_setTheme") -@_cdecl("bjs_setTheme") -public func _bjs_setTheme(_ themeBytes: Int32, _ themeLength: Int32) -> Void { - #if arch(wasm32) - let ret = setTheme(_: Theme.bridgeJSLiftParameter(themeBytes, themeLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getTheme") -@_cdecl("bjs_getTheme") -public func _bjs_getTheme() -> Void { - #if arch(wasm32) - let ret = getTheme() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_setHttpStatus") -@_cdecl("bjs_setHttpStatus") -public func _bjs_setHttpStatus(_ status: Int32) -> Int32 { - #if arch(wasm32) - let ret = setHttpStatus(_: HttpStatus.bridgeJSLiftParameter(status)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getHttpStatus") -@_cdecl("bjs_getHttpStatus") -public func _bjs_getHttpStatus() -> Int32 { - #if arch(wasm32) - let ret = getHttpStatus() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_setFileSize") -@_cdecl("bjs_setFileSize") -public func _bjs_setFileSize(_ size: Int64) -> Int64 { - #if arch(wasm32) - let ret = setFileSize(_: FileSize.bridgeJSLiftParameter(size)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getFileSize") -@_cdecl("bjs_getFileSize") -public func _bjs_getFileSize() -> Int64 { - #if arch(wasm32) - let ret = getFileSize() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_setSessionId") -@_cdecl("bjs_setSessionId") -public func _bjs_setSessionId(_ session: Int64) -> Int64 { - #if arch(wasm32) - let ret = setSessionId(_: SessionId.bridgeJSLiftParameter(session)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getSessionId") -@_cdecl("bjs_getSessionId") -public func _bjs_getSessionId() -> Int64 { - #if arch(wasm32) - let ret = getSessionId() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_processTheme") -@_cdecl("bjs_processTheme") -public func _bjs_processTheme(_ themeBytes: Int32, _ themeLength: Int32) -> Int32 { - #if arch(wasm32) - let ret = processTheme(_: Theme.bridgeJSLiftParameter(themeBytes, themeLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_setTSDirection") -@_cdecl("bjs_setTSDirection") -public func _bjs_setTSDirection(_ direction: Int32) -> Int32 { - #if arch(wasm32) - let ret = setTSDirection(_: TSDirection.bridgeJSLiftParameter(direction)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getTSDirection") -@_cdecl("bjs_getTSDirection") -public func _bjs_getTSDirection() -> Int32 { - #if arch(wasm32) - let ret = getTSDirection() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_setTSTheme") -@_cdecl("bjs_setTSTheme") -public func _bjs_setTSTheme(_ themeBytes: Int32, _ themeLength: Int32) -> Void { - #if arch(wasm32) - let ret = setTSTheme(_: TSTheme.bridgeJSLiftParameter(themeBytes, themeLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getTSTheme") -@_cdecl("bjs_getTSTheme") -public func _bjs_getTSTheme() -> Void { - #if arch(wasm32) - let ret = getTSTheme() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_createConverter") -@_cdecl("bjs_createConverter") -public func _bjs_createConverter() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = createConverter() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_useConverter") -@_cdecl("bjs_useConverter") -public func _bjs_useConverter(_ converter: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - let ret = useConverter(converter: Utils.Converter.bridgeJSLiftParameter(converter), value: Int.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripConverterArray") -@_cdecl("bjs_roundTripConverterArray") -public func _bjs_roundTripConverterArray() -> Void { - #if arch(wasm32) - let ret = roundTripConverterArray(_: [Utils.Converter].bridgeJSStackPop()) - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_createHTTPServer") -@_cdecl("bjs_createHTTPServer") -public func _bjs_createHTTPServer() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = createHTTPServer() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_createUUID") -@_cdecl("bjs_createUUID") -public func _bjs_createUUID(_ valueBytes: Int32, _ valueLength: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = createUUID(value: String.bridgeJSLiftParameter(valueBytes, valueLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripUUID") -@_cdecl("bjs_roundTripUUID") -public func _bjs_roundTripUUID(_ uuid: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = roundTripUUID(_: UUID.bridgeJSLiftParameter(uuid)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundtripNetworkingAPIMethod") -@_cdecl("bjs_roundtripNetworkingAPIMethod") -public func _bjs_roundtripNetworkingAPIMethod(_ method: Int32) -> Int32 { - #if arch(wasm32) - let ret = roundtripNetworkingAPIMethod(_: Networking.API.Method.bridgeJSLiftParameter(method)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundtripConfigurationLogLevel") -@_cdecl("bjs_roundtripConfigurationLogLevel") -public func _bjs_roundtripConfigurationLogLevel(_ levelBytes: Int32, _ levelLength: Int32) -> Void { - #if arch(wasm32) - let ret = roundtripConfigurationLogLevel(_: Configuration.LogLevel.bridgeJSLiftParameter(levelBytes, levelLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundtripConfigurationPort") -@_cdecl("bjs_roundtripConfigurationPort") -public func _bjs_roundtripConfigurationPort(_ port: Int32) -> Int32 { - #if arch(wasm32) - let ret = roundtripConfigurationPort(_: Configuration.Port.bridgeJSLiftParameter(port)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_processConfigurationLogLevel") -@_cdecl("bjs_processConfigurationLogLevel") -public func _bjs_processConfigurationLogLevel(_ levelBytes: Int32, _ levelLength: Int32) -> Int32 { - #if arch(wasm32) - let ret = processConfigurationLogLevel(_: Configuration.LogLevel.bridgeJSLiftParameter(levelBytes, levelLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundtripInternalSupportedMethod") -@_cdecl("bjs_roundtripInternalSupportedMethod") -public func _bjs_roundtripInternalSupportedMethod(_ method: Int32) -> Int32 { - #if arch(wasm32) - let ret = roundtripInternalSupportedMethod(_: Internal.SupportedMethod.bridgeJSLiftParameter(method)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundtripAPIResult") -@_cdecl("bjs_roundtripAPIResult") -public func _bjs_roundtripAPIResult(_ result: Int32) -> Void { - #if arch(wasm32) - let ret = roundtripAPIResult(result: APIResult.bridgeJSLiftParameter(result)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeAPIResultSuccess") -@_cdecl("bjs_makeAPIResultSuccess") -public func _bjs_makeAPIResultSuccess(_ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - let ret = makeAPIResultSuccess(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeAPIResultFailure") -@_cdecl("bjs_makeAPIResultFailure") -public func _bjs_makeAPIResultFailure(_ value: Int32) -> Void { - #if arch(wasm32) - let ret = makeAPIResultFailure(_: Int.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeAPIResultInfo") -@_cdecl("bjs_makeAPIResultInfo") -public func _bjs_makeAPIResultInfo() -> Void { - #if arch(wasm32) - let ret = makeAPIResultInfo() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeAPIResultFlag") -@_cdecl("bjs_makeAPIResultFlag") -public func _bjs_makeAPIResultFlag(_ value: Int32) -> Void { - #if arch(wasm32) - let ret = makeAPIResultFlag(_: Bool.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeAPIResultRate") -@_cdecl("bjs_makeAPIResultRate") -public func _bjs_makeAPIResultRate(_ value: Float32) -> Void { - #if arch(wasm32) - let ret = makeAPIResultRate(_: Float.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeAPIResultPrecise") -@_cdecl("bjs_makeAPIResultPrecise") -public func _bjs_makeAPIResultPrecise(_ value: Float64) -> Void { - #if arch(wasm32) - let ret = makeAPIResultPrecise(_: Double.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundtripComplexResult") -@_cdecl("bjs_roundtripComplexResult") -public func _bjs_roundtripComplexResult(_ result: Int32) -> Void { - #if arch(wasm32) - let ret = roundtripComplexResult(_: ComplexResult.bridgeJSLiftParameter(result)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeComplexResultSuccess") -@_cdecl("bjs_makeComplexResultSuccess") -public func _bjs_makeComplexResultSuccess(_ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - let ret = makeComplexResultSuccess(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeComplexResultError") -@_cdecl("bjs_makeComplexResultError") -public func _bjs_makeComplexResultError(_ messageBytes: Int32, _ messageLength: Int32, _ code: Int32) -> Void { - #if arch(wasm32) - let ret = makeComplexResultError(_: String.bridgeJSLiftParameter(messageBytes, messageLength), _: Int.bridgeJSLiftParameter(code)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeComplexResultLocation") -@_cdecl("bjs_makeComplexResultLocation") -public func _bjs_makeComplexResultLocation(_ lat: Float64, _ lng: Float64, _ nameBytes: Int32, _ nameLength: Int32) -> Void { - #if arch(wasm32) - let ret = makeComplexResultLocation(_: Double.bridgeJSLiftParameter(lat), _: Double.bridgeJSLiftParameter(lng), _: String.bridgeJSLiftParameter(nameBytes, nameLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeComplexResultStatus") -@_cdecl("bjs_makeComplexResultStatus") -public func _bjs_makeComplexResultStatus(_ active: Int32, _ code: Int32, _ messageBytes: Int32, _ messageLength: Int32) -> Void { - #if arch(wasm32) - let ret = makeComplexResultStatus(_: Bool.bridgeJSLiftParameter(active), _: Int.bridgeJSLiftParameter(code), _: String.bridgeJSLiftParameter(messageBytes, messageLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeComplexResultCoordinates") -@_cdecl("bjs_makeComplexResultCoordinates") -public func _bjs_makeComplexResultCoordinates(_ x: Float64, _ y: Float64, _ z: Float64) -> Void { - #if arch(wasm32) - let ret = makeComplexResultCoordinates(_: Double.bridgeJSLiftParameter(x), _: Double.bridgeJSLiftParameter(y), _: Double.bridgeJSLiftParameter(z)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeComplexResultComprehensive") -@_cdecl("bjs_makeComplexResultComprehensive") -public func _bjs_makeComplexResultComprehensive(_ flag1: Int32, _ flag2: Int32, _ count1: Int32, _ count2: Int32, _ value1: Float64, _ value2: Float64, _ text1Bytes: Int32, _ text1Length: Int32, _ text2Bytes: Int32, _ text2Length: Int32, _ text3Bytes: Int32, _ text3Length: Int32) -> Void { - #if arch(wasm32) - let ret = makeComplexResultComprehensive(_: Bool.bridgeJSLiftParameter(flag1), _: Bool.bridgeJSLiftParameter(flag2), _: Int.bridgeJSLiftParameter(count1), _: Int.bridgeJSLiftParameter(count2), _: Double.bridgeJSLiftParameter(value1), _: Double.bridgeJSLiftParameter(value2), _: String.bridgeJSLiftParameter(text1Bytes, text1Length), _: String.bridgeJSLiftParameter(text2Bytes, text2Length), _: String.bridgeJSLiftParameter(text3Bytes, text3Length)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeComplexResultInfo") -@_cdecl("bjs_makeComplexResultInfo") -public func _bjs_makeComplexResultInfo() -> Void { - #if arch(wasm32) - let ret = makeComplexResultInfo() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeUtilitiesResultSuccess") -@_cdecl("bjs_makeUtilitiesResultSuccess") -public func _bjs_makeUtilitiesResultSuccess(_ messageBytes: Int32, _ messageLength: Int32) -> Void { - #if arch(wasm32) - let ret = makeUtilitiesResultSuccess(_: String.bridgeJSLiftParameter(messageBytes, messageLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeUtilitiesResultFailure") -@_cdecl("bjs_makeUtilitiesResultFailure") -public func _bjs_makeUtilitiesResultFailure(_ errorBytes: Int32, _ errorLength: Int32, _ code: Int32) -> Void { - #if arch(wasm32) - let ret = makeUtilitiesResultFailure(_: String.bridgeJSLiftParameter(errorBytes, errorLength), _: Int.bridgeJSLiftParameter(code)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeUtilitiesResultStatus") -@_cdecl("bjs_makeUtilitiesResultStatus") -public func _bjs_makeUtilitiesResultStatus(_ active: Int32, _ code: Int32, _ messageBytes: Int32, _ messageLength: Int32) -> Void { - #if arch(wasm32) - let ret = makeUtilitiesResultStatus(_: Bool.bridgeJSLiftParameter(active), _: Int.bridgeJSLiftParameter(code), _: String.bridgeJSLiftParameter(messageBytes, messageLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeAPINetworkingResultSuccess") -@_cdecl("bjs_makeAPINetworkingResultSuccess") -public func _bjs_makeAPINetworkingResultSuccess(_ messageBytes: Int32, _ messageLength: Int32) -> Void { - #if arch(wasm32) - let ret = makeAPINetworkingResultSuccess(_: String.bridgeJSLiftParameter(messageBytes, messageLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeAPINetworkingResultFailure") -@_cdecl("bjs_makeAPINetworkingResultFailure") -public func _bjs_makeAPINetworkingResultFailure(_ errorBytes: Int32, _ errorLength: Int32, _ code: Int32) -> Void { - #if arch(wasm32) - let ret = makeAPINetworkingResultFailure(_: String.bridgeJSLiftParameter(errorBytes, errorLength), _: Int.bridgeJSLiftParameter(code)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundtripUtilitiesResult") -@_cdecl("bjs_roundtripUtilitiesResult") -public func _bjs_roundtripUtilitiesResult(_ result: Int32) -> Void { - #if arch(wasm32) - let ret = roundtripUtilitiesResult(_: Utilities.Result.bridgeJSLiftParameter(result)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundtripAPINetworkingResult") -@_cdecl("bjs_roundtripAPINetworkingResult") -public func _bjs_roundtripAPINetworkingResult(_ result: Int32) -> Void { - #if arch(wasm32) - let ret = roundtripAPINetworkingResult(_: API.NetworkingResult.bridgeJSLiftParameter(result)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripAllTypesResult") -@_cdecl("bjs_roundTripAllTypesResult") -public func _bjs_roundTripAllTypesResult(_ result: Int32) -> Void { - #if arch(wasm32) - let ret = roundTripAllTypesResult(_: AllTypesResult.bridgeJSLiftParameter(result)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripTypedPayloadResult") -@_cdecl("bjs_roundTripTypedPayloadResult") -public func _bjs_roundTripTypedPayloadResult(_ result: Int32) -> Void { - #if arch(wasm32) - let ret = roundTripTypedPayloadResult(_: TypedPayloadResult.bridgeJSLiftParameter(result)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_createPropertyHolder") -@_cdecl("bjs_createPropertyHolder") -public func _bjs_createPropertyHolder(_ intValue: Int32, _ floatValue: Float32, _ doubleValue: Float64, _ boolValue: Int32, _ stringValueBytes: Int32, _ stringValueLength: Int32, _ jsObject: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = createPropertyHolder(intValue: Int.bridgeJSLiftParameter(intValue), floatValue: Float.bridgeJSLiftParameter(floatValue), doubleValue: Double.bridgeJSLiftParameter(doubleValue), boolValue: Bool.bridgeJSLiftParameter(boolValue), stringValue: String.bridgeJSLiftParameter(stringValueBytes, stringValueLength), jsObject: JSObject.bridgeJSLiftParameter(jsObject)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_testPropertyHolder") -@_cdecl("bjs_testPropertyHolder") -public func _bjs_testPropertyHolder(_ holder: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = testPropertyHolder(holder: PropertyHolder.bridgeJSLiftParameter(holder)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_resetObserverCounts") -@_cdecl("bjs_resetObserverCounts") -public func _bjs_resetObserverCounts() -> Void { - #if arch(wasm32) - resetObserverCounts() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getObserverStats") -@_cdecl("bjs_getObserverStats") -public func _bjs_getObserverStats() -> Void { - #if arch(wasm32) - let ret = getObserverStats() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_formatName") -@_cdecl("bjs_formatName") -public func _bjs_formatName(_ nameBytes: Int32, _ nameLength: Int32, _ transform: Int32) -> Void { - #if arch(wasm32) - let ret = formatName(_: String.bridgeJSLiftParameter(nameBytes, nameLength), transform: _BJS_Closure_20BridgeJSRuntimeTestsSS_SS.bridgeJSLift(transform)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeFormatter") -@_cdecl("bjs_makeFormatter") -public func _bjs_makeFormatter(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { - #if arch(wasm32) - let ret = makeFormatter(prefix: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_makeAdder") -@_cdecl("bjs_makeAdder") -public func _bjs_makeAdder(_ base: Int32) -> Int32 { - #if arch(wasm32) - let ret = makeAdder(base: Int.bridgeJSLiftParameter(base)) - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getSharedSubject") -@_cdecl("bjs_getSharedSubject") -public func _bjs_getSharedSubject() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = getSharedSubject() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_resetSharedSubject") -@_cdecl("bjs_resetSharedSubject") -public func _bjs_resetSharedSubject() -> Void { - #if arch(wasm32) - resetSharedSubject() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getRetainLeakSubject") -@_cdecl("bjs_getRetainLeakSubject") -public func _bjs_getRetainLeakSubject() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = getRetainLeakSubject() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_resetRetainLeakSubject") -@_cdecl("bjs_resetRetainLeakSubject") -public func _bjs_resetRetainLeakSubject() -> Void { - #if arch(wasm32) - resetRetainLeakSubject() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getRetainLeakDeinits") -@_cdecl("bjs_getRetainLeakDeinits") -public func _bjs_getRetainLeakDeinits() -> Int32 { - #if arch(wasm32) - let ret = getRetainLeakDeinits() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_resetRetainLeakDeinits") -@_cdecl("bjs_resetRetainLeakDeinits") -public func _bjs_resetRetainLeakDeinits() -> Void { - #if arch(wasm32) - resetRetainLeakDeinits() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_setupArrayPool") -@_cdecl("bjs_setupArrayPool") -public func _bjs_setupArrayPool(_ count: Int32) -> Void { - #if arch(wasm32) - setupArrayPool(_: Int.bridgeJSLiftParameter(count)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getArrayPool") -@_cdecl("bjs_getArrayPool") -public func _bjs_getArrayPool() -> Void { - #if arch(wasm32) - let ret = getArrayPool() - ret.bridgeJSStackPush() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getArrayPoolElement") -@_cdecl("bjs_getArrayPoolElement") -public func _bjs_getArrayPoolElement(_ index: Int32) -> Void { - #if arch(wasm32) - let ret = getArrayPoolElement(_: Int.bridgeJSLiftParameter(index)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_getArrayPoolDeinits") -@_cdecl("bjs_getArrayPoolDeinits") -public func _bjs_getArrayPoolDeinits() -> Int32 { - #if arch(wasm32) - let ret = getArrayPoolDeinits() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_resetArrayPoolDeinits") -@_cdecl("bjs_resetArrayPoolDeinits") -public func _bjs_resetArrayPoolDeinits() -> Void { - #if arch(wasm32) - resetArrayPoolDeinits() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_clearArrayPool") -@_cdecl("bjs_clearArrayPool") -public func _bjs_clearArrayPool() -> Void { - #if arch(wasm32) - clearArrayPool() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripPointerFields") -@_cdecl("bjs_roundTripPointerFields") -public func _bjs_roundTripPointerFields() -> Void { - #if arch(wasm32) - let ret = roundTripPointerFields(_: PointerFields.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_testStructDefault") -@_cdecl("bjs_testStructDefault") -public func _bjs_testStructDefault() -> Void { - #if arch(wasm32) - let ret = testStructDefault(point: DataPoint.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_cartToJSObject") -@_cdecl("bjs_cartToJSObject") -public func _bjs_cartToJSObject() -> Int32 { - #if arch(wasm32) - let ret = cartToJSObject(_: CopyableCart.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_nestedCartToJSObject") -@_cdecl("bjs_nestedCartToJSObject") -public func _bjs_nestedCartToJSObject() -> Int32 { - #if arch(wasm32) - let ret = nestedCartToJSObject(_: CopyableNestedCart.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripDataPoint") -@_cdecl("bjs_roundTripDataPoint") -public func _bjs_roundTripDataPoint() -> Void { - #if arch(wasm32) - let ret = roundTripDataPoint(_: DataPoint.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripPublicPoint") -@_cdecl("bjs_roundTripPublicPoint") -public func _bjs_roundTripPublicPoint() -> Void { - #if arch(wasm32) - let ret = roundTripPublicPoint(_: PublicPoint.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripContact") -@_cdecl("bjs_roundTripContact") -public func _bjs_roundTripContact() -> Void { - #if arch(wasm32) - let ret = roundTripContact(_: Contact.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripConfig") -@_cdecl("bjs_roundTripConfig") -public func _bjs_roundTripConfig() -> Void { - #if arch(wasm32) - let ret = roundTripConfig(_: Config.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripSessionData") -@_cdecl("bjs_roundTripSessionData") -public func _bjs_roundTripSessionData() -> Void { - #if arch(wasm32) - let ret = roundTripSessionData(_: SessionData.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripValidationReport") -@_cdecl("bjs_roundTripValidationReport") -public func _bjs_roundTripValidationReport() -> Void { - #if arch(wasm32) - let ret = roundTripValidationReport(_: ValidationReport.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripAdvancedConfig") -@_cdecl("bjs_roundTripAdvancedConfig") -public func _bjs_roundTripAdvancedConfig() -> Void { - #if arch(wasm32) - let ret = roundTripAdvancedConfig(_: AdvancedConfig.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripMeasurementConfig") -@_cdecl("bjs_roundTripMeasurementConfig") -public func _bjs_roundTripMeasurementConfig() -> Void { - #if arch(wasm32) - let ret = roundTripMeasurementConfig(_: MeasurementConfig.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_updateValidationReport") -@_cdecl("bjs_updateValidationReport") -public func _bjs_updateValidationReport(_ newResultIsSome: Int32, _ newResultCaseId: Int32) -> Void { - #if arch(wasm32) - let _tmp_report = ValidationReport.bridgeJSLiftParameter() - let _tmp_newResult = Optional.bridgeJSLiftParameter(newResultIsSome, newResultCaseId) - let ret = updateValidationReport(_: _tmp_newResult, _: _tmp_report) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_testContainerWithStruct") -@_cdecl("bjs_testContainerWithStruct") -public func _bjs_testContainerWithStruct() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = testContainerWithStruct(_: DataPoint.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripJSObjectContainer") -@_cdecl("bjs_roundTripJSObjectContainer") -public func _bjs_roundTripJSObjectContainer() -> Void { - #if arch(wasm32) - let ret = roundTripJSObjectContainer(_: JSObjectContainer.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripFooContainer") -@_cdecl("bjs_roundTripFooContainer") -public func _bjs_roundTripFooContainer() -> Void { - #if arch(wasm32) - let ret = roundTripFooContainer(_: FooContainer.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_roundTripArrayMembers") -@_cdecl("bjs_roundTripArrayMembers") -public func _bjs_roundTripArrayMembers() -> Void { - #if arch(wasm32) - let ret = roundTripArrayMembers(_: ArrayMembers.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_arrayMembersSum") -@_cdecl("bjs_arrayMembersSum") -public func _bjs_arrayMembersSum() -> Int32 { - #if arch(wasm32) - let _tmp_values = [Int].bridgeJSStackPop() - let _tmp_value = ArrayMembers.bridgeJSLiftParameter() - let ret = arrayMembersSum(_: _tmp_value, _: _tmp_values) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_arrayMembersFirst") -@_cdecl("bjs_arrayMembersFirst") -public func _bjs_arrayMembersFirst() -> Void { - #if arch(wasm32) - let _tmp_values = [String].bridgeJSStackPop() - let _tmp_value = ArrayMembers.bridgeJSLiftParameter() - let ret = arrayMembersFirst(_: _tmp_value, _: _tmp_values) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ClosureSupportExports_static_makeIntToInt") -@_cdecl("bjs_ClosureSupportExports_static_makeIntToInt") -public func _bjs_ClosureSupportExports_static_makeIntToInt(_ base: Int32) -> Int32 { - #if arch(wasm32) - let ret = ClosureSupportExports.makeIntToInt(_: Int.bridgeJSLiftParameter(base)) - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ClosureSupportExports_static_makeDoubleToDouble") -@_cdecl("bjs_ClosureSupportExports_static_makeDoubleToDouble") -public func _bjs_ClosureSupportExports_static_makeDoubleToDouble(_ base: Float64) -> Int32 { - #if arch(wasm32) - let ret = ClosureSupportExports.makeDoubleToDouble(_: Double.bridgeJSLiftParameter(base)) - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ClosureSupportExports_static_makeStringToString") -@_cdecl("bjs_ClosureSupportExports_static_makeStringToString") -public func _bjs_ClosureSupportExports_static_makeStringToString(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { - #if arch(wasm32) - let ret = ClosureSupportExports.makeStringToString(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ClosureSupportExports_static_makeJSIntToInt") -@_cdecl("bjs_ClosureSupportExports_static_makeJSIntToInt") -public func _bjs_ClosureSupportExports_static_makeJSIntToInt(_ base: Int32) -> Int32 { - #if arch(wasm32) - let ret = ClosureSupportExports.makeJSIntToInt(_: Int.bridgeJSLiftParameter(base)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ClosureSupportExports_static_makeJSDoubleToDouble") -@_cdecl("bjs_ClosureSupportExports_static_makeJSDoubleToDouble") -public func _bjs_ClosureSupportExports_static_makeJSDoubleToDouble(_ base: Float64) -> Int32 { - #if arch(wasm32) - let ret = ClosureSupportExports.makeJSDoubleToDouble(_: Double.bridgeJSLiftParameter(base)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ClosureSupportExports_static_makeJSStringToString") -@_cdecl("bjs_ClosureSupportExports_static_makeJSStringToString") -public func _bjs_ClosureSupportExports_static_makeJSStringToString(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { - #if arch(wasm32) - let ret = ClosureSupportExports.makeJSStringToString(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ClosureSupportExports_deinit") -@_cdecl("bjs_ClosureSupportExports_deinit") -public func _bjs_ClosureSupportExports_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension ClosureSupportExports: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_ClosureSupportExports_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_ClosureSupportExports_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportExports_wrap") -fileprivate func _bjs_ClosureSupportExports_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_ClosureSupportExports_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_ClosureSupportExports_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_ClosureSupportExports_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_init") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_init") -public func _bjs_DefaultArgumentConstructorDefaults_init(_ nameBytes: Int32, _ nameLength: Int32, _ count: Int32, _ enabled: Int32, _ status: Int32, _ tagIsSome: Int32, _ tagBytes: Int32, _ tagLength: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = DefaultArgumentConstructorDefaults(name: String.bridgeJSLiftParameter(nameBytes, nameLength), count: Int.bridgeJSLiftParameter(count), enabled: Bool.bridgeJSLiftParameter(enabled), status: Status.bridgeJSLiftParameter(status), tag: Optional.bridgeJSLiftParameter(tagIsSome, tagBytes, tagLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_describe") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_describe") -public func _bjs_DefaultArgumentConstructorDefaults_describe(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).describe() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_name_get") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_name_get") -public func _bjs_DefaultArgumentConstructorDefaults_name_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).name - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_name_set") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_name_set") -public func _bjs_DefaultArgumentConstructorDefaults_name_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_count_get") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_count_get") -public func _bjs_DefaultArgumentConstructorDefaults_count_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).count - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_count_set") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_count_set") -public func _bjs_DefaultArgumentConstructorDefaults_count_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).count = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_enabled_get") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_enabled_get") -public func _bjs_DefaultArgumentConstructorDefaults_enabled_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).enabled - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_enabled_set") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_enabled_set") -public func _bjs_DefaultArgumentConstructorDefaults_enabled_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).enabled = Bool.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_status_get") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_status_get") -public func _bjs_DefaultArgumentConstructorDefaults_status_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).status - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_status_set") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_status_set") -public func _bjs_DefaultArgumentConstructorDefaults_status_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).status = Status.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_tag_get") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_tag_get") -public func _bjs_DefaultArgumentConstructorDefaults_tag_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).tag - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_tag_set") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_tag_set") -public func _bjs_DefaultArgumentConstructorDefaults_tag_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).tag = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_deinit") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_deinit") -public func _bjs_DefaultArgumentConstructorDefaults_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension DefaultArgumentConstructorDefaults: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_DefaultArgumentConstructorDefaults_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_DefaultArgumentConstructorDefaults_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DefaultArgumentConstructorDefaults_wrap") -fileprivate func _bjs_DefaultArgumentConstructorDefaults_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_DefaultArgumentConstructorDefaults_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_DefaultArgumentConstructorDefaults_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_DefaultArgumentConstructorDefaults_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_Greeter_init") -@_cdecl("bjs_Greeter_init") -public func _bjs_Greeter_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = Greeter(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_greet") -@_cdecl("bjs_Greeter_greet") -public func _bjs_Greeter_greet(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = Greeter.bridgeJSLiftParameter(_self).greet() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_changeName") -@_cdecl("bjs_Greeter_changeName") -public func _bjs_Greeter_changeName(_ _self: UnsafeMutableRawPointer, _ nameBytes: Int32, _ nameLength: Int32) -> Void { - #if arch(wasm32) - Greeter.bridgeJSLiftParameter(_self).changeName(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_greetWith") -@_cdecl("bjs_Greeter_greetWith") -public func _bjs_Greeter_greetWith(_ _self: UnsafeMutableRawPointer, _ greeter: UnsafeMutableRawPointer, _ customGreeting: Int32) -> Void { - #if arch(wasm32) - let ret = Greeter.bridgeJSLiftParameter(_self).greetWith(greeter: Greeter.bridgeJSLiftParameter(greeter), customGreeting: _BJS_Closure_20BridgeJSRuntimeTests7GreeterC_SS.bridgeJSLift(customGreeting)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_makeFormatter") -@_cdecl("bjs_Greeter_makeFormatter") -public func _bjs_Greeter_makeFormatter(_ _self: UnsafeMutableRawPointer, _ suffixBytes: Int32, _ suffixLength: Int32) -> Int32 { - #if arch(wasm32) - let ret = Greeter.bridgeJSLiftParameter(_self).makeFormatter(suffix: String.bridgeJSLiftParameter(suffixBytes, suffixLength)) - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_static_makeCreator") -@_cdecl("bjs_Greeter_static_makeCreator") -public func _bjs_Greeter_static_makeCreator(_ defaultNameBytes: Int32, _ defaultNameLength: Int32) -> Int32 { - #if arch(wasm32) - let ret = Greeter.makeCreator(defaultName: String.bridgeJSLiftParameter(defaultNameBytes, defaultNameLength)) - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_makeCustomGreeter") -@_cdecl("bjs_Greeter_makeCustomGreeter") -public func _bjs_Greeter_makeCustomGreeter(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = Greeter.bridgeJSLiftParameter(_self).makeCustomGreeter() - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_greetEnthusiastically") -@_cdecl("bjs_Greeter_greetEnthusiastically") -public func _bjs_Greeter_greetEnthusiastically(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = Greeter.bridgeJSLiftParameter(_self).greetEnthusiastically() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_static_greetAnonymously") -@_cdecl("bjs_Greeter_static_greetAnonymously") -public func _bjs_Greeter_static_greetAnonymously() -> Void { - #if arch(wasm32) - let ret = Greeter.greetAnonymously() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_name_get") -@_cdecl("bjs_Greeter_name_get") -public func _bjs_Greeter_name_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = Greeter.bridgeJSLiftParameter(_self).name - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_name_set") -@_cdecl("bjs_Greeter_name_set") -public func _bjs_Greeter_name_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - Greeter.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_prefix_get") -@_cdecl("bjs_Greeter_prefix_get") -public func _bjs_Greeter_prefix_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = Greeter.bridgeJSLiftParameter(_self).prefix - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_nameCount_get") -@_cdecl("bjs_Greeter_nameCount_get") -public func _bjs_Greeter_nameCount_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = Greeter.bridgeJSLiftParameter(_self).nameCount - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_static_defaultGreeting_get") -@_cdecl("bjs_Greeter_static_defaultGreeting_get") -public func _bjs_Greeter_static_defaultGreeting_get() -> Void { - #if arch(wasm32) - let ret = Greeter.defaultGreeting - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Greeter_deinit") -@_cdecl("bjs_Greeter_deinit") -public func _bjs_Greeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension Greeter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - public var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_Greeter_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - public consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_Greeter_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Greeter_wrap") -fileprivate func _bjs_Greeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_Greeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_Greeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_Greeter_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_Calculator_square") -@_cdecl("bjs_Calculator_square") -public func _bjs_Calculator_square(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Int32 { - #if arch(wasm32) - let ret = Calculator.bridgeJSLiftParameter(_self).square(value: Int.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Calculator_add") -@_cdecl("bjs_Calculator_add") -public func _bjs_Calculator_add(_ _self: UnsafeMutableRawPointer, _ a: Int32, _ b: Int32) -> Int32 { - #if arch(wasm32) - let ret = Calculator.bridgeJSLiftParameter(_self).add(a: Int.bridgeJSLiftParameter(a), b: Int.bridgeJSLiftParameter(b)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Calculator_deinit") -@_cdecl("bjs_Calculator_deinit") -public func _bjs_Calculator_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension Calculator: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_Calculator_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_Calculator_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Calculator_wrap") -fileprivate func _bjs_Calculator_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_Calculator_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_Calculator_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_Calculator_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_InternalGreeter_deinit") -@_cdecl("bjs_InternalGreeter_deinit") -public func _bjs_InternalGreeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension InternalGreeter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - internal var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_InternalGreeter_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - internal consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_InternalGreeter_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_InternalGreeter_wrap") -fileprivate func _bjs_InternalGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_InternalGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_InternalGreeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_InternalGreeter_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_PublicGreeter_deinit") -@_cdecl("bjs_PublicGreeter_deinit") -public func _bjs_PublicGreeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension PublicGreeter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - public var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_PublicGreeter_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - public consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_PublicGreeter_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PublicGreeter_wrap") -fileprivate func _bjs_PublicGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_PublicGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_PublicGreeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_PublicGreeter_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_PackageGreeter_deinit") -@_cdecl("bjs_PackageGreeter_deinit") -public func _bjs_PackageGreeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension PackageGreeter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - package var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_PackageGreeter_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - package consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_PackageGreeter_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PackageGreeter_wrap") -fileprivate func _bjs_PackageGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_PackageGreeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_PackageGreeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_PackageGreeter_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_Utils_Converter_init") -@_cdecl("bjs_Utils_Converter_init") -public func _bjs_Utils_Converter_init() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = Utils.Converter() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Utils_Converter_toString") -@_cdecl("bjs_Utils_Converter_toString") -public func _bjs_Utils_Converter_toString(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - let ret = Utils.Converter.bridgeJSLiftParameter(_self).toString(value: Int.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Utils_Converter_precision_get") -@_cdecl("bjs_Utils_Converter_precision_get") -public func _bjs_Utils_Converter_precision_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = Utils.Converter.bridgeJSLiftParameter(_self).precision - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Utils_Converter_precision_set") -@_cdecl("bjs_Utils_Converter_precision_set") -public func _bjs_Utils_Converter_precision_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - Utils.Converter.bridgeJSLiftParameter(_self).precision = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Utils_Converter_deinit") -@_cdecl("bjs_Utils_Converter_deinit") -public func _bjs_Utils_Converter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension Utils.Converter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_Utils_Converter_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_Utils_Converter_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Utils_Converter_wrap") -fileprivate func _bjs_Utils_Converter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_Utils_Converter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_Utils_Converter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_Utils_Converter_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_Networking_API_HTTPServer_init") -@_cdecl("bjs_Networking_API_HTTPServer_init") -public func _bjs_Networking_API_HTTPServer_init() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = Networking.API.HTTPServer() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Networking_API_HTTPServer_call") -@_cdecl("bjs_Networking_API_HTTPServer_call") -public func _bjs_Networking_API_HTTPServer_call(_ _self: UnsafeMutableRawPointer, _ method: Int32) -> Void { - #if arch(wasm32) - Networking.API.HTTPServer.bridgeJSLiftParameter(_self).call(_: Networking.API.Method.bridgeJSLiftParameter(method)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Networking_API_HTTPServer_deinit") -@_cdecl("bjs_Networking_API_HTTPServer_deinit") -public func _bjs_Networking_API_HTTPServer_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension Networking.API.HTTPServer: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_Networking_API_HTTPServer_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_Networking_API_HTTPServer_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Networking_API_HTTPServer_wrap") -fileprivate func _bjs_Networking_API_HTTPServer_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_Networking_API_HTTPServer_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_Networking_API_HTTPServer_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_Networking_API_HTTPServer_wrap_extern(pointer) -} - -@_expose(wasm, "bjs___Swift_Foundation_UUID_init") -@_cdecl("bjs___Swift_Foundation_UUID_init") -public func _bjs___Swift_Foundation_UUID_init(_ valueBytes: Int32, _ valueLength: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = UUID(value: String.bridgeJSLiftParameter(valueBytes, valueLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs___Swift_Foundation_UUID_uuidString") -@_cdecl("bjs___Swift_Foundation_UUID_uuidString") -public func _bjs___Swift_Foundation_UUID_uuidString(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = UUID.bridgeJSLiftParameter(_self).uuidString() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs___Swift_Foundation_UUID_static_fromValue") -@_cdecl("bjs___Swift_Foundation_UUID_static_fromValue") -public func _bjs___Swift_Foundation_UUID_static_fromValue(_ valueBytes: Int32, _ valueLength: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = UUID.fromValue(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs___Swift_Foundation_UUID_static_placeholder_get") -@_cdecl("bjs___Swift_Foundation_UUID_static_placeholder_get") -public func _bjs___Swift_Foundation_UUID_static_placeholder_get() -> Void { - #if arch(wasm32) - let ret = UUID.placeholder - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs___Swift_Foundation_UUID_deinit") -@_cdecl("bjs___Swift_Foundation_UUID_deinit") -public func _bjs___Swift_Foundation_UUID_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension UUID: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs___Swift_Foundation_UUID_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs___Swift_Foundation_UUID_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs___Swift_Foundation_UUID_wrap") -fileprivate func _bjs___Swift_Foundation_UUID_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs___Swift_Foundation_UUID_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs___Swift_Foundation_UUID_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs___Swift_Foundation_UUID_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_Networking_APIV2_Internal_TestServer_init") -@_cdecl("bjs_Networking_APIV2_Internal_TestServer_init") -public func _bjs_Networking_APIV2_Internal_TestServer_init() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = Internal.TestServer() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Networking_APIV2_Internal_TestServer_call") -@_cdecl("bjs_Networking_APIV2_Internal_TestServer_call") -public func _bjs_Networking_APIV2_Internal_TestServer_call(_ _self: UnsafeMutableRawPointer, _ method: Int32) -> Void { - #if arch(wasm32) - Internal.TestServer.bridgeJSLiftParameter(_self).call(_: Internal.SupportedMethod.bridgeJSLiftParameter(method)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Networking_APIV2_Internal_TestServer_deinit") -@_cdecl("bjs_Networking_APIV2_Internal_TestServer_deinit") -public func _bjs_Networking_APIV2_Internal_TestServer_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension Internal.TestServer: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_Networking_APIV2_Internal_TestServer_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_Networking_APIV2_Internal_TestServer_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Networking_APIV2_Internal_TestServer_wrap") -fileprivate func _bjs_Networking_APIV2_Internal_TestServer_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_Networking_APIV2_Internal_TestServer_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_Networking_APIV2_Internal_TestServer_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_Networking_APIV2_Internal_TestServer_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_SimplePropertyHolder_init") -@_cdecl("bjs_SimplePropertyHolder_init") -public func _bjs_SimplePropertyHolder_init(_ value: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = SimplePropertyHolder(value: Int.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SimplePropertyHolder_value_get") -@_cdecl("bjs_SimplePropertyHolder_value_get") -public func _bjs_SimplePropertyHolder_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = SimplePropertyHolder.bridgeJSLiftParameter(_self).value - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SimplePropertyHolder_value_set") -@_cdecl("bjs_SimplePropertyHolder_value_set") -public func _bjs_SimplePropertyHolder_value_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - SimplePropertyHolder.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SimplePropertyHolder_deinit") -@_cdecl("bjs_SimplePropertyHolder_deinit") -public func _bjs_SimplePropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension SimplePropertyHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_SimplePropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_SimplePropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SimplePropertyHolder_wrap") -fileprivate func _bjs_SimplePropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_SimplePropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_SimplePropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_SimplePropertyHolder_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_PropertyHolder_init") -@_cdecl("bjs_PropertyHolder_init") -public func _bjs_PropertyHolder_init(_ intValue: Int32, _ floatValue: Float32, _ doubleValue: Float64, _ boolValue: Int32, _ stringValueBytes: Int32, _ stringValueLength: Int32, _ jsObject: Int32, _ sibling: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = PropertyHolder(intValue: Int.bridgeJSLiftParameter(intValue), floatValue: Float.bridgeJSLiftParameter(floatValue), doubleValue: Double.bridgeJSLiftParameter(doubleValue), boolValue: Bool.bridgeJSLiftParameter(boolValue), stringValue: String.bridgeJSLiftParameter(stringValueBytes, stringValueLength), jsObject: JSObject.bridgeJSLiftParameter(jsObject), sibling: SimplePropertyHolder.bridgeJSLiftParameter(sibling)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_getAllValues") -@_cdecl("bjs_PropertyHolder_getAllValues") -public func _bjs_PropertyHolder_getAllValues(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).getAllValues() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_intValue_get") -@_cdecl("bjs_PropertyHolder_intValue_get") -public func _bjs_PropertyHolder_intValue_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).intValue - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_intValue_set") -@_cdecl("bjs_PropertyHolder_intValue_set") -public func _bjs_PropertyHolder_intValue_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - PropertyHolder.bridgeJSLiftParameter(_self).intValue = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_floatValue_get") -@_cdecl("bjs_PropertyHolder_floatValue_get") -public func _bjs_PropertyHolder_floatValue_get(_ _self: UnsafeMutableRawPointer) -> Float32 { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).floatValue - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_floatValue_set") -@_cdecl("bjs_PropertyHolder_floatValue_set") -public func _bjs_PropertyHolder_floatValue_set(_ _self: UnsafeMutableRawPointer, _ value: Float32) -> Void { - #if arch(wasm32) - PropertyHolder.bridgeJSLiftParameter(_self).floatValue = Float.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_doubleValue_get") -@_cdecl("bjs_PropertyHolder_doubleValue_get") -public func _bjs_PropertyHolder_doubleValue_get(_ _self: UnsafeMutableRawPointer) -> Float64 { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).doubleValue - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_doubleValue_set") -@_cdecl("bjs_PropertyHolder_doubleValue_set") -public func _bjs_PropertyHolder_doubleValue_set(_ _self: UnsafeMutableRawPointer, _ value: Float64) -> Void { - #if arch(wasm32) - PropertyHolder.bridgeJSLiftParameter(_self).doubleValue = Double.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_boolValue_get") -@_cdecl("bjs_PropertyHolder_boolValue_get") -public func _bjs_PropertyHolder_boolValue_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).boolValue - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_boolValue_set") -@_cdecl("bjs_PropertyHolder_boolValue_set") -public func _bjs_PropertyHolder_boolValue_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - PropertyHolder.bridgeJSLiftParameter(_self).boolValue = Bool.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_stringValue_get") -@_cdecl("bjs_PropertyHolder_stringValue_get") -public func _bjs_PropertyHolder_stringValue_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).stringValue - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_stringValue_set") -@_cdecl("bjs_PropertyHolder_stringValue_set") -public func _bjs_PropertyHolder_stringValue_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - PropertyHolder.bridgeJSLiftParameter(_self).stringValue = String.bridgeJSLiftParameter(valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_readonlyInt_get") -@_cdecl("bjs_PropertyHolder_readonlyInt_get") -public func _bjs_PropertyHolder_readonlyInt_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyInt - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_readonlyFloat_get") -@_cdecl("bjs_PropertyHolder_readonlyFloat_get") -public func _bjs_PropertyHolder_readonlyFloat_get(_ _self: UnsafeMutableRawPointer) -> Float32 { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyFloat - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_readonlyDouble_get") -@_cdecl("bjs_PropertyHolder_readonlyDouble_get") -public func _bjs_PropertyHolder_readonlyDouble_get(_ _self: UnsafeMutableRawPointer) -> Float64 { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyDouble - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_readonlyBool_get") -@_cdecl("bjs_PropertyHolder_readonlyBool_get") -public func _bjs_PropertyHolder_readonlyBool_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyBool - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_readonlyString_get") -@_cdecl("bjs_PropertyHolder_readonlyString_get") -public func _bjs_PropertyHolder_readonlyString_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyString - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_jsObject_get") -@_cdecl("bjs_PropertyHolder_jsObject_get") -public func _bjs_PropertyHolder_jsObject_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).jsObject - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_jsObject_set") -@_cdecl("bjs_PropertyHolder_jsObject_set") -public func _bjs_PropertyHolder_jsObject_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - PropertyHolder.bridgeJSLiftParameter(_self).jsObject = JSObject.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_sibling_get") -@_cdecl("bjs_PropertyHolder_sibling_get") -public func _bjs_PropertyHolder_sibling_get(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).sibling - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_sibling_set") -@_cdecl("bjs_PropertyHolder_sibling_set") -public func _bjs_PropertyHolder_sibling_set(_ _self: UnsafeMutableRawPointer, _ value: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - PropertyHolder.bridgeJSLiftParameter(_self).sibling = SimplePropertyHolder.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_lazyValue_get") -@_cdecl("bjs_PropertyHolder_lazyValue_get") -public func _bjs_PropertyHolder_lazyValue_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).lazyValue - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_lazyValue_set") -@_cdecl("bjs_PropertyHolder_lazyValue_set") -public func _bjs_PropertyHolder_lazyValue_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - PropertyHolder.bridgeJSLiftParameter(_self).lazyValue = String.bridgeJSLiftParameter(valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_computedReadonly_get") -@_cdecl("bjs_PropertyHolder_computedReadonly_get") -public func _bjs_PropertyHolder_computedReadonly_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).computedReadonly - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_computedReadWrite_get") -@_cdecl("bjs_PropertyHolder_computedReadWrite_get") -public func _bjs_PropertyHolder_computedReadWrite_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).computedReadWrite - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_computedReadWrite_set") -@_cdecl("bjs_PropertyHolder_computedReadWrite_set") -public func _bjs_PropertyHolder_computedReadWrite_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - PropertyHolder.bridgeJSLiftParameter(_self).computedReadWrite = String.bridgeJSLiftParameter(valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_observedProperty_get") -@_cdecl("bjs_PropertyHolder_observedProperty_get") -public func _bjs_PropertyHolder_observedProperty_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).observedProperty - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_observedProperty_set") -@_cdecl("bjs_PropertyHolder_observedProperty_set") -public func _bjs_PropertyHolder_observedProperty_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - PropertyHolder.bridgeJSLiftParameter(_self).observedProperty = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PropertyHolder_deinit") -@_cdecl("bjs_PropertyHolder_deinit") -public func _bjs_PropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension PropertyHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_PropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_PropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PropertyHolder_wrap") -fileprivate func _bjs_PropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_PropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_PropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_PropertyHolder_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_MathUtils_static_add") -@_cdecl("bjs_MathUtils_static_add") -public func _bjs_MathUtils_static_add(_ a: Int32, _ b: Int32) -> Int32 { - #if arch(wasm32) - let ret = MathUtils.add(a: Int.bridgeJSLiftParameter(a), b: Int.bridgeJSLiftParameter(b)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_MathUtils_static_substract") -@_cdecl("bjs_MathUtils_static_substract") -public func _bjs_MathUtils_static_substract(_ a: Int32, _ b: Int32) -> Int32 { - #if arch(wasm32) - let ret = MathUtils.substract(a: Int.bridgeJSLiftParameter(a), b: Int.bridgeJSLiftParameter(b)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_MathUtils_deinit") -@_cdecl("bjs_MathUtils_deinit") -public func _bjs_MathUtils_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension MathUtils: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_MathUtils_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_MathUtils_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_MathUtils_wrap") -fileprivate func _bjs_MathUtils_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_MathUtils_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_MathUtils_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_MathUtils_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_StaticPropertyHolder_init") -@_cdecl("bjs_StaticPropertyHolder_init") -public func _bjs_StaticPropertyHolder_init() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = StaticPropertyHolder() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_staticConstant_get") -@_cdecl("bjs_StaticPropertyHolder_static_staticConstant_get") -public func _bjs_StaticPropertyHolder_static_staticConstant_get() -> Void { - #if arch(wasm32) - let ret = StaticPropertyHolder.staticConstant - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_staticVariable_get") -@_cdecl("bjs_StaticPropertyHolder_static_staticVariable_get") -public func _bjs_StaticPropertyHolder_static_staticVariable_get() -> Int32 { - #if arch(wasm32) - let ret = StaticPropertyHolder.staticVariable - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_staticVariable_set") -@_cdecl("bjs_StaticPropertyHolder_static_staticVariable_set") -public func _bjs_StaticPropertyHolder_static_staticVariable_set(_ value: Int32) -> Void { - #if arch(wasm32) - StaticPropertyHolder.staticVariable = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_staticString_get") -@_cdecl("bjs_StaticPropertyHolder_static_staticString_get") -public func _bjs_StaticPropertyHolder_static_staticString_get() -> Void { - #if arch(wasm32) - let ret = StaticPropertyHolder.staticString - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_staticString_set") -@_cdecl("bjs_StaticPropertyHolder_static_staticString_set") -public func _bjs_StaticPropertyHolder_static_staticString_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - StaticPropertyHolder.staticString = String.bridgeJSLiftParameter(valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_staticBool_get") -@_cdecl("bjs_StaticPropertyHolder_static_staticBool_get") -public func _bjs_StaticPropertyHolder_static_staticBool_get() -> Int32 { - #if arch(wasm32) - let ret = StaticPropertyHolder.staticBool - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_staticBool_set") -@_cdecl("bjs_StaticPropertyHolder_static_staticBool_set") -public func _bjs_StaticPropertyHolder_static_staticBool_set(_ value: Int32) -> Void { - #if arch(wasm32) - StaticPropertyHolder.staticBool = Bool.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_staticFloat_get") -@_cdecl("bjs_StaticPropertyHolder_static_staticFloat_get") -public func _bjs_StaticPropertyHolder_static_staticFloat_get() -> Float32 { - #if arch(wasm32) - let ret = StaticPropertyHolder.staticFloat - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_staticFloat_set") -@_cdecl("bjs_StaticPropertyHolder_static_staticFloat_set") -public func _bjs_StaticPropertyHolder_static_staticFloat_set(_ value: Float32) -> Void { - #if arch(wasm32) - StaticPropertyHolder.staticFloat = Float.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_staticDouble_get") -@_cdecl("bjs_StaticPropertyHolder_static_staticDouble_get") -public func _bjs_StaticPropertyHolder_static_staticDouble_get() -> Float64 { - #if arch(wasm32) - let ret = StaticPropertyHolder.staticDouble - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_staticDouble_set") -@_cdecl("bjs_StaticPropertyHolder_static_staticDouble_set") -public func _bjs_StaticPropertyHolder_static_staticDouble_set(_ value: Float64) -> Void { - #if arch(wasm32) - StaticPropertyHolder.staticDouble = Double.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_computedProperty_get") -@_cdecl("bjs_StaticPropertyHolder_static_computedProperty_get") -public func _bjs_StaticPropertyHolder_static_computedProperty_get() -> Void { - #if arch(wasm32) - let ret = StaticPropertyHolder.computedProperty - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_computedProperty_set") -@_cdecl("bjs_StaticPropertyHolder_static_computedProperty_set") -public func _bjs_StaticPropertyHolder_static_computedProperty_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - StaticPropertyHolder.computedProperty = String.bridgeJSLiftParameter(valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_readOnlyComputed_get") -@_cdecl("bjs_StaticPropertyHolder_static_readOnlyComputed_get") -public func _bjs_StaticPropertyHolder_static_readOnlyComputed_get() -> Int32 { - #if arch(wasm32) - let ret = StaticPropertyHolder.readOnlyComputed - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_optionalString_get") -@_cdecl("bjs_StaticPropertyHolder_static_optionalString_get") -public func _bjs_StaticPropertyHolder_static_optionalString_get() -> Void { - #if arch(wasm32) - let ret = StaticPropertyHolder.optionalString - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_optionalString_set") -@_cdecl("bjs_StaticPropertyHolder_static_optionalString_set") -public func _bjs_StaticPropertyHolder_static_optionalString_set(_ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - StaticPropertyHolder.optionalString = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_optionalInt_get") -@_cdecl("bjs_StaticPropertyHolder_static_optionalInt_get") -public func _bjs_StaticPropertyHolder_static_optionalInt_get() -> Void { - #if arch(wasm32) - let ret = StaticPropertyHolder.optionalInt - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_optionalInt_set") -@_cdecl("bjs_StaticPropertyHolder_static_optionalInt_set") -public func _bjs_StaticPropertyHolder_static_optionalInt_set(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { - #if arch(wasm32) - StaticPropertyHolder.optionalInt = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_jsObjectProperty_get") -@_cdecl("bjs_StaticPropertyHolder_static_jsObjectProperty_get") -public func _bjs_StaticPropertyHolder_static_jsObjectProperty_get() -> Int32 { - #if arch(wasm32) - let ret = StaticPropertyHolder.jsObjectProperty - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_static_jsObjectProperty_set") -@_cdecl("bjs_StaticPropertyHolder_static_jsObjectProperty_set") -public func _bjs_StaticPropertyHolder_static_jsObjectProperty_set(_ value: Int32) -> Void { - #if arch(wasm32) - StaticPropertyHolder.jsObjectProperty = JSObject.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_StaticPropertyHolder_deinit") -@_cdecl("bjs_StaticPropertyHolder_deinit") -public func _bjs_StaticPropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension StaticPropertyHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_StaticPropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_StaticPropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticPropertyHolder_wrap") -fileprivate func _bjs_StaticPropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_StaticPropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_StaticPropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_StaticPropertyHolder_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_DataProcessorManager_init") -@_cdecl("bjs_DataProcessorManager_init") -public func _bjs_DataProcessorManager_init(_ processor: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = DataProcessorManager(processor: AnyDataProcessor.bridgeJSLiftParameter(processor)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_incrementByAmount") -@_cdecl("bjs_DataProcessorManager_incrementByAmount") -public func _bjs_DataProcessorManager_incrementByAmount(_ _self: UnsafeMutableRawPointer, _ amount: Int32) -> Void { - #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).incrementByAmount(_: Int.bridgeJSLiftParameter(amount)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_setProcessorLabel") -@_cdecl("bjs_DataProcessorManager_setProcessorLabel") -public func _bjs_DataProcessorManager_setProcessorLabel(_ _self: UnsafeMutableRawPointer, _ prefixBytes: Int32, _ prefixLength: Int32, _ suffixBytes: Int32, _ suffixLength: Int32) -> Void { - #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorLabel(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength), _: String.bridgeJSLiftParameter(suffixBytes, suffixLength)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_isProcessorEven") -@_cdecl("bjs_DataProcessorManager_isProcessorEven") -public func _bjs_DataProcessorManager_isProcessorEven(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).isProcessorEven() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_getProcessorLabel") -@_cdecl("bjs_DataProcessorManager_getProcessorLabel") -public func _bjs_DataProcessorManager_getProcessorLabel(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorLabel() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_getCurrentValue") -@_cdecl("bjs_DataProcessorManager_getCurrentValue") -public func _bjs_DataProcessorManager_getCurrentValue(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getCurrentValue() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_incrementBoth") -@_cdecl("bjs_DataProcessorManager_incrementBoth") -public func _bjs_DataProcessorManager_incrementBoth(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).incrementBoth() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_getBackupValue") -@_cdecl("bjs_DataProcessorManager_getBackupValue") -public func _bjs_DataProcessorManager_getBackupValue(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getBackupValue() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_hasBackup") -@_cdecl("bjs_DataProcessorManager_hasBackup") -public func _bjs_DataProcessorManager_hasBackup(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).hasBackup() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_getProcessorOptionalTag") -@_cdecl("bjs_DataProcessorManager_getProcessorOptionalTag") -public func _bjs_DataProcessorManager_getProcessorOptionalTag(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorOptionalTag() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_setProcessorOptionalTag") -@_cdecl("bjs_DataProcessorManager_setProcessorOptionalTag") -public func _bjs_DataProcessorManager_setProcessorOptionalTag(_ _self: UnsafeMutableRawPointer, _ tagIsSome: Int32, _ tagBytes: Int32, _ tagLength: Int32) -> Void { - #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorOptionalTag(_: Optional.bridgeJSLiftParameter(tagIsSome, tagBytes, tagLength)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_getProcessorOptionalCount") -@_cdecl("bjs_DataProcessorManager_getProcessorOptionalCount") -public func _bjs_DataProcessorManager_getProcessorOptionalCount(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorOptionalCount() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_setProcessorOptionalCount") -@_cdecl("bjs_DataProcessorManager_setProcessorOptionalCount") -public func _bjs_DataProcessorManager_setProcessorOptionalCount(_ _self: UnsafeMutableRawPointer, _ countIsSome: Int32, _ countValue: Int32) -> Void { - #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorOptionalCount(_: Optional.bridgeJSLiftParameter(countIsSome, countValue)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_getProcessorDirection") -@_cdecl("bjs_DataProcessorManager_getProcessorDirection") -public func _bjs_DataProcessorManager_getProcessorDirection(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorDirection() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_setProcessorDirection") -@_cdecl("bjs_DataProcessorManager_setProcessorDirection") -public func _bjs_DataProcessorManager_setProcessorDirection(_ _self: UnsafeMutableRawPointer, _ directionIsSome: Int32, _ directionValue: Int32) -> Void { - #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorDirection(_: Optional.bridgeJSLiftParameter(directionIsSome, directionValue)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_getProcessorTheme") -@_cdecl("bjs_DataProcessorManager_getProcessorTheme") -public func _bjs_DataProcessorManager_getProcessorTheme(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorTheme() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_setProcessorTheme") -@_cdecl("bjs_DataProcessorManager_setProcessorTheme") -public func _bjs_DataProcessorManager_setProcessorTheme(_ _self: UnsafeMutableRawPointer, _ themeIsSome: Int32, _ themeBytes: Int32, _ themeLength: Int32) -> Void { - #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorTheme(_: Optional.bridgeJSLiftParameter(themeIsSome, themeBytes, themeLength)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_getProcessorHttpStatus") -@_cdecl("bjs_DataProcessorManager_getProcessorHttpStatus") -public func _bjs_DataProcessorManager_getProcessorHttpStatus(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorHttpStatus() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_setProcessorHttpStatus") -@_cdecl("bjs_DataProcessorManager_setProcessorHttpStatus") -public func _bjs_DataProcessorManager_setProcessorHttpStatus(_ _self: UnsafeMutableRawPointer, _ statusIsSome: Int32, _ statusValue: Int32) -> Void { - #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorHttpStatus(_: Optional.bridgeJSLiftParameter(statusIsSome, statusValue)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_getProcessorAPIResult") -@_cdecl("bjs_DataProcessorManager_getProcessorAPIResult") -public func _bjs_DataProcessorManager_getProcessorAPIResult(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorAPIResult() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_setProcessorAPIResult") -@_cdecl("bjs_DataProcessorManager_setProcessorAPIResult") -public func _bjs_DataProcessorManager_setProcessorAPIResult(_ _self: UnsafeMutableRawPointer, _ apiResultIsSome: Int32, _ apiResultCaseId: Int32) -> Void { - #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorAPIResult(_: Optional.bridgeJSLiftParameter(apiResultIsSome, apiResultCaseId)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_processor_get") -@_cdecl("bjs_DataProcessorManager_processor_get") -public func _bjs_DataProcessorManager_processor_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).processor as! _BridgedSwiftProtocolExportable - return ret.bridgeJSLowerAsProtocolReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_processor_set") -@_cdecl("bjs_DataProcessorManager_processor_set") -public func _bjs_DataProcessorManager_processor_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).processor = AnyDataProcessor.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_backupProcessor_get") -@_cdecl("bjs_DataProcessorManager_backupProcessor_get") -public func _bjs_DataProcessorManager_backupProcessor_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).backupProcessor - if let ret { - _swift_js_return_optional_object(1, (ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) - } else { - _swift_js_return_optional_object(0, 0) - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_backupProcessor_set") -@_cdecl("bjs_DataProcessorManager_backupProcessor_set") -public func _bjs_DataProcessorManager_backupProcessor_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { - #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).backupProcessor = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_DataProcessorManager_deinit") -@_cdecl("bjs_DataProcessorManager_deinit") -public func _bjs_DataProcessorManager_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension DataProcessorManager: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_DataProcessorManager_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_DataProcessorManager_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessorManager_wrap") -fileprivate func _bjs_DataProcessorManager_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_DataProcessorManager_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_DataProcessorManager_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_DataProcessorManager_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_SwiftDataProcessor_init") -@_cdecl("bjs_SwiftDataProcessor_init") -public func _bjs_SwiftDataProcessor_init() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = SwiftDataProcessor() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_increment") -@_cdecl("bjs_SwiftDataProcessor_increment") -public func _bjs_SwiftDataProcessor_increment(_ _self: UnsafeMutableRawPointer, _ amount: Int32) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).increment(by: Int.bridgeJSLiftParameter(amount)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_getValue") -@_cdecl("bjs_SwiftDataProcessor_getValue") -public func _bjs_SwiftDataProcessor_getValue(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).getValue() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_setLabelElements") -@_cdecl("bjs_SwiftDataProcessor_setLabelElements") -public func _bjs_SwiftDataProcessor_setLabelElements(_ _self: UnsafeMutableRawPointer, _ labelPrefixBytes: Int32, _ labelPrefixLength: Int32, _ labelSuffixBytes: Int32, _ labelSuffixLength: Int32) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).setLabelElements(_: String.bridgeJSLiftParameter(labelPrefixBytes, labelPrefixLength), _: String.bridgeJSLiftParameter(labelSuffixBytes, labelSuffixLength)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_getLabel") -@_cdecl("bjs_SwiftDataProcessor_getLabel") -public func _bjs_SwiftDataProcessor_getLabel(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).getLabel() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_isEven") -@_cdecl("bjs_SwiftDataProcessor_isEven") -public func _bjs_SwiftDataProcessor_isEven(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).isEven() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_processGreeter") -@_cdecl("bjs_SwiftDataProcessor_processGreeter") -public func _bjs_SwiftDataProcessor_processGreeter(_ _self: UnsafeMutableRawPointer, _ greeter: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).processGreeter(_: Greeter.bridgeJSLiftParameter(greeter)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_createGreeter") -@_cdecl("bjs_SwiftDataProcessor_createGreeter") -public func _bjs_SwiftDataProcessor_createGreeter(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).createGreeter() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_processOptionalGreeter") -@_cdecl("bjs_SwiftDataProcessor_processOptionalGreeter") -public func _bjs_SwiftDataProcessor_processOptionalGreeter(_ _self: UnsafeMutableRawPointer, _ greeterIsSome: Int32, _ greeterValue: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).processOptionalGreeter(_: Optional.bridgeJSLiftParameter(greeterIsSome, greeterValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_createOptionalGreeter") -@_cdecl("bjs_SwiftDataProcessor_createOptionalGreeter") -public func _bjs_SwiftDataProcessor_createOptionalGreeter(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).createOptionalGreeter() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_handleAPIResult") -@_cdecl("bjs_SwiftDataProcessor_handleAPIResult") -public func _bjs_SwiftDataProcessor_handleAPIResult(_ _self: UnsafeMutableRawPointer, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).handleAPIResult(_: Optional.bridgeJSLiftParameter(resultIsSome, resultCaseId)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_getAPIResult") -@_cdecl("bjs_SwiftDataProcessor_getAPIResult") -public func _bjs_SwiftDataProcessor_getAPIResult(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).getAPIResult() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_count_get") -@_cdecl("bjs_SwiftDataProcessor_count_get") -public func _bjs_SwiftDataProcessor_count_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).count - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_count_set") -@_cdecl("bjs_SwiftDataProcessor_count_set") -public func _bjs_SwiftDataProcessor_count_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).count = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_name_get") -@_cdecl("bjs_SwiftDataProcessor_name_get") -public func _bjs_SwiftDataProcessor_name_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).name - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_optionalTag_get") -@_cdecl("bjs_SwiftDataProcessor_optionalTag_get") -public func _bjs_SwiftDataProcessor_optionalTag_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTag - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_optionalTag_set") -@_cdecl("bjs_SwiftDataProcessor_optionalTag_set") -public func _bjs_SwiftDataProcessor_optionalTag_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTag = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_optionalCount_get") -@_cdecl("bjs_SwiftDataProcessor_optionalCount_get") -public func _bjs_SwiftDataProcessor_optionalCount_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalCount - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_optionalCount_set") -@_cdecl("bjs_SwiftDataProcessor_optionalCount_set") -public func _bjs_SwiftDataProcessor_optionalCount_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalCount = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_direction_get") -@_cdecl("bjs_SwiftDataProcessor_direction_get") -public func _bjs_SwiftDataProcessor_direction_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).direction - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_direction_set") -@_cdecl("bjs_SwiftDataProcessor_direction_set") -public func _bjs_SwiftDataProcessor_direction_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).direction = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_optionalTheme_get") -@_cdecl("bjs_SwiftDataProcessor_optionalTheme_get") -public func _bjs_SwiftDataProcessor_optionalTheme_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTheme - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_optionalTheme_set") -@_cdecl("bjs_SwiftDataProcessor_optionalTheme_set") -public func _bjs_SwiftDataProcessor_optionalTheme_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTheme = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_httpStatus_get") -@_cdecl("bjs_SwiftDataProcessor_httpStatus_get") -public func _bjs_SwiftDataProcessor_httpStatus_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).httpStatus - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_httpStatus_set") -@_cdecl("bjs_SwiftDataProcessor_httpStatus_set") -public func _bjs_SwiftDataProcessor_httpStatus_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).httpStatus = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_apiResult_get") -@_cdecl("bjs_SwiftDataProcessor_apiResult_get") -public func _bjs_SwiftDataProcessor_apiResult_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).apiResult - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_apiResult_set") -@_cdecl("bjs_SwiftDataProcessor_apiResult_set") -public func _bjs_SwiftDataProcessor_apiResult_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).apiResult = Optional.bridgeJSLiftParameter(valueIsSome, valueCaseId) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_helper_get") -@_cdecl("bjs_SwiftDataProcessor_helper_get") -public func _bjs_SwiftDataProcessor_helper_get(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).helper - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_helper_set") -@_cdecl("bjs_SwiftDataProcessor_helper_set") -public func _bjs_SwiftDataProcessor_helper_set(_ _self: UnsafeMutableRawPointer, _ value: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).helper = Greeter.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_optionalHelper_get") -@_cdecl("bjs_SwiftDataProcessor_optionalHelper_get") -public func _bjs_SwiftDataProcessor_optionalHelper_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalHelper - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_optionalHelper_set") -@_cdecl("bjs_SwiftDataProcessor_optionalHelper_set") -public func _bjs_SwiftDataProcessor_optionalHelper_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalHelper = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_SwiftDataProcessor_deinit") -@_cdecl("bjs_SwiftDataProcessor_deinit") -public func _bjs_SwiftDataProcessor_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension SwiftDataProcessor: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_SwiftDataProcessor_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_SwiftDataProcessor_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftDataProcessor_wrap") -fileprivate func _bjs_SwiftDataProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_SwiftDataProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_SwiftDataProcessor_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_SwiftDataProcessor_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessor") -@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessor") -public func _bjs_ProtocolReturnTests_static_createNativeProcessor() -> Int32 { - #if arch(wasm32) - let ret = ProtocolReturnTests.createNativeProcessor() as! _BridgedSwiftProtocolExportable - return ret.bridgeJSLowerAsProtocolReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessorOptional") -@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessorOptional") -public func _bjs_ProtocolReturnTests_static_createNativeProcessorOptional() -> Void { - #if arch(wasm32) - let ret = ProtocolReturnTests.createNativeProcessorOptional() - if let ret { - _swift_js_return_optional_object(1, (ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) - } else { - _swift_js_return_optional_object(0, 0) - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessorNil") -@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessorNil") -public func _bjs_ProtocolReturnTests_static_createNativeProcessorNil() -> Void { - #if arch(wasm32) - let ret = ProtocolReturnTests.createNativeProcessorNil() - if let ret { - _swift_js_return_optional_object(1, (ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) - } else { - _swift_js_return_optional_object(0, 0) - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessorArray") -@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessorArray") -public func _bjs_ProtocolReturnTests_static_createNativeProcessorArray() -> Void { - #if arch(wasm32) - let ret = ProtocolReturnTests.createNativeProcessorArray() - for __bjs_elem_ret in ret { - _swift_js_push_i32((__bjs_elem_ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) - } - _swift_js_push_i32(Int32(ret.count)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessorDictionary") -@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessorDictionary") -public func _bjs_ProtocolReturnTests_static_createNativeProcessorDictionary() -> Void { - #if arch(wasm32) - let ret = ProtocolReturnTests.createNativeProcessorDictionary() - for __bjs_kv_ret in ret { - __bjs_kv_ret.key.bridgeJSStackPush() - _swift_js_push_i32((__bjs_kv_ret.value as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) - } - _swift_js_push_i32(Int32(ret.count)) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ProtocolReturnTests_deinit") -@_cdecl("bjs_ProtocolReturnTests_deinit") -public func _bjs_ProtocolReturnTests_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension ProtocolReturnTests: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_ProtocolReturnTests_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_ProtocolReturnTests_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ProtocolReturnTests_wrap") -fileprivate func _bjs_ProtocolReturnTests_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_ProtocolReturnTests_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_ProtocolReturnTests_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_ProtocolReturnTests_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_TextProcessor_init") -@_cdecl("bjs_TextProcessor_init") -public func _bjs_TextProcessor_init(_ transform: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = TextProcessor(transform: _BJS_Closure_20BridgeJSRuntimeTestsSS_SS.bridgeJSLift(transform)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_process") -@_cdecl("bjs_TextProcessor_process") -public func _bjs_TextProcessor_process(_ _self: UnsafeMutableRawPointer, _ textBytes: Int32, _ textLength: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).process(_: String.bridgeJSLiftParameter(textBytes, textLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processWithCustom") -@_cdecl("bjs_TextProcessor_processWithCustom") -public func _bjs_TextProcessor_processWithCustom(_ _self: UnsafeMutableRawPointer, _ textBytes: Int32, _ textLength: Int32, _ customTransform: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processWithCustom(_: String.bridgeJSLiftParameter(textBytes, textLength), customTransform: _BJS_Closure_20BridgeJSRuntimeTestsSiSSSd_SS.bridgeJSLift(customTransform)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_getTransform") -@_cdecl("bjs_TextProcessor_getTransform") -public func _bjs_TextProcessor_getTransform(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).getTransform() - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processOptionalString") -@_cdecl("bjs_TextProcessor_processOptionalString") -public func _bjs_TextProcessor_processOptionalString(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalString(_: _BJS_Closure_20BridgeJSRuntimeTestsSqSS_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processOptionalInt") -@_cdecl("bjs_TextProcessor_processOptionalInt") -public func _bjs_TextProcessor_processOptionalInt(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalInt(_: _BJS_Closure_20BridgeJSRuntimeTestsSqSi_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processOptionalGreeter") -@_cdecl("bjs_TextProcessor_processOptionalGreeter") -public func _bjs_TextProcessor_processOptionalGreeter(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalGreeter(_: _BJS_Closure_20BridgeJSRuntimeTestsSq7GreeterC_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_makeOptionalStringFormatter") -@_cdecl("bjs_TextProcessor_makeOptionalStringFormatter") -public func _bjs_TextProcessor_makeOptionalStringFormatter(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).makeOptionalStringFormatter() - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_makeOptionalGreeterCreator") -@_cdecl("bjs_TextProcessor_makeOptionalGreeterCreator") -public func _bjs_TextProcessor_makeOptionalGreeterCreator(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).makeOptionalGreeterCreator() - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processDirection") -@_cdecl("bjs_TextProcessor_processDirection") -public func _bjs_TextProcessor_processDirection(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processDirection(_: _BJS_Closure_20BridgeJSRuntimeTests9DirectionO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processTheme") -@_cdecl("bjs_TextProcessor_processTheme") -public func _bjs_TextProcessor_processTheme(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processTheme(_: _BJS_Closure_20BridgeJSRuntimeTests5ThemeO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processHttpStatus") -@_cdecl("bjs_TextProcessor_processHttpStatus") -public func _bjs_TextProcessor_processHttpStatus(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Int32 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processHttpStatus(_: _BJS_Closure_20BridgeJSRuntimeTests10HttpStatusO_Si.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processAPIResult") -@_cdecl("bjs_TextProcessor_processAPIResult") -public func _bjs_TextProcessor_processAPIResult(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processAPIResult(_: _BJS_Closure_20BridgeJSRuntimeTests9APIResultO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_makeDirectionChecker") -@_cdecl("bjs_TextProcessor_makeDirectionChecker") -public func _bjs_TextProcessor_makeDirectionChecker(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).makeDirectionChecker() - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_makeThemeValidator") -@_cdecl("bjs_TextProcessor_makeThemeValidator") -public func _bjs_TextProcessor_makeThemeValidator(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).makeThemeValidator() - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_makeStatusCodeExtractor") -@_cdecl("bjs_TextProcessor_makeStatusCodeExtractor") -public func _bjs_TextProcessor_makeStatusCodeExtractor(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).makeStatusCodeExtractor() - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_makeAPIResultHandler") -@_cdecl("bjs_TextProcessor_makeAPIResultHandler") -public func _bjs_TextProcessor_makeAPIResultHandler(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).makeAPIResultHandler() - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processOptionalDirection") -@_cdecl("bjs_TextProcessor_processOptionalDirection") -public func _bjs_TextProcessor_processOptionalDirection(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalDirection(_: _BJS_Closure_20BridgeJSRuntimeTestsSq9DirectionO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processOptionalTheme") -@_cdecl("bjs_TextProcessor_processOptionalTheme") -public func _bjs_TextProcessor_processOptionalTheme(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalTheme(_: _BJS_Closure_20BridgeJSRuntimeTestsSq5ThemeO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processOptionalAPIResult") -@_cdecl("bjs_TextProcessor_processOptionalAPIResult") -public func _bjs_TextProcessor_processOptionalAPIResult(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalAPIResult(_: _BJS_Closure_20BridgeJSRuntimeTestsSq9APIResultO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_makeOptionalDirectionFormatter") -@_cdecl("bjs_TextProcessor_makeOptionalDirectionFormatter") -public func _bjs_TextProcessor_makeOptionalDirectionFormatter(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).makeOptionalDirectionFormatter() - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processDataProcessor") -@_cdecl("bjs_TextProcessor_processDataProcessor") -public func _bjs_TextProcessor_processDataProcessor(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processDataProcessor(_: _BJS_Closure_20BridgeJSRuntimeTests13DataProcessorP_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_makeDataProcessorFactory") -@_cdecl("bjs_TextProcessor_makeDataProcessorFactory") -public func _bjs_TextProcessor_makeDataProcessorFactory(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).makeDataProcessorFactory() - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_roundtripDataProcessor") -@_cdecl("bjs_TextProcessor_roundtripDataProcessor") -public func _bjs_TextProcessor_roundtripDataProcessor(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Int32 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).roundtripDataProcessor(_: _BJS_Closure_20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP.bridgeJSLift(callback)) - return JSTypedClosure(ret).bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_processOptionalDataProcessor") -@_cdecl("bjs_TextProcessor_processOptionalDataProcessor") -public func _bjs_TextProcessor_processOptionalDataProcessor(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalDataProcessor(_: _BJS_Closure_20BridgeJSRuntimeTestsSq13DataProcessorP_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_TextProcessor_deinit") -@_cdecl("bjs_TextProcessor_deinit") -public func _bjs_TextProcessor_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension TextProcessor: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_TextProcessor_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_TextProcessor_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TextProcessor_wrap") -fileprivate func _bjs_TextProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_TextProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_TextProcessor_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_TextProcessor_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_IdentityTestSubject_init") -@_cdecl("bjs_IdentityTestSubject_init") -public func _bjs_IdentityTestSubject_init(_ value: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = IdentityTestSubject(value: Int.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IdentityTestSubject_value_get") -@_cdecl("bjs_IdentityTestSubject_value_get") -public func _bjs_IdentityTestSubject_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = IdentityTestSubject.bridgeJSLiftParameter(_self).value - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IdentityTestSubject_value_set") -@_cdecl("bjs_IdentityTestSubject_value_set") -public func _bjs_IdentityTestSubject_value_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - IdentityTestSubject.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IdentityTestSubject_currentValue_get") -@_cdecl("bjs_IdentityTestSubject_currentValue_get") -public func _bjs_IdentityTestSubject_currentValue_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = IdentityTestSubject.bridgeJSLiftParameter(_self).currentValue - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_IdentityTestSubject_deinit") -@_cdecl("bjs_IdentityTestSubject_deinit") -public func _bjs_IdentityTestSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension IdentityTestSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_IdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_IdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IdentityTestSubject_wrap") -fileprivate func _bjs_IdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_IdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_IdentityTestSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_IdentityTestSubject_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_RetainLeakSubject_init") -@_cdecl("bjs_RetainLeakSubject_init") -public func _bjs_RetainLeakSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = RetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_RetainLeakSubject_tag_get") -@_cdecl("bjs_RetainLeakSubject_tag_get") -public func _bjs_RetainLeakSubject_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = RetainLeakSubject.bridgeJSLiftParameter(_self).tag - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_RetainLeakSubject_tag_set") -@_cdecl("bjs_RetainLeakSubject_tag_set") -public func _bjs_RetainLeakSubject_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - RetainLeakSubject.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_RetainLeakSubject_deinit") -@_cdecl("bjs_RetainLeakSubject_deinit") -public func _bjs_RetainLeakSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension RetainLeakSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_RetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_RetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_RetainLeakSubject_wrap") -fileprivate func _bjs_RetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_RetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_RetainLeakSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_RetainLeakSubject_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_ArrayIdentityElement_init") -@_cdecl("bjs_ArrayIdentityElement_init") -public func _bjs_ArrayIdentityElement_init(_ tag: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = ArrayIdentityElement(tag: Int.bridgeJSLiftParameter(tag)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArrayIdentityElement_tag_get") -@_cdecl("bjs_ArrayIdentityElement_tag_get") -public func _bjs_ArrayIdentityElement_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { - #if arch(wasm32) - let ret = ArrayIdentityElement.bridgeJSLiftParameter(_self).tag - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArrayIdentityElement_tag_set") -@_cdecl("bjs_ArrayIdentityElement_tag_set") -public func _bjs_ArrayIdentityElement_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { - #if arch(wasm32) - ArrayIdentityElement.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_ArrayIdentityElement_deinit") -@_cdecl("bjs_ArrayIdentityElement_deinit") -public func _bjs_ArrayIdentityElement_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension ArrayIdentityElement: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_ArrayIdentityElement_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_ArrayIdentityElement_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayIdentityElement_wrap") -fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_ArrayIdentityElement_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_ArrayIdentityElement_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_OptionalHolder_init") -@_cdecl("bjs_OptionalHolder_init") -public func _bjs_OptionalHolder_init(_ nullableGreeterIsSome: Int32, _ nullableGreeterValue: UnsafeMutableRawPointer, _ undefinedNumberIsSome: Int32, _ undefinedNumberValue: Float64) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = OptionalHolder(nullableGreeter: Optional.bridgeJSLiftParameter(nullableGreeterIsSome, nullableGreeterValue), undefinedNumber: JSUndefinedOr.bridgeJSLiftParameter(undefinedNumberIsSome, undefinedNumberValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalHolder_nullableGreeter_get") -@_cdecl("bjs_OptionalHolder_nullableGreeter_get") -public func _bjs_OptionalHolder_nullableGreeter_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = OptionalHolder.bridgeJSLiftParameter(_self).nullableGreeter - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalHolder_nullableGreeter_set") -@_cdecl("bjs_OptionalHolder_nullableGreeter_set") -public func _bjs_OptionalHolder_nullableGreeter_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - OptionalHolder.bridgeJSLiftParameter(_self).nullableGreeter = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalHolder_undefinedNumber_get") -@_cdecl("bjs_OptionalHolder_undefinedNumber_get") -public func _bjs_OptionalHolder_undefinedNumber_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = OptionalHolder.bridgeJSLiftParameter(_self).undefinedNumber - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalHolder_undefinedNumber_set") -@_cdecl("bjs_OptionalHolder_undefinedNumber_set") -public func _bjs_OptionalHolder_undefinedNumber_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Float64) -> Void { - #if arch(wasm32) - OptionalHolder.bridgeJSLiftParameter(_self).undefinedNumber = JSUndefinedOr.bridgeJSLiftParameter(valueIsSome, valueValue) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalHolder_deinit") -@_cdecl("bjs_OptionalHolder_deinit") -public func _bjs_OptionalHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension OptionalHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_OptionalHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_OptionalHolder_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalHolder_wrap") -fileprivate func _bjs_OptionalHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_OptionalHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_OptionalHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_OptionalHolder_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_OptionalPropertyHolder_init") -@_cdecl("bjs_OptionalPropertyHolder_init") -public func _bjs_OptionalPropertyHolder_init(_ optionalNameIsSome: Int32, _ optionalNameBytes: Int32, _ optionalNameLength: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = OptionalPropertyHolder(optionalName: Optional.bridgeJSLiftParameter(optionalNameIsSome, optionalNameBytes, optionalNameLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalPropertyHolder_optionalName_get") -@_cdecl("bjs_OptionalPropertyHolder_optionalName_get") -public func _bjs_OptionalPropertyHolder_optionalName_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalName - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalPropertyHolder_optionalName_set") -@_cdecl("bjs_OptionalPropertyHolder_optionalName_set") -public func _bjs_OptionalPropertyHolder_optionalName_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - #if arch(wasm32) - OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalName = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalPropertyHolder_optionalAge_get") -@_cdecl("bjs_OptionalPropertyHolder_optionalAge_get") -public func _bjs_OptionalPropertyHolder_optionalAge_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalAge - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalPropertyHolder_optionalAge_set") -@_cdecl("bjs_OptionalPropertyHolder_optionalAge_set") -public func _bjs_OptionalPropertyHolder_optionalAge_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { - #if arch(wasm32) - OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalAge = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalPropertyHolder_optionalGreeter_get") -@_cdecl("bjs_OptionalPropertyHolder_optionalGreeter_get") -public func _bjs_OptionalPropertyHolder_optionalGreeter_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalGreeter - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalPropertyHolder_optionalGreeter_set") -@_cdecl("bjs_OptionalPropertyHolder_optionalGreeter_set") -public func _bjs_OptionalPropertyHolder_optionalGreeter_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalGreeter = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_OptionalPropertyHolder_deinit") -@_cdecl("bjs_OptionalPropertyHolder_deinit") -public func _bjs_OptionalPropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension OptionalPropertyHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_OptionalPropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_OptionalPropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalPropertyHolder_wrap") -fileprivate func _bjs_OptionalPropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_OptionalPropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_OptionalPropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_OptionalPropertyHolder_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_Container_init") -@_cdecl("bjs_Container_init") -public func _bjs_Container_init() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let _tmp_config = Optional.bridgeJSLiftParameter() - let _tmp_location = DataPoint.bridgeJSLiftParameter() - let ret = Container(location: _tmp_location, config: _tmp_config) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Container_location_get") -@_cdecl("bjs_Container_location_get") -public func _bjs_Container_location_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = Container.bridgeJSLiftParameter(_self).location - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Container_location_set") -@_cdecl("bjs_Container_location_set") -public func _bjs_Container_location_set(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Container.bridgeJSLiftParameter(_self).location = DataPoint.bridgeJSLiftParameter() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Container_config_get") -@_cdecl("bjs_Container_config_get") -public func _bjs_Container_config_get(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = Container.bridgeJSLiftParameter(_self).config - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Container_config_set") -@_cdecl("bjs_Container_config_set") -public func _bjs_Container_config_set(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Container.bridgeJSLiftParameter(_self).config = Optional.bridgeJSLiftParameter() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_Container_deinit") -@_cdecl("bjs_Container_deinit") -public func _bjs_Container_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension Container: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_Container_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_Container_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Container_wrap") -fileprivate func _bjs_Container_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_Container_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_Container_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_Container_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_LeakCheck_init") -@_cdecl("bjs_LeakCheck_init") -public func _bjs_LeakCheck_init() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = LeakCheck() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_LeakCheck_deinit") -@_cdecl("bjs_LeakCheck_deinit") -public func _bjs_LeakCheck_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() - #else - fatalError("Only available on WebAssembly") - #endif -} - -extension LeakCheck: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - public var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_LeakCheck_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - public consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_LeakCheck_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_LeakCheck_wrap") -fileprivate func _bjs_LeakCheck_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_LeakCheck_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_LeakCheck_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_LeakCheck_wrap_extern(pointer) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayElementObject_init") -fileprivate func bjs_ArrayElementObject_init_extern(_ idBytes: Int32, _ idLength: Int32) -> Int32 -#else -fileprivate func bjs_ArrayElementObject_init_extern(_ idBytes: Int32, _ idLength: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArrayElementObject_init(_ idBytes: Int32, _ idLength: Int32) -> Int32 { - return bjs_ArrayElementObject_init_extern(idBytes, idLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayElementObject_id_get") -fileprivate func bjs_ArrayElementObject_id_get_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs_ArrayElementObject_id_get_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArrayElementObject_id_get(_ self: Int32) -> Int32 { - return bjs_ArrayElementObject_id_get_extern(self) -} - -func _$ArrayElementObject_init(_ id: String) throws(JSException) -> JSObject { - let ret0 = id.bridgeJSWithLoweredParameter { (idBytes, idLength) in - let ret = bjs_ArrayElementObject_init(idBytes, idLength) - return ret - } - let ret = ret0 - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) -} - -func _$ArrayElementObject_id_get(_ self: JSObject) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_ArrayElementObject_id_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsIntArrayLength_static") -fileprivate func bjs_ArraySupportImports_jsIntArrayLength_static_extern() -> Int32 -#else -fileprivate func bjs_ArraySupportImports_jsIntArrayLength_static_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsIntArrayLength_static() -> Int32 { - return bjs_ArraySupportImports_jsIntArrayLength_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripIntArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripIntArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripIntArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripIntArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripIntArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripNumberArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripNumberArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripNumberArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripNumberArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripNumberArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripStringArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripStringArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripStringArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripStringArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripStringArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripBoolArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripBoolArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripBoolArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripBoolArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripBoolArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripJSValueArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripJSValueArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripJSValueArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripJSValueArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripJSValueArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripJSObjectArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripJSObjectArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripJSObjectArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripJSObjectArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripJSObjectArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripJSClassArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripJSClassArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripJSClassArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripJSClassArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripJSClassArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static") -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static() -> Void { - return bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsSumNumberArray_static") -fileprivate func bjs_ArraySupportImports_jsSumNumberArray_static_extern() -> Float64 -#else -fileprivate func bjs_ArraySupportImports_jsSumNumberArray_static_extern() -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsSumNumberArray_static() -> Float64 { - return bjs_ArraySupportImports_jsSumNumberArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_jsCreateNumberArray_static") -fileprivate func bjs_ArraySupportImports_jsCreateNumberArray_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_jsCreateNumberArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_jsCreateNumberArray_static() -> Void { - return bjs_ArraySupportImports_jsCreateNumberArray_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArraySupportImports_runJsArraySupportTests_static") -fileprivate func bjs_ArraySupportImports_runJsArraySupportTests_static_extern() -> Void -#else -fileprivate func bjs_ArraySupportImports_runJsArraySupportTests_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ArraySupportImports_runJsArraySupportTests_static() -> Void { - return bjs_ArraySupportImports_runJsArraySupportTests_static_extern() -} - -func _$ArraySupportImports_jsIntArrayLength(_ items: [Int]) throws(JSException) -> Int { - let _ = items.bridgeJSLowerParameter() - let ret = bjs_ArraySupportImports_jsIntArrayLength_static() - if let error = _swift_js_take_exception() { - throw error - } - return Int.bridgeJSLiftReturn(ret) -} - -func _$ArraySupportImports_jsRoundTripIntArray(_ items: [Int]) throws(JSException) -> [Int] { - let _ = items.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripIntArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [Int].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripNumberArray(_ values: [Double]) throws(JSException) -> [Double] { - let _ = values.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripNumberArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [Double].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripStringArray(_ values: [String]) throws(JSException) -> [String] { - let _ = values.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripStringArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [String].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripBoolArray(_ values: [Bool]) throws(JSException) -> [Bool] { - let _ = values.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripBoolArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [Bool].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripJSValueArray(_ v: [JSValue]) throws(JSException) -> [JSValue] { - let _ = v.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripJSValueArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [JSValue].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripJSObjectArray(_ values: [JSObject]) throws(JSException) -> [JSObject] { - let _ = values.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripJSObjectArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [JSObject].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripJSClassArray(_ values: [ArrayElementObject]) throws(JSException) -> [ArrayElementObject] { - let _ = values.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripJSClassArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [ArrayElementObject].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripOptionalIntArray(_ values: [Optional]) throws(JSException) -> [Optional] { - let _ = values.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripOptionalIntArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [Optional].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripOptionalStringArray(_ values: [Optional]) throws(JSException) -> [Optional] { - let _ = values.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripOptionalStringArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [Optional].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripOptionalBoolArray(_ values: [Optional]) throws(JSException) -> [Optional] { - let _ = values.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripOptionalBoolArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [Optional].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripOptionalJSValueArray(_ values: [Optional]) throws(JSException) -> [Optional] { - let _ = values.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripOptionalJSValueArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [Optional].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripOptionalJSObjectArray(_ values: [Optional]) throws(JSException) -> [Optional] { - let _ = values.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripOptionalJSObjectArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [Optional].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsRoundTripOptionalJSClassArray(_ values: [Optional]) throws(JSException) -> [Optional] { - let _ = values.bridgeJSLowerParameter() - bjs_ArraySupportImports_jsRoundTripOptionalJSClassArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [Optional].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_jsSumNumberArray(_ values: [Double]) throws(JSException) -> Double { - let _ = values.bridgeJSLowerParameter() - let ret = bjs_ArraySupportImports_jsSumNumberArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -func _$ArraySupportImports_jsCreateNumberArray() throws(JSException) -> [Double] { - bjs_ArraySupportImports_jsCreateNumberArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [Double].bridgeJSLiftReturn() -} - -func _$ArraySupportImports_runJsArraySupportTests() throws(JSException) -> Void { - bjs_ArraySupportImports_runJsArraySupportTests_static() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripVoid_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripVoid_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripVoid_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripVoid_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripVoid_static_extern(resolveRef, rejectRef) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripNumber_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripNumber_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Float64) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripNumber_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripNumber_static(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Float64) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripNumber_static_extern(resolveRef, rejectRef, v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripBool_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBool_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBool_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBool_static(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripBool_static_extern(resolveRef, rejectRef, v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripString_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripString_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripString_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripString_static(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripString_static_extern(resolveRef, rejectRef, vBytes, vLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static_extern(resolveRef, rejectRef, vIsSome, vBytes, vLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vValue: Float64) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vValue: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vValue: Float64) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static_extern(resolveRef, rejectRef, vIsSome, vValue) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static_extern(resolveRef, rejectRef) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static_extern(resolveRef, rejectRef) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static_extern(resolveRef, rejectRef) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static(_ resolveRef: Int32, _ rejectRef: Int32, _ vBytes: Int32, _ vLength: Int32) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_extern(resolveRef, rejectRef, vBytes, vLength) -} - -func _$AsyncImportImports_jsAsyncRoundTripVoid() async throws(JSException) -> Void { - try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<() -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - bjs_AsyncImportImports_jsAsyncRoundTripVoid_static(resolveRef, rejectRef) - } -} - -func _$AsyncImportImports_jsAsyncRoundTripNumber(_ v: Double) async throws(JSException) -> Double { - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending Double) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let vValue = v.bridgeJSLowerParameter() - bjs_AsyncImportImports_jsAsyncRoundTripNumber_static(resolveRef, rejectRef, vValue) - } - return resolved -} - -func _$AsyncImportImports_jsAsyncRoundTripBool(_ v: Bool) async throws(JSException) -> Bool { - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending Bool) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let vValue = v.bridgeJSLowerParameter() - bjs_AsyncImportImports_jsAsyncRoundTripBool_static(resolveRef, rejectRef, vValue) - } - return resolved -} - -func _$AsyncImportImports_jsAsyncRoundTripString(_ v: String) async throws(JSException) -> String { - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending String) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - v.bridgeJSWithLoweredParameter { (vBytes, vLength) in - bjs_AsyncImportImports_jsAsyncRoundTripString_static(resolveRef, rejectRef, vBytes, vLength) - } - } - return resolved -} - -func _$AsyncImportImports_jsAsyncRoundTripOptionalString(_ v: Optional) async throws(JSException) -> Optional { - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending Optional) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - v.bridgeJSWithLoweredParameter { (vIsSome, vBytes, vLength) in - bjs_AsyncImportImports_jsAsyncRoundTripOptionalString_static(resolveRef, rejectRef, vIsSome, vBytes, vLength) - } - } - return resolved -} - -func _$AsyncImportImports_jsAsyncRoundTripOptionalNumber(_ v: Optional) async throws(JSException) -> Optional { - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending Optional) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let (vIsSome, vValue) = v.bridgeJSLowerParameter() - bjs_AsyncImportImports_jsAsyncRoundTripOptionalNumber_static(resolveRef, rejectRef, vIsSome, vValue) - } - return resolved -} - -func _$AsyncImportImports_jsAsyncRoundTripBoolArray(_ values: [Bool]) async throws(JSException) -> [Bool] { - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending [Bool]) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let _ = values.bridgeJSLowerParameter() - bjs_AsyncImportImports_jsAsyncRoundTripBoolArray_static(resolveRef, rejectRef) - } - return resolved -} - -func _$AsyncImportImports_jsAsyncRoundTripIntArray(_ values: [Double]) async throws(JSException) -> [Double] { - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending [Double]) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let _ = values.bridgeJSLowerParameter() - bjs_AsyncImportImports_jsAsyncRoundTripIntArray_static(resolveRef, rejectRef) - } - return resolved -} - -func _$AsyncImportImports_jsAsyncRoundTripStringArray(_ values: [String]) async throws(JSException) -> [String] { - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending [String]) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let _ = values.bridgeJSLowerParameter() - bjs_AsyncImportImports_jsAsyncRoundTripStringArray_static(resolveRef, rejectRef) - } - return resolved -} - -func _$AsyncImportImports_jsAsyncRoundTripFeatureFlag(_ v: FeatureFlag) async throws(JSException) -> FeatureFlag { - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending FeatureFlag) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - v.bridgeJSWithLoweredParameter { (vBytes, vLength) in - bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static(resolveRef, rejectRef, vBytes, vLength) - } - } - return resolved -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyVoid_static") -fileprivate func bjs_ClosureSupportImports_jsApplyVoid_static_extern(_ callback: Int32) -> Void -#else -fileprivate func bjs_ClosureSupportImports_jsApplyVoid_static_extern(_ callback: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyVoid_static(_ callback: Int32) -> Void { - return bjs_ClosureSupportImports_jsApplyVoid_static_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyBool_static") -fileprivate func bjs_ClosureSupportImports_jsApplyBool_static_extern(_ callback: Int32) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsApplyBool_static_extern(_ callback: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyBool_static(_ callback: Int32) -> Int32 { - return bjs_ClosureSupportImports_jsApplyBool_static_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyInt_static") -fileprivate func bjs_ClosureSupportImports_jsApplyInt_static_extern(_ value: Int32, _ transform: Int32) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsApplyInt_static_extern(_ value: Int32, _ transform: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyInt_static(_ value: Int32, _ transform: Int32) -> Int32 { - return bjs_ClosureSupportImports_jsApplyInt_static_extern(value, transform) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyDouble_static") -fileprivate func bjs_ClosureSupportImports_jsApplyDouble_static_extern(_ value: Float64, _ transform: Int32) -> Float64 -#else -fileprivate func bjs_ClosureSupportImports_jsApplyDouble_static_extern(_ value: Float64, _ transform: Int32) -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyDouble_static(_ value: Float64, _ transform: Int32) -> Float64 { - return bjs_ClosureSupportImports_jsApplyDouble_static_extern(value, transform) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyString_static") -fileprivate func bjs_ClosureSupportImports_jsApplyString_static_extern(_ valueBytes: Int32, _ valueLength: Int32, _ transform: Int32) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsApplyString_static_extern(_ valueBytes: Int32, _ valueLength: Int32, _ transform: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyString_static(_ valueBytes: Int32, _ valueLength: Int32, _ transform: Int32) -> Int32 { - return bjs_ClosureSupportImports_jsApplyString_static_extern(valueBytes, valueLength, transform) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyJSObject_static") -fileprivate func bjs_ClosureSupportImports_jsApplyJSObject_static_extern(_ value: Int32, _ transform: Int32) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsApplyJSObject_static_extern(_ value: Int32, _ transform: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsApplyJSObject_static(_ value: Int32, _ transform: Int32) -> Int32 { - return bjs_ClosureSupportImports_jsApplyJSObject_static_extern(value, transform) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsMakeIntToInt_static") -fileprivate func bjs_ClosureSupportImports_jsMakeIntToInt_static_extern(_ base: Int32) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsMakeIntToInt_static_extern(_ base: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsMakeIntToInt_static(_ base: Int32) -> Int32 { - return bjs_ClosureSupportImports_jsMakeIntToInt_static_extern(base) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsMakeDoubleToDouble_static") -fileprivate func bjs_ClosureSupportImports_jsMakeDoubleToDouble_static_extern(_ base: Float64) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsMakeDoubleToDouble_static_extern(_ base: Float64) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsMakeDoubleToDouble_static(_ base: Float64) -> Int32 { - return bjs_ClosureSupportImports_jsMakeDoubleToDouble_static_extern(base) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsMakeStringToString_static") -fileprivate func bjs_ClosureSupportImports_jsMakeStringToString_static_extern(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsMakeStringToString_static_extern(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsMakeStringToString_static(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { - return bjs_ClosureSupportImports_jsMakeStringToString_static_extern(prefixBytes, prefixLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsCallTwice_static") -fileprivate func bjs_ClosureSupportImports_jsCallTwice_static_extern(_ value: Int32, _ callback: Int32) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsCallTwice_static_extern(_ value: Int32, _ callback: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsCallTwice_static(_ value: Int32, _ callback: Int32) -> Int32 { - return bjs_ClosureSupportImports_jsCallTwice_static_extern(value, callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsCallBinary_static") -fileprivate func bjs_ClosureSupportImports_jsCallBinary_static_extern(_ callback: Int32) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsCallBinary_static_extern(_ callback: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsCallBinary_static(_ callback: Int32) -> Int32 { - return bjs_ClosureSupportImports_jsCallBinary_static_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsCallTriple_static") -fileprivate func bjs_ClosureSupportImports_jsCallTriple_static_extern(_ callback: Int32) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsCallTriple_static_extern(_ callback: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsCallTriple_static(_ callback: Int32) -> Int32 { - return bjs_ClosureSupportImports_jsCallTriple_static_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsCallAfterRelease_static") -fileprivate func bjs_ClosureSupportImports_jsCallAfterRelease_static_extern(_ callback: Int32) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsCallAfterRelease_static_extern(_ callback: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsCallAfterRelease_static(_ callback: Int32) -> Int32 { - return bjs_ClosureSupportImports_jsCallAfterRelease_static_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsOptionalInvoke_static") -fileprivate func bjs_ClosureSupportImports_jsOptionalInvoke_static_extern(_ callbackIsSome: Int32, _ callbackFuncRef: Int32) -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsOptionalInvoke_static_extern(_ callbackIsSome: Int32, _ callbackFuncRef: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsOptionalInvoke_static(_ callbackIsSome: Int32, _ callbackFuncRef: Int32) -> Int32 { - return bjs_ClosureSupportImports_jsOptionalInvoke_static_extern(callbackIsSome, callbackFuncRef) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsStoreClosure_static") -fileprivate func bjs_ClosureSupportImports_jsStoreClosure_static_extern(_ callback: Int32) -> Void -#else -fileprivate func bjs_ClosureSupportImports_jsStoreClosure_static_extern(_ callback: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsStoreClosure_static(_ callback: Int32) -> Void { - return bjs_ClosureSupportImports_jsStoreClosure_static_extern(callback) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsCallStoredClosure_static") -fileprivate func bjs_ClosureSupportImports_jsCallStoredClosure_static_extern() -> Void -#else -fileprivate func bjs_ClosureSupportImports_jsCallStoredClosure_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsCallStoredClosure_static() -> Void { - return bjs_ClosureSupportImports_jsCallStoredClosure_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsHeapCount_static") -fileprivate func bjs_ClosureSupportImports_jsHeapCount_static_extern() -> Int32 -#else -fileprivate func bjs_ClosureSupportImports_jsHeapCount_static_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_jsHeapCount_static() -> Int32 { - return bjs_ClosureSupportImports_jsHeapCount_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_runJsClosureSupportTests_static") -fileprivate func bjs_ClosureSupportImports_runJsClosureSupportTests_static_extern() -> Void -#else -fileprivate func bjs_ClosureSupportImports_runJsClosureSupportTests_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureSupportImports_runJsClosureSupportTests_static() -> Void { - return bjs_ClosureSupportImports_runJsClosureSupportTests_static_extern() -} - -func _$ClosureSupportImports_jsApplyVoid(_ callback: JSTypedClosure<() -> Void>) throws(JSException) -> Void { - let callbackFuncRef = callback.bridgeJSLowerParameter() - bjs_ClosureSupportImports_jsApplyVoid_static(callbackFuncRef) - if let error = _swift_js_take_exception() { - throw error - } -} - -func _$ClosureSupportImports_jsApplyBool(_ callback: JSTypedClosure<() -> Bool>) throws(JSException) -> Bool { - let callbackFuncRef = callback.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsApplyBool_static(callbackFuncRef) - if let error = _swift_js_take_exception() { - throw error - } - return Bool.bridgeJSLiftReturn(ret) -} - -func _$ClosureSupportImports_jsApplyInt(_ value: Int, _ transform: JSTypedClosure<(Int) -> Int>) throws(JSException) -> Int { - let valueValue = value.bridgeJSLowerParameter() - let transformFuncRef = transform.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsApplyInt_static(valueValue, transformFuncRef) - if let error = _swift_js_take_exception() { - throw error - } - return Int.bridgeJSLiftReturn(ret) -} - -func _$ClosureSupportImports_jsApplyDouble(_ value: Double, _ transform: JSTypedClosure<(Double) -> Double>) throws(JSException) -> Double { - let valueValue = value.bridgeJSLowerParameter() - let transformFuncRef = transform.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsApplyDouble_static(valueValue, transformFuncRef) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -func _$ClosureSupportImports_jsApplyString(_ value: String, _ transform: JSTypedClosure<(String) -> String>) throws(JSException) -> String { - let ret0 = value.bridgeJSWithLoweredParameter { (valueBytes, valueLength) in - let transformFuncRef = transform.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsApplyString_static(valueBytes, valueLength, transformFuncRef) - return ret - } - let ret = ret0 - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -func _$ClosureSupportImports_jsApplyJSObject(_ value: JSObject, _ transform: JSTypedClosure<(JSObject) -> JSObject>) throws(JSException) -> JSObject { - let valueValue = value.bridgeJSLowerParameter() - let transformFuncRef = transform.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsApplyJSObject_static(valueValue, transformFuncRef) - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) -} - -func _$ClosureSupportImports_jsMakeIntToInt(_ base: Int) throws(JSException) -> (Int) -> Int { - let baseValue = base.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsMakeIntToInt_static(baseValue) - if let error = _swift_js_take_exception() { - throw error - } - return _BJS_Closure_20BridgeJSRuntimeTestsSi_Si.bridgeJSLift(ret) -} - -func _$ClosureSupportImports_jsMakeDoubleToDouble(_ base: Double) throws(JSException) -> (Double) -> Double { - let baseValue = base.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsMakeDoubleToDouble_static(baseValue) - if let error = _swift_js_take_exception() { - throw error - } - return _BJS_Closure_20BridgeJSRuntimeTestsSd_Sd.bridgeJSLift(ret) -} - -func _$ClosureSupportImports_jsMakeStringToString(_ prefix: String) throws(JSException) -> (String) -> String { - let ret0 = prefix.bridgeJSWithLoweredParameter { (prefixBytes, prefixLength) in - let ret = bjs_ClosureSupportImports_jsMakeStringToString_static(prefixBytes, prefixLength) - return ret - } - let ret = ret0 - if let error = _swift_js_take_exception() { - throw error - } - return _BJS_Closure_20BridgeJSRuntimeTestsSS_SS.bridgeJSLift(ret) -} - -func _$ClosureSupportImports_jsCallTwice(_ value: Int, _ callback: JSTypedClosure<(Int) -> Void>) throws(JSException) -> Int { - let valueValue = value.bridgeJSLowerParameter() - let callbackFuncRef = callback.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsCallTwice_static(valueValue, callbackFuncRef) - if let error = _swift_js_take_exception() { - throw error - } - return Int.bridgeJSLiftReturn(ret) -} - -func _$ClosureSupportImports_jsCallBinary(_ callback: JSTypedClosure<(Int, Int) -> Int>) throws(JSException) -> Int { - let callbackFuncRef = callback.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsCallBinary_static(callbackFuncRef) - if let error = _swift_js_take_exception() { - throw error - } - return Int.bridgeJSLiftReturn(ret) -} - -func _$ClosureSupportImports_jsCallTriple(_ callback: JSTypedClosure<(Int, Int, Int) -> Int>) throws(JSException) -> Int { - let callbackFuncRef = callback.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsCallTriple_static(callbackFuncRef) - if let error = _swift_js_take_exception() { - throw error - } - return Int.bridgeJSLiftReturn(ret) -} - -func _$ClosureSupportImports_jsCallAfterRelease(_ callback: JSTypedClosure<() -> Void>) throws(JSException) -> String { - let callbackFuncRef = callback.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsCallAfterRelease_static(callbackFuncRef) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -func _$ClosureSupportImports_jsOptionalInvoke(_ callback: Optional Bool>>) throws(JSException) -> Bool { - let (callbackIsSome, callbackFuncRef) = callback.bridgeJSLowerParameter() - let ret = bjs_ClosureSupportImports_jsOptionalInvoke_static(callbackIsSome, callbackFuncRef) - if let error = _swift_js_take_exception() { - throw error - } - return Bool.bridgeJSLiftReturn(ret) -} - -func _$ClosureSupportImports_jsStoreClosure(_ callback: JSTypedClosure<() -> Void>) throws(JSException) -> Void { - let callbackFuncRef = callback.bridgeJSLowerParameter() - bjs_ClosureSupportImports_jsStoreClosure_static(callbackFuncRef) - if let error = _swift_js_take_exception() { - throw error - } -} - -func _$ClosureSupportImports_jsCallStoredClosure() throws(JSException) -> Void { - bjs_ClosureSupportImports_jsCallStoredClosure_static() - if let error = _swift_js_take_exception() { - throw error - } -} - -func _$ClosureSupportImports_jsHeapCount() throws(JSException) -> Int { - let ret = bjs_ClosureSupportImports_jsHeapCount_static() - if let error = _swift_js_take_exception() { - throw error - } - return Int.bridgeJSLiftReturn(ret) -} - -func _$ClosureSupportImports_runJsClosureSupportTests() throws(JSException) -> Void { - bjs_ClosureSupportImports_runJsClosureSupportTests_static() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static") -fileprivate func bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static_extern() -> Void -#else -fileprivate func bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static() -> Void { - return bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static_extern() -} - -func _$DefaultArgumentImports_runJsDefaultArgumentTests() throws(JSException) -> Void { - bjs_DefaultArgumentImports_runJsDefaultArgumentTests_static() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static") -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static_extern() -> Void -#else -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static() -> Void { - return bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static") -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static_extern() -> Void -#else -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static() -> Void { - return bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static") -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static_extern() -> Void -#else -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static() -> Void { - return bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static") -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static_extern() -> Void -#else -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static() -> Void { - return bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static") -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static_extern() -> Void -#else -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static() -> Void { - return bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static") -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static_extern() -> Void -#else -fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static() -> Void { - return bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static_extern() -} - -func _$DictionarySupportImports_jsRoundTripDictionaryInt(_ values: [String: Int]) throws(JSException) -> [String: Int] { - let _ = values.bridgeJSLowerParameter() - bjs_DictionarySupportImports_jsRoundTripDictionaryInt_static() - if let error = _swift_js_take_exception() { - throw error - } - return [String: Int].bridgeJSLiftReturn() -} - -func _$DictionarySupportImports_jsRoundTripDictionaryBool(_ values: [String: Bool]) throws(JSException) -> [String: Bool] { - let _ = values.bridgeJSLowerParameter() - bjs_DictionarySupportImports_jsRoundTripDictionaryBool_static() - if let error = _swift_js_take_exception() { - throw error - } - return [String: Bool].bridgeJSLiftReturn() -} - -func _$DictionarySupportImports_jsRoundTripDictionaryDouble(_ values: [String: Double]) throws(JSException) -> [String: Double] { - let _ = values.bridgeJSLowerParameter() - bjs_DictionarySupportImports_jsRoundTripDictionaryDouble_static() - if let error = _swift_js_take_exception() { - throw error - } - return [String: Double].bridgeJSLiftReturn() -} - -func _$DictionarySupportImports_jsRoundTripDictionaryJSObject(_ values: [String: JSObject]) throws(JSException) -> [String: JSObject] { - let _ = values.bridgeJSLowerParameter() - bjs_DictionarySupportImports_jsRoundTripDictionaryJSObject_static() - if let error = _swift_js_take_exception() { - throw error - } - return [String: JSObject].bridgeJSLiftReturn() -} - -func _$DictionarySupportImports_jsRoundTripDictionaryJSValue(_ values: [String: JSValue]) throws(JSException) -> [String: JSValue] { - let _ = values.bridgeJSLowerParameter() - bjs_DictionarySupportImports_jsRoundTripDictionaryJSValue_static() - if let error = _swift_js_take_exception() { - throw error - } - return [String: JSValue].bridgeJSLiftReturn() -} - -func _$DictionarySupportImports_jsRoundTripDictionaryDoubleArray(_ values: [String: [Double]]) throws(JSException) -> [String: [Double]] { - let _ = values.bridgeJSLowerParameter() - bjs_DictionarySupportImports_jsRoundTripDictionaryDoubleArray_static() - if let error = _swift_js_take_exception() { - throw error - } - return [String: [Double]].bridgeJSLiftReturn() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Foo_init") -fileprivate func bjs_Foo_init_extern(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 -#else -fileprivate func bjs_Foo_init_extern(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_Foo_init(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 { - return bjs_Foo_init_extern(valueBytes, valueLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Foo_value_get") -fileprivate func bjs_Foo_value_get_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs_Foo_value_get_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_Foo_value_get(_ self: Int32) -> Int32 { - return bjs_Foo_value_get_extern(self) -} - -func _$Foo_init(_ value: String) throws(JSException) -> JSObject { - let ret0 = value.bridgeJSWithLoweredParameter { (valueBytes, valueLength) in - let ret = bjs_Foo_init(valueBytes, valueLength) - return ret - } - let ret = ret0 - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) -} - -func _$Foo_value_get(_ self: JSObject) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_Foo_value_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_globalObject1_get") -fileprivate func bjs_globalObject1_get_extern() -> Void -#else -fileprivate func bjs_globalObject1_get_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_globalObject1_get() -> Void { - return bjs_globalObject1_get_extern() -} - -func _$globalObject1_get() throws(JSException) -> JSValue { - bjs_globalObject1_get() - if let error = _swift_js_take_exception() { - throw error - } - return JSValue.bridgeJSLiftReturn() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripVoid") -fileprivate func bjs_jsRoundTripVoid_extern() -> Void -#else -fileprivate func bjs_jsRoundTripVoid_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsRoundTripVoid() -> Void { - return bjs_jsRoundTripVoid_extern() -} - -func _$jsRoundTripVoid() throws(JSException) -> Void { - bjs_jsRoundTripVoid() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripNumber") -fileprivate func bjs_jsRoundTripNumber_extern(_ v: Float64) -> Float64 -#else -fileprivate func bjs_jsRoundTripNumber_extern(_ v: Float64) -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsRoundTripNumber(_ v: Float64) -> Float64 { - return bjs_jsRoundTripNumber_extern(v) -} - -func _$jsRoundTripNumber(_ v: Double) throws(JSException) -> Double { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_jsRoundTripNumber(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripBool") -fileprivate func bjs_jsRoundTripBool_extern(_ v: Int32) -> Int32 -#else -fileprivate func bjs_jsRoundTripBool_extern(_ v: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsRoundTripBool(_ v: Int32) -> Int32 { - return bjs_jsRoundTripBool_extern(v) -} - -func _$jsRoundTripBool(_ v: Bool) throws(JSException) -> Bool { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_jsRoundTripBool(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return Bool.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripString") -fileprivate func bjs_jsRoundTripString_extern(_ vBytes: Int32, _ vLength: Int32) -> Int32 -#else -fileprivate func bjs_jsRoundTripString_extern(_ vBytes: Int32, _ vLength: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsRoundTripString(_ vBytes: Int32, _ vLength: Int32) -> Int32 { - return bjs_jsRoundTripString_extern(vBytes, vLength) -} - -func _$jsRoundTripString(_ v: String) throws(JSException) -> String { - let ret0 = v.bridgeJSWithLoweredParameter { (vBytes, vLength) in - let ret = bjs_jsRoundTripString(vBytes, vLength) - return ret - } - let ret = ret0 - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripJSValue") -fileprivate func bjs_jsRoundTripJSValue_extern(_ vKind: Int32, _ vPayload1: Int32, _ vPayload2: Float64) -> Void -#else -fileprivate func bjs_jsRoundTripJSValue_extern(_ vKind: Int32, _ vPayload1: Int32, _ vPayload2: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsRoundTripJSValue(_ vKind: Int32, _ vPayload1: Int32, _ vPayload2: Float64) -> Void { - return bjs_jsRoundTripJSValue_extern(vKind, vPayload1, vPayload2) -} - -func _$jsRoundTripJSValue(_ v: JSValue) throws(JSException) -> JSValue { - let (vKind, vPayload1, vPayload2) = v.bridgeJSLowerParameter() - bjs_jsRoundTripJSValue(vKind, vPayload1, vPayload2) - if let error = _swift_js_take_exception() { - throw error - } - return JSValue.bridgeJSLiftReturn() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrVoid") -fileprivate func bjs_jsThrowOrVoid_extern(_ shouldThrow: Int32) -> Void -#else -fileprivate func bjs_jsThrowOrVoid_extern(_ shouldThrow: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsThrowOrVoid(_ shouldThrow: Int32) -> Void { - return bjs_jsThrowOrVoid_extern(shouldThrow) -} - -func _$jsThrowOrVoid(_ shouldThrow: Bool) throws(JSException) -> Void { - let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() - bjs_jsThrowOrVoid(shouldThrowValue) - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrNumber") -fileprivate func bjs_jsThrowOrNumber_extern(_ shouldThrow: Int32) -> Float64 -#else -fileprivate func bjs_jsThrowOrNumber_extern(_ shouldThrow: Int32) -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsThrowOrNumber(_ shouldThrow: Int32) -> Float64 { - return bjs_jsThrowOrNumber_extern(shouldThrow) -} - -func _$jsThrowOrNumber(_ shouldThrow: Bool) throws(JSException) -> Double { - let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() - let ret = bjs_jsThrowOrNumber(shouldThrowValue) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrBool") -fileprivate func bjs_jsThrowOrBool_extern(_ shouldThrow: Int32) -> Int32 -#else -fileprivate func bjs_jsThrowOrBool_extern(_ shouldThrow: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsThrowOrBool(_ shouldThrow: Int32) -> Int32 { - return bjs_jsThrowOrBool_extern(shouldThrow) -} - -func _$jsThrowOrBool(_ shouldThrow: Bool) throws(JSException) -> Bool { - let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() - let ret = bjs_jsThrowOrBool(shouldThrowValue) - if let error = _swift_js_take_exception() { - throw error - } - return Bool.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsThrowOrString") -fileprivate func bjs_jsThrowOrString_extern(_ shouldThrow: Int32) -> Int32 -#else -fileprivate func bjs_jsThrowOrString_extern(_ shouldThrow: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsThrowOrString(_ shouldThrow: Int32) -> Int32 { - return bjs_jsThrowOrString_extern(shouldThrow) -} - -func _$jsThrowOrString(_ shouldThrow: Bool) throws(JSException) -> String { - let shouldThrowValue = shouldThrow.bridgeJSLowerParameter() - let ret = bjs_jsThrowOrString(shouldThrowValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripFeatureFlag") -fileprivate func bjs_jsRoundTripFeatureFlag_extern(_ flagBytes: Int32, _ flagLength: Int32) -> Int32 -#else -fileprivate func bjs_jsRoundTripFeatureFlag_extern(_ flagBytes: Int32, _ flagLength: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsRoundTripFeatureFlag(_ flagBytes: Int32, _ flagLength: Int32) -> Int32 { - return bjs_jsRoundTripFeatureFlag_extern(flagBytes, flagLength) -} - -func _$jsRoundTripFeatureFlag(_ flag: FeatureFlag) throws(JSException) -> FeatureFlag { - let ret0 = flag.bridgeJSWithLoweredParameter { (flagBytes, flagLength) in - let ret = bjs_jsRoundTripFeatureFlag(flagBytes, flagLength) - return ret - } - let ret = ret0 - if let error = _swift_js_take_exception() { - throw error - } - return FeatureFlag.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_runAsyncWorks") -fileprivate func bjs_runAsyncWorks_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void -#else -fileprivate func bjs_runAsyncWorks_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_runAsyncWorks(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - return bjs_runAsyncWorks_extern(resolveRef, rejectRef) -} - -func _$runAsyncWorks() async throws(JSException) -> Void { - try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<() -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - bjs_runAsyncWorks(resolveRef, rejectRef) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_fetchWeatherData") -fileprivate func bjs_fetchWeatherData_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ cityBytes: Int32, _ cityLength: Int32) -> Void -#else -fileprivate func bjs_fetchWeatherData_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ cityBytes: Int32, _ cityLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_fetchWeatherData(_ resolveRef: Int32, _ rejectRef: Int32, _ cityBytes: Int32, _ cityLength: Int32) -> Void { - return bjs_fetchWeatherData_extern(resolveRef, rejectRef, cityBytes, cityLength) -} - -func _$fetchWeatherData(_ city: String) async throws(JSException) -> WeatherData { - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending WeatherData) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - city.bridgeJSWithLoweredParameter { (cityBytes, cityLength) in - bjs_fetchWeatherData(resolveRef, rejectRef, cityBytes, cityLength) - } - } - return resolved -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs__jsWeirdFunction") -fileprivate func bjs__jsWeirdFunction_extern() -> Float64 -#else -fileprivate func bjs__jsWeirdFunction_extern() -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs__jsWeirdFunction() -> Float64 { - return bjs__jsWeirdFunction_extern() -} - -func _$_jsWeirdFunction() throws(JSException) -> Double { - let ret = bjs__jsWeirdFunction() - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_parseInt") -fileprivate func bjs_parseInt_extern(_ stringBytes: Int32, _ stringLength: Int32) -> Float64 -#else -fileprivate func bjs_parseInt_extern(_ stringBytes: Int32, _ stringLength: Int32) -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_parseInt(_ stringBytes: Int32, _ stringLength: Int32) -> Float64 { - return bjs_parseInt_extern(stringBytes, stringLength) -} - -func _$parseInt(_ string: String) throws(JSException) -> Double { - let ret0 = string.bridgeJSWithLoweredParameter { (stringBytes, stringLength) in - let ret = bjs_parseInt(stringBytes, stringLength) - return ret - } - let ret = ret0 - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_init") -fileprivate func bjs_JsGreeter_init_extern(_ nameBytes: Int32, _ nameLength: Int32, _ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 -#else -fileprivate func bjs_JsGreeter_init_extern(_ nameBytes: Int32, _ nameLength: Int32, _ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JsGreeter_init(_ nameBytes: Int32, _ nameLength: Int32, _ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { - return bjs_JsGreeter_init_extern(nameBytes, nameLength, prefixBytes, prefixLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_name_get") -fileprivate func bjs_JsGreeter_name_get_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs_JsGreeter_name_get_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JsGreeter_name_get(_ self: Int32) -> Int32 { - return bjs_JsGreeter_name_get_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_prefix_get") -fileprivate func bjs_JsGreeter_prefix_get_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs_JsGreeter_prefix_get_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JsGreeter_prefix_get(_ self: Int32) -> Int32 { - return bjs_JsGreeter_prefix_get_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_name_set") -fileprivate func bjs_JsGreeter_name_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void -#else -fileprivate func bjs_JsGreeter_name_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JsGreeter_name_set(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { - return bjs_JsGreeter_name_set_extern(self, newValueBytes, newValueLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_greet") -fileprivate func bjs_JsGreeter_greet_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs_JsGreeter_greet_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JsGreeter_greet(_ self: Int32) -> Int32 { - return bjs_JsGreeter_greet_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JsGreeter_changeName") -fileprivate func bjs_JsGreeter_changeName_extern(_ self: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void -#else -fileprivate func bjs_JsGreeter_changeName_extern(_ self: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JsGreeter_changeName(_ self: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { - return bjs_JsGreeter_changeName_extern(self, nameBytes, nameLength) -} - -func _$JsGreeter_init(_ name: String, _ prefix: String) throws(JSException) -> JSObject { - let ret0 = name.bridgeJSWithLoweredParameter { (nameBytes, nameLength) in - let ret1 = prefix.bridgeJSWithLoweredParameter { (prefixBytes, prefixLength) in - let ret = bjs_JsGreeter_init(nameBytes, nameLength, prefixBytes, prefixLength) - return ret - } - return ret1 - } - let ret = ret0 - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) -} - -func _$JsGreeter_name_get(_ self: JSObject) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_JsGreeter_name_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -func _$JsGreeter_prefix_get(_ self: JSObject) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_JsGreeter_prefix_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -func _$JsGreeter_name_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - newValue.bridgeJSWithLoweredParameter { (newValueBytes, newValueLength) in - bjs_JsGreeter_name_set(selfValue, newValueBytes, newValueLength) - } - if let error = _swift_js_take_exception() { - throw error - } -} - -func _$JsGreeter_greet(_ self: JSObject) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_JsGreeter_greet(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -func _$JsGreeter_changeName(_ self: JSObject, _ name: String) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - name.bridgeJSWithLoweredParameter { (nameBytes, nameLength) in - bjs_JsGreeter_changeName(selfValue, nameBytes, nameLength) - } - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_temperature_get") -fileprivate func bjs_WeatherData_temperature_get_extern(_ self: Int32) -> Float64 -#else -fileprivate func bjs_WeatherData_temperature_get_extern(_ self: Int32) -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_WeatherData_temperature_get(_ self: Int32) -> Float64 { - return bjs_WeatherData_temperature_get_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_description_get") -fileprivate func bjs_WeatherData_description_get_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs_WeatherData_description_get_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_WeatherData_description_get(_ self: Int32) -> Int32 { - return bjs_WeatherData_description_get_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_humidity_get") -fileprivate func bjs_WeatherData_humidity_get_extern(_ self: Int32) -> Float64 -#else -fileprivate func bjs_WeatherData_humidity_get_extern(_ self: Int32) -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_WeatherData_humidity_get(_ self: Int32) -> Float64 { - return bjs_WeatherData_humidity_get_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_temperature_set") -fileprivate func bjs_WeatherData_temperature_set_extern(_ self: Int32, _ newValue: Float64) -> Void -#else -fileprivate func bjs_WeatherData_temperature_set_extern(_ self: Int32, _ newValue: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_WeatherData_temperature_set(_ self: Int32, _ newValue: Float64) -> Void { - return bjs_WeatherData_temperature_set_extern(self, newValue) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_description_set") -fileprivate func bjs_WeatherData_description_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void -#else -fileprivate func bjs_WeatherData_description_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_WeatherData_description_set(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { - return bjs_WeatherData_description_set_extern(self, newValueBytes, newValueLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_humidity_set") -fileprivate func bjs_WeatherData_humidity_set_extern(_ self: Int32, _ newValue: Float64) -> Void -#else -fileprivate func bjs_WeatherData_humidity_set_extern(_ self: Int32, _ newValue: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_WeatherData_humidity_set(_ self: Int32, _ newValue: Float64) -> Void { - return bjs_WeatherData_humidity_set_extern(self, newValue) -} - -func _$WeatherData_temperature_get(_ self: JSObject) throws(JSException) -> Double { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_WeatherData_temperature_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -func _$WeatherData_description_get(_ self: JSObject) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_WeatherData_description_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -func _$WeatherData_humidity_get(_ self: JSObject) throws(JSException) -> Double { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_WeatherData_humidity_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -func _$WeatherData_temperature_set(_ self: JSObject, _ newValue: Double) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let newValueValue = newValue.bridgeJSLowerParameter() - bjs_WeatherData_temperature_set(selfValue, newValueValue) - if let error = _swift_js_take_exception() { - throw error - } -} - -func _$WeatherData_description_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - newValue.bridgeJSWithLoweredParameter { (newValueBytes, newValueLength) in - bjs_WeatherData_description_set(selfValue, newValueBytes, newValueLength) - } - if let error = _swift_js_take_exception() { - throw error - } -} - -func _$WeatherData_humidity_set(_ self: JSObject, _ newValue: Double) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let newValueValue = newValue.bridgeJSLowerParameter() - bjs_WeatherData_humidity_set(selfValue, newValueValue) - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs__WeirdClass_init") -fileprivate func bjs__WeirdClass_init_extern() -> Int32 -#else -fileprivate func bjs__WeirdClass_init_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs__WeirdClass_init() -> Int32 { - return bjs__WeirdClass_init_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs__WeirdClass_method_with_dashes") -fileprivate func bjs__WeirdClass_method_with_dashes_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs__WeirdClass_method_with_dashes_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs__WeirdClass_method_with_dashes(_ self: Int32) -> Int32 { - return bjs__WeirdClass_method_with_dashes_extern(self) -} - -func _$_WeirdClass_init() throws(JSException) -> JSObject { - let ret = bjs__WeirdClass_init() - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) -} - -func _$_WeirdClass_method_with_dashes(_ self: JSObject) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs__WeirdClass_method_with_dashes(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_init") -fileprivate func bjs_StaticBox_init_extern(_ value: Float64) -> Int32 -#else -fileprivate func bjs_StaticBox_init_extern(_ value: Float64) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_StaticBox_init(_ value: Float64) -> Int32 { - return bjs_StaticBox_init_extern(value) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_create_static") -fileprivate func bjs_StaticBox_create_static_extern(_ value: Float64) -> Int32 -#else -fileprivate func bjs_StaticBox_create_static_extern(_ value: Float64) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_StaticBox_create_static(_ value: Float64) -> Int32 { - return bjs_StaticBox_create_static_extern(value) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_value_static") -fileprivate func bjs_StaticBox_value_static_extern() -> Float64 -#else -fileprivate func bjs_StaticBox_value_static_extern() -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_StaticBox_value_static() -> Float64 { - return bjs_StaticBox_value_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_makeDefault_static") -fileprivate func bjs_StaticBox_makeDefault_static_extern() -> Int32 -#else -fileprivate func bjs_StaticBox_makeDefault_static_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_StaticBox_makeDefault_static() -> Int32 { - return bjs_StaticBox_makeDefault_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_with_dashes_static") -fileprivate func bjs_StaticBox_with_dashes_static_extern() -> Int32 -#else -fileprivate func bjs_StaticBox_with_dashes_static_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_StaticBox_with_dashes_static() -> Int32 { - return bjs_StaticBox_with_dashes_static_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_StaticBox_value") -fileprivate func bjs_StaticBox_value_extern(_ self: Int32) -> Float64 -#else -fileprivate func bjs_StaticBox_value_extern(_ self: Int32) -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_StaticBox_value(_ self: Int32) -> Float64 { - return bjs_StaticBox_value_extern(self) -} - -func _$StaticBox_init(_ value: Double) throws(JSException) -> JSObject { - let valueValue = value.bridgeJSLowerParameter() - let ret = bjs_StaticBox_init(valueValue) - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) -} - -func _$StaticBox_create(_ value: Double) throws(JSException) -> StaticBox { - let valueValue = value.bridgeJSLowerParameter() - let ret = bjs_StaticBox_create_static(valueValue) - if let error = _swift_js_take_exception() { - throw error - } - return StaticBox.bridgeJSLiftReturn(ret) -} - -func _$StaticBox_value() throws(JSException) -> Double { - let ret = bjs_StaticBox_value_static() - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -func _$StaticBox_makeDefault() throws(JSException) -> StaticBox { - let ret = bjs_StaticBox_makeDefault_static() - if let error = _swift_js_take_exception() { - throw error - } - return StaticBox.bridgeJSLiftReturn(ret) -} - -func _$StaticBox_with_dashes() throws(JSException) -> StaticBox { - let ret = bjs_StaticBox_with_dashes_static() - if let error = _swift_js_take_exception() { - throw error - } - return StaticBox.bridgeJSLiftReturn(ret) -} - -func _$StaticBox_value(_ self: JSObject) throws(JSException) -> Double { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_StaticBox_value(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_init") -fileprivate func bjs_Animal_init_extern(_ nameBytes: Int32, _ nameLength: Int32, _ age: Float64, _ isCat: Int32) -> Int32 -#else -fileprivate func bjs_Animal_init_extern(_ nameBytes: Int32, _ nameLength: Int32, _ age: Float64, _ isCat: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_Animal_init(_ nameBytes: Int32, _ nameLength: Int32, _ age: Float64, _ isCat: Int32) -> Int32 { - return bjs_Animal_init_extern(nameBytes, nameLength, age, isCat) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_name_get") -fileprivate func bjs_Animal_name_get_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs_Animal_name_get_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_Animal_name_get(_ self: Int32) -> Int32 { - return bjs_Animal_name_get_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_age_get") -fileprivate func bjs_Animal_age_get_extern(_ self: Int32) -> Float64 -#else -fileprivate func bjs_Animal_age_get_extern(_ self: Int32) -> Float64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_Animal_age_get(_ self: Int32) -> Float64 { - return bjs_Animal_age_get_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_isCat_get") -fileprivate func bjs_Animal_isCat_get_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs_Animal_isCat_get_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_Animal_isCat_get(_ self: Int32) -> Int32 { - return bjs_Animal_isCat_get_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_name_set") -fileprivate func bjs_Animal_name_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void -#else -fileprivate func bjs_Animal_name_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_Animal_name_set(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { - return bjs_Animal_name_set_extern(self, newValueBytes, newValueLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_age_set") -fileprivate func bjs_Animal_age_set_extern(_ self: Int32, _ newValue: Float64) -> Void -#else -fileprivate func bjs_Animal_age_set_extern(_ self: Int32, _ newValue: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_Animal_age_set(_ self: Int32, _ newValue: Float64) -> Void { - return bjs_Animal_age_set_extern(self, newValue) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_isCat_set") -fileprivate func bjs_Animal_isCat_set_extern(_ self: Int32, _ newValue: Int32) -> Void -#else -fileprivate func bjs_Animal_isCat_set_extern(_ self: Int32, _ newValue: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_Animal_isCat_set(_ self: Int32, _ newValue: Int32) -> Void { - return bjs_Animal_isCat_set_extern(self, newValue) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_bark") -fileprivate func bjs_Animal_bark_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs_Animal_bark_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_Animal_bark(_ self: Int32) -> Int32 { - return bjs_Animal_bark_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Animal_getIsCat") -fileprivate func bjs_Animal_getIsCat_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs_Animal_getIsCat_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_Animal_getIsCat(_ self: Int32) -> Int32 { - return bjs_Animal_getIsCat_extern(self) -} - -func _$Animal_init(_ name: String, _ age: Double, _ isCat: Bool) throws(JSException) -> JSObject { - let ret0 = name.bridgeJSWithLoweredParameter { (nameBytes, nameLength) in - let ageValue = age.bridgeJSLowerParameter() - let isCatValue = isCat.bridgeJSLowerParameter() - let ret = bjs_Animal_init(nameBytes, nameLength, ageValue, isCatValue) - return ret - } - let ret = ret0 - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) -} - -func _$Animal_name_get(_ self: JSObject) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_Animal_name_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -func _$Animal_age_get(_ self: JSObject) throws(JSException) -> Double { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_Animal_age_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return Double.bridgeJSLiftReturn(ret) -} - -func _$Animal_isCat_get(_ self: JSObject) throws(JSException) -> Bool { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_Animal_isCat_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return Bool.bridgeJSLiftReturn(ret) -} - -func _$Animal_name_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - newValue.bridgeJSWithLoweredParameter { (newValueBytes, newValueLength) in - bjs_Animal_name_set(selfValue, newValueBytes, newValueLength) - } - if let error = _swift_js_take_exception() { - throw error - } -} - -func _$Animal_age_set(_ self: JSObject, _ newValue: Double) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let newValueValue = newValue.bridgeJSLowerParameter() - bjs_Animal_age_set(selfValue, newValueValue) - if let error = _swift_js_take_exception() { - throw error - } -} - -func _$Animal_isCat_set(_ self: JSObject, _ newValue: Bool) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let newValueValue = newValue.bridgeJSLowerParameter() - bjs_Animal_isCat_set(selfValue, newValueValue) - if let error = _swift_js_take_exception() { - throw error - } -} - -func _$Animal_bark(_ self: JSObject) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_Animal_bark(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -func _$Animal_getIsCat(_ self: JSObject) throws(JSException) -> Bool { - let selfValue = self.bridgeJSLowerParameter() - let ret = bjs_Animal_getIsCat(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return Bool.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static") -fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() -> Void -#else -fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static() -> Void { - return bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static_extern() -} - -func _$IdentityModeSupportImports_runJsIdentityModeSupportTests() throws(JSException) -> Void { - bjs_IdentityModeSupportImports_runJsIdentityModeSupportTests_static() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsTranslatePoint") -fileprivate func bjs_jsTranslatePoint_extern(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 -#else -fileprivate func bjs_jsTranslatePoint_extern(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsTranslatePoint(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 { - return bjs_jsTranslatePoint_extern(point, dx, dy) -} - -func _$jsTranslatePoint(_ point: Point, _ dx: Int, _ dy: Int) throws(JSException) -> Point { - let pointObjectId = point.bridgeJSLowerParameter() - let dxValue = dx.bridgeJSLowerParameter() - let dyValue = dy.bridgeJSLowerParameter() - let ret = bjs_jsTranslatePoint(pointObjectId, dxValue, dyValue) - if let error = _swift_js_take_exception() { - throw error - } - return Point.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt_static") -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt_static_extern(_ v: Int32) -> Int32 -#else -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt_static_extern(_ v: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt_static(_ v: Int32) -> Int32 { - return bjs_IntegerTypesSupportImports_jsRoundTripInt_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripUInt_static") -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt_static_extern(_ v: Int32) -> Int32 -#else -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt_static_extern(_ v: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt_static(_ v: Int32) -> Int32 { - return bjs_IntegerTypesSupportImports_jsRoundTripUInt_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt8_static") -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt8_static_extern(_ v: Int32) -> Int32 -#else -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt8_static_extern(_ v: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt8_static(_ v: Int32) -> Int32 { - return bjs_IntegerTypesSupportImports_jsRoundTripInt8_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static") -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static_extern(_ v: Int32) -> Int32 -#else -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static_extern(_ v: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static(_ v: Int32) -> Int32 { - return bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt16_static") -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt16_static_extern(_ v: Int32) -> Int32 -#else -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt16_static_extern(_ v: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt16_static(_ v: Int32) -> Int32 { - return bjs_IntegerTypesSupportImports_jsRoundTripInt16_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static") -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static_extern(_ v: Int32) -> Int32 -#else -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static_extern(_ v: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static(_ v: Int32) -> Int32 { - return bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt32_static") -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt32_static_extern(_ v: Int32) -> Int32 -#else -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt32_static_extern(_ v: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt32_static(_ v: Int32) -> Int32 { - return bjs_IntegerTypesSupportImports_jsRoundTripInt32_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static") -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static_extern(_ v: Int32) -> Int32 -#else -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static_extern(_ v: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static(_ v: Int32) -> Int32 { - return bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt64_static") -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt64_static_extern(_ v: Int64) -> Int64 -#else -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt64_static_extern(_ v: Int64) -> Int64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt64_static(_ v: Int64) -> Int64 { - return bjs_IntegerTypesSupportImports_jsRoundTripInt64_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static") -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static_extern(_ v: Int64) -> Int64 -#else -fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static_extern(_ v: Int64) -> Int64 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static(_ v: Int64) -> Int64 { - return bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static") -fileprivate func bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static_extern() -> Void -#else -fileprivate func bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static() -> Void { - return bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static_extern() -} - -func _$IntegerTypesSupportImports_jsRoundTripInt(_ v: Int) throws(JSException) -> Int { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_IntegerTypesSupportImports_jsRoundTripInt_static(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return Int.bridgeJSLiftReturn(ret) -} - -func _$IntegerTypesSupportImports_jsRoundTripUInt(_ v: UInt) throws(JSException) -> UInt { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_IntegerTypesSupportImports_jsRoundTripUInt_static(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return UInt.bridgeJSLiftReturn(ret) -} - -func _$IntegerTypesSupportImports_jsRoundTripInt8(_ v: Int8) throws(JSException) -> Int8 { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_IntegerTypesSupportImports_jsRoundTripInt8_static(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return Int8.bridgeJSLiftReturn(ret) -} - -func _$IntegerTypesSupportImports_jsRoundTripUInt8(_ v: UInt8) throws(JSException) -> UInt8 { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_IntegerTypesSupportImports_jsRoundTripUInt8_static(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return UInt8.bridgeJSLiftReturn(ret) -} - -func _$IntegerTypesSupportImports_jsRoundTripInt16(_ v: Int16) throws(JSException) -> Int16 { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_IntegerTypesSupportImports_jsRoundTripInt16_static(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return Int16.bridgeJSLiftReturn(ret) -} - -func _$IntegerTypesSupportImports_jsRoundTripUInt16(_ v: UInt16) throws(JSException) -> UInt16 { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_IntegerTypesSupportImports_jsRoundTripUInt16_static(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return UInt16.bridgeJSLiftReturn(ret) -} - -func _$IntegerTypesSupportImports_jsRoundTripInt32(_ v: Int32) throws(JSException) -> Int32 { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_IntegerTypesSupportImports_jsRoundTripInt32_static(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return Int32.bridgeJSLiftReturn(ret) -} - -func _$IntegerTypesSupportImports_jsRoundTripUInt32(_ v: UInt32) throws(JSException) -> UInt32 { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_IntegerTypesSupportImports_jsRoundTripUInt32_static(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return UInt32.bridgeJSLiftReturn(ret) -} - -func _$IntegerTypesSupportImports_jsRoundTripInt64(_ v: Int64) throws(JSException) -> Int64 { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_IntegerTypesSupportImports_jsRoundTripInt64_static(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return Int64.bridgeJSLiftReturn(ret) -} - -func _$IntegerTypesSupportImports_jsRoundTripUInt64(_ v: UInt64) throws(JSException) -> UInt64 { - let vValue = v.bridgeJSLowerParameter() - let ret = bjs_IntegerTypesSupportImports_jsRoundTripUInt64_static(vValue) - if let error = _swift_js_take_exception() { - throw error - } - return UInt64.bridgeJSLiftReturn(ret) -} - -func _$IntegerTypesSupportImports_runJsIntegerTypesSupportTests() throws(JSException) -> Void { - bjs_IntegerTypesSupportImports_runJsIntegerTypesSupportTests_static() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_init") -fileprivate func bjs_JSClassWithArrayMembers_init_extern() -> Int32 -#else -fileprivate func bjs_JSClassWithArrayMembers_init_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JSClassWithArrayMembers_init() -> Int32 { - return bjs_JSClassWithArrayMembers_init_extern() -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_numbers_get") -fileprivate func bjs_JSClassWithArrayMembers_numbers_get_extern(_ self: Int32) -> Void -#else -fileprivate func bjs_JSClassWithArrayMembers_numbers_get_extern(_ self: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JSClassWithArrayMembers_numbers_get(_ self: Int32) -> Void { - return bjs_JSClassWithArrayMembers_numbers_get_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_labels_get") -fileprivate func bjs_JSClassWithArrayMembers_labels_get_extern(_ self: Int32) -> Void -#else -fileprivate func bjs_JSClassWithArrayMembers_labels_get_extern(_ self: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JSClassWithArrayMembers_labels_get(_ self: Int32) -> Void { - return bjs_JSClassWithArrayMembers_labels_get_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_numbers_set") -fileprivate func bjs_JSClassWithArrayMembers_numbers_set_extern(_ self: Int32) -> Void -#else -fileprivate func bjs_JSClassWithArrayMembers_numbers_set_extern(_ self: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JSClassWithArrayMembers_numbers_set(_ self: Int32) -> Void { - return bjs_JSClassWithArrayMembers_numbers_set_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_labels_set") -fileprivate func bjs_JSClassWithArrayMembers_labels_set_extern(_ self: Int32) -> Void -#else -fileprivate func bjs_JSClassWithArrayMembers_labels_set_extern(_ self: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JSClassWithArrayMembers_labels_set(_ self: Int32) -> Void { - return bjs_JSClassWithArrayMembers_labels_set_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_concatNumbers") -fileprivate func bjs_JSClassWithArrayMembers_concatNumbers_extern(_ self: Int32) -> Void -#else -fileprivate func bjs_JSClassWithArrayMembers_concatNumbers_extern(_ self: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JSClassWithArrayMembers_concatNumbers(_ self: Int32) -> Void { - return bjs_JSClassWithArrayMembers_concatNumbers_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_concatLabels") -fileprivate func bjs_JSClassWithArrayMembers_concatLabels_extern(_ self: Int32) -> Void -#else -fileprivate func bjs_JSClassWithArrayMembers_concatLabels_extern(_ self: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JSClassWithArrayMembers_concatLabels(_ self: Int32) -> Void { - return bjs_JSClassWithArrayMembers_concatLabels_extern(self) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassWithArrayMembers_firstLabel") -fileprivate func bjs_JSClassWithArrayMembers_firstLabel_extern(_ self: Int32) -> Int32 -#else -fileprivate func bjs_JSClassWithArrayMembers_firstLabel_extern(_ self: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JSClassWithArrayMembers_firstLabel(_ self: Int32) -> Int32 { - return bjs_JSClassWithArrayMembers_firstLabel_extern(self) -} - -func _$JSClassWithArrayMembers_init(_ numbers: [Int], _ labels: [String]) throws(JSException) -> JSObject { - let _ = labels.bridgeJSLowerParameter() - let _ = numbers.bridgeJSLowerParameter() - let ret = bjs_JSClassWithArrayMembers_init() - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) -} - -func _$JSClassWithArrayMembers_numbers_get(_ self: JSObject) throws(JSException) -> [Int] { - let selfValue = self.bridgeJSLowerParameter() - bjs_JSClassWithArrayMembers_numbers_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return [Int].bridgeJSLiftReturn() -} - -func _$JSClassWithArrayMembers_labels_get(_ self: JSObject) throws(JSException) -> [String] { - let selfValue = self.bridgeJSLowerParameter() - bjs_JSClassWithArrayMembers_labels_get(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return [String].bridgeJSLiftReturn() -} - -func _$JSClassWithArrayMembers_numbers_set(_ self: JSObject, _ newValue: [Int]) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let _ = newValue.bridgeJSLowerParameter() - bjs_JSClassWithArrayMembers_numbers_set(selfValue) - if let error = _swift_js_take_exception() { - throw error - } -} - -func _$JSClassWithArrayMembers_labels_set(_ self: JSObject, _ newValue: [String]) throws(JSException) -> Void { - let selfValue = self.bridgeJSLowerParameter() - let _ = newValue.bridgeJSLowerParameter() - bjs_JSClassWithArrayMembers_labels_set(selfValue) - if let error = _swift_js_take_exception() { - throw error - } -} - -func _$JSClassWithArrayMembers_concatNumbers(_ self: JSObject, _ values: [Int]) throws(JSException) -> [Int] { - let selfValue = self.bridgeJSLowerParameter() - let _ = values.bridgeJSLowerParameter() - bjs_JSClassWithArrayMembers_concatNumbers(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return [Int].bridgeJSLiftReturn() -} - -func _$JSClassWithArrayMembers_concatLabels(_ self: JSObject, _ values: [String]) throws(JSException) -> [String] { - let selfValue = self.bridgeJSLowerParameter() - let _ = values.bridgeJSLowerParameter() - bjs_JSClassWithArrayMembers_concatLabels(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return [String].bridgeJSLiftReturn() -} - -func _$JSClassWithArrayMembers_firstLabel(_ self: JSObject, _ values: [String]) throws(JSException) -> String { - let selfValue = self.bridgeJSLowerParameter() - let _ = values.bridgeJSLowerParameter() - let ret = bjs_JSClassWithArrayMembers_firstLabel(selfValue) - if let error = _swift_js_take_exception() { - throw error - } - return String.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static") -fileprivate func bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static_extern() -> Int32 -#else -fileprivate func bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static() -> Int32 { - return bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static_extern() -} - -func _$JSClassSupportImports_makeJSClassWithArrayMembers(_ numbers: [Int], _ labels: [String]) throws(JSException) -> JSClassWithArrayMembers { - let _ = labels.bridgeJSLowerParameter() - let _ = numbers.bridgeJSLowerParameter() - let ret = bjs_JSClassSupportImports_makeJSClassWithArrayMembers_static() - if let error = _swift_js_take_exception() { - throw error - } - return JSClassWithArrayMembers.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_MyJSClassInternal_init") -fileprivate func bjs_MyJSClassInternal_init_extern() -> Int32 -#else -fileprivate func bjs_MyJSClassInternal_init_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_MyJSClassInternal_init() -> Int32 { - return bjs_MyJSClassInternal_init_extern() -} - -func _$MyJSClassInternal_init() throws(JSException) -> JSObject { - let ret = bjs_MyJSClassInternal_init() - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_MyJSClassPublic_init") -fileprivate func bjs_MyJSClassPublic_init_extern() -> Int32 -#else -fileprivate func bjs_MyJSClassPublic_init_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_MyJSClassPublic_init() -> Int32 { - return bjs_MyJSClassPublic_init_extern() -} - -func _$MyJSClassPublic_init() throws(JSException) -> JSObject { - let ret = bjs_MyJSClassPublic_init() - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_MyJSClassPackage_init") -fileprivate func bjs_MyJSClassPackage_init_extern() -> Int32 -#else -fileprivate func bjs_MyJSClassPackage_init_extern() -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_MyJSClassPackage_init() -> Int32 { - return bjs_MyJSClassPackage_init_extern() -} - -func _$MyJSClassPackage_init() throws(JSException) -> JSObject { - let ret = bjs_MyJSClassPackage_init() - if let error = _swift_js_take_exception() { - throw error - } - return JSObject.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsFunctionWithPackageAccess") -fileprivate func bjs_jsFunctionWithPackageAccess_extern() -> Void -#else -fileprivate func bjs_jsFunctionWithPackageAccess_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsFunctionWithPackageAccess() -> Void { - return bjs_jsFunctionWithPackageAccess_extern() -} - -func _$jsFunctionWithPackageAccess() throws(JSException) -> Void { - bjs_jsFunctionWithPackageAccess() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsFunctionWithPublicAccess") -fileprivate func bjs_jsFunctionWithPublicAccess_extern() -> Void -#else -fileprivate func bjs_jsFunctionWithPublicAccess_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsFunctionWithPublicAccess() -> Void { - return bjs_jsFunctionWithPublicAccess_extern() -} - -func _$jsFunctionWithPublicAccess() throws(JSException) -> Void { - bjs_jsFunctionWithPublicAccess() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsFunctionWithInternalAccess") -fileprivate func bjs_jsFunctionWithInternalAccess_extern() -> Void -#else -fileprivate func bjs_jsFunctionWithInternalAccess_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsFunctionWithInternalAccess() -> Void { - return bjs_jsFunctionWithInternalAccess_extern() -} - -func _$jsFunctionWithInternalAccess() throws(JSException) -> Void { - bjs_jsFunctionWithInternalAccess() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsFunctionWithFilePrivateAccess") -fileprivate func bjs_jsFunctionWithFilePrivateAccess_extern() -> Void -#else -fileprivate func bjs_jsFunctionWithFilePrivateAccess_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsFunctionWithFilePrivateAccess() -> Void { - return bjs_jsFunctionWithFilePrivateAccess_extern() -} - -func _$jsFunctionWithFilePrivateAccess() throws(JSException) -> Void { - bjs_jsFunctionWithFilePrivateAccess() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsFunctionWithPrivateAccess") -fileprivate func bjs_jsFunctionWithPrivateAccess_extern() -> Void -#else -fileprivate func bjs_jsFunctionWithPrivateAccess_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsFunctionWithPrivateAccess() -> Void { - return bjs_jsFunctionWithPrivateAccess_extern() -} - -func _$jsFunctionWithPrivateAccess() throws(JSException) -> Void { - bjs_jsFunctionWithPrivateAccess() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static") -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void -#else -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { - return bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static_extern(valueIsSome, valueValue) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static") -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void -#else -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { - return bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static_extern(valueIsSome, valueValue) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static") -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static_extern(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void -#else -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static_extern(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { - return bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static_extern(nameIsSome, nameBytes, nameLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static") -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static_extern(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void -#else -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static_extern(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static(_ nameIsSome: Int32, _ nameBytes: Int32, _ nameLength: Int32) -> Void { - return bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static_extern(nameIsSome, nameBytes, nameLength) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static") -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static_extern(_ v: Int32) -> Void -#else -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static_extern(_ v: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static(_ v: Int32) -> Void { - return bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static") -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static_extern(_ v: Int32) -> Void -#else -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static_extern(_ v: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static(_ v: Int32) -> Void { - return bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static") -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static_extern(_ v: Int32) -> Void -#else -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static_extern(_ v: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static(_ v: Int32) -> Void { - return bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static") -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static_extern(_ v: Int32) -> Void -#else -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static_extern(_ v: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static(_ v: Int32) -> Void { - return bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static_extern(v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_runJsOptionalSupportTests_static") -fileprivate func bjs_OptionalSupportImports_runJsOptionalSupportTests_static_extern() -> Void -#else -fileprivate func bjs_OptionalSupportImports_runJsOptionalSupportTests_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_OptionalSupportImports_runJsOptionalSupportTests_static() -> Void { - return bjs_OptionalSupportImports_runJsOptionalSupportTests_static_extern() -} - -func _$OptionalSupportImports_jsRoundTripOptionalNumberNull(_ value: Optional) throws(JSException) -> Optional { - let (valueIsSome, valueValue) = value.bridgeJSLowerParameter() - bjs_OptionalSupportImports_jsRoundTripOptionalNumberNull_static(valueIsSome, valueValue) - if let error = _swift_js_take_exception() { - throw error - } - return Optional.bridgeJSLiftReturnFromSideChannel() -} - -func _$OptionalSupportImports_jsRoundTripOptionalNumberUndefined(_ value: JSUndefinedOr) throws(JSException) -> JSUndefinedOr { - let (valueIsSome, valueValue) = value.bridgeJSLowerParameter() - bjs_OptionalSupportImports_jsRoundTripOptionalNumberUndefined_static(valueIsSome, valueValue) - if let error = _swift_js_take_exception() { - throw error - } - return JSUndefinedOr.bridgeJSLiftReturnFromSideChannel() -} - -func _$OptionalSupportImports_jsRoundTripOptionalStringNull(_ name: Optional) throws(JSException) -> Optional { - name.bridgeJSWithLoweredParameter { (nameIsSome, nameBytes, nameLength) in - bjs_OptionalSupportImports_jsRoundTripOptionalStringNull_static(nameIsSome, nameBytes, nameLength) - } - if let error = _swift_js_take_exception() { - throw error - } - return Optional.bridgeJSLiftReturnFromSideChannel() -} - -func _$OptionalSupportImports_jsRoundTripOptionalStringUndefined(_ name: JSUndefinedOr) throws(JSException) -> JSUndefinedOr { - name.bridgeJSWithLoweredParameter { (nameIsSome, nameBytes, nameLength) in - bjs_OptionalSupportImports_jsRoundTripOptionalStringUndefined_static(nameIsSome, nameBytes, nameLength) - } - if let error = _swift_js_take_exception() { - throw error - } - return JSUndefinedOr.bridgeJSLiftReturnFromSideChannel() -} - -func _$OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull(_ v: Optional<[JSValue]>) throws(JSException) -> Optional<[JSValue]> { - let vIsSome = v.bridgeJSLowerParameter() - bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayNull_static(vIsSome) - if let error = _swift_js_take_exception() { - throw error - } - return Optional<[JSValue]>.bridgeJSLiftReturn() -} - -func _$OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined(_ v: JSUndefinedOr<[JSValue]>) throws(JSException) -> JSUndefinedOr<[JSValue]> { - let vIsSome = v.bridgeJSLowerParameter() - bjs_OptionalSupportImports_jsRoundTripOptionalJSValueArrayUndefined_static(vIsSome) - if let error = _swift_js_take_exception() { - throw error - } - return JSUndefinedOr<[JSValue]>.bridgeJSLiftReturn() -} - -func _$OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull(_ v: Optional<[String: String]>) throws(JSException) -> Optional<[String: String]> { - let vIsSome = v.bridgeJSLowerParameter() - bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryNull_static(vIsSome) - if let error = _swift_js_take_exception() { - throw error - } - return Optional<[String: String]>.bridgeJSLiftReturn() -} - -func _$OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined(_ v: JSUndefinedOr<[String: String]>) throws(JSException) -> JSUndefinedOr<[String: String]> { - let vIsSome = v.bridgeJSLowerParameter() - bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static(vIsSome) - if let error = _swift_js_take_exception() { - throw error - } - return JSUndefinedOr<[String: String]>.bridgeJSLiftReturn() -} - -func _$OptionalSupportImports_runJsOptionalSupportTests() throws(JSException) -> Void { - bjs_OptionalSupportImports_runJsOptionalSupportTests_static() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_gc") -fileprivate func bjs_gc_extern() -> Void -#else -fileprivate func bjs_gc_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_gc() -> Void { - return bjs_gc_extern() -} - -func _$gc() throws(JSException) -> Void { - bjs_gc() - if let error = _swift_js_take_exception() { - throw error - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftClassSupportImports_jsRoundTripGreeter_static") -fileprivate func bjs_SwiftClassSupportImports_jsRoundTripGreeter_static_extern(_ greeter: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer -#else -fileprivate func bjs_SwiftClassSupportImports_jsRoundTripGreeter_static_extern(_ greeter: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_SwiftClassSupportImports_jsRoundTripGreeter_static(_ greeter: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - return bjs_SwiftClassSupportImports_jsRoundTripGreeter_static_extern(greeter) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftClassSupportImports_jsRoundTripUUID_static") -fileprivate func bjs_SwiftClassSupportImports_jsRoundTripUUID_static_extern(_ uuid: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer -#else -fileprivate func bjs_SwiftClassSupportImports_jsRoundTripUUID_static_extern(_ uuid: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_SwiftClassSupportImports_jsRoundTripUUID_static(_ uuid: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - return bjs_SwiftClassSupportImports_jsRoundTripUUID_static_extern(uuid) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static") -fileprivate func bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static_extern(_ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer -#else -fileprivate func bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static_extern(_ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static(_ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { - return bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static_extern(greeterIsSome, greeterPointer) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static") -fileprivate func bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static_extern(_ value: UnsafeMutableRawPointer) -> Void -#else -fileprivate func bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static_extern(_ value: UnsafeMutableRawPointer) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static(_ value: UnsafeMutableRawPointer) -> Void { - return bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static_extern(value) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static") -fileprivate func bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static_extern(_ valueIsSome: Int32, _ valuePointer: UnsafeMutableRawPointer) -> Void -#else -fileprivate func bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static_extern(_ valueIsSome: Int32, _ valuePointer: UnsafeMutableRawPointer) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static(_ valueIsSome: Int32, _ valuePointer: UnsafeMutableRawPointer) -> Void { - return bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static_extern(valueIsSome, valuePointer) -} - -func _$SwiftClassSupportImports_jsRoundTripGreeter(_ greeter: Greeter) throws(JSException) -> Greeter { - let greeterPointer = greeter.bridgeJSLowerParameter() - let ret = bjs_SwiftClassSupportImports_jsRoundTripGreeter_static(greeterPointer) - if let error = _swift_js_take_exception() { - throw error - } - return Greeter.bridgeJSLiftReturn(ret) -} - -func _$SwiftClassSupportImports_jsRoundTripUUID(_ uuid: UUID) throws(JSException) -> UUID { - let uuidPointer = uuid.bridgeJSLowerParameter() - let ret = bjs_SwiftClassSupportImports_jsRoundTripUUID_static(uuidPointer) - if let error = _swift_js_take_exception() { - throw error - } - return UUID.bridgeJSLiftReturn(ret) -} - -func _$SwiftClassSupportImports_jsRoundTripOptionalGreeter(_ greeter: Optional) throws(JSException) -> Optional { - let (greeterIsSome, greeterPointer) = greeter.bridgeJSLowerParameter() - let ret = bjs_SwiftClassSupportImports_jsRoundTripOptionalGreeter_static(greeterIsSome, greeterPointer) - if let error = _swift_js_take_exception() { - throw error - } - return Optional.bridgeJSLiftReturn(ret) -} - -func _$SwiftClassSupportImports_jsConsumeLeakCheck(_ value: LeakCheck) throws(JSException) -> Void { - let valuePointer = value.bridgeJSLowerParameter() - bjs_SwiftClassSupportImports_jsConsumeLeakCheck_static(valuePointer) - if let error = _swift_js_take_exception() { - throw error - } +@inline(never) fileprivate func bjs_IdentityModeTestImports_runJsIdentityModeTests_static() -> Void { + return bjs_IdentityModeTestImports_runJsIdentityModeTests_static_extern() } -func _$SwiftClassSupportImports_jsConsumeOptionalLeakCheck(_ value: Optional) throws(JSException) -> Void { - let (valueIsSome, valuePointer) = value.bridgeJSLowerParameter() - bjs_SwiftClassSupportImports_jsConsumeOptionalLeakCheck_static(valueIsSome, valuePointer) +func _$IdentityModeTestImports_runJsIdentityModeTests() throws(JSException) -> Void { + bjs_IdentityModeTestImports_runJsIdentityModeTests_static() if let error = _swift_js_take_exception() { throw error } diff --git a/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json index ccca68ceb..d30ca00f8 100644 --- a/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json @@ -2,329 +2,65 @@ "exported" : { "classes" : [ { - "methods" : [ - { - "abiName" : "bjs_ClosureSupportExports_static_makeIntToInt", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "makeIntToInt", - "parameters" : [ - { - "label" : "_", - "name" : "base", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - }, - "staticContext" : { - "className" : { - "_0" : "ClosureSupportExports" - } - } + "constructor" : { + "abiName" : "bjs_IdentityTestSubject_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false }, - { - "abiName" : "bjs_ClosureSupportExports_static_makeDoubleToDouble", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "makeDoubleToDouble", - "parameters" : [ - { - "label" : "_", - "name" : "base", - "type" : { - "double" : { - + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "double" : { - - } - } - ], - "returnType" : { - "double" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - }, - "staticContext" : { - "className" : { - "_0" : "ClosureSupportExports" - } } - }, - { - "abiName" : "bjs_ClosureSupportExports_static_makeStringToString", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "makeStringToString", - "parameters" : [ - { - "label" : "_", - "name" : "prefix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { + ] + }, + "methods" : [ - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - }, - "staticContext" : { - "className" : { - "_0" : "ClosureSupportExports" - } - } - }, + ], + "name" : "IdentityTestSubject", + "properties" : [ { - "abiName" : "bjs_ClosureSupportExports_static_makeJSIntToInt", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "makeJSIntToInt", - "parameters" : [ - { - "label" : "_", - "name" : "base", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "closure" : { + "isReadonly" : false, + "isStatic" : false, + "name" : "value", + "type" : { + "integer" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - }, - "staticContext" : { - "className" : { - "_0" : "ClosureSupportExports" - } - } - }, - { - "abiName" : "bjs_ClosureSupportExports_static_makeJSDoubleToDouble", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "makeJSDoubleToDouble", - "parameters" : [ - { - "label" : "_", - "name" : "base", - "type" : { - "double" : { - - } + "isSigned" : true, + "width" : "word" } } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "double" : { - - } - } - ], - "returnType" : { - "double" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - }, - "staticContext" : { - "className" : { - "_0" : "ClosureSupportExports" - } } }, { - "abiName" : "bjs_ClosureSupportExports_static_makeJSStringToString", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "makeJSStringToString", - "parameters" : [ - { - "label" : "_", - "name" : "prefix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "closure" : { + "isReadonly" : true, + "isStatic" : false, + "name" : "currentValue", + "type" : { + "integer" : { "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - }, - "staticContext" : { - "className" : { - "_0" : "ClosureSupportExports" + "isSigned" : true, + "width" : "word" + } } } } ], - "name" : "ClosureSupportExports", - "properties" : [ - - ], - "swiftCallName" : "ClosureSupportExports" + "swiftCallName" : "IdentityTestSubject" }, { "constructor" : { - "abiName" : "bjs_DefaultArgumentConstructorDefaults_init", + "abiName" : "bjs_RetainLeakSubject_init", "effects" : { "isAsync" : false, "isStatic" : false, @@ -332,27 +68,8 @@ }, "parameters" : [ { - "defaultValue" : { - "string" : { - "_0" : "Default" - } - }, - "label" : "name", - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "defaultValue" : { - "int" : { - "_0" : 42 - } - }, - "label" : "count", - "name" : "count", + "label" : "tag", + "name" : "tag", "type" : { "integer" : { "_0" : { @@ -361,92 +78,18 @@ } } } - }, - { - "defaultValue" : { - "bool" : { - "_0" : true - } - }, - "label" : "enabled", - "name" : "enabled", - "type" : { - "bool" : { - - } - } - }, - { - "defaultValue" : { - "enumCase" : { - "_0" : "Status", - "_1" : "success" - } - }, - "label" : "status", - "name" : "status", - "type" : { - "caseEnum" : { - "_0" : "Status" - } - } - }, - { - "defaultValue" : { - "null" : { - - } - }, - "label" : "tag", - "name" : "tag", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } } ] }, "methods" : [ - { - "abiName" : "bjs_DefaultArgumentConstructorDefaults_describe", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "describe", - "parameters" : [ - - ], - "returnType" : { - "string" : { - } - } - } ], - "name" : "DefaultArgumentConstructorDefaults", + "name" : "RetainLeakSubject", "properties" : [ { "isReadonly" : false, "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "count", + "name" : "tag", "type" : { "integer" : { "_0" : { @@ -455,48 +98,13 @@ } } } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "enabled", - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "status", - "type" : { - "caseEnum" : { - "_0" : "Status" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "tag", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } } ], - "swiftCallName" : "DefaultArgumentConstructorDefaults" + "swiftCallName" : "RetainLeakSubject" }, { "constructor" : { - "abiName" : "bjs_Greeter_init", + "abiName" : "bjs_ArrayIdentityElement_init", "effects" : { "isAsync" : false, "isStatic" : false, @@ -504,308 +112,163 @@ }, "parameters" : [ { - "label" : "name", - "name" : "name", + "label" : "tag", + "name" : "tag", "type" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ] }, - "explicitAccessControl" : "public", "methods" : [ - { - "abiName" : "bjs_Greeter_greet", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "greet", - "parameters" : [ - - ], - "returnType" : { - "string" : { - } - } - }, + ], + "name" : "ArrayIdentityElement", + "properties" : [ { - "abiName" : "bjs_Greeter_changeName", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "changeName", - "parameters" : [ - { - "label" : "name", - "name" : "name", - "type" : { - "string" : { - - } + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } - ], - "returnType" : { - "void" : { - - } } - }, - { - "abiName" : "bjs_Greeter_greetWith", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "greetWith", - "parameters" : [ - { - "label" : "greeter", - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "label" : "customGreeting", - "name" : "customGreeting", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests7GreeterC_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - ], - "returnType" : { - "string" : { + } + ], + "swiftCallName" : "ArrayIdentityElement" + } + ], + "enums" : [ - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_Greeter_makeFormatter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeFormatter", - "parameters" : [ - { - "label" : "suffix", - "name" : "suffix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_Greeter_static_makeCreator", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "makeCreator", - "parameters" : [ - { - "label" : "defaultName", - "name" : "defaultName", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_7GreeterC", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_getSharedSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getSharedSubject", + "parameters" : [ - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - }, - "staticContext" : { - "className" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_Greeter_makeCustomGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeCustomGreeter", - "parameters" : [ + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "IdentityTestSubject" + } + } + }, + { + "abiName" : "bjs_resetSharedSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetSharedSubject", + "parameters" : [ - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests7GreeterC_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - ], - "returnType" : { - "string" : { + ], + "returnType" : { + "void" : { - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_Greeter_greetEnthusiastically", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "greetEnthusiastically", - "parameters" : [ + } + } + }, + { + "abiName" : "bjs_getRetainLeakSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getRetainLeakSubject", + "parameters" : [ - ], - "returnType" : { - "string" : { + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "RetainLeakSubject" + } + } + }, + { + "abiName" : "bjs_resetRetainLeakSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetRetainLeakSubject", + "parameters" : [ - } - } - }, - { - "abiName" : "bjs_Greeter_static_greetAnonymously", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "greetAnonymously", - "parameters" : [ + ], + "returnType" : { + "void" : { - ], - "returnType" : { - "string" : { + } + } + }, + { + "abiName" : "bjs_getRetainLeakDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getRetainLeakDeinits", + "parameters" : [ - } - }, - "staticContext" : { - "className" : { - "_0" : "Greeter" - } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } - ], - "name" : "Greeter", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { + } + }, + { + "abiName" : "bjs_resetRetainLeakDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetRetainLeakDeinits", + "parameters" : [ - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "prefix", - "type" : { - "string" : { + ], + "returnType" : { + "void" : { - } - } - }, + } + } + }, + { + "abiName" : "bjs_setupArrayPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setupArrayPool", + "parameters" : [ { - "isReadonly" : true, - "isStatic" : false, - "name" : "nameCount", + "label" : "_", + "name" : "count", "type" : { "integer" : { "_0" : { @@ -814,93 +277,48 @@ } } } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "defaultGreeting", - "staticContext" : { - "className" : { - "_0" : "Greeter" - } - }, - "type" : { - "string" : { - - } - } } ], - "swiftCallName" : "Greeter" + "returnType" : { + "void" : { + + } + } }, { - "methods" : [ - { - "abiName" : "bjs_Calculator_square", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "square", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "abiName" : "bjs_getArrayPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getArrayPool", + "parameters" : [ + + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "ArrayIdentityElement" } } - }, + } + } + }, + { + "abiName" : "bjs_getArrayPoolElement", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getArrayPoolElement", + "parameters" : [ { - "abiName" : "bjs_Calculator_add", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "add", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "b", - "name" : "b", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { + "label" : "_", + "name" : "index", + "type" : { "integer" : { "_0" : { "isSigned" : true, @@ -910,19849 +328,85 @@ } } ], - "name" : "Calculator", - "properties" : [ - - ], - "swiftCallName" : "Calculator" - }, - { - "explicitAccessControl" : "internal", - "methods" : [ - - ], - "name" : "InternalGreeter", - "properties" : [ - - ], - "swiftCallName" : "InternalGreeter" - }, - { - "explicitAccessControl" : "public", - "methods" : [ - - ], - "name" : "PublicGreeter", - "properties" : [ - - ], - "swiftCallName" : "PublicGreeter" - }, - { - "explicitAccessControl" : "package", - "methods" : [ - - ], - "name" : "PackageGreeter", - "properties" : [ - - ], - "swiftCallName" : "PackageGreeter" - }, - { - "constructor" : { - "abiName" : "bjs_Utils_Converter_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_Utils_Converter_toString", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "toString", - "namespace" : [ - "Utils" - ], - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "Converter", - "namespace" : [ - "Utils" - ], - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "precision", - "namespace" : [ - "Utils" - ], - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "Utils.Converter" - }, - { - "constructor" : { - "abiName" : "bjs_Networking_API_HTTPServer_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_Networking_API_HTTPServer_call", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "call", - "namespace" : [ - "Networking", - "API" - ], - "parameters" : [ - { - "label" : "_", - "name" : "method", - "type" : { - "caseEnum" : { - "_0" : "Networking.API.Method" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - } - ], - "name" : "HTTPServer", - "namespace" : [ - "Networking", - "API" - ], - "properties" : [ - - ], - "swiftCallName" : "Networking.API.HTTPServer" - }, - { - "constructor" : { - "abiName" : "bjs___Swift_Foundation_UUID_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs___Swift_Foundation_UUID_uuidString", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "uuidString", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs___Swift_Foundation_UUID_static_fromValue", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "fromValue", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { + "returnType" : { + "nullable" : { + "_0" : { "swiftHeapObject" : { - "_0" : "UUID" - } - }, - "staticContext" : { - "className" : { - "_0" : "__Swift_Foundation_UUID" - } - } - } - ], - "name" : "UUID", - "namespace" : [ - "__Swift", - "Foundation" - ], - "properties" : [ - { - "isReadonly" : true, - "isStatic" : true, - "name" : "placeholder", - "staticContext" : { - "className" : { - "_0" : "__Swift_Foundation_UUID" - } - }, - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "UUID" - }, - { - "constructor" : { - "abiName" : "bjs_Networking_APIV2_Internal_TestServer_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_Networking_APIV2_Internal_TestServer_call", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "call", - "namespace" : [ - "Networking", - "APIV2", - "Internal" - ], - "parameters" : [ - { - "label" : "_", - "name" : "method", - "type" : { - "caseEnum" : { - "_0" : "Internal.SupportedMethod" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - } - ], - "name" : "TestServer", - "namespace" : [ - "Networking", - "APIV2", - "Internal" - ], - "properties" : [ - - ], - "swiftCallName" : "Internal.TestServer" - }, - { - "constructor" : { - "abiName" : "bjs_SimplePropertyHolder_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "SimplePropertyHolder", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "SimplePropertyHolder" - }, - { - "constructor" : { - "abiName" : "bjs_PropertyHolder_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "intValue", - "name" : "intValue", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "floatValue", - "name" : "floatValue", - "type" : { - "float" : { - - } - } - }, - { - "label" : "doubleValue", - "name" : "doubleValue", - "type" : { - "double" : { - - } - } - }, - { - "label" : "boolValue", - "name" : "boolValue", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "stringValue", - "name" : "stringValue", - "type" : { - "string" : { - - } - } - }, - { - "label" : "jsObject", - "name" : "jsObject", - "type" : { - "jsObject" : { - - } - } - }, - { - "label" : "sibling", - "name" : "sibling", - "type" : { - "swiftHeapObject" : { - "_0" : "SimplePropertyHolder" - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_PropertyHolder_getAllValues", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getAllValues", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "PropertyHolder", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "intValue", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "floatValue", - "type" : { - "float" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "doubleValue", - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "boolValue", - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "stringValue", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "readonlyInt", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "readonlyFloat", - "type" : { - "float" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "readonlyDouble", - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "readonlyBool", - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "readonlyString", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "jsObject", - "type" : { - "jsObject" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "sibling", - "type" : { - "swiftHeapObject" : { - "_0" : "SimplePropertyHolder" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "lazyValue", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "computedReadonly", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "computedReadWrite", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "observedProperty", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "PropertyHolder" - }, - { - "methods" : [ - { - "abiName" : "bjs_MathUtils_static_add", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "add", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "b", - "name" : "b", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "staticContext" : { - "className" : { - "_0" : "MathUtils" - } - } - }, - { - "abiName" : "bjs_MathUtils_static_substract", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "substract", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "b", - "name" : "b", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "staticContext" : { - "className" : { - "_0" : "MathUtils" - } - } - } - ], - "name" : "MathUtils", - "properties" : [ - - ], - "swiftCallName" : "MathUtils" - }, - { - "constructor" : { - "abiName" : "bjs_StaticPropertyHolder_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - - ], - "name" : "StaticPropertyHolder", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : true, - "name" : "staticConstant", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "staticVariable", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "staticString", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "staticBool", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "staticFloat", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "float" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "staticDouble", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "computedProperty", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "readOnlyComputed", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "optionalString", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "optionalInt", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "jsObjectProperty", - "staticContext" : { - "className" : { - "_0" : "StaticPropertyHolder" - } - }, - "type" : { - "jsObject" : { - - } - } - } - ], - "swiftCallName" : "StaticPropertyHolder" - }, - { - "constructor" : { - "abiName" : "bjs_DataProcessorManager_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "processor", - "name" : "processor", - "type" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_DataProcessorManager_incrementByAmount", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "incrementByAmount", - "parameters" : [ - { - "label" : "_", - "name" : "amount", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorLabel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorLabel", - "parameters" : [ - { - "label" : "_", - "name" : "prefix", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "suffix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_isProcessorEven", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "isProcessorEven", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorLabel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorLabel", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getCurrentValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getCurrentValue", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_incrementBoth", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "incrementBoth", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getBackupValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getBackupValue", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_hasBackup", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "hasBackup", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorOptionalTag", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorOptionalTag", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorOptionalTag", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorOptionalTag", - "parameters" : [ - { - "label" : "_", - "name" : "tag", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorOptionalCount", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorOptionalCount", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorOptionalCount", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorOptionalCount", - "parameters" : [ - { - "label" : "_", - "name" : "count", - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorDirection", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorDirection", - "parameters" : [ - { - "label" : "_", - "name" : "direction", - "type" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorTheme", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorTheme", - "parameters" : [ - { - "label" : "_", - "name" : "theme", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorHttpStatus", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorHttpStatus", - "parameters" : [ - { - "label" : "_", - "name" : "status", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_getProcessorAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getProcessorAPIResult", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_DataProcessorManager_setProcessorAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setProcessorAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "apiResult", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - } - ], - "name" : "DataProcessorManager", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "processor", - "type" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "backupProcessor", - "type" : { - "nullable" : { - "_0" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "DataProcessorManager" - }, - { - "constructor" : { - "abiName" : "bjs_SwiftDataProcessor_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_SwiftDataProcessor_increment", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "increment", - "parameters" : [ - { - "label" : "by", - "name" : "amount", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_getValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getValue", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_setLabelElements", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setLabelElements", - "parameters" : [ - { - "label" : "_", - "name" : "labelPrefix", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "labelSuffix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_getLabel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getLabel", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_isEven", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "isEven", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_processGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_createGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createGreeter", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_processOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "greeter", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_createOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createOptionalGreeter", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_handleAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "handleAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_SwiftDataProcessor_getAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getAPIResult", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - } - ], - "name" : "SwiftDataProcessor", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "count", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalTag", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalCount", - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "direction", - "type" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalTheme", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "httpStatus", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "apiResult", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "helper", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalHelper", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "SwiftDataProcessor" - }, - { - "methods" : [ - { - "abiName" : "bjs_ProtocolReturnTests_static_createNativeProcessor", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "createNativeProcessor", - "parameters" : [ - - ], - "returnType" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - }, - "staticContext" : { - "className" : { - "_0" : "ProtocolReturnTests" - } - } - }, - { - "abiName" : "bjs_ProtocolReturnTests_static_createNativeProcessorOptional", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "createNativeProcessorOptional", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "className" : { - "_0" : "ProtocolReturnTests" - } - } - }, - { - "abiName" : "bjs_ProtocolReturnTests_static_createNativeProcessorNil", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "createNativeProcessorNil", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "className" : { - "_0" : "ProtocolReturnTests" - } - } - }, - { - "abiName" : "bjs_ProtocolReturnTests_static_createNativeProcessorArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "createNativeProcessorArray", - "parameters" : [ - - ], - "returnType" : { - "array" : { - "_0" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - } - } - }, - "staticContext" : { - "className" : { - "_0" : "ProtocolReturnTests" - } - } - }, - { - "abiName" : "bjs_ProtocolReturnTests_static_createNativeProcessorDictionary", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "createNativeProcessorDictionary", - "parameters" : [ - - ], - "returnType" : { - "dictionary" : { - "_0" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - } - } - }, - "staticContext" : { - "className" : { - "_0" : "ProtocolReturnTests" - } - } - } - ], - "name" : "ProtocolReturnTests", - "properties" : [ - - ], - "swiftCallName" : "ProtocolReturnTests" - }, - { - "constructor" : { - "abiName" : "bjs_TextProcessor_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "transform", - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_TextProcessor_process", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "process", - "parameters" : [ - { - "label" : "_", - "name" : "text", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processWithCustom", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processWithCustom", - "parameters" : [ - { - "label" : "_", - "name" : "text", - "type" : { - "string" : { - - } - } - }, - { - "label" : "customTransform", - "name" : "customTransform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSiSSSd_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - { - "string" : { - - } - }, - { - "double" : { - - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_getTransform", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getTransform", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalString", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalString", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSqSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalInt", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalInt", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSqSi_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq7GreeterC_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeOptionalStringFormatter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeOptionalStringFormatter", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSqSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeOptionalGreeterCreator", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeOptionalGreeterCreator", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_Sq7GreeterC", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_TextProcessor_processDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processDirection", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests9DirectionO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "caseEnum" : { - "_0" : "Direction" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processTheme", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests5ThemeO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processHttpStatus", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests10HttpStatusO_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_TextProcessor_processAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests9APIResultO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeDirectionChecker", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeDirectionChecker", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests9DirectionO_Sb", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "caseEnum" : { - "_0" : "Direction" - } - } - ], - "returnType" : { - "bool" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeThemeValidator", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeThemeValidator", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests5ThemeO_Sb", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - ], - "returnType" : { - "bool" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeStatusCodeExtractor", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeStatusCodeExtractor", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests10HttpStatusO_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeAPIResultHandler", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultHandler", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests9APIResultO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalDirection", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq9DirectionO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalTheme", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq5ThemeO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq9APIResultO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeOptionalDirectionFormatter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeOptionalDirectionFormatter", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq9DirectionO_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_TextProcessor_processDataProcessor", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processDataProcessor", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests13DataProcessorP_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_TextProcessor_makeDataProcessorFactory", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeDataProcessorFactory", - "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_13DataProcessorP", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_TextProcessor_roundtripDataProcessor", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripDataProcessor", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - } - ], - "returnType" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests13DataProcessorP_13DataProcessorP", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - } - ], - "returnType" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_TextProcessor_processOptionalDataProcessor", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalDataProcessor", - "parameters" : [ - { - "label" : "_", - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq13DataProcessorP_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "nullable" : { - "_0" : { - "swiftProtocol" : { - "_0" : "DataProcessor" - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "TextProcessor", - "properties" : [ - - ], - "swiftCallName" : "TextProcessor" - }, - { - "constructor" : { - "abiName" : "bjs_IdentityTestSubject_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "IdentityTestSubject", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "currentValue", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "IdentityTestSubject" - }, - { - "constructor" : { - "abiName" : "bjs_RetainLeakSubject_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "tag", - "name" : "tag", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "RetainLeakSubject", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "tag", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "RetainLeakSubject" - }, - { - "constructor" : { - "abiName" : "bjs_ArrayIdentityElement_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "tag", - "name" : "tag", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "ArrayIdentityElement", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "tag", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "ArrayIdentityElement" - }, - { - "constructor" : { - "abiName" : "bjs_OptionalHolder_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "nullableGreeter", - "name" : "nullableGreeter", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - }, - { - "label" : "undefinedNumber", - "name" : "undefinedNumber", - "type" : { - "nullable" : { - "_0" : { - "double" : { - - } - }, - "_1" : "undefined" - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "OptionalHolder", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "nullableGreeter", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "undefinedNumber", - "type" : { - "nullable" : { - "_0" : { - "double" : { - - } - }, - "_1" : "undefined" - } - } - } - ], - "swiftCallName" : "OptionalHolder" - }, - { - "constructor" : { - "abiName" : "bjs_OptionalPropertyHolder_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "optionalName", - "name" : "optionalName", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "OptionalPropertyHolder", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalName", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalAge", - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "optionalGreeter", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "OptionalPropertyHolder" - }, - { - "constructor" : { - "abiName" : "bjs_Container_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "location", - "name" : "location", - "type" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - }, - { - "label" : "config", - "name" : "config", - "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "Config" - } - }, - "_1" : "null" - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "Container", - "properties" : [ - { - "isReadonly" : false, - "isStatic" : false, - "name" : "location", - "type" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - }, - { - "isReadonly" : false, - "isStatic" : false, - "name" : "config", - "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "Config" - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "Container" - }, - { - "constructor" : { - "abiName" : "bjs_LeakCheck_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "explicitAccessControl" : "public", - "methods" : [ - - ], - "name" : "LeakCheck", - "properties" : [ - - ], - "swiftCallName" : "LeakCheck" - } - ], - "enums" : [ - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "ArraySupportExports", - "staticMethods" : [ - { - "abiName" : "bjs_ArraySupportExports_static_roundTripIntArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripIntArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripStringArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripStringArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripDoubleArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripDoubleArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripBoolArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripBoolArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "bool" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "bool" : { - - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripUnsafeRawPointerArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripUnsafeRawPointerArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeRawPointer" - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeRawPointer" - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripUnsafeMutableRawPointerArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripUnsafeMutableRawPointerArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutableRawPointer" - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutableRawPointer" - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOpaquePointerArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOpaquePointerArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripUnsafePointerArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripUnsafePointerArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripUnsafeMutablePointerArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripUnsafeMutablePointerArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripJSValueArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripJSValueArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "jsValue" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "jsValue" : { - - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripJSObjectArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripJSObjectArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "jsObject" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "jsObject" : { - - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripCaseEnumArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripCaseEnumArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripStringRawValueEnumArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripStringRawValueEnumArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripIntRawValueEnumArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripIntRawValueEnumArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripInt64RawValueEnumArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripInt64RawValueEnumArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripUInt64RawValueEnumArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripUInt64RawValueEnumArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "rawValueEnum" : { - "_0" : "SessionId", - "_1" : "UInt64" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "rawValueEnum" : { - "_0" : "SessionId", - "_1" : "UInt64" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripStructArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripStructArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripSwiftClassArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripSwiftClassArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripNamespacedSwiftClassArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripNamespacedSwiftClassArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Utils.Converter" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Utils.Converter" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripProtocolArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripProtocolArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "swiftProtocol" : { - "_0" : "ArrayElementProtocol" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "swiftProtocol" : { - "_0" : "ArrayElementProtocol" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripJSClassArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripJSClassArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalIntArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalIntArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalStringArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalStringArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalJSObjectArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalJSObjectArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { - - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { - - } - }, - "_1" : "null" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalCaseEnumArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalCaseEnumArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalStringRawValueEnumArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalStringRawValueEnumArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalIntRawValueEnumArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalIntRawValueEnumArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - }, - "_1" : "null" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalInt64RawValueEnumArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalInt64RawValueEnumArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - }, - "_1" : "null" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalUInt64RawValueEnumArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalUInt64RawValueEnumArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "SessionId", - "_1" : "UInt64" - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "SessionId", - "_1" : "UInt64" - } - }, - "_1" : "null" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalStructArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalStructArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - }, - "_1" : "null" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalSwiftClassArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalSwiftClassArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripOptionalJSClassArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalJSClassArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" - } - }, - "_1" : "null" - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripNestedIntArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripNestedIntArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripNestedStringArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripNestedStringArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripNestedDoubleArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripNestedDoubleArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripNestedBoolArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripNestedBoolArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "bool" : { - - } - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "bool" : { - - } - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripNestedStructArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripNestedStructArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripNestedCaseEnumArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripNestedCaseEnumArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_roundTripNestedSwiftClassArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripNestedSwiftClassArray", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_multiArrayFirst", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "multiArrayFirst", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "a", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "label" : "_", - "name" : "b", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_multiArraySecond", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "multiArraySecond", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "a", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "label" : "_", - "name" : "b", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_multiOptionalArrayFirst", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "multiOptionalArrayFirst", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "a", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - }, - "_1" : "null" - } - } - }, - { - "label" : "_", - "name" : "b", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - }, - { - "abiName" : "bjs_ArraySupportExports_static_multiOptionalArraySecond", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "multiOptionalArraySecond", - "namespace" : [ - "ArraySupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "a", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - }, - "_1" : "null" - } - } - }, - { - "label" : "_", - "name" : "b", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "ArraySupportExports" - } - } - } - ], - "staticProperties" : [ - - ], - "swiftCallName" : "ArraySupportExports", - "tsFullPath" : "ArraySupportExports" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "DefaultArgumentExports", - "staticMethods" : [ - { - "abiName" : "bjs_DefaultArgumentExports_static_testStringDefault", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "testStringDefault", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "string" : { - "_0" : "Hello World" - } - }, - "label" : "message", - "name" : "message", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_testIntDefault", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "testIntDefault", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "int" : { - "_0" : 42 - } - }, - "label" : "count", - "name" : "count", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_testBoolDefault", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "testBoolDefault", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "bool" : { - "_0" : true - } - }, - "label" : "flag", - "name" : "flag", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_testOptionalDefault", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "testOptionalDefault", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "null" : { - - } - }, - "label" : "name", - "name" : "name", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_testMultipleDefaults", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "testMultipleDefaults", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "string" : { - "_0" : "Default Title" - } - }, - "label" : "title", - "name" : "title", - "type" : { - "string" : { - - } - } - }, - { - "defaultValue" : { - "int" : { - "_0" : -10 - } - }, - "label" : "count", - "name" : "count", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "defaultValue" : { - "bool" : { - "_0" : false - } - }, - "label" : "enabled", - "name" : "enabled", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_testSimpleEnumDefault", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "testSimpleEnumDefault", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "enumCase" : { - "_0" : "Status", - "_1" : "success" - } - }, - "label" : "status", - "name" : "status", - "type" : { - "caseEnum" : { - "_0" : "Status" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Status" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_testDirectionDefault", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "testDirectionDefault", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "enumCase" : { - "_0" : "Direction", - "_1" : "north" - } - }, - "label" : "direction", - "name" : "direction", - "type" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_testRawStringEnumDefault", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "testRawStringEnumDefault", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "enumCase" : { - "_0" : "Theme", - "_1" : "light" - } - }, - "label" : "theme", - "name" : "theme", - "type" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_testComplexInit", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "testComplexInit", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "objectWithArguments" : { - "_0" : "Greeter", - "_1" : [ - { - "string" : { - "_0" : "DefaultGreeter" - } - } - ] - } - }, - "label" : "greeter", - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "string" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_testEmptyInit", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "testEmptyInit", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "object" : { - "_0" : "StaticPropertyHolder" - } - }, - "label" : "_", - "name" : "object", - "type" : { - "swiftHeapObject" : { - "_0" : "StaticPropertyHolder" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "StaticPropertyHolder" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_createConstructorDefaults", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "createConstructorDefaults", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "string" : { - "_0" : "Default" - } - }, - "label" : "name", - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "defaultValue" : { - "int" : { - "_0" : 42 - } - }, - "label" : "count", - "name" : "count", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "defaultValue" : { - "bool" : { - "_0" : true - } - }, - "label" : "enabled", - "name" : "enabled", - "type" : { - "bool" : { - - } - } - }, - { - "defaultValue" : { - "enumCase" : { - "_0" : "Status", - "_1" : "success" - } - }, - "label" : "status", - "name" : "status", - "type" : { - "caseEnum" : { - "_0" : "Status" - } - } - }, - { - "defaultValue" : { - "null" : { - - } - }, - "label" : "tag", - "name" : "tag", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "DefaultArgumentConstructorDefaults" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_describeConstructorDefaults", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "describeConstructorDefaults", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftHeapObject" : { - "_0" : "DefaultArgumentConstructorDefaults" - } - } - } - ], - "returnType" : { - "string" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_arrayWithDefault", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "arrayWithDefault", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "array" : { - "_0" : [ - { - "int" : { - "_0" : 1 - } - }, - { - "int" : { - "_0" : 2 - } - }, - { - "int" : { - "_0" : 3 - } - } - ] - } - }, - "label" : "_", - "name" : "values", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_arrayWithOptionalDefault", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "arrayWithOptionalDefault", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "null" : { - - } - }, - "label" : "_", - "name" : "values", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - }, - { - "abiName" : "bjs_DefaultArgumentExports_static_arrayMixedDefaults", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "arrayMixedDefaults", - "namespace" : [ - "DefaultArgumentExports" - ], - "parameters" : [ - { - "defaultValue" : { - "string" : { - "_0" : "Sum" - } - }, - "label" : "prefix", - "name" : "prefix", - "type" : { - "string" : { - - } - } - }, - { - "defaultValue" : { - "array" : { - "_0" : [ - { - "int" : { - "_0" : 10 - } - }, - { - "int" : { - "_0" : 20 - } - } - ] - } - }, - "label" : "values", - "name" : "values", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "defaultValue" : { - "string" : { - "_0" : "!" - } - }, - "label" : "suffix", - "name" : "suffix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "DefaultArgumentExports" - } - } - } - ], - "staticProperties" : [ - - ], - "swiftCallName" : "DefaultArgumentExports", - "tsFullPath" : "DefaultArgumentExports" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "north" - }, - { - "associatedValues" : [ - - ], - "name" : "south" - }, - { - "associatedValues" : [ - - ], - "name" : "east" - }, - { - "associatedValues" : [ - - ], - "name" : "west" - } - ], - "emitStyle" : "const", - "name" : "Direction", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Direction", - "tsFullPath" : "Direction" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "loading" - }, - { - "associatedValues" : [ - - ], - "name" : "success" - }, - { - "associatedValues" : [ - - ], - "name" : "error" - } - ], - "emitStyle" : "const", - "name" : "Status", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Status", - "tsFullPath" : "Status" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "light", - "rawValue" : "light" - }, - { - "associatedValues" : [ - - ], - "name" : "dark", - "rawValue" : "dark" - }, - { - "associatedValues" : [ - - ], - "name" : "auto", - "rawValue" : "auto" - } - ], - "emitStyle" : "const", - "name" : "Theme", - "rawType" : "String", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Theme", - "tsFullPath" : "Theme" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "ok", - "rawValue" : "200" - }, - { - "associatedValues" : [ - - ], - "name" : "notFound", - "rawValue" : "404" - }, - { - "associatedValues" : [ - - ], - "name" : "serverError", - "rawValue" : "500" - }, - { - "associatedValues" : [ - - ], - "name" : "unknown", - "rawValue" : "-1" - } - ], - "emitStyle" : "const", - "name" : "HttpStatus", - "rawType" : "Int", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "HttpStatus", - "tsFullPath" : "HttpStatus" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "tiny", - "rawValue" : "1024" - }, - { - "associatedValues" : [ - - ], - "name" : "small", - "rawValue" : "10240" - }, - { - "associatedValues" : [ - - ], - "name" : "medium", - "rawValue" : "102400" - }, - { - "associatedValues" : [ - - ], - "name" : "large", - "rawValue" : "1048576" - } - ], - "emitStyle" : "const", - "name" : "FileSize", - "rawType" : "Int64", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "FileSize", - "tsFullPath" : "FileSize" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "none", - "rawValue" : "0" - }, - { - "associatedValues" : [ - - ], - "name" : "active", - "rawValue" : "9876543210" - }, - { - "associatedValues" : [ - - ], - "name" : "expired", - "rawValue" : "1234567890" - } - ], - "emitStyle" : "const", - "name" : "SessionId", - "rawType" : "UInt64", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "SessionId", - "tsFullPath" : "SessionId" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "rough", - "rawValue" : "0.1" - }, - { - "associatedValues" : [ - - ], - "name" : "normal", - "rawValue" : "0.01" - }, - { - "associatedValues" : [ - - ], - "name" : "fine", - "rawValue" : "0.001" - } - ], - "emitStyle" : "const", - "name" : "Precision", - "rawType" : "Float", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Precision", - "tsFullPath" : "Precision" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "quarter", - "rawValue" : "0.25" - }, - { - "associatedValues" : [ - - ], - "name" : "half", - "rawValue" : "0.5" - }, - { - "associatedValues" : [ - - ], - "name" : "golden", - "rawValue" : "1.618" - } - ], - "emitStyle" : "const", - "name" : "Ratio", - "rawType" : "Double", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Ratio", - "tsFullPath" : "Ratio" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "north" - }, - { - "associatedValues" : [ - - ], - "name" : "south" - }, - { - "associatedValues" : [ - - ], - "name" : "east" - }, - { - "associatedValues" : [ - - ], - "name" : "west" - } - ], - "emitStyle" : "tsEnum", - "name" : "TSDirection", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "TSDirection", - "tsFullPath" : "TSDirection" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "light", - "rawValue" : "light" - }, - { - "associatedValues" : [ - - ], - "name" : "dark", - "rawValue" : "dark" - }, - { - "associatedValues" : [ - - ], - "name" : "auto", - "rawValue" : "auto" - } - ], - "emitStyle" : "tsEnum", - "name" : "TSTheme", - "rawType" : "String", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "TSTheme", - "tsFullPath" : "TSTheme" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Utils", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Utils", - "tsFullPath" : "Utils" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "StringUtils", - "namespace" : [ - "Utils" - ], - "staticMethods" : [ - { - "abiName" : "bjs_Utils_StringUtils_static_uppercase", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "uppercase", - "namespace" : [ - "Utils", - "StringUtils" - ], - "parameters" : [ - { - "label" : "_", - "name" : "text", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "Utils.StringUtils" - } - } - }, - { - "abiName" : "bjs_Utils_StringUtils_static_lowercase", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "lowercase", - "namespace" : [ - "Utils", - "StringUtils" - ], - "parameters" : [ - { - "label" : "_", - "name" : "text", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "Utils.StringUtils" - } - } - } - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Utils.StringUtils", - "tsFullPath" : "Utils.StringUtils" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Networking", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Networking", - "tsFullPath" : "Networking" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "API", - "namespace" : [ - "Networking" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Networking.API", - "tsFullPath" : "Networking.API" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "get" - }, - { - "associatedValues" : [ - - ], - "name" : "post" - }, - { - "associatedValues" : [ - - ], - "name" : "put" - }, - { - "associatedValues" : [ - - ], - "name" : "delete" - } - ], - "emitStyle" : "const", - "name" : "Method", - "namespace" : [ - "Networking", - "API" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Networking.API.Method", - "tsFullPath" : "Networking.API.Method" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Configuration", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Configuration", - "tsFullPath" : "Configuration" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "debug", - "rawValue" : "debug" - }, - { - "associatedValues" : [ - - ], - "name" : "info", - "rawValue" : "info" - }, - { - "associatedValues" : [ - - ], - "name" : "warning", - "rawValue" : "warning" - }, - { - "associatedValues" : [ - - ], - "name" : "error", - "rawValue" : "error" - } - ], - "emitStyle" : "const", - "name" : "LogLevel", - "namespace" : [ - "Configuration" - ], - "rawType" : "String", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Configuration.LogLevel", - "tsFullPath" : "Configuration.LogLevel" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "http", - "rawValue" : "80" - }, - { - "associatedValues" : [ - - ], - "name" : "https", - "rawValue" : "443" - }, - { - "associatedValues" : [ - - ], - "name" : "development", - "rawValue" : "3000" - } - ], - "emitStyle" : "const", - "name" : "Port", - "namespace" : [ - "Configuration" - ], - "rawType" : "Int", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Configuration.Port", - "tsFullPath" : "Configuration.Port" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Internal", - "namespace" : [ - "Networking", - "APIV2" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Internal", - "tsFullPath" : "Networking.APIV2.Internal" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "get" - }, - { - "associatedValues" : [ - - ], - "name" : "post" - } - ], - "emitStyle" : "const", - "name" : "SupportedMethod", - "namespace" : [ - "Networking", - "APIV2", - "Internal" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Internal.SupportedMethod", - "tsFullPath" : "Networking.APIV2.Internal.SupportedMethod" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "name" : "failure" - }, - { - "associatedValues" : [ - { - "type" : { - "bool" : { - - } - } - } - ], - "name" : "flag" - }, - { - "associatedValues" : [ - { - "type" : { - "float" : { - - } - } - } - ], - "name" : "rate" - }, - { - "associatedValues" : [ - { - "type" : { - "double" : { - - } - } - } - ], - "name" : "precise" - }, - { - "associatedValues" : [ - - ], - "name" : "info" - } - ], - "emitStyle" : "const", - "name" : "APIResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "APIResult", - "tsFullPath" : "APIResult" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "name" : "error" - }, - { - "associatedValues" : [ - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "location" - }, - { - "associatedValues" : [ - { - "type" : { - "bool" : { - - } - } - }, - { - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "status" - }, - { - "associatedValues" : [ - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - } - ], - "name" : "coordinates" - }, - { - "associatedValues" : [ - { - "type" : { - "bool" : { - - } - } - }, - { - "type" : { - "bool" : { - - } - } - }, - { - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "double" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "comprehensive" - }, - { - "associatedValues" : [ - - ], - "name" : "info" - } - ], - "emitStyle" : "const", - "name" : "ComplexResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "ComplexResult", - "tsFullPath" : "ComplexResult" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Utilities", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Utilities", - "tsFullPath" : "Utilities" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "name" : "failure" - }, - { - "associatedValues" : [ - { - "type" : { - "bool" : { - - } - } - }, - { - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "status" - } - ], - "emitStyle" : "const", - "name" : "Result", - "namespace" : [ - "Utilities" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "Utilities.Result", - "tsFullPath" : "Utilities.Result" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "API", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "API", - "tsFullPath" : "API" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - }, - { - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "name" : "failure" - } - ], - "emitStyle" : "const", - "name" : "NetworkingResult", - "namespace" : [ - "API" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "API.NetworkingResult", - "tsFullPath" : "API.NetworkingResult" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "swiftStruct" : { - "_0" : "Address" - } - } - } - ], - "name" : "structPayload" - }, - { - "associatedValues" : [ - { - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "name" : "classPayload" - }, - { - "associatedValues" : [ - { - "type" : { - "jsObject" : { - - } - } - } - ], - "name" : "jsObjectPayload" - }, - { - "associatedValues" : [ - { - "type" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - ], - "name" : "nestedEnum" - }, - { - "associatedValues" : [ - { - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - ], - "name" : "arrayPayload" - }, - { - "associatedValues" : [ - { - "type" : { - "jsObject" : { - "_0" : "Foo" - } - } - } - ], - "name" : "jsClassPayload" - }, - { - "associatedValues" : [ - - ], - "name" : "empty" - } - ], - "emitStyle" : "const", - "name" : "AllTypesResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "AllTypesResult", - "tsFullPath" : "AllTypesResult" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "rawValueEnum" : { - "_0" : "Precision", - "_1" : "Float" - } - } - } - ], - "name" : "precision" - }, - { - "associatedValues" : [ - { - "type" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - ], - "name" : "direction" - }, - { - "associatedValues" : [ - { - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Precision", - "_1" : "Float" - } - }, - "_1" : "null" - } - } - } - ], - "name" : "optPrecision" - }, - { - "associatedValues" : [ - { - "type" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" - } - } - } - ], - "name" : "optDirection" - }, - { - "associatedValues" : [ - - ], - "name" : "empty" - } - ], - "emitStyle" : "const", - "name" : "TypedPayloadResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "TypedPayloadResult", - "tsFullPath" : "TypedPayloadResult" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "scientific" - }, - { - "associatedValues" : [ - - ], - "name" : "basic" - } - ], - "emitStyle" : "const", - "name" : "StaticCalculator", - "staticMethods" : [ - { - "abiName" : "bjs_StaticCalculator_static_roundtrip", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundtrip", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "staticContext" : { - "enumName" : { - "_0" : "StaticCalculator" - } - } - }, - { - "abiName" : "bjs_StaticCalculator_static_doubleValue", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "doubleValue", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "staticContext" : { - "enumName" : { - "_0" : "StaticCalculator" - } - } - } - ], - "staticProperties" : [ - { - "isReadonly" : true, - "isStatic" : true, - "name" : "version", - "staticContext" : { - "enumName" : { - "_0" : "StaticCalculator" - } - }, - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "StaticCalculator", - "tsFullPath" : "StaticCalculator" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "StaticUtils", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "StaticUtils", - "tsFullPath" : "StaticUtils" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "Nested", - "namespace" : [ - "StaticUtils" - ], - "staticMethods" : [ - { - "abiName" : "bjs_StaticUtils_Nested_static_roundtrip", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundtrip", - "namespace" : [ - "StaticUtils", - "Nested" - ], - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "StaticUtils.Nested" - } - } - } - ], - "staticProperties" : [ - - ], - "swiftCallName" : "StaticUtils.Nested", - "tsFullPath" : "StaticUtils.Nested" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "GraphOperations", - "namespace" : [ - "Services", - "Graph" - ], - "staticMethods" : [ - { - "abiName" : "bjs_Services_Graph_GraphOperations_static_createGraph", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "createGraph", - "namespace" : [ - "Services", - "Graph", - "GraphOperations" - ], - "parameters" : [ - { - "label" : "rootId", - "name" : "rootId", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "GraphOperations" - } - } - }, - { - "abiName" : "bjs_Services_Graph_GraphOperations_static_nodeCount", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "nodeCount", - "namespace" : [ - "Services", - "Graph", - "GraphOperations" - ], - "parameters" : [ - { - "label" : "graphId", - "name" : "graphId", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "GraphOperations" - } - } - } - ], - "staticProperties" : [ - - ], - "swiftCallName" : "GraphOperations", - "tsFullPath" : "Services.Graph.GraphOperations" - }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "option1" - }, - { - "associatedValues" : [ - - ], - "name" : "option2" - } - ], - "emitStyle" : "const", - "name" : "StaticPropertyEnum", - "staticMethods" : [ - - ], - "staticProperties" : [ - { - "isReadonly" : false, - "isStatic" : true, - "name" : "enumProperty", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "enumConstant", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "enumBool", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "enumVariable", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "computedReadonly", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "computedReadWrite", - "staticContext" : { - "enumName" : { - "_0" : "StaticPropertyEnum" - } - }, - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "StaticPropertyEnum", - "tsFullPath" : "StaticPropertyEnum" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "StaticPropertyNamespace", - "staticMethods" : [ - - ], - "staticProperties" : [ - { - "isReadonly" : false, - "isStatic" : true, - "name" : "namespaceProperty", - "namespace" : [ - "StaticPropertyNamespace" - ], - "staticContext" : { - "namespaceEnum" : { - "_0" : "StaticPropertyNamespace" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "namespaceConstant", - "namespace" : [ - "StaticPropertyNamespace" - ], - "staticContext" : { - "namespaceEnum" : { - "_0" : "StaticPropertyNamespace" - } - }, - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "StaticPropertyNamespace", - "tsFullPath" : "StaticPropertyNamespace" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "NestedProperties", - "namespace" : [ - "StaticPropertyNamespace" - ], - "staticMethods" : [ - - ], - "staticProperties" : [ - { - "isReadonly" : false, - "isStatic" : true, - "name" : "nestedProperty", - "namespace" : [ - "StaticPropertyNamespace", - "NestedProperties" - ], - "staticContext" : { - "namespaceEnum" : { - "_0" : "StaticPropertyNamespace.NestedProperties" - } - }, - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "nestedConstant", - "namespace" : [ - "StaticPropertyNamespace", - "NestedProperties" - ], - "staticContext" : { - "namespaceEnum" : { - "_0" : "StaticPropertyNamespace.NestedProperties" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "nestedDouble", - "namespace" : [ - "StaticPropertyNamespace", - "NestedProperties" - ], - "staticContext" : { - "namespaceEnum" : { - "_0" : "StaticPropertyNamespace.NestedProperties" - } - }, - "type" : { - "double" : { - - } - } - } - ], - "swiftCallName" : "StaticPropertyNamespace.NestedProperties", - "tsFullPath" : "StaticPropertyNamespace.NestedProperties" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "IntegerTypesSupportExports", - "staticMethods" : [ - { - "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripInt", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripInt", - "namespace" : [ - "IntegerTypesSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "IntegerTypesSupportExports" - } - } - }, - { - "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripUInt", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripUInt", - "namespace" : [ - "IntegerTypesSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "word" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "IntegerTypesSupportExports" - } - } - }, - { - "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripInt8", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripInt8", - "namespace" : [ - "IntegerTypesSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w8" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w8" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "IntegerTypesSupportExports" - } - } - }, - { - "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripUInt8", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripUInt8", - "namespace" : [ - "IntegerTypesSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w8" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w8" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "IntegerTypesSupportExports" - } - } - }, - { - "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripInt16", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripInt16", - "namespace" : [ - "IntegerTypesSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w16" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w16" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "IntegerTypesSupportExports" - } - } - }, - { - "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripUInt16", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripUInt16", - "namespace" : [ - "IntegerTypesSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w16" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w16" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "IntegerTypesSupportExports" - } - } - }, - { - "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripInt32", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripInt32", - "namespace" : [ - "IntegerTypesSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w32" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w32" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "IntegerTypesSupportExports" - } - } - }, - { - "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripUInt32", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripUInt32", - "namespace" : [ - "IntegerTypesSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w32" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w32" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "IntegerTypesSupportExports" - } - } - }, - { - "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripInt64", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripInt64", - "namespace" : [ - "IntegerTypesSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w64" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w64" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "IntegerTypesSupportExports" - } - } - }, - { - "abiName" : "bjs_IntegerTypesSupportExports_static_roundTripUInt64", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripUInt64", - "namespace" : [ - "IntegerTypesSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w64" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w64" - } - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "IntegerTypesSupportExports" - } - } - } - ], - "staticProperties" : [ - - ], - "swiftCallName" : "IntegerTypesSupportExports", - "tsFullPath" : "IntegerTypesSupportExports" - }, - { - "cases" : [ - - ], - "emitStyle" : "const", - "name" : "OptionalSupportExports", - "staticMethods" : [ - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalString", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalString", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalInt", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalInt", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalBool", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalBool", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "bool" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "bool" : { - - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalFloat", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalFloat", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "float" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "float" : { - - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalDouble", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalDouble", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "double" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "double" : { - - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalSyntax", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalSyntax", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalCaseEnum", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalCaseEnum", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Status" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Status" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalStringRawValueEnum", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalStringRawValueEnum", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalIntRawValueEnum", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalIntRawValueEnum", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalInt64RawValueEnum", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalInt64RawValueEnum", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalUInt64RawValueEnum", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalUInt64RawValueEnum", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "SessionId", - "_1" : "UInt64" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "SessionId", - "_1" : "UInt64" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalTSEnum", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalTSEnum", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "TSDirection" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "TSDirection" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalTSStringEnum", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalTSStringEnum", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "TSTheme", - "_1" : "String" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "TSTheme", - "_1" : "String" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalNamespacedEnum", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalNamespacedEnum", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Networking.API.Method" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Networking.API.Method" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalSwiftClass", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalSwiftClass", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalIntArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalIntArray", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalStringArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalStringArray", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalSwiftClassArray", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalSwiftClassArray", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalAPIResult", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalTypedPayloadResult", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalTypedPayloadResult", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "TypedPayloadResult" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "TypedPayloadResult" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalComplexResult", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalComplexResult", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalAllTypesResult", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalAllTypesResult", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "AllTypesResult" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "AllTypesResult" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalPayloadResult", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalPayloadResult", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "associatedValueEnum" : { - "_0" : "OptionalAllTypesResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "OptionalAllTypesResult" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalPayloadResultOpt", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalPayloadResultOpt", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "OptionalAllTypesResult" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "OptionalAllTypesResult" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_roundTripOptionalAPIOptionalResult", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "roundTripOptionalAPIOptionalResult", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIOptionalResult" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIOptionalResult" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_takeOptionalJSObject", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "takeOptionalJSObject", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "nullable" : { - "_0" : { - "jsObject" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "void" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_applyOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "applyOptionalGreeter", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - }, - { - "label" : "_", - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSq7GreeterC_Sq7GreeterC", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_makeOptionalHolder", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "makeOptionalHolder", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "nullableGreeter", - "name" : "nullableGreeter", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - }, - { - "label" : "undefinedNumber", - "name" : "undefinedNumber", - "type" : { - "nullable" : { - "_0" : { - "double" : { - - } - }, - "_1" : "undefined" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "OptionalHolder" - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - }, - { - "abiName" : "bjs_OptionalSupportExports_static_compareAPIResults", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "compareAPIResults", - "namespace" : [ - "OptionalSupportExports" - ], - "parameters" : [ - { - "label" : "_", - "name" : "r1", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - }, - { - "label" : "_", - "name" : "r2", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "string" : { - - } - }, - "staticContext" : { - "namespaceEnum" : { - "_0" : "OptionalSupportExports" - } - } - } - ], - "staticProperties" : [ - - ], - "swiftCallName" : "OptionalSupportExports", - "tsFullPath" : "OptionalSupportExports" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "Address" - } - }, - "_1" : "null" - } - } - } - ], - "name" : "optStruct" - }, - { - "associatedValues" : [ - { - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - ], - "name" : "optClass" - }, - { - "associatedValues" : [ - { - "type" : { - "nullable" : { - "_0" : { - "jsObject" : { - - } - }, - "_1" : "null" - } - } - } - ], - "name" : "optJSObject" - }, - { - "associatedValues" : [ - { - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - } - ], - "name" : "optNestedEnum" - }, - { - "associatedValues" : [ - { - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - }, - "_1" : "null" - } - } - } - ], - "name" : "optArray" - }, - { - "associatedValues" : [ - { - "type" : { - "nullable" : { - "_0" : { - "jsObject" : { - "_0" : "Foo" - } - }, - "_1" : "null" - } - } - } - ], - "name" : "optJsClass" - }, - { - "associatedValues" : [ - - ], - "name" : "empty" - } - ], - "emitStyle" : "const", - "name" : "OptionalAllTypesResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "OptionalAllTypesResult", - "tsFullPath" : "OptionalAllTypesResult" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - }, - { - "type" : { - "nullable" : { - "_0" : { - "bool" : { - - } - }, - "_1" : "null" - } - } - } - ], - "name" : "failure" - }, - { - "associatedValues" : [ - { - "type" : { - "nullable" : { - "_0" : { - "bool" : { - - } - }, - "_1" : "null" - } - } - }, - { - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - }, - { - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "name" : "status" - } - ], - "emitStyle" : "const", - "name" : "APIOptionalResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "APIOptionalResult", - "tsFullPath" : "APIOptionalResult" - } - ], - "exposeToGlobal" : false, - "functions" : [ - { - "abiName" : "bjs_roundTripVoid", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripVoid", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_roundTripFloat", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripFloat", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "float" : { - - } - } - } - ], - "returnType" : { - "float" : { - - } - } - }, - { - "abiName" : "bjs_roundTripDouble", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripDouble", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_roundTripBool", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripBool", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_roundTripString", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripString", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_roundTripSwiftHeapObject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripSwiftHeapObject", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_roundTripUnsafeRawPointer", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripUnsafeRawPointer", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeRawPointer" - } - } - } - } - ], - "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeRawPointer" - } - } - } - }, - { - "abiName" : "bjs_roundTripUnsafeMutableRawPointer", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripUnsafeMutableRawPointer", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutableRawPointer" - } - } - } - } - ], - "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutableRawPointer" - } - } - } - }, - { - "abiName" : "bjs_roundTripOpaquePointer", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOpaquePointer", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" - } - } - } - } - ], - "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" - } - } - } - }, - { - "abiName" : "bjs_roundTripUnsafePointer", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripUnsafePointer", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" - } - } - } - } - ], - "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" - } - } - } - }, - { - "abiName" : "bjs_roundTripUnsafeMutablePointer", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripUnsafeMutablePointer", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" - } - } - } - } - ], - "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" - } - } - } - }, - { - "abiName" : "bjs_roundTripJSObject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripJSObject", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "jsObject" : { - - } - } - } - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_roundTripDictionaryExport", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripDictionaryExport", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "dictionary" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - ], - "returnType" : { - "dictionary" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "abiName" : "bjs_roundTripOptionalDictionaryExport", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalDictionaryExport", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "dictionary" : { - "_0" : { - "string" : { - - } - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "dictionary" : { - "_0" : { - "string" : { - - } - } - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_roundTripJSValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripJSValue", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "jsValue" : { - - } - } - } - ], - "returnType" : { - "jsValue" : { - - } - } - }, - { - "abiName" : "bjs_roundTripOptionalJSValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalJSValue", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "jsValue" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "jsValue" : { - - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_roundTripOptionalJSValueArray", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripOptionalJSValueArray", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "jsValue" : { - - } - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "jsValue" : { - - } - } - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_makeImportedFoo", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "makeImportedFoo", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "jsObject" : { - "_0" : "Foo" - } - } - }, - { - "abiName" : "bjs_throwsSwiftError", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsSwiftError", - "parameters" : [ - { - "label" : "shouldThrow", - "name" : "shouldThrow", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_throwsWithIntResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithIntResult", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_throwsWithStringResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithStringResult", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_throwsWithBoolResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithBoolResult", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_throwsWithFloatResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithFloatResult", - "parameters" : [ - - ], - "returnType" : { - "float" : { - - } - } - }, - { - "abiName" : "bjs_throwsWithDoubleResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithDoubleResult", - "parameters" : [ - - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_throwsWithSwiftHeapObjectResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithSwiftHeapObjectResult", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_throwsWithJSObjectResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "throwsWithJSObjectResult", - "parameters" : [ - - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripVoid", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripVoid", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripInt", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripInt", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_asyncRoundTripFloat", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripFloat", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "float" : { - - } - } - } - ], - "returnType" : { - "float" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripDouble", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripDouble", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripBool", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripBool", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripString", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripString", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_asyncRoundTripSwiftHeapObject", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripSwiftHeapObject", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_asyncRoundTripJSObject", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripJSObject", - "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "jsObject" : { - - } - } - } - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_takeGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "takeGreeter", - "parameters" : [ - { - "label" : "g", - "name" : "g", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "label" : "name", - "name" : "name", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_createCalculator", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createCalculator", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Calculator" - } - } - }, - { - "abiName" : "bjs_useCalculator", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "useCalculator", - "parameters" : [ - { - "label" : "calc", - "name" : "calc", - "type" : { - "swiftHeapObject" : { - "_0" : "Calculator" - } - } - }, - { - "label" : "x", - "name" : "x", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "y", - "name" : "y", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_testGreeterToJSValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testGreeterToJSValue", - "parameters" : [ - - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_testCalculatorToJSValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testCalculatorToJSValue", - "parameters" : [ - - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_testSwiftClassAsJSValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testSwiftClassAsJSValue", - "parameters" : [ - { - "label" : "greeter", - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_setDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setDirection", - "parameters" : [ - { - "label" : "_", - "name" : "direction", - "type" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Direction" - } - } - }, - { - "abiName" : "bjs_getDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getDirection", - "parameters" : [ - - ], - "returnType" : { - "caseEnum" : { - "_0" : "Direction" - } - } - }, - { - "abiName" : "bjs_processDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processDirection", - "parameters" : [ - { - "label" : "_", - "name" : "input", - "type" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Status" - } - } - }, - { - "abiName" : "bjs_setTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setTheme", - "parameters" : [ - { - "label" : "_", - "name" : "theme", - "type" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - }, - { - "abiName" : "bjs_getTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getTheme", - "parameters" : [ - - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - }, - { - "abiName" : "bjs_setHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setHttpStatus", - "parameters" : [ - { - "label" : "_", - "name" : "status", - "type" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - }, - { - "abiName" : "bjs_getHttpStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getHttpStatus", - "parameters" : [ - - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - }, - { - "abiName" : "bjs_setFileSize", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setFileSize", - "parameters" : [ - { - "label" : "_", - "name" : "size", - "type" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - } - }, - { - "abiName" : "bjs_getFileSize", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getFileSize", - "parameters" : [ - - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - } - }, - { - "abiName" : "bjs_setSessionId", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setSessionId", - "parameters" : [ - { - "label" : "_", - "name" : "session", - "type" : { - "rawValueEnum" : { - "_0" : "SessionId", - "_1" : "UInt64" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "SessionId", - "_1" : "UInt64" - } - } - }, - { - "abiName" : "bjs_getSessionId", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getSessionId", - "parameters" : [ - - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "SessionId", - "_1" : "UInt64" - } - } - }, - { - "abiName" : "bjs_processTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processTheme", - "parameters" : [ - { - "label" : "_", - "name" : "theme", - "type" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - } - }, - { - "abiName" : "bjs_setTSDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setTSDirection", - "parameters" : [ - { - "label" : "_", - "name" : "direction", - "type" : { - "caseEnum" : { - "_0" : "TSDirection" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "TSDirection" - } - } - }, - { - "abiName" : "bjs_getTSDirection", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getTSDirection", - "parameters" : [ - - ], - "returnType" : { - "caseEnum" : { - "_0" : "TSDirection" - } - } - }, - { - "abiName" : "bjs_setTSTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setTSTheme", - "parameters" : [ - { - "label" : "_", - "name" : "theme", - "type" : { - "rawValueEnum" : { - "_0" : "TSTheme", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "TSTheme", - "_1" : "String" - } - } - }, - { - "abiName" : "bjs_getTSTheme", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getTSTheme", - "parameters" : [ - - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "TSTheme", - "_1" : "String" - } - } - }, - { - "abiName" : "bjs_createConverter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createConverter", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Utils.Converter" - } - } - }, - { - "abiName" : "bjs_useConverter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "useConverter", - "parameters" : [ - { - "label" : "converter", - "name" : "converter", - "type" : { - "swiftHeapObject" : { - "_0" : "Utils.Converter" - } - } - }, - { - "label" : "value", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_roundTripConverterArray", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripConverterArray", - "parameters" : [ - { - "label" : "_", - "name" : "converters", - "type" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Utils.Converter" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Utils.Converter" - } - } - } - } - }, - { - "abiName" : "bjs_createHTTPServer", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createHTTPServer", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Networking.API.HTTPServer" - } - } - }, - { - "abiName" : "bjs_createUUID", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createUUID", - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "UUID" - } - } - }, - { - "abiName" : "bjs_roundTripUUID", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripUUID", - "parameters" : [ - { - "label" : "_", - "name" : "uuid", - "type" : { - "swiftHeapObject" : { - "_0" : "UUID" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "UUID" - } - } - }, - { - "abiName" : "bjs_roundtripNetworkingAPIMethod", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripNetworkingAPIMethod", - "parameters" : [ - { - "label" : "_", - "name" : "method", - "type" : { - "caseEnum" : { - "_0" : "Networking.API.Method" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Networking.API.Method" - } - } - }, - { - "abiName" : "bjs_roundtripConfigurationLogLevel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripConfigurationLogLevel", - "parameters" : [ - { - "label" : "_", - "name" : "level", - "type" : { - "rawValueEnum" : { - "_0" : "Configuration.LogLevel", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Configuration.LogLevel", - "_1" : "String" - } - } - }, - { - "abiName" : "bjs_roundtripConfigurationPort", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripConfigurationPort", - "parameters" : [ - { - "label" : "_", - "name" : "port", - "type" : { - "rawValueEnum" : { - "_0" : "Configuration.Port", - "_1" : "Int" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Configuration.Port", - "_1" : "Int" - } - } - }, - { - "abiName" : "bjs_processConfigurationLogLevel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processConfigurationLogLevel", - "parameters" : [ - { - "label" : "_", - "name" : "level", - "type" : { - "rawValueEnum" : { - "_0" : "Configuration.LogLevel", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "Configuration.Port", - "_1" : "Int" - } - } - }, - { - "abiName" : "bjs_roundtripInternalSupportedMethod", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripInternalSupportedMethod", - "parameters" : [ - { - "label" : "_", - "name" : "method", - "type" : { - "caseEnum" : { - "_0" : "Internal.SupportedMethod" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "Internal.SupportedMethod" - } - } - }, - { - "abiName" : "bjs_roundtripAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripAPIResult", - "parameters" : [ - { - "label" : "result", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultSuccess", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultSuccess", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultFailure", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultFailure", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultInfo", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultInfo", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultFlag", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultFlag", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultRate", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultRate", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "float" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_makeAPIResultPrecise", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPIResultPrecise", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "abiName" : "bjs_roundtripComplexResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripComplexResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultSuccess", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultSuccess", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultError", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultError", - "parameters" : [ - { - "label" : "_", - "name" : "message", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "code", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultLocation", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultLocation", - "parameters" : [ - { - "label" : "_", - "name" : "lat", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "lng", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "name", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultStatus", - "parameters" : [ - { - "label" : "_", - "name" : "active", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "_", - "name" : "code", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "_", - "name" : "message", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultCoordinates", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultCoordinates", - "parameters" : [ - { - "label" : "_", - "name" : "x", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "y", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "z", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultComprehensive", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultComprehensive", - "parameters" : [ - { - "label" : "_", - "name" : "flag1", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "_", - "name" : "flag2", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "_", - "name" : "count1", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "_", - "name" : "count2", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "_", - "name" : "value1", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "value2", - "type" : { - "double" : { - - } - } - }, - { - "label" : "_", - "name" : "text1", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "text2", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "text3", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeComplexResultInfo", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeComplexResultInfo", - "parameters" : [ - - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ComplexResult" - } - } - }, - { - "abiName" : "bjs_makeUtilitiesResultSuccess", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeUtilitiesResultSuccess", - "parameters" : [ - { - "label" : "_", - "name" : "message", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "Utilities.Result" - } - } - }, - { - "abiName" : "bjs_makeUtilitiesResultFailure", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeUtilitiesResultFailure", - "parameters" : [ - { - "label" : "_", - "name" : "error", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "code", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "Utilities.Result" - } - } - }, - { - "abiName" : "bjs_makeUtilitiesResultStatus", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeUtilitiesResultStatus", - "parameters" : [ - { - "label" : "_", - "name" : "active", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "_", - "name" : "code", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "_", - "name" : "message", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "Utilities.Result" - } - } - }, - { - "abiName" : "bjs_makeAPINetworkingResultSuccess", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPINetworkingResultSuccess", - "parameters" : [ - { - "label" : "_", - "name" : "message", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "API.NetworkingResult" - } - } - }, - { - "abiName" : "bjs_makeAPINetworkingResultFailure", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAPINetworkingResultFailure", - "parameters" : [ - { - "label" : "_", - "name" : "error", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "code", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "API.NetworkingResult" - } - } - }, - { - "abiName" : "bjs_roundtripUtilitiesResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripUtilitiesResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "Utilities.Result" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "Utilities.Result" - } - } - }, - { - "abiName" : "bjs_roundtripAPINetworkingResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundtripAPINetworkingResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "API.NetworkingResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "API.NetworkingResult" - } - } - }, - { - "abiName" : "bjs_roundTripAllTypesResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripAllTypesResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "AllTypesResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "AllTypesResult" - } - } - }, - { - "abiName" : "bjs_roundTripTypedPayloadResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripTypedPayloadResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "TypedPayloadResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "TypedPayloadResult" - } - } - }, - { - "abiName" : "bjs_createPropertyHolder", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createPropertyHolder", - "parameters" : [ - { - "label" : "intValue", - "name" : "intValue", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "floatValue", - "name" : "floatValue", - "type" : { - "float" : { - - } - } - }, - { - "label" : "doubleValue", - "name" : "doubleValue", - "type" : { - "double" : { - - } - } - }, - { - "label" : "boolValue", - "name" : "boolValue", - "type" : { - "bool" : { - - } - } - }, - { - "label" : "stringValue", - "name" : "stringValue", - "type" : { - "string" : { - - } - } - }, - { - "label" : "jsObject", - "name" : "jsObject", - "type" : { - "jsObject" : { - - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "PropertyHolder" - } - } - }, - { - "abiName" : "bjs_testPropertyHolder", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testPropertyHolder", - "parameters" : [ - { - "label" : "holder", - "name" : "holder", - "type" : { - "swiftHeapObject" : { - "_0" : "PropertyHolder" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_resetObserverCounts", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "resetObserverCounts", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_getObserverStats", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getObserverStats", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_formatName", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "formatName", - "parameters" : [ - { - "label" : "_", - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "label" : "transform", - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_makeFormatter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeFormatter", - "parameters" : [ - { - "label" : "prefix", - "name" : "prefix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_makeAdder", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeAdder", - "parameters" : [ - { - "label" : "base", - "name" : "base", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "abiName" : "bjs_getSharedSubject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getSharedSubject", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "IdentityTestSubject" - } - } - }, - { - "abiName" : "bjs_resetSharedSubject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "resetSharedSubject", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_getRetainLeakSubject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getRetainLeakSubject", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "RetainLeakSubject" - } - } - }, - { - "abiName" : "bjs_resetRetainLeakSubject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "resetRetainLeakSubject", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_getRetainLeakDeinits", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getRetainLeakDeinits", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_resetRetainLeakDeinits", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "resetRetainLeakDeinits", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_setupArrayPool", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setupArrayPool", - "parameters" : [ - { - "label" : "_", - "name" : "count", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_getArrayPool", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getArrayPool", - "parameters" : [ - - ], - "returnType" : { - "array" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "ArrayIdentityElement" - } - } - } - } - }, - { - "abiName" : "bjs_getArrayPoolElement", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getArrayPoolElement", - "parameters" : [ - { - "label" : "_", - "name" : "index", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "ArrayIdentityElement" - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_getArrayPoolDeinits", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getArrayPoolDeinits", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_resetArrayPoolDeinits", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "resetArrayPoolDeinits", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_clearArrayPool", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "clearArrayPool", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_roundTripPointerFields", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripPointerFields", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "PointerFields" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "PointerFields" - } - } - }, - { - "abiName" : "bjs_testStructDefault", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testStructDefault", - "parameters" : [ - { - "defaultValue" : { - "structLiteral" : { - "_0" : "DataPoint", - "_1" : [ - { - "name" : "x", - "value" : { - "float" : { - "_0" : 1 - } - } - }, - { - "name" : "y", - "value" : { - "float" : { - "_0" : 2 - } - } - }, - { - "name" : "label", - "value" : { - "string" : { - "_0" : "default" - } - } - }, - { - "name" : "optCount", - "value" : { - "null" : { - - } - } - }, - { - "name" : "optFlag", - "value" : { - "null" : { - - } - } - } - ] - } - }, - "label" : "point", - "name" : "point", - "type" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_cartToJSObject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "cartToJSObject", - "parameters" : [ - { - "label" : "_", - "name" : "cart", - "type" : { - "swiftStruct" : { - "_0" : "CopyableCart" - } - } - } - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_nestedCartToJSObject", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "nestedCartToJSObject", - "parameters" : [ - { - "label" : "_", - "name" : "cart", - "type" : { - "swiftStruct" : { - "_0" : "CopyableNestedCart" - } - } - } - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "abiName" : "bjs_roundTripDataPoint", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripDataPoint", - "parameters" : [ - { - "label" : "_", - "name" : "data", - "type" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - }, - { - "abiName" : "bjs_roundTripPublicPoint", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripPublicPoint", - "parameters" : [ - { - "label" : "_", - "name" : "point", - "type" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - } - }, - { - "abiName" : "bjs_roundTripContact", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripContact", - "parameters" : [ - { - "label" : "_", - "name" : "contact", - "type" : { - "swiftStruct" : { - "_0" : "Contact" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Contact" - } - } - }, - { - "abiName" : "bjs_roundTripConfig", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripConfig", - "parameters" : [ - { - "label" : "_", - "name" : "config", - "type" : { - "swiftStruct" : { - "_0" : "Config" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Config" - } - } - }, - { - "abiName" : "bjs_roundTripSessionData", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripSessionData", - "parameters" : [ - { - "label" : "_", - "name" : "session", - "type" : { - "swiftStruct" : { - "_0" : "SessionData" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "SessionData" - } - } - }, - { - "abiName" : "bjs_roundTripValidationReport", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripValidationReport", - "parameters" : [ - { - "label" : "_", - "name" : "report", - "type" : { - "swiftStruct" : { - "_0" : "ValidationReport" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "ValidationReport" - } - } - }, - { - "abiName" : "bjs_roundTripAdvancedConfig", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripAdvancedConfig", - "parameters" : [ - { - "label" : "_", - "name" : "config", - "type" : { - "swiftStruct" : { - "_0" : "AdvancedConfig" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "AdvancedConfig" - } - } - }, - { - "abiName" : "bjs_roundTripMeasurementConfig", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripMeasurementConfig", - "parameters" : [ - { - "label" : "_", - "name" : "config", - "type" : { - "swiftStruct" : { - "_0" : "MeasurementConfig" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "MeasurementConfig" - } - } - }, - { - "abiName" : "bjs_updateValidationReport", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "updateValidationReport", - "parameters" : [ - { - "label" : "_", - "name" : "newResult", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - }, - { - "label" : "_", - "name" : "report", - "type" : { - "swiftStruct" : { - "_0" : "ValidationReport" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "ValidationReport" - } - } - }, - { - "abiName" : "bjs_testContainerWithStruct", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testContainerWithStruct", - "parameters" : [ - { - "label" : "_", - "name" : "point", - "type" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Container" - } - } - }, - { - "abiName" : "bjs_roundTripJSObjectContainer", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripJSObjectContainer", - "parameters" : [ - { - "label" : "_", - "name" : "container", - "type" : { - "swiftStruct" : { - "_0" : "JSObjectContainer" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "JSObjectContainer" - } - } - }, - { - "abiName" : "bjs_roundTripFooContainer", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripFooContainer", - "parameters" : [ - { - "label" : "_", - "name" : "container", - "type" : { - "swiftStruct" : { - "_0" : "FooContainer" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "FooContainer" - } - } - }, - { - "abiName" : "bjs_roundTripArrayMembers", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripArrayMembers", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "ArrayMembers" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "ArrayMembers" - } - } - }, - { - "abiName" : "bjs_arrayMembersSum", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "arrayMembersSum", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "ArrayMembers" - } - } - }, - { - "label" : "_", - "name" : "values", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_arrayMembersFirst", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "arrayMembersFirst", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "swiftStruct" : { - "_0" : "ArrayMembers" - } - } - }, - { - "label" : "_", - "name" : "values", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "protocols" : [ - { - "methods" : [ - - ], - "name" : "ArrayElementProtocol", - "properties" : [ - { - "isReadonly" : false, - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ] - }, - { - "methods" : [ - { - "abiName" : "bjs_DataProcessor_increment", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "increment", - "parameters" : [ - { - "label" : "by", - "name" : "amount", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_getValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getValue", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_DataProcessor_setLabelElements", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "setLabelElements", - "parameters" : [ - { - "label" : "_", - "name" : "labelPrefix", - "type" : { - "string" : { - - } - } - }, - { - "label" : "_", - "name" : "labelSuffix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_getLabel", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getLabel", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_isEven", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "isEven", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_processGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_createGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createGreeter", - "parameters" : [ - - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "abiName" : "bjs_DataProcessor_processOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "processOptionalGreeter", - "parameters" : [ - { - "label" : "_", - "name" : "greeter", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_createOptionalGreeter", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "createOptionalGreeter", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_DataProcessor_handleAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "handleAPIResult", - "parameters" : [ - { - "label" : "_", - "name" : "result", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "abiName" : "bjs_DataProcessor_getAPIResult", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getAPIResult", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - } - ], - "name" : "DataProcessor", - "properties" : [ - { - "isReadonly" : false, - "name" : "count", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : false, - "name" : "optionalTag", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "name" : "optionalCount", - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "name" : "direction", - "type" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "name" : "optionalTheme", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "name" : "httpStatus", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "HttpStatus", - "_1" : "Int" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "name" : "apiResult", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : false, - "name" : "helper", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "isReadonly" : false, - "name" : "optionalHelper", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - ] - } - ], - "structs" : [ - { - "methods" : [ - - ], - "name" : "Point", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "x", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "y", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "Point" - }, - { - "constructor" : { - "abiName" : "bjs_PointerFields_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "raw", - "name" : "raw", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeRawPointer" - } - } - } - }, - { - "label" : "mutRaw", - "name" : "mutRaw", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutableRawPointer" - } - } - } - }, - { - "label" : "opaque", - "name" : "opaque", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" - } - } - } - }, - { - "label" : "ptr", - "name" : "ptr", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" - } - } - } - }, - { - "label" : "mutPtr", - "name" : "mutPtr", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" - } - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "PointerFields", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "raw", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeRawPointer" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "mutRaw", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutableRawPointer" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "opaque", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "ptr", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "mutPtr", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" - } - } - } - } - ], - "swiftCallName" : "PointerFields" - }, - { - "constructor" : { - "abiName" : "bjs_DataPoint_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "x", - "name" : "x", - "type" : { - "double" : { - - } - } - }, - { - "label" : "y", - "name" : "y", - "type" : { - "double" : { - - } - } - }, - { - "label" : "label", - "name" : "label", - "type" : { - "string" : { - - } - } - }, - { - "label" : "optCount", - "name" : "optCount", - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - }, - { - "label" : "optFlag", - "name" : "optFlag", - "type" : { - "nullable" : { - "_0" : { - "bool" : { - - } - }, - "_1" : "null" - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_DataPoint_static_origin", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "origin", - "parameters" : [ - - ], - "returnType" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - }, - "staticContext" : { - "structName" : { - "_0" : "DataPoint" - } - } - } - ], - "name" : "DataPoint", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "x", - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "y", - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "label", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "optCount", - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "optFlag", - "type" : { - "nullable" : { - "_0" : { - "bool" : { - - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "dimensions", - "staticContext" : { - "structName" : { - "_0" : "DataPoint" - } - }, - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "DataPoint" - }, - { - "constructor" : { - "abiName" : "bjs_PublicPoint_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "x", - "name" : "x", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "y", - "name" : "y", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ] - }, - "explicitAccessControl" : "public", - "methods" : [ - - ], - "name" : "PublicPoint", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "x", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "y", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "PublicPoint" - }, - { - "methods" : [ - - ], - "name" : "Address", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "street", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "city", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "zipCode", - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "Address" - }, - { - "methods" : [ - - ], - "name" : "Contact", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "age", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "address", - "type" : { - "swiftStruct" : { - "_0" : "Address" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "email", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "secondaryAddress", - "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "Address" - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "Contact" - }, - { - "methods" : [ - - ], - "name" : "Config", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "theme", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "direction", - "type" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "status", - "type" : { - "caseEnum" : { - "_0" : "Status" - } - } - } - ], - "swiftCallName" : "Config" - }, - { - "methods" : [ - - ], - "name" : "SessionData", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "id", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "owner", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "SessionData" - }, - { - "methods" : [ - - ], - "name" : "ValidationReport", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "id", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "result", - "type" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "status", - "type" : { - "nullable" : { - "_0" : { - "caseEnum" : { - "_0" : "Status" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "outcome", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "ValidationReport" - }, - { - "methods" : [ - - ], - "name" : "AdvancedConfig", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "id", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "title", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "enabled", - "type" : { - "bool" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "theme", - "type" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "status", - "type" : { - "caseEnum" : { - "_0" : "Status" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "result", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "APIResult" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "metadata", - "type" : { - "nullable" : { - "_0" : { - "jsObject" : { - - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "location", - "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "defaults", - "type" : { - "swiftStruct" : { - "_0" : "ConfigStruct" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "overrideDefaults", - "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "ConfigStruct" - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "AdvancedConfig" - }, - { - "methods" : [ - - ], - "name" : "MeasurementConfig", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "precision", - "type" : { - "rawValueEnum" : { - "_0" : "Precision", - "_1" : "Float" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "ratio", - "type" : { - "rawValueEnum" : { - "_0" : "Ratio", - "_1" : "Double" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "optionalPrecision", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Precision", - "_1" : "Float" - } - }, - "_1" : "null" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "optionalRatio", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Ratio", - "_1" : "Double" - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "MeasurementConfig" - }, - { - "constructor" : { - "abiName" : "bjs_MathOperations_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "defaultValue" : { - "double" : { - "_0" : 0 - } - }, - "label" : "baseValue", - "name" : "baseValue", - "type" : { - "double" : { - - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_MathOperations_add", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "add", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "double" : { - - } - } - }, - { - "defaultValue" : { - "double" : { - "_0" : 10 - } - }, - "label" : "b", - "name" : "b", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_MathOperations_multiply", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "multiply", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "double" : { - - } - } - }, - { - "label" : "b", - "name" : "b", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_MathOperations_static_subtract", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "subtract", - "parameters" : [ - { - "label" : "a", - "name" : "a", - "type" : { - "double" : { - - } - } - }, - { - "defaultValue" : { - "double" : { - "_0" : 5 - } - }, - "label" : "b", - "name" : "b", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - }, - "staticContext" : { - "structName" : { - "_0" : "MathOperations" - } - } - } - ], - "name" : "MathOperations", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "baseValue", - "type" : { - "double" : { - - } - } - } - ], - "swiftCallName" : "MathOperations" - }, - { - "methods" : [ - { - "abiName" : "bjs_CopyableCart_static_fromJSObject", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "fromJSObject", - "parameters" : [ - { - "label" : "_", - "name" : "object", - "type" : { - "jsObject" : { - - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "CopyableCart" - } - }, - "staticContext" : { - "structName" : { - "_0" : "CopyableCart" - } - } - } - ], - "name" : "CopyableCart", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "x", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "note", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "CopyableCart" - }, - { - "methods" : [ - - ], - "name" : "CopyableCartItem", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "sku", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "quantity", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "swiftCallName" : "CopyableCartItem" - }, - { - "methods" : [ - { - "abiName" : "bjs_CopyableNestedCart_static_fromJSObject", - "effects" : { - "isAsync" : false, - "isStatic" : true, - "isThrows" : false - }, - "name" : "fromJSObject", - "parameters" : [ - { - "label" : "_", - "name" : "object", - "type" : { - "jsObject" : { - - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "CopyableNestedCart" - } - }, - "staticContext" : { - "structName" : { - "_0" : "CopyableNestedCart" - } - } - } - ], - "name" : "CopyableNestedCart", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "id", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "item", - "type" : { - "swiftStruct" : { - "_0" : "CopyableCartItem" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "shippingAddress", - "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "Address" - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "CopyableNestedCart" - }, - { - "methods" : [ - - ], - "name" : "ConfigStruct", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "defaultConfig", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, - "type" : { - "string" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "maxRetries", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "isReadonly" : false, - "isStatic" : true, - "name" : "timeout", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : true, - "name" : "computedSetting", - "staticContext" : { - "structName" : { - "_0" : "ConfigStruct" - } - }, - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "ConfigStruct" - }, - { - "constructor" : { - "abiName" : "bjs_Vector2D_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "dx", - "name" : "dx", - "type" : { - "double" : { - - } - } - }, - { - "label" : "dy", - "name" : "dy", - "type" : { - "double" : { - - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_Vector2D_magnitude", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "magnitude", - "parameters" : [ - - ], - "returnType" : { - "double" : { - - } - } - }, - { - "abiName" : "bjs_Vector2D_scaled", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "scaled", - "parameters" : [ - { - "label" : "by", - "name" : "factor", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Vector2D" - } - } - } - ], - "name" : "Vector2D", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "dx", - "type" : { - "double" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "dy", - "type" : { - "double" : { - - } - } - } - ], - "swiftCallName" : "Vector2D" - }, - { - "methods" : [ - - ], - "name" : "JSObjectContainer", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "object", - "type" : { - "jsObject" : { - - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "optionalObject", - "type" : { - "nullable" : { - "_0" : { - "jsObject" : { - - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "JSObjectContainer" - }, - { - "methods" : [ - - ], - "name" : "FooContainer", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "foo", - "type" : { - "jsObject" : { - "_0" : "Foo" - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "optionalFoo", - "type" : { - "nullable" : { - "_0" : { - "jsObject" : { - "_0" : "Foo" - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "FooContainer" - }, - { - "methods" : [ - { - "abiName" : "bjs_ArrayMembers_sumValues", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "sumValues", - "parameters" : [ - { - "label" : "_", - "name" : "values", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "abiName" : "bjs_ArrayMembers_firstString", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "firstString", - "parameters" : [ - { - "label" : "_", - "name" : "values", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "name" : "ArrayMembers", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "ints", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "optStrings", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - }, - "_1" : "null" - } - } - } - ], - "swiftCallName" : "ArrayMembers" - } - ] - }, - "imported" : { - "children" : [ - { - "functions" : [ - - ], - "types" : [ - { - "constructor" : { - "parameters" : [ - { - "name" : "id", - "type" : { - "string" : { - - } - } - } - ] - }, - "getters" : [ - { - "name" : "id", - "type" : { - "string" : { - - } - } - } - ], - "methods" : [ - - ], - "name" : "ArrayElementObject", - "setters" : [ - - ], - "staticMethods" : [ - - ] - }, - { - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "ArraySupportImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsIntArrayLength", - "parameters" : [ - { - "name" : "items", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripIntArray", - "parameters" : [ - { - "name" : "items", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripNumberArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripStringArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripBoolArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "bool" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "bool" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripJSValueArray", - "parameters" : [ - { - "name" : "v", - "type" : { - "array" : { - "_0" : { - "jsValue" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "jsValue" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripJSObjectArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "jsObject" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "jsObject" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripJSClassArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalIntArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalStringArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalBoolArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "bool" : { - - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "bool" : { - - } - }, - "_1" : "null" - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalJSValueArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsValue" : { - - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsValue" : { - - } - }, - "_1" : "null" - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalJSObjectArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { - - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { - - } - }, - "_1" : "null" - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalJSClassArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" - } - }, - "_1" : "null" - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "nullable" : { - "_0" : { - "jsObject" : { - "_0" : "ArrayElementObject" - } - }, - "_1" : "null" - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsSumNumberArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsCreateNumberArray", - "parameters" : [ - - ], - "returnType" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runJsArraySupportTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "AsyncImportImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripVoid", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripNumber", - "parameters" : [ - { - "name" : "v", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripBool", - "parameters" : [ - { - "name" : "v", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripString", - "parameters" : [ - { - "name" : "v", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripOptionalString", - "parameters" : [ - { - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - }, - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripOptionalNumber", - "parameters" : [ - { - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "double" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "double" : { - - } - }, - "_1" : "null" - } - } - }, - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripBoolArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "bool" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "bool" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripIntArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripStringArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripFeatureFlag", - "parameters" : [ - { - "name" : "v", - "type" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" - } - } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "ClosureSupportImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyVoid", - "parameters" : [ - { - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_y", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyBool", - "parameters" : [ - { - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_Sb", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyInt", - "parameters" : [ - { - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyDouble", - "parameters" : [ - { - "name" : "value", - "type" : { - "double" : { - - } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "double" : { - - } - } - ], - "returnType" : { - "double" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyString", - "parameters" : [ - { - "name" : "value", - "type" : { - "string" : { - - } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsApplyJSObject", - "parameters" : [ - { - "name" : "value", - "type" : { - "jsObject" : { - - } - } - }, - { - "name" : "transform", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTests8JSObjectC_8JSObjectC", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "jsObject" : { - - } - } - ], - "returnType" : { - "jsObject" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "jsObject" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsMakeIntToInt", - "parameters" : [ - { - "name" : "base", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsMakeDoubleToDouble", - "parameters" : [ - { - "name" : "base", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSd_Sd", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "double" : { - - } - } - ], - "returnType" : { - "double" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsMakeStringToString", - "parameters" : [ - { - "name" : "prefix", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsCallTwice", - "parameters" : [ - { - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSi_y", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "void" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsCallBinary", - "parameters" : [ - { - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSiSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsCallTriple", - "parameters" : [ - { - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsSiSiSi_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsCallAfterRelease", - "parameters" : [ - { - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_y", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsOptionalInvoke", - "parameters" : [ - { - "name" : "callback", - "type" : { - "nullable" : { - "_0" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_Sb", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsStoreClosure", - "parameters" : [ - { - "name" : "callback", - "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsy_y", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsCallStoredClosure", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsHeapCount", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runJsClosureSupportTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "DefaultArgumentImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runJsDefaultArgumentTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "DictionarySupportImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripDictionaryInt", - "parameters" : [ - { - "name" : "values", - "type" : { - "dictionary" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - ], - "returnType" : { - "dictionary" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripDictionaryBool", - "parameters" : [ - { - "name" : "values", - "type" : { - "dictionary" : { - "_0" : { - "bool" : { - - } - } - } - } - } - ], - "returnType" : { - "dictionary" : { - "_0" : { - "bool" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripDictionaryDouble", - "parameters" : [ - { - "name" : "values", - "type" : { - "dictionary" : { - "_0" : { - "double" : { - - } - } - } - } - } - ], - "returnType" : { - "dictionary" : { - "_0" : { - "double" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripDictionaryJSObject", - "parameters" : [ - { - "name" : "values", - "type" : { - "dictionary" : { - "_0" : { - "jsObject" : { - - } - } - } - } - } - ], - "returnType" : { - "dictionary" : { - "_0" : { - "jsObject" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripDictionaryJSValue", - "parameters" : [ - { - "name" : "values", - "type" : { - "dictionary" : { - "_0" : { - "jsValue" : { - - } - } - } - } - } - ], - "returnType" : { - "dictionary" : { - "_0" : { - "jsValue" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripDictionaryDoubleArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "dictionary" : { - "_0" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - } - } - } - ], - "returnType" : { - "dictionary" : { - "_0" : { - "array" : { - "_0" : { - "double" : { - - } - } - } - } - } - } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "constructor" : { - "parameters" : [ - { - "name" : "value", - "type" : { - "string" : { - - } - } - } - ] - }, - "getters" : [ - { - "name" : "value", - "type" : { - "string" : { - - } - } - } - ], - "methods" : [ - - ], - "name" : "Foo", - "setters" : [ - - ], - "staticMethods" : [ - - ] - } - ] - }, - { - "functions" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripVoid", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripNumber", - "parameters" : [ - { - "name" : "v", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripBool", - "parameters" : [ - { - "name" : "v", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripString", - "parameters" : [ - { - "name" : "v", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripJSValue", - "parameters" : [ - { - "name" : "v", - "type" : { - "jsValue" : { - - } - } - } - ], - "returnType" : { - "jsValue" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsThrowOrVoid", - "parameters" : [ - { - "name" : "shouldThrow", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsThrowOrNumber", - "parameters" : [ - { - "name" : "shouldThrow", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsThrowOrBool", - "parameters" : [ - { - "name" : "shouldThrow", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "bool" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsThrowOrString", - "parameters" : [ - { - "name" : "shouldThrow", - "type" : { - "bool" : { - - } - } - } - ], - "returnType" : { - "string" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripFeatureFlag", - "parameters" : [ - { - "name" : "flag", - "type" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" - } - } - }, - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runAsyncWorks", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "fetchWeatherData", - "parameters" : [ - { - "name" : "city", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "jsObject" : { - "_0" : "WeatherData" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "jsName" : "$jsWeirdFunction", - "name" : "_jsWeirdFunction", - "parameters" : [ - - ], - "returnType" : { - "double" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "from" : "global", - "name" : "parseInt", - "parameters" : [ - { - "name" : "string", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "double" : { - - } - } - } - ], - "globalGetters" : [ - { - "from" : "global", - "name" : "globalObject1", - "type" : { - "jsValue" : { - - } - } - } - ], - "types" : [ - { - "constructor" : { - "parameters" : [ - { - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "name" : "prefix", - "type" : { - "string" : { - - } - } - } - ] - }, - "getters" : [ - { - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "name" : "prefix", - "type" : { - "string" : { - - } - } - } - ], - "methods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "greet", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "changeName", - "parameters" : [ - { - "name" : "name", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "void" : { - - } - } - } - ], - "name" : "JsGreeter", - "setters" : [ - { - "functionName" : "name_set", - "name" : "name", - "type" : { - "string" : { - - } - } - } - ], - "staticMethods" : [ - - ] - }, - { - "getters" : [ - { - "name" : "temperature", - "type" : { - "double" : { - - } - } - }, - { - "name" : "description", - "type" : { - "string" : { - - } - } - }, - { - "name" : "humidity", - "type" : { - "double" : { - - } - } - } - ], - "methods" : [ - - ], - "name" : "WeatherData", - "setters" : [ - { - "functionName" : "temperature_set", - "name" : "temperature", - "type" : { - "double" : { - - } - } - }, - { - "functionName" : "description_set", - "name" : "description", - "type" : { - "string" : { - - } - } - }, - { - "functionName" : "humidity_set", - "name" : "humidity", - "type" : { - "double" : { - - } - } - } - ], - "staticMethods" : [ - - ] - }, - { - "constructor" : { - "parameters" : [ - - ] - }, - "getters" : [ - - ], - "jsName" : "$WeirdClass", - "methods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "jsName" : "method-with-dashes", - "name" : "method_with_dashes", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "_WeirdClass", - "setters" : [ - - ], - "staticMethods" : [ - - ] - }, - { - "constructor" : { - "parameters" : [ - { - "name" : "value", - "type" : { - "double" : { - - } - } - } - ] - }, - "getters" : [ - - ], - "methods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "value", - "parameters" : [ - - ], - "returnType" : { - "double" : { - - } - } - } - ], - "name" : "StaticBox", - "setters" : [ - - ], - "staticMethods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "create", - "parameters" : [ - { - "name" : "value", - "type" : { - "double" : { - - } - } - } - ], - "returnType" : { - "jsObject" : { - "_0" : "StaticBox" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "value", - "parameters" : [ - - ], - "returnType" : { - "double" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "makeDefault", - "parameters" : [ - - ], - "returnType" : { - "jsObject" : { - "_0" : "StaticBox" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "jsName" : "with-dashes", - "name" : "with_dashes", - "parameters" : [ - - ], - "returnType" : { - "jsObject" : { - "_0" : "StaticBox" - } - } - } - ] - }, - { - "constructor" : { - "parameters" : [ - { - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "name" : "age", - "type" : { - "double" : { - - } - } - }, - { - "name" : "isCat", - "type" : { - "bool" : { - - } - } - } - ] - }, - "from" : "global", - "getters" : [ - { - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "name" : "age", - "type" : { - "double" : { - - } - } - }, - { - "name" : "isCat", - "type" : { - "bool" : { - - } - } - } - ], - "methods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "bark", - "parameters" : [ - - ], - "returnType" : { - "string" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "getIsCat", - "parameters" : [ - - ], - "returnType" : { - "bool" : { - - } - } - } - ], - "name" : "Animal", - "setters" : [ - { - "functionName" : "name_set", - "name" : "name", - "type" : { - "string" : { - - } - } - }, - { - "functionName" : "age_set", - "name" : "age", - "type" : { - "double" : { - - } - } - }, - { - "functionName" : "isCat_set", - "name" : "isCat", - "type" : { - "bool" : { - - } - } - } - ], - "staticMethods" : [ - - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "IdentityModeSupportImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runJsIdentityModeSupportTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - } - ] - } - ] - }, - { - "functions" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsTranslatePoint", - "parameters" : [ - { - "name" : "point", - "type" : { - "swiftStruct" : { - "_0" : "Point" - } - } - }, - { - "name" : "dx", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "name" : "dy", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "Point" - } - } - } - ], - "types" : [ - - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "IntegerTypesSupportImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripInt", - "parameters" : [ - { - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripUInt", - "parameters" : [ - { - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "word" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripInt8", - "parameters" : [ - { - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w8" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w8" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripUInt8", - "parameters" : [ - { - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w8" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w8" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripInt16", - "parameters" : [ - { - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w16" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w16" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripUInt16", - "parameters" : [ - { - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w16" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w16" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripInt32", - "parameters" : [ - { - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w32" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w32" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripUInt32", - "parameters" : [ - { - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w32" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w32" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripInt64", - "parameters" : [ - { - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w64" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "w64" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripUInt64", - "parameters" : [ - { - "name" : "v", - "type" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w64" - } - } - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : false, - "width" : "w64" - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runJsIntegerTypesSupportTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "constructor" : { - "parameters" : [ - { - "name" : "numbers", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "name" : "labels", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ] - }, - "getters" : [ - { - "name" : "numbers", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "name" : "labels", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "methods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "concatNumbers", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "concatLabels", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "firstLabel", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "string" : { - - } - } - } - ], - "name" : "JSClassWithArrayMembers", - "setters" : [ - { - "functionName" : "numbers_set", - "name" : "numbers", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "functionName" : "labels_set", - "name" : "labels", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "staticMethods" : [ - - ] - }, - { - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "JSClassSupportImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "makeJSClassWithArrayMembers", - "parameters" : [ - { - "name" : "numbers", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - }, - { - "name" : "labels", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "jsObject" : { - "_0" : "JSClassWithArrayMembers" - } - } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "constructor" : { - "parameters" : [ - - ] - }, - "from" : "global", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "MyJSClassInternal", - "setters" : [ - - ], - "staticMethods" : [ - - ] - }, - { - "constructor" : { - "parameters" : [ - - ] - }, - "from" : "global", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "MyJSClassPublic", - "setters" : [ - - ], - "staticMethods" : [ - - ] - }, - { - "constructor" : { - "parameters" : [ - - ] - }, - "from" : "global", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "MyJSClassPackage", - "setters" : [ - - ], - "staticMethods" : [ - - ] - } - ] - }, - { - "functions" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsFunctionWithPackageAccess", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsFunctionWithPublicAccess", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsFunctionWithInternalAccess", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsFunctionWithFilePrivateAccess", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true + "_0" : "ArrayIdentityElement" + } }, - "name" : "jsFunctionWithPrivateAccess", - "parameters" : [ - - ], - "returnType" : { - "void" : { + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_getArrayPoolDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getArrayPoolDeinits", + "parameters" : [ - } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } - ], - "types" : [ - - ] + } }, { - "functions" : [ + "abiName" : "bjs_resetArrayPoolDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetArrayPoolDeinits", + "parameters" : [ ], - "types" : [ - { - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "OptionalSupportImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalNumberNull", - "parameters" : [ - { - "name" : "value", - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "null" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalNumberUndefined", - "parameters" : [ - { - "name" : "value", - "type" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "undefined" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "_1" : "undefined" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalStringNull", - "parameters" : [ - { - "name" : "name", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "null" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalStringUndefined", - "parameters" : [ - { - "name" : "name", - "type" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "undefined" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "string" : { - - } - }, - "_1" : "undefined" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalJSValueArrayNull", - "parameters" : [ - { - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "jsValue" : { - - } - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "jsValue" : { - - } - } - } - }, - "_1" : "null" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalJSValueArrayUndefined", - "parameters" : [ - { - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "jsValue" : { - - } - } - } - }, - "_1" : "undefined" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "jsValue" : { - - } - } - } - }, - "_1" : "undefined" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalStringToStringDictionaryNull", - "parameters" : [ - { - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "dictionary" : { - "_0" : { - "string" : { - - } - } - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "dictionary" : { - "_0" : { - "string" : { + "returnType" : { + "void" : { - } - } - } - }, - "_1" : "null" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalStringToStringDictionaryUndefined", - "parameters" : [ - { - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "dictionary" : { - "_0" : { - "string" : { + } + } + }, + { + "abiName" : "bjs_clearArrayPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "clearArrayPool", + "parameters" : [ - } - } - } - }, - "_1" : "undefined" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "dictionary" : { - "_0" : { - "string" : { + ], + "returnType" : { + "void" : { - } - } - } - }, - "_1" : "undefined" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runJsOptionalSupportTests", - "parameters" : [ + } + } + } + ], + "identityMode" : "pointer", + "protocols" : [ - ], - "returnType" : { - "void" : { + ], + "structs" : [ - } - } - } - ] - } - ] - }, + ] + }, + "imported" : { + "children" : [ { "functions" : [ - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "from" : "global", - "name" : "gc", - "parameters" : [ - - ], - "returnType" : { - "void" : { - } - } - } ], "types" : [ { @@ -20762,7 +416,7 @@ "methods" : [ ], - "name" : "SwiftClassSupportImports", + "name" : "IdentityModeTestImports", "setters" : [ ], @@ -20773,123 +427,9 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsRoundTripGreeter", - "parameters" : [ - { - "name" : "greeter", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripUUID", - "parameters" : [ - { - "name" : "uuid", - "type" : { - "swiftHeapObject" : { - "_0" : "UUID" - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "UUID" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalGreeter", - "parameters" : [ - { - "name" : "greeter", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsConsumeLeakCheck", + "name" : "runJsIdentityModeTests", "parameters" : [ - { - "name" : "value", - "type" : { - "swiftHeapObject" : { - "_0" : "LeakCheck" - } - } - } - ], - "returnType" : { - "void" : { - } - } - }, - { - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsConsumeOptionalLeakCheck", - "parameters" : [ - { - "name" : "value", - "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "LeakCheck" - } - }, - "_1" : "null" - } - } - } ], "returnType" : { "void" : { @@ -20903,5 +443,5 @@ } ] }, - "moduleName" : "BridgeJSRuntimeTests" + "moduleName" : "BridgeJSIdentityTests" } \ No newline at end of file diff --git a/Utilities/bridge-js-generate.sh b/Utilities/bridge-js-generate.sh index 22182d24b..77bdd0833 100755 --- a/Utilities/bridge-js-generate.sh +++ b/Utilities/bridge-js-generate.sh @@ -6,5 +6,6 @@ swift build --package-path ./Plugins/BridgeJS --product BridgeJSTool ./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name BridgeJSRuntimeTests --target-dir ./Tests/BridgeJSRuntimeTests --output-dir ./Tests/BridgeJSRuntimeTests/Generated ./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name BridgeJSGlobalTests --target-dir ./Tests/BridgeJSGlobalTests --output-dir ./Tests/BridgeJSGlobalTests/Generated +./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name BridgeJSIdentityTests --target-dir ./Tests/BridgeJSIdentityTests --output-dir ./Tests/BridgeJSIdentityTests/Generated ./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name Benchmarks --target-dir ./Benchmarks/Sources --output-dir ./Benchmarks/Sources/Generated ./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name PlayBridgeJS --target-dir ./Examples/PlayBridgeJS/Sources/PlayBridgeJS --output-dir ./Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated From 7f61a8b3310f0cf3ba4dbd9bfc10296bdfe00873 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Fri, 17 Apr 2026 14:04:03 +0200 Subject: [PATCH 09/18] fix: Read identityMode from first skeleton that defines it When multiple targets share one createInstantiator (e.g. test package), use compactMap to find the first non-nil identityMode across all skeletons instead of reading from the first skeleton which may not have it set. --- Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 50d2a4317..2ee8cd869 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -983,7 +983,7 @@ public struct BridgeJSLink { try printer.indent { printer.write(lines: generateVariableDeclarations()) - let configIdentityMode = skeletons.compactMap(\.exported).first?.identityMode ?? "none" + let configIdentityMode = skeletons.compactMap(\.exported).compactMap(\.identityMode).first ?? "none" printer.write("const identityMode = options.identityMode ?? \"\(configIdentityMode)\";") printer.write( "const shouldUseIdentityMap = identityMode === \"pointer\" && typeof WeakRef !== \"undefined\" && typeof FinalizationRegistry !== \"undefined\";" From 40ed8d9f0f066d0cbf6756dc415a57819531d37b Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Tue, 21 Apr 2026 11:54:46 +0200 Subject: [PATCH 10/18] feat: Add identity mode benchmark infrastructure Extend run.js with --identity-mode, --identity-iterations, --identity-reuse-pools, and --identity-memory CLI flags. Extract identity scenarios into lib/identity-benchmarks.js: roundtrip reuse, bulk pool return (100 cached objects), churn (create-roundtrip-release), consume, and create paths. Memory telemetry via --identity-memory. Update README.md with identity mode flags and scenario descriptions. --- Benchmarks/README.md | 37 ++++ Benchmarks/lib/identity-benchmarks.js | 255 ++++++++++++++++++++++++++ Benchmarks/run.js | 45 ++++- 3 files changed, 330 insertions(+), 7 deletions(-) create mode 100644 Benchmarks/lib/identity-benchmarks.js diff --git a/Benchmarks/README.md b/Benchmarks/README.md index 65d867eba..409681eeb 100644 --- a/Benchmarks/README.md +++ b/Benchmarks/README.md @@ -35,3 +35,40 @@ node run.js --filter=Call node run.js --filter=/^Property access\// node run.js --filter=/string/i ``` + +## Identity Mode Benchmarks + +Compare `identityMode: "pointer"` vs default (`"none"`) for SwiftHeapObject wrapper caching. Requires `--expose-gc` for memory benchmarks. + +```bash +# Run identity benchmarks comparing both modes +node --expose-gc run.js --identity-mode=both + +# Pointer mode only +node --expose-gc run.js --identity-mode=pointer + +# Control iteration count (default: 1000000) +node --expose-gc run.js --identity-mode=both --identity-iterations=500000 + +# Control pool sizes for reuse scenarios (default: 1) +node --expose-gc run.js --identity-mode=both --identity-reuse-pools=1,16 + +# Include memory profiling (heap snapshots before/during/after) +node --expose-gc run.js --identity-mode=both --identity-memory + +# Combine with adaptive sampling +node --expose-gc run.js --identity-mode=both --adaptive + +# Save identity results +node --expose-gc run.js --identity-mode=both --output=results/identity-mode/results.json +``` + +### Identity Mode Scenarios + +| Scenario | What it measures | +|----------|-----------------| +| `passBothWaysRoundtrip` | Same object crossing boundary repeatedly (cache hit path) | +| `getPoolRepeated_100` | Bulk return of 100 cached objects (model collection pattern) | +| `churnObjects` | Create, roundtrip, release cycle (FinalizationRegistry cleanup pressure) | +| `swiftConsumesSameObject` | JS passes same object to Swift repeatedly | +| `swiftCreatesObject` | Fresh object creation overhead (cache miss path) | diff --git a/Benchmarks/lib/identity-benchmarks.js b/Benchmarks/lib/identity-benchmarks.js new file mode 100644 index 000000000..a916f694e --- /dev/null +++ b/Benchmarks/lib/identity-benchmarks.js @@ -0,0 +1,255 @@ +import { instantiate } from "../.build/plugins/PackageToJS/outputs/Package/instantiate.js" +import { defaultNodeSetup } from "../.build/plugins/PackageToJS/outputs/Package/platforms/node.js" + +/** + * Force a garbage collection cycle if available + */ +function forceGC() { + if (typeof globalThis.gc === 'function') { + globalThis.gc() + } +} + +/** + * Format a byte count as a human-readable string + * @param {number} bytes - Byte count to format + * @returns {string} Formatted string (B, KiB, or MiB) + */ +function formatBytes(bytes) { + if (Math.abs(bytes) < 1024) return `${bytes} B` + if (Math.abs(bytes) < 1024 * 1024) + return `${(bytes / 1024).toFixed(2)} KiB` + return `${(bytes / (1024 * 1024)).toFixed(2)} MiB` +} + +/** + * Parse the --identity-mode CLI argument into a list of modes to benchmark + * @param {string} modeArg - Mode argument: off, none, pointer, or both + * @returns {string[]} List of identity modes to run + */ +function parseIdentityModes(modeArg) { + if (!modeArg || modeArg === 'off') return [] + if (modeArg === 'none') return ['none'] + if (modeArg === 'pointer') return ['pointer'] + if (modeArg === 'both') return ['none', 'pointer'] + console.error( + `Invalid --identity-mode value: ${modeArg}. Expected off, none, pointer, or both.` + ) + process.exit(1) +} + +/** + * Parse the --identity-reuse-pools CLI argument into pool sizes + * @param {string} value - Comma-separated pool sizes (default: "1") + * @returns {number[]} List of pool sizes + */ +function parseIdentityReusePools(value) { + const raw = (value || '1') + .split(',') + .map((part) => part.trim()) + .filter(Boolean) + const parsed = [] + for (const item of raw) { + const poolSize = Number.parseInt(item, 10) + if (!Number.isInteger(poolSize) || poolSize <= 0) { + console.error( + `Invalid --identity-reuse-pools value: ${value}. Expected comma-separated positive integers.` + ) + process.exit(1) + } + if (!parsed.includes(poolSize)) { + parsed.push(poolSize) + } + } + if (parsed.length === 0) { + console.error( + 'Invalid --identity-reuse-pools value: expected at least one pool size.' + ) + process.exit(1) + } + return parsed +} + +/** + * Capture a memory profile sample for identity mode benchmarks. + * Measures heap cost of holding roundtrip results in an array. + * In pointer mode, retained entries reference the same wrapper; in none mode, each is distinct. + * @param {object} classRoundtrip - ClassRoundtrip instance + * @param {object} baseObject - Base SimpleClass instance + * @param {number} iterations - Number of roundtrip iterations + * @param {number} sampleInterval - How often to sample heap usage + * @returns {Promise} Memory profile sample + */ +async function captureIdentityMemorySample(classRoundtrip, baseObject, iterations, sampleInterval) { + const v8 = await import('v8') + forceGC() + const before = process.memoryUsage() + const beforeHeapStats = v8.getHeapStatistics() + let peakHeapUsed = before.heapUsed + + const retained = [] + let current = baseObject + const startedAt = performance.now() + for (let i = 0; i < iterations; i++) { + current = classRoundtrip.roundtripSimpleClass(current) + retained.push(current) + if ((i + 1) % sampleInterval === 0) { + peakHeapUsed = Math.max(peakHeapUsed, process.memoryUsage().heapUsed) + } + } + const durationMs = performance.now() - startedAt + + const afterRetain = process.memoryUsage() + peakHeapUsed = Math.max(peakHeapUsed, afterRetain.heapUsed) + retained.length = 0 + + forceGC() + const afterGC = process.memoryUsage() + const afterHeapStats = v8.getHeapStatistics() + + return { + iterations, + durationMs, + heapUsedBefore: before.heapUsed, + heapUsedPeak: peakHeapUsed, + heapUsedAfterRetain: afterRetain.heapUsed, + heapUsedAfterGC: afterGC.heapUsed, + heapSizeLimit: beforeHeapStats.heap_size_limit, + totalHeapSizeBefore: beforeHeapStats.total_heap_size, + totalHeapSizeAfter: afterHeapStats.total_heap_size, + retainedHeapDelta: afterRetain.heapUsed - before.heapUsed, + peakHeapDelta: peakHeapUsed - before.heapUsed, + postGCDelta: afterGC.heapUsed - before.heapUsed, + } +} + +/** + * Run identity mode benchmarks for each configured mode. + * Creates a separate WASM instance per mode to isolate identity cache state. + * @param {object} results - Results object to accumulate benchmark data + * @param {function|null} nameFilter - Optional filter for benchmark names + * @param {object|null} identityConfig - Identity benchmark configuration + * @param {function} benchmarkRunner - Benchmark runner function from singleRun + */ +async function runIdentityModeBenchmarks(results, nameFilter, identityConfig, benchmarkRunner) { + if (!identityConfig || identityConfig.modes.length === 0) return + + for (const mode of identityConfig.modes) { + const options = await defaultNodeSetup({}) + const { exports } = await instantiate({ + ...options, + identityMode: mode, + getImports: () => ({ + benchmarkHelperNoop: () => {}, + benchmarkHelperNoopWithNumber: () => {}, + benchmarkRunner: () => {}, + }), + }) + + const classRoundtrip = new exports.ClassRoundtrip() + const baseObject = new exports.SimpleClass('Hello', 42, true, 0.5, 3.14159) + + for (const poolSize of identityConfig.reusePools) { + const pool = Array.from({ length: poolSize }, (_, i) => { + return new exports.SimpleClass(`Hello ${i}`, i, true, 0.5, 3.14159) + }) + const testName = poolSize === 1 + ? `IdentityMode/${mode}/passBothWaysRoundtrip` + : `IdentityMode/${mode}/passBothWaysPool${poolSize}` + benchmarkRunner(testName, () => { + for (let i = 0; i < identityConfig.iterations; i++) { + const index = i % poolSize + pool[index] = classRoundtrip.roundtripSimpleClass(pool[index]) + } + }) + for (const object of pool) { + object.release() + } + } + + benchmarkRunner(`IdentityMode/${mode}/swiftConsumesSameObject`, () => { + for (let i = 0; i < identityConfig.iterations; i++) { + classRoundtrip.takeSimpleClass(baseObject) + } + }) + + + // Churn scenario: create, roundtrip, release in a tight loop. + // Tests FinalizationRegistry cleanup overhead when objects are + // constantly created and dropped. In pointer mode, the identity + // cache accumulates WeakRef entries that must be cleaned up. + benchmarkRunner(`IdentityMode/${mode}/churnObjects`, () => { + for (let i = 0; i < identityConfig.iterations; i++) { + const obj = new exports.SimpleClass(`temp ${i}`, i, true, 0.5, 3.14159) + classRoundtrip.roundtripSimpleClass(obj) + obj.release() + } + }) + + // Bulk array return: Swift returns same cached array of 100 objects. + // Tests the common pattern of returning model collections (e.g. building.floors). + // Uses fewer iterations since each call returns 100 objects. + const identityCacheBench = new exports.IdentityCacheBenchmark() + identityCacheBench.setupPool(100) + identityCacheBench.getPoolRepeated() // warm the cache + benchmarkRunner(`IdentityMode/${mode}/getPoolRepeated_100`, () => { + for (let i = 0; i < Math.floor(identityConfig.iterations / 100); i++) { + identityCacheBench.getPoolRepeated() + } + }) + identityCacheBench.release() + + benchmarkRunner(`IdentityMode/${mode}/swiftCreatesObject`, () => { + for (let i = 0; i < identityConfig.iterations; i++) { + classRoundtrip.makeSimpleClass() + } + }) + + if (identityConfig.memory) { + const sample = await captureIdentityMemorySample( + classRoundtrip, baseObject, + identityConfig.iterations, identityConfig.sampleInterval + ) + if (!identityConfig.memorySamples[mode]) { + identityConfig.memorySamples[mode] = [] + } + identityConfig.memorySamples[mode].push(sample) + } + + baseObject.release() + classRoundtrip.release() + } +} + +/** + * Summarize memory profiling results across all identity modes + * @param {object} identityConfig - Identity benchmark configuration with memorySamples + * @returns {object[]} Table rows for console.table display + */ +function summarizeIdentityMemory(identityConfig) { + const rows = [] + for (const mode of identityConfig.modes) { + const samples = identityConfig.memorySamples[mode] || [] + if (samples.length === 0) continue + const avg = (selector) => + samples.reduce((acc, sample) => acc + selector(sample), 0) / samples.length + rows.push({ + Mode: mode, + Samples: samples.length, + Iterations: samples[0].iterations, + 'Avg duration (ms)': avg((s) => s.durationMs).toFixed(2), + 'Avg peak delta': formatBytes(Math.round(avg((s) => s.peakHeapDelta))), + 'Avg retained delta': formatBytes(Math.round(avg((s) => s.retainedHeapDelta))), + 'Avg post-GC delta': formatBytes(Math.round(avg((s) => s.postGCDelta))), + 'Heap limit': formatBytes(samples[0].heapSizeLimit), + }) + } + return rows +} + +export { + parseIdentityModes, + parseIdentityReusePools, + runIdentityModeBenchmarks, + summarizeIdentityMemory, +} diff --git a/Benchmarks/run.js b/Benchmarks/run.js index 5a1ae61e6..772c84f2b 100644 --- a/Benchmarks/run.js +++ b/Benchmarks/run.js @@ -2,7 +2,8 @@ import { instantiate } from "./.build/plugins/PackageToJS/outputs/Package/instan import { defaultNodeSetup } from "./.build/plugins/PackageToJS/outputs/Package/platforms/node.js" import fs from 'fs'; import path from 'path'; -import { parseArgs } from "util"; +import { parseArgs } from "util" +import { parseIdentityModes, parseIdentityReusePools, runIdentityModeBenchmarks, summarizeIdentityMemory } from "./lib/identity-benchmarks.js" import { APIResultValues as APIResult, ComplexResultValues as ComplexResult } from "./.build/plugins/PackageToJS/outputs/Package/bridge-js.js"; /** @@ -275,7 +276,7 @@ function saveJsonResults(filePath, data) { * @param {number} iterations - Loop iterations per JS benchmark * @returns {Promise} */ -async function singleRun(results, nameFilter, iterations) { +async function singleRun(results, nameFilter, iterations, identityConfig) { const options = await defaultNodeSetup({}) const benchmarkRunner = (name, body) => { if (nameFilter && !nameFilter(name)) { @@ -869,6 +870,8 @@ async function singleRun(results, nameFilter, iterations) { arrayRoundtrip.roundtripOptionalArray(null) } }) + + await runIdentityModeBenchmarks(results, nameFilter, identityConfig, benchmarkRunner) } /** @@ -878,7 +881,7 @@ async function singleRun(results, nameFilter, iterations) { * @param {number} iterations - Loop iterations per JS benchmark * @returns {Promise} */ -async function runUntilStable(results, options, width, nameFilter, filterArg, iterations) { +async function runUntilStable(results, options, width, nameFilter, filterArg, iterations, identityConfig) { const { minRuns = 5, maxRuns = 50, @@ -897,7 +900,7 @@ async function runUntilStable(results, options, width, nameFilter, filterArg, it // Update progress with estimated completion updateProgress(runs, maxRuns, "Benchmark Progress:", width); - await singleRun(results, nameFilter, iterations); + await singleRun(results, nameFilter, iterations, identityConfig) runs++; if (runs === 1 && Object.keys(results).length === 0) { @@ -968,6 +971,10 @@ Options: --max-runs=NUMBER Maximum runs for adaptive sampling (default: 50) --target-cv=NUMBER Target coefficient of variation % (default: 5) --filter=PATTERN Filter benchmarks by name (substring or /regex/flags) + --identity-mode=MODE Identity benchmarks: off, none, pointer, both (default: off) + --identity-iterations=N Iterations for identity benchmarks (default: 1000000) + --identity-reuse-pools=N,N Pool sizes for reuse scenarios (default: 1) + --identity-memory Enable memory profiling for identity benchmarks --help Show this help message `); } @@ -984,7 +991,11 @@ async function main() { 'min-runs': { type: 'string', default: '5' }, 'max-runs': { type: 'string', default: '50' }, 'target-cv': { type: 'string', default: '5' }, - filter: { type: 'string' } + filter: { type: 'string' }, + 'identity-mode': { type: 'string', default: 'off' }, + 'identity-iterations': { type: 'string', default: '1000000' }, + 'identity-reuse-pools': { type: 'string' }, + 'identity-memory': { type: 'boolean', default: false } } }); @@ -998,6 +1009,17 @@ async function main() { const filterArg = args.values.filter; const nameFilter = createNameFilter(filterArg); + const identityModes = parseIdentityModes(args.values['identity-mode']) + const identityIterations = parseInt(args.values['identity-iterations'], 10) + const identityConfig = identityModes.length > 0 ? { + modes: identityModes, + iterations: identityIterations, + reusePools: parseIdentityReusePools(args.values['identity-reuse-pools']), + memory: args.values['identity-memory'], + memorySamples: {}, + sampleInterval: 10000, + } : null + const iterations = parseInt(args.values.iterations, 10); if (isNaN(iterations) || iterations <= 0) { console.error('Invalid --iterations value:', args.values.iterations); @@ -1017,7 +1039,7 @@ async function main() { console.log(`Results will be saved to: ${args.values.output}`); } - await runUntilStable(results, options, width, nameFilter, filterArg, iterations); + await runUntilStable(results, options, width, nameFilter, filterArg, iterations, identityConfig) } else { // Fixed number of runs mode const runs = parseInt(args.values.runs, 10); @@ -1039,7 +1061,7 @@ async function main() { console.log("\nOverall Progress:"); for (let i = 0; i < runs; i++) { updateProgress(i, runs, "Benchmark Runs:", width); - await singleRun(results, nameFilter, iterations); + await singleRun(results, nameFilter, iterations, identityConfig) if (i === 0 && Object.keys(results).length === 0) { process.stdout.write("\n"); console.error(`No benchmarks matched filter: ${filterArg}`); @@ -1071,6 +1093,15 @@ async function main() { } } + // Identity memory summary + if (identityConfig?.memory) { + const memoryRows = summarizeIdentityMemory(identityConfig) + if (memoryRows.length > 0) { + console.log("\n=== Identity Mode Memory Profile ===") + console.table(memoryRows) + } + } + // Save JSON to file if specified if (args.values.output) { saveJsonResults(args.values.output, formattedResults); From 19c3f8e4ee58420f4faa5ebc9d64b982e30b5da1 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Tue, 21 Apr 2026 11:54:53 +0200 Subject: [PATCH 11/18] feat: Add identity mode benchmark Swift sources Add IdentityCacheBenchmark with setupPool/getPoolRepeated for bulk array return scenarios. Update generated BridgeJS bindings for benchmark target. --- Benchmarks/Sources/Benchmarks.swift | 48 ++++ Benchmarks/Sources/Generated/BridgeJS.swift | 169 ++++++++++++ .../Generated/JavaScript/BridgeJS.json | 243 ++++++++++++++++++ 3 files changed, 460 insertions(+) diff --git a/Benchmarks/Sources/Benchmarks.swift b/Benchmarks/Sources/Benchmarks.swift index 59da8c96c..45a2438ea 100644 --- a/Benchmarks/Sources/Benchmarks.swift +++ b/Benchmarks/Sources/Benchmarks.swift @@ -257,6 +257,54 @@ enum ComplexResult { } } +// MARK: - Class Array Performance Tests + +nonisolated(unsafe) var _classArrayPool: [SimpleClass] = [] + +@JS class ClassArrayRoundtrip { + @JS init() {} + + @JS func setupPool(_ count: Int) { + _classArrayPool = (0.. [SimpleClass] { + return _classArrayPool + } + + @JS func makeClassArray() -> [SimpleClass] { + return (0..<100).map { + SimpleClass(name: "Item \($0)", count: $0, flag: true, rate: 0.5, precise: 3.14) + } + } + + @JS func takeClassArray(_ values: [SimpleClass]) {} + + @JS func roundtripClassArray(_ values: [SimpleClass]) -> [SimpleClass] { + return values + } +} + +// MARK: - Identity Cache Benchmark + +nonisolated(unsafe) var _cachedPool: [SimpleClass] = [] + +@JS class IdentityCacheBenchmark { + @JS init() {} + + @JS func setupPool(_ count: Int) { + _cachedPool = (0.. [SimpleClass] { + return _cachedPool + } +} + // MARK: - Array Performance Tests @JS struct Point { diff --git a/Benchmarks/Sources/Generated/BridgeJS.swift b/Benchmarks/Sources/Generated/BridgeJS.swift index c9adb2b1a..f01d84fb8 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.swift @@ -1373,6 +1373,175 @@ fileprivate func _bjs_ClassRoundtrip_wrap_extern(_ pointer: UnsafeMutableRawPoin return _bjs_ClassRoundtrip_wrap_extern(pointer) } +@_expose(wasm, "bjs_ClassArrayRoundtrip_init") +@_cdecl("bjs_ClassArrayRoundtrip_init") +public func _bjs_ClassArrayRoundtrip_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ClassArrayRoundtrip() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassArrayRoundtrip_setupPool") +@_cdecl("bjs_ClassArrayRoundtrip_setupPool") +public func _bjs_ClassArrayRoundtrip_setupPool(_ _self: UnsafeMutableRawPointer, _ count: Int32) -> Void { + #if arch(wasm32) + ClassArrayRoundtrip.bridgeJSLiftParameter(_self).setupPool(_: Int.bridgeJSLiftParameter(count)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassArrayRoundtrip_getPool") +@_cdecl("bjs_ClassArrayRoundtrip_getPool") +public func _bjs_ClassArrayRoundtrip_getPool(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = ClassArrayRoundtrip.bridgeJSLiftParameter(_self).getPool() + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassArrayRoundtrip_makeClassArray") +@_cdecl("bjs_ClassArrayRoundtrip_makeClassArray") +public func _bjs_ClassArrayRoundtrip_makeClassArray(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = ClassArrayRoundtrip.bridgeJSLiftParameter(_self).makeClassArray() + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassArrayRoundtrip_takeClassArray") +@_cdecl("bjs_ClassArrayRoundtrip_takeClassArray") +public func _bjs_ClassArrayRoundtrip_takeClassArray(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + ClassArrayRoundtrip.bridgeJSLiftParameter(_self).takeClassArray(_: [SimpleClass].bridgeJSStackPop()) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassArrayRoundtrip_roundtripClassArray") +@_cdecl("bjs_ClassArrayRoundtrip_roundtripClassArray") +public func _bjs_ClassArrayRoundtrip_roundtripClassArray(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = ClassArrayRoundtrip.bridgeJSLiftParameter(_self).roundtripClassArray(_: [SimpleClass].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassArrayRoundtrip_deinit") +@_cdecl("bjs_ClassArrayRoundtrip_deinit") +public func _bjs_ClassArrayRoundtrip_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ClassArrayRoundtrip: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ClassArrayRoundtrip_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ClassArrayRoundtrip_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_ClassArrayRoundtrip_wrap") +fileprivate func _bjs_ClassArrayRoundtrip_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ClassArrayRoundtrip_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ClassArrayRoundtrip_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ClassArrayRoundtrip_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_IdentityCacheBenchmark_init") +@_cdecl("bjs_IdentityCacheBenchmark_init") +public func _bjs_IdentityCacheBenchmark_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = IdentityCacheBenchmark() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmark_setupPool") +@_cdecl("bjs_IdentityCacheBenchmark_setupPool") +public func _bjs_IdentityCacheBenchmark_setupPool(_ _self: UnsafeMutableRawPointer, _ count: Int32) -> Void { + #if arch(wasm32) + IdentityCacheBenchmark.bridgeJSLiftParameter(_self).setupPool(_: Int.bridgeJSLiftParameter(count)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmark_getPoolRepeated") +@_cdecl("bjs_IdentityCacheBenchmark_getPoolRepeated") +public func _bjs_IdentityCacheBenchmark_getPoolRepeated(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = IdentityCacheBenchmark.bridgeJSLiftParameter(_self).getPoolRepeated() + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmark_getSingleRepeated") +@_cdecl("bjs_IdentityCacheBenchmark_getSingleRepeated") +public func _bjs_IdentityCacheBenchmark_getSingleRepeated(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = IdentityCacheBenchmark.bridgeJSLiftParameter(_self).getSingleRepeated() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmark_deinit") +@_cdecl("bjs_IdentityCacheBenchmark_deinit") +public func _bjs_IdentityCacheBenchmark_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension IdentityCacheBenchmark: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_IdentityCacheBenchmark_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_IdentityCacheBenchmark_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_IdentityCacheBenchmark_wrap") +fileprivate func _bjs_IdentityCacheBenchmark_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_IdentityCacheBenchmark_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_IdentityCacheBenchmark_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_IdentityCacheBenchmark_wrap_extern(pointer) +} + @_expose(wasm, "bjs_ArrayRoundtrip_init") @_cdecl("bjs_ArrayRoundtrip_init") public func _bjs_ArrayRoundtrip_init() -> UnsafeMutableRawPointer { diff --git a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json index b2c33ac01..15da088ec 100644 --- a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json +++ b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json @@ -1270,6 +1270,249 @@ ], "swiftCallName" : "ClassRoundtrip" }, + { + "constructor" : { + "abiName" : "bjs_ClassArrayRoundtrip_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_ClassArrayRoundtrip_setupPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setupPool", + "parameters" : [ + { + "label" : "_", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_ClassArrayRoundtrip_getPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getPool", + "parameters" : [ + + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "SimpleClass" + } + } + } + } + }, + { + "abiName" : "bjs_ClassArrayRoundtrip_makeClassArray", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeClassArray", + "parameters" : [ + + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "SimpleClass" + } + } + } + } + }, + { + "abiName" : "bjs_ClassArrayRoundtrip_takeClassArray", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "takeClassArray", + "parameters" : [ + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "SimpleClass" + } + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_ClassArrayRoundtrip_roundtripClassArray", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripClassArray", + "parameters" : [ + { + "label" : "_", + "name" : "values", + "type" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "SimpleClass" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "SimpleClass" + } + } + } + } + } + ], + "name" : "ClassArrayRoundtrip", + "properties" : [ + + ], + "swiftCallName" : "ClassArrayRoundtrip" + }, + { + "constructor" : { + "abiName" : "bjs_IdentityCacheBenchmark_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_IdentityCacheBenchmark_setupPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setupPool", + "parameters" : [ + { + "label" : "_", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_IdentityCacheBenchmark_getPoolRepeated", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getPoolRepeated", + "parameters" : [ + + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "SimpleClass" + } + } + } + } + }, + { + "abiName" : "bjs_IdentityCacheBenchmark_getSingleRepeated", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getSingleRepeated", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "SimpleClass" + } + }, + "_1" : "null" + } + } + } + ], + "name" : "IdentityCacheBenchmark", + "properties" : [ + + ], + "swiftCallName" : "IdentityCacheBenchmark" + }, { "constructor" : { "abiName" : "bjs_ArrayRoundtrip_init", From 2aac6d62d12b480588f0fec6106997470286a023 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Tue, 21 Apr 2026 11:55:19 +0200 Subject: [PATCH 12/18] perf: Add IQR outlier removal and median to benchmark statistics Benchmark results can be noisy due to GC timing and V8 JIT compilation. IQR filtering discards values outside Q1-1.5*IQR to Q3+1.5*IQR before computing statistics. The Samples column shows retained count (e.g. '4 (-1)' means 4 kept, 1 discarded). Falls back to the full dataset if fewer than 4 samples. Applies to all benchmarks, not just identity mode. --- Benchmarks/Sources/Generated/BridgeJS.swift | 11 --- .../Generated/JavaScript/BridgeJS.json | 22 ----- Benchmarks/run.js | 82 +++++++++++++------ 3 files changed, 57 insertions(+), 58 deletions(-) diff --git a/Benchmarks/Sources/Generated/BridgeJS.swift b/Benchmarks/Sources/Generated/BridgeJS.swift index f01d84fb8..66cab321e 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.swift @@ -1500,17 +1500,6 @@ public func _bjs_IdentityCacheBenchmark_getPoolRepeated(_ _self: UnsafeMutableRa #endif } -@_expose(wasm, "bjs_IdentityCacheBenchmark_getSingleRepeated") -@_cdecl("bjs_IdentityCacheBenchmark_getSingleRepeated") -public func _bjs_IdentityCacheBenchmark_getSingleRepeated(_ _self: UnsafeMutableRawPointer) -> Void { - #if arch(wasm32) - let ret = IdentityCacheBenchmark.bridgeJSLiftParameter(_self).getSingleRepeated() - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_IdentityCacheBenchmark_deinit") @_cdecl("bjs_IdentityCacheBenchmark_deinit") public func _bjs_IdentityCacheBenchmark_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { diff --git a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json index 15da088ec..9036b503e 100644 --- a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json +++ b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json @@ -1483,28 +1483,6 @@ } } } - }, - { - "abiName" : "bjs_IdentityCacheBenchmark_getSingleRepeated", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "getSingleRepeated", - "parameters" : [ - - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "SimpleClass" - } - }, - "_1" : "null" - } - } } ], "name" : "IdentityCacheBenchmark", diff --git a/Benchmarks/run.js b/Benchmarks/run.js index 772c84f2b..f72ee6a47 100644 --- a/Benchmarks/run.js +++ b/Benchmarks/run.js @@ -2,7 +2,7 @@ import { instantiate } from "./.build/plugins/PackageToJS/outputs/Package/instan import { defaultNodeSetup } from "./.build/plugins/PackageToJS/outputs/Package/platforms/node.js" import fs from 'fs'; import path from 'path'; -import { parseArgs } from "util" +import { parseArgs } from "util"; import { parseIdentityModes, parseIdentityReusePools, runIdentityModeBenchmarks, summarizeIdentityMemory } from "./lib/identity-benchmarks.js" import { APIResultValues as APIResult, ComplexResultValues as ComplexResult } from "./.build/plugins/PackageToJS/outputs/Package/bridge-js.js"; @@ -63,17 +63,44 @@ function createNameFilter(arg) { * @returns {number} Coefficient of variation as a percentage */ function calculateCV(values) { - if (values.length < 2) return 0; - - const sum = values.reduce((a, b) => a + b, 0); - const mean = sum / values.length; - - if (mean === 0) return 0; + if (values.length < 2) return 0 + const filtered = removeOutliers(values) + const sum = filtered.reduce((a, b) => a + b, 0) + const mean = sum / filtered.length + if (mean === 0) return 0 + const variance = filtered.reduce((a, b) => a + Math.pow(b - mean, 2), 0) / filtered.length + const stdDev = Math.sqrt(variance) + return (stdDev / mean) * 100 +} - const variance = values.reduce((a, b) => a + Math.pow(b - mean, 2), 0) / values.length; - const stdDev = Math.sqrt(variance); +/** + * Remove outliers using the IQR (interquartile range) method. + * Discards values below Q1-1.5*IQR or above Q3+1.5*IQR. + * Returns the filtered array (or the original if too few samples). + * @param {Array} values - Array of measurement values + * @returns {Array} Values with outliers removed + */ +function removeOutliers(values) { + if (values.length < 4) return values + const sorted = [...values].sort((a, b) => a - b) + const q1 = sorted[Math.floor(sorted.length * 0.25)] + const q3 = sorted[Math.floor(sorted.length * 0.75)] + const iqr = q3 - q1 + const lower = q1 - 1.5 * iqr + const upper = q3 + 1.5 * iqr + const filtered = values.filter(v => v >= lower && v <= upper) + return filtered.length > 0 ? filtered : values +} - return (stdDev / mean) * 100; // Return as percentage +/** + * Calculate the median of an array of numbers + * @param {Array} values - Array of measurement values + * @returns {number} Median value + */ +function median(values) { + const sorted = [...values].sort((a, b) => a - b) + const mid = Math.floor(sorted.length / 2) + return sorted.length % 2 !== 0 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2 } /** @@ -86,33 +113,38 @@ function calculateStatistics(results) { const consoleTable = []; for (const [name, times] of Object.entries(results)) { - const sum = times.reduce((a, b) => a + b, 0); - const avg = sum / times.length; - const min = Math.min(...times); - const max = Math.max(...times); - const variance = times.reduce((a, b) => a + Math.pow(b - avg, 2), 0) / times.length; - const stdDev = Math.sqrt(variance); - const cv = (stdDev / avg) * 100; // Coefficient of variation as percentage + const filtered = removeOutliers(times) + const sum = filtered.reduce((a, b) => a + b, 0) + const avg = sum / filtered.length + const med = median(filtered) + const min = Math.min(...filtered) + const max = Math.max(...filtered) + const variance = filtered.reduce((a, b) => a + Math.pow(b - avg, 2), 0) / filtered.length + const stdDev = Math.sqrt(variance) + const cv = (stdDev / avg) * 100 + const outliers = times.length - filtered.length formattedResults[name] = { "avg_ms": parseFloat(avg.toFixed(2)), + "median_ms": parseFloat(med.toFixed(2)), "min_ms": parseFloat(min.toFixed(2)), "max_ms": parseFloat(max.toFixed(2)), "stdDev_ms": parseFloat(stdDev.toFixed(2)), "cv_percent": parseFloat(cv.toFixed(2)), - "samples": times.length, + "samples": filtered.length, + "outliers_removed": outliers, "rawTimes_ms": times.map(t => parseFloat(t.toFixed(2))) - }; + } consoleTable.push({ Test: name, + 'Median (ms)': med.toFixed(2), 'Avg (ms)': avg.toFixed(2), 'Min (ms)': min.toFixed(2), 'Max (ms)': max.toFixed(2), - 'StdDev (ms)': stdDev.toFixed(2), 'CV (%)': cv.toFixed(2), - 'Samples': times.length - }); + 'Samples': filtered.length + (outliers > 0 ? ` (-${outliers})` : '') + }) } return { formattedResults, consoleTable }; @@ -283,7 +315,7 @@ async function singleRun(results, nameFilter, iterations, identityConfig) { return; } // Warmup to reduce JIT/IC noise. - body(); + body() if (typeof globalThis.gc === "function") { globalThis.gc(); } @@ -900,7 +932,7 @@ async function runUntilStable(results, options, width, nameFilter, filterArg, it // Update progress with estimated completion updateProgress(runs, maxRuns, "Benchmark Progress:", width); - await singleRun(results, nameFilter, iterations, identityConfig) + await singleRun(results, nameFilter, iterations, identityConfig); runs++; if (runs === 1 && Object.keys(results).length === 0) { @@ -973,7 +1005,7 @@ Options: --filter=PATTERN Filter benchmarks by name (substring or /regex/flags) --identity-mode=MODE Identity benchmarks: off, none, pointer, both (default: off) --identity-iterations=N Iterations for identity benchmarks (default: 1000000) - --identity-reuse-pools=N,N Pool sizes for reuse scenarios (default: 1) + --identity-reuse-pools=N,N Pool sizes for reuse scenarios (default: 1,8,64) --identity-memory Enable memory profiling for identity benchmarks --help Show this help message `); From b47bd9c137bb70f982f845359157628177a8d8a2 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Tue, 21 Apr 2026 15:00:11 +0200 Subject: [PATCH 13/18] feat: Add per-class identityMode via @JS macro parameter Add identityMode: Bool parameter to @JS macro. When set to true on a class, that class uses pointer identity caching. When false or not set, the class uses the bridge-js.config.json default. Identity is resolved entirely at codegen time - no runtime option. Classes with identity mode get static __identityCache passed to __wrap. Classes without it pass null. No runtime branching in __construct. Resolution: @JS(identityMode: true/false) > bridge-js.config.json > default (off). --- Benchmarks/README.md | 34 +- Benchmarks/Sources/Benchmarks.swift | 55 +++ Benchmarks/Sources/Generated/BridgeJS.swift | 284 ++++++++++++++ .../Generated/JavaScript/BridgeJS.json | 279 ++++++++++++++ Benchmarks/Sources/bridge-js.config.json | 1 - Benchmarks/lib/identity-benchmarks.js | 86 +++-- Benchmarks/run.js | 4 +- .../BridgeJSCore/SwiftToSkeleton.swift | 12 +- .../Sources/BridgeJSLink/BridgeJSLink.swift | 68 +++- .../BridgeJSSkeleton/BridgeJSSkeleton.swift | 5 +- .../BridgeJSToolTests/BridgeJSLinkTests.swift | 74 ++-- .../Inputs/MacroSwift/IdentityModeClass.swift | 28 ++ .../IdentityModeClass.json | 148 +++++++ .../IdentityModeClass.swift | 188 +++++++++ .../BridgeJSLinkTests/ArrayTypes.d.ts | 1 - .../BridgeJSLinkTests/ArrayTypes.js | 12 +- .../BridgeJSLinkTests/Async.d.ts | 1 - .../__Snapshots__/BridgeJSLinkTests/Async.js | 2 - .../BridgeJSLinkTests/AsyncImport.d.ts | 1 - .../BridgeJSLinkTests/AsyncImport.js | 2 - .../BridgeJSLinkTests/AsyncStaticImport.d.ts | 1 - .../BridgeJSLinkTests/AsyncStaticImport.js | 2 - .../BridgeJSLinkTests/DefaultParameters.d.ts | 1 - .../BridgeJSLinkTests/DefaultParameters.js | 16 +- .../BridgeJSLinkTests/DictionaryTypes.d.ts | 1 - .../BridgeJSLinkTests/DictionaryTypes.js | 8 +- .../EnumAssociatedValue.d.ts | 1 - .../BridgeJSLinkTests/EnumAssociatedValue.js | 8 +- .../BridgeJSLinkTests/EnumCase.d.ts | 1 - .../BridgeJSLinkTests/EnumCase.js | 2 - .../EnumNamespace.Global.d.ts | 1 - .../BridgeJSLinkTests/EnumNamespace.Global.js | 20 +- .../BridgeJSLinkTests/EnumNamespace.d.ts | 1 - .../BridgeJSLinkTests/EnumNamespace.js | 20 +- .../BridgeJSLinkTests/EnumRawType.d.ts | 1 - .../BridgeJSLinkTests/EnumRawType.js | 2 - .../BridgeJSLinkTests/FixedWidthIntegers.d.ts | 1 - .../BridgeJSLinkTests/FixedWidthIntegers.js | 2 - .../BridgeJSLinkTests/GlobalGetter.d.ts | 1 - .../BridgeJSLinkTests/GlobalGetter.js | 2 - .../BridgeJSLinkTests/GlobalThisImports.d.ts | 1 - .../BridgeJSLinkTests/GlobalThisImports.js | 2 - .../IdentityModeClass.ConfigPointer.d.ts | 42 ++ .../IdentityModeClass.ConfigPointer.js | 362 ++++++++++++++++++ .../IdentityModeClass.PerClass.d.ts | 42 ++ .../IdentityModeClass.PerClass.js | 350 +++++++++++++++++ .../BridgeJSLinkTests/IdentityModeClass.d.ts | 42 ++ .../BridgeJSLinkTests/IdentityModeClass.js | 350 +++++++++++++++++ .../BridgeJSLinkTests/ImportArray.d.ts | 1 - .../BridgeJSLinkTests/ImportArray.js | 2 - .../ImportedTypeInExportedInterface.d.ts | 1 - .../ImportedTypeInExportedInterface.js | 2 - .../InvalidPropertyNames.d.ts | 1 - .../BridgeJSLinkTests/InvalidPropertyNames.js | 2 - .../BridgeJSLinkTests/JSClass.d.ts | 1 - .../BridgeJSLinkTests/JSClass.js | 2 - .../JSClassStaticFunctions.d.ts | 1 - .../JSClassStaticFunctions.js | 2 - .../BridgeJSLinkTests/JSValue.d.ts | 1 - .../BridgeJSLinkTests/JSValue.js | 8 +- .../BridgeJSLinkTests/MixedGlobal.d.ts | 1 - .../BridgeJSLinkTests/MixedGlobal.js | 8 +- .../BridgeJSLinkTests/MixedModules.d.ts | 1 - .../BridgeJSLinkTests/MixedModules.js | 12 +- .../BridgeJSLinkTests/MixedPrivate.d.ts | 1 - .../BridgeJSLinkTests/MixedPrivate.js | 8 +- .../BridgeJSLinkTests/Namespaces.Global.d.ts | 1 - .../BridgeJSLinkTests/Namespaces.Global.js | 20 +- .../BridgeJSLinkTests/Namespaces.d.ts | 1 - .../BridgeJSLinkTests/Namespaces.js | 20 +- .../BridgeJSLinkTests/Optionals.d.ts | 1 - .../BridgeJSLinkTests/Optionals.js | 12 +- .../PrimitiveParameters.d.ts | 1 - .../BridgeJSLinkTests/PrimitiveParameters.js | 2 - .../BridgeJSLinkTests/PrimitiveReturn.d.ts | 1 - .../BridgeJSLinkTests/PrimitiveReturn.js | 2 - .../BridgeJSLinkTests/PropertyTypes.d.ts | 1 - .../BridgeJSLinkTests/PropertyTypes.js | 8 +- .../BridgeJSLinkTests/Protocol.d.ts | 1 - .../BridgeJSLinkTests/Protocol.js | 16 +- .../BridgeJSLinkTests/ProtocolInClosure.d.ts | 1 - .../BridgeJSLinkTests/ProtocolInClosure.js | 8 +- .../StaticFunctions.Global.d.ts | 1 - .../StaticFunctions.Global.js | 8 +- .../BridgeJSLinkTests/StaticFunctions.d.ts | 1 - .../BridgeJSLinkTests/StaticFunctions.js | 8 +- .../StaticProperties.Global.d.ts | 1 - .../StaticProperties.Global.js | 8 +- .../BridgeJSLinkTests/StaticProperties.d.ts | 1 - .../BridgeJSLinkTests/StaticProperties.js | 8 +- .../BridgeJSLinkTests/StringParameter.d.ts | 1 - .../BridgeJSLinkTests/StringParameter.js | 2 - .../BridgeJSLinkTests/StringReturn.d.ts | 1 - .../BridgeJSLinkTests/StringReturn.js | 2 - .../BridgeJSLinkTests/SwiftClass.d.ts | 1 - .../BridgeJSLinkTests/SwiftClass.js | 16 +- .../BridgeJSLinkTests/SwiftClosure.d.ts | 1 - .../BridgeJSLinkTests/SwiftClosure.js | 12 +- .../SwiftClosureImports.d.ts | 1 - .../BridgeJSLinkTests/SwiftClosureImports.js | 2 - .../BridgeJSLinkTests/SwiftStruct.d.ts | 1 - .../BridgeJSLinkTests/SwiftStruct.js | 8 +- .../BridgeJSLinkTests/SwiftStructImports.d.ts | 1 - .../BridgeJSLinkTests/SwiftStructImports.js | 2 - .../BridgeJSLinkTests/Throws.d.ts | 1 - .../__Snapshots__/BridgeJSLinkTests/Throws.js | 2 - .../BridgeJSLinkTests/UnsafePointer.d.ts | 1 - .../BridgeJSLinkTests/UnsafePointer.js | 2 - .../VoidParameterVoidReturn.d.ts | 1 - .../VoidParameterVoidReturn.js | 2 - Plugins/PackageToJS/Templates/index.d.ts | 6 - Plugins/PackageToJS/Templates/index.js | 9 +- .../PackageToJS/Templates/instantiate.d.ts | 5 - Sources/JavaScriptKit/Macros.swift | 3 +- .../JSClosure+AsyncTests.swift | 89 +++-- 115 files changed, 2472 insertions(+), 455 deletions(-) delete mode 100644 Benchmarks/Sources/bridge-js.config.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/IdentityModeClass.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js diff --git a/Benchmarks/README.md b/Benchmarks/README.md index 409681eeb..834ddcdbf 100644 --- a/Benchmarks/README.md +++ b/Benchmarks/README.md @@ -38,15 +38,35 @@ node run.js --filter=/string/i ## Identity Mode Benchmarks -Compare `identityMode: "pointer"` vs default (`"none"`) for SwiftHeapObject wrapper caching. Requires `--expose-gc` for memory benchmarks. +Compare `identityMode: "pointer"` vs default (`"none"`) for SwiftHeapObject wrapper caching. Both class variants are compiled into the **same build** via per-class `@JS(identityMode: true)` annotations, so no separate builds or config files are needed. + +Requires `--expose-gc` for memory benchmarks. + +### Build once + +```bash +swift package --swift-sdk $SWIFT_SDK_ID js -c release +``` + +### Compare both modes in one run ```bash -# Run identity benchmarks comparing both modes -node --expose-gc run.js --identity-mode=both +node --expose-gc run.js --identity-mode=both --identity-iterations=1000000 +``` + +### Run only one mode -# Pointer mode only -node --expose-gc run.js --identity-mode=pointer +```bash +# Only pointer (identity-cached) classes +node --expose-gc run.js --identity-mode=pointer --identity-iterations=1000000 +# Only non-identity classes +node --expose-gc run.js --identity-mode=none --identity-iterations=1000000 +``` + +### Additional options + +```bash # Control iteration count (default: 1000000) node --expose-gc run.js --identity-mode=both --identity-iterations=500000 @@ -59,8 +79,8 @@ node --expose-gc run.js --identity-mode=both --identity-memory # Combine with adaptive sampling node --expose-gc run.js --identity-mode=both --adaptive -# Save identity results -node --expose-gc run.js --identity-mode=both --output=results/identity-mode/results.json +# Filter to specific identity benchmarks +node --expose-gc run.js --adaptive --filter=passBothWaysRoundtrip --identity-mode=both --identity-iterations=1000000 ``` ### Identity Mode Scenarios diff --git a/Benchmarks/Sources/Benchmarks.swift b/Benchmarks/Sources/Benchmarks.swift index 45a2438ea..3e24e597b 100644 --- a/Benchmarks/Sources/Benchmarks.swift +++ b/Benchmarks/Sources/Benchmarks.swift @@ -305,6 +305,61 @@ nonisolated(unsafe) var _cachedPool: [SimpleClass] = [] } } +// MARK: - Identity Mode Benchmark Variants +// These classes use @JS(identityMode: true) so that identity cache benchmarks +// can run in the SAME build alongside the non-identity classes above. + +@JS(identityMode: true) +class SimpleClassIdentity { + @JS var name: String + @JS var count: Int + @JS var flag: Bool + @JS var rate: Float + @JS var precise: Double + + @JS init(name: String, count: Int, flag: Bool, rate: Float, precise: Double) { + self.name = name + self.count = count + self.flag = flag + self.rate = rate + self.precise = precise + } +} + +@JS(identityMode: true) +class ClassRoundtripIdentity { + @JS init() {} + + @JS func roundtripSimpleClassIdentity(_ obj: SimpleClassIdentity) -> SimpleClassIdentity { + return obj + } + + @JS func makeSimpleClassIdentity() -> SimpleClassIdentity { + return SimpleClassIdentity(name: "Hello", count: 42, flag: true, rate: 0.5, precise: 3.14159) + } + + @JS func takeSimpleClassIdentity(_ obj: SimpleClassIdentity) { + // consume without returning + } +} + +nonisolated(unsafe) var _cachedPoolIdentity: [SimpleClassIdentity] = [] + +@JS(identityMode: true) +class IdentityCacheBenchmarkIdentity { + @JS init() {} + + @JS func setupPool(_ count: Int) { + _cachedPoolIdentity = (0.. [SimpleClassIdentity] { + return _cachedPoolIdentity + } +} + // MARK: - Array Performance Tests @JS struct Point { diff --git a/Benchmarks/Sources/Generated/BridgeJS.swift b/Benchmarks/Sources/Generated/BridgeJS.swift index 66cab321e..e199e4a29 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.swift @@ -1531,6 +1531,290 @@ fileprivate func _bjs_IdentityCacheBenchmark_wrap_extern(_ pointer: UnsafeMutabl return _bjs_IdentityCacheBenchmark_wrap_extern(pointer) } +@_expose(wasm, "bjs_SimpleClassIdentity_init") +@_cdecl("bjs_SimpleClassIdentity_init") +public func _bjs_SimpleClassIdentity_init(_ nameBytes: Int32, _ nameLength: Int32, _ count: Int32, _ flag: Int32, _ rate: Float32, _ precise: Float64) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = SimpleClassIdentity(name: String.bridgeJSLiftParameter(nameBytes, nameLength), count: Int.bridgeJSLiftParameter(count), flag: Bool.bridgeJSLiftParameter(flag), rate: Float.bridgeJSLiftParameter(rate), precise: Double.bridgeJSLiftParameter(precise)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassIdentity_name_get") +@_cdecl("bjs_SimpleClassIdentity_name_get") +public func _bjs_SimpleClassIdentity_name_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SimpleClassIdentity.bridgeJSLiftParameter(_self).name + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassIdentity_name_set") +@_cdecl("bjs_SimpleClassIdentity_name_set") +public func _bjs_SimpleClassIdentity_name_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + SimpleClassIdentity.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassIdentity_count_get") +@_cdecl("bjs_SimpleClassIdentity_count_get") +public func _bjs_SimpleClassIdentity_count_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SimpleClassIdentity.bridgeJSLiftParameter(_self).count + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassIdentity_count_set") +@_cdecl("bjs_SimpleClassIdentity_count_set") +public func _bjs_SimpleClassIdentity_count_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + SimpleClassIdentity.bridgeJSLiftParameter(_self).count = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassIdentity_flag_get") +@_cdecl("bjs_SimpleClassIdentity_flag_get") +public func _bjs_SimpleClassIdentity_flag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SimpleClassIdentity.bridgeJSLiftParameter(_self).flag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassIdentity_flag_set") +@_cdecl("bjs_SimpleClassIdentity_flag_set") +public func _bjs_SimpleClassIdentity_flag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + SimpleClassIdentity.bridgeJSLiftParameter(_self).flag = Bool.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassIdentity_rate_get") +@_cdecl("bjs_SimpleClassIdentity_rate_get") +public func _bjs_SimpleClassIdentity_rate_get(_ _self: UnsafeMutableRawPointer) -> Float32 { + #if arch(wasm32) + let ret = SimpleClassIdentity.bridgeJSLiftParameter(_self).rate + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassIdentity_rate_set") +@_cdecl("bjs_SimpleClassIdentity_rate_set") +public func _bjs_SimpleClassIdentity_rate_set(_ _self: UnsafeMutableRawPointer, _ value: Float32) -> Void { + #if arch(wasm32) + SimpleClassIdentity.bridgeJSLiftParameter(_self).rate = Float.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassIdentity_precise_get") +@_cdecl("bjs_SimpleClassIdentity_precise_get") +public func _bjs_SimpleClassIdentity_precise_get(_ _self: UnsafeMutableRawPointer) -> Float64 { + #if arch(wasm32) + let ret = SimpleClassIdentity.bridgeJSLiftParameter(_self).precise + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassIdentity_precise_set") +@_cdecl("bjs_SimpleClassIdentity_precise_set") +public func _bjs_SimpleClassIdentity_precise_set(_ _self: UnsafeMutableRawPointer, _ value: Float64) -> Void { + #if arch(wasm32) + SimpleClassIdentity.bridgeJSLiftParameter(_self).precise = Double.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassIdentity_deinit") +@_cdecl("bjs_SimpleClassIdentity_deinit") +public func _bjs_SimpleClassIdentity_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension SimpleClassIdentity: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_SimpleClassIdentity_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_SimpleClassIdentity_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_SimpleClassIdentity_wrap") +fileprivate func _bjs_SimpleClassIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_SimpleClassIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_SimpleClassIdentity_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_SimpleClassIdentity_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_ClassRoundtripIdentity_init") +@_cdecl("bjs_ClassRoundtripIdentity_init") +public func _bjs_ClassRoundtripIdentity_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ClassRoundtripIdentity() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassRoundtripIdentity_roundtripSimpleClassIdentity") +@_cdecl("bjs_ClassRoundtripIdentity_roundtripSimpleClassIdentity") +public func _bjs_ClassRoundtripIdentity_roundtripSimpleClassIdentity(_ _self: UnsafeMutableRawPointer, _ obj: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ClassRoundtripIdentity.bridgeJSLiftParameter(_self).roundtripSimpleClassIdentity(_: SimpleClassIdentity.bridgeJSLiftParameter(obj)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassRoundtripIdentity_makeSimpleClassIdentity") +@_cdecl("bjs_ClassRoundtripIdentity_makeSimpleClassIdentity") +public func _bjs_ClassRoundtripIdentity_makeSimpleClassIdentity(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ClassRoundtripIdentity.bridgeJSLiftParameter(_self).makeSimpleClassIdentity() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassRoundtripIdentity_takeSimpleClassIdentity") +@_cdecl("bjs_ClassRoundtripIdentity_takeSimpleClassIdentity") +public func _bjs_ClassRoundtripIdentity_takeSimpleClassIdentity(_ _self: UnsafeMutableRawPointer, _ obj: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + ClassRoundtripIdentity.bridgeJSLiftParameter(_self).takeSimpleClassIdentity(_: SimpleClassIdentity.bridgeJSLiftParameter(obj)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassRoundtripIdentity_deinit") +@_cdecl("bjs_ClassRoundtripIdentity_deinit") +public func _bjs_ClassRoundtripIdentity_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ClassRoundtripIdentity: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ClassRoundtripIdentity_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ClassRoundtripIdentity_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_ClassRoundtripIdentity_wrap") +fileprivate func _bjs_ClassRoundtripIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ClassRoundtripIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ClassRoundtripIdentity_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ClassRoundtripIdentity_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_IdentityCacheBenchmarkIdentity_init") +@_cdecl("bjs_IdentityCacheBenchmarkIdentity_init") +public func _bjs_IdentityCacheBenchmarkIdentity_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = IdentityCacheBenchmarkIdentity() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmarkIdentity_setupPool") +@_cdecl("bjs_IdentityCacheBenchmarkIdentity_setupPool") +public func _bjs_IdentityCacheBenchmarkIdentity_setupPool(_ _self: UnsafeMutableRawPointer, _ count: Int32) -> Void { + #if arch(wasm32) + IdentityCacheBenchmarkIdentity.bridgeJSLiftParameter(_self).setupPool(_: Int.bridgeJSLiftParameter(count)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmarkIdentity_getPoolRepeated") +@_cdecl("bjs_IdentityCacheBenchmarkIdentity_getPoolRepeated") +public func _bjs_IdentityCacheBenchmarkIdentity_getPoolRepeated(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = IdentityCacheBenchmarkIdentity.bridgeJSLiftParameter(_self).getPoolRepeated() + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmarkIdentity_deinit") +@_cdecl("bjs_IdentityCacheBenchmarkIdentity_deinit") +public func _bjs_IdentityCacheBenchmarkIdentity_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension IdentityCacheBenchmarkIdentity: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_IdentityCacheBenchmarkIdentity_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_IdentityCacheBenchmarkIdentity_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_IdentityCacheBenchmarkIdentity_wrap") +fileprivate func _bjs_IdentityCacheBenchmarkIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_IdentityCacheBenchmarkIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_IdentityCacheBenchmarkIdentity_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_IdentityCacheBenchmarkIdentity_wrap_extern(pointer) +} + @_expose(wasm, "bjs_ArrayRoundtrip_init") @_cdecl("bjs_ArrayRoundtrip_init") public func _bjs_ArrayRoundtrip_init() -> UnsafeMutableRawPointer { diff --git a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json index 9036b503e..0bddddfb6 100644 --- a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json +++ b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json @@ -1491,6 +1491,285 @@ ], "swiftCallName" : "IdentityCacheBenchmark" }, + { + "constructor" : { + "abiName" : "bjs_SimpleClassIdentity_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "label" : "count", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "flag", + "name" : "flag", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "rate", + "name" : "rate", + "type" : { + "float" : { + + } + } + }, + { + "label" : "precise", + "name" : "precise", + "type" : { + "double" : { + + } + } + } + ] + }, + "identityMode" : true, + "methods" : [ + + ], + "name" : "SimpleClassIdentity", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "flag", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "rate", + "type" : { + "float" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "precise", + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "SimpleClassIdentity" + }, + { + "constructor" : { + "abiName" : "bjs_ClassRoundtripIdentity_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "identityMode" : true, + "methods" : [ + { + "abiName" : "bjs_ClassRoundtripIdentity_roundtripSimpleClassIdentity", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripSimpleClassIdentity", + "parameters" : [ + { + "label" : "_", + "name" : "obj", + "type" : { + "swiftHeapObject" : { + "_0" : "SimpleClassIdentity" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "SimpleClassIdentity" + } + } + }, + { + "abiName" : "bjs_ClassRoundtripIdentity_makeSimpleClassIdentity", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeSimpleClassIdentity", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "SimpleClassIdentity" + } + } + }, + { + "abiName" : "bjs_ClassRoundtripIdentity_takeSimpleClassIdentity", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "takeSimpleClassIdentity", + "parameters" : [ + { + "label" : "_", + "name" : "obj", + "type" : { + "swiftHeapObject" : { + "_0" : "SimpleClassIdentity" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "ClassRoundtripIdentity", + "properties" : [ + + ], + "swiftCallName" : "ClassRoundtripIdentity" + }, + { + "constructor" : { + "abiName" : "bjs_IdentityCacheBenchmarkIdentity_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "identityMode" : true, + "methods" : [ + { + "abiName" : "bjs_IdentityCacheBenchmarkIdentity_setupPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setupPool", + "parameters" : [ + { + "label" : "_", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_IdentityCacheBenchmarkIdentity_getPoolRepeated", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getPoolRepeated", + "parameters" : [ + + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "SimpleClassIdentity" + } + } + } + } + } + ], + "name" : "IdentityCacheBenchmarkIdentity", + "properties" : [ + + ], + "swiftCallName" : "IdentityCacheBenchmarkIdentity" + }, { "constructor" : { "abiName" : "bjs_ArrayRoundtrip_init", diff --git a/Benchmarks/Sources/bridge-js.config.json b/Benchmarks/Sources/bridge-js.config.json deleted file mode 100644 index 9e26dfeeb..000000000 --- a/Benchmarks/Sources/bridge-js.config.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/Benchmarks/lib/identity-benchmarks.js b/Benchmarks/lib/identity-benchmarks.js index a916f694e..f83eb9c1d 100644 --- a/Benchmarks/lib/identity-benchmarks.js +++ b/Benchmarks/lib/identity-benchmarks.js @@ -1,6 +1,3 @@ -import { instantiate } from "../.build/plugins/PackageToJS/outputs/Package/instantiate.js" -import { defaultNodeSetup } from "../.build/plugins/PackageToJS/outputs/Package/platforms/node.js" - /** * Force a garbage collection cycle if available */ @@ -23,9 +20,14 @@ function formatBytes(bytes) { } /** - * Parse the --identity-mode CLI argument into a list of modes to benchmark + * Parse the --identity-mode CLI argument into mode labels. + * + * Both class variants (with and without identity mode) are compiled into the + * same WASM build via per-class `@JS(identityMode: true)` annotations, so + * "both" mode works in a single run. + * * @param {string} modeArg - Mode argument: off, none, pointer, or both - * @returns {string[]} List of identity modes to run + * @returns {string[]} Array of mode labels, or empty for "off" */ function parseIdentityModes(modeArg) { if (!modeArg || modeArg === 'off') return [] @@ -73,14 +75,13 @@ function parseIdentityReusePools(value) { /** * Capture a memory profile sample for identity mode benchmarks. * Measures heap cost of holding roundtrip results in an array. - * In pointer mode, retained entries reference the same wrapper; in none mode, each is distinct. - * @param {object} classRoundtrip - ClassRoundtrip instance - * @param {object} baseObject - Base SimpleClass instance + * @param {function} roundtrip - Function that roundtrips an object + * @param {object} baseObject - Base object instance * @param {number} iterations - Number of roundtrip iterations * @param {number} sampleInterval - How often to sample heap usage * @returns {Promise} Memory profile sample */ -async function captureIdentityMemorySample(classRoundtrip, baseObject, iterations, sampleInterval) { +async function captureIdentityMemorySample(roundtrip, baseObject, iterations, sampleInterval) { const v8 = await import('v8') forceGC() const before = process.memoryUsage() @@ -91,7 +92,7 @@ async function captureIdentityMemorySample(classRoundtrip, baseObject, iteration let current = baseObject const startedAt = performance.now() for (let i = 0; i < iterations; i++) { - current = classRoundtrip.roundtripSimpleClass(current) + current = roundtrip(current) retained.push(current) if ((i + 1) % sampleInterval === 0) { peakHeapUsed = Math.max(peakHeapUsed, process.memoryUsage().heapUsed) @@ -124,34 +125,47 @@ async function captureIdentityMemorySample(classRoundtrip, baseObject, iteration } /** - * Run identity mode benchmarks for each configured mode. - * Creates a separate WASM instance per mode to isolate identity cache state. + * Run identity mode benchmarks using dual-class strategy. + * + * Both class variants live in the same WASM build: + * - "none" mode uses: SimpleClass, ClassRoundtrip, IdentityCacheBenchmark + * - "pointer" mode uses: SimpleClassIdentity, ClassRoundtripIdentity, IdentityCacheBenchmarkIdentity + * * @param {object} results - Results object to accumulate benchmark data * @param {function|null} nameFilter - Optional filter for benchmark names * @param {object|null} identityConfig - Identity benchmark configuration * @param {function} benchmarkRunner - Benchmark runner function from singleRun + * @param {object} exports - Exports from the main WASM instance */ -async function runIdentityModeBenchmarks(results, nameFilter, identityConfig, benchmarkRunner) { +async function runIdentityModeBenchmarks(results, nameFilter, identityConfig, benchmarkRunner, exports) { if (!identityConfig || identityConfig.modes.length === 0) return for (const mode of identityConfig.modes) { - const options = await defaultNodeSetup({}) - const { exports } = await instantiate({ - ...options, - identityMode: mode, - getImports: () => ({ - benchmarkHelperNoop: () => {}, - benchmarkHelperNoopWithNumber: () => {}, - benchmarkRunner: () => {}, - }), - }) + // Select the right class set based on mode + let classRoundtrip, baseObject, roundtrip, makeSimple, takeSimple + let SimpleClassCtor, IdentityCacheCtor - const classRoundtrip = new exports.ClassRoundtrip() - const baseObject = new exports.SimpleClass('Hello', 42, true, 0.5, 3.14159) + if (mode === 'pointer') { + classRoundtrip = new exports.ClassRoundtripIdentity() + baseObject = new exports.SimpleClassIdentity('Hello', 42, true, 0.5, 3.14159) + SimpleClassCtor = exports.SimpleClassIdentity + IdentityCacheCtor = exports.IdentityCacheBenchmarkIdentity + roundtrip = (obj) => classRoundtrip.roundtripSimpleClassIdentity(obj) + makeSimple = () => classRoundtrip.makeSimpleClassIdentity() + takeSimple = (obj) => classRoundtrip.takeSimpleClassIdentity(obj) + } else { + classRoundtrip = new exports.ClassRoundtrip() + baseObject = new exports.SimpleClass('Hello', 42, true, 0.5, 3.14159) + SimpleClassCtor = exports.SimpleClass + IdentityCacheCtor = exports.IdentityCacheBenchmark + roundtrip = (obj) => classRoundtrip.roundtripSimpleClass(obj) + makeSimple = () => classRoundtrip.makeSimpleClass() + takeSimple = (obj) => classRoundtrip.takeSimpleClass(obj) + } for (const poolSize of identityConfig.reusePools) { const pool = Array.from({ length: poolSize }, (_, i) => { - return new exports.SimpleClass(`Hello ${i}`, i, true, 0.5, 3.14159) + return new SimpleClassCtor(`Hello ${i}`, i, true, 0.5, 3.14159) }) const testName = poolSize === 1 ? `IdentityMode/${mode}/passBothWaysRoundtrip` @@ -159,7 +173,7 @@ async function runIdentityModeBenchmarks(results, nameFilter, identityConfig, be benchmarkRunner(testName, () => { for (let i = 0; i < identityConfig.iterations; i++) { const index = i % poolSize - pool[index] = classRoundtrip.roundtripSimpleClass(pool[index]) + pool[index] = roundtrip(pool[index]) } }) for (const object of pool) { @@ -169,27 +183,21 @@ async function runIdentityModeBenchmarks(results, nameFilter, identityConfig, be benchmarkRunner(`IdentityMode/${mode}/swiftConsumesSameObject`, () => { for (let i = 0; i < identityConfig.iterations; i++) { - classRoundtrip.takeSimpleClass(baseObject) + takeSimple(baseObject) } }) - // Churn scenario: create, roundtrip, release in a tight loop. - // Tests FinalizationRegistry cleanup overhead when objects are - // constantly created and dropped. In pointer mode, the identity - // cache accumulates WeakRef entries that must be cleaned up. benchmarkRunner(`IdentityMode/${mode}/churnObjects`, () => { for (let i = 0; i < identityConfig.iterations; i++) { - const obj = new exports.SimpleClass(`temp ${i}`, i, true, 0.5, 3.14159) - classRoundtrip.roundtripSimpleClass(obj) + const obj = new SimpleClassCtor(`temp ${i}`, i, true, 0.5, 3.14159) + roundtrip(obj) obj.release() } }) // Bulk array return: Swift returns same cached array of 100 objects. - // Tests the common pattern of returning model collections (e.g. building.floors). - // Uses fewer iterations since each call returns 100 objects. - const identityCacheBench = new exports.IdentityCacheBenchmark() + const identityCacheBench = new IdentityCacheCtor() identityCacheBench.setupPool(100) identityCacheBench.getPoolRepeated() // warm the cache benchmarkRunner(`IdentityMode/${mode}/getPoolRepeated_100`, () => { @@ -201,13 +209,13 @@ async function runIdentityModeBenchmarks(results, nameFilter, identityConfig, be benchmarkRunner(`IdentityMode/${mode}/swiftCreatesObject`, () => { for (let i = 0; i < identityConfig.iterations; i++) { - classRoundtrip.makeSimpleClass() + makeSimple() } }) if (identityConfig.memory) { const sample = await captureIdentityMemorySample( - classRoundtrip, baseObject, + roundtrip, baseObject, identityConfig.iterations, identityConfig.sampleInterval ) if (!identityConfig.memorySamples[mode]) { diff --git a/Benchmarks/run.js b/Benchmarks/run.js index f72ee6a47..f48fa8acf 100644 --- a/Benchmarks/run.js +++ b/Benchmarks/run.js @@ -903,7 +903,7 @@ async function singleRun(results, nameFilter, iterations, identityConfig) { } }) - await runIdentityModeBenchmarks(results, nameFilter, identityConfig, benchmarkRunner) + await runIdentityModeBenchmarks(results, nameFilter, identityConfig, benchmarkRunner, exports) } /** @@ -1004,6 +1004,8 @@ Options: --target-cv=NUMBER Target coefficient of variation % (default: 5) --filter=PATTERN Filter benchmarks by name (substring or /regex/flags) --identity-mode=MODE Identity benchmarks: off, none, pointer, both (default: off) + Both class variants are in the same build via per-class + @JS(identityMode: true). Use 'both' to compare side-by-side. --identity-iterations=N Iterations for identity benchmarks (default: 1000000) --identity-reuse-pools=N,N Pool sizes for reuse scenarios (default: 1,8,64) --identity-memory Enable memory profiling for identity benchmarks diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index 404eef634..3d8f417e3 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -1197,6 +1197,14 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { return nil } + private func extractIdentityMode(from jsAttribute: AttributeSyntax) -> Bool? { + guard let arguments = jsAttribute.arguments?.as(LabeledExprListSyntax.self), + let identityArg = arguments.first(where: { $0.label?.text == "identityMode" }) + else { return nil } + let text = identityArg.expression.trimmedDescription + return text == "true" + } + override func visit(_ node: InitializerDeclSyntax) -> SyntaxVisitorContinueKind { guard let jsAttribute = node.attributes.firstJSAttribute else { return .skipChildren } @@ -1384,6 +1392,7 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { for: node, message: "Class visibility must be at least internal" ) + let classIdentityMode = extractIdentityMode(from: jsAttribute) let exportedClass = ExportedClass( name: name, swiftCallName: swiftCallName, @@ -1391,7 +1400,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { constructor: nil, methods: [], properties: [], - namespace: namespaceResult.namespace + namespace: namespaceResult.namespace, + identityMode: classIdentityMode ) let uniqueKey = makeKey(name: name, namespace: namespaceResult.namespace) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 2ee8cd869..db83d3987 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -25,6 +25,21 @@ public struct BridgeJSLink { self.sharedMemory = sharedMemory } + /// The identity mode from the config file, resolved from skeletons. + var configIdentityMode: String { + skeletons.compactMap(\.exported).compactMap(\.identityMode).first ?? "none" + } + + /// Whether a class should use identity caching based on its annotation and the config default. + private func shouldUseIdentityCache(for klass: ExportedClass) -> Bool { + // Per-class annotation takes priority + if let classOverride = klass.identityMode { + return classOverride + } + // Fall back to config default + return configIdentityMode == "pointer" + } + mutating func addSkeletonFile(data: Data) throws { do { let unified = try JSONDecoder().decode(BridgeJSSkeleton.self, from: data) @@ -110,7 +125,7 @@ public struct BridgeJSLink { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -937,7 +952,6 @@ public struct BridgeJSLink { printer.write("export function createInstantiator(options: {") printer.indent { printer.write("imports: Imports;") - printer.write("identityMode?: \"none\" | \"pointer\";") } printer.write("}, swift: any): Promise<{") printer.indent { @@ -983,11 +997,6 @@ public struct BridgeJSLink { try printer.indent { printer.write(lines: generateVariableDeclarations()) - let configIdentityMode = skeletons.compactMap(\.exported).compactMap(\.identityMode).first ?? "none" - printer.write("const identityMode = options.identityMode ?? \"\(configIdentityMode)\";") - printer.write( - "const shouldUseIdentityMap = identityMode === \"pointer\" && typeof WeakRef !== \"undefined\" && typeof FinalizationRegistry !== \"undefined\";" - ) let bodyPrinter = CodeFragmentPrinter() let allStructs = exportedSkeletons.flatMap { $0.structs } @@ -1993,18 +2002,45 @@ extension BridgeJSLink { dtsExportEntryPrinter.write("\(klass.name): {") jsPrinter.write("class \(klass.name) extends SwiftHeapObject {") - // Always add __construct and constructor methods for all classes + // Per-class identity mode: determine at codegen time whether this class uses identity caching + let useIdentity = shouldUseIdentityCache(for: klass) jsPrinter.indent { - jsPrinter.write("static __identityCache = new Map();") - jsPrinter.nextLine() + if useIdentity { + jsPrinter.write("static __identityCache = new Map();") + jsPrinter.nextLine() + } jsPrinter.write("static __construct(ptr) {") jsPrinter.indent { - jsPrinter.write( - "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_\(klass.abiName)_deinit, \(klass.name).prototype, \(klass.name).__identityCache);" - ) + if useIdentity { + jsPrinter.write( + "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_\(klass.abiName)_deinit, \(klass.name).prototype, \(klass.name).__identityCache);" + ) + } else { + jsPrinter.write( + "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_\(klass.abiName)_deinit, \(klass.name).prototype, null);" + ) + } } jsPrinter.write("}") jsPrinter.nextLine() + // __constructFresh skips the identity cache lookup for newly created objects. + // Since the pointer is brand new, it cannot already be in the cache. + if useIdentity { + jsPrinter.write("static __constructFresh(ptr) {") + jsPrinter.indent { + jsPrinter.write("const obj = Object.create(\(klass.name).prototype);") + jsPrinter.write( + "const state = { pointer: ptr, deinit: instance.exports.bjs_\(klass.abiName)_deinit, hasReleased: false, identityMap: \(klass.name).__identityCache };" + ) + jsPrinter.write("obj.pointer = ptr;") + jsPrinter.write("obj.__swiftHeapObjectState = state;") + jsPrinter.write("swiftHeapObjectFinalizationRegistry.register(obj, state, state);") + jsPrinter.write("\(klass.name).__identityCache.set(ptr, new WeakRef(obj));") + jsPrinter.write("return obj;") + } + jsPrinter.write("}") + jsPrinter.nextLine() + } } if let constructor: ExportedConstructor = klass.constructor { @@ -2021,10 +2057,14 @@ extension BridgeJSLink { jsPrinter.indent { jsPrinter.write("constructor(\(constructorParamList)) {") let returnExpr = thunkBuilder.callConstructor(abiName: constructor.abiName) + let constructCall = + useIdentity + ? "\(klass.name).__constructFresh(\(returnExpr))" + : "\(klass.name).__construct(\(returnExpr))" jsPrinter.indent { thunkBuilder.renderFunctionBody( into: jsPrinter, - returnExpr: "\(klass.name).__construct(\(returnExpr))" + returnExpr: constructCall ) } jsPrinter.write("}") diff --git a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift index f77b66043..03e6d676a 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift @@ -784,6 +784,7 @@ public struct ExportedClass: Codable, NamespacedExportedType { public var methods: [ExportedFunction] public var properties: [ExportedProperty] public var namespace: [String]? + public var identityMode: Bool? // nil = use config default, true/false = override public init( name: String, @@ -792,7 +793,8 @@ public struct ExportedClass: Codable, NamespacedExportedType { constructor: ExportedConstructor? = nil, methods: [ExportedFunction], properties: [ExportedProperty] = [], - namespace: [String]? = nil + namespace: [String]? = nil, + identityMode: Bool? = nil ) { self.name = name self.swiftCallName = swiftCallName @@ -801,6 +803,7 @@ public struct ExportedClass: Codable, NamespacedExportedType { self.methods = methods self.properties = properties self.namespace = namespace + self.identityMode = identityMode } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift index 8906cdeb3..64c9ae535 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift @@ -107,43 +107,51 @@ import Testing } @Test - func emitsIdentityModeOptionAndRuntimeScaffolding() throws { - let url = Self.inputsDirectory.appendingPathComponent("SwiftClass.swift") + func perClassIdentityModeFromAnnotation() throws { + let url = Self.inputsDirectory.appendingPathComponent("IdentityModeClass.swift") let sourceFile = Parser.parse(source: try String(contentsOf: url, encoding: .utf8)) - let swiftAPI = SwiftToSkeleton(progress: .silent, moduleName: "TestModule", exposeToGlobal: false) - swiftAPI.addSourceFile(sourceFile, inputFilePath: "SwiftClass.swift") - let outputSkeleton = try swiftAPI.finalize() - let bridgeJSLink = BridgeJSLink( - skeletons: [ - outputSkeleton - ], - sharedMemory: false + let swiftAPI = SwiftToSkeleton( + progress: .silent, + moduleName: "TestModule", + exposeToGlobal: false, + identityMode: nil // no config default ) + swiftAPI.addSourceFile(sourceFile, inputFilePath: "IdentityModeClass.swift") + let outputSkeleton = try swiftAPI.finalize() - let (outputJs, outputDts) = try bridgeJSLink.link() + // Verify skeleton has per-class identity mode (not captured by snapshots) + let cachedClass = outputSkeleton.exported!.classes.first { $0.name == "CachedModel" } + let uncachedClass = outputSkeleton.exported!.classes.first { $0.name == "UncachedModel" } + let explicitlyUncachedClass = outputSkeleton.exported!.classes.first { $0.name == "ExplicitlyUncachedModel" } + #expect(cachedClass?.identityMode == true) + #expect(uncachedClass?.identityMode == nil) + #expect(explicitlyUncachedClass?.identityMode == false) - #expect(outputDts.contains("identityMode?: \"none\" | \"pointer\";")) - #expect( - outputJs.contains("const identityMode = options.identityMode ?? \"none\";") - ) - #expect( - outputJs.contains( - "const shouldUseIdentityMap = identityMode === \"pointer\" && typeof WeakRef !== \"undefined\" && typeof FinalizationRegistry !== \"undefined\";" - ) - ) - #expect(outputJs.contains("if (!shouldUseIdentityMap) {")) - #expect(outputJs.contains("state.identityMap?.delete(state.pointer);")) - #expect(!outputJs.contains("static finalizerByDeinit")) - #expect(!outputJs.contains("static __getFinalizer")) - #expect(!outputJs.contains("static identityCache = new Map();")) - #expect(!outputJs.contains("identityCacheByDeinit")) - #expect(!outputJs.contains("identityCache ??")) - #expect(outputJs.contains("static __wrap(pointer, deinit, prototype, identityCache)")) - #expect(outputJs.contains("static __identityCache = new Map();")) - #expect( - outputJs.contains( - "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache);" - ) + // Verify generated JS via snapshot + let bridgeJSLink = BridgeJSLink(skeletons: [outputSkeleton], sharedMemory: false) + try snapshot(bridgeJSLink: bridgeJSLink, name: "IdentityModeClass.PerClass") + } + + @Test + func perClassIdentityModeWithConfigOverride() throws { + let url = Self.inputsDirectory.appendingPathComponent("IdentityModeClass.swift") + let sourceFile = Parser.parse(source: try String(contentsOf: url, encoding: .utf8)) + let swiftAPI = SwiftToSkeleton( + progress: .silent, + moduleName: "TestModule", + exposeToGlobal: false, + identityMode: "pointer" // config says pointer for all classes ) + swiftAPI.addSourceFile(sourceFile, inputFilePath: "IdentityModeClass.swift") + let outputSkeleton = try swiftAPI.finalize() + + // When config says "pointer", classes without annotation get identity mode from config. + // But @JS(identityMode: false) should still override to "without identity". + let explicitlyUncachedClass = outputSkeleton.exported!.classes.first { $0.name == "ExplicitlyUncachedModel" } + #expect(explicitlyUncachedClass?.identityMode == false) + + // Verify generated JS via snapshot + let bridgeJSLink = BridgeJSLink(skeletons: [outputSkeleton], sharedMemory: false) + try snapshot(bridgeJSLink: bridgeJSLink, name: "IdentityModeClass.ConfigPointer") } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/IdentityModeClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/IdentityModeClass.swift new file mode 100644 index 000000000..4d50b6c76 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/IdentityModeClass.swift @@ -0,0 +1,28 @@ +import JavaScriptKit + +@JS(identityMode: true) +class CachedModel { + @JS var name: String + + @JS init(name: String) { + self.name = name + } +} + +@JS +class UncachedModel { + @JS var value: Int + + @JS init(value: Int) { + self.value = value + } +} + +@JS(identityMode: false) +class ExplicitlyUncachedModel { + @JS var count: Int + + @JS init(count: Int) { + self.count = count + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json new file mode 100644 index 000000000..d7a9064dc --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json @@ -0,0 +1,148 @@ +{ + "exported" : { + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_CachedModel_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ] + }, + "identityMode" : true, + "methods" : [ + + ], + "name" : "CachedModel", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "CachedModel" + }, + { + "constructor" : { + "abiName" : "bjs_UncachedModel_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "UncachedModel", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "UncachedModel" + }, + { + "constructor" : { + "abiName" : "bjs_ExplicitlyUncachedModel_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "count", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "identityMode" : false, + "methods" : [ + + ], + "name" : "ExplicitlyUncachedModel", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "ExplicitlyUncachedModel" + } + ], + "enums" : [ + + ], + "exposeToGlobal" : false, + "functions" : [ + + ], + "protocols" : [ + + ], + "structs" : [ + + ] + }, + "moduleName" : "TestModule" +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.swift new file mode 100644 index 000000000..a79b91d56 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.swift @@ -0,0 +1,188 @@ +@_expose(wasm, "bjs_CachedModel_init") +@_cdecl("bjs_CachedModel_init") +public func _bjs_CachedModel_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = CachedModel(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_CachedModel_name_get") +@_cdecl("bjs_CachedModel_name_get") +public func _bjs_CachedModel_name_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = CachedModel.bridgeJSLiftParameter(_self).name + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_CachedModel_name_set") +@_cdecl("bjs_CachedModel_name_set") +public func _bjs_CachedModel_name_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + CachedModel.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_CachedModel_deinit") +@_cdecl("bjs_CachedModel_deinit") +public func _bjs_CachedModel_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension CachedModel: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_CachedModel_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_CachedModel_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_CachedModel_wrap") +fileprivate func _bjs_CachedModel_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_CachedModel_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_CachedModel_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_CachedModel_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_UncachedModel_init") +@_cdecl("bjs_UncachedModel_init") +public func _bjs_UncachedModel_init(_ value: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = UncachedModel(value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_UncachedModel_value_get") +@_cdecl("bjs_UncachedModel_value_get") +public func _bjs_UncachedModel_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = UncachedModel.bridgeJSLiftParameter(_self).value + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_UncachedModel_value_set") +@_cdecl("bjs_UncachedModel_value_set") +public func _bjs_UncachedModel_value_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + UncachedModel.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_UncachedModel_deinit") +@_cdecl("bjs_UncachedModel_deinit") +public func _bjs_UncachedModel_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension UncachedModel: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_UncachedModel_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_UncachedModel_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_UncachedModel_wrap") +fileprivate func _bjs_UncachedModel_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_UncachedModel_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_UncachedModel_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_UncachedModel_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_ExplicitlyUncachedModel_init") +@_cdecl("bjs_ExplicitlyUncachedModel_init") +public func _bjs_ExplicitlyUncachedModel_init(_ count: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ExplicitlyUncachedModel(count: Int.bridgeJSLiftParameter(count)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ExplicitlyUncachedModel_count_get") +@_cdecl("bjs_ExplicitlyUncachedModel_count_get") +public func _bjs_ExplicitlyUncachedModel_count_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = ExplicitlyUncachedModel.bridgeJSLiftParameter(_self).count + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ExplicitlyUncachedModel_count_set") +@_cdecl("bjs_ExplicitlyUncachedModel_count_set") +public func _bjs_ExplicitlyUncachedModel_count_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + ExplicitlyUncachedModel.bridgeJSLiftParameter(_self).count = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ExplicitlyUncachedModel_deinit") +@_cdecl("bjs_ExplicitlyUncachedModel_deinit") +public func _bjs_ExplicitlyUncachedModel_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ExplicitlyUncachedModel: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ExplicitlyUncachedModel_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ExplicitlyUncachedModel_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_ExplicitlyUncachedModel_wrap") +fileprivate func _bjs_ExplicitlyUncachedModel_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ExplicitlyUncachedModel_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ExplicitlyUncachedModel_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ExplicitlyUncachedModel_wrap_extern(pointer) +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts index cf51c51f3..255249eef 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts @@ -88,7 +88,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js index 32d9126fc..8359220c9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js @@ -43,8 +43,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointHelpers = () => ({ lower: (value) => { f64Stack.push(value.x); @@ -369,7 +367,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -397,18 +395,14 @@ export async function createInstantiator(options, swift) { } } class Item extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Item_deinit, Item.prototype, Item.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Item_deinit, Item.prototype, null); } } class MultiArrayContainer extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MultiArrayContainer_deinit, MultiArrayContainer.prototype, MultiArrayContainer.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MultiArrayContainer_deinit, MultiArrayContainer.prototype, null); } constructor(nums, strs) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.d.ts index 29236eb44..aecab090e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.d.ts @@ -17,7 +17,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js index c3a2a2e53..bf368738e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.d.ts index 46e521365..e612ae1e1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.d.ts @@ -16,7 +16,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js index 8f2a26d9b..89ab29827 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; function __bjs_jsValueLower(value) { let kind; let payload1; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.d.ts index e93f46d69..491a66795 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.d.ts @@ -16,7 +16,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js index 4dec1f812..7fd6a0d6b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; function __bjs_jsValueLower(value) { let kind; let payload1; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts index dca39489e..ac5658eb3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts @@ -158,7 +158,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index 3064e18a9..cafd250b0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -36,8 +36,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createConfigHelpers = () => ({ lower: (value) => { const bytes = textEncoder.encode(value.name); @@ -300,7 +298,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -328,10 +326,8 @@ export async function createInstantiator(options, swift) { } } class DefaultGreeter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_DefaultGreeter_deinit, DefaultGreeter.prototype, DefaultGreeter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_DefaultGreeter_deinit, DefaultGreeter.prototype, null); } constructor(name) { @@ -353,10 +349,8 @@ export async function createInstantiator(options, swift) { } } class EmptyGreeter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_EmptyGreeter_deinit, EmptyGreeter.prototype, EmptyGreeter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_EmptyGreeter_deinit, EmptyGreeter.prototype, null); } constructor() { @@ -365,10 +359,8 @@ export async function createInstantiator(options, swift) { } } class ConstructorDefaults extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_ConstructorDefaults_deinit, ConstructorDefaults.prototype, ConstructorDefaults.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_ConstructorDefaults_deinit, ConstructorDefaults.prototype, null); } constructor(name = "Default", count = 42, enabled = true, status = StatusValues.Active, tag = null) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts index d31cf3d66..f14b29aa4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts @@ -32,7 +32,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js index 100550c7e..920017972 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createCountersHelpers = () => ({ lower: (value) => { const bytes = textEncoder.encode(value.name); @@ -309,7 +307,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -337,10 +335,8 @@ export async function createInstantiator(options, swift) { } } class Box extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Box_deinit, Box.prototype, Box.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Box_deinit, Box.prototype, null); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts index eeb0cf428..13f77ae08 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts @@ -192,7 +192,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js index 375493923..3d2230c6c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js @@ -111,8 +111,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointHelpers = () => ({ lower: (value) => { f64Stack.push(value.x); @@ -976,7 +974,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -1004,10 +1002,8 @@ export async function createInstantiator(options, swift) { } } class User extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_User_deinit, User.prototype, User.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_User_deinit, User.prototype, null); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.d.ts index c403d38b4..5581df31e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.d.ts @@ -53,7 +53,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js index 481a198db..fe94c046f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js @@ -54,8 +54,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts index 9fafb6f01..b78f0cecd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts @@ -151,7 +151,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js index 21dbd3c55..10fe31f64 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js @@ -74,8 +74,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -292,7 +290,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -320,10 +318,8 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converter_deinit, Converter.prototype, null); } constructor() { @@ -345,10 +341,8 @@ export async function createInstantiator(options, swift) { } } class HTTPServer extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_API_HTTPServer_deinit, HTTPServer.prototype, HTTPServer.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_API_HTTPServer_deinit, HTTPServer.prototype, null); } constructor() { @@ -360,10 +354,8 @@ export async function createInstantiator(options, swift) { } } class TestServer extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_APIV2_Internal_TestServer_deinit, TestServer.prototype, TestServer.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_APIV2_Internal_TestServer_deinit, TestServer.prototype, null); } constructor() { @@ -375,10 +367,8 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Formatting_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Formatting_Converter_deinit, Converter.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts index d8a145e3b..23d872d27 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts @@ -112,7 +112,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js index 7e7627d32..a6aeee4b0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js @@ -55,8 +55,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -273,7 +271,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -301,10 +299,8 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converter_deinit, Converter.prototype, null); } constructor() { @@ -326,10 +322,8 @@ export async function createInstantiator(options, swift) { } } class HTTPServer extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_API_HTTPServer_deinit, HTTPServer.prototype, HTTPServer.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_API_HTTPServer_deinit, HTTPServer.prototype, null); } constructor() { @@ -341,10 +335,8 @@ export async function createInstantiator(options, swift) { } } class TestServer extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_APIV2_Internal_TestServer_deinit, TestServer.prototype, TestServer.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Networking_APIV2_Internal_TestServer_deinit, TestServer.prototype, null); } constructor() { @@ -356,10 +348,8 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Formatting_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Formatting_Converter_deinit, Converter.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.d.ts index 92f043b9d..fbd5ad637 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.d.ts @@ -166,7 +166,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js index f47ae00ce..7e5334811 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js @@ -105,8 +105,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.d.ts index 88ff36752..d6ab5aa8f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.d.ts @@ -26,7 +26,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js index 18cb1d34d..53ddd7301 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.d.ts index d138fcdde..312f56786 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.d.ts @@ -14,7 +14,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js index 4f7732d63..346b74eac 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.d.ts index 12ac7a310..ae1152016 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.d.ts @@ -16,7 +16,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js index aff235d10..f74095374 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.d.ts new file mode 100644 index 000000000..e5e2a3a84 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.d.ts @@ -0,0 +1,42 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +/// Represents a Swift heap object like a class instance or an actor instance. +export interface SwiftHeapObject { + /// Release the heap object. + /// + /// Note: Calling this method will release the heap object and it will no longer be accessible. + release(): void; +} +export interface CachedModel extends SwiftHeapObject { + name: string; +} +export interface UncachedModel extends SwiftHeapObject { + value: number; +} +export interface ExplicitlyUncachedModel extends SwiftHeapObject { + count: number; +} +export type Exports = { + CachedModel: { + new(name: string): CachedModel; + } + UncachedModel: { + new(value: number): UncachedModel; + } + ExplicitlyUncachedModel: { + new(count: number): ExplicitlyUncachedModel; + } +} +export type Imports = { +} +export function createInstantiator(options: { + imports: Imports; +}, swift: any): Promise<{ + addImports: (importObject: WebAssembly.Imports) => void; + setInstance: (instance: WebAssembly.Instance) => void; + createExports: (instance: WebAssembly.Instance) => Exports; +}>; \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js new file mode 100644 index 000000000..7970a905d --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js @@ -0,0 +1,362 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +export async function createInstantiator(options, swift) { + let instance; + let memory; + let setException; + let decodeString; + const textDecoder = new TextDecoder("utf-8"); + const textEncoder = new TextEncoder("utf-8"); + let tmpRetString; + let tmpRetBytes; + let tmpRetException; + let tmpRetOptionalBool; + let tmpRetOptionalInt; + let tmpRetOptionalFloat; + let tmpRetOptionalDouble; + let tmpRetOptionalHeapObject; + let strStack = []; + let i32Stack = []; + let i64Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + + return { + /** + * @param {WebAssembly.Imports} importObject + */ + addImports: (importObject, importsContext) => { + bjs = {}; + importObject["bjs"] = bjs; + bjs["swift_js_return_string"] = function(ptr, len) { + tmpRetString = decodeString(ptr, len); + } + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { + const source = swift.memory.getObject(sourceId); + swift.memory.release(sourceId); + const bytes = new Uint8Array(memory.buffer, bytesPtr); + bytes.set(source); + } + bjs["swift_js_make_js_string"] = function(ptr, len) { + return swift.memory.retain(decodeString(ptr, len)); + } + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { + const target = new Uint8Array(memory.buffer, ptr, len); + target.set(tmpRetBytes); + tmpRetBytes = undefined; + } + bjs["swift_js_throw"] = function(id) { + tmpRetException = swift.memory.retainByRef(id); + } + bjs["swift_js_retain"] = function(id) { + return swift.memory.retainByRef(id); + } + bjs["swift_js_release"] = function(id) { + swift.memory.release(id); + } + bjs["swift_js_push_i32"] = function(v) { + i32Stack.push(v | 0); + } + bjs["swift_js_push_f32"] = function(v) { + f32Stack.push(Math.fround(v)); + } + bjs["swift_js_push_f64"] = function(v) { + f64Stack.push(v); + } + bjs["swift_js_push_string"] = function(ptr, len) { + const value = decodeString(ptr, len); + strStack.push(value); + } + bjs["swift_js_pop_i32"] = function() { + return i32Stack.pop(); + } + bjs["swift_js_pop_f32"] = function() { + return f32Stack.pop(); + } + bjs["swift_js_pop_f64"] = function() { + return f64Stack.pop(); + } + bjs["swift_js_push_pointer"] = function(pointer) { + ptrStack.push(pointer); + } + bjs["swift_js_pop_pointer"] = function() { + return ptrStack.pop(); + } + bjs["swift_js_push_i64"] = function(v) { + i64Stack.push(v); + } + bjs["swift_js_pop_i64"] = function() { + return i64Stack.pop(); + } + bjs["swift_js_return_optional_bool"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalBool = null; + } else { + tmpRetOptionalBool = value !== 0; + } + } + bjs["swift_js_return_optional_int"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalInt = null; + } else { + tmpRetOptionalInt = value | 0; + } + } + bjs["swift_js_return_optional_float"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalFloat = null; + } else { + tmpRetOptionalFloat = Math.fround(value); + } + } + bjs["swift_js_return_optional_double"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalDouble = null; + } else { + tmpRetOptionalDouble = value; + } + } + bjs["swift_js_return_optional_string"] = function(isSome, ptr, len) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = decodeString(ptr, len); + } + } + bjs["swift_js_return_optional_object"] = function(isSome, objectId) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = swift.memory.getObject(objectId); + } + } + bjs["swift_js_return_optional_heap_object"] = function(isSome, pointer) { + if (isSome === 0) { + tmpRetOptionalHeapObject = null; + } else { + tmpRetOptionalHeapObject = pointer; + } + } + bjs["swift_js_get_optional_int_presence"] = function() { + return tmpRetOptionalInt != null ? 1 : 0; + } + bjs["swift_js_get_optional_int_value"] = function() { + const value = tmpRetOptionalInt; + tmpRetOptionalInt = undefined; + return value; + } + bjs["swift_js_get_optional_string"] = function() { + const str = tmpRetString; + tmpRetString = undefined; + if (str == null) { + return -1; + } else { + const bytes = textEncoder.encode(str); + tmpRetBytes = bytes; + return bytes.length; + } + } + bjs["swift_js_get_optional_float_presence"] = function() { + return tmpRetOptionalFloat != null ? 1 : 0; + } + bjs["swift_js_get_optional_float_value"] = function() { + const value = tmpRetOptionalFloat; + tmpRetOptionalFloat = undefined; + return value; + } + bjs["swift_js_get_optional_double_presence"] = function() { + return tmpRetOptionalDouble != null ? 1 : 0; + } + bjs["swift_js_get_optional_double_value"] = function() { + const value = tmpRetOptionalDouble; + tmpRetOptionalDouble = undefined; + return value; + } + bjs["swift_js_get_optional_heap_object_pointer"] = function() { + const pointer = tmpRetOptionalHeapObject; + tmpRetOptionalHeapObject = undefined; + return pointer || 0; + } + bjs["swift_js_closure_unregister"] = function(funcRef) {} + // Wrapper functions for module: TestModule + if (!importObject["TestModule"]) { + importObject["TestModule"] = {}; + } + importObject["TestModule"]["bjs_CachedModel_wrap"] = function(pointer) { + const obj = _exports['CachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_ExplicitlyUncachedModel_wrap"] = function(pointer) { + const obj = _exports['ExplicitlyUncachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_UncachedModel_wrap"] = function(pointer) { + const obj = _exports['UncachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + }, + setInstance: (i) => { + instance = i; + memory = instance.exports.memory; + + decodeString = (ptr, len) => { const bytes = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); return textDecoder.decode(bytes); } + + setException = (error) => { + instance.exports._swift_js_exception.value = swift.memory.retain(error) + } + }, + /** @param {WebAssembly.Instance} instance */ + createExports: (instance) => { + const js = swift.memory.heap; + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + + /// Represents a Swift heap object like a class instance or an actor instance. + class SwiftHeapObject { + static __wrap(pointer, deinit, prototype, identityCache) { + const makeFresh = (identityMap) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + swiftHeapObjectFinalizationRegistry.register(obj, state, state); + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!identityCache) { + return makeFresh(null); + } + + const cached = identityCache.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); + return cached; + } + if (identityCache.has(pointer)) { + identityCache.delete(pointer); + } + + return makeFresh(identityCache); + } + + release() { + const state = this.__swiftHeapObjectState; + if (state.hasReleased) { + return; + } + state.hasReleased = true; + swiftHeapObjectFinalizationRegistry.unregister(state); + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + } + } + class CachedModel extends SwiftHeapObject { + static __identityCache = new Map(); + + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_CachedModel_deinit, CachedModel.prototype, CachedModel.__identityCache); + } + + static __constructFresh(ptr) { + const obj = Object.create(CachedModel.prototype); + const state = { pointer: ptr, deinit: instance.exports.bjs_CachedModel_deinit, hasReleased: false, identityMap: CachedModel.__identityCache }; + obj.pointer = ptr; + obj.__swiftHeapObjectState = state; + swiftHeapObjectFinalizationRegistry.register(obj, state, state); + CachedModel.__identityCache.set(ptr, new WeakRef(obj)); + return obj; + } + + constructor(name) { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + const ret = instance.exports.bjs_CachedModel_init(nameId, nameBytes.length); + return CachedModel.__constructFresh(ret); + } + get name() { + instance.exports.bjs_CachedModel_name_get(this.pointer); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + } + set name(value) { + const valueBytes = textEncoder.encode(value); + const valueId = swift.memory.retain(valueBytes); + instance.exports.bjs_CachedModel_name_set(this.pointer, valueId, valueBytes.length); + } + } + class UncachedModel extends SwiftHeapObject { + static __identityCache = new Map(); + + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_UncachedModel_deinit, UncachedModel.prototype, UncachedModel.__identityCache); + } + + static __constructFresh(ptr) { + const obj = Object.create(UncachedModel.prototype); + const state = { pointer: ptr, deinit: instance.exports.bjs_UncachedModel_deinit, hasReleased: false, identityMap: UncachedModel.__identityCache }; + obj.pointer = ptr; + obj.__swiftHeapObjectState = state; + swiftHeapObjectFinalizationRegistry.register(obj, state, state); + UncachedModel.__identityCache.set(ptr, new WeakRef(obj)); + return obj; + } + + constructor(value) { + const ret = instance.exports.bjs_UncachedModel_init(value); + return UncachedModel.__constructFresh(ret); + } + get value() { + const ret = instance.exports.bjs_UncachedModel_value_get(this.pointer); + return ret; + } + set value(value) { + instance.exports.bjs_UncachedModel_value_set(this.pointer, value); + } + } + class ExplicitlyUncachedModel extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_ExplicitlyUncachedModel_deinit, ExplicitlyUncachedModel.prototype, null); + } + + constructor(count) { + const ret = instance.exports.bjs_ExplicitlyUncachedModel_init(count); + return ExplicitlyUncachedModel.__construct(ret); + } + get count() { + const ret = instance.exports.bjs_ExplicitlyUncachedModel_count_get(this.pointer); + return ret; + } + set count(value) { + instance.exports.bjs_ExplicitlyUncachedModel_count_set(this.pointer, value); + } + } + const exports = { + CachedModel, + UncachedModel, + ExplicitlyUncachedModel, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.d.ts new file mode 100644 index 000000000..e5e2a3a84 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.d.ts @@ -0,0 +1,42 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +/// Represents a Swift heap object like a class instance or an actor instance. +export interface SwiftHeapObject { + /// Release the heap object. + /// + /// Note: Calling this method will release the heap object and it will no longer be accessible. + release(): void; +} +export interface CachedModel extends SwiftHeapObject { + name: string; +} +export interface UncachedModel extends SwiftHeapObject { + value: number; +} +export interface ExplicitlyUncachedModel extends SwiftHeapObject { + count: number; +} +export type Exports = { + CachedModel: { + new(name: string): CachedModel; + } + UncachedModel: { + new(value: number): UncachedModel; + } + ExplicitlyUncachedModel: { + new(count: number): ExplicitlyUncachedModel; + } +} +export type Imports = { +} +export function createInstantiator(options: { + imports: Imports; +}, swift: any): Promise<{ + addImports: (importObject: WebAssembly.Imports) => void; + setInstance: (instance: WebAssembly.Instance) => void; + createExports: (instance: WebAssembly.Instance) => Exports; +}>; \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js new file mode 100644 index 000000000..9025bf986 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js @@ -0,0 +1,350 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +export async function createInstantiator(options, swift) { + let instance; + let memory; + let setException; + let decodeString; + const textDecoder = new TextDecoder("utf-8"); + const textEncoder = new TextEncoder("utf-8"); + let tmpRetString; + let tmpRetBytes; + let tmpRetException; + let tmpRetOptionalBool; + let tmpRetOptionalInt; + let tmpRetOptionalFloat; + let tmpRetOptionalDouble; + let tmpRetOptionalHeapObject; + let strStack = []; + let i32Stack = []; + let i64Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + + return { + /** + * @param {WebAssembly.Imports} importObject + */ + addImports: (importObject, importsContext) => { + bjs = {}; + importObject["bjs"] = bjs; + bjs["swift_js_return_string"] = function(ptr, len) { + tmpRetString = decodeString(ptr, len); + } + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { + const source = swift.memory.getObject(sourceId); + swift.memory.release(sourceId); + const bytes = new Uint8Array(memory.buffer, bytesPtr); + bytes.set(source); + } + bjs["swift_js_make_js_string"] = function(ptr, len) { + return swift.memory.retain(decodeString(ptr, len)); + } + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { + const target = new Uint8Array(memory.buffer, ptr, len); + target.set(tmpRetBytes); + tmpRetBytes = undefined; + } + bjs["swift_js_throw"] = function(id) { + tmpRetException = swift.memory.retainByRef(id); + } + bjs["swift_js_retain"] = function(id) { + return swift.memory.retainByRef(id); + } + bjs["swift_js_release"] = function(id) { + swift.memory.release(id); + } + bjs["swift_js_push_i32"] = function(v) { + i32Stack.push(v | 0); + } + bjs["swift_js_push_f32"] = function(v) { + f32Stack.push(Math.fround(v)); + } + bjs["swift_js_push_f64"] = function(v) { + f64Stack.push(v); + } + bjs["swift_js_push_string"] = function(ptr, len) { + const value = decodeString(ptr, len); + strStack.push(value); + } + bjs["swift_js_pop_i32"] = function() { + return i32Stack.pop(); + } + bjs["swift_js_pop_f32"] = function() { + return f32Stack.pop(); + } + bjs["swift_js_pop_f64"] = function() { + return f64Stack.pop(); + } + bjs["swift_js_push_pointer"] = function(pointer) { + ptrStack.push(pointer); + } + bjs["swift_js_pop_pointer"] = function() { + return ptrStack.pop(); + } + bjs["swift_js_push_i64"] = function(v) { + i64Stack.push(v); + } + bjs["swift_js_pop_i64"] = function() { + return i64Stack.pop(); + } + bjs["swift_js_return_optional_bool"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalBool = null; + } else { + tmpRetOptionalBool = value !== 0; + } + } + bjs["swift_js_return_optional_int"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalInt = null; + } else { + tmpRetOptionalInt = value | 0; + } + } + bjs["swift_js_return_optional_float"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalFloat = null; + } else { + tmpRetOptionalFloat = Math.fround(value); + } + } + bjs["swift_js_return_optional_double"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalDouble = null; + } else { + tmpRetOptionalDouble = value; + } + } + bjs["swift_js_return_optional_string"] = function(isSome, ptr, len) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = decodeString(ptr, len); + } + } + bjs["swift_js_return_optional_object"] = function(isSome, objectId) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = swift.memory.getObject(objectId); + } + } + bjs["swift_js_return_optional_heap_object"] = function(isSome, pointer) { + if (isSome === 0) { + tmpRetOptionalHeapObject = null; + } else { + tmpRetOptionalHeapObject = pointer; + } + } + bjs["swift_js_get_optional_int_presence"] = function() { + return tmpRetOptionalInt != null ? 1 : 0; + } + bjs["swift_js_get_optional_int_value"] = function() { + const value = tmpRetOptionalInt; + tmpRetOptionalInt = undefined; + return value; + } + bjs["swift_js_get_optional_string"] = function() { + const str = tmpRetString; + tmpRetString = undefined; + if (str == null) { + return -1; + } else { + const bytes = textEncoder.encode(str); + tmpRetBytes = bytes; + return bytes.length; + } + } + bjs["swift_js_get_optional_float_presence"] = function() { + return tmpRetOptionalFloat != null ? 1 : 0; + } + bjs["swift_js_get_optional_float_value"] = function() { + const value = tmpRetOptionalFloat; + tmpRetOptionalFloat = undefined; + return value; + } + bjs["swift_js_get_optional_double_presence"] = function() { + return tmpRetOptionalDouble != null ? 1 : 0; + } + bjs["swift_js_get_optional_double_value"] = function() { + const value = tmpRetOptionalDouble; + tmpRetOptionalDouble = undefined; + return value; + } + bjs["swift_js_get_optional_heap_object_pointer"] = function() { + const pointer = tmpRetOptionalHeapObject; + tmpRetOptionalHeapObject = undefined; + return pointer || 0; + } + bjs["swift_js_closure_unregister"] = function(funcRef) {} + // Wrapper functions for module: TestModule + if (!importObject["TestModule"]) { + importObject["TestModule"] = {}; + } + importObject["TestModule"]["bjs_CachedModel_wrap"] = function(pointer) { + const obj = _exports['CachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_ExplicitlyUncachedModel_wrap"] = function(pointer) { + const obj = _exports['ExplicitlyUncachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_UncachedModel_wrap"] = function(pointer) { + const obj = _exports['UncachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + }, + setInstance: (i) => { + instance = i; + memory = instance.exports.memory; + + decodeString = (ptr, len) => { const bytes = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); return textDecoder.decode(bytes); } + + setException = (error) => { + instance.exports._swift_js_exception.value = swift.memory.retain(error) + } + }, + /** @param {WebAssembly.Instance} instance */ + createExports: (instance) => { + const js = swift.memory.heap; + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + + /// Represents a Swift heap object like a class instance or an actor instance. + class SwiftHeapObject { + static __wrap(pointer, deinit, prototype, identityCache) { + const makeFresh = (identityMap) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + swiftHeapObjectFinalizationRegistry.register(obj, state, state); + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!identityCache) { + return makeFresh(null); + } + + const cached = identityCache.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); + return cached; + } + if (identityCache.has(pointer)) { + identityCache.delete(pointer); + } + + return makeFresh(identityCache); + } + + release() { + const state = this.__swiftHeapObjectState; + if (state.hasReleased) { + return; + } + state.hasReleased = true; + swiftHeapObjectFinalizationRegistry.unregister(state); + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + } + } + class CachedModel extends SwiftHeapObject { + static __identityCache = new Map(); + + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_CachedModel_deinit, CachedModel.prototype, CachedModel.__identityCache); + } + + static __constructFresh(ptr) { + const obj = Object.create(CachedModel.prototype); + const state = { pointer: ptr, deinit: instance.exports.bjs_CachedModel_deinit, hasReleased: false, identityMap: CachedModel.__identityCache }; + obj.pointer = ptr; + obj.__swiftHeapObjectState = state; + swiftHeapObjectFinalizationRegistry.register(obj, state, state); + CachedModel.__identityCache.set(ptr, new WeakRef(obj)); + return obj; + } + + constructor(name) { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + const ret = instance.exports.bjs_CachedModel_init(nameId, nameBytes.length); + return CachedModel.__constructFresh(ret); + } + get name() { + instance.exports.bjs_CachedModel_name_get(this.pointer); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + } + set name(value) { + const valueBytes = textEncoder.encode(value); + const valueId = swift.memory.retain(valueBytes); + instance.exports.bjs_CachedModel_name_set(this.pointer, valueId, valueBytes.length); + } + } + class UncachedModel extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_UncachedModel_deinit, UncachedModel.prototype, null); + } + + constructor(value) { + const ret = instance.exports.bjs_UncachedModel_init(value); + return UncachedModel.__construct(ret); + } + get value() { + const ret = instance.exports.bjs_UncachedModel_value_get(this.pointer); + return ret; + } + set value(value) { + instance.exports.bjs_UncachedModel_value_set(this.pointer, value); + } + } + class ExplicitlyUncachedModel extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_ExplicitlyUncachedModel_deinit, ExplicitlyUncachedModel.prototype, null); + } + + constructor(count) { + const ret = instance.exports.bjs_ExplicitlyUncachedModel_init(count); + return ExplicitlyUncachedModel.__construct(ret); + } + get count() { + const ret = instance.exports.bjs_ExplicitlyUncachedModel_count_get(this.pointer); + return ret; + } + set count(value) { + instance.exports.bjs_ExplicitlyUncachedModel_count_set(this.pointer, value); + } + } + const exports = { + CachedModel, + UncachedModel, + ExplicitlyUncachedModel, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.d.ts new file mode 100644 index 000000000..e5e2a3a84 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.d.ts @@ -0,0 +1,42 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +/// Represents a Swift heap object like a class instance or an actor instance. +export interface SwiftHeapObject { + /// Release the heap object. + /// + /// Note: Calling this method will release the heap object and it will no longer be accessible. + release(): void; +} +export interface CachedModel extends SwiftHeapObject { + name: string; +} +export interface UncachedModel extends SwiftHeapObject { + value: number; +} +export interface ExplicitlyUncachedModel extends SwiftHeapObject { + count: number; +} +export type Exports = { + CachedModel: { + new(name: string): CachedModel; + } + UncachedModel: { + new(value: number): UncachedModel; + } + ExplicitlyUncachedModel: { + new(count: number): ExplicitlyUncachedModel; + } +} +export type Imports = { +} +export function createInstantiator(options: { + imports: Imports; +}, swift: any): Promise<{ + addImports: (importObject: WebAssembly.Imports) => void; + setInstance: (instance: WebAssembly.Instance) => void; + createExports: (instance: WebAssembly.Instance) => Exports; +}>; \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js new file mode 100644 index 000000000..9025bf986 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js @@ -0,0 +1,350 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +export async function createInstantiator(options, swift) { + let instance; + let memory; + let setException; + let decodeString; + const textDecoder = new TextDecoder("utf-8"); + const textEncoder = new TextEncoder("utf-8"); + let tmpRetString; + let tmpRetBytes; + let tmpRetException; + let tmpRetOptionalBool; + let tmpRetOptionalInt; + let tmpRetOptionalFloat; + let tmpRetOptionalDouble; + let tmpRetOptionalHeapObject; + let strStack = []; + let i32Stack = []; + let i64Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + + return { + /** + * @param {WebAssembly.Imports} importObject + */ + addImports: (importObject, importsContext) => { + bjs = {}; + importObject["bjs"] = bjs; + bjs["swift_js_return_string"] = function(ptr, len) { + tmpRetString = decodeString(ptr, len); + } + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { + const source = swift.memory.getObject(sourceId); + swift.memory.release(sourceId); + const bytes = new Uint8Array(memory.buffer, bytesPtr); + bytes.set(source); + } + bjs["swift_js_make_js_string"] = function(ptr, len) { + return swift.memory.retain(decodeString(ptr, len)); + } + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { + const target = new Uint8Array(memory.buffer, ptr, len); + target.set(tmpRetBytes); + tmpRetBytes = undefined; + } + bjs["swift_js_throw"] = function(id) { + tmpRetException = swift.memory.retainByRef(id); + } + bjs["swift_js_retain"] = function(id) { + return swift.memory.retainByRef(id); + } + bjs["swift_js_release"] = function(id) { + swift.memory.release(id); + } + bjs["swift_js_push_i32"] = function(v) { + i32Stack.push(v | 0); + } + bjs["swift_js_push_f32"] = function(v) { + f32Stack.push(Math.fround(v)); + } + bjs["swift_js_push_f64"] = function(v) { + f64Stack.push(v); + } + bjs["swift_js_push_string"] = function(ptr, len) { + const value = decodeString(ptr, len); + strStack.push(value); + } + bjs["swift_js_pop_i32"] = function() { + return i32Stack.pop(); + } + bjs["swift_js_pop_f32"] = function() { + return f32Stack.pop(); + } + bjs["swift_js_pop_f64"] = function() { + return f64Stack.pop(); + } + bjs["swift_js_push_pointer"] = function(pointer) { + ptrStack.push(pointer); + } + bjs["swift_js_pop_pointer"] = function() { + return ptrStack.pop(); + } + bjs["swift_js_push_i64"] = function(v) { + i64Stack.push(v); + } + bjs["swift_js_pop_i64"] = function() { + return i64Stack.pop(); + } + bjs["swift_js_return_optional_bool"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalBool = null; + } else { + tmpRetOptionalBool = value !== 0; + } + } + bjs["swift_js_return_optional_int"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalInt = null; + } else { + tmpRetOptionalInt = value | 0; + } + } + bjs["swift_js_return_optional_float"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalFloat = null; + } else { + tmpRetOptionalFloat = Math.fround(value); + } + } + bjs["swift_js_return_optional_double"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalDouble = null; + } else { + tmpRetOptionalDouble = value; + } + } + bjs["swift_js_return_optional_string"] = function(isSome, ptr, len) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = decodeString(ptr, len); + } + } + bjs["swift_js_return_optional_object"] = function(isSome, objectId) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = swift.memory.getObject(objectId); + } + } + bjs["swift_js_return_optional_heap_object"] = function(isSome, pointer) { + if (isSome === 0) { + tmpRetOptionalHeapObject = null; + } else { + tmpRetOptionalHeapObject = pointer; + } + } + bjs["swift_js_get_optional_int_presence"] = function() { + return tmpRetOptionalInt != null ? 1 : 0; + } + bjs["swift_js_get_optional_int_value"] = function() { + const value = tmpRetOptionalInt; + tmpRetOptionalInt = undefined; + return value; + } + bjs["swift_js_get_optional_string"] = function() { + const str = tmpRetString; + tmpRetString = undefined; + if (str == null) { + return -1; + } else { + const bytes = textEncoder.encode(str); + tmpRetBytes = bytes; + return bytes.length; + } + } + bjs["swift_js_get_optional_float_presence"] = function() { + return tmpRetOptionalFloat != null ? 1 : 0; + } + bjs["swift_js_get_optional_float_value"] = function() { + const value = tmpRetOptionalFloat; + tmpRetOptionalFloat = undefined; + return value; + } + bjs["swift_js_get_optional_double_presence"] = function() { + return tmpRetOptionalDouble != null ? 1 : 0; + } + bjs["swift_js_get_optional_double_value"] = function() { + const value = tmpRetOptionalDouble; + tmpRetOptionalDouble = undefined; + return value; + } + bjs["swift_js_get_optional_heap_object_pointer"] = function() { + const pointer = tmpRetOptionalHeapObject; + tmpRetOptionalHeapObject = undefined; + return pointer || 0; + } + bjs["swift_js_closure_unregister"] = function(funcRef) {} + // Wrapper functions for module: TestModule + if (!importObject["TestModule"]) { + importObject["TestModule"] = {}; + } + importObject["TestModule"]["bjs_CachedModel_wrap"] = function(pointer) { + const obj = _exports['CachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_ExplicitlyUncachedModel_wrap"] = function(pointer) { + const obj = _exports['ExplicitlyUncachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_UncachedModel_wrap"] = function(pointer) { + const obj = _exports['UncachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + }, + setInstance: (i) => { + instance = i; + memory = instance.exports.memory; + + decodeString = (ptr, len) => { const bytes = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); return textDecoder.decode(bytes); } + + setException = (error) => { + instance.exports._swift_js_exception.value = swift.memory.retain(error) + } + }, + /** @param {WebAssembly.Instance} instance */ + createExports: (instance) => { + const js = swift.memory.heap; + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + + /// Represents a Swift heap object like a class instance or an actor instance. + class SwiftHeapObject { + static __wrap(pointer, deinit, prototype, identityCache) { + const makeFresh = (identityMap) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + swiftHeapObjectFinalizationRegistry.register(obj, state, state); + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!identityCache) { + return makeFresh(null); + } + + const cached = identityCache.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); + return cached; + } + if (identityCache.has(pointer)) { + identityCache.delete(pointer); + } + + return makeFresh(identityCache); + } + + release() { + const state = this.__swiftHeapObjectState; + if (state.hasReleased) { + return; + } + state.hasReleased = true; + swiftHeapObjectFinalizationRegistry.unregister(state); + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + } + } + class CachedModel extends SwiftHeapObject { + static __identityCache = new Map(); + + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_CachedModel_deinit, CachedModel.prototype, CachedModel.__identityCache); + } + + static __constructFresh(ptr) { + const obj = Object.create(CachedModel.prototype); + const state = { pointer: ptr, deinit: instance.exports.bjs_CachedModel_deinit, hasReleased: false, identityMap: CachedModel.__identityCache }; + obj.pointer = ptr; + obj.__swiftHeapObjectState = state; + swiftHeapObjectFinalizationRegistry.register(obj, state, state); + CachedModel.__identityCache.set(ptr, new WeakRef(obj)); + return obj; + } + + constructor(name) { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + const ret = instance.exports.bjs_CachedModel_init(nameId, nameBytes.length); + return CachedModel.__constructFresh(ret); + } + get name() { + instance.exports.bjs_CachedModel_name_get(this.pointer); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + } + set name(value) { + const valueBytes = textEncoder.encode(value); + const valueId = swift.memory.retain(valueBytes); + instance.exports.bjs_CachedModel_name_set(this.pointer, valueId, valueBytes.length); + } + } + class UncachedModel extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_UncachedModel_deinit, UncachedModel.prototype, null); + } + + constructor(value) { + const ret = instance.exports.bjs_UncachedModel_init(value); + return UncachedModel.__construct(ret); + } + get value() { + const ret = instance.exports.bjs_UncachedModel_value_get(this.pointer); + return ret; + } + set value(value) { + instance.exports.bjs_UncachedModel_value_set(this.pointer, value); + } + } + class ExplicitlyUncachedModel extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_ExplicitlyUncachedModel_deinit, ExplicitlyUncachedModel.prototype, null); + } + + constructor(count) { + const ret = instance.exports.bjs_ExplicitlyUncachedModel_init(count); + return ExplicitlyUncachedModel.__construct(ret); + } + get count() { + const ret = instance.exports.bjs_ExplicitlyUncachedModel_count_get(this.pointer); + return ret; + } + set count(value) { + instance.exports.bjs_ExplicitlyUncachedModel_count_set(this.pointer, value); + } + } + const exports = { + CachedModel, + UncachedModel, + ExplicitlyUncachedModel, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.d.ts index 7b36ca3d8..5d1e2c4dc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.d.ts @@ -12,7 +12,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js index 9971930a4..06cf6550e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.d.ts index a1067c2ef..22b4e6a1c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.d.ts @@ -23,7 +23,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js index 041822b7f..c469fcb58 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createFooContainerHelpers = () => ({ lower: (value) => { let id; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.d.ts index af7e3ab7d..ac0e05a91 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.d.ts @@ -30,7 +30,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js index b49a8922c..952197c2a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.d.ts index 80531f880..aaf227cf7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.d.ts @@ -24,7 +24,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js index 56b7a70e6..88a5adb38 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.d.ts index ab40d43c4..3b2b5de99 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.d.ts @@ -25,7 +25,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js index 03b1a3cb8..10fafb7a0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts index 2b74659a9..f4c13c610 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts @@ -33,7 +33,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js index 1626f7c50..0258b63b6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; function __bjs_jsValueLower(value) { let kind; let payload1; @@ -363,7 +361,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -391,10 +389,8 @@ export async function createInstantiator(options, swift) { } } class JSValueHolder extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_JSValueHolder_deinit, JSValueHolder.prototype, JSValueHolder.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_JSValueHolder_deinit, JSValueHolder.prototype, null); } constructor(value, optionalValue) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts index b093041e7..7b4cc95e6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts @@ -26,7 +26,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js index 4dabe1466..195eef468 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -236,7 +234,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -264,10 +262,8 @@ export async function createInstantiator(options, swift) { } } class GlobalClass extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalAPI_GlobalClass_deinit, GlobalClass.prototype, GlobalClass.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalAPI_GlobalClass_deinit, GlobalClass.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts index c0b6b13bd..88485232e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts @@ -48,7 +48,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js index 35133ca32..ca54493f6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -244,7 +242,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -272,10 +270,8 @@ export async function createInstantiator(options, swift) { } } class GlobalClass extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalAPI_GlobalClass_deinit, GlobalClass.prototype, GlobalClass.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_GlobalAPI_GlobalClass_deinit, GlobalClass.prototype, null); } constructor() { @@ -290,10 +286,8 @@ export async function createInstantiator(options, swift) { } } class PrivateClass extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateAPI_PrivateClass_deinit, PrivateClass.prototype, PrivateClass.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateAPI_PrivateClass_deinit, PrivateClass.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts index 169a25c84..193857072 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts @@ -26,7 +26,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js index 81a878053..3551caab2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -236,7 +234,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -264,10 +262,8 @@ export async function createInstantiator(options, swift) { } } class PrivateClass extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateAPI_PrivateClass_deinit, PrivateClass.prototype, PrivateClass.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PrivateAPI_PrivateClass_deinit, PrivateClass.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts index 242c11285..1353220bc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts @@ -100,7 +100,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js index f18eaf4d5..a63df44be 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -248,7 +246,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -276,10 +274,8 @@ export async function createInstantiator(options, swift) { } } class Greeter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_Greeter_deinit, Greeter.prototype, null); } constructor(name) { @@ -306,10 +302,8 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converters_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converters_Converter_deinit, Converter.prototype, null); } constructor() { @@ -324,10 +318,8 @@ export async function createInstantiator(options, swift) { } } class UUID extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_UUID_deinit, UUID.prototype, UUID.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_UUID_deinit, UUID.prototype, null); } uuidString() { @@ -338,10 +330,8 @@ export async function createInstantiator(options, swift) { } } class Container extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Collections_Container_deinit, Container.prototype, Container.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Collections_Container_deinit, Container.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts index 62a62b273..6b2d65cd8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts @@ -59,7 +59,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js index ef0f69b5e..32a325bda 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -248,7 +246,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -276,10 +274,8 @@ export async function createInstantiator(options, swift) { } } class Greeter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_Greeter_deinit, Greeter.prototype, null); } constructor(name) { @@ -306,10 +302,8 @@ export async function createInstantiator(options, swift) { } } class Converter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converters_Converter_deinit, Converter.prototype, Converter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Utils_Converters_Converter_deinit, Converter.prototype, null); } constructor() { @@ -324,10 +318,8 @@ export async function createInstantiator(options, swift) { } } class UUID extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_UUID_deinit, UUID.prototype, UUID.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs___Swift_Foundation_UUID_deinit, UUID.prototype, null); } uuidString() { @@ -338,10 +330,8 @@ export async function createInstantiator(options, swift) { } } class Container extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Collections_Container_deinit, Container.prototype, Container.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Collections_Container_deinit, Container.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts index 4b2944157..a5a6e16fb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts @@ -75,7 +75,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js index c01c54626..5971c2fa8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -492,7 +490,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -520,10 +518,8 @@ export async function createInstantiator(options, swift) { } } class Greeter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, null); } constructor(name) { @@ -583,10 +579,8 @@ export async function createInstantiator(options, swift) { } } class OptionalPropertyHolder extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_OptionalPropertyHolder_deinit, OptionalPropertyHolder.prototype, OptionalPropertyHolder.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_OptionalPropertyHolder_deinit, OptionalPropertyHolder.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.d.ts index 2adda19be..961f97635 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.d.ts @@ -12,7 +12,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js index abb362ce7..490f2b4e2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.d.ts index b524c9666..77e269d16 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.d.ts @@ -17,7 +17,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js index a2f0d3e4c..bec07b959 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts index f7ffa5b66..8f65849ab 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts @@ -41,7 +41,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js index dc3416dc8..7f840708e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -236,7 +234,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -264,10 +262,8 @@ export async function createInstantiator(options, swift) { } } class PropertyHolder extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyHolder_deinit, PropertyHolder.prototype, PropertyHolder.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyHolder_deinit, PropertyHolder.prototype, null); } constructor(intValue, floatValue, doubleValue, boolValue, stringValue, jsObject) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts index 1a8178c4f..27cd9212b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts @@ -116,7 +116,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js index f0d2a2a06..9fb9b172b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js @@ -54,8 +54,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createResultValuesHelpers = () => ({ lower: (value) => { const enumTag = value.tag; @@ -596,7 +594,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -624,10 +622,8 @@ export async function createInstantiator(options, swift) { } } class Helper extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Helper_deinit, Helper.prototype, Helper.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Helper_deinit, Helper.prototype, null); } constructor(value) { @@ -646,10 +642,8 @@ export async function createInstantiator(options, swift) { } } class MyViewController extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MyViewController_deinit, MyViewController.prototype, MyViewController.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MyViewController_deinit, MyViewController.prototype, null); } constructor(delegate) { @@ -709,10 +703,8 @@ export async function createInstantiator(options, swift) { } } class DelegateManager extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_DelegateManager_deinit, DelegateManager.prototype, DelegateManager.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_DelegateManager_deinit, DelegateManager.prototype, null); } constructor(delegates) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts index 133982a77..6b7a9d28d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts @@ -31,7 +31,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js index 2d98e6115..aefdb5679 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.unregistered) { return; } instance?.exports?.bjs_release_swift_closure(state.pointer); @@ -382,7 +380,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -410,10 +408,8 @@ export async function createInstantiator(options, swift) { } } class Widget extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Widget_deinit, Widget.prototype, Widget.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Widget_deinit, Widget.prototype, null); } constructor(name) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts index 6d1f908f8..5916e1648 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts @@ -70,7 +70,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js index 2bdc3596a..ef685b8a4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js @@ -41,8 +41,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createAPIResultValuesHelpers = () => ({ lower: (value) => { const enumTag = value.tag; @@ -280,7 +278,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -308,10 +306,8 @@ export async function createInstantiator(options, swift) { } } class MathUtils extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MathUtils_deinit, MathUtils.prototype, MathUtils.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MathUtils_deinit, MathUtils.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts index a49010973..c9cb26910 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts @@ -60,7 +60,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js index d497f84f0..1fd066076 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js @@ -41,8 +41,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createAPIResultValuesHelpers = () => ({ lower: (value) => { const enumTag = value.tag; @@ -280,7 +278,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -308,10 +306,8 @@ export async function createInstantiator(options, swift) { } } class MathUtils extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MathUtils_deinit, MathUtils.prototype, MathUtils.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_MathUtils_deinit, MathUtils.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.d.ts index 336f5589d..fea3c4b59 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.d.ts @@ -65,7 +65,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js index d1090525d..5800fcb56 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js @@ -35,8 +35,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -241,7 +239,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -269,10 +267,8 @@ export async function createInstantiator(options, swift) { } } class PropertyClass extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyClass_deinit, PropertyClass.prototype, PropertyClass.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyClass_deinit, PropertyClass.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts index 2972749cf..4ce689edb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts @@ -51,7 +51,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js index 81e15106d..b81255810 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js @@ -35,8 +35,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -241,7 +239,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -269,10 +267,8 @@ export async function createInstantiator(options, swift) { } } class PropertyClass extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyClass_deinit, PropertyClass.prototype, PropertyClass.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PropertyClass_deinit, PropertyClass.prototype, null); } constructor() { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.d.ts index 8e3a8f98f..5e45162a1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.d.ts @@ -14,7 +14,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js index 239206e95..033f08cd2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.d.ts index 98ed8ce88..b43ff062c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.d.ts @@ -12,7 +12,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js index 2f8d3dd22..8187b9e92 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts index a450bf30f..6d590950c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts @@ -40,7 +40,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js index 47b6bc560..9ee57d692 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** @@ -264,7 +262,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -292,10 +290,8 @@ export async function createInstantiator(options, swift) { } } class Greeter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, null); } constructor(name) { @@ -350,18 +346,14 @@ export async function createInstantiator(options, swift) { } } class PublicGreeter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PublicGreeter_deinit, PublicGreeter.prototype, PublicGreeter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PublicGreeter_deinit, PublicGreeter.prototype, null); } } class PackageGreeter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PackageGreeter_deinit, PackageGreeter.prototype, PackageGreeter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PackageGreeter_deinit, PackageGreeter.prototype, null); } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts index 73635c41d..ccc95eb3b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts @@ -97,7 +97,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index 7020ab4ec..03a5504e4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -60,8 +60,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.unregistered) { return; } instance?.exports?.bjs_release_swift_closure(state.pointer); @@ -923,7 +921,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -951,10 +949,8 @@ export async function createInstantiator(options, swift) { } } class Person extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Person_deinit, Person.prototype, Person.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Person_deinit, Person.prototype, null); } constructor(name) { @@ -965,10 +961,8 @@ export async function createInstantiator(options, swift) { } } class TestProcessor extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_TestProcessor_deinit, TestProcessor.prototype, TestProcessor.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_TestProcessor_deinit, TestProcessor.prototype, null); } constructor(transform) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts index f08b5ac48..ebf493910 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts @@ -12,7 +12,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js index 2724a6322..d9df868ec 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.unregistered) { return; } instance?.exports?.bjs_release_swift_closure(state.pointer); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts index 0880baf02..bf4ebc71f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts @@ -86,7 +86,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js index 525093444..abfb24d48 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js @@ -35,8 +35,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createDataPointHelpers = () => ({ lower: (value) => { f64Stack.push(value.x); @@ -505,7 +503,7 @@ export async function createInstantiator(options, swift) { return obj; }; - if (!shouldUseIdentityMap) { + if (!identityCache) { return makeFresh(null); } @@ -533,10 +531,8 @@ export async function createInstantiator(options, swift) { } } class Greeter extends SwiftHeapObject { - static __identityCache = new Map(); - static __construct(ptr) { - return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, Greeter.__identityCache); + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, null); } constructor(name) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.d.ts index cc963fe97..3677f1e44 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.d.ts @@ -15,7 +15,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js index 092a49f9b..d4f1160f3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointHelpers = () => ({ lower: (value) => { i32Stack.push((value.x | 0)); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.d.ts index 1b9223753..9199ad1ae 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.d.ts @@ -11,7 +11,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js index 5b07dae16..b2c381a03 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts index ac1c9b771..4f9aa4e4a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts @@ -31,7 +31,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js index 181cc29a9..ef81ef69e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; const __bjs_createPointerFieldsHelpers = () => ({ lower: (value) => { ptrStack.push((value.raw | 0)); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.d.ts index 63276ca35..7acba67a0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.d.ts @@ -12,7 +12,6 @@ export type Imports = { } export function createInstantiator(options: { imports: Imports; - identityMode?: "none" | "pointer"; }, swift: any): Promise<{ addImports: (importObject: WebAssembly.Imports) => void; setInstance: (instance: WebAssembly.Instance) => void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js index 901732e48..97948b286 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js @@ -30,8 +30,6 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; - const identityMode = options.identityMode ?? "none"; - const shouldUseIdentityMap = identityMode === "pointer" && typeof WeakRef !== "undefined" && typeof FinalizationRegistry !== "undefined"; return { /** diff --git a/Plugins/PackageToJS/Templates/index.d.ts b/Plugins/PackageToJS/Templates/index.d.ts index 780d30845..f3491b4e3 100644 --- a/Plugins/PackageToJS/Templates/index.d.ts +++ b/Plugins/PackageToJS/Templates/index.d.ts @@ -15,12 +15,6 @@ export type Options = { */ getImports: () => Imports; /* #endif */ - /** - * Controls whether exported Swift class instances use pointer-based identity mapping. - * When set to "pointer", the same Swift heap pointer will always return the same JS wrapper object. - * Defaults to "none". - */ - identityMode?: "none" | "pointer"; }; /** diff --git a/Plugins/PackageToJS/Templates/index.js b/Plugins/PackageToJS/Templates/index.js index 1e0db0f53..7cde8edc9 100644 --- a/Plugins/PackageToJS/Templates/index.js +++ b/Plugins/PackageToJS/Templates/index.js @@ -9,18 +9,14 @@ import { defaultBrowserSetup /* #if USE_SHARED_MEMORY */, createDefaultWorkerFac /* #if TARGET_DEFAULT_PLATFORM_NODE */ /** @type {import('./index.d').init} */ async function initNode(_options) { - const { identityMode: _identityMode, ...rest } = _options || {}; /** @type {import('./platforms/node.d.ts').DefaultNodeSetupOptions} */ const options = { - ...rest, + ...(_options || {}), /* #if USE_SHARED_MEMORY */ spawnWorker: createDefaultWorkerFactoryForNode(), /* #endif */ }; const instantiateOptions = await defaultNodeSetup(options); - if (_options?.identityMode) { - instantiateOptions.identityMode = _options.identityMode; - } return await instantiate(instantiateOptions); } @@ -48,9 +44,6 @@ async function initBrowser(_options) { spawnWorker: createDefaultWorkerFactoryForBrowser() /* #endif */ }) - if (options?.identityMode) { - instantiateOptions.identityMode = options.identityMode; - } return await instantiate(instantiateOptions); } diff --git a/Plugins/PackageToJS/Templates/instantiate.d.ts b/Plugins/PackageToJS/Templates/instantiate.d.ts index 0caf328dc..8f6170beb 100644 --- a/Plugins/PackageToJS/Templates/instantiate.d.ts +++ b/Plugins/PackageToJS/Templates/instantiate.d.ts @@ -130,11 +130,6 @@ export type InstantiateOptions = { } ) => WebAssembly.Instance - /** - * Controls whether exported Swift class instances use pointer-based identity mapping. - * When set to "pointer", the same Swift heap pointer will always return the same JS wrapper object. - */ - identityMode?: "none" | "pointer" } /** diff --git a/Sources/JavaScriptKit/Macros.swift b/Sources/JavaScriptKit/Macros.swift index 67b3488bf..3189cdeab 100644 --- a/Sources/JavaScriptKit/Macros.swift +++ b/Sources/JavaScriptKit/Macros.swift @@ -113,7 +113,8 @@ public enum JSImportFrom: String { /// /// - Important: This feature is still experimental. No API stability is guaranteed, and the API may change in future releases. @attached(peer) -public macro JS(namespace: String? = nil, enumStyle: JSEnumStyle = .const) = Builtin.ExternalMacro +public macro JS(namespace: String? = nil, enumStyle: JSEnumStyle = .const, identityMode: Bool = false) = + Builtin.ExternalMacro /// A macro that generates a Swift getter that reads a value from JavaScript. /// diff --git a/Tests/JavaScriptEventLoopTests/JSClosure+AsyncTests.swift b/Tests/JavaScriptEventLoopTests/JSClosure+AsyncTests.swift index db093e549..164ad6727 100644 --- a/Tests/JavaScriptEventLoopTests/JSClosure+AsyncTests.swift +++ b/Tests/JavaScriptEventLoopTests/JSClosure+AsyncTests.swift @@ -62,49 +62,48 @@ class JSClosureAsyncTests: XCTestCase { // - Make JSObject a final-class // - Unify JSFunction and JSObject into JSValue // - Make JS(Oneshot)Closure as a wrapper of JSObject, not a subclass - /* - func testAsyncOneshotClosure() async throws { - let closure = JSOneshotClosure.async { _ in - return (42.0).jsValue - }.jsValue - let result = try await JSPromise( - from: closure.function!() - )!.value() - XCTAssertEqual(result, 42.0) - } - - func testAsyncOneshotClosureWithPriority() async throws { - let priority = UnsafeSendableBox(nil) - let closure = JSOneshotClosure.async(priority: .high) { _ in - priority.value = Task.currentPriority - return (42.0).jsValue - }.jsValue - let result = try await JSPromise(from: closure.function!())!.value() - XCTAssertEqual(result, 42.0) - XCTAssertEqual(priority.value, .high) - } - - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - func testAsyncOneshotClosureWithTaskExecutor() async throws { - let executor = AnyTaskExecutor() - let closure = JSOneshotClosure.async(executorPreference: executor) { _ in - return (42.0).jsValue - }.jsValue - let result = try await JSPromise(from: closure.function!())!.value() - XCTAssertEqual(result, 42.0) - } - - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - func testAsyncOneshotClosureWithTaskExecutorPreference() async throws { - let executor = AnyTaskExecutor() - let priority = UnsafeSendableBox(nil) - let closure = JSOneshotClosure.async(executorPreference: executor, priority: .high) { _ in - priority.value = Task.currentPriority - return (42.0).jsValue - }.jsValue - let result = try await JSPromise(from: closure.function!())!.value() - XCTAssertEqual(result, 42.0) - XCTAssertEqual(priority.value, .high) - } - */ + // + // func testAsyncOneshotClosure() async throws { + // let closure = JSOneshotClosure.async { _ in + // return (42.0).jsValue + // }.jsValue + // let result = try await JSPromise( + // from: closure.function!() + // )!.value() + // XCTAssertEqual(result, 42.0) + // } + // + // func testAsyncOneshotClosureWithPriority() async throws { + // let priority = UnsafeSendableBox(nil) + // let closure = JSOneshotClosure.async(priority: .high) { _ in + // priority.value = Task.currentPriority + // return (42.0).jsValue + // }.jsValue + // let result = try await JSPromise(from: closure.function!())!.value() + // XCTAssertEqual(result, 42.0) + // XCTAssertEqual(priority.value, .high) + // } + // + // @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) + // func testAsyncOneshotClosureWithTaskExecutor() async throws { + // let executor = AnyTaskExecutor() + // let closure = JSOneshotClosure.async(executorPreference: executor) { _ in + // return (42.0).jsValue + // }.jsValue + // let result = try await JSPromise(from: closure.function!())!.value() + // XCTAssertEqual(result, 42.0) + // } + // + // @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) + // func testAsyncOneshotClosureWithTaskExecutorPreference() async throws { + // let executor = AnyTaskExecutor() + // let priority = UnsafeSendableBox(nil) + // let closure = JSOneshotClosure.async(executorPreference: executor, priority: .high) { _ in + // priority.value = Task.currentPriority + // return (42.0).jsValue + // }.jsValue + // let result = try await JSPromise(from: closure.function!())!.value() + // XCTAssertEqual(result, 42.0) + // XCTAssertEqual(priority.value, .high) + // } } From d7e34a506fb6e041cf37243364a902dec7e44b0d Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Wed, 22 Apr 2026 14:28:02 +0200 Subject: [PATCH 14/18] feat: add opt-in "swift" identity mode with Swift-owned strong cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduces a third value for @JS(identityMode:): .swift, alongside the existing .none (default) and .pointer (weak JS-side cache shipped in main). With .swift mode, Swift owns the wrapper lifetime via per-class tables: var __identityTable: [UnsafeMutableRawPointer: Int32] // ptr → id var __idToPointer: [Int32: UnsafeMutableRawPointer] // id → ptr var __wrapperRefs: [Int32] // id → JS ref var __freeIds: [Int32] var __nextId: Int32 On return, Swift looks up the pointer; on miss it retains, allocates an id, and pushes (id, freshBit) on the existing i32 stack. JS pops the pair, and either returns cache[id] (hit) or builds a wrapper and calls back via bjs__register_wrapper to install the retained JS ref. Release is driven by an explicit bjs__release_wrapper(id) export. The miss-heavy regression of .pointer mode (FinalizationRegistry.register + new WeakRef + Map.set account for 88% of miss cost per Phase 0 profiling) is addressed: .swift mode keeps no WeakRef, no FinalizationRegistry, no per-miss Map.set — just a dense array indexed by Swift-assigned id. Per-class opt-in via @JS(identityMode: .swift); project-wide default via "identityMode": "swift" in bridge-js.config.json. A JSIdentityMode enum replaces the legacy identityMode: Bool macro parameter; true/false literals are still accepted at parse time for backward compatibility. Changes: - New JSIdentityMode enum + macro parameter migration (Bool → enum) - Skeleton.identityMode: Bool? → String?, with per-class and config-default resolution threaded through ExportSwift and BridgeJSLink - New Wasm intrinsic _swift_js_release_ref - ExportSwift emits per-class tables + register/release thunks + bridgeJSStackPush override for array-element returns - BridgeJSLink emits a standalone SwiftIdentityHeapObject template (no SwiftHeapObject inheritance, no FinalizationRegistry, no WeakRef) with a use-after-release guard on every instance member - New BridgeJSSwiftIdentityTests target for config-default opt-in E2E coverage; extends BridgeJSIdentityTests with per-class opt-in scenarios - *SwiftIdentity benchmark variants + three-mode harness in identity-benchmarks.js - DocC article Identity-Modes-For-Exported-Classes.md; cross-references from Exporting-Swift-Class.md, Exporting-Swift-to-JavaScript.md, BridgeJS-Configuration.md --- Benchmarks/Package.swift | 4 +- Benchmarks/Sources/Benchmarks.swift | 65 +- Benchmarks/Sources/Generated/BridgeJS.swift | 595 ++++++++++++++++ .../Generated/JavaScript/BridgeJS.json | 285 +++++++- Benchmarks/lib/identity-benchmarks.js | 20 +- Package.swift | 20 +- .../Sources/BridgeJSCore/ExportSwift.swift | 185 ++++- .../BridgeJS/Sources/BridgeJSCore/Misc.swift | 23 +- .../BridgeJSCore/SwiftToSkeleton.swift | 13 +- .../Sources/BridgeJSLink/BridgeJSLink.swift | 242 +++++-- .../BridgeJSSkeleton/BridgeJSSkeleton.swift | 6 +- .../BridgeJSToolTests/BridgeJSLinkTests.swift | 69 +- .../MacroSwift/IdentityModeSwiftClass.swift | 18 + .../IdentityModeClass.json | 4 +- .../IdentityModeSwiftClass.json | 148 ++++ .../IdentityModeSwiftClass.swift | 277 ++++++++ .../IdentityModeClass.ConfigSwift.d.ts | 42 ++ .../IdentityModeClass.ConfigSwift.js | 381 ++++++++++ .../IdentityModeSwiftClass.d.ts | 42 ++ .../IdentityModeSwiftClass.js | 381 ++++++++++ .../JavaScriptKit/BridgeJSIntrinsics.swift | 16 + .../BridgeJS/BridgeJS-Configuration.md | 20 + .../BridgeJS/Exporting-Swift-to-JavaScript.md | 1 + .../Exporting-Swift/Exporting-Swift-Class.md | 4 + .../Identity-Modes-For-Exported-Classes.md | 107 +++ Sources/JavaScriptKit/JSIdentityMode.swift | 13 + Sources/JavaScriptKit/Macros.swift | 2 +- .../Generated/BridgeJS.swift | 651 +++++++++++++++++ .../Generated/JavaScript/BridgeJS.json | 377 ++++++++++ .../IdentityModeTests.swift | 114 +++ .../JavaScript/IdentityModeTests.mjs | 325 +++++++++ .../SwiftIdentityIntrinsicsTests.swift | 17 + .../Generated/BridgeJS.swift | 667 ++++++++++++++++++ .../Generated/JavaScript/BridgeJS.json | 415 +++++++++++ .../JavaScript/SwiftIdentityModeTests.mjs | 263 +++++++ .../SwiftIdentityModeTests.swift | 116 +++ .../bridge-js.config.json | 3 + Tests/prelude.mjs | 2 + Utilities/bridge-js-generate.sh | 1 + 39 files changed, 5852 insertions(+), 82 deletions(-) create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/IdentityModeSwiftClass.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js create mode 100644 Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Identity-Modes-For-Exported-Classes.md create mode 100644 Sources/JavaScriptKit/JSIdentityMode.swift create mode 100644 Tests/BridgeJSIdentityTests/SwiftIdentityIntrinsicsTests.swift create mode 100644 Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift create mode 100644 Tests/BridgeJSSwiftIdentityTests/Generated/JavaScript/BridgeJS.json create mode 100644 Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs create mode 100644 Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift create mode 100644 Tests/BridgeJSSwiftIdentityTests/bridge-js.config.json diff --git a/Benchmarks/Package.swift b/Benchmarks/Package.swift index 751e239e6..496d60d00 100644 --- a/Benchmarks/Package.swift +++ b/Benchmarks/Package.swift @@ -12,13 +12,13 @@ let package = Package( .macCatalyst(.v13), ], dependencies: [ - .package(path: "../") + .package(name: "JavaScriptKit", path: "../") ], targets: [ .executableTarget( name: "Benchmarks", dependencies: [ - "JavaScriptKit", + .product(name: "JavaScriptKit", package: "JavaScriptKit"), .product(name: "JavaScriptFoundationCompat", package: "JavaScriptKit"), ], exclude: ["Generated/JavaScript", "bridge-js.d.ts"], diff --git a/Benchmarks/Sources/Benchmarks.swift b/Benchmarks/Sources/Benchmarks.swift index 3e24e597b..124ca7481 100644 --- a/Benchmarks/Sources/Benchmarks.swift +++ b/Benchmarks/Sources/Benchmarks.swift @@ -305,11 +305,11 @@ nonisolated(unsafe) var _cachedPool: [SimpleClass] = [] } } -// MARK: - Identity Mode Benchmark Variants -// These classes use @JS(identityMode: true) so that identity cache benchmarks +// MARK: - Identity Mode Benchmark Variants (pointer mode) +// These classes use @JS(identityMode: .pointer) so that identity cache benchmarks // can run in the SAME build alongside the non-identity classes above. -@JS(identityMode: true) +@JS(identityMode: .pointer) class SimpleClassIdentity { @JS var name: String @JS var count: Int @@ -326,7 +326,7 @@ class SimpleClassIdentity { } } -@JS(identityMode: true) +@JS(identityMode: .pointer) class ClassRoundtripIdentity { @JS init() {} @@ -345,7 +345,7 @@ class ClassRoundtripIdentity { nonisolated(unsafe) var _cachedPoolIdentity: [SimpleClassIdentity] = [] -@JS(identityMode: true) +@JS(identityMode: .pointer) class IdentityCacheBenchmarkIdentity { @JS init() {} @@ -360,6 +360,61 @@ class IdentityCacheBenchmarkIdentity { } } +// MARK: - Identity Mode Benchmark Variants (swift-owned cache) +// Parallel set using @JS(identityMode: .swift) so the third mode can run +// in the same build alongside the other two. + +@JS(identityMode: .swift) +class SimpleClassSwiftIdentity { + @JS var name: String + @JS var count: Int + @JS var flag: Bool + @JS var rate: Float + @JS var precise: Double + + @JS init(name: String, count: Int, flag: Bool, rate: Float, precise: Double) { + self.name = name + self.count = count + self.flag = flag + self.rate = rate + self.precise = precise + } +} + +@JS(identityMode: .swift) +class ClassRoundtripSwiftIdentity { + @JS init() {} + + @JS func roundtripSimpleClassSwiftIdentity(_ obj: SimpleClassSwiftIdentity) -> SimpleClassSwiftIdentity { + return obj + } + + @JS func makeSimpleClassSwiftIdentity() -> SimpleClassSwiftIdentity { + return SimpleClassSwiftIdentity(name: "Hello", count: 42, flag: true, rate: 0.5, precise: 3.14159) + } + + @JS func takeSimpleClassSwiftIdentity(_ obj: SimpleClassSwiftIdentity) { + // consume without returning + } +} + +nonisolated(unsafe) var _cachedPoolSwiftIdentity: [SimpleClassSwiftIdentity] = [] + +@JS(identityMode: .swift) +class IdentityCacheBenchmarkSwiftIdentity { + @JS init() {} + + @JS func setupPool(_ count: Int) { + _cachedPoolSwiftIdentity = (0.. [SimpleClassSwiftIdentity] { + return _cachedPoolSwiftIdentity + } +} + // MARK: - Array Performance Tests @JS struct Point { diff --git a/Benchmarks/Sources/Generated/BridgeJS.swift b/Benchmarks/Sources/Generated/BridgeJS.swift index e199e4a29..99b20581e 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.swift @@ -1815,6 +1815,601 @@ fileprivate func _bjs_IdentityCacheBenchmarkIdentity_wrap_extern(_ pointer: Unsa return _bjs_IdentityCacheBenchmarkIdentity_wrap_extern(pointer) } +nonisolated(unsafe) var _SimpleClassSwiftIdentity_identityTable: [UnsafeMutableRawPointer: Int32] = [:] + +nonisolated(unsafe) var _SimpleClassSwiftIdentity_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] + +nonisolated(unsafe) var _SimpleClassSwiftIdentity_wrapperRefs: [Int32] = [] + +nonisolated(unsafe) var _SimpleClassSwiftIdentity_freeIds: [Int32] = [] + +nonisolated(unsafe) var _SimpleClassSwiftIdentity_nextId: Int32 = 0 + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_init") +@_cdecl("bjs_SimpleClassSwiftIdentity_init") +public func _bjs_SimpleClassSwiftIdentity_init(_ nameBytes: Int32, _ nameLength: Int32, _ count: Int32, _ flag: Int32, _ rate: Float32, _ precise: Float64) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = SimpleClassSwiftIdentity(name: String.bridgeJSLiftParameter(nameBytes, nameLength), count: Int.bridgeJSLiftParameter(count), flag: Bool.bridgeJSLiftParameter(flag), rate: Float.bridgeJSLiftParameter(rate), precise: Double.bridgeJSLiftParameter(precise)) + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _SimpleClassSwiftIdentity_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _SimpleClassSwiftIdentity_freeIds.popLast() { + id = recycled + } else { + id = _SimpleClassSwiftIdentity_nextId + _SimpleClassSwiftIdentity_nextId += 1 + _SimpleClassSwiftIdentity_wrapperRefs.append(0) + } + _SimpleClassSwiftIdentity_identityTable[ptr] = id + _SimpleClassSwiftIdentity_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_name_get") +@_cdecl("bjs_SimpleClassSwiftIdentity_name_get") +public func _bjs_SimpleClassSwiftIdentity_name_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SimpleClassSwiftIdentity.bridgeJSLiftParameter(_self).name + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_name_set") +@_cdecl("bjs_SimpleClassSwiftIdentity_name_set") +public func _bjs_SimpleClassSwiftIdentity_name_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + SimpleClassSwiftIdentity.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_count_get") +@_cdecl("bjs_SimpleClassSwiftIdentity_count_get") +public func _bjs_SimpleClassSwiftIdentity_count_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SimpleClassSwiftIdentity.bridgeJSLiftParameter(_self).count + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_count_set") +@_cdecl("bjs_SimpleClassSwiftIdentity_count_set") +public func _bjs_SimpleClassSwiftIdentity_count_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + SimpleClassSwiftIdentity.bridgeJSLiftParameter(_self).count = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_flag_get") +@_cdecl("bjs_SimpleClassSwiftIdentity_flag_get") +public func _bjs_SimpleClassSwiftIdentity_flag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SimpleClassSwiftIdentity.bridgeJSLiftParameter(_self).flag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_flag_set") +@_cdecl("bjs_SimpleClassSwiftIdentity_flag_set") +public func _bjs_SimpleClassSwiftIdentity_flag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + SimpleClassSwiftIdentity.bridgeJSLiftParameter(_self).flag = Bool.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_rate_get") +@_cdecl("bjs_SimpleClassSwiftIdentity_rate_get") +public func _bjs_SimpleClassSwiftIdentity_rate_get(_ _self: UnsafeMutableRawPointer) -> Float32 { + #if arch(wasm32) + let ret = SimpleClassSwiftIdentity.bridgeJSLiftParameter(_self).rate + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_rate_set") +@_cdecl("bjs_SimpleClassSwiftIdentity_rate_set") +public func _bjs_SimpleClassSwiftIdentity_rate_set(_ _self: UnsafeMutableRawPointer, _ value: Float32) -> Void { + #if arch(wasm32) + SimpleClassSwiftIdentity.bridgeJSLiftParameter(_self).rate = Float.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_precise_get") +@_cdecl("bjs_SimpleClassSwiftIdentity_precise_get") +public func _bjs_SimpleClassSwiftIdentity_precise_get(_ _self: UnsafeMutableRawPointer) -> Float64 { + #if arch(wasm32) + let ret = SimpleClassSwiftIdentity.bridgeJSLiftParameter(_self).precise + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_precise_set") +@_cdecl("bjs_SimpleClassSwiftIdentity_precise_set") +public func _bjs_SimpleClassSwiftIdentity_precise_set(_ _self: UnsafeMutableRawPointer, _ value: Float64) -> Void { + #if arch(wasm32) + SimpleClassSwiftIdentity.bridgeJSLiftParameter(_self).precise = Double.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_deinit") +@_cdecl("bjs_SimpleClassSwiftIdentity_deinit") +public func _bjs_SimpleClassSwiftIdentity_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_register_wrapper") +@_cdecl("bjs_SimpleClassSwiftIdentity_register_wrapper") +public func _bjs_SimpleClassSwiftIdentity_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { + #if arch(wasm32) + _SimpleClassSwiftIdentity_wrapperRefs[Int(id)] = jsRef + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SimpleClassSwiftIdentity_release_wrapper") +@_cdecl("bjs_SimpleClassSwiftIdentity_release_wrapper") +public func _bjs_SimpleClassSwiftIdentity_release_wrapper(_ id: Int32) -> Void { + #if arch(wasm32) + let slot = Int(id) + let jsRef = _SimpleClassSwiftIdentity_wrapperRefs[slot] + guard jsRef != 0 else { return } + _SimpleClassSwiftIdentity_wrapperRefs[slot] = 0 + if let ptr = _SimpleClassSwiftIdentity_idToPointer.removeValue(forKey: id) { + _SimpleClassSwiftIdentity_identityTable.removeValue(forKey: ptr) + Unmanaged.fromOpaque(ptr).release() + } + _SimpleClassSwiftIdentity_freeIds.append(id) + _swift_js_release_ref(jsRef) + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension SimpleClassSwiftIdentity { + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if let id = _SimpleClassSwiftIdentity_identityTable[ptr] { + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(self) + let id: Int32 + if let recycled = _SimpleClassSwiftIdentity_freeIds.popLast() { + id = recycled + } else { + id = _SimpleClassSwiftIdentity_nextId + _SimpleClassSwiftIdentity_nextId += 1 + _SimpleClassSwiftIdentity_wrapperRefs.append(0) + } + _SimpleClassSwiftIdentity_identityTable[ptr] = id + _SimpleClassSwiftIdentity_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + _swift_js_push_pointer(ptr) + } +} + +extension SimpleClassSwiftIdentity: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_SimpleClassSwiftIdentity_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_SimpleClassSwiftIdentity_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_SimpleClassSwiftIdentity_wrap") +fileprivate func _bjs_SimpleClassSwiftIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_SimpleClassSwiftIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_SimpleClassSwiftIdentity_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_SimpleClassSwiftIdentity_wrap_extern(pointer) +} + +nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_identityTable: [UnsafeMutableRawPointer: Int32] = [:] + +nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] + +nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_wrapperRefs: [Int32] = [] + +nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_freeIds: [Int32] = [] + +nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_nextId: Int32 = 0 + +@_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_init") +@_cdecl("bjs_ClassRoundtripSwiftIdentity_init") +public func _bjs_ClassRoundtripSwiftIdentity_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ClassRoundtripSwiftIdentity() + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _ClassRoundtripSwiftIdentity_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _ClassRoundtripSwiftIdentity_freeIds.popLast() { + id = recycled + } else { + id = _ClassRoundtripSwiftIdentity_nextId + _ClassRoundtripSwiftIdentity_nextId += 1 + _ClassRoundtripSwiftIdentity_wrapperRefs.append(0) + } + _ClassRoundtripSwiftIdentity_identityTable[ptr] = id + _ClassRoundtripSwiftIdentity_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_roundtripSimpleClassSwiftIdentity") +@_cdecl("bjs_ClassRoundtripSwiftIdentity_roundtripSimpleClassSwiftIdentity") +public func _bjs_ClassRoundtripSwiftIdentity_roundtripSimpleClassSwiftIdentity(_ _self: UnsafeMutableRawPointer, _ obj: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ClassRoundtripSwiftIdentity.bridgeJSLiftParameter(_self).roundtripSimpleClassSwiftIdentity(_: SimpleClassSwiftIdentity.bridgeJSLiftParameter(obj)) + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _SimpleClassSwiftIdentity_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _SimpleClassSwiftIdentity_freeIds.popLast() { + id = recycled + } else { + id = _SimpleClassSwiftIdentity_nextId + _SimpleClassSwiftIdentity_nextId += 1 + _SimpleClassSwiftIdentity_wrapperRefs.append(0) + } + _SimpleClassSwiftIdentity_identityTable[ptr] = id + _SimpleClassSwiftIdentity_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_makeSimpleClassSwiftIdentity") +@_cdecl("bjs_ClassRoundtripSwiftIdentity_makeSimpleClassSwiftIdentity") +public func _bjs_ClassRoundtripSwiftIdentity_makeSimpleClassSwiftIdentity(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ClassRoundtripSwiftIdentity.bridgeJSLiftParameter(_self).makeSimpleClassSwiftIdentity() + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _SimpleClassSwiftIdentity_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _SimpleClassSwiftIdentity_freeIds.popLast() { + id = recycled + } else { + id = _SimpleClassSwiftIdentity_nextId + _SimpleClassSwiftIdentity_nextId += 1 + _SimpleClassSwiftIdentity_wrapperRefs.append(0) + } + _SimpleClassSwiftIdentity_identityTable[ptr] = id + _SimpleClassSwiftIdentity_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_takeSimpleClassSwiftIdentity") +@_cdecl("bjs_ClassRoundtripSwiftIdentity_takeSimpleClassSwiftIdentity") +public func _bjs_ClassRoundtripSwiftIdentity_takeSimpleClassSwiftIdentity(_ _self: UnsafeMutableRawPointer, _ obj: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + ClassRoundtripSwiftIdentity.bridgeJSLiftParameter(_self).takeSimpleClassSwiftIdentity(_: SimpleClassSwiftIdentity.bridgeJSLiftParameter(obj)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_deinit") +@_cdecl("bjs_ClassRoundtripSwiftIdentity_deinit") +public func _bjs_ClassRoundtripSwiftIdentity_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_register_wrapper") +@_cdecl("bjs_ClassRoundtripSwiftIdentity_register_wrapper") +public func _bjs_ClassRoundtripSwiftIdentity_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { + #if arch(wasm32) + _ClassRoundtripSwiftIdentity_wrapperRefs[Int(id)] = jsRef + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_release_wrapper") +@_cdecl("bjs_ClassRoundtripSwiftIdentity_release_wrapper") +public func _bjs_ClassRoundtripSwiftIdentity_release_wrapper(_ id: Int32) -> Void { + #if arch(wasm32) + let slot = Int(id) + let jsRef = _ClassRoundtripSwiftIdentity_wrapperRefs[slot] + guard jsRef != 0 else { return } + _ClassRoundtripSwiftIdentity_wrapperRefs[slot] = 0 + if let ptr = _ClassRoundtripSwiftIdentity_idToPointer.removeValue(forKey: id) { + _ClassRoundtripSwiftIdentity_identityTable.removeValue(forKey: ptr) + Unmanaged.fromOpaque(ptr).release() + } + _ClassRoundtripSwiftIdentity_freeIds.append(id) + _swift_js_release_ref(jsRef) + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ClassRoundtripSwiftIdentity { + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if let id = _ClassRoundtripSwiftIdentity_identityTable[ptr] { + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(self) + let id: Int32 + if let recycled = _ClassRoundtripSwiftIdentity_freeIds.popLast() { + id = recycled + } else { + id = _ClassRoundtripSwiftIdentity_nextId + _ClassRoundtripSwiftIdentity_nextId += 1 + _ClassRoundtripSwiftIdentity_wrapperRefs.append(0) + } + _ClassRoundtripSwiftIdentity_identityTable[ptr] = id + _ClassRoundtripSwiftIdentity_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + _swift_js_push_pointer(ptr) + } +} + +extension ClassRoundtripSwiftIdentity: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ClassRoundtripSwiftIdentity_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ClassRoundtripSwiftIdentity_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_ClassRoundtripSwiftIdentity_wrap") +fileprivate func _bjs_ClassRoundtripSwiftIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ClassRoundtripSwiftIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ClassRoundtripSwiftIdentity_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ClassRoundtripSwiftIdentity_wrap_extern(pointer) +} + +nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_identityTable: [UnsafeMutableRawPointer: Int32] = [:] + +nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] + +nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs: [Int32] = [] + +nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_freeIds: [Int32] = [] + +nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_nextId: Int32 = 0 + +@_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_init") +@_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_init") +public func _bjs_IdentityCacheBenchmarkSwiftIdentity_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = IdentityCacheBenchmarkSwiftIdentity() + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _IdentityCacheBenchmarkSwiftIdentity_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _IdentityCacheBenchmarkSwiftIdentity_freeIds.popLast() { + id = recycled + } else { + id = _IdentityCacheBenchmarkSwiftIdentity_nextId + _IdentityCacheBenchmarkSwiftIdentity_nextId += 1 + _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs.append(0) + } + _IdentityCacheBenchmarkSwiftIdentity_identityTable[ptr] = id + _IdentityCacheBenchmarkSwiftIdentity_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_setupPool") +@_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_setupPool") +public func _bjs_IdentityCacheBenchmarkSwiftIdentity_setupPool(_ _self: UnsafeMutableRawPointer, _ count: Int32) -> Void { + #if arch(wasm32) + IdentityCacheBenchmarkSwiftIdentity.bridgeJSLiftParameter(_self).setupPool(_: Int.bridgeJSLiftParameter(count)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_getPoolRepeated") +@_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_getPoolRepeated") +public func _bjs_IdentityCacheBenchmarkSwiftIdentity_getPoolRepeated(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = IdentityCacheBenchmarkSwiftIdentity.bridgeJSLiftParameter(_self).getPoolRepeated() + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_deinit") +@_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_deinit") +public func _bjs_IdentityCacheBenchmarkSwiftIdentity_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_register_wrapper") +@_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_register_wrapper") +public func _bjs_IdentityCacheBenchmarkSwiftIdentity_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { + #if arch(wasm32) + _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs[Int(id)] = jsRef + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_release_wrapper") +@_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_release_wrapper") +public func _bjs_IdentityCacheBenchmarkSwiftIdentity_release_wrapper(_ id: Int32) -> Void { + #if arch(wasm32) + let slot = Int(id) + let jsRef = _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs[slot] + guard jsRef != 0 else { return } + _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs[slot] = 0 + if let ptr = _IdentityCacheBenchmarkSwiftIdentity_idToPointer.removeValue(forKey: id) { + _IdentityCacheBenchmarkSwiftIdentity_identityTable.removeValue(forKey: ptr) + Unmanaged.fromOpaque(ptr).release() + } + _IdentityCacheBenchmarkSwiftIdentity_freeIds.append(id) + _swift_js_release_ref(jsRef) + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension IdentityCacheBenchmarkSwiftIdentity { + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if let id = _IdentityCacheBenchmarkSwiftIdentity_identityTable[ptr] { + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(self) + let id: Int32 + if let recycled = _IdentityCacheBenchmarkSwiftIdentity_freeIds.popLast() { + id = recycled + } else { + id = _IdentityCacheBenchmarkSwiftIdentity_nextId + _IdentityCacheBenchmarkSwiftIdentity_nextId += 1 + _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs.append(0) + } + _IdentityCacheBenchmarkSwiftIdentity_identityTable[ptr] = id + _IdentityCacheBenchmarkSwiftIdentity_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + _swift_js_push_pointer(ptr) + } +} + +extension IdentityCacheBenchmarkSwiftIdentity: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_IdentityCacheBenchmarkSwiftIdentity_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_IdentityCacheBenchmarkSwiftIdentity_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "Benchmarks", name: "bjs_IdentityCacheBenchmarkSwiftIdentity_wrap") +fileprivate func _bjs_IdentityCacheBenchmarkSwiftIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_IdentityCacheBenchmarkSwiftIdentity_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_IdentityCacheBenchmarkSwiftIdentity_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_IdentityCacheBenchmarkSwiftIdentity_wrap_extern(pointer) +} + @_expose(wasm, "bjs_ArrayRoundtrip_init") @_cdecl("bjs_ArrayRoundtrip_init") public func _bjs_ArrayRoundtrip_init() -> UnsafeMutableRawPointer { diff --git a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json index 0bddddfb6..8f89c720f 100644 --- a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json +++ b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json @@ -1550,7 +1550,7 @@ } ] }, - "identityMode" : true, + "identityMode" : "pointer", "methods" : [ ], @@ -1624,7 +1624,7 @@ ] }, - "identityMode" : true, + "identityMode" : "pointer", "methods" : [ { "abiName" : "bjs_ClassRoundtripIdentity_roundtripSimpleClassIdentity", @@ -1712,7 +1712,7 @@ ] }, - "identityMode" : true, + "identityMode" : "pointer", "methods" : [ { "abiName" : "bjs_IdentityCacheBenchmarkIdentity_setupPool", @@ -1770,6 +1770,285 @@ ], "swiftCallName" : "IdentityCacheBenchmarkIdentity" }, + { + "constructor" : { + "abiName" : "bjs_SimpleClassSwiftIdentity_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "label" : "count", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "flag", + "name" : "flag", + "type" : { + "bool" : { + + } + } + }, + { + "label" : "rate", + "name" : "rate", + "type" : { + "float" : { + + } + } + }, + { + "label" : "precise", + "name" : "precise", + "type" : { + "double" : { + + } + } + } + ] + }, + "identityMode" : "swift", + "methods" : [ + + ], + "name" : "SimpleClassSwiftIdentity", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "flag", + "type" : { + "bool" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "rate", + "type" : { + "float" : { + + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "precise", + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "SimpleClassSwiftIdentity" + }, + { + "constructor" : { + "abiName" : "bjs_ClassRoundtripSwiftIdentity_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "identityMode" : "swift", + "methods" : [ + { + "abiName" : "bjs_ClassRoundtripSwiftIdentity_roundtripSimpleClassSwiftIdentity", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripSimpleClassSwiftIdentity", + "parameters" : [ + { + "label" : "_", + "name" : "obj", + "type" : { + "swiftHeapObject" : { + "_0" : "SimpleClassSwiftIdentity" + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "SimpleClassSwiftIdentity" + } + } + }, + { + "abiName" : "bjs_ClassRoundtripSwiftIdentity_makeSimpleClassSwiftIdentity", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeSimpleClassSwiftIdentity", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "SimpleClassSwiftIdentity" + } + } + }, + { + "abiName" : "bjs_ClassRoundtripSwiftIdentity_takeSimpleClassSwiftIdentity", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "takeSimpleClassSwiftIdentity", + "parameters" : [ + { + "label" : "_", + "name" : "obj", + "type" : { + "swiftHeapObject" : { + "_0" : "SimpleClassSwiftIdentity" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "ClassRoundtripSwiftIdentity", + "properties" : [ + + ], + "swiftCallName" : "ClassRoundtripSwiftIdentity" + }, + { + "constructor" : { + "abiName" : "bjs_IdentityCacheBenchmarkSwiftIdentity_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "identityMode" : "swift", + "methods" : [ + { + "abiName" : "bjs_IdentityCacheBenchmarkSwiftIdentity_setupPool", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "setupPool", + "parameters" : [ + { + "label" : "_", + "name" : "count", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_IdentityCacheBenchmarkSwiftIdentity_getPoolRepeated", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getPoolRepeated", + "parameters" : [ + + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "SimpleClassSwiftIdentity" + } + } + } + } + } + ], + "name" : "IdentityCacheBenchmarkSwiftIdentity", + "properties" : [ + + ], + "swiftCallName" : "IdentityCacheBenchmarkSwiftIdentity" + }, { "constructor" : { "abiName" : "bjs_ArrayRoundtrip_init", diff --git a/Benchmarks/lib/identity-benchmarks.js b/Benchmarks/lib/identity-benchmarks.js index f83eb9c1d..b193332c5 100644 --- a/Benchmarks/lib/identity-benchmarks.js +++ b/Benchmarks/lib/identity-benchmarks.js @@ -22,20 +22,22 @@ function formatBytes(bytes) { /** * Parse the --identity-mode CLI argument into mode labels. * - * Both class variants (with and without identity mode) are compiled into the - * same WASM build via per-class `@JS(identityMode: true)` annotations, so - * "both" mode works in a single run. + * Class variants for all three modes are compiled into the same WASM build + * via per-class `@JS(identityMode: .pointer)` and `@JS(identityMode: .swift)` + * annotations, so `both` and `both3` work in a single run. * - * @param {string} modeArg - Mode argument: off, none, pointer, or both + * @param {string} modeArg - Mode argument: off, none, pointer, swift, both (none+pointer), or both3 (none+pointer+swift) * @returns {string[]} Array of mode labels, or empty for "off" */ function parseIdentityModes(modeArg) { if (!modeArg || modeArg === 'off') return [] if (modeArg === 'none') return ['none'] if (modeArg === 'pointer') return ['pointer'] + if (modeArg === 'swift') return ['swift'] if (modeArg === 'both') return ['none', 'pointer'] + if (modeArg === 'both3') return ['none', 'pointer', 'swift'] console.error( - `Invalid --identity-mode value: ${modeArg}. Expected off, none, pointer, or both.` + `Invalid --identity-mode value: ${modeArg}. Expected off, none, pointer, swift, both, or both3.` ) process.exit(1) } @@ -153,6 +155,14 @@ async function runIdentityModeBenchmarks(results, nameFilter, identityConfig, be roundtrip = (obj) => classRoundtrip.roundtripSimpleClassIdentity(obj) makeSimple = () => classRoundtrip.makeSimpleClassIdentity() takeSimple = (obj) => classRoundtrip.takeSimpleClassIdentity(obj) + } else if (mode === 'swift') { + classRoundtrip = new exports.ClassRoundtripSwiftIdentity() + baseObject = new exports.SimpleClassSwiftIdentity('Hello', 42, true, 0.5, 3.14159) + SimpleClassCtor = exports.SimpleClassSwiftIdentity + IdentityCacheCtor = exports.IdentityCacheBenchmarkSwiftIdentity + roundtrip = (obj) => classRoundtrip.roundtripSimpleClassSwiftIdentity(obj) + makeSimple = () => classRoundtrip.makeSimpleClassSwiftIdentity() + takeSimple = (obj) => classRoundtrip.takeSimpleClassSwiftIdentity(obj) } else { classRoundtrip = new exports.ClassRoundtrip() baseObject = new exports.SimpleClass('Hello', 42, true, 0.5, 3.14159) diff --git a/Package.swift b/Package.swift index 3d0f1e943..c5576be44 100644 --- a/Package.swift +++ b/Package.swift @@ -225,7 +225,25 @@ let package = Package( "Generated/JavaScript", ], swiftSettings: [ - .enableExperimentalFeature("Extern") + .enableExperimentalFeature("Extern"), + // Exposes gated `@JS func getSwift*ForChurn() -> Int` helpers + // that let Task-5 id-recycling tests read `__nextId`. + // Do NOT export these in non-test builds. + .define("ENABLE_TEST_INTROSPECTION"), + ], + linkerSettings: testingLinkerFlags + ), + .testTarget( + name: "BridgeJSSwiftIdentityTests", + dependencies: ["JavaScriptKit", "JavaScriptEventLoop"], + exclude: [ + "bridge-js.config.json", + "Generated/JavaScript", + ], + swiftSettings: [ + .enableExperimentalFeature("Extern"), + // Same id-recycling introspection knob as BridgeJSIdentityTests. + .define("ENABLE_TEST_INTROSPECTION"), ], linkerSettings: testingLinkerFlags ), diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index b649b244d..257e90d87 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -31,6 +31,28 @@ public class ExportSwift { self.skeleton = skeleton } + /// Resolves whether a class is configured for `identityMode: "swift"`. + /// + /// Per-class `@JS(identityMode:)` takes priority over the skeleton-wide + /// default from `bridge-js.config.json`. Matches the resolution order in + /// `BridgeJSLink.shouldUseIdentityCache` but checks for the `"swift"` value + /// rather than `"pointer"`. + /// + /// Looks up by either the `name` or `swiftCallName` of an exported class — + /// the return-type's `.swiftHeapObject(String)` payload can be either + /// depending on how the type was referenced. + func isSwiftIdentityMode(_ className: String) -> Bool { + guard + let klass = skeleton.classes.first(where: { + $0.name == className || $0.swiftCallName == className + }) + else { + return false + } + let resolved = klass.identityMode ?? skeleton.identityMode + return resolved == "swift" + } + /// Finalizes the export process and generates the bridge code /// /// - Parameters: @@ -103,9 +125,15 @@ public class ExportSwift { var abiReturnType: WasmCoreType? var externDecls: [DeclSyntax] = [] let effects: Effects + /// Predicate that resolves whether a class-name corresponds to an + /// `identityMode: "swift"` class. Default: always false. Threaded + /// through from `ExportSwift.isSwiftIdentityMode(_:)` at construction + /// time so return-lowering can emit the per-class cache glue. + let isSwiftIdentityMode: (String) -> Bool - init(effects: Effects) { + init(effects: Effects, isSwiftIdentityMode: @escaping (String) -> Bool = { _ in false }) { self.effects = effects + self.isSwiftIdentityMode = isSwiftIdentityMode } private func append(_ item: CodeBlockItemSyntax) { @@ -323,6 +351,41 @@ public class ExportSwift { } """ ) + case .swiftHeapObject(let className) where isSwiftIdentityMode(className): + // identityMode: "swift" — Swift owns the wrapper lifetime and + // the authoritative pointer→id table. On hit, skip the + // passRetained; on miss, retain once and reserve a wrapper + // slot. JS pops (id, freshBit) from the i32 stack after the + // return pointer and either returns the cached wrapper or + // builds a fresh one and calls back via + // `bjs__register_wrapper` to install the strong JS ref. + append( + """ + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _\(raw: className)_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _\(raw: className)_freeIds.popLast() { + id = recycled + } else { + id = _\(raw: className)_nextId + _\(raw: className)_nextId += 1 + _\(raw: className)_wrapperRefs.append(0) + } + _\(raw: className)_identityTable[ptr] = id + _\(raw: className)_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + """ + ) default: append("return ret.bridgeJSLowerReturn()") } @@ -457,7 +520,10 @@ public class ExportSwift { let className = context.className let isStatic = context.isStatic - let getterBuilder = ExportedThunkBuilder(effects: Effects(isAsync: false, isThrows: false, isStatic: isStatic)) + let getterBuilder = ExportedThunkBuilder( + effects: Effects(isAsync: false, isThrows: false, isStatic: isStatic), + isSwiftIdentityMode: isSwiftIdentityMode + ) if !isStatic { try getterBuilder.liftParameter( @@ -477,7 +543,8 @@ public class ExportSwift { // Generate property setter if not readonly if !property.isReadonly { let setterBuilder = ExportedThunkBuilder( - effects: Effects(isAsync: false, isThrows: false, isStatic: isStatic) + effects: Effects(isAsync: false, isThrows: false, isStatic: isStatic), + isSwiftIdentityMode: isSwiftIdentityMode ) // Lift parameters based on property type @@ -507,7 +574,7 @@ public class ExportSwift { } func renderSingleExportedFunction(function: ExportedFunction) throws -> DeclSyntax { - let builder = ExportedThunkBuilder(effects: function.effects) + let builder = ExportedThunkBuilder(effects: function.effects, isSwiftIdentityMode: isSwiftIdentityMode) for param in function.parameters { try builder.liftParameter(param: param) } @@ -536,7 +603,7 @@ public class ExportSwift { callName: String, returnType: BridgeType ) throws -> DeclSyntax { - let builder = ExportedThunkBuilder(effects: constructor.effects) + let builder = ExportedThunkBuilder(effects: constructor.effects, isSwiftIdentityMode: isSwiftIdentityMode) for param in constructor.parameters { try builder.liftParameter(param: param) } @@ -550,7 +617,7 @@ public class ExportSwift { ownerTypeName: String, instanceSelfType: BridgeType ) throws -> DeclSyntax { - let builder = ExportedThunkBuilder(effects: method.effects) + let builder = ExportedThunkBuilder(effects: method.effects, isSwiftIdentityMode: isSwiftIdentityMode) if !method.effects.isStatic { try builder.liftParameter(param: Parameter(label: nil, name: "_self", type: instanceSelfType)) } @@ -652,6 +719,28 @@ public class ExportSwift { func renderSingleExportedClass(klass: ExportedClass) throws -> [DeclSyntax] { var decls: [DeclSyntax] = [] + // identityMode: "swift" — emit the per-class Swift-owned identity cache + // state (pointer→id forward map, id→pointer reverse map for O(1) + // release, dense wrapper-ref array, free-id stack, monotonic counter). + // See Docs/superpowers/specs/2026-04-21-swift-side-identity-cache-design.md §5.1. + if isSwiftIdentityMode(klass.name) { + decls.append( + "nonisolated(unsafe) var _\(raw: klass.name)_identityTable: [UnsafeMutableRawPointer: Int32] = [:]" + ) + decls.append( + "nonisolated(unsafe) var _\(raw: klass.name)_idToPointer: [Int32: UnsafeMutableRawPointer] = [:]" + ) + decls.append( + "nonisolated(unsafe) var _\(raw: klass.name)_wrapperRefs: [Int32] = []" + ) + decls.append( + "nonisolated(unsafe) var _\(raw: klass.name)_freeIds: [Int32] = []" + ) + decls.append( + "nonisolated(unsafe) var _\(raw: klass.name)_nextId: Int32 = 0" + ) + } + if let constructor = klass.constructor { decls.append( try renderSingleExportedConstructor( @@ -691,6 +780,90 @@ public class ExportSwift { decls.append(DeclSyntax(funcDecl)) } + // identityMode: "swift" — emit the register/release thunks that pair + // with the JS-side fresh-wrapper handshake. See spec §5.3 and §5.4. + // Per D8.3, release uses the reverse dictionary (O(1) drop). + if isSwiftIdentityMode(klass.name) { + do { + let registerDecl = SwiftCodePattern.buildExposedFunctionDecl( + abiName: "bjs_\(klass.abiName)_register_wrapper", + signature: SwiftSignatureBuilder.buildABIFunctionSignature( + abiParameters: [("id", .i32), ("jsRef", .i32)], + returnType: nil + ) + ) { printer in + printer.write("_\(klass.name)_wrapperRefs[Int(id)] = jsRef") + } + decls.append(DeclSyntax(registerDecl)) + } + + do { + let releaseDecl = SwiftCodePattern.buildExposedFunctionDecl( + abiName: "bjs_\(klass.abiName)_release_wrapper", + signature: SwiftSignatureBuilder.buildABIFunctionSignature( + abiParameters: [("id", .i32)], + returnType: nil + ) + ) { printer in + printer.write("let slot = Int(id)") + printer.write("let jsRef = _\(klass.name)_wrapperRefs[slot]") + printer.write("guard jsRef != 0 else { return }") + printer.write("_\(klass.name)_wrapperRefs[slot] = 0") + printer.write("if let ptr = _\(klass.name)_idToPointer.removeValue(forKey: id) {") + printer.write(" _\(klass.name)_identityTable.removeValue(forKey: ptr)") + printer.write(" Unmanaged<\(klass.swiftCallName)>.fromOpaque(ptr).release()") + printer.write("}") + printer.write("_\(klass.name)_freeIds.append(id)") + printer.write("_swift_js_release_ref(jsRef)") + } + decls.append(DeclSyntax(releaseDecl)) + } + + // Override the default `_BridgedSwiftHeapObject.bridgeJSStackPush` so + // array-element returns (`[SwiftCached]`) go through the same + // identity-cache handshake as scalar returns. + // + // See DECISIONS.md D15. The default in BridgeJSIntrinsics.swift just + // calls `_swift_js_push_pointer(Unmanaged.passRetained(self).toOpaque())` + // — that bypasses `__identityTable` and leaves JS's `__wrap` + // popping garbage instead of `(id, freshBit)`. + // + // Push order: `(id, freshBit)` on the i32 stack first, then the + // pointer on the pointer stack. JS pops in reverse (pointer, then + // freshBit, then id), matching how the codegen-emitted `__wrap` + // already reads them. + let stackPushExt: DeclSyntax = """ + extension \(raw: klass.swiftCallName) { + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if let id = _\(raw: klass.name)_identityTable[ptr] { + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(self) + let id: Int32 + if let recycled = _\(raw: klass.name)_freeIds.popLast() { + id = recycled + } else { + id = _\(raw: klass.name)_nextId + _\(raw: klass.name)_nextId += 1 + _\(raw: klass.name)_wrapperRefs.append(0) + } + _\(raw: klass.name)_identityTable[ptr] = id + _\(raw: klass.name)_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + _swift_js_push_pointer(ptr) + } + } + """ + decls.append(stackPushExt) + } + // Generate ConvertibleToJSValue extension decls.append(contentsOf: renderConvertibleToJSValueExtension(klass: klass)) diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift index 37040d7a6..a246fdc92 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift @@ -344,9 +344,14 @@ public struct BridgeJSConfig: Codable { /// The identity mode to use for exported Swift heap objects. /// - /// When `"pointer"`, Swift heap objects are tracked by pointer identity, - /// enabling identity-based caching. When `"none"` or `nil`, no identity - /// tracking is performed. + /// Valid values: `"none"` | `"pointer"` | `"swift"`. + /// + /// - `"none"` (or `nil`): No identity tracking. Each boundary crossing produces a fresh JS wrapper. + /// - `"pointer"`: JS-side identity cache keyed by the Swift pointer (weak refs + `FinalizationRegistry`). + /// - `"swift"`: Swift-side identity cache (opt-in; strong retention of the JS wrapper for the + /// lifetime of the Swift heap object). See spec §3. + /// + /// A per-class `@JS(identityMode: ...)` annotation overrides this default. /// /// Default: `nil` (treated as `"none"`) public var identityMode: String? @@ -368,8 +373,20 @@ public struct BridgeJSConfig: Codable { tools = try container.decodeIfPresent([String: String].self, forKey: .tools) exposeToGlobal = try container.decodeIfPresent(Bool.self, forKey: .exposeToGlobal) ?? false identityMode = try container.decodeIfPresent(String.self, forKey: .identityMode) + if let mode = identityMode, !BridgeJSConfig.validIdentityModes.contains(mode) { + throw DecodingError.dataCorruptedError( + forKey: .identityMode, + in: container, + debugDescription: + "Invalid identityMode \"\(mode)\". Expected one of: \(BridgeJSConfig.validIdentityModes.sorted().map { "\"\($0)\"" }.joined(separator: ", "))." + ) + } } + /// The set of accepted values for the top-level `identityMode` config field. + /// Keep in sync with `JSIdentityMode` in `Sources/JavaScriptKit/JSIdentityMode.swift`. + static let validIdentityModes: Set = ["none", "pointer", "swift"] + /// Load the configuration file from the SwiftPM package target directory. /// /// Files are loaded **in this order** and merged (later files override earlier ones): diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index 3d8f417e3..715029142 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -1197,12 +1197,21 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { return nil } - private func extractIdentityMode(from jsAttribute: AttributeSyntax) -> Bool? { + private func extractIdentityMode(from jsAttribute: AttributeSyntax) -> String? { guard let arguments = jsAttribute.arguments?.as(LabeledExprListSyntax.self), let identityArg = arguments.first(where: { $0.label?.text == "identityMode" }) else { return nil } let text = identityArg.expression.trimmedDescription - return text == "true" + // Enum member-access form (current `JSIdentityMode` API). + if text.contains(".swift") { return "swift" } + if text.contains(".pointer") { return "pointer" } + if text.contains(".none") { return "none" } + // Legacy Bool literals (pre-D8.1 spelling — map for forward compatibility + // during the transition; the macro itself no longer accepts these, but + // fixtures and third-party sources may still spell it this way.) + if text == "true" { return "pointer" } + if text == "false" { return "none" } + return nil } override func visit(_ node: InitializerDeclSyntax) -> SyntaxVisitorContinueKind { diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index db83d3987..312479e63 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -25,19 +25,49 @@ public struct BridgeJSLink { self.sharedMemory = sharedMemory } - /// The identity mode from the config file, resolved from skeletons. - var configIdentityMode: String { - skeletons.compactMap(\.exported).compactMap(\.identityMode).first ?? "none" + /// The identity mode config default that applies to a given class. + /// + /// Each `BridgeJSSkeleton` corresponds to one module (one `bridge-js.config.json`). + /// When several modules are linked together (e.g. multiple test targets in one + /// `swift test` invocation), their config defaults MUST NOT bleed across module + /// boundaries: `BridgeJSSwiftIdentityTests`' `"swift"` config default must apply + /// only to its own classes, never to classes in `BridgeJSRuntimeTests` or any + /// other module. + /// + /// We locate the owning skeleton by class identity (name + optional namespace) + /// and return its `exported.identityMode` directly. Fall-through default is + /// `"none"` — matching the pre-change baseline for unconfigured modules. + private func configIdentityMode(for klass: ExportedClass) -> String { + for unified in skeletons { + guard let exported = unified.exported else { continue } + if exported.classes.contains(where: { $0.name == klass.name && $0.namespace == klass.namespace }) { + return exported.identityMode ?? "none" + } + } + return "none" } - /// Whether a class should use identity caching based on its annotation and the config default. + /// Whether a class should use the JS-side pointer identity cache. + /// + /// Resolution order: per-class annotation beats config default. `"swift"` is + /// a *distinct* mode handled by a separate codegen path (see + /// `shouldUseSwiftIdentityCache`) and must NOT trigger the pointer-cache path + /// here — we return `false` for it so the `"pointer"`/`"none"` output remains + /// byte-identical to the pre-change baseline. private func shouldUseIdentityCache(for klass: ExportedClass) -> Bool { - // Per-class annotation takes priority - if let classOverride = klass.identityMode { - return classOverride - } - // Fall back to config default - return configIdentityMode == "pointer" + let resolved = klass.identityMode ?? configIdentityMode(for: klass) + return resolved == "pointer" + } + + /// Whether a class should use the Swift-owned identity cache (dense-array fast path). + /// + /// Resolution order mirrors `shouldUseIdentityCache`: per-class annotation wins over + /// config default. Returns `true` only when the resolved value is `"swift"`, in which + /// case `renderExportedClass` emits the standalone `SwiftIdentityHeapObject`-style + /// template (no `SwiftHeapObject` inheritance, no `FinalizationRegistry`, no `WeakRef`). + private func shouldUseSwiftIdentityCache(for klass: ExportedClass) -> Bool { + let resolved = klass.identityMode ?? configIdentityMode(for: klass) + return resolved == "swift" } mutating func addSkeletonFile(data: Data) throws { @@ -178,13 +208,31 @@ public struct BridgeJSLink { private func collectLinkData() throws -> LinkData { var data = LinkData() - // Swift heap object class definitions - if skeletons.contains(where: { $0.exported?.classes.isEmpty == false }) { + // Swift heap object class definitions. + // + // The JS-side `SwiftHeapObject` base class is only needed for classes that actually + // extend it (the `.none` and `.pointer` identity modes). `.swift`-mode classes are + // standalone and bring their own dense-array fast path, so if the module only has + // `.swift` classes (or no classes at all), we skip emitting `swiftHeapObjectClassJs`. + // + // The `.d.ts` output is kept byte-identical to the pre-change baseline (spec §6.4): + // `SwiftHeapObject` is still declared whenever the module has any class, because + // `.swift`-mode classes still render `extends SwiftHeapObject` in their interface. + let hasAnyPointerOrNoneClass = skeletons.contains { unified in + guard let exported = unified.exported else { return false } + return exported.classes.contains { klass in + !shouldUseSwiftIdentityCache(for: klass) + } + } + let hasAnyClass = skeletons.contains(where: { $0.exported?.classes.isEmpty == false }) + if hasAnyPointerOrNoneClass { data.classLines.append( contentsOf: swiftHeapObjectClassJs.split(separator: "\n", omittingEmptySubsequences: false).map { String($0) } ) + } + if hasAnyClass { data.dtsClassLines.append( contentsOf: swiftHeapObjectClassDts.split(separator: "\n", omittingEmptySubsequences: false).map { String($0) @@ -1998,48 +2046,111 @@ extension BridgeJSLink { let dtsTypePrinter = CodeFragmentPrinter() let dtsExportEntryPrinter = CodeFragmentPrinter() + // Per-class identity mode: determine at codegen time which cache strategy to emit. + // - `.pointer` → JS-owned WeakRef/FinalizationRegistry cache keyed by pointer. + // - `.swift` → Swift-owned dense-array cache keyed by id (Task 4, spec §6.2). + // - `.none` → no caching (pre-change baseline). + let useIdentity = shouldUseIdentityCache(for: klass) + let useSwiftIdentity = shouldUseSwiftIdentityCache(for: klass) + + // `.d.ts` output is kept byte-identical across all three modes (spec §6.4): the + // `.swift`-mode class still satisfies the `SwiftHeapObject` interface (it has a + // `release()` method), so the interface declaration stays the same. dtsTypePrinter.write("export interface \(klass.name) extends SwiftHeapObject {") dtsExportEntryPrinter.write("\(klass.name): {") - jsPrinter.write("class \(klass.name) extends SwiftHeapObject {") - // Per-class identity mode: determine at codegen time whether this class uses identity caching - let useIdentity = shouldUseIdentityCache(for: klass) - jsPrinter.indent { - if useIdentity { - jsPrinter.write("static __identityCache = new Map();") + if useSwiftIdentity { + // Spec §6.2: a `.swift`-mode class is STANDALONE — it does NOT extend + // `SwiftHeapObject`. It owns its own dense-array wrapper cache and lifetime + // (no `FinalizationRegistry`, no `WeakRef`). Swift holds wrappers strongly + // via `__wrapperRefs`; JS clears the slot on `release()`. + jsPrinter.write("class \(klass.name) {") + jsPrinter.indent { + jsPrinter.write("static __swiftIdentityWrappers = [];") + jsPrinter.nextLine() + jsPrinter.write("static __wrap(pointer) {") + jsPrinter.indent { + // Swift pushes (id, freshBit) to the i32 stack AFTER returning the + // pointer; JS pops LIFO — freshBit first, id second. + jsPrinter.write("const freshBit = bjs.swift_js_pop_i32();") + jsPrinter.write("const id = bjs.swift_js_pop_i32();") + jsPrinter.write("if (freshBit === 0) {") + jsPrinter.indent { + jsPrinter.write("return \(klass.name).__swiftIdentityWrappers[id];") + } + jsPrinter.write("}") + jsPrinter.write("const obj = Object.create(\(klass.name).prototype);") + jsPrinter.write("obj.pointer = pointer;") + jsPrinter.write("obj.__swiftIdentityId = id;") + jsPrinter.write("obj.__swiftIdentityHasReleased = false;") + jsPrinter.write("\(klass.name).__swiftIdentityWrappers[id] = obj;") + // Retain the wrapper in swift.memory so Swift can hold it strongly + // via `__wrapperRefs[id]` until release_wrapper fires. + jsPrinter.write("const jsRef = swift.memory.retain(obj);") + jsPrinter.write("instance.exports.bjs_\(klass.abiName)_register_wrapper(id, jsRef);") + jsPrinter.write("return obj;") + } + jsPrinter.write("}") jsPrinter.nextLine() + jsPrinter.write("static __construct(pointer) {") + jsPrinter.indent { + // Swift's `_init` export pushed (id, freshBit) itself. `__wrap` + // pops them and returns either the cached wrapper or a fresh one. + jsPrinter.write("return \(klass.name).__wrap(pointer);") + } + jsPrinter.write("}") + jsPrinter.nextLine() + jsPrinter.write("release() {") + jsPrinter.indent { + jsPrinter.write("if (this.__swiftIdentityHasReleased) return;") + jsPrinter.write("this.__swiftIdentityHasReleased = true;") + jsPrinter.write("const id = this.__swiftIdentityId;") + jsPrinter.write("instance.exports.bjs_\(klass.abiName)_release_wrapper(id);") + // Swift's release_wrapper already called `_swift_js_release_ref(jsRef)`, + // so we just clear our JS-side slot so the id can be recycled. + jsPrinter.write("\(klass.name).__swiftIdentityWrappers[id] = undefined;") + } + jsPrinter.write("}") } - jsPrinter.write("static __construct(ptr) {") + } else { + jsPrinter.write("class \(klass.name) extends SwiftHeapObject {") jsPrinter.indent { if useIdentity { - jsPrinter.write( - "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_\(klass.abiName)_deinit, \(klass.name).prototype, \(klass.name).__identityCache);" - ) - } else { - jsPrinter.write( - "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_\(klass.abiName)_deinit, \(klass.name).prototype, null);" - ) + jsPrinter.write("static __identityCache = new Map();") + jsPrinter.nextLine() } - } - jsPrinter.write("}") - jsPrinter.nextLine() - // __constructFresh skips the identity cache lookup for newly created objects. - // Since the pointer is brand new, it cannot already be in the cache. - if useIdentity { - jsPrinter.write("static __constructFresh(ptr) {") + jsPrinter.write("static __construct(ptr) {") jsPrinter.indent { - jsPrinter.write("const obj = Object.create(\(klass.name).prototype);") - jsPrinter.write( - "const state = { pointer: ptr, deinit: instance.exports.bjs_\(klass.abiName)_deinit, hasReleased: false, identityMap: \(klass.name).__identityCache };" - ) - jsPrinter.write("obj.pointer = ptr;") - jsPrinter.write("obj.__swiftHeapObjectState = state;") - jsPrinter.write("swiftHeapObjectFinalizationRegistry.register(obj, state, state);") - jsPrinter.write("\(klass.name).__identityCache.set(ptr, new WeakRef(obj));") - jsPrinter.write("return obj;") + if useIdentity { + jsPrinter.write( + "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_\(klass.abiName)_deinit, \(klass.name).prototype, \(klass.name).__identityCache);" + ) + } else { + jsPrinter.write( + "return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_\(klass.abiName)_deinit, \(klass.name).prototype, null);" + ) + } } jsPrinter.write("}") jsPrinter.nextLine() + // __constructFresh skips the identity cache lookup for newly created objects. + // Since the pointer is brand new, it cannot already be in the cache. + if useIdentity { + jsPrinter.write("static __constructFresh(ptr) {") + jsPrinter.indent { + jsPrinter.write("const obj = Object.create(\(klass.name).prototype);") + jsPrinter.write( + "const state = { pointer: ptr, deinit: instance.exports.bjs_\(klass.abiName)_deinit, hasReleased: false, identityMap: \(klass.name).__identityCache };" + ) + jsPrinter.write("obj.pointer = ptr;") + jsPrinter.write("obj.__swiftHeapObjectState = state;") + jsPrinter.write("swiftHeapObjectFinalizationRegistry.register(obj, state, state);") + jsPrinter.write("\(klass.name).__identityCache.set(ptr, new WeakRef(obj));") + jsPrinter.write("return obj;") + } + jsPrinter.write("}") + jsPrinter.nextLine() + } } } @@ -2057,10 +2168,16 @@ extension BridgeJSLink { jsPrinter.indent { jsPrinter.write("constructor(\(constructorParamList)) {") let returnExpr = thunkBuilder.callConstructor(abiName: constructor.abiName) - let constructCall = - useIdentity - ? "\(klass.name).__constructFresh(\(returnExpr))" - : "\(klass.name).__construct(\(returnExpr))" + let constructCall: String + if useSwiftIdentity { + // `.swift` mode: the init export itself pushed (id, freshBit). + // `__wrap` pops them and deduplicates. + constructCall = "\(klass.name).__wrap(\(returnExpr))" + } else if useIdentity { + constructCall = "\(klass.name).__constructFresh(\(returnExpr))" + } else { + constructCall = "\(klass.name).__construct(\(returnExpr))" + } jsPrinter.indent { thunkBuilder.renderFunctionBody( into: jsPrinter, @@ -2113,6 +2230,14 @@ extension BridgeJSLink { effects: method.effects, intrinsicRegistry: intrinsicRegistry ) + // Spec §6.2: for `.swift`-mode classes, every INSTANCE member must + // guard against use-after-release. Static members are exempt because + // `this` is the class, not the released wrapper. The guard is prepended + // to `body` BEFORE lowering/calling so it emits at the top of the + // generated function body. + if useSwiftIdentity { + appendUseAfterReleaseGuard(to: thunkBuilder.body, className: klass.name) + } thunkBuilder.lowerSelf() for param in method.parameters { try thunkBuilder.lowerParameter(param: param) @@ -2143,7 +2268,9 @@ extension BridgeJSLink { try renderClassProperty( property: property, className: klass.abiName, + classJsName: klass.name, isStatic: property.isStatic, + useSwiftIdentity: useSwiftIdentity, jsPrinter: jsPrinter, dtsPrinter: property.isStatic ? dtsExportEntryPrinter : dtsTypePrinter ) @@ -2156,10 +2283,25 @@ extension BridgeJSLink { return (jsPrinter.lines, dtsTypePrinter.lines, dtsExportEntryPrinter.lines) } + /// Writes the use-after-release guard for a `.swift`-mode class to the given printer. + /// Must be called before any other content is written so the guard appears at the top + /// of the generated function body. + private func appendUseAfterReleaseGuard(to printer: CodeFragmentPrinter, className: String) { + printer.write("if (this.__swiftIdentityHasReleased) {") + printer.indent { + printer.write( + "throw new Error(\"Attempted to call a member on a released \(className)\");" + ) + } + printer.write("}") + } + private func renderClassProperty( property: ExportedProperty, className: String, + classJsName: String, isStatic: Bool, + useSwiftIdentity: Bool, jsPrinter: CodeFragmentPrinter, dtsPrinter: CodeFragmentPrinter ) throws { @@ -2167,6 +2309,11 @@ extension BridgeJSLink { effects: Effects(isAsync: false, isThrows: false), intrinsicRegistry: intrinsicRegistry ) + // Spec §6.2: instance-property accessors on `.swift`-mode classes must also + // guard against use-after-release. Static accessors are exempt. + if !isStatic && useSwiftIdentity { + appendUseAfterReleaseGuard(to: getterThunkBuilder.body, className: classJsName) + } if !isStatic { getterThunkBuilder.lowerSelf() } @@ -2192,6 +2339,9 @@ extension BridgeJSLink { effects: Effects(isAsync: false, isThrows: false), intrinsicRegistry: intrinsicRegistry ) + if !isStatic && useSwiftIdentity { + appendUseAfterReleaseGuard(to: setterThunkBuilder.body, className: classJsName) + } if !isStatic { setterThunkBuilder.lowerSelf() } diff --git a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift index 03e6d676a..daaaf0040 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift @@ -784,7 +784,9 @@ public struct ExportedClass: Codable, NamespacedExportedType { public var methods: [ExportedFunction] public var properties: [ExportedProperty] public var namespace: [String]? - public var identityMode: Bool? // nil = use config default, true/false = override + /// Per-class identity-mode override. `nil` means "use the config default". + /// Valid values: `"none"`, `"pointer"`, `"swift"`. See `JSIdentityMode`. + public var identityMode: String? public init( name: String, @@ -794,7 +796,7 @@ public struct ExportedClass: Codable, NamespacedExportedType { methods: [ExportedFunction], properties: [ExportedProperty] = [], namespace: [String]? = nil, - identityMode: Bool? = nil + identityMode: String? = nil ) { self.name = name self.swiftCallName = swiftCallName diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift index 64c9ae535..e75626702 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift @@ -123,9 +123,9 @@ import Testing let cachedClass = outputSkeleton.exported!.classes.first { $0.name == "CachedModel" } let uncachedClass = outputSkeleton.exported!.classes.first { $0.name == "UncachedModel" } let explicitlyUncachedClass = outputSkeleton.exported!.classes.first { $0.name == "ExplicitlyUncachedModel" } - #expect(cachedClass?.identityMode == true) + #expect(cachedClass?.identityMode == "pointer") #expect(uncachedClass?.identityMode == nil) - #expect(explicitlyUncachedClass?.identityMode == false) + #expect(explicitlyUncachedClass?.identityMode == "none") // Verify generated JS via snapshot let bridgeJSLink = BridgeJSLink(skeletons: [outputSkeleton], sharedMemory: false) @@ -146,12 +146,73 @@ import Testing let outputSkeleton = try swiftAPI.finalize() // When config says "pointer", classes without annotation get identity mode from config. - // But @JS(identityMode: false) should still override to "without identity". + // But @JS(identityMode: .none) should still override to "without identity". let explicitlyUncachedClass = outputSkeleton.exported!.classes.first { $0.name == "ExplicitlyUncachedModel" } - #expect(explicitlyUncachedClass?.identityMode == false) + #expect(explicitlyUncachedClass?.identityMode == "none") // Verify generated JS via snapshot let bridgeJSLink = BridgeJSLink(skeletons: [outputSkeleton], sharedMemory: false) try snapshot(bridgeJSLink: bridgeJSLink, name: "IdentityModeClass.ConfigPointer") } + + @Test + func testLinkIdentityModeSwiftClass() throws { + // Per-class `identityMode: .swift` opt-in — no config default. + // Fixture `IdentityModeSwiftClass.swift` has three classes: + // - SwiftCached: @JS(identityMode: .swift) -> "swift" + // - WeakCached: @JS(identityMode: .pointer) -> "pointer" + // - Untouched: @JS -> nil (inherits config, which is "none" here) + let url = Self.inputsDirectory.appendingPathComponent("IdentityModeSwiftClass.swift") + let sourceFile = Parser.parse(source: try String(contentsOf: url, encoding: .utf8)) + let swiftAPI = SwiftToSkeleton( + progress: .silent, + moduleName: "TestModule", + exposeToGlobal: false, + identityMode: nil // no config default + ) + swiftAPI.addSourceFile(sourceFile, inputFilePath: "IdentityModeSwiftClass.swift") + let outputSkeleton = try swiftAPI.finalize() + + // Verify skeleton has per-class identity modes resolved from annotations. + let swiftCached = outputSkeleton.exported!.classes.first { $0.name == "SwiftCached" } + let weakCached = outputSkeleton.exported!.classes.first { $0.name == "WeakCached" } + let untouched = outputSkeleton.exported!.classes.first { $0.name == "Untouched" } + #expect(swiftCached?.identityMode == "swift") + #expect(weakCached?.identityMode == "pointer") + #expect(untouched?.identityMode == nil) + + // Verify generated JS via snapshot + let bridgeJSLink = BridgeJSLink(skeletons: [outputSkeleton], sharedMemory: false) + try snapshot(bridgeJSLink: bridgeJSLink, name: "IdentityModeSwiftClass") + } + + @Test + func testLinkIdentityModeConfigSwift() throws { + // Config-default `identityMode: "swift"` — reuses the existing `IdentityModeClass.swift` fixture. + // - ExplicitlyUncachedModel: @JS(identityMode: false) -> "none" (explicit override wins) + // - UncachedModel: @JS -> nil (inherits config -> "swift" at resolution time) + // - CachedModel: @JS(identityMode: true) -> "pointer" (explicit per-class override stays) + let url = Self.inputsDirectory.appendingPathComponent("IdentityModeClass.swift") + let sourceFile = Parser.parse(source: try String(contentsOf: url, encoding: .utf8)) + let swiftAPI = SwiftToSkeleton( + progress: .silent, + moduleName: "TestModule", + exposeToGlobal: false, + identityMode: "swift" // config default says swift for unannotated classes + ) + swiftAPI.addSourceFile(sourceFile, inputFilePath: "IdentityModeClass.swift") + let outputSkeleton = try swiftAPI.finalize() + + // Per-class annotation still wins over config default. + let explicitlyUncachedClass = outputSkeleton.exported!.classes.first { $0.name == "ExplicitlyUncachedModel" } + let uncachedClass = outputSkeleton.exported!.classes.first { $0.name == "UncachedModel" } + let cachedClass = outputSkeleton.exported!.classes.first { $0.name == "CachedModel" } + #expect(explicitlyUncachedClass?.identityMode == "none") + #expect(uncachedClass?.identityMode == nil) // inherits config at resolution time + #expect(cachedClass?.identityMode == "pointer") + + // Verify generated JS via snapshot + let bridgeJSLink = BridgeJSLink(skeletons: [outputSkeleton], sharedMemory: false) + try snapshot(bridgeJSLink: bridgeJSLink, name: "IdentityModeClass.ConfigSwift") + } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/IdentityModeSwiftClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/IdentityModeSwiftClass.swift new file mode 100644 index 000000000..de3175e81 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/IdentityModeSwiftClass.swift @@ -0,0 +1,18 @@ +import JavaScriptKit + +@JS(identityMode: .swift) +class SwiftCached { + @JS var name: String + @JS init(name: String) { self.name = name } +} + +@JS(identityMode: .pointer) +class WeakCached { + @JS var value: Int + @JS init(value: Int) { self.value = value } +} + +@JS class Untouched { + @JS var v: Int + @JS init(v: Int) { self.v = v } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json index d7a9064dc..1d6d747bc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json @@ -21,7 +21,7 @@ } ] }, - "identityMode" : true, + "identityMode" : "pointer", "methods" : [ ], @@ -107,7 +107,7 @@ } ] }, - "identityMode" : false, + "identityMode" : "none", "methods" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.json new file mode 100644 index 000000000..459491051 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.json @@ -0,0 +1,148 @@ +{ + "exported" : { + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_SwiftCached_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ] + }, + "identityMode" : "swift", + "methods" : [ + + ], + "name" : "SwiftCached", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "SwiftCached" + }, + { + "constructor" : { + "abiName" : "bjs_WeakCached_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "identityMode" : "pointer", + "methods" : [ + + ], + "name" : "WeakCached", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "WeakCached" + }, + { + "constructor" : { + "abiName" : "bjs_Untouched_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "Untouched", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "v", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "Untouched" + } + ], + "enums" : [ + + ], + "exposeToGlobal" : false, + "functions" : [ + + ], + "protocols" : [ + + ], + "structs" : [ + + ] + }, + "moduleName" : "TestModule" +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift new file mode 100644 index 000000000..56af5bbf8 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift @@ -0,0 +1,277 @@ +nonisolated(unsafe) var _SwiftCached_identityTable: [UnsafeMutableRawPointer: Int32] = [:] + +nonisolated(unsafe) var _SwiftCached_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] + +nonisolated(unsafe) var _SwiftCached_wrapperRefs: [Int32] = [] + +nonisolated(unsafe) var _SwiftCached_freeIds: [Int32] = [] + +nonisolated(unsafe) var _SwiftCached_nextId: Int32 = 0 + +@_expose(wasm, "bjs_SwiftCached_init") +@_cdecl("bjs_SwiftCached_init") +public func _bjs_SwiftCached_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = SwiftCached(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _SwiftCached_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _SwiftCached_freeIds.popLast() { + id = recycled + } else { + id = _SwiftCached_nextId + _SwiftCached_nextId += 1 + _SwiftCached_wrapperRefs.append(0) + } + _SwiftCached_identityTable[ptr] = id + _SwiftCached_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftCached_name_get") +@_cdecl("bjs_SwiftCached_name_get") +public func _bjs_SwiftCached_name_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = SwiftCached.bridgeJSLiftParameter(_self).name + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftCached_name_set") +@_cdecl("bjs_SwiftCached_name_set") +public func _bjs_SwiftCached_name_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + SwiftCached.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftCached_deinit") +@_cdecl("bjs_SwiftCached_deinit") +public func _bjs_SwiftCached_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftCached_register_wrapper") +@_cdecl("bjs_SwiftCached_register_wrapper") +public func _bjs_SwiftCached_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { + #if arch(wasm32) + _SwiftCached_wrapperRefs[Int(id)] = jsRef + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftCached_release_wrapper") +@_cdecl("bjs_SwiftCached_release_wrapper") +public func _bjs_SwiftCached_release_wrapper(_ id: Int32) -> Void { + #if arch(wasm32) + let slot = Int(id) + let jsRef = _SwiftCached_wrapperRefs[slot] + guard jsRef != 0 else { return } + _SwiftCached_wrapperRefs[slot] = 0 + if let ptr = _SwiftCached_idToPointer.removeValue(forKey: id) { + _SwiftCached_identityTable.removeValue(forKey: ptr) + Unmanaged.fromOpaque(ptr).release() + } + _SwiftCached_freeIds.append(id) + _swift_js_release_ref(jsRef) + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension SwiftCached { + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if let id = _SwiftCached_identityTable[ptr] { + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(self) + let id: Int32 + if let recycled = _SwiftCached_freeIds.popLast() { + id = recycled + } else { + id = _SwiftCached_nextId + _SwiftCached_nextId += 1 + _SwiftCached_wrapperRefs.append(0) + } + _SwiftCached_identityTable[ptr] = id + _SwiftCached_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + _swift_js_push_pointer(ptr) + } +} + +extension SwiftCached: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_SwiftCached_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_SwiftCached_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_SwiftCached_wrap") +fileprivate func _bjs_SwiftCached_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_SwiftCached_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_SwiftCached_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_SwiftCached_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_WeakCached_init") +@_cdecl("bjs_WeakCached_init") +public func _bjs_WeakCached_init(_ value: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = WeakCached(value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_WeakCached_value_get") +@_cdecl("bjs_WeakCached_value_get") +public func _bjs_WeakCached_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = WeakCached.bridgeJSLiftParameter(_self).value + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_WeakCached_value_set") +@_cdecl("bjs_WeakCached_value_set") +public func _bjs_WeakCached_value_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + WeakCached.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_WeakCached_deinit") +@_cdecl("bjs_WeakCached_deinit") +public func _bjs_WeakCached_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension WeakCached: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_WeakCached_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_WeakCached_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_WeakCached_wrap") +fileprivate func _bjs_WeakCached_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_WeakCached_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_WeakCached_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_WeakCached_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_Untouched_init") +@_cdecl("bjs_Untouched_init") +public func _bjs_Untouched_init(_ v: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = Untouched(v: Int.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Untouched_v_get") +@_cdecl("bjs_Untouched_v_get") +public func _bjs_Untouched_v_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = Untouched.bridgeJSLiftParameter(_self).v + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Untouched_v_set") +@_cdecl("bjs_Untouched_v_set") +public func _bjs_Untouched_v_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + Untouched.bridgeJSLiftParameter(_self).v = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Untouched_deinit") +@_cdecl("bjs_Untouched_deinit") +public func _bjs_Untouched_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Untouched: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Untouched_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_Untouched_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Untouched_wrap") +fileprivate func _bjs_Untouched_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_Untouched_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_Untouched_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Untouched_wrap_extern(pointer) +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.d.ts new file mode 100644 index 000000000..e5e2a3a84 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.d.ts @@ -0,0 +1,42 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +/// Represents a Swift heap object like a class instance or an actor instance. +export interface SwiftHeapObject { + /// Release the heap object. + /// + /// Note: Calling this method will release the heap object and it will no longer be accessible. + release(): void; +} +export interface CachedModel extends SwiftHeapObject { + name: string; +} +export interface UncachedModel extends SwiftHeapObject { + value: number; +} +export interface ExplicitlyUncachedModel extends SwiftHeapObject { + count: number; +} +export type Exports = { + CachedModel: { + new(name: string): CachedModel; + } + UncachedModel: { + new(value: number): UncachedModel; + } + ExplicitlyUncachedModel: { + new(count: number): ExplicitlyUncachedModel; + } +} +export type Imports = { +} +export function createInstantiator(options: { + imports: Imports; +}, swift: any): Promise<{ + addImports: (importObject: WebAssembly.Imports) => void; + setInstance: (instance: WebAssembly.Instance) => void; + createExports: (instance: WebAssembly.Instance) => Exports; +}>; \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js new file mode 100644 index 000000000..2bb59cb7c --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js @@ -0,0 +1,381 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +export async function createInstantiator(options, swift) { + let instance; + let memory; + let setException; + let decodeString; + const textDecoder = new TextDecoder("utf-8"); + const textEncoder = new TextEncoder("utf-8"); + let tmpRetString; + let tmpRetBytes; + let tmpRetException; + let tmpRetOptionalBool; + let tmpRetOptionalInt; + let tmpRetOptionalFloat; + let tmpRetOptionalDouble; + let tmpRetOptionalHeapObject; + let strStack = []; + let i32Stack = []; + let i64Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + + return { + /** + * @param {WebAssembly.Imports} importObject + */ + addImports: (importObject, importsContext) => { + bjs = {}; + importObject["bjs"] = bjs; + bjs["swift_js_return_string"] = function(ptr, len) { + tmpRetString = decodeString(ptr, len); + } + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { + const source = swift.memory.getObject(sourceId); + swift.memory.release(sourceId); + const bytes = new Uint8Array(memory.buffer, bytesPtr); + bytes.set(source); + } + bjs["swift_js_make_js_string"] = function(ptr, len) { + return swift.memory.retain(decodeString(ptr, len)); + } + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { + const target = new Uint8Array(memory.buffer, ptr, len); + target.set(tmpRetBytes); + tmpRetBytes = undefined; + } + bjs["swift_js_throw"] = function(id) { + tmpRetException = swift.memory.retainByRef(id); + } + bjs["swift_js_retain"] = function(id) { + return swift.memory.retainByRef(id); + } + bjs["swift_js_release"] = function(id) { + swift.memory.release(id); + } + bjs["swift_js_push_i32"] = function(v) { + i32Stack.push(v | 0); + } + bjs["swift_js_push_f32"] = function(v) { + f32Stack.push(Math.fround(v)); + } + bjs["swift_js_push_f64"] = function(v) { + f64Stack.push(v); + } + bjs["swift_js_push_string"] = function(ptr, len) { + const value = decodeString(ptr, len); + strStack.push(value); + } + bjs["swift_js_pop_i32"] = function() { + return i32Stack.pop(); + } + bjs["swift_js_pop_f32"] = function() { + return f32Stack.pop(); + } + bjs["swift_js_pop_f64"] = function() { + return f64Stack.pop(); + } + bjs["swift_js_push_pointer"] = function(pointer) { + ptrStack.push(pointer); + } + bjs["swift_js_pop_pointer"] = function() { + return ptrStack.pop(); + } + bjs["swift_js_push_i64"] = function(v) { + i64Stack.push(v); + } + bjs["swift_js_pop_i64"] = function() { + return i64Stack.pop(); + } + bjs["swift_js_return_optional_bool"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalBool = null; + } else { + tmpRetOptionalBool = value !== 0; + } + } + bjs["swift_js_return_optional_int"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalInt = null; + } else { + tmpRetOptionalInt = value | 0; + } + } + bjs["swift_js_return_optional_float"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalFloat = null; + } else { + tmpRetOptionalFloat = Math.fround(value); + } + } + bjs["swift_js_return_optional_double"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalDouble = null; + } else { + tmpRetOptionalDouble = value; + } + } + bjs["swift_js_return_optional_string"] = function(isSome, ptr, len) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = decodeString(ptr, len); + } + } + bjs["swift_js_return_optional_object"] = function(isSome, objectId) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = swift.memory.getObject(objectId); + } + } + bjs["swift_js_return_optional_heap_object"] = function(isSome, pointer) { + if (isSome === 0) { + tmpRetOptionalHeapObject = null; + } else { + tmpRetOptionalHeapObject = pointer; + } + } + bjs["swift_js_get_optional_int_presence"] = function() { + return tmpRetOptionalInt != null ? 1 : 0; + } + bjs["swift_js_get_optional_int_value"] = function() { + const value = tmpRetOptionalInt; + tmpRetOptionalInt = undefined; + return value; + } + bjs["swift_js_get_optional_string"] = function() { + const str = tmpRetString; + tmpRetString = undefined; + if (str == null) { + return -1; + } else { + const bytes = textEncoder.encode(str); + tmpRetBytes = bytes; + return bytes.length; + } + } + bjs["swift_js_get_optional_float_presence"] = function() { + return tmpRetOptionalFloat != null ? 1 : 0; + } + bjs["swift_js_get_optional_float_value"] = function() { + const value = tmpRetOptionalFloat; + tmpRetOptionalFloat = undefined; + return value; + } + bjs["swift_js_get_optional_double_presence"] = function() { + return tmpRetOptionalDouble != null ? 1 : 0; + } + bjs["swift_js_get_optional_double_value"] = function() { + const value = tmpRetOptionalDouble; + tmpRetOptionalDouble = undefined; + return value; + } + bjs["swift_js_get_optional_heap_object_pointer"] = function() { + const pointer = tmpRetOptionalHeapObject; + tmpRetOptionalHeapObject = undefined; + return pointer || 0; + } + bjs["swift_js_closure_unregister"] = function(funcRef) {} + // Wrapper functions for module: TestModule + if (!importObject["TestModule"]) { + importObject["TestModule"] = {}; + } + importObject["TestModule"]["bjs_CachedModel_wrap"] = function(pointer) { + const obj = _exports['CachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_ExplicitlyUncachedModel_wrap"] = function(pointer) { + const obj = _exports['ExplicitlyUncachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_UncachedModel_wrap"] = function(pointer) { + const obj = _exports['UncachedModel'].__construct(pointer); + return swift.memory.retain(obj); + }; + }, + setInstance: (i) => { + instance = i; + memory = instance.exports.memory; + + decodeString = (ptr, len) => { const bytes = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); return textDecoder.decode(bytes); } + + setException = (error) => { + instance.exports._swift_js_exception.value = swift.memory.retain(error) + } + }, + /** @param {WebAssembly.Instance} instance */ + createExports: (instance) => { + const js = swift.memory.heap; + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + + /// Represents a Swift heap object like a class instance or an actor instance. + class SwiftHeapObject { + static __wrap(pointer, deinit, prototype, identityCache) { + const makeFresh = (identityMap) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + swiftHeapObjectFinalizationRegistry.register(obj, state, state); + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!identityCache) { + return makeFresh(null); + } + + const cached = identityCache.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); + return cached; + } + if (identityCache.has(pointer)) { + identityCache.delete(pointer); + } + + return makeFresh(identityCache); + } + + release() { + const state = this.__swiftHeapObjectState; + if (state.hasReleased) { + return; + } + state.hasReleased = true; + swiftHeapObjectFinalizationRegistry.unregister(state); + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + } + } + class CachedModel extends SwiftHeapObject { + static __identityCache = new Map(); + + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_CachedModel_deinit, CachedModel.prototype, CachedModel.__identityCache); + } + + static __constructFresh(ptr) { + const obj = Object.create(CachedModel.prototype); + const state = { pointer: ptr, deinit: instance.exports.bjs_CachedModel_deinit, hasReleased: false, identityMap: CachedModel.__identityCache }; + obj.pointer = ptr; + obj.__swiftHeapObjectState = state; + swiftHeapObjectFinalizationRegistry.register(obj, state, state); + CachedModel.__identityCache.set(ptr, new WeakRef(obj)); + return obj; + } + + constructor(name) { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + const ret = instance.exports.bjs_CachedModel_init(nameId, nameBytes.length); + return CachedModel.__constructFresh(ret); + } + get name() { + instance.exports.bjs_CachedModel_name_get(this.pointer); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + } + set name(value) { + const valueBytes = textEncoder.encode(value); + const valueId = swift.memory.retain(valueBytes); + instance.exports.bjs_CachedModel_name_set(this.pointer, valueId, valueBytes.length); + } + } + class UncachedModel { + static __swiftIdentityWrappers = []; + + static __wrap(pointer) { + const freshBit = bjs.swift_js_pop_i32(); + const id = bjs.swift_js_pop_i32(); + if (freshBit === 0) { + return UncachedModel.__swiftIdentityWrappers[id]; + } + const obj = Object.create(UncachedModel.prototype); + obj.pointer = pointer; + obj.__swiftIdentityId = id; + obj.__swiftIdentityHasReleased = false; + UncachedModel.__swiftIdentityWrappers[id] = obj; + const jsRef = swift.memory.retain(obj); + instance.exports.bjs_UncachedModel_register_wrapper(id, jsRef); + return obj; + } + + static __construct(pointer) { + return UncachedModel.__wrap(pointer); + } + + release() { + if (this.__swiftIdentityHasReleased) return; + this.__swiftIdentityHasReleased = true; + const id = this.__swiftIdentityId; + instance.exports.bjs_UncachedModel_release_wrapper(id); + UncachedModel.__swiftIdentityWrappers[id] = undefined; + } + constructor(value) { + const ret = instance.exports.bjs_UncachedModel_init(value); + return UncachedModel.__wrap(ret); + } + get value() { + if (this.__swiftIdentityHasReleased) { + throw new Error("Attempted to call a member on a released UncachedModel"); + } + const ret = instance.exports.bjs_UncachedModel_value_get(this.pointer); + return ret; + } + set value(value) { + if (this.__swiftIdentityHasReleased) { + throw new Error("Attempted to call a member on a released UncachedModel"); + } + instance.exports.bjs_UncachedModel_value_set(this.pointer, value); + } + } + class ExplicitlyUncachedModel extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_ExplicitlyUncachedModel_deinit, ExplicitlyUncachedModel.prototype, null); + } + + constructor(count) { + const ret = instance.exports.bjs_ExplicitlyUncachedModel_init(count); + return ExplicitlyUncachedModel.__construct(ret); + } + get count() { + const ret = instance.exports.bjs_ExplicitlyUncachedModel_count_get(this.pointer); + return ret; + } + set count(value) { + instance.exports.bjs_ExplicitlyUncachedModel_count_set(this.pointer, value); + } + } + const exports = { + CachedModel, + UncachedModel, + ExplicitlyUncachedModel, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.d.ts new file mode 100644 index 000000000..63047ee5a --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.d.ts @@ -0,0 +1,42 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +/// Represents a Swift heap object like a class instance or an actor instance. +export interface SwiftHeapObject { + /// Release the heap object. + /// + /// Note: Calling this method will release the heap object and it will no longer be accessible. + release(): void; +} +export interface SwiftCached extends SwiftHeapObject { + name: string; +} +export interface WeakCached extends SwiftHeapObject { + value: number; +} +export interface Untouched extends SwiftHeapObject { + v: number; +} +export type Exports = { + SwiftCached: { + new(name: string): SwiftCached; + } + WeakCached: { + new(value: number): WeakCached; + } + Untouched: { + new(v: number): Untouched; + } +} +export type Imports = { +} +export function createInstantiator(options: { + imports: Imports; +}, swift: any): Promise<{ + addImports: (importObject: WebAssembly.Imports) => void; + setInstance: (instance: WebAssembly.Instance) => void; + createExports: (instance: WebAssembly.Instance) => Exports; +}>; \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js new file mode 100644 index 000000000..8328f8e46 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js @@ -0,0 +1,381 @@ +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +export async function createInstantiator(options, swift) { + let instance; + let memory; + let setException; + let decodeString; + const textDecoder = new TextDecoder("utf-8"); + const textEncoder = new TextEncoder("utf-8"); + let tmpRetString; + let tmpRetBytes; + let tmpRetException; + let tmpRetOptionalBool; + let tmpRetOptionalInt; + let tmpRetOptionalFloat; + let tmpRetOptionalDouble; + let tmpRetOptionalHeapObject; + let strStack = []; + let i32Stack = []; + let i64Stack = []; + let f32Stack = []; + let f64Stack = []; + let ptrStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + + return { + /** + * @param {WebAssembly.Imports} importObject + */ + addImports: (importObject, importsContext) => { + bjs = {}; + importObject["bjs"] = bjs; + bjs["swift_js_return_string"] = function(ptr, len) { + tmpRetString = decodeString(ptr, len); + } + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { + const source = swift.memory.getObject(sourceId); + swift.memory.release(sourceId); + const bytes = new Uint8Array(memory.buffer, bytesPtr); + bytes.set(source); + } + bjs["swift_js_make_js_string"] = function(ptr, len) { + return swift.memory.retain(decodeString(ptr, len)); + } + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { + const target = new Uint8Array(memory.buffer, ptr, len); + target.set(tmpRetBytes); + tmpRetBytes = undefined; + } + bjs["swift_js_throw"] = function(id) { + tmpRetException = swift.memory.retainByRef(id); + } + bjs["swift_js_retain"] = function(id) { + return swift.memory.retainByRef(id); + } + bjs["swift_js_release"] = function(id) { + swift.memory.release(id); + } + bjs["swift_js_push_i32"] = function(v) { + i32Stack.push(v | 0); + } + bjs["swift_js_push_f32"] = function(v) { + f32Stack.push(Math.fround(v)); + } + bjs["swift_js_push_f64"] = function(v) { + f64Stack.push(v); + } + bjs["swift_js_push_string"] = function(ptr, len) { + const value = decodeString(ptr, len); + strStack.push(value); + } + bjs["swift_js_pop_i32"] = function() { + return i32Stack.pop(); + } + bjs["swift_js_pop_f32"] = function() { + return f32Stack.pop(); + } + bjs["swift_js_pop_f64"] = function() { + return f64Stack.pop(); + } + bjs["swift_js_push_pointer"] = function(pointer) { + ptrStack.push(pointer); + } + bjs["swift_js_pop_pointer"] = function() { + return ptrStack.pop(); + } + bjs["swift_js_push_i64"] = function(v) { + i64Stack.push(v); + } + bjs["swift_js_pop_i64"] = function() { + return i64Stack.pop(); + } + bjs["swift_js_return_optional_bool"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalBool = null; + } else { + tmpRetOptionalBool = value !== 0; + } + } + bjs["swift_js_return_optional_int"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalInt = null; + } else { + tmpRetOptionalInt = value | 0; + } + } + bjs["swift_js_return_optional_float"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalFloat = null; + } else { + tmpRetOptionalFloat = Math.fround(value); + } + } + bjs["swift_js_return_optional_double"] = function(isSome, value) { + if (isSome === 0) { + tmpRetOptionalDouble = null; + } else { + tmpRetOptionalDouble = value; + } + } + bjs["swift_js_return_optional_string"] = function(isSome, ptr, len) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = decodeString(ptr, len); + } + } + bjs["swift_js_return_optional_object"] = function(isSome, objectId) { + if (isSome === 0) { + tmpRetString = null; + } else { + tmpRetString = swift.memory.getObject(objectId); + } + } + bjs["swift_js_return_optional_heap_object"] = function(isSome, pointer) { + if (isSome === 0) { + tmpRetOptionalHeapObject = null; + } else { + tmpRetOptionalHeapObject = pointer; + } + } + bjs["swift_js_get_optional_int_presence"] = function() { + return tmpRetOptionalInt != null ? 1 : 0; + } + bjs["swift_js_get_optional_int_value"] = function() { + const value = tmpRetOptionalInt; + tmpRetOptionalInt = undefined; + return value; + } + bjs["swift_js_get_optional_string"] = function() { + const str = tmpRetString; + tmpRetString = undefined; + if (str == null) { + return -1; + } else { + const bytes = textEncoder.encode(str); + tmpRetBytes = bytes; + return bytes.length; + } + } + bjs["swift_js_get_optional_float_presence"] = function() { + return tmpRetOptionalFloat != null ? 1 : 0; + } + bjs["swift_js_get_optional_float_value"] = function() { + const value = tmpRetOptionalFloat; + tmpRetOptionalFloat = undefined; + return value; + } + bjs["swift_js_get_optional_double_presence"] = function() { + return tmpRetOptionalDouble != null ? 1 : 0; + } + bjs["swift_js_get_optional_double_value"] = function() { + const value = tmpRetOptionalDouble; + tmpRetOptionalDouble = undefined; + return value; + } + bjs["swift_js_get_optional_heap_object_pointer"] = function() { + const pointer = tmpRetOptionalHeapObject; + tmpRetOptionalHeapObject = undefined; + return pointer || 0; + } + bjs["swift_js_closure_unregister"] = function(funcRef) {} + // Wrapper functions for module: TestModule + if (!importObject["TestModule"]) { + importObject["TestModule"] = {}; + } + importObject["TestModule"]["bjs_SwiftCached_wrap"] = function(pointer) { + const obj = _exports['SwiftCached'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_Untouched_wrap"] = function(pointer) { + const obj = _exports['Untouched'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_WeakCached_wrap"] = function(pointer) { + const obj = _exports['WeakCached'].__construct(pointer); + return swift.memory.retain(obj); + }; + }, + setInstance: (i) => { + instance = i; + memory = instance.exports.memory; + + decodeString = (ptr, len) => { const bytes = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); return textDecoder.decode(bytes); } + + setException = (error) => { + instance.exports._swift_js_exception.value = swift.memory.retain(error) + } + }, + /** @param {WebAssembly.Instance} instance */ + createExports: (instance) => { + const js = swift.memory.heap; + const swiftHeapObjectFinalizationRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + if (state.hasReleased) { + return; + } + state.hasReleased = true; + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + }); + + /// Represents a Swift heap object like a class instance or an actor instance. + class SwiftHeapObject { + static __wrap(pointer, deinit, prototype, identityCache) { + const makeFresh = (identityMap) => { + const obj = Object.create(prototype); + const state = { pointer, deinit, hasReleased: false, identityMap }; + obj.pointer = pointer; + obj.__swiftHeapObjectState = state; + swiftHeapObjectFinalizationRegistry.register(obj, state, state); + if (identityMap) { + identityMap.set(pointer, new WeakRef(obj)); + } + return obj; + }; + + if (!identityCache) { + return makeFresh(null); + } + + const cached = identityCache.get(pointer)?.deref(); + if (cached && !cached.__swiftHeapObjectState.hasReleased) { + deinit(pointer); + return cached; + } + if (identityCache.has(pointer)) { + identityCache.delete(pointer); + } + + return makeFresh(identityCache); + } + + release() { + const state = this.__swiftHeapObjectState; + if (state.hasReleased) { + return; + } + state.hasReleased = true; + swiftHeapObjectFinalizationRegistry.unregister(state); + state.identityMap?.delete(state.pointer); + state.deinit(state.pointer); + } + } + class SwiftCached { + static __swiftIdentityWrappers = []; + + static __wrap(pointer) { + const freshBit = bjs.swift_js_pop_i32(); + const id = bjs.swift_js_pop_i32(); + if (freshBit === 0) { + return SwiftCached.__swiftIdentityWrappers[id]; + } + const obj = Object.create(SwiftCached.prototype); + obj.pointer = pointer; + obj.__swiftIdentityId = id; + obj.__swiftIdentityHasReleased = false; + SwiftCached.__swiftIdentityWrappers[id] = obj; + const jsRef = swift.memory.retain(obj); + instance.exports.bjs_SwiftCached_register_wrapper(id, jsRef); + return obj; + } + + static __construct(pointer) { + return SwiftCached.__wrap(pointer); + } + + release() { + if (this.__swiftIdentityHasReleased) return; + this.__swiftIdentityHasReleased = true; + const id = this.__swiftIdentityId; + instance.exports.bjs_SwiftCached_release_wrapper(id); + SwiftCached.__swiftIdentityWrappers[id] = undefined; + } + constructor(name) { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + const ret = instance.exports.bjs_SwiftCached_init(nameId, nameBytes.length); + return SwiftCached.__wrap(ret); + } + get name() { + if (this.__swiftIdentityHasReleased) { + throw new Error("Attempted to call a member on a released SwiftCached"); + } + instance.exports.bjs_SwiftCached_name_get(this.pointer); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + } + set name(value) { + if (this.__swiftIdentityHasReleased) { + throw new Error("Attempted to call a member on a released SwiftCached"); + } + const valueBytes = textEncoder.encode(value); + const valueId = swift.memory.retain(valueBytes); + instance.exports.bjs_SwiftCached_name_set(this.pointer, valueId, valueBytes.length); + } + } + class WeakCached extends SwiftHeapObject { + static __identityCache = new Map(); + + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_WeakCached_deinit, WeakCached.prototype, WeakCached.__identityCache); + } + + static __constructFresh(ptr) { + const obj = Object.create(WeakCached.prototype); + const state = { pointer: ptr, deinit: instance.exports.bjs_WeakCached_deinit, hasReleased: false, identityMap: WeakCached.__identityCache }; + obj.pointer = ptr; + obj.__swiftHeapObjectState = state; + swiftHeapObjectFinalizationRegistry.register(obj, state, state); + WeakCached.__identityCache.set(ptr, new WeakRef(obj)); + return obj; + } + + constructor(value) { + const ret = instance.exports.bjs_WeakCached_init(value); + return WeakCached.__constructFresh(ret); + } + get value() { + const ret = instance.exports.bjs_WeakCached_value_get(this.pointer); + return ret; + } + set value(value) { + instance.exports.bjs_WeakCached_value_set(this.pointer, value); + } + } + class Untouched extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Untouched_deinit, Untouched.prototype, null); + } + + constructor(v) { + const ret = instance.exports.bjs_Untouched_init(v); + return Untouched.__construct(ret); + } + get v() { + const ret = instance.exports.bjs_Untouched_v_get(this.pointer); + return ret; + } + set v(value) { + instance.exports.bjs_Untouched_v_set(this.pointer, value); + } + } + const exports = { + SwiftCached, + WeakCached, + Untouched, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift index 867d0e835..f40decac2 100644 --- a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift +++ b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift @@ -1059,6 +1059,22 @@ private func _swift_js_retain_extern(_ id: Int32) -> Int32 { _swift_js_retain_extern(id) } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_release") +private func _swift_js_release_ref_extern(_ id: Int32) +#else +/// Releases a previously-retained JavaScript object reference, balancing a +/// prior `_swift_js_retain` call. Used by `identityMode: "swift"` classes to +/// drop Swift's strong hold on the JS wrapper ref when the Swift object is +/// released. +private func _swift_js_release_ref_extern(_ id: Int32) { + _onlyAvailableOnWasm() +} +#endif +@_spi(BridgeJS) @inline(never) public func _swift_js_release_ref(_ id: Int32) { + _swift_js_release_ref_extern(id) +} + #if arch(wasm32) @_extern(wasm, module: "bjs", name: "swift_js_return_optional_bool") private func _swift_js_return_optional_bool_extern(_ isSome: Int32, _ value: Int32) diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/BridgeJS-Configuration.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/BridgeJS-Configuration.md index 604017aad..7b79b8877 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/BridgeJS-Configuration.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/BridgeJS-Configuration.md @@ -73,6 +73,26 @@ const greeter = new exports.MyModule.Greeter("World"); // globalThis.MyModule is undefined ``` +### `identityMode` + +Default wrapper-identity policy for `@JS class` returns in this module. Controls whether two Swift→JS returns of the same Swift object produce the same JS wrapper (`===`), and where the identity cache lives. + +| Value | Effect | +|-------|--------| +| `"none"` (default) | No cache. Every return allocates a fresh wrapper. | +| `"pointer"` | JS-side `WeakRef` cache. `===` holds while reachable; wrapper may be GC'd. | +| `"swift"` | Swift-owned strong cache. `===` holds until explicit `release()`. Best for create-heavy workloads. | + +Example: + +```json +{ + "identityMode": "swift" +} +``` + +A per-class `@JS(identityMode: .none | .pointer | .swift)` annotation overrides the config default for a single class. See for the full comparison, tradeoffs, and benchmark results. + ### `tools` Specify custom paths for external executables. This is particularly useful when working in environments like Xcode where the system PATH may not be inherited, or when you need to use a specific version of tools for your project. diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift-to-JavaScript.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift-to-JavaScript.md index b14d2eebe..1155c327b 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift-to-JavaScript.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift-to-JavaScript.md @@ -16,6 +16,7 @@ Configure your package and build for JavaScript as described in - +- - - - diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Class.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Class.md index a16c81286..8ee8eddba 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Class.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Class.md @@ -153,3 +153,7 @@ This differs from structs, which use copy semantics and transfer data by value. | Extension methods/properties | ✅ | | Subscripts: `subscript()` | ❌ | | Generics | ❌ | + +## Wrapper identity (`===` on re-export) + +By default, Swift→JS returns allocate a fresh JS wrapper every time, so `===` between two returns of the same Swift object is `false`. Opt into stable identity per class with `@JS(identityMode: .pointer)` (weak, JS-side cache) or `@JS(identityMode: .swift)` (strong, Swift-side cache — best for create-heavy workloads). See . diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Identity-Modes-For-Exported-Classes.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Identity-Modes-For-Exported-Classes.md new file mode 100644 index 000000000..2b6a50242 --- /dev/null +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Identity-Modes-For-Exported-Classes.md @@ -0,0 +1,107 @@ +# Identity Modes for Exported Classes + +Control whether a Swift class returned to JavaScript produces a stable JS wrapper on re-export, and where the identity cache lives. + +## Overview + +Every time an `@JS class` instance crosses the Swift→JS boundary, BridgeJS has to give JavaScript *some* value that represents the underlying Swift object. By default, it builds a fresh JS wrapper each time — so two calls that return the same Swift object produce two different JS objects: + +```javascript +const a = exports.getCurrentUser(); +const b = exports.getCurrentUser(); +a === b; // false — two different wrappers around the same Swift object +``` + +For many apps that's fine. But if your JS code uses `===` to compare, or stores wrappers as keys in a `Map`/`Set`, or keeps mutable state on the wrapper, you probably want stable identity. BridgeJS offers three policies via `identityMode`: + +| Mode | Meaning | When to use | +|------|---------|-------------| +| `.none` | No cache. Fresh wrapper on every crossing. **Default.** | You don't need `===` identity and you want zero bookkeeping overhead. | +| `.pointer` | JS-side `WeakRef` cache. `===` holds while the wrapper is reachable. | Hit-heavy workloads with many long-lived wrappers. You want weak semantics (wrapper can be GC'd if JS code drops its reference). | +| `.swift` | Swift-owned strong cache. `===` holds until explicit `release()`. | Create-heavy or churn-heavy workloads. You want the lowest per-miss cost and don't mind retaining wrappers until you explicitly release. | + +## Per-class opt-in + +```swift +import JavaScriptKit + +@JS(identityMode: .swift) +class Building { + @JS var name: String + @JS init(name: String) { self.name = name } +} +``` + +Classes without an `identityMode:` argument inherit the project default (see below). A per-class annotation always wins over the config default. + +## Project-wide default + +Set a default in `bridge-js.config.json`: + +```json +{ "identityMode": "swift" } +``` + +This makes every `@JS class` in the project use swift mode unless it explicitly overrides with its own annotation. The three valid string values are `"none"`, `"pointer"`, and `"swift"`. + +## What each mode does at runtime + +### `.none` (default) + +Every Swift→JS return allocates a new wrapper. Wrappers release via a `FinalizationRegistry` when JS GCs them. No identity guarantees; lowest peak memory for short-lived crossings. + +### `.pointer` + +BridgeJS keeps a `Map>` on the JS side, keyed by the raw Swift pointer. On re-export, if the weakref still deref'es to a live wrapper, the same wrapper is returned. Wrappers can still be GC'd if JS drops all references — and on the next re-export a fresh wrapper is built. `===` is "best-effort" in the face of GC. + +### `.swift` + +The Swift side keeps an authoritative `pointer → id` table per class, plus an `id → JavaScriptObjectRef` table holding a strong reference to the JS wrapper. On re-export, Swift returns the known id, and JS fetches the cached wrapper from a dense array by integer index — no `WeakRef.deref`, no `Map.get`. On a fresh object, Swift tells JS to build a new wrapper and JS registers its retained ref back with Swift. + +The key differences vs `.pointer`: + +- **Stronger identity.** The wrapper is strongly retained by Swift until JS calls `release()`. GC will NOT collect it. +- **Faster miss path.** No `FinalizationRegistry.register`, no `WeakRef` allocation per miss. Benchmarks show a 1.7–2.3× improvement on create-heavy and churn-heavy workloads vs `.pointer`. +- **Higher peak memory.** A wrapper that's created and forgotten without `release()` lives for the lifetime of its Swift heap object. Use `.pointer` or `.none` for streaming / short-lived workloads. + +## Lifecycle + +```javascript +const b = exports.getBuilding(); // allocates a wrapper (if fresh) +b.name; // stable === with any future getBuilding() that returns the same Swift object +b.release(); // mandatory for swift mode — frees the Swift heap object and the wrapper slot +// after release(): b.name throws "Attempted to call a member on a released Building" +``` + +Double-release is a safe no-op. Static members (class-level methods, constructors) are not affected by release. + +## Benchmarks (summary) + +Full results in [`Benchmarks/results/swift-side-cache/Benchmarks.md`](../../../../../Benchmarks/results/swift-side-cache/Benchmarks.md). Baseline arm64-macOS, Swift 6.3, Node 22, release build, 500k iters per scenario, median ms: + +| Scenario | `.none` | `.pointer` | `.swift` | +|---|---:|---:|---:| +| `passBothWaysRoundtrip` (hit) | 160 | 31 | **26** | +| `getPoolRepeated_100` (hit) | 183 | 46 | **32** | +| `swiftCreatesObject` (miss) | 514 | 2021 | **593** | +| `churnObjects` (create/release) | — | 793 | **317** | +| `swiftConsumesSameObject` | 17 | 10 | **10** | + +`.swift` mode is a strict Pareto improvement over `.pointer` mode: faster on hit, 3.4× faster on miss, 2.5× faster on churn, parity on one-way. + +## Known limitations + +- **Optional identity is not preserved.** If your Swift API returns `SomeClass?`, `.some(x)` produces a fresh wrapper each call even with `.swift` mode. Lifecycle is still correct, but `a === b` where both come from an optional return will be `false`. Workaround: wrap in `[SomeClass]` (array element identity IS preserved). +- **No automatic cleanup.** You must call `release()` explicitly. A future version may add a Swift-side timeout or GC-assisted cleanup. +- **Wasm-only.** Like all of BridgeJS, identity modes only activate on `wasm32`. On the host, the macro expands to no-op code paths so your test harness can still compile. + +## Choosing a mode + +- **Most apps:** leave as `.none`. You don't need identity, don't pay the cost. +- **Long-lived object graph you cache on the JS side and you want weak GC-safe semantics:** `.pointer`. +- **Create-heavy, churn-heavy, or hit-heavy workloads where explicit `release()` is acceptable:** `.swift`. Strictly faster than `.pointer` on every benchmark scenario; only difference is strong retention until release. + +## See also + +- +- diff --git a/Sources/JavaScriptKit/JSIdentityMode.swift b/Sources/JavaScriptKit/JSIdentityMode.swift new file mode 100644 index 000000000..51954baa8 --- /dev/null +++ b/Sources/JavaScriptKit/JSIdentityMode.swift @@ -0,0 +1,13 @@ +/// Per-class identity caching policy for `@JS`-exported classes. +/// +/// See `Docs/superpowers/specs/2026-04-21-swift-side-identity-cache-design.md` §3. +/// +/// - `.none`: No identity caching. Each boundary crossing produces a fresh JS wrapper. +/// - `.pointer`: JS-side identity cache keyed by the Swift pointer (weak refs + `FinalizationRegistry`). +/// - `.swift`: Swift-side identity cache (opt-in; strong retention of the JS wrapper for the +/// lifetime of the Swift heap object). +public enum JSIdentityMode: String, Sendable { + case none + case pointer + case swift +} diff --git a/Sources/JavaScriptKit/Macros.swift b/Sources/JavaScriptKit/Macros.swift index 3189cdeab..8666aed17 100644 --- a/Sources/JavaScriptKit/Macros.swift +++ b/Sources/JavaScriptKit/Macros.swift @@ -113,7 +113,7 @@ public enum JSImportFrom: String { /// /// - Important: This feature is still experimental. No API stability is guaranteed, and the API may change in future releases. @attached(peer) -public macro JS(namespace: String? = nil, enumStyle: JSEnumStyle = .const, identityMode: Bool = false) = +public macro JS(namespace: String? = nil, enumStyle: JSEnumStyle = .const, identityMode: JSIdentityMode = .none) = Builtin.ExternalMacro /// A macro that generates a Swift getter that reads a value from JavaScript. diff --git a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift index e25ebeb4c..c8e020349 100644 --- a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift @@ -133,6 +133,157 @@ public func _bjs_clearArrayPool() -> Void { #endif } +@_expose(wasm, "bjs_getSharedSwiftSubject") +@_cdecl("bjs_getSharedSwiftSubject") +public func _bjs_getSharedSwiftSubject() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = getSharedSwiftSubject() + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _SwiftIdentityTestSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _SwiftIdentityTestSubject_freeIds.popLast() { + id = recycled + } else { + id = _SwiftIdentityTestSubject_nextId + _SwiftIdentityTestSubject_nextId += 1 + _SwiftIdentityTestSubject_wrapperRefs.append(0) + } + _SwiftIdentityTestSubject_identityTable[ptr] = id + _SwiftIdentityTestSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetSharedSwiftSubject") +@_cdecl("bjs_resetSharedSwiftSubject") +public func _bjs_resetSharedSwiftSubject() -> Void { + #if arch(wasm32) + resetSharedSwiftSubject() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getRetainLeakSubjectSwift") +@_cdecl("bjs_getRetainLeakSubjectSwift") +public func _bjs_getRetainLeakSubjectSwift() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = getRetainLeakSubjectSwift() + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _SwiftRetainLeakSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _SwiftRetainLeakSubject_freeIds.popLast() { + id = recycled + } else { + id = _SwiftRetainLeakSubject_nextId + _SwiftRetainLeakSubject_nextId += 1 + _SwiftRetainLeakSubject_wrapperRefs.append(0) + } + _SwiftRetainLeakSubject_identityTable[ptr] = id + _SwiftRetainLeakSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetRetainLeakSubjectSwift") +@_cdecl("bjs_resetRetainLeakSubjectSwift") +public func _bjs_resetRetainLeakSubjectSwift() -> Void { + #if arch(wasm32) + resetRetainLeakSubjectSwift() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getRetainLeakDeinitsSwift") +@_cdecl("bjs_getRetainLeakDeinitsSwift") +public func _bjs_getRetainLeakDeinitsSwift() -> Int32 { + #if arch(wasm32) + let ret = getRetainLeakDeinitsSwift() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetRetainLeakDeinitsSwift") +@_cdecl("bjs_resetRetainLeakDeinitsSwift") +public func _bjs_resetRetainLeakDeinitsSwift() -> Void { + #if arch(wasm32) + resetRetainLeakDeinitsSwift() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getSwiftNextIdForSharedSubject") +@_cdecl("bjs_getSwiftNextIdForSharedSubject") +public func _bjs_getSwiftNextIdForSharedSubject() -> Int32 { + #if arch(wasm32) + let ret = getSwiftNextIdForSharedSubject() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeSwiftIdentityArray") +@_cdecl("bjs_makeSwiftIdentityArray") +public func _bjs_makeSwiftIdentityArray(_ a: UnsafeMutableRawPointer, _ b: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = makeSwiftIdentityArray(_: SwiftIdentityTestSubject.bridgeJSLiftParameter(a), _: SwiftIdentityTestSubject.bridgeJSLiftParameter(b)) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_maybeSwiftSubject") +@_cdecl("bjs_maybeSwiftSubject") +public func _bjs_maybeSwiftSubject(_ present: Int32) -> Void { + #if arch(wasm32) + let ret = maybeSwiftSubject(_: Bool.bridgeJSLiftParameter(present)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getSwiftNextIdForChurn") +@_cdecl("bjs_getSwiftNextIdForChurn") +public func _bjs_getSwiftNextIdForChurn() -> Int32 { + #if arch(wasm32) + let ret = getSwiftNextIdForChurn() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + @_expose(wasm, "bjs_IdentityTestSubject_init") @_cdecl("bjs_IdentityTestSubject_init") public func _bjs_IdentityTestSubject_init(_ value: Int32) -> UnsafeMutableRawPointer { @@ -333,6 +484,506 @@ fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableR return _bjs_ArrayIdentityElement_wrap_extern(pointer) } +nonisolated(unsafe) var _SwiftIdentityTestSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] + +nonisolated(unsafe) var _SwiftIdentityTestSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] + +nonisolated(unsafe) var _SwiftIdentityTestSubject_wrapperRefs: [Int32] = [] + +nonisolated(unsafe) var _SwiftIdentityTestSubject_freeIds: [Int32] = [] + +nonisolated(unsafe) var _SwiftIdentityTestSubject_nextId: Int32 = 0 + +@_expose(wasm, "bjs_SwiftIdentityTestSubject_init") +@_cdecl("bjs_SwiftIdentityTestSubject_init") +public func _bjs_SwiftIdentityTestSubject_init(_ value: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = SwiftIdentityTestSubject(value: Int.bridgeJSLiftParameter(value)) + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _SwiftIdentityTestSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _SwiftIdentityTestSubject_freeIds.popLast() { + id = recycled + } else { + id = _SwiftIdentityTestSubject_nextId + _SwiftIdentityTestSubject_nextId += 1 + _SwiftIdentityTestSubject_wrapperRefs.append(0) + } + _SwiftIdentityTestSubject_identityTable[ptr] = id + _SwiftIdentityTestSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftIdentityTestSubject_self_") +@_cdecl("bjs_SwiftIdentityTestSubject_self_") +public func _bjs_SwiftIdentityTestSubject_self_(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = SwiftIdentityTestSubject.bridgeJSLiftParameter(_self).self_() + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _SwiftIdentityTestSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _SwiftIdentityTestSubject_freeIds.popLast() { + id = recycled + } else { + id = _SwiftIdentityTestSubject_nextId + _SwiftIdentityTestSubject_nextId += 1 + _SwiftIdentityTestSubject_wrapperRefs.append(0) + } + _SwiftIdentityTestSubject_identityTable[ptr] = id + _SwiftIdentityTestSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftIdentityTestSubject_value_get") +@_cdecl("bjs_SwiftIdentityTestSubject_value_get") +public func _bjs_SwiftIdentityTestSubject_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SwiftIdentityTestSubject.bridgeJSLiftParameter(_self).value + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftIdentityTestSubject_value_set") +@_cdecl("bjs_SwiftIdentityTestSubject_value_set") +public func _bjs_SwiftIdentityTestSubject_value_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + SwiftIdentityTestSubject.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftIdentityTestSubject_currentValue_get") +@_cdecl("bjs_SwiftIdentityTestSubject_currentValue_get") +public func _bjs_SwiftIdentityTestSubject_currentValue_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SwiftIdentityTestSubject.bridgeJSLiftParameter(_self).currentValue + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftIdentityTestSubject_deinit") +@_cdecl("bjs_SwiftIdentityTestSubject_deinit") +public func _bjs_SwiftIdentityTestSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftIdentityTestSubject_register_wrapper") +@_cdecl("bjs_SwiftIdentityTestSubject_register_wrapper") +public func _bjs_SwiftIdentityTestSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { + #if arch(wasm32) + _SwiftIdentityTestSubject_wrapperRefs[Int(id)] = jsRef + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftIdentityTestSubject_release_wrapper") +@_cdecl("bjs_SwiftIdentityTestSubject_release_wrapper") +public func _bjs_SwiftIdentityTestSubject_release_wrapper(_ id: Int32) -> Void { + #if arch(wasm32) + let slot = Int(id) + let jsRef = _SwiftIdentityTestSubject_wrapperRefs[slot] + guard jsRef != 0 else { return } + _SwiftIdentityTestSubject_wrapperRefs[slot] = 0 + if let ptr = _SwiftIdentityTestSubject_idToPointer.removeValue(forKey: id) { + _SwiftIdentityTestSubject_identityTable.removeValue(forKey: ptr) + Unmanaged.fromOpaque(ptr).release() + } + _SwiftIdentityTestSubject_freeIds.append(id) + _swift_js_release_ref(jsRef) + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension SwiftIdentityTestSubject { + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if let id = _SwiftIdentityTestSubject_identityTable[ptr] { + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(self) + let id: Int32 + if let recycled = _SwiftIdentityTestSubject_freeIds.popLast() { + id = recycled + } else { + id = _SwiftIdentityTestSubject_nextId + _SwiftIdentityTestSubject_nextId += 1 + _SwiftIdentityTestSubject_wrapperRefs.append(0) + } + _SwiftIdentityTestSubject_identityTable[ptr] = id + _SwiftIdentityTestSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + _swift_js_push_pointer(ptr) + } +} + +extension SwiftIdentityTestSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_SwiftIdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_SwiftIdentityTestSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSIdentityTests", name: "bjs_SwiftIdentityTestSubject_wrap") +fileprivate func _bjs_SwiftIdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_SwiftIdentityTestSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_SwiftIdentityTestSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_SwiftIdentityTestSubject_wrap_extern(pointer) +} + +nonisolated(unsafe) var _SwiftRetainLeakSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] + +nonisolated(unsafe) var _SwiftRetainLeakSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] + +nonisolated(unsafe) var _SwiftRetainLeakSubject_wrapperRefs: [Int32] = [] + +nonisolated(unsafe) var _SwiftRetainLeakSubject_freeIds: [Int32] = [] + +nonisolated(unsafe) var _SwiftRetainLeakSubject_nextId: Int32 = 0 + +@_expose(wasm, "bjs_SwiftRetainLeakSubject_init") +@_cdecl("bjs_SwiftRetainLeakSubject_init") +public func _bjs_SwiftRetainLeakSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = SwiftRetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _SwiftRetainLeakSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _SwiftRetainLeakSubject_freeIds.popLast() { + id = recycled + } else { + id = _SwiftRetainLeakSubject_nextId + _SwiftRetainLeakSubject_nextId += 1 + _SwiftRetainLeakSubject_wrapperRefs.append(0) + } + _SwiftRetainLeakSubject_identityTable[ptr] = id + _SwiftRetainLeakSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftRetainLeakSubject_tag_get") +@_cdecl("bjs_SwiftRetainLeakSubject_tag_get") +public func _bjs_SwiftRetainLeakSubject_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SwiftRetainLeakSubject.bridgeJSLiftParameter(_self).tag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftRetainLeakSubject_tag_set") +@_cdecl("bjs_SwiftRetainLeakSubject_tag_set") +public func _bjs_SwiftRetainLeakSubject_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + SwiftRetainLeakSubject.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftRetainLeakSubject_deinit") +@_cdecl("bjs_SwiftRetainLeakSubject_deinit") +public func _bjs_SwiftRetainLeakSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftRetainLeakSubject_register_wrapper") +@_cdecl("bjs_SwiftRetainLeakSubject_register_wrapper") +public func _bjs_SwiftRetainLeakSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { + #if arch(wasm32) + _SwiftRetainLeakSubject_wrapperRefs[Int(id)] = jsRef + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftRetainLeakSubject_release_wrapper") +@_cdecl("bjs_SwiftRetainLeakSubject_release_wrapper") +public func _bjs_SwiftRetainLeakSubject_release_wrapper(_ id: Int32) -> Void { + #if arch(wasm32) + let slot = Int(id) + let jsRef = _SwiftRetainLeakSubject_wrapperRefs[slot] + guard jsRef != 0 else { return } + _SwiftRetainLeakSubject_wrapperRefs[slot] = 0 + if let ptr = _SwiftRetainLeakSubject_idToPointer.removeValue(forKey: id) { + _SwiftRetainLeakSubject_identityTable.removeValue(forKey: ptr) + Unmanaged.fromOpaque(ptr).release() + } + _SwiftRetainLeakSubject_freeIds.append(id) + _swift_js_release_ref(jsRef) + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension SwiftRetainLeakSubject { + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if let id = _SwiftRetainLeakSubject_identityTable[ptr] { + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(self) + let id: Int32 + if let recycled = _SwiftRetainLeakSubject_freeIds.popLast() { + id = recycled + } else { + id = _SwiftRetainLeakSubject_nextId + _SwiftRetainLeakSubject_nextId += 1 + _SwiftRetainLeakSubject_wrapperRefs.append(0) + } + _SwiftRetainLeakSubject_identityTable[ptr] = id + _SwiftRetainLeakSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + _swift_js_push_pointer(ptr) + } +} + +extension SwiftRetainLeakSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_SwiftRetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_SwiftRetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSIdentityTests", name: "bjs_SwiftRetainLeakSubject_wrap") +fileprivate func _bjs_SwiftRetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_SwiftRetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_SwiftRetainLeakSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_SwiftRetainLeakSubject_wrap_extern(pointer) +} + +nonisolated(unsafe) var _SwiftChurnSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] + +nonisolated(unsafe) var _SwiftChurnSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] + +nonisolated(unsafe) var _SwiftChurnSubject_wrapperRefs: [Int32] = [] + +nonisolated(unsafe) var _SwiftChurnSubject_freeIds: [Int32] = [] + +nonisolated(unsafe) var _SwiftChurnSubject_nextId: Int32 = 0 + +@_expose(wasm, "bjs_SwiftChurnSubject_init") +@_cdecl("bjs_SwiftChurnSubject_init") +public func _bjs_SwiftChurnSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = SwiftChurnSubject(tag: Int.bridgeJSLiftParameter(tag)) + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _SwiftChurnSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _SwiftChurnSubject_freeIds.popLast() { + id = recycled + } else { + id = _SwiftChurnSubject_nextId + _SwiftChurnSubject_nextId += 1 + _SwiftChurnSubject_wrapperRefs.append(0) + } + _SwiftChurnSubject_identityTable[ptr] = id + _SwiftChurnSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftChurnSubject_tag_get") +@_cdecl("bjs_SwiftChurnSubject_tag_get") +public func _bjs_SwiftChurnSubject_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = SwiftChurnSubject.bridgeJSLiftParameter(_self).tag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftChurnSubject_tag_set") +@_cdecl("bjs_SwiftChurnSubject_tag_set") +public func _bjs_SwiftChurnSubject_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + SwiftChurnSubject.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftChurnSubject_deinit") +@_cdecl("bjs_SwiftChurnSubject_deinit") +public func _bjs_SwiftChurnSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftChurnSubject_register_wrapper") +@_cdecl("bjs_SwiftChurnSubject_register_wrapper") +public func _bjs_SwiftChurnSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { + #if arch(wasm32) + _SwiftChurnSubject_wrapperRefs[Int(id)] = jsRef + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_SwiftChurnSubject_release_wrapper") +@_cdecl("bjs_SwiftChurnSubject_release_wrapper") +public func _bjs_SwiftChurnSubject_release_wrapper(_ id: Int32) -> Void { + #if arch(wasm32) + let slot = Int(id) + let jsRef = _SwiftChurnSubject_wrapperRefs[slot] + guard jsRef != 0 else { return } + _SwiftChurnSubject_wrapperRefs[slot] = 0 + if let ptr = _SwiftChurnSubject_idToPointer.removeValue(forKey: id) { + _SwiftChurnSubject_identityTable.removeValue(forKey: ptr) + Unmanaged.fromOpaque(ptr).release() + } + _SwiftChurnSubject_freeIds.append(id) + _swift_js_release_ref(jsRef) + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension SwiftChurnSubject { + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if let id = _SwiftChurnSubject_identityTable[ptr] { + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(self) + let id: Int32 + if let recycled = _SwiftChurnSubject_freeIds.popLast() { + id = recycled + } else { + id = _SwiftChurnSubject_nextId + _SwiftChurnSubject_nextId += 1 + _SwiftChurnSubject_wrapperRefs.append(0) + } + _SwiftChurnSubject_identityTable[ptr] = id + _SwiftChurnSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + _swift_js_push_pointer(ptr) + } +} + +extension SwiftChurnSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_SwiftChurnSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_SwiftChurnSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSIdentityTests", name: "bjs_SwiftChurnSubject_wrap") +fileprivate func _bjs_SwiftChurnSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_SwiftChurnSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_SwiftChurnSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_SwiftChurnSubject_wrap_extern(pointer) +} + #if arch(wasm32) @_extern(wasm, module: "BridgeJSIdentityTests", name: "bjs_IdentityModeTestImports_runJsIdentityModeTests_static") fileprivate func bjs_IdentityModeTestImports_runJsIdentityModeTests_static_extern() -> Void diff --git a/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json index d30ca00f8..4757b84c2 100644 --- a/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json @@ -145,6 +145,170 @@ } ], "swiftCallName" : "ArrayIdentityElement" + }, + { + "constructor" : { + "abiName" : "bjs_SwiftIdentityTestSubject_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "identityMode" : "swift", + "methods" : [ + { + "abiName" : "bjs_SwiftIdentityTestSubject_self_", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "self_", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "SwiftIdentityTestSubject" + } + } + } + ], + "name" : "SwiftIdentityTestSubject", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "currentValue", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "SwiftIdentityTestSubject" + }, + { + "constructor" : { + "abiName" : "bjs_SwiftRetainLeakSubject_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "tag", + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "identityMode" : "swift", + "methods" : [ + + ], + "name" : "SwiftRetainLeakSubject", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "SwiftRetainLeakSubject" + }, + { + "constructor" : { + "abiName" : "bjs_SwiftChurnSubject_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "tag", + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "identityMode" : "swift", + "methods" : [ + + ], + "name" : "SwiftChurnSubject", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "SwiftChurnSubject" } ], "enums" : [ @@ -392,6 +556,219 @@ } } + }, + { + "abiName" : "bjs_getSharedSwiftSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getSharedSwiftSubject", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "SwiftIdentityTestSubject" + } + } + }, + { + "abiName" : "bjs_resetSharedSwiftSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetSharedSwiftSubject", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getRetainLeakSubjectSwift", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getRetainLeakSubjectSwift", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "SwiftRetainLeakSubject" + } + } + }, + { + "abiName" : "bjs_resetRetainLeakSubjectSwift", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetRetainLeakSubjectSwift", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getRetainLeakDeinitsSwift", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getRetainLeakDeinitsSwift", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_resetRetainLeakDeinitsSwift", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetRetainLeakDeinitsSwift", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getSwiftNextIdForSharedSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getSwiftNextIdForSharedSubject", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_makeSwiftIdentityArray", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeSwiftIdentityArray", + "parameters" : [ + { + "label" : "_", + "name" : "a", + "type" : { + "swiftHeapObject" : { + "_0" : "SwiftIdentityTestSubject" + } + } + }, + { + "label" : "_", + "name" : "b", + "type" : { + "swiftHeapObject" : { + "_0" : "SwiftIdentityTestSubject" + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "SwiftIdentityTestSubject" + } + } + } + } + }, + { + "abiName" : "bjs_maybeSwiftSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "maybeSwiftSubject", + "parameters" : [ + { + "label" : "_", + "name" : "present", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "SwiftIdentityTestSubject" + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_getSwiftNextIdForChurn", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getSwiftNextIdForChurn", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } } ], "identityMode" : "pointer", diff --git a/Tests/BridgeJSIdentityTests/IdentityModeTests.swift b/Tests/BridgeJSIdentityTests/IdentityModeTests.swift index 795b0679b..2f92c1a3a 100644 --- a/Tests/BridgeJSIdentityTests/IdentityModeTests.swift +++ b/Tests/BridgeJSIdentityTests/IdentityModeTests.swift @@ -111,3 +111,117 @@ nonisolated(unsafe) private var _arrayPool: [ArrayIdentityElement] = [] @JS func clearArrayPool() { _arrayPool = [] } + +// MARK: - identityMode: .swift per-class opt-in (coexists with .pointer classes above) +// +// These classes explicitly opt INTO Swift-owned identity caching. The target's +// bridge-js.config.json default is "pointer", so the existing classes above stay +// on the pointer path; adding these .swift classes verifies mode coexistence. +// See Docs/superpowers/specs/2026-04-21-swift-side-identity-cache-design.md §5, §6.2. + +@JS(identityMode: .swift) class SwiftIdentityTestSubject { + @JS var value: Int + + @JS init(value: Int) { + self.value = value + } + + @JS var currentValue: Int { value } + + @JS func self_() -> SwiftIdentityTestSubject { self } +} + +nonisolated(unsafe) private var _sharedSwiftSubject: SwiftIdentityTestSubject? + +@JS func getSharedSwiftSubject() -> SwiftIdentityTestSubject { + if _sharedSwiftSubject == nil { + _sharedSwiftSubject = SwiftIdentityTestSubject(value: 42) + } + return _sharedSwiftSubject! +} + +@JS func resetSharedSwiftSubject() { + _sharedSwiftSubject = nil +} + +// Deinit counter used for scenario (b) "explicit release frees heap object" +// and scenario (c) "double release is idempotent". +@JS(identityMode: .swift) class SwiftRetainLeakSubject { + nonisolated(unsafe) static var deinits: Int = 0 + + @JS var tag: Int + + @JS init(tag: Int) { + self.tag = tag + } + + deinit { + Self.deinits += 1 + } +} + +nonisolated(unsafe) private var _swiftRetainLeakSubject: SwiftRetainLeakSubject? + +@JS func getRetainLeakSubjectSwift() -> SwiftRetainLeakSubject { + if _swiftRetainLeakSubject == nil { + _swiftRetainLeakSubject = SwiftRetainLeakSubject(tag: 1) + } + return _swiftRetainLeakSubject! +} + +@JS func resetRetainLeakSubjectSwift() { + _swiftRetainLeakSubject = nil +} + +@JS func getRetainLeakDeinitsSwift() -> Int { + SwiftRetainLeakSubject.deinits +} + +@JS func resetRetainLeakDeinitsSwift() { + SwiftRetainLeakSubject.deinits = 0 +} + +// Scenario (d): id-recycling introspection. +// +// Gated behind `ENABLE_TEST_INTROSPECTION` so the debug-only getter does not +// become part of the public test surface (or, worse, add codegen weight to +// release binaries). The test target defines this flag in its swiftSettings. +#if ENABLE_TEST_INTROSPECTION +@JS func getSwiftNextIdForSharedSubject() -> Int { + Int(_SwiftIdentityTestSubject_nextId) +} +#endif + +// Scenario (e): array returns — Swift returns `[a, b, a]` so JS can assert +// `result[0] === result[2]` preserves identity across array elements. +@JS func makeSwiftIdentityArray( + _ a: SwiftIdentityTestSubject, + _ b: SwiftIdentityTestSubject +) -> [SwiftIdentityTestSubject] { + return [a, b, a] +} + +// Scenario (h): optional identity — `.some(x)` returns cached wrapper, `.none` +// returns null. +@JS func maybeSwiftSubject(_ present: Bool) -> SwiftIdentityTestSubject? { + if _sharedSwiftSubject == nil { + _sharedSwiftSubject = SwiftIdentityTestSubject(value: 99) + } + return present ? _sharedSwiftSubject : nil +} + +// Scenario (d) support: a dedicated "churn" class so id-recycling assertions +// are not perturbed by the shared-subject lifetime used in (a), (f), (h). +@JS(identityMode: .swift) class SwiftChurnSubject { + @JS var tag: Int + + @JS init(tag: Int) { + self.tag = tag + } +} + +#if ENABLE_TEST_INTROSPECTION +@JS func getSwiftNextIdForChurn() -> Int { + Int(_SwiftChurnSubject_nextId) +} +#endif diff --git a/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs b/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs index b2ae2187d..f38c39817 100644 --- a/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs +++ b/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs @@ -28,6 +28,22 @@ function runIdentityModeTests(exports) { testArrayElementIdentity(exports); testArrayElementMatchesSingleGetter(exports); testArrayRetainLeak(exports); + + // identityMode: .swift per-class tests (Task 5 Part A). + // + // These exercise the Swift-owned identity cache in coexistence with the + // pointer-mode classes above. Each function is self-contained (resets + // state, releases wrappers) so tests stay independent. + testSwiftModeIdentity(exports); + testSwiftModeSelfMethodIdentity(exports); + testSwiftModeReleaseFreesHeapObject(exports); + testSwiftModeDoubleReleaseIdempotent(exports); + testSwiftModeIdRecycling(exports); + testSwiftModeArrayCrossElementIdentity(exports); + testSwiftModeGcSurvivability(exports); + testSwiftModeOptionalIdentity(exports); + testSwiftModeReleaseGuardsMembers(exports); + testModeCoexistence(exports); } /** @@ -198,3 +214,312 @@ function testDifferentClassesDontCollide(exports) { subject1.release(); subject2.release(); } + +// ========================================================================= +// identityMode: .swift — per-class opt-in tests (Task 5 Part A) +// +// These tests exercise classes annotated with `@JS(identityMode: .swift)` in +// Tests/BridgeJSIdentityTests/IdentityModeTests.swift. The target's config +// default is "pointer" so any `.swift` annotation is an explicit opt-in. +// ========================================================================= + +/** + * (a) Identity on re-export. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testSwiftModeIdentity(exports) { + exports.resetSharedSwiftSubject(); + const a = exports.getSharedSwiftSubject(); + const b = exports.getSharedSwiftSubject(); + const c = exports.getSharedSwiftSubject(); + + assert.strictEqual(a, b, "swift mode: same Swift object returns same wrapper"); + assert.strictEqual(b, c, "swift mode: identity is transitive across re-exports"); + assert.equal(a.currentValue, 42); + assert.equal(typeof a.__swiftIdentityId, "number"); + + a.release(); + exports.resetSharedSwiftSubject(); +} + +/** + * (a') Method returning `self` preserves identity. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testSwiftModeSelfMethodIdentity(exports) { + exports.resetSharedSwiftSubject(); + const a = exports.getSharedSwiftSubject(); + const viaSelf = a.self_(); + + assert.strictEqual( + a, + viaSelf, + "swift mode: `self_()` must return the same JS wrapper (identity preserved across method boundary)", + ); + + a.release(); + exports.resetSharedSwiftSubject(); +} + +/** + * (b) Explicit release frees the underlying Swift heap object. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testSwiftModeReleaseFreesHeapObject(exports) { + exports.resetRetainLeakDeinitsSwift(); + exports.resetRetainLeakSubjectSwift(); + + const obj = exports.getRetainLeakSubjectSwift(); + // Drop the only Swift-side strong reference so the sole remaining anchor + // is Swift's retain on the heap object performed during the fresh-wrap path. + exports.resetRetainLeakSubjectSwift(); + obj.release(); + + assert.strictEqual( + exports.getRetainLeakDeinitsSwift(), + 1, + "swift mode: release must invoke Swift deinit exactly once (check bjs__release_wrapper fires Unmanaged.release)", + ); +} + +/** + * (c) Double-release is idempotent. No crash, no over-release. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testSwiftModeDoubleReleaseIdempotent(exports) { + exports.resetRetainLeakDeinitsSwift(); + exports.resetRetainLeakSubjectSwift(); + + const obj = exports.getRetainLeakSubjectSwift(); + exports.resetRetainLeakSubjectSwift(); + + obj.release(); + // Second release must be a no-op guarded by __swiftIdentityHasReleased. + obj.release(); + obj.release(); + + assert.strictEqual( + exports.getRetainLeakDeinitsSwift(), + 1, + "swift mode: double-release must not deinit twice", + ); +} + +/** + * (d) Id recycling — nextId does not grow past the pool size. + * + * Uses the dedicated SwiftChurnSubject class so this assertion is not + * perturbed by id allocations performed by other tests. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testSwiftModeIdRecycling(exports) { + if (typeof exports.getSwiftNextIdForChurn !== "function") { + // ENABLE_TEST_INTROSPECTION not set — skip silently. + return; + } + + const POOL = 10; + const first = []; + for (let i = 0; i < POOL; i++) { + first.push(new exports.SwiftChurnSubject(i)); + } + const peakAfterFirst = exports.getSwiftNextIdForChurn(); + + for (const obj of first) { + obj.release(); + } + + const second = []; + for (let i = 0; i < POOL; i++) { + second.push(new exports.SwiftChurnSubject(100 + i)); + } + const peakAfterSecond = exports.getSwiftNextIdForChurn(); + + assert.strictEqual( + peakAfterSecond, + peakAfterFirst, + `swift mode: id recycling failed — nextId grew from ${peakAfterFirst} to ${peakAfterSecond} despite ${POOL} freed ids in between`, + ); + + for (const obj of second) { + obj.release(); + } +} + +/** + * (e) Array of the same wrapper preserves cross-element identity. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testSwiftModeArrayCrossElementIdentity(exports) { + const a = new exports.SwiftIdentityTestSubject(1); + const b = new exports.SwiftIdentityTestSubject(2); + + const result = exports.makeSwiftIdentityArray(a, b); + assert.equal(result.length, 3); + + assert.strictEqual(result[0], a, "swift mode: array element 0 === original a"); + assert.strictEqual(result[1], b, "swift mode: array element 1 === original b"); + assert.strictEqual(result[2], a, "swift mode: array element 2 === original a"); + assert.strictEqual(result[0], result[2], "swift mode: cross-element identity"); + + a.release(); + b.release(); +} + +/** + * (f) GC survivability — wrapper survives forced GC because Swift holds a + * strong JS ref via `swift.memory.retain`. + * + * Requires node to be launched with `--expose-gc`. `make unittest` does so + * (see Makefile:22). Guarded so we don't fail in environments that don't. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testSwiftModeGcSurvivability(exports) { + if (typeof globalThis.gc !== "function") { + console.warn("Skipping swift-mode GC test — run with --expose-gc"); + return; + } + + exports.resetSharedSwiftSubject(); + let obj = exports.getSharedSwiftSubject(); + const idBefore = obj.__swiftIdentityId; + const weakProbe = new WeakRef(obj); + + // Drop the local reference and force GC twice with a microtask flush in + // between (V8 sometimes needs two cycles to collect newly-unreferenced + // objects). + obj = null; + globalThis.gc(); + // synchronous setImmediate-equivalent flush + const flush = () => + new Promise((resolve) => { + if (typeof setImmediate === "function") { + setImmediate(resolve); + } else { + setTimeout(resolve, 0); + } + }); + // Note: we can't await here (caller is synchronous). For a sync harness, + // run gc twice back-to-back — that's sufficient under V8's two-phase + // collector for this test's purposes. + globalThis.gc(); + + // Re-fetch from Swift. The wrapper must still be === to whatever deref + // yields (since Swift's retain on the JS ref keeps it alive). + const again = exports.getSharedSwiftSubject(); + assert.strictEqual( + again.__swiftIdentityId, + idBefore, + "swift mode: id must be stable across GC (Swift still retains the heap object)", + ); + assert.strictEqual( + weakProbe.deref(), + again, + "swift mode: wrapper survived GC — Swift retain kept it alive", + ); + + again.release(); + exports.resetSharedSwiftSubject(); + + // Suppress "unused" warning for the async helper (kept around in case + // future refactors make this test async). + void flush; +} + +/** + * (h) Optional identity — `.some(x)` returns a valid wrapper; `.none` → null. + * + * v1 LIMITATION (see DECISIONS.md D16): the scalar Optional + * return path does NOT preserve `===` identity. `.some(x)` returns a fresh JS + * wrapper each time because the Optional bridge calls the default + * `_BridgedSwiftHeapObject.bridgeJSLowerReturn` (passRetained + pointer) + * rather than the per-class identity-cache handshake. Lifecycle is still + * correct; only the strong-cache invariant is relaxed for this specific + * return type. A follow-up can emit a per-class `bridgeJSLowerReturn` + * override to fix this. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testSwiftModeOptionalIdentity(exports) { + exports.resetSharedSwiftSubject(); + const direct = exports.getSharedSwiftSubject(); + const viaOptional = exports.maybeSwiftSubject(true); + + // v1: only verify the call works and the value is observable — NOT `===`. + assert.ok( + viaOptional != null, + "swift mode: Optional.some returns a wrapper (v1: identity not preserved — see D16)", + ); + assert.equal( + viaOptional.currentValue, + direct.currentValue, + "swift mode: Optional.some wrapper observes the same underlying value", + ); + + const absent = exports.maybeSwiftSubject(false); + assert.strictEqual(absent, null, "swift mode: Optional.none returns null"); + + // The extra wrapper from viaOptional needs its own release since it's + // a fresh id (v1 limitation). + viaOptional.release(); + direct.release(); + exports.resetSharedSwiftSubject(); +} + +/** + * Released wrappers guard instance members (throws on use-after-release). + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testSwiftModeReleaseGuardsMembers(exports) { + exports.resetSharedSwiftSubject(); + const obj = exports.getSharedSwiftSubject(); + obj.release(); + + assert.throws( + () => obj.currentValue, + /released|Attempted to call a member/, + "swift mode: use-after-release must throw", + ); + + exports.resetSharedSwiftSubject(); +} + +/** + * (i) Mode coexistence — .swift class and .pointer class in the same build, + * disjoint tables. + * + * The target's config default is "pointer", so IdentityTestSubject (no + * per-class annotation) is a pointer-mode class. SwiftIdentityTestSubject is + * explicitly .swift. Both must work simultaneously and their identity + * machinery must not leak between classes. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testModeCoexistence(exports) { + const ptr1 = new exports.IdentityTestSubject(10); // pointer-mode + const ptr2 = new exports.IdentityTestSubject(20); + const swift1 = new exports.SwiftIdentityTestSubject(30); // swift-mode + const swift2 = new exports.SwiftIdentityTestSubject(40); + + assert.notStrictEqual(ptr1, swift1); + assert.notStrictEqual(ptr2, swift2); + assert.equal(ptr1.currentValue, 10); + assert.equal(swift1.currentValue, 30); + + // Pointer-mode exposes no __swiftIdentityId; swift-mode does. + assert.equal(typeof swift1.__swiftIdentityId, "number"); + assert.equal(typeof ptr1.__swiftIdentityId, "undefined"); + + ptr1.release(); + ptr2.release(); + swift1.release(); + swift2.release(); +} diff --git a/Tests/BridgeJSIdentityTests/SwiftIdentityIntrinsicsTests.swift b/Tests/BridgeJSIdentityTests/SwiftIdentityIntrinsicsTests.swift new file mode 100644 index 000000000..adf5d23ee --- /dev/null +++ b/Tests/BridgeJSIdentityTests/SwiftIdentityIntrinsicsTests.swift @@ -0,0 +1,17 @@ +import XCTest +@_spi(BridgeJS) import JavaScriptKit + +final class SwiftIdentityIntrinsicsTests: XCTestCase { + func testPushPopIdFreshBitPair() throws { + #if arch(wasm32) + // Swift pushes id=42 then freshBit=1; pops in LIFO order: + // first pop = freshBit, second pop = id. + _swift_js_push_i32(42) + _swift_js_push_i32(1) + XCTAssertEqual(_swift_js_pop_i32(), 1) // freshBit + XCTAssertEqual(_swift_js_pop_i32(), 42) // id + #else + throw XCTSkip("Stack intrinsics are wasm32-only") + #endif + } +} diff --git a/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift new file mode 100644 index 000000000..10396ec0c --- /dev/null +++ b/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift @@ -0,0 +1,667 @@ +// bridge-js: skip +// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit, +// DO NOT EDIT. +// +// To update this file, just rebuild your project or run +// `swift package bridge-js`. + +@_spi(BridgeJS) import JavaScriptKit + +@_expose(wasm, "bjs_getConfigSwiftSubject") +@_cdecl("bjs_getConfigSwiftSubject") +public func _bjs_getConfigSwiftSubject() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = getConfigSwiftSubject() + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _ConfigSwiftSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _ConfigSwiftSubject_freeIds.popLast() { + id = recycled + } else { + id = _ConfigSwiftSubject_nextId + _ConfigSwiftSubject_nextId += 1 + _ConfigSwiftSubject_wrapperRefs.append(0) + } + _ConfigSwiftSubject_identityTable[ptr] = id + _ConfigSwiftSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetConfigSwiftSubject") +@_cdecl("bjs_resetConfigSwiftSubject") +public func _bjs_resetConfigSwiftSubject() -> Void { + #if arch(wasm32) + resetConfigSwiftSubject() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getConfigSwiftRetainLeakSubject") +@_cdecl("bjs_getConfigSwiftRetainLeakSubject") +public func _bjs_getConfigSwiftRetainLeakSubject() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = getConfigSwiftRetainLeakSubject() + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _ConfigSwiftRetainLeakSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _ConfigSwiftRetainLeakSubject_freeIds.popLast() { + id = recycled + } else { + id = _ConfigSwiftRetainLeakSubject_nextId + _ConfigSwiftRetainLeakSubject_nextId += 1 + _ConfigSwiftRetainLeakSubject_wrapperRefs.append(0) + } + _ConfigSwiftRetainLeakSubject_identityTable[ptr] = id + _ConfigSwiftRetainLeakSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetConfigSwiftRetainLeakSubject") +@_cdecl("bjs_resetConfigSwiftRetainLeakSubject") +public func _bjs_resetConfigSwiftRetainLeakSubject() -> Void { + #if arch(wasm32) + resetConfigSwiftRetainLeakSubject() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getConfigSwiftRetainLeakDeinits") +@_cdecl("bjs_getConfigSwiftRetainLeakDeinits") +public func _bjs_getConfigSwiftRetainLeakDeinits() -> Int32 { + #if arch(wasm32) + let ret = getConfigSwiftRetainLeakDeinits() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_resetConfigSwiftRetainLeakDeinits") +@_cdecl("bjs_resetConfigSwiftRetainLeakDeinits") +public func _bjs_resetConfigSwiftRetainLeakDeinits() -> Void { + #if arch(wasm32) + resetConfigSwiftRetainLeakDeinits() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_getConfigSwiftNextIdForChurn") +@_cdecl("bjs_getConfigSwiftNextIdForChurn") +public func _bjs_getConfigSwiftNextIdForChurn() -> Int32 { + #if arch(wasm32) + let ret = getConfigSwiftNextIdForChurn() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeConfigSwiftArray") +@_cdecl("bjs_makeConfigSwiftArray") +public func _bjs_makeConfigSwiftArray(_ a: UnsafeMutableRawPointer, _ b: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = makeConfigSwiftArray(_: ConfigSwiftSubject.bridgeJSLiftParameter(a), _: ConfigSwiftSubject.bridgeJSLiftParameter(b)) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_maybeConfigSwiftSubject") +@_cdecl("bjs_maybeConfigSwiftSubject") +public func _bjs_maybeConfigSwiftSubject(_ present: Int32) -> Void { + #if arch(wasm32) + let ret = maybeConfigSwiftSubject(_: Bool.bridgeJSLiftParameter(present)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +nonisolated(unsafe) var _ConfigSwiftSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] + +nonisolated(unsafe) var _ConfigSwiftSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] + +nonisolated(unsafe) var _ConfigSwiftSubject_wrapperRefs: [Int32] = [] + +nonisolated(unsafe) var _ConfigSwiftSubject_freeIds: [Int32] = [] + +nonisolated(unsafe) var _ConfigSwiftSubject_nextId: Int32 = 0 + +@_expose(wasm, "bjs_ConfigSwiftSubject_init") +@_cdecl("bjs_ConfigSwiftSubject_init") +public func _bjs_ConfigSwiftSubject_init(_ value: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ConfigSwiftSubject(value: Int.bridgeJSLiftParameter(value)) + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _ConfigSwiftSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _ConfigSwiftSubject_freeIds.popLast() { + id = recycled + } else { + id = _ConfigSwiftSubject_nextId + _ConfigSwiftSubject_nextId += 1 + _ConfigSwiftSubject_wrapperRefs.append(0) + } + _ConfigSwiftSubject_identityTable[ptr] = id + _ConfigSwiftSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftSubject_self_") +@_cdecl("bjs_ConfigSwiftSubject_self_") +public func _bjs_ConfigSwiftSubject_self_(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ConfigSwiftSubject.bridgeJSLiftParameter(_self).self_() + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _ConfigSwiftSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _ConfigSwiftSubject_freeIds.popLast() { + id = recycled + } else { + id = _ConfigSwiftSubject_nextId + _ConfigSwiftSubject_nextId += 1 + _ConfigSwiftSubject_wrapperRefs.append(0) + } + _ConfigSwiftSubject_identityTable[ptr] = id + _ConfigSwiftSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftSubject_value_get") +@_cdecl("bjs_ConfigSwiftSubject_value_get") +public func _bjs_ConfigSwiftSubject_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = ConfigSwiftSubject.bridgeJSLiftParameter(_self).value + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftSubject_value_set") +@_cdecl("bjs_ConfigSwiftSubject_value_set") +public func _bjs_ConfigSwiftSubject_value_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + ConfigSwiftSubject.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftSubject_currentValue_get") +@_cdecl("bjs_ConfigSwiftSubject_currentValue_get") +public func _bjs_ConfigSwiftSubject_currentValue_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = ConfigSwiftSubject.bridgeJSLiftParameter(_self).currentValue + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftSubject_deinit") +@_cdecl("bjs_ConfigSwiftSubject_deinit") +public func _bjs_ConfigSwiftSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftSubject_register_wrapper") +@_cdecl("bjs_ConfigSwiftSubject_register_wrapper") +public func _bjs_ConfigSwiftSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { + #if arch(wasm32) + _ConfigSwiftSubject_wrapperRefs[Int(id)] = jsRef + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftSubject_release_wrapper") +@_cdecl("bjs_ConfigSwiftSubject_release_wrapper") +public func _bjs_ConfigSwiftSubject_release_wrapper(_ id: Int32) -> Void { + #if arch(wasm32) + let slot = Int(id) + let jsRef = _ConfigSwiftSubject_wrapperRefs[slot] + guard jsRef != 0 else { return } + _ConfigSwiftSubject_wrapperRefs[slot] = 0 + if let ptr = _ConfigSwiftSubject_idToPointer.removeValue(forKey: id) { + _ConfigSwiftSubject_identityTable.removeValue(forKey: ptr) + Unmanaged.fromOpaque(ptr).release() + } + _ConfigSwiftSubject_freeIds.append(id) + _swift_js_release_ref(jsRef) + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ConfigSwiftSubject { + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if let id = _ConfigSwiftSubject_identityTable[ptr] { + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(self) + let id: Int32 + if let recycled = _ConfigSwiftSubject_freeIds.popLast() { + id = recycled + } else { + id = _ConfigSwiftSubject_nextId + _ConfigSwiftSubject_nextId += 1 + _ConfigSwiftSubject_wrapperRefs.append(0) + } + _ConfigSwiftSubject_identityTable[ptr] = id + _ConfigSwiftSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + _swift_js_push_pointer(ptr) + } +} + +extension ConfigSwiftSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ConfigSwiftSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ConfigSwiftSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSSwiftIdentityTests", name: "bjs_ConfigSwiftSubject_wrap") +fileprivate func _bjs_ConfigSwiftSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ConfigSwiftSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ConfigSwiftSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ConfigSwiftSubject_wrap_extern(pointer) +} + +nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] + +nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] + +nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_wrapperRefs: [Int32] = [] + +nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_freeIds: [Int32] = [] + +nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_nextId: Int32 = 0 + +@_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_init") +@_cdecl("bjs_ConfigSwiftRetainLeakSubject_init") +public func _bjs_ConfigSwiftRetainLeakSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ConfigSwiftRetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _ConfigSwiftRetainLeakSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _ConfigSwiftRetainLeakSubject_freeIds.popLast() { + id = recycled + } else { + id = _ConfigSwiftRetainLeakSubject_nextId + _ConfigSwiftRetainLeakSubject_nextId += 1 + _ConfigSwiftRetainLeakSubject_wrapperRefs.append(0) + } + _ConfigSwiftRetainLeakSubject_identityTable[ptr] = id + _ConfigSwiftRetainLeakSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_tag_get") +@_cdecl("bjs_ConfigSwiftRetainLeakSubject_tag_get") +public func _bjs_ConfigSwiftRetainLeakSubject_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = ConfigSwiftRetainLeakSubject.bridgeJSLiftParameter(_self).tag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_tag_set") +@_cdecl("bjs_ConfigSwiftRetainLeakSubject_tag_set") +public func _bjs_ConfigSwiftRetainLeakSubject_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + ConfigSwiftRetainLeakSubject.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_deinit") +@_cdecl("bjs_ConfigSwiftRetainLeakSubject_deinit") +public func _bjs_ConfigSwiftRetainLeakSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_register_wrapper") +@_cdecl("bjs_ConfigSwiftRetainLeakSubject_register_wrapper") +public func _bjs_ConfigSwiftRetainLeakSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { + #if arch(wasm32) + _ConfigSwiftRetainLeakSubject_wrapperRefs[Int(id)] = jsRef + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_release_wrapper") +@_cdecl("bjs_ConfigSwiftRetainLeakSubject_release_wrapper") +public func _bjs_ConfigSwiftRetainLeakSubject_release_wrapper(_ id: Int32) -> Void { + #if arch(wasm32) + let slot = Int(id) + let jsRef = _ConfigSwiftRetainLeakSubject_wrapperRefs[slot] + guard jsRef != 0 else { return } + _ConfigSwiftRetainLeakSubject_wrapperRefs[slot] = 0 + if let ptr = _ConfigSwiftRetainLeakSubject_idToPointer.removeValue(forKey: id) { + _ConfigSwiftRetainLeakSubject_identityTable.removeValue(forKey: ptr) + Unmanaged.fromOpaque(ptr).release() + } + _ConfigSwiftRetainLeakSubject_freeIds.append(id) + _swift_js_release_ref(jsRef) + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ConfigSwiftRetainLeakSubject { + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if let id = _ConfigSwiftRetainLeakSubject_identityTable[ptr] { + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(self) + let id: Int32 + if let recycled = _ConfigSwiftRetainLeakSubject_freeIds.popLast() { + id = recycled + } else { + id = _ConfigSwiftRetainLeakSubject_nextId + _ConfigSwiftRetainLeakSubject_nextId += 1 + _ConfigSwiftRetainLeakSubject_wrapperRefs.append(0) + } + _ConfigSwiftRetainLeakSubject_identityTable[ptr] = id + _ConfigSwiftRetainLeakSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + _swift_js_push_pointer(ptr) + } +} + +extension ConfigSwiftRetainLeakSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ConfigSwiftRetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ConfigSwiftRetainLeakSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSSwiftIdentityTests", name: "bjs_ConfigSwiftRetainLeakSubject_wrap") +fileprivate func _bjs_ConfigSwiftRetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ConfigSwiftRetainLeakSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ConfigSwiftRetainLeakSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ConfigSwiftRetainLeakSubject_wrap_extern(pointer) +} + +nonisolated(unsafe) var _ConfigSwiftChurnSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] + +nonisolated(unsafe) var _ConfigSwiftChurnSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] + +nonisolated(unsafe) var _ConfigSwiftChurnSubject_wrapperRefs: [Int32] = [] + +nonisolated(unsafe) var _ConfigSwiftChurnSubject_freeIds: [Int32] = [] + +nonisolated(unsafe) var _ConfigSwiftChurnSubject_nextId: Int32 = 0 + +@_expose(wasm, "bjs_ConfigSwiftChurnSubject_init") +@_cdecl("bjs_ConfigSwiftChurnSubject_init") +public func _bjs_ConfigSwiftChurnSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ConfigSwiftChurnSubject(tag: Int.bridgeJSLiftParameter(tag)) + return withExtendedLifetime(ret) { + let ptr = Unmanaged.passUnretained(ret).toOpaque() + if let id = _ConfigSwiftChurnSubject_identityTable[ptr] { + // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(ret) + let id: Int32 + if let recycled = _ConfigSwiftChurnSubject_freeIds.popLast() { + id = recycled + } else { + id = _ConfigSwiftChurnSubject_nextId + _ConfigSwiftChurnSubject_nextId += 1 + _ConfigSwiftChurnSubject_wrapperRefs.append(0) + } + _ConfigSwiftChurnSubject_identityTable[ptr] = id + _ConfigSwiftChurnSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftChurnSubject_tag_get") +@_cdecl("bjs_ConfigSwiftChurnSubject_tag_get") +public func _bjs_ConfigSwiftChurnSubject_tag_get(_ _self: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = ConfigSwiftChurnSubject.bridgeJSLiftParameter(_self).tag + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftChurnSubject_tag_set") +@_cdecl("bjs_ConfigSwiftChurnSubject_tag_set") +public func _bjs_ConfigSwiftChurnSubject_tag_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { + #if arch(wasm32) + ConfigSwiftChurnSubject.bridgeJSLiftParameter(_self).tag = Int.bridgeJSLiftParameter(value) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftChurnSubject_deinit") +@_cdecl("bjs_ConfigSwiftChurnSubject_deinit") +public func _bjs_ConfigSwiftChurnSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftChurnSubject_register_wrapper") +@_cdecl("bjs_ConfigSwiftChurnSubject_register_wrapper") +public func _bjs_ConfigSwiftChurnSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { + #if arch(wasm32) + _ConfigSwiftChurnSubject_wrapperRefs[Int(id)] = jsRef + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ConfigSwiftChurnSubject_release_wrapper") +@_cdecl("bjs_ConfigSwiftChurnSubject_release_wrapper") +public func _bjs_ConfigSwiftChurnSubject_release_wrapper(_ id: Int32) -> Void { + #if arch(wasm32) + let slot = Int(id) + let jsRef = _ConfigSwiftChurnSubject_wrapperRefs[slot] + guard jsRef != 0 else { return } + _ConfigSwiftChurnSubject_wrapperRefs[slot] = 0 + if let ptr = _ConfigSwiftChurnSubject_idToPointer.removeValue(forKey: id) { + _ConfigSwiftChurnSubject_identityTable.removeValue(forKey: ptr) + Unmanaged.fromOpaque(ptr).release() + } + _ConfigSwiftChurnSubject_freeIds.append(id) + _swift_js_release_ref(jsRef) + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ConfigSwiftChurnSubject { + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if let id = _ConfigSwiftChurnSubject_identityTable[ptr] { + _swift_js_push_i32(id) + _swift_js_push_i32(0) + return ptr + } + _ = Unmanaged.passRetained(self) + let id: Int32 + if let recycled = _ConfigSwiftChurnSubject_freeIds.popLast() { + id = recycled + } else { + id = _ConfigSwiftChurnSubject_nextId + _ConfigSwiftChurnSubject_nextId += 1 + _ConfigSwiftChurnSubject_wrapperRefs.append(0) + } + _ConfigSwiftChurnSubject_identityTable[ptr] = id + _ConfigSwiftChurnSubject_idToPointer[id] = ptr + _swift_js_push_i32(id) + _swift_js_push_i32(1) + return ptr + } + _swift_js_push_pointer(ptr) + } +} + +extension ConfigSwiftChurnSubject: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ConfigSwiftChurnSubject_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ConfigSwiftChurnSubject_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSSwiftIdentityTests", name: "bjs_ConfigSwiftChurnSubject_wrap") +fileprivate func _bjs_ConfigSwiftChurnSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ConfigSwiftChurnSubject_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ConfigSwiftChurnSubject_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ConfigSwiftChurnSubject_wrap_extern(pointer) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSSwiftIdentityTests", name: "bjs_SwiftIdentityModeTestImports_runJsSwiftIdentityModeTests_static") +fileprivate func bjs_SwiftIdentityModeTestImports_runJsSwiftIdentityModeTests_static_extern() -> Void +#else +fileprivate func bjs_SwiftIdentityModeTestImports_runJsSwiftIdentityModeTests_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_SwiftIdentityModeTestImports_runJsSwiftIdentityModeTests_static() -> Void { + return bjs_SwiftIdentityModeTestImports_runJsSwiftIdentityModeTests_static_extern() +} + +func _$SwiftIdentityModeTestImports_runJsSwiftIdentityModeTests() throws(JSException) -> Void { + bjs_SwiftIdentityModeTestImports_runJsSwiftIdentityModeTests_static() + if let error = _swift_js_take_exception() { + throw error + } +} \ No newline at end of file diff --git a/Tests/BridgeJSSwiftIdentityTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSSwiftIdentityTests/Generated/JavaScript/BridgeJS.json new file mode 100644 index 000000000..7849a5e5c --- /dev/null +++ b/Tests/BridgeJSSwiftIdentityTests/Generated/JavaScript/BridgeJS.json @@ -0,0 +1,415 @@ +{ + "exported" : { + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_ConfigSwiftSubject_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_ConfigSwiftSubject_self_", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "self_", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "ConfigSwiftSubject" + } + } + } + ], + "name" : "ConfigSwiftSubject", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "currentValue", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "ConfigSwiftSubject" + }, + { + "constructor" : { + "abiName" : "bjs_ConfigSwiftRetainLeakSubject_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "tag", + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "ConfigSwiftRetainLeakSubject", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "ConfigSwiftRetainLeakSubject" + }, + { + "constructor" : { + "abiName" : "bjs_ConfigSwiftChurnSubject_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "tag", + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "ConfigSwiftChurnSubject", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "ConfigSwiftChurnSubject" + } + ], + "enums" : [ + + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_getConfigSwiftSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getConfigSwiftSubject", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "ConfigSwiftSubject" + } + } + }, + { + "abiName" : "bjs_resetConfigSwiftSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetConfigSwiftSubject", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getConfigSwiftRetainLeakSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getConfigSwiftRetainLeakSubject", + "parameters" : [ + + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "ConfigSwiftRetainLeakSubject" + } + } + }, + { + "abiName" : "bjs_resetConfigSwiftRetainLeakSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetConfigSwiftRetainLeakSubject", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getConfigSwiftRetainLeakDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getConfigSwiftRetainLeakDeinits", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_resetConfigSwiftRetainLeakDeinits", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "resetConfigSwiftRetainLeakDeinits", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_getConfigSwiftNextIdForChurn", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "getConfigSwiftNextIdForChurn", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_makeConfigSwiftArray", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeConfigSwiftArray", + "parameters" : [ + { + "label" : "_", + "name" : "a", + "type" : { + "swiftHeapObject" : { + "_0" : "ConfigSwiftSubject" + } + } + }, + { + "label" : "_", + "name" : "b", + "type" : { + "swiftHeapObject" : { + "_0" : "ConfigSwiftSubject" + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "ConfigSwiftSubject" + } + } + } + } + }, + { + "abiName" : "bjs_maybeConfigSwiftSubject", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "maybeConfigSwiftSubject", + "parameters" : [ + { + "label" : "_", + "name" : "present", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "ConfigSwiftSubject" + } + }, + "_1" : "null" + } + } + } + ], + "identityMode" : "swift", + "protocols" : [ + + ], + "structs" : [ + + ] + }, + "imported" : { + "children" : [ + { + "functions" : [ + + ], + "types" : [ + { + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "SwiftIdentityModeTestImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsSwiftIdentityModeTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + } + ] + }, + "moduleName" : "BridgeJSSwiftIdentityTests" +} \ No newline at end of file diff --git a/Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs b/Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs new file mode 100644 index 000000000..99b5fc6d1 --- /dev/null +++ b/Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs @@ -0,0 +1,263 @@ +// @ts-check + +// Config-default identity mode test harness (Task 5 Part B). +// +// Parallel of Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs, +// but every @JS class in the companion Swift file has NO per-class +// identityMode argument — the `"swift"` mode is inherited from the target's +// bridge-js.config.json. We reuse the same assertions as Part A minus the +// mode-coexistence scenario (only one mode is active in this target). + +import assert from "node:assert"; + +/** + * @returns {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Imports["SwiftIdentityModeTestImports"]} + */ +export function getImports(importsContext) { + return { + runJsSwiftIdentityModeTests: () => { + const exports = importsContext.getExports(); + if (!exports) { + throw new Error("No exports!?"); + } + runSwiftIdentityModeTests(exports); + }, + }; +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runSwiftIdentityModeTests(exports) { + testConfigSwiftIdentity(exports); + testConfigSwiftSelfMethodIdentity(exports); + testConfigSwiftReleaseFreesHeapObject(exports); + testConfigSwiftDoubleReleaseIdempotent(exports); + testConfigSwiftIdRecycling(exports); + testConfigSwiftArrayCrossElementIdentity(exports); + testConfigSwiftGcSurvivability(exports); + testConfigSwiftOptionalIdentity(exports); + testConfigSwiftReleaseGuardsMembers(exports); +} + +/** + * (a) Identity on re-export (config-default swift mode). + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testConfigSwiftIdentity(exports) { + exports.resetConfigSwiftSubject(); + const a = exports.getConfigSwiftSubject(); + const b = exports.getConfigSwiftSubject(); + const c = exports.getConfigSwiftSubject(); + + assert.strictEqual(a, b, "config-swift: re-export identity"); + assert.strictEqual(b, c, "config-swift: re-export identity transitive"); + assert.equal(a.currentValue, 7); + assert.equal( + typeof a.__swiftIdentityId, + "number", + "config-default `swift` mode should emit __swiftIdentityId — verify BridgeJSLink.shouldUseSwiftIdentityCache picks up the config", + ); + + a.release(); + exports.resetConfigSwiftSubject(); +} + +/** + * (a') Method returning self preserves identity. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testConfigSwiftSelfMethodIdentity(exports) { + exports.resetConfigSwiftSubject(); + const a = exports.getConfigSwiftSubject(); + const viaSelf = a.self_(); + assert.strictEqual(a, viaSelf, "config-swift: self_() preserves identity"); + + a.release(); + exports.resetConfigSwiftSubject(); +} + +/** + * (b) Explicit release frees underlying Swift heap object. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testConfigSwiftReleaseFreesHeapObject(exports) { + exports.resetConfigSwiftRetainLeakDeinits(); + exports.resetConfigSwiftRetainLeakSubject(); + + const obj = exports.getConfigSwiftRetainLeakSubject(); + exports.resetConfigSwiftRetainLeakSubject(); + obj.release(); + + assert.strictEqual( + exports.getConfigSwiftRetainLeakDeinits(), + 1, + "config-swift: release must deinit exactly once", + ); +} + +/** + * (c) Double-release is idempotent. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testConfigSwiftDoubleReleaseIdempotent(exports) { + exports.resetConfigSwiftRetainLeakDeinits(); + exports.resetConfigSwiftRetainLeakSubject(); + + const obj = exports.getConfigSwiftRetainLeakSubject(); + exports.resetConfigSwiftRetainLeakSubject(); + + obj.release(); + obj.release(); + obj.release(); + + assert.strictEqual( + exports.getConfigSwiftRetainLeakDeinits(), + 1, + "config-swift: double-release must not deinit twice", + ); +} + +/** + * (d) Id recycling — nextId does not grow past the pool size. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testConfigSwiftIdRecycling(exports) { + if (typeof exports.getConfigSwiftNextIdForChurn !== "function") { + return; // ENABLE_TEST_INTROSPECTION not defined + } + + const POOL = 10; + const first = []; + for (let i = 0; i < POOL; i++) { + first.push(new exports.ConfigSwiftChurnSubject(i)); + } + const peakAfterFirst = exports.getConfigSwiftNextIdForChurn(); + + for (const o of first) o.release(); + + const second = []; + for (let i = 0; i < POOL; i++) { + second.push(new exports.ConfigSwiftChurnSubject(100 + i)); + } + const peakAfterSecond = exports.getConfigSwiftNextIdForChurn(); + + assert.strictEqual( + peakAfterSecond, + peakAfterFirst, + `config-swift: id recycling failed — nextId grew from ${peakAfterFirst} to ${peakAfterSecond}`, + ); + + for (const o of second) o.release(); +} + +/** + * (e) Array returns preserve cross-element identity. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testConfigSwiftArrayCrossElementIdentity(exports) { + const a = new exports.ConfigSwiftSubject(1); + const b = new exports.ConfigSwiftSubject(2); + + const result = exports.makeConfigSwiftArray(a, b); + assert.equal(result.length, 3); + + assert.strictEqual(result[0], a); + assert.strictEqual(result[1], b); + assert.strictEqual(result[2], a); + assert.strictEqual(result[0], result[2], "config-swift: cross-element identity"); + + a.release(); + b.release(); +} + +/** + * (f) GC survivability. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testConfigSwiftGcSurvivability(exports) { + if (typeof globalThis.gc !== "function") { + console.warn("Skipping config-swift GC test — run with --expose-gc"); + return; + } + + exports.resetConfigSwiftSubject(); + let obj = exports.getConfigSwiftSubject(); + const idBefore = obj.__swiftIdentityId; + const weakProbe = new WeakRef(obj); + + obj = null; + globalThis.gc(); + globalThis.gc(); + + const again = exports.getConfigSwiftSubject(); + assert.strictEqual( + again.__swiftIdentityId, + idBefore, + "config-swift: id stable across GC", + ); + assert.strictEqual( + weakProbe.deref(), + again, + "config-swift: wrapper survived GC — Swift retain kept it alive", + ); + + again.release(); + exports.resetConfigSwiftSubject(); +} + +/** + * (h) Optional identity. + * + * v1 LIMITATION (see DECISIONS.md D16): `.some(x)` returns a fresh wrapper — + * the scalar-Optional path bypasses the identity cache. Lifecycle is still + * correct. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testConfigSwiftOptionalIdentity(exports) { + exports.resetConfigSwiftSubject(); + const direct = exports.getConfigSwiftSubject(); + const viaOptional = exports.maybeConfigSwiftSubject(true); + + // v1: only verify the call works (see D16 — identity not preserved for Optional). + assert.ok(viaOptional != null, "config-swift: Optional.some returns a wrapper"); + assert.equal( + viaOptional.currentValue, + direct.currentValue, + "config-swift: Optional.some wrapper observes the same value", + ); + + const absent = exports.maybeConfigSwiftSubject(false); + assert.strictEqual(absent, null, "config-swift: Optional.none returns null"); + + viaOptional.release(); + direct.release(); + exports.resetConfigSwiftSubject(); +} + +/** + * Released wrappers guard instance members. + * + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function testConfigSwiftReleaseGuardsMembers(exports) { + exports.resetConfigSwiftSubject(); + const obj = exports.getConfigSwiftSubject(); + obj.release(); + + assert.throws( + () => obj.currentValue, + /released|Attempted to call a member/, + "config-swift: use-after-release must throw", + ); + + exports.resetConfigSwiftSubject(); +} diff --git a/Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift b/Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift new file mode 100644 index 000000000..80c45d5f2 --- /dev/null +++ b/Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift @@ -0,0 +1,116 @@ +import XCTest +import JavaScriptKit + +// Config-default identity mode test target. +// +// The target's bridge-js.config.json sets `"identityMode": "swift"`. Every +// `@JS class` in this file OMITS the per-class `identityMode:` argument so +// we exercise the config-default resolution path in +// `ExportSwift.isSwiftIdentityMode` / `BridgeJSLink.shouldUseSwiftIdentityCache`. +// +// See Docs/superpowers/specs/2026-04-21-swift-side-identity-cache-design.md §3.2 +// and plan Task 5 Part B. + +@JSClass struct SwiftIdentityModeTestImports { + @JSFunction static func runJsSwiftIdentityModeTests() throws(JSException) +} + +final class SwiftIdentityModeTests: XCTestCase { + func testRunJsSwiftIdentityModeTests() throws { + try SwiftIdentityModeTestImports.runJsSwiftIdentityModeTests() + } +} + +// NOTE: No `identityMode:` argument — inherits "swift" from bridge-js.config.json. +@JS class ConfigSwiftSubject { + @JS var value: Int + + @JS init(value: Int) { + self.value = value + } + + @JS var currentValue: Int { value } + + @JS func self_() -> ConfigSwiftSubject { self } +} + +nonisolated(unsafe) private var _configSwiftSubject: ConfigSwiftSubject? + +@JS func getConfigSwiftSubject() -> ConfigSwiftSubject { + if _configSwiftSubject == nil { + _configSwiftSubject = ConfigSwiftSubject(value: 7) + } + return _configSwiftSubject! +} + +@JS func resetConfigSwiftSubject() { + _configSwiftSubject = nil +} + +// Dedicated class with a deinit counter for scenarios (b), (c). +@JS class ConfigSwiftRetainLeakSubject { + nonisolated(unsafe) static var deinits: Int = 0 + + @JS var tag: Int + + @JS init(tag: Int) { + self.tag = tag + } + + deinit { + Self.deinits += 1 + } +} + +nonisolated(unsafe) private var _configSwiftRetainLeakSubject: ConfigSwiftRetainLeakSubject? + +@JS func getConfigSwiftRetainLeakSubject() -> ConfigSwiftRetainLeakSubject { + if _configSwiftRetainLeakSubject == nil { + _configSwiftRetainLeakSubject = ConfigSwiftRetainLeakSubject(tag: 1) + } + return _configSwiftRetainLeakSubject! +} + +@JS func resetConfigSwiftRetainLeakSubject() { + _configSwiftRetainLeakSubject = nil +} + +@JS func getConfigSwiftRetainLeakDeinits() -> Int { + ConfigSwiftRetainLeakSubject.deinits +} + +@JS func resetConfigSwiftRetainLeakDeinits() { + ConfigSwiftRetainLeakSubject.deinits = 0 +} + +// Scenario (d): dedicated churn class + introspection getter gated behind +// ENABLE_TEST_INTROSPECTION so it is not part of the public test surface. +@JS class ConfigSwiftChurnSubject { + @JS var tag: Int + + @JS init(tag: Int) { + self.tag = tag + } +} + +#if ENABLE_TEST_INTROSPECTION +@JS func getConfigSwiftNextIdForChurn() -> Int { + Int(_ConfigSwiftChurnSubject_nextId) +} +#endif + +// Scenario (e): array returns preserving cross-element identity. +@JS func makeConfigSwiftArray( + _ a: ConfigSwiftSubject, + _ b: ConfigSwiftSubject +) -> [ConfigSwiftSubject] { + return [a, b, a] +} + +// Scenario (h): optional identity. +@JS func maybeConfigSwiftSubject(_ present: Bool) -> ConfigSwiftSubject? { + if _configSwiftSubject == nil { + _configSwiftSubject = ConfigSwiftSubject(value: 99) + } + return present ? _configSwiftSubject : nil +} diff --git a/Tests/BridgeJSSwiftIdentityTests/bridge-js.config.json b/Tests/BridgeJSSwiftIdentityTests/bridge-js.config.json new file mode 100644 index 000000000..310d6b0f5 --- /dev/null +++ b/Tests/BridgeJSSwiftIdentityTests/bridge-js.config.json @@ -0,0 +1,3 @@ +{ + "identityMode": "swift" +} diff --git a/Tests/prelude.mjs b/Tests/prelude.mjs index 79c0cc740..714e94638 100644 --- a/Tests/prelude.mjs +++ b/Tests/prelude.mjs @@ -15,6 +15,7 @@ import { getImports as getJSClassSupportImports, JSClassWithArrayMembers } from import { getImports as getIntegerTypesSupportImports } from './BridgeJSRuntimeTests/JavaScript/IntegerTypesSupportTests.mjs'; import { getImports as getAsyncImportImports, runAsyncWorksTests } from './BridgeJSRuntimeTests/JavaScript/AsyncImportTests.mjs'; import { getImports as getIdentityModeTestImports } from './BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs'; +import { getImports as getSwiftIdentityModeTestImports } from './BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs'; /** @type {import('../.build/plugins/PackageToJS/outputs/PackageTests/test.d.ts').SetupOptionsFn} */ export async function setupOptions(options, context) { @@ -158,6 +159,7 @@ export async function setupOptions(options, context) { JSClassSupportImports: getJSClassSupportImports(importsContext), IntegerTypesSupportImports: getIntegerTypesSupportImports(importsContext), IdentityModeTestImports: getIdentityModeTestImports(importsContext), + SwiftIdentityModeTestImports: getSwiftIdentityModeTestImports(importsContext), }; }, addToCoreImports(importObject, importsContext) { diff --git a/Utilities/bridge-js-generate.sh b/Utilities/bridge-js-generate.sh index 77bdd0833..6dae0e472 100755 --- a/Utilities/bridge-js-generate.sh +++ b/Utilities/bridge-js-generate.sh @@ -7,5 +7,6 @@ swift build --package-path ./Plugins/BridgeJS --product BridgeJSTool ./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name BridgeJSRuntimeTests --target-dir ./Tests/BridgeJSRuntimeTests --output-dir ./Tests/BridgeJSRuntimeTests/Generated ./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name BridgeJSGlobalTests --target-dir ./Tests/BridgeJSGlobalTests --output-dir ./Tests/BridgeJSGlobalTests/Generated ./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name BridgeJSIdentityTests --target-dir ./Tests/BridgeJSIdentityTests --output-dir ./Tests/BridgeJSIdentityTests/Generated +./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name BridgeJSSwiftIdentityTests --target-dir ./Tests/BridgeJSSwiftIdentityTests --output-dir ./Tests/BridgeJSSwiftIdentityTests/Generated ./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name Benchmarks --target-dir ./Benchmarks/Sources --output-dir ./Benchmarks/Sources/Generated ./Plugins/BridgeJS/.build/debug/BridgeJSTool generate --project ./tsconfig.json --module-name PlayBridgeJS --target-dir ./Examples/PlayBridgeJS/Sources/PlayBridgeJS --output-dir ./Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated From cb04d8c5dd5cebf4d897d6010399cfbc15053f19 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Wed, 22 Apr 2026 14:28:48 +0200 Subject: [PATCH 15/18] =?UTF-8?q?refactor:=20simplify=20identity=20cache?= =?UTF-8?q?=20=E2=80=94=20drop=20compact=20id,=20key=20by=20pointer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The initial implementation used a Swift-assigned compact Int32 id so that JS could index a dense Array. In isolation Array[i] is ~2x faster than Map.get (194ns vs 98ns for 1M integer-keyed lookups), but end-to-end benchmarks never surfaced that win — the swift-mode hit path came in at parity with pointer mode regardless. Meanwhile the id machinery carried real cost: five per-class globals, id allocation + recycling, reverse lookup dictionary, two i32 push/pop pairs per return. Swift per-class state: 5 globals → 2 _identityTable: [ptr:id] → Set _idToPointer: [id:ptr] → removed _wrapperRefs: [Int32] → [ptr:Int32] _freeIds → removed _nextId → removed JS per-class cache: Array[id] → Map Stack pushes per return: 2 (id, freshBit) → 1 (freshBit) Wasm exports: register_wrapper / release_wrapper now take pointer ABI contract, === semantics, and lifetime guarantees are unchanged. Performance impact (500k iters, median ms, swift mode only): v1 v2 delta passBothWaysRoundtrip 33 28 -15% getPoolRepeated_100 41 34 -17% swiftCreatesObject 846 592 -30% churnObjects 456 438 -4% Simpler code runs faster; the id-allocation + reverse-dict upkeep was net negative. 165/165 tests green. --- Benchmarks/Sources/Generated/BridgeJS.swift | 214 ++++----------- .../Sources/BridgeJSCore/ExportSwift.swift | 112 +++----- .../Sources/BridgeJSLink/BridgeJSLink.swift | 35 ++- .../IdentityModeSwiftClass.swift | 60 +---- .../IdentityModeClass.ConfigSwift.js | 16 +- .../IdentityModeSwiftClass.js | 16 +- .../Generated/BridgeJS.swift | 253 ++++-------------- .../Generated/JavaScript/BridgeJS.json | 8 +- .../IdentityModeTests.swift | 15 +- .../JavaScript/IdentityModeTests.mjs | 48 ++-- .../Generated/BridgeJS.swift | 239 ++++------------- .../Generated/JavaScript/BridgeJS.json | 4 +- .../JavaScript/SwiftIdentityModeTests.mjs | 34 ++- .../SwiftIdentityModeTests.swift | 4 +- 14 files changed, 292 insertions(+), 766 deletions(-) diff --git a/Benchmarks/Sources/Generated/BridgeJS.swift b/Benchmarks/Sources/Generated/BridgeJS.swift index 99b20581e..0f05eb466 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.swift @@ -1815,15 +1815,9 @@ fileprivate func _bjs_IdentityCacheBenchmarkIdentity_wrap_extern(_ pointer: Unsa return _bjs_IdentityCacheBenchmarkIdentity_wrap_extern(pointer) } -nonisolated(unsafe) var _SimpleClassSwiftIdentity_identityTable: [UnsafeMutableRawPointer: Int32] = [:] +nonisolated(unsafe) var _SimpleClassSwiftIdentity_identityTable: Set = [] -nonisolated(unsafe) var _SimpleClassSwiftIdentity_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] - -nonisolated(unsafe) var _SimpleClassSwiftIdentity_wrapperRefs: [Int32] = [] - -nonisolated(unsafe) var _SimpleClassSwiftIdentity_freeIds: [Int32] = [] - -nonisolated(unsafe) var _SimpleClassSwiftIdentity_nextId: Int32 = 0 +nonisolated(unsafe) var _SimpleClassSwiftIdentity_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] @_expose(wasm, "bjs_SimpleClassSwiftIdentity_init") @_cdecl("bjs_SimpleClassSwiftIdentity_init") @@ -1832,24 +1826,13 @@ public func _bjs_SimpleClassSwiftIdentity_init(_ nameBytes: Int32, _ nameLength: let ret = SimpleClassSwiftIdentity(name: String.bridgeJSLiftParameter(nameBytes, nameLength), count: Int.bridgeJSLiftParameter(count), flag: Bool.bridgeJSLiftParameter(flag), rate: Float.bridgeJSLiftParameter(rate), precise: Double.bridgeJSLiftParameter(precise)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _SimpleClassSwiftIdentity_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _SimpleClassSwiftIdentity_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _SimpleClassSwiftIdentity_freeIds.popLast() { - id = recycled - } else { - id = _SimpleClassSwiftIdentity_nextId - _SimpleClassSwiftIdentity_nextId += 1 - _SimpleClassSwiftIdentity_wrapperRefs.append(0) - } - _SimpleClassSwiftIdentity_identityTable[ptr] = id - _SimpleClassSwiftIdentity_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SimpleClassSwiftIdentity_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -1975,9 +1958,9 @@ public func _bjs_SimpleClassSwiftIdentity_deinit(_ pointer: UnsafeMutableRawPoin @_expose(wasm, "bjs_SimpleClassSwiftIdentity_register_wrapper") @_cdecl("bjs_SimpleClassSwiftIdentity_register_wrapper") -public func _bjs_SimpleClassSwiftIdentity_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { +public func _bjs_SimpleClassSwiftIdentity_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { #if arch(wasm32) - _SimpleClassSwiftIdentity_wrapperRefs[Int(id)] = jsRef + _SimpleClassSwiftIdentity_wrapperRefs[pointer] = jsRef #else fatalError("Only available on WebAssembly") #endif @@ -1985,17 +1968,11 @@ public func _bjs_SimpleClassSwiftIdentity_register_wrapper(_ id: Int32, _ jsRef: @_expose(wasm, "bjs_SimpleClassSwiftIdentity_release_wrapper") @_cdecl("bjs_SimpleClassSwiftIdentity_release_wrapper") -public func _bjs_SimpleClassSwiftIdentity_release_wrapper(_ id: Int32) -> Void { +public func _bjs_SimpleClassSwiftIdentity_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let slot = Int(id) - let jsRef = _SimpleClassSwiftIdentity_wrapperRefs[slot] - guard jsRef != 0 else { return } - _SimpleClassSwiftIdentity_wrapperRefs[slot] = 0 - if let ptr = _SimpleClassSwiftIdentity_idToPointer.removeValue(forKey: id) { - _SimpleClassSwiftIdentity_identityTable.removeValue(forKey: ptr) - Unmanaged.fromOpaque(ptr).release() - } - _SimpleClassSwiftIdentity_freeIds.append(id) + guard let jsRef = _SimpleClassSwiftIdentity_wrapperRefs.removeValue(forKey: pointer) else { return } + _SimpleClassSwiftIdentity_identityTable.remove(pointer) + Unmanaged.fromOpaque(pointer).release() _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") @@ -2006,23 +1983,12 @@ extension SimpleClassSwiftIdentity { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if let id = _SimpleClassSwiftIdentity_identityTable[ptr] { - _swift_js_push_i32(id) + if _SimpleClassSwiftIdentity_identityTable.contains(ptr) { _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(self) - let id: Int32 - if let recycled = _SimpleClassSwiftIdentity_freeIds.popLast() { - id = recycled - } else { - id = _SimpleClassSwiftIdentity_nextId - _SimpleClassSwiftIdentity_nextId += 1 - _SimpleClassSwiftIdentity_wrapperRefs.append(0) - } - _SimpleClassSwiftIdentity_identityTable[ptr] = id - _SimpleClassSwiftIdentity_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SimpleClassSwiftIdentity_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -2051,15 +2017,9 @@ fileprivate func _bjs_SimpleClassSwiftIdentity_wrap_extern(_ pointer: UnsafeMuta return _bjs_SimpleClassSwiftIdentity_wrap_extern(pointer) } -nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_identityTable: [UnsafeMutableRawPointer: Int32] = [:] - -nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] - -nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_wrapperRefs: [Int32] = [] +nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_identityTable: Set = [] -nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_freeIds: [Int32] = [] - -nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_nextId: Int32 = 0 +nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] @_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_init") @_cdecl("bjs_ClassRoundtripSwiftIdentity_init") @@ -2068,24 +2028,13 @@ public func _bjs_ClassRoundtripSwiftIdentity_init() -> UnsafeMutableRawPointer { let ret = ClassRoundtripSwiftIdentity() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _ClassRoundtripSwiftIdentity_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _ClassRoundtripSwiftIdentity_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _ClassRoundtripSwiftIdentity_freeIds.popLast() { - id = recycled - } else { - id = _ClassRoundtripSwiftIdentity_nextId - _ClassRoundtripSwiftIdentity_nextId += 1 - _ClassRoundtripSwiftIdentity_wrapperRefs.append(0) - } - _ClassRoundtripSwiftIdentity_identityTable[ptr] = id - _ClassRoundtripSwiftIdentity_idToPointer[id] = ptr - _swift_js_push_i32(id) + _ClassRoundtripSwiftIdentity_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -2101,24 +2050,13 @@ public func _bjs_ClassRoundtripSwiftIdentity_roundtripSimpleClassSwiftIdentity(_ let ret = ClassRoundtripSwiftIdentity.bridgeJSLiftParameter(_self).roundtripSimpleClassSwiftIdentity(_: SimpleClassSwiftIdentity.bridgeJSLiftParameter(obj)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _SimpleClassSwiftIdentity_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _SimpleClassSwiftIdentity_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _SimpleClassSwiftIdentity_freeIds.popLast() { - id = recycled - } else { - id = _SimpleClassSwiftIdentity_nextId - _SimpleClassSwiftIdentity_nextId += 1 - _SimpleClassSwiftIdentity_wrapperRefs.append(0) - } - _SimpleClassSwiftIdentity_identityTable[ptr] = id - _SimpleClassSwiftIdentity_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SimpleClassSwiftIdentity_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -2134,24 +2072,13 @@ public func _bjs_ClassRoundtripSwiftIdentity_makeSimpleClassSwiftIdentity(_ _sel let ret = ClassRoundtripSwiftIdentity.bridgeJSLiftParameter(_self).makeSimpleClassSwiftIdentity() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _SimpleClassSwiftIdentity_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _SimpleClassSwiftIdentity_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _SimpleClassSwiftIdentity_freeIds.popLast() { - id = recycled - } else { - id = _SimpleClassSwiftIdentity_nextId - _SimpleClassSwiftIdentity_nextId += 1 - _SimpleClassSwiftIdentity_wrapperRefs.append(0) - } - _SimpleClassSwiftIdentity_identityTable[ptr] = id - _SimpleClassSwiftIdentity_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SimpleClassSwiftIdentity_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -2182,9 +2109,9 @@ public func _bjs_ClassRoundtripSwiftIdentity_deinit(_ pointer: UnsafeMutableRawP @_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_register_wrapper") @_cdecl("bjs_ClassRoundtripSwiftIdentity_register_wrapper") -public func _bjs_ClassRoundtripSwiftIdentity_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { +public func _bjs_ClassRoundtripSwiftIdentity_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { #if arch(wasm32) - _ClassRoundtripSwiftIdentity_wrapperRefs[Int(id)] = jsRef + _ClassRoundtripSwiftIdentity_wrapperRefs[pointer] = jsRef #else fatalError("Only available on WebAssembly") #endif @@ -2192,17 +2119,11 @@ public func _bjs_ClassRoundtripSwiftIdentity_register_wrapper(_ id: Int32, _ jsR @_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_release_wrapper") @_cdecl("bjs_ClassRoundtripSwiftIdentity_release_wrapper") -public func _bjs_ClassRoundtripSwiftIdentity_release_wrapper(_ id: Int32) -> Void { +public func _bjs_ClassRoundtripSwiftIdentity_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let slot = Int(id) - let jsRef = _ClassRoundtripSwiftIdentity_wrapperRefs[slot] - guard jsRef != 0 else { return } - _ClassRoundtripSwiftIdentity_wrapperRefs[slot] = 0 - if let ptr = _ClassRoundtripSwiftIdentity_idToPointer.removeValue(forKey: id) { - _ClassRoundtripSwiftIdentity_identityTable.removeValue(forKey: ptr) - Unmanaged.fromOpaque(ptr).release() - } - _ClassRoundtripSwiftIdentity_freeIds.append(id) + guard let jsRef = _ClassRoundtripSwiftIdentity_wrapperRefs.removeValue(forKey: pointer) else { return } + _ClassRoundtripSwiftIdentity_identityTable.remove(pointer) + Unmanaged.fromOpaque(pointer).release() _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") @@ -2213,23 +2134,12 @@ extension ClassRoundtripSwiftIdentity { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if let id = _ClassRoundtripSwiftIdentity_identityTable[ptr] { - _swift_js_push_i32(id) + if _ClassRoundtripSwiftIdentity_identityTable.contains(ptr) { _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(self) - let id: Int32 - if let recycled = _ClassRoundtripSwiftIdentity_freeIds.popLast() { - id = recycled - } else { - id = _ClassRoundtripSwiftIdentity_nextId - _ClassRoundtripSwiftIdentity_nextId += 1 - _ClassRoundtripSwiftIdentity_wrapperRefs.append(0) - } - _ClassRoundtripSwiftIdentity_identityTable[ptr] = id - _ClassRoundtripSwiftIdentity_idToPointer[id] = ptr - _swift_js_push_i32(id) + _ClassRoundtripSwiftIdentity_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -2258,15 +2168,9 @@ fileprivate func _bjs_ClassRoundtripSwiftIdentity_wrap_extern(_ pointer: UnsafeM return _bjs_ClassRoundtripSwiftIdentity_wrap_extern(pointer) } -nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_identityTable: [UnsafeMutableRawPointer: Int32] = [:] - -nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] - -nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs: [Int32] = [] +nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_identityTable: Set = [] -nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_freeIds: [Int32] = [] - -nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_nextId: Int32 = 0 +nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] @_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_init") @_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_init") @@ -2275,24 +2179,13 @@ public func _bjs_IdentityCacheBenchmarkSwiftIdentity_init() -> UnsafeMutableRawP let ret = IdentityCacheBenchmarkSwiftIdentity() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _IdentityCacheBenchmarkSwiftIdentity_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _IdentityCacheBenchmarkSwiftIdentity_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _IdentityCacheBenchmarkSwiftIdentity_freeIds.popLast() { - id = recycled - } else { - id = _IdentityCacheBenchmarkSwiftIdentity_nextId - _IdentityCacheBenchmarkSwiftIdentity_nextId += 1 - _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs.append(0) - } - _IdentityCacheBenchmarkSwiftIdentity_identityTable[ptr] = id - _IdentityCacheBenchmarkSwiftIdentity_idToPointer[id] = ptr - _swift_js_push_i32(id) + _IdentityCacheBenchmarkSwiftIdentity_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -2334,9 +2227,9 @@ public func _bjs_IdentityCacheBenchmarkSwiftIdentity_deinit(_ pointer: UnsafeMut @_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_register_wrapper") @_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_register_wrapper") -public func _bjs_IdentityCacheBenchmarkSwiftIdentity_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { +public func _bjs_IdentityCacheBenchmarkSwiftIdentity_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { #if arch(wasm32) - _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs[Int(id)] = jsRef + _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs[pointer] = jsRef #else fatalError("Only available on WebAssembly") #endif @@ -2344,17 +2237,11 @@ public func _bjs_IdentityCacheBenchmarkSwiftIdentity_register_wrapper(_ id: Int3 @_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_release_wrapper") @_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_release_wrapper") -public func _bjs_IdentityCacheBenchmarkSwiftIdentity_release_wrapper(_ id: Int32) -> Void { +public func _bjs_IdentityCacheBenchmarkSwiftIdentity_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let slot = Int(id) - let jsRef = _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs[slot] - guard jsRef != 0 else { return } - _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs[slot] = 0 - if let ptr = _IdentityCacheBenchmarkSwiftIdentity_idToPointer.removeValue(forKey: id) { - _IdentityCacheBenchmarkSwiftIdentity_identityTable.removeValue(forKey: ptr) - Unmanaged.fromOpaque(ptr).release() - } - _IdentityCacheBenchmarkSwiftIdentity_freeIds.append(id) + guard let jsRef = _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs.removeValue(forKey: pointer) else { return } + _IdentityCacheBenchmarkSwiftIdentity_identityTable.remove(pointer) + Unmanaged.fromOpaque(pointer).release() _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") @@ -2365,23 +2252,12 @@ extension IdentityCacheBenchmarkSwiftIdentity { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if let id = _IdentityCacheBenchmarkSwiftIdentity_identityTable[ptr] { - _swift_js_push_i32(id) + if _IdentityCacheBenchmarkSwiftIdentity_identityTable.contains(ptr) { _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(self) - let id: Int32 - if let recycled = _IdentityCacheBenchmarkSwiftIdentity_freeIds.popLast() { - id = recycled - } else { - id = _IdentityCacheBenchmarkSwiftIdentity_nextId - _IdentityCacheBenchmarkSwiftIdentity_nextId += 1 - _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs.append(0) - } - _IdentityCacheBenchmarkSwiftIdentity_identityTable[ptr] = id - _IdentityCacheBenchmarkSwiftIdentity_idToPointer[id] = ptr - _swift_js_push_i32(id) + _IdentityCacheBenchmarkSwiftIdentity_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index 257e90d87..459f979f4 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -352,35 +352,27 @@ public class ExportSwift { """ ) case .swiftHeapObject(let className) where isSwiftIdentityMode(className): - // identityMode: "swift" — Swift owns the wrapper lifetime and - // the authoritative pointer→id table. On hit, skip the - // passRetained; on miss, retain once and reserve a wrapper - // slot. JS pops (id, freshBit) from the i32 stack after the - // return pointer and either returns the cached wrapper or - // builds a fresh one and calls back via - // `bjs__register_wrapper` to install the strong JS ref. + // identityMode: "swift" — Swift tracks which pointers have + // an associated JS wrapper via a per-class Set. On hit, skip + // the passRetained; JS keeps the wrapper alive via its + // strong `Map`. On miss, retain once and + // signal freshBit=1 so JS builds the wrapper. + // + // ABI: one i32 push after the return pointer — `freshBit`. + // JS pops `freshBit` and either returns its cached wrapper + // (0) or builds a fresh one and calls `register_wrapper` to + // give Swift the retained JS ref (1). append( """ return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _\(raw: className)_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _\(raw: className)_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _\(raw: className)_freeIds.popLast() { - id = recycled - } else { - id = _\(raw: className)_nextId - _\(raw: className)_nextId += 1 - _\(raw: className)_wrapperRefs.append(0) - } - _\(raw: className)_identityTable[ptr] = id - _\(raw: className)_idToPointer[id] = ptr - _swift_js_push_i32(id) + _\(raw: className)_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -719,25 +711,19 @@ public class ExportSwift { func renderSingleExportedClass(klass: ExportedClass) throws -> [DeclSyntax] { var decls: [DeclSyntax] = [] - // identityMode: "swift" — emit the per-class Swift-owned identity cache - // state (pointer→id forward map, id→pointer reverse map for O(1) - // release, dense wrapper-ref array, free-id stack, monotonic counter). - // See Docs/superpowers/specs/2026-04-21-swift-side-identity-cache-design.md §5.1. + // identityMode: "swift" — per-class state. Simpler than the original + // id-based design: the JS-side cache is keyed directly by pointer (as + // a strong Map), so Swift only needs: + // - a Set of pointers that already have a JS wrapper + // - a Map of pointer → JS ref (so Swift can release the JS ref + // when the wrapper is released) + // See DECISIONS.md D18 for why this supersedes the 5-global design. if isSwiftIdentityMode(klass.name) { decls.append( - "nonisolated(unsafe) var _\(raw: klass.name)_identityTable: [UnsafeMutableRawPointer: Int32] = [:]" + "nonisolated(unsafe) var _\(raw: klass.name)_identityTable: Set = []" ) decls.append( - "nonisolated(unsafe) var _\(raw: klass.name)_idToPointer: [Int32: UnsafeMutableRawPointer] = [:]" - ) - decls.append( - "nonisolated(unsafe) var _\(raw: klass.name)_wrapperRefs: [Int32] = []" - ) - decls.append( - "nonisolated(unsafe) var _\(raw: klass.name)_freeIds: [Int32] = []" - ) - decls.append( - "nonisolated(unsafe) var _\(raw: klass.name)_nextId: Int32 = 0" + "nonisolated(unsafe) var _\(raw: klass.name)_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:]" ) } @@ -781,18 +767,18 @@ public class ExportSwift { } // identityMode: "swift" — emit the register/release thunks that pair - // with the JS-side fresh-wrapper handshake. See spec §5.3 and §5.4. - // Per D8.3, release uses the reverse dictionary (O(1) drop). + // with the JS-side fresh-wrapper handshake. Both thunks are keyed by + // raw pointer — no id indirection. See DECISIONS.md D18. if isSwiftIdentityMode(klass.name) { do { let registerDecl = SwiftCodePattern.buildExposedFunctionDecl( abiName: "bjs_\(klass.abiName)_register_wrapper", signature: SwiftSignatureBuilder.buildABIFunctionSignature( - abiParameters: [("id", .i32), ("jsRef", .i32)], + abiParameters: [("pointer", .pointer), ("jsRef", .i32)], returnType: nil ) ) { printer in - printer.write("_\(klass.name)_wrapperRefs[Int(id)] = jsRef") + printer.write("_\(klass.name)_wrapperRefs[pointer] = jsRef") } decls.append(DeclSyntax(registerDecl)) } @@ -801,59 +787,33 @@ public class ExportSwift { let releaseDecl = SwiftCodePattern.buildExposedFunctionDecl( abiName: "bjs_\(klass.abiName)_release_wrapper", signature: SwiftSignatureBuilder.buildABIFunctionSignature( - abiParameters: [("id", .i32)], + abiParameters: [("pointer", .pointer)], returnType: nil ) ) { printer in - printer.write("let slot = Int(id)") - printer.write("let jsRef = _\(klass.name)_wrapperRefs[slot]") - printer.write("guard jsRef != 0 else { return }") - printer.write("_\(klass.name)_wrapperRefs[slot] = 0") - printer.write("if let ptr = _\(klass.name)_idToPointer.removeValue(forKey: id) {") - printer.write(" _\(klass.name)_identityTable.removeValue(forKey: ptr)") - printer.write(" Unmanaged<\(klass.swiftCallName)>.fromOpaque(ptr).release()") - printer.write("}") - printer.write("_\(klass.name)_freeIds.append(id)") + printer.write("guard let jsRef = _\(klass.name)_wrapperRefs.removeValue(forKey: pointer) else { return }") + printer.write("_\(klass.name)_identityTable.remove(pointer)") + printer.write("Unmanaged<\(klass.swiftCallName)>.fromOpaque(pointer).release()") printer.write("_swift_js_release_ref(jsRef)") } decls.append(DeclSyntax(releaseDecl)) } - // Override the default `_BridgedSwiftHeapObject.bridgeJSStackPush` so - // array-element returns (`[SwiftCached]`) go through the same - // identity-cache handshake as scalar returns. - // - // See DECISIONS.md D15. The default in BridgeJSIntrinsics.swift just - // calls `_swift_js_push_pointer(Unmanaged.passRetained(self).toOpaque())` - // — that bypasses `__identityTable` and leaves JS's `__wrap` - // popping garbage instead of `(id, freshBit)`. - // - // Push order: `(id, freshBit)` on the i32 stack first, then the - // pointer on the pointer stack. JS pops in reverse (pointer, then - // freshBit, then id), matching how the codegen-emitted `__wrap` - // already reads them. + // Override the default `_BridgedSwiftHeapObject.bridgeJSStackPush` + // so array-element returns (`[SwiftCached]`) go through the same + // identity-cache handshake. See DECISIONS.md D15 (still applies — + // only the internals changed; D18 simplified them). let stackPushExt: DeclSyntax = """ extension \(raw: klass.swiftCallName) { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if let id = _\(raw: klass.name)_identityTable[ptr] { - _swift_js_push_i32(id) + if _\(raw: klass.name)_identityTable.contains(ptr) { _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(self) - let id: Int32 - if let recycled = _\(raw: klass.name)_freeIds.popLast() { - id = recycled - } else { - id = _\(raw: klass.name)_nextId - _\(raw: klass.name)_nextId += 1 - _\(raw: klass.name)_wrapperRefs.append(0) - } - _\(raw: klass.name)_identityTable[ptr] = id - _\(raw: klass.name)_idToPointer[id] = ptr - _swift_js_push_i32(id) + _\(raw: klass.name)_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 312479e63..4bf3ce056 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -2060,42 +2060,37 @@ extension BridgeJSLink { dtsExportEntryPrinter.write("\(klass.name): {") if useSwiftIdentity { - // Spec §6.2: a `.swift`-mode class is STANDALONE — it does NOT extend - // `SwiftHeapObject`. It owns its own dense-array wrapper cache and lifetime - // (no `FinalizationRegistry`, no `WeakRef`). Swift holds wrappers strongly - // via `__wrapperRefs`; JS clears the slot on `release()`. + // DECISIONS.md D18: the `.swift`-mode class is standalone — it does NOT + // extend `SwiftHeapObject`. It keeps a strong `Map` so + // re-exports of the same Swift pointer get the same JS wrapper. Swift + // signals "cache hit" via a single `freshBit` push on the i32 stack + // (0 = cached, 1 = fresh). No id indirection, no dense array. jsPrinter.write("class \(klass.name) {") jsPrinter.indent { - jsPrinter.write("static __swiftIdentityWrappers = [];") + jsPrinter.write("static __swiftIdentityWrappers = new Map();") jsPrinter.nextLine() jsPrinter.write("static __wrap(pointer) {") jsPrinter.indent { - // Swift pushes (id, freshBit) to the i32 stack AFTER returning the - // pointer; JS pops LIFO — freshBit first, id second. jsPrinter.write("const freshBit = bjs.swift_js_pop_i32();") - jsPrinter.write("const id = bjs.swift_js_pop_i32();") jsPrinter.write("if (freshBit === 0) {") jsPrinter.indent { - jsPrinter.write("return \(klass.name).__swiftIdentityWrappers[id];") + jsPrinter.write("return \(klass.name).__swiftIdentityWrappers.get(pointer);") } jsPrinter.write("}") jsPrinter.write("const obj = Object.create(\(klass.name).prototype);") jsPrinter.write("obj.pointer = pointer;") - jsPrinter.write("obj.__swiftIdentityId = id;") jsPrinter.write("obj.__swiftIdentityHasReleased = false;") - jsPrinter.write("\(klass.name).__swiftIdentityWrappers[id] = obj;") + jsPrinter.write("\(klass.name).__swiftIdentityWrappers.set(pointer, obj);") // Retain the wrapper in swift.memory so Swift can hold it strongly - // via `__wrapperRefs[id]` until release_wrapper fires. + // via `__wrapperRefs[pointer]` until release_wrapper fires. jsPrinter.write("const jsRef = swift.memory.retain(obj);") - jsPrinter.write("instance.exports.bjs_\(klass.abiName)_register_wrapper(id, jsRef);") + jsPrinter.write("instance.exports.bjs_\(klass.abiName)_register_wrapper(pointer, jsRef);") jsPrinter.write("return obj;") } jsPrinter.write("}") jsPrinter.nextLine() jsPrinter.write("static __construct(pointer) {") jsPrinter.indent { - // Swift's `_init` export pushed (id, freshBit) itself. `__wrap` - // pops them and returns either the cached wrapper or a fresh one. jsPrinter.write("return \(klass.name).__wrap(pointer);") } jsPrinter.write("}") @@ -2104,11 +2099,11 @@ extension BridgeJSLink { jsPrinter.indent { jsPrinter.write("if (this.__swiftIdentityHasReleased) return;") jsPrinter.write("this.__swiftIdentityHasReleased = true;") - jsPrinter.write("const id = this.__swiftIdentityId;") - jsPrinter.write("instance.exports.bjs_\(klass.abiName)_release_wrapper(id);") - // Swift's release_wrapper already called `_swift_js_release_ref(jsRef)`, - // so we just clear our JS-side slot so the id can be recycled. - jsPrinter.write("\(klass.name).__swiftIdentityWrappers[id] = undefined;") + jsPrinter.write("const pointer = this.pointer;") + jsPrinter.write("instance.exports.bjs_\(klass.abiName)_release_wrapper(pointer);") + // Swift's release_wrapper already released the JS ref; clear + // the JS-side map entry. + jsPrinter.write("\(klass.name).__swiftIdentityWrappers.delete(pointer);") } jsPrinter.write("}") } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift index 56af5bbf8..9b9579330 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift @@ -1,12 +1,6 @@ -nonisolated(unsafe) var _SwiftCached_identityTable: [UnsafeMutableRawPointer: Int32] = [:] +nonisolated(unsafe) var _SwiftCached_identityTable: Set = [] -nonisolated(unsafe) var _SwiftCached_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] - -nonisolated(unsafe) var _SwiftCached_wrapperRefs: [Int32] = [] - -nonisolated(unsafe) var _SwiftCached_freeIds: [Int32] = [] - -nonisolated(unsafe) var _SwiftCached_nextId: Int32 = 0 +nonisolated(unsafe) var _SwiftCached_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] @_expose(wasm, "bjs_SwiftCached_init") @_cdecl("bjs_SwiftCached_init") @@ -15,24 +9,13 @@ public func _bjs_SwiftCached_init(_ nameBytes: Int32, _ nameLength: Int32) -> Un let ret = SwiftCached(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _SwiftCached_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _SwiftCached_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _SwiftCached_freeIds.popLast() { - id = recycled - } else { - id = _SwiftCached_nextId - _SwiftCached_nextId += 1 - _SwiftCached_wrapperRefs.append(0) - } - _SwiftCached_identityTable[ptr] = id - _SwiftCached_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SwiftCached_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -74,9 +57,9 @@ public func _bjs_SwiftCached_deinit(_ pointer: UnsafeMutableRawPointer) -> Void @_expose(wasm, "bjs_SwiftCached_register_wrapper") @_cdecl("bjs_SwiftCached_register_wrapper") -public func _bjs_SwiftCached_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { +public func _bjs_SwiftCached_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { #if arch(wasm32) - _SwiftCached_wrapperRefs[Int(id)] = jsRef + _SwiftCached_wrapperRefs[pointer] = jsRef #else fatalError("Only available on WebAssembly") #endif @@ -84,17 +67,11 @@ public func _bjs_SwiftCached_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Vo @_expose(wasm, "bjs_SwiftCached_release_wrapper") @_cdecl("bjs_SwiftCached_release_wrapper") -public func _bjs_SwiftCached_release_wrapper(_ id: Int32) -> Void { +public func _bjs_SwiftCached_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let slot = Int(id) - let jsRef = _SwiftCached_wrapperRefs[slot] - guard jsRef != 0 else { return } - _SwiftCached_wrapperRefs[slot] = 0 - if let ptr = _SwiftCached_idToPointer.removeValue(forKey: id) { - _SwiftCached_identityTable.removeValue(forKey: ptr) - Unmanaged.fromOpaque(ptr).release() - } - _SwiftCached_freeIds.append(id) + guard let jsRef = _SwiftCached_wrapperRefs.removeValue(forKey: pointer) else { return } + _SwiftCached_identityTable.remove(pointer) + Unmanaged.fromOpaque(pointer).release() _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") @@ -105,23 +82,12 @@ extension SwiftCached { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if let id = _SwiftCached_identityTable[ptr] { - _swift_js_push_i32(id) + if _SwiftCached_identityTable.contains(ptr) { _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(self) - let id: Int32 - if let recycled = _SwiftCached_freeIds.popLast() { - id = recycled - } else { - id = _SwiftCached_nextId - _SwiftCached_nextId += 1 - _SwiftCached_wrapperRefs.append(0) - } - _SwiftCached_identityTable[ptr] = id - _SwiftCached_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SwiftCached_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js index 2bb59cb7c..5cf4f8f60 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js @@ -305,21 +305,19 @@ export async function createInstantiator(options, swift) { } } class UncachedModel { - static __swiftIdentityWrappers = []; + static __swiftIdentityWrappers = new Map(); static __wrap(pointer) { const freshBit = bjs.swift_js_pop_i32(); - const id = bjs.swift_js_pop_i32(); if (freshBit === 0) { - return UncachedModel.__swiftIdentityWrappers[id]; + return UncachedModel.__swiftIdentityWrappers.get(pointer); } const obj = Object.create(UncachedModel.prototype); obj.pointer = pointer; - obj.__swiftIdentityId = id; obj.__swiftIdentityHasReleased = false; - UncachedModel.__swiftIdentityWrappers[id] = obj; + UncachedModel.__swiftIdentityWrappers.set(pointer, obj); const jsRef = swift.memory.retain(obj); - instance.exports.bjs_UncachedModel_register_wrapper(id, jsRef); + instance.exports.bjs_UncachedModel_register_wrapper(pointer, jsRef); return obj; } @@ -330,9 +328,9 @@ export async function createInstantiator(options, swift) { release() { if (this.__swiftIdentityHasReleased) return; this.__swiftIdentityHasReleased = true; - const id = this.__swiftIdentityId; - instance.exports.bjs_UncachedModel_release_wrapper(id); - UncachedModel.__swiftIdentityWrappers[id] = undefined; + const pointer = this.pointer; + instance.exports.bjs_UncachedModel_release_wrapper(pointer); + UncachedModel.__swiftIdentityWrappers.delete(pointer); } constructor(value) { const ret = instance.exports.bjs_UncachedModel_init(value); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js index 8328f8e46..9f5ea6426 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js @@ -270,21 +270,19 @@ export async function createInstantiator(options, swift) { } } class SwiftCached { - static __swiftIdentityWrappers = []; + static __swiftIdentityWrappers = new Map(); static __wrap(pointer) { const freshBit = bjs.swift_js_pop_i32(); - const id = bjs.swift_js_pop_i32(); if (freshBit === 0) { - return SwiftCached.__swiftIdentityWrappers[id]; + return SwiftCached.__swiftIdentityWrappers.get(pointer); } const obj = Object.create(SwiftCached.prototype); obj.pointer = pointer; - obj.__swiftIdentityId = id; obj.__swiftIdentityHasReleased = false; - SwiftCached.__swiftIdentityWrappers[id] = obj; + SwiftCached.__swiftIdentityWrappers.set(pointer, obj); const jsRef = swift.memory.retain(obj); - instance.exports.bjs_SwiftCached_register_wrapper(id, jsRef); + instance.exports.bjs_SwiftCached_register_wrapper(pointer, jsRef); return obj; } @@ -295,9 +293,9 @@ export async function createInstantiator(options, swift) { release() { if (this.__swiftIdentityHasReleased) return; this.__swiftIdentityHasReleased = true; - const id = this.__swiftIdentityId; - instance.exports.bjs_SwiftCached_release_wrapper(id); - SwiftCached.__swiftIdentityWrappers[id] = undefined; + const pointer = this.pointer; + instance.exports.bjs_SwiftCached_release_wrapper(pointer); + SwiftCached.__swiftIdentityWrappers.delete(pointer); } constructor(name) { const nameBytes = textEncoder.encode(name); diff --git a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift index c8e020349..10c04b2a5 100644 --- a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift @@ -140,24 +140,13 @@ public func _bjs_getSharedSwiftSubject() -> UnsafeMutableRawPointer { let ret = getSharedSwiftSubject() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _SwiftIdentityTestSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _SwiftIdentityTestSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _SwiftIdentityTestSubject_freeIds.popLast() { - id = recycled - } else { - id = _SwiftIdentityTestSubject_nextId - _SwiftIdentityTestSubject_nextId += 1 - _SwiftIdentityTestSubject_wrapperRefs.append(0) - } - _SwiftIdentityTestSubject_identityTable[ptr] = id - _SwiftIdentityTestSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SwiftIdentityTestSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -183,24 +172,13 @@ public func _bjs_getRetainLeakSubjectSwift() -> UnsafeMutableRawPointer { let ret = getRetainLeakSubjectSwift() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _SwiftRetainLeakSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _SwiftRetainLeakSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _SwiftRetainLeakSubject_freeIds.popLast() { - id = recycled - } else { - id = _SwiftRetainLeakSubject_nextId - _SwiftRetainLeakSubject_nextId += 1 - _SwiftRetainLeakSubject_wrapperRefs.append(0) - } - _SwiftRetainLeakSubject_identityTable[ptr] = id - _SwiftRetainLeakSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SwiftRetainLeakSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -240,11 +218,11 @@ public func _bjs_resetRetainLeakDeinitsSwift() -> Void { #endif } -@_expose(wasm, "bjs_getSwiftNextIdForSharedSubject") -@_cdecl("bjs_getSwiftNextIdForSharedSubject") -public func _bjs_getSwiftNextIdForSharedSubject() -> Int32 { +@_expose(wasm, "bjs_getSwiftIdentityTableSizeForSharedSubject") +@_cdecl("bjs_getSwiftIdentityTableSizeForSharedSubject") +public func _bjs_getSwiftIdentityTableSizeForSharedSubject() -> Int32 { #if arch(wasm32) - let ret = getSwiftNextIdForSharedSubject() + let ret = getSwiftIdentityTableSizeForSharedSubject() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -273,11 +251,11 @@ public func _bjs_maybeSwiftSubject(_ present: Int32) -> Void { #endif } -@_expose(wasm, "bjs_getSwiftNextIdForChurn") -@_cdecl("bjs_getSwiftNextIdForChurn") -public func _bjs_getSwiftNextIdForChurn() -> Int32 { +@_expose(wasm, "bjs_getSwiftIdentityTableSizeForChurn") +@_cdecl("bjs_getSwiftIdentityTableSizeForChurn") +public func _bjs_getSwiftIdentityTableSizeForChurn() -> Int32 { #if arch(wasm32) - let ret = getSwiftNextIdForChurn() + let ret = getSwiftIdentityTableSizeForChurn() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -484,15 +462,9 @@ fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableR return _bjs_ArrayIdentityElement_wrap_extern(pointer) } -nonisolated(unsafe) var _SwiftIdentityTestSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] - -nonisolated(unsafe) var _SwiftIdentityTestSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] - -nonisolated(unsafe) var _SwiftIdentityTestSubject_wrapperRefs: [Int32] = [] +nonisolated(unsafe) var _SwiftIdentityTestSubject_identityTable: Set = [] -nonisolated(unsafe) var _SwiftIdentityTestSubject_freeIds: [Int32] = [] - -nonisolated(unsafe) var _SwiftIdentityTestSubject_nextId: Int32 = 0 +nonisolated(unsafe) var _SwiftIdentityTestSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] @_expose(wasm, "bjs_SwiftIdentityTestSubject_init") @_cdecl("bjs_SwiftIdentityTestSubject_init") @@ -501,24 +473,13 @@ public func _bjs_SwiftIdentityTestSubject_init(_ value: Int32) -> UnsafeMutableR let ret = SwiftIdentityTestSubject(value: Int.bridgeJSLiftParameter(value)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _SwiftIdentityTestSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _SwiftIdentityTestSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _SwiftIdentityTestSubject_freeIds.popLast() { - id = recycled - } else { - id = _SwiftIdentityTestSubject_nextId - _SwiftIdentityTestSubject_nextId += 1 - _SwiftIdentityTestSubject_wrapperRefs.append(0) - } - _SwiftIdentityTestSubject_identityTable[ptr] = id - _SwiftIdentityTestSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SwiftIdentityTestSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -534,24 +495,13 @@ public func _bjs_SwiftIdentityTestSubject_self_(_ _self: UnsafeMutableRawPointer let ret = SwiftIdentityTestSubject.bridgeJSLiftParameter(_self).self_() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _SwiftIdentityTestSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _SwiftIdentityTestSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _SwiftIdentityTestSubject_freeIds.popLast() { - id = recycled - } else { - id = _SwiftIdentityTestSubject_nextId - _SwiftIdentityTestSubject_nextId += 1 - _SwiftIdentityTestSubject_wrapperRefs.append(0) - } - _SwiftIdentityTestSubject_identityTable[ptr] = id - _SwiftIdentityTestSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SwiftIdentityTestSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -604,9 +554,9 @@ public func _bjs_SwiftIdentityTestSubject_deinit(_ pointer: UnsafeMutableRawPoin @_expose(wasm, "bjs_SwiftIdentityTestSubject_register_wrapper") @_cdecl("bjs_SwiftIdentityTestSubject_register_wrapper") -public func _bjs_SwiftIdentityTestSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { +public func _bjs_SwiftIdentityTestSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { #if arch(wasm32) - _SwiftIdentityTestSubject_wrapperRefs[Int(id)] = jsRef + _SwiftIdentityTestSubject_wrapperRefs[pointer] = jsRef #else fatalError("Only available on WebAssembly") #endif @@ -614,17 +564,11 @@ public func _bjs_SwiftIdentityTestSubject_register_wrapper(_ id: Int32, _ jsRef: @_expose(wasm, "bjs_SwiftIdentityTestSubject_release_wrapper") @_cdecl("bjs_SwiftIdentityTestSubject_release_wrapper") -public func _bjs_SwiftIdentityTestSubject_release_wrapper(_ id: Int32) -> Void { - #if arch(wasm32) - let slot = Int(id) - let jsRef = _SwiftIdentityTestSubject_wrapperRefs[slot] - guard jsRef != 0 else { return } - _SwiftIdentityTestSubject_wrapperRefs[slot] = 0 - if let ptr = _SwiftIdentityTestSubject_idToPointer.removeValue(forKey: id) { - _SwiftIdentityTestSubject_identityTable.removeValue(forKey: ptr) - Unmanaged.fromOpaque(ptr).release() - } - _SwiftIdentityTestSubject_freeIds.append(id) +public func _bjs_SwiftIdentityTestSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + guard let jsRef = _SwiftIdentityTestSubject_wrapperRefs.removeValue(forKey: pointer) else { return } + _SwiftIdentityTestSubject_identityTable.remove(pointer) + Unmanaged.fromOpaque(pointer).release() _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") @@ -635,23 +579,12 @@ extension SwiftIdentityTestSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if let id = _SwiftIdentityTestSubject_identityTable[ptr] { - _swift_js_push_i32(id) + if _SwiftIdentityTestSubject_identityTable.contains(ptr) { _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(self) - let id: Int32 - if let recycled = _SwiftIdentityTestSubject_freeIds.popLast() { - id = recycled - } else { - id = _SwiftIdentityTestSubject_nextId - _SwiftIdentityTestSubject_nextId += 1 - _SwiftIdentityTestSubject_wrapperRefs.append(0) - } - _SwiftIdentityTestSubject_identityTable[ptr] = id - _SwiftIdentityTestSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SwiftIdentityTestSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -680,15 +613,9 @@ fileprivate func _bjs_SwiftIdentityTestSubject_wrap_extern(_ pointer: UnsafeMuta return _bjs_SwiftIdentityTestSubject_wrap_extern(pointer) } -nonisolated(unsafe) var _SwiftRetainLeakSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] - -nonisolated(unsafe) var _SwiftRetainLeakSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] - -nonisolated(unsafe) var _SwiftRetainLeakSubject_wrapperRefs: [Int32] = [] - -nonisolated(unsafe) var _SwiftRetainLeakSubject_freeIds: [Int32] = [] +nonisolated(unsafe) var _SwiftRetainLeakSubject_identityTable: Set = [] -nonisolated(unsafe) var _SwiftRetainLeakSubject_nextId: Int32 = 0 +nonisolated(unsafe) var _SwiftRetainLeakSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] @_expose(wasm, "bjs_SwiftRetainLeakSubject_init") @_cdecl("bjs_SwiftRetainLeakSubject_init") @@ -697,24 +624,13 @@ public func _bjs_SwiftRetainLeakSubject_init(_ tag: Int32) -> UnsafeMutableRawPo let ret = SwiftRetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _SwiftRetainLeakSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _SwiftRetainLeakSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _SwiftRetainLeakSubject_freeIds.popLast() { - id = recycled - } else { - id = _SwiftRetainLeakSubject_nextId - _SwiftRetainLeakSubject_nextId += 1 - _SwiftRetainLeakSubject_wrapperRefs.append(0) - } - _SwiftRetainLeakSubject_identityTable[ptr] = id - _SwiftRetainLeakSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SwiftRetainLeakSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -756,9 +672,9 @@ public func _bjs_SwiftRetainLeakSubject_deinit(_ pointer: UnsafeMutableRawPointe @_expose(wasm, "bjs_SwiftRetainLeakSubject_register_wrapper") @_cdecl("bjs_SwiftRetainLeakSubject_register_wrapper") -public func _bjs_SwiftRetainLeakSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { +public func _bjs_SwiftRetainLeakSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { #if arch(wasm32) - _SwiftRetainLeakSubject_wrapperRefs[Int(id)] = jsRef + _SwiftRetainLeakSubject_wrapperRefs[pointer] = jsRef #else fatalError("Only available on WebAssembly") #endif @@ -766,17 +682,11 @@ public func _bjs_SwiftRetainLeakSubject_register_wrapper(_ id: Int32, _ jsRef: I @_expose(wasm, "bjs_SwiftRetainLeakSubject_release_wrapper") @_cdecl("bjs_SwiftRetainLeakSubject_release_wrapper") -public func _bjs_SwiftRetainLeakSubject_release_wrapper(_ id: Int32) -> Void { - #if arch(wasm32) - let slot = Int(id) - let jsRef = _SwiftRetainLeakSubject_wrapperRefs[slot] - guard jsRef != 0 else { return } - _SwiftRetainLeakSubject_wrapperRefs[slot] = 0 - if let ptr = _SwiftRetainLeakSubject_idToPointer.removeValue(forKey: id) { - _SwiftRetainLeakSubject_identityTable.removeValue(forKey: ptr) - Unmanaged.fromOpaque(ptr).release() - } - _SwiftRetainLeakSubject_freeIds.append(id) +public func _bjs_SwiftRetainLeakSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + guard let jsRef = _SwiftRetainLeakSubject_wrapperRefs.removeValue(forKey: pointer) else { return } + _SwiftRetainLeakSubject_identityTable.remove(pointer) + Unmanaged.fromOpaque(pointer).release() _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") @@ -787,23 +697,12 @@ extension SwiftRetainLeakSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if let id = _SwiftRetainLeakSubject_identityTable[ptr] { - _swift_js_push_i32(id) + if _SwiftRetainLeakSubject_identityTable.contains(ptr) { _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(self) - let id: Int32 - if let recycled = _SwiftRetainLeakSubject_freeIds.popLast() { - id = recycled - } else { - id = _SwiftRetainLeakSubject_nextId - _SwiftRetainLeakSubject_nextId += 1 - _SwiftRetainLeakSubject_wrapperRefs.append(0) - } - _SwiftRetainLeakSubject_identityTable[ptr] = id - _SwiftRetainLeakSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SwiftRetainLeakSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -832,15 +731,9 @@ fileprivate func _bjs_SwiftRetainLeakSubject_wrap_extern(_ pointer: UnsafeMutabl return _bjs_SwiftRetainLeakSubject_wrap_extern(pointer) } -nonisolated(unsafe) var _SwiftChurnSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] - -nonisolated(unsafe) var _SwiftChurnSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] - -nonisolated(unsafe) var _SwiftChurnSubject_wrapperRefs: [Int32] = [] +nonisolated(unsafe) var _SwiftChurnSubject_identityTable: Set = [] -nonisolated(unsafe) var _SwiftChurnSubject_freeIds: [Int32] = [] - -nonisolated(unsafe) var _SwiftChurnSubject_nextId: Int32 = 0 +nonisolated(unsafe) var _SwiftChurnSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] @_expose(wasm, "bjs_SwiftChurnSubject_init") @_cdecl("bjs_SwiftChurnSubject_init") @@ -849,24 +742,13 @@ public func _bjs_SwiftChurnSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer let ret = SwiftChurnSubject(tag: Int.bridgeJSLiftParameter(tag)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _SwiftChurnSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _SwiftChurnSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _SwiftChurnSubject_freeIds.popLast() { - id = recycled - } else { - id = _SwiftChurnSubject_nextId - _SwiftChurnSubject_nextId += 1 - _SwiftChurnSubject_wrapperRefs.append(0) - } - _SwiftChurnSubject_identityTable[ptr] = id - _SwiftChurnSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SwiftChurnSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -908,9 +790,9 @@ public func _bjs_SwiftChurnSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> @_expose(wasm, "bjs_SwiftChurnSubject_register_wrapper") @_cdecl("bjs_SwiftChurnSubject_register_wrapper") -public func _bjs_SwiftChurnSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { +public func _bjs_SwiftChurnSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { #if arch(wasm32) - _SwiftChurnSubject_wrapperRefs[Int(id)] = jsRef + _SwiftChurnSubject_wrapperRefs[pointer] = jsRef #else fatalError("Only available on WebAssembly") #endif @@ -918,17 +800,11 @@ public func _bjs_SwiftChurnSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) @_expose(wasm, "bjs_SwiftChurnSubject_release_wrapper") @_cdecl("bjs_SwiftChurnSubject_release_wrapper") -public func _bjs_SwiftChurnSubject_release_wrapper(_ id: Int32) -> Void { - #if arch(wasm32) - let slot = Int(id) - let jsRef = _SwiftChurnSubject_wrapperRefs[slot] - guard jsRef != 0 else { return } - _SwiftChurnSubject_wrapperRefs[slot] = 0 - if let ptr = _SwiftChurnSubject_idToPointer.removeValue(forKey: id) { - _SwiftChurnSubject_identityTable.removeValue(forKey: ptr) - Unmanaged.fromOpaque(ptr).release() - } - _SwiftChurnSubject_freeIds.append(id) +public func _bjs_SwiftChurnSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + guard let jsRef = _SwiftChurnSubject_wrapperRefs.removeValue(forKey: pointer) else { return } + _SwiftChurnSubject_identityTable.remove(pointer) + Unmanaged.fromOpaque(pointer).release() _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") @@ -939,23 +815,12 @@ extension SwiftChurnSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if let id = _SwiftChurnSubject_identityTable[ptr] { - _swift_js_push_i32(id) + if _SwiftChurnSubject_identityTable.contains(ptr) { _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(self) - let id: Int32 - if let recycled = _SwiftChurnSubject_freeIds.popLast() { - id = recycled - } else { - id = _SwiftChurnSubject_nextId - _SwiftChurnSubject_nextId += 1 - _SwiftChurnSubject_wrapperRefs.append(0) - } - _SwiftChurnSubject_identityTable[ptr] = id - _SwiftChurnSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _SwiftChurnSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } diff --git a/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json index 4757b84c2..3a4a55056 100644 --- a/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json @@ -663,13 +663,13 @@ } }, { - "abiName" : "bjs_getSwiftNextIdForSharedSubject", + "abiName" : "bjs_getSwiftIdentityTableSizeForSharedSubject", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "getSwiftNextIdForSharedSubject", + "name" : "getSwiftIdentityTableSizeForSharedSubject", "parameters" : [ ], @@ -751,13 +751,13 @@ } }, { - "abiName" : "bjs_getSwiftNextIdForChurn", + "abiName" : "bjs_getSwiftIdentityTableSizeForChurn", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "getSwiftNextIdForChurn", + "name" : "getSwiftIdentityTableSizeForChurn", "parameters" : [ ], diff --git a/Tests/BridgeJSIdentityTests/IdentityModeTests.swift b/Tests/BridgeJSIdentityTests/IdentityModeTests.swift index 2f92c1a3a..049ac4d8f 100644 --- a/Tests/BridgeJSIdentityTests/IdentityModeTests.swift +++ b/Tests/BridgeJSIdentityTests/IdentityModeTests.swift @@ -181,14 +181,15 @@ nonisolated(unsafe) private var _swiftRetainLeakSubject: SwiftRetainLeakSubject? SwiftRetainLeakSubject.deinits = 0 } -// Scenario (d): id-recycling introspection. +// Scenario (d): identity-table size introspection. // +// Post-D18 the Swift-side state is a Set (no ids). The analogous +// "compactness" check is: after N allocate+release cycles, the Set is empty. // Gated behind `ENABLE_TEST_INTROSPECTION` so the debug-only getter does not -// become part of the public test surface (or, worse, add codegen weight to -// release binaries). The test target defines this flag in its swiftSettings. +// become part of the public test surface. #if ENABLE_TEST_INTROSPECTION -@JS func getSwiftNextIdForSharedSubject() -> Int { - Int(_SwiftIdentityTestSubject_nextId) +@JS func getSwiftIdentityTableSizeForSharedSubject() -> Int { + _SwiftIdentityTestSubject_identityTable.count } #endif @@ -221,7 +222,7 @@ nonisolated(unsafe) private var _swiftRetainLeakSubject: SwiftRetainLeakSubject? } #if ENABLE_TEST_INTROSPECTION -@JS func getSwiftNextIdForChurn() -> Int { - Int(_SwiftChurnSubject_nextId) +@JS func getSwiftIdentityTableSizeForChurn() -> Int { + _SwiftChurnSubject_identityTable.count } #endif diff --git a/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs b/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs index f38c39817..128829195 100644 --- a/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs +++ b/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs @@ -38,7 +38,7 @@ function runIdentityModeTests(exports) { testSwiftModeSelfMethodIdentity(exports); testSwiftModeReleaseFreesHeapObject(exports); testSwiftModeDoubleReleaseIdempotent(exports); - testSwiftModeIdRecycling(exports); + testSwiftModeIdentityTableCleanup(exports); testSwiftModeArrayCrossElementIdentity(exports); testSwiftModeGcSurvivability(exports); testSwiftModeOptionalIdentity(exports); @@ -237,7 +237,7 @@ function testSwiftModeIdentity(exports) { assert.strictEqual(a, b, "swift mode: same Swift object returns same wrapper"); assert.strictEqual(b, c, "swift mode: identity is transitive across re-exports"); assert.equal(a.currentValue, 42); - assert.equal(typeof a.__swiftIdentityId, "number"); + assert.equal(typeof a.pointer, "number"); a.release(); exports.resetSharedSwiftSubject(); @@ -310,15 +310,20 @@ function testSwiftModeDoubleReleaseIdempotent(exports) { } /** - * (d) Id recycling — nextId does not grow past the pool size. + * (d) Identity-table cleanup — the Swift-side `Set` returns to size 0 + * after allocating N wrappers and releasing all of them. + * + * Post-D18 there is no id allocation to recycle; the equivalent correctness + * check is that `release_wrapper` drops its entry from `__identityTable` + * so the Set doesn't grow unboundedly over a churn loop. * * Uses the dedicated SwiftChurnSubject class so this assertion is not - * perturbed by id allocations performed by other tests. + * perturbed by other tests' allocations. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ -function testSwiftModeIdRecycling(exports) { - if (typeof exports.getSwiftNextIdForChurn !== "function") { +function testSwiftModeIdentityTableCleanup(exports) { + if (typeof exports.getSwiftIdentityTableSizeForChurn !== "function") { // ENABLE_TEST_INTROSPECTION not set — skip silently. return; } @@ -328,23 +333,21 @@ function testSwiftModeIdRecycling(exports) { for (let i = 0; i < POOL; i++) { first.push(new exports.SwiftChurnSubject(i)); } - const peakAfterFirst = exports.getSwiftNextIdForChurn(); + const peakAfterFirst = exports.getSwiftIdentityTableSizeForChurn(); + assert.strictEqual(peakAfterFirst, POOL, `swift mode: identity table should hold ${POOL} entries; got ${peakAfterFirst}`); for (const obj of first) { obj.release(); } + const afterRelease = exports.getSwiftIdentityTableSizeForChurn(); + assert.strictEqual(afterRelease, 0, `swift mode: identity table should empty after release; got ${afterRelease}`); const second = []; for (let i = 0; i < POOL; i++) { second.push(new exports.SwiftChurnSubject(100 + i)); } - const peakAfterSecond = exports.getSwiftNextIdForChurn(); - - assert.strictEqual( - peakAfterSecond, - peakAfterFirst, - `swift mode: id recycling failed — nextId grew from ${peakAfterFirst} to ${peakAfterSecond} despite ${POOL} freed ids in between`, - ); + const peakAfterSecond = exports.getSwiftIdentityTableSizeForChurn(); + assert.strictEqual(peakAfterSecond, POOL, `swift mode: identity table should hold ${POOL} entries again; got ${peakAfterSecond}`); for (const obj of second) { obj.release(); @@ -389,7 +392,7 @@ function testSwiftModeGcSurvivability(exports) { exports.resetSharedSwiftSubject(); let obj = exports.getSharedSwiftSubject(); - const idBefore = obj.__swiftIdentityId; + const pointerBefore = obj.pointer; const weakProbe = new WeakRef(obj); // Drop the local reference and force GC twice with a microtask flush in @@ -415,9 +418,9 @@ function testSwiftModeGcSurvivability(exports) { // yields (since Swift's retain on the JS ref keeps it alive). const again = exports.getSharedSwiftSubject(); assert.strictEqual( - again.__swiftIdentityId, - idBefore, - "swift mode: id must be stable across GC (Swift still retains the heap object)", + again.pointer, + pointerBefore, + "swift mode: pointer must be stable across GC (Swift still retains the heap object)", ); assert.strictEqual( weakProbe.deref(), @@ -514,9 +517,12 @@ function testModeCoexistence(exports) { assert.equal(ptr1.currentValue, 10); assert.equal(swift1.currentValue, 30); - // Pointer-mode exposes no __swiftIdentityId; swift-mode does. - assert.equal(typeof swift1.__swiftIdentityId, "number"); - assert.equal(typeof ptr1.__swiftIdentityId, "undefined"); + // Pointer-mode wrappers have `__swiftHeapObjectState` from SwiftHeapObject; + // swift-mode standalone wrappers have `__swiftIdentityHasReleased` instead. + assert.equal(typeof swift1.__swiftIdentityHasReleased, "boolean"); + assert.equal(typeof ptr1.__swiftIdentityHasReleased, "undefined"); + assert.equal(typeof ptr1.__swiftHeapObjectState, "object"); + assert.equal(typeof swift1.__swiftHeapObjectState, "undefined"); ptr1.release(); ptr2.release(); diff --git a/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift index 10396ec0c..7fe1804e8 100644 --- a/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift @@ -14,24 +14,13 @@ public func _bjs_getConfigSwiftSubject() -> UnsafeMutableRawPointer { let ret = getConfigSwiftSubject() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _ConfigSwiftSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _ConfigSwiftSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _ConfigSwiftSubject_freeIds.popLast() { - id = recycled - } else { - id = _ConfigSwiftSubject_nextId - _ConfigSwiftSubject_nextId += 1 - _ConfigSwiftSubject_wrapperRefs.append(0) - } - _ConfigSwiftSubject_identityTable[ptr] = id - _ConfigSwiftSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _ConfigSwiftSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -57,24 +46,13 @@ public func _bjs_getConfigSwiftRetainLeakSubject() -> UnsafeMutableRawPointer { let ret = getConfigSwiftRetainLeakSubject() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _ConfigSwiftRetainLeakSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _ConfigSwiftRetainLeakSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _ConfigSwiftRetainLeakSubject_freeIds.popLast() { - id = recycled - } else { - id = _ConfigSwiftRetainLeakSubject_nextId - _ConfigSwiftRetainLeakSubject_nextId += 1 - _ConfigSwiftRetainLeakSubject_wrapperRefs.append(0) - } - _ConfigSwiftRetainLeakSubject_identityTable[ptr] = id - _ConfigSwiftRetainLeakSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -114,11 +92,11 @@ public func _bjs_resetConfigSwiftRetainLeakDeinits() -> Void { #endif } -@_expose(wasm, "bjs_getConfigSwiftNextIdForChurn") -@_cdecl("bjs_getConfigSwiftNextIdForChurn") -public func _bjs_getConfigSwiftNextIdForChurn() -> Int32 { +@_expose(wasm, "bjs_getConfigSwiftIdentityTableSizeForChurn") +@_cdecl("bjs_getConfigSwiftIdentityTableSizeForChurn") +public func _bjs_getConfigSwiftIdentityTableSizeForChurn() -> Int32 { #if arch(wasm32) - let ret = getConfigSwiftNextIdForChurn() + let ret = getConfigSwiftIdentityTableSizeForChurn() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -147,15 +125,9 @@ public func _bjs_maybeConfigSwiftSubject(_ present: Int32) -> Void { #endif } -nonisolated(unsafe) var _ConfigSwiftSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] - -nonisolated(unsafe) var _ConfigSwiftSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] +nonisolated(unsafe) var _ConfigSwiftSubject_identityTable: Set = [] -nonisolated(unsafe) var _ConfigSwiftSubject_wrapperRefs: [Int32] = [] - -nonisolated(unsafe) var _ConfigSwiftSubject_freeIds: [Int32] = [] - -nonisolated(unsafe) var _ConfigSwiftSubject_nextId: Int32 = 0 +nonisolated(unsafe) var _ConfigSwiftSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] @_expose(wasm, "bjs_ConfigSwiftSubject_init") @_cdecl("bjs_ConfigSwiftSubject_init") @@ -164,24 +136,13 @@ public func _bjs_ConfigSwiftSubject_init(_ value: Int32) -> UnsafeMutableRawPoin let ret = ConfigSwiftSubject(value: Int.bridgeJSLiftParameter(value)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _ConfigSwiftSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _ConfigSwiftSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _ConfigSwiftSubject_freeIds.popLast() { - id = recycled - } else { - id = _ConfigSwiftSubject_nextId - _ConfigSwiftSubject_nextId += 1 - _ConfigSwiftSubject_wrapperRefs.append(0) - } - _ConfigSwiftSubject_identityTable[ptr] = id - _ConfigSwiftSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _ConfigSwiftSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -197,24 +158,13 @@ public func _bjs_ConfigSwiftSubject_self_(_ _self: UnsafeMutableRawPointer) -> U let ret = ConfigSwiftSubject.bridgeJSLiftParameter(_self).self_() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _ConfigSwiftSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _ConfigSwiftSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _ConfigSwiftSubject_freeIds.popLast() { - id = recycled - } else { - id = _ConfigSwiftSubject_nextId - _ConfigSwiftSubject_nextId += 1 - _ConfigSwiftSubject_wrapperRefs.append(0) - } - _ConfigSwiftSubject_identityTable[ptr] = id - _ConfigSwiftSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _ConfigSwiftSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -267,9 +217,9 @@ public func _bjs_ConfigSwiftSubject_deinit(_ pointer: UnsafeMutableRawPointer) - @_expose(wasm, "bjs_ConfigSwiftSubject_register_wrapper") @_cdecl("bjs_ConfigSwiftSubject_register_wrapper") -public func _bjs_ConfigSwiftSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { +public func _bjs_ConfigSwiftSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { #if arch(wasm32) - _ConfigSwiftSubject_wrapperRefs[Int(id)] = jsRef + _ConfigSwiftSubject_wrapperRefs[pointer] = jsRef #else fatalError("Only available on WebAssembly") #endif @@ -277,17 +227,11 @@ public func _bjs_ConfigSwiftSubject_register_wrapper(_ id: Int32, _ jsRef: Int32 @_expose(wasm, "bjs_ConfigSwiftSubject_release_wrapper") @_cdecl("bjs_ConfigSwiftSubject_release_wrapper") -public func _bjs_ConfigSwiftSubject_release_wrapper(_ id: Int32) -> Void { +public func _bjs_ConfigSwiftSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let slot = Int(id) - let jsRef = _ConfigSwiftSubject_wrapperRefs[slot] - guard jsRef != 0 else { return } - _ConfigSwiftSubject_wrapperRefs[slot] = 0 - if let ptr = _ConfigSwiftSubject_idToPointer.removeValue(forKey: id) { - _ConfigSwiftSubject_identityTable.removeValue(forKey: ptr) - Unmanaged.fromOpaque(ptr).release() - } - _ConfigSwiftSubject_freeIds.append(id) + guard let jsRef = _ConfigSwiftSubject_wrapperRefs.removeValue(forKey: pointer) else { return } + _ConfigSwiftSubject_identityTable.remove(pointer) + Unmanaged.fromOpaque(pointer).release() _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") @@ -298,23 +242,12 @@ extension ConfigSwiftSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if let id = _ConfigSwiftSubject_identityTable[ptr] { - _swift_js_push_i32(id) + if _ConfigSwiftSubject_identityTable.contains(ptr) { _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(self) - let id: Int32 - if let recycled = _ConfigSwiftSubject_freeIds.popLast() { - id = recycled - } else { - id = _ConfigSwiftSubject_nextId - _ConfigSwiftSubject_nextId += 1 - _ConfigSwiftSubject_wrapperRefs.append(0) - } - _ConfigSwiftSubject_identityTable[ptr] = id - _ConfigSwiftSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _ConfigSwiftSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -343,15 +276,9 @@ fileprivate func _bjs_ConfigSwiftSubject_wrap_extern(_ pointer: UnsafeMutableRaw return _bjs_ConfigSwiftSubject_wrap_extern(pointer) } -nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] - -nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] - -nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_wrapperRefs: [Int32] = [] +nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_identityTable: Set = [] -nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_freeIds: [Int32] = [] - -nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_nextId: Int32 = 0 +nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] @_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_init") @_cdecl("bjs_ConfigSwiftRetainLeakSubject_init") @@ -360,24 +287,13 @@ public func _bjs_ConfigSwiftRetainLeakSubject_init(_ tag: Int32) -> UnsafeMutabl let ret = ConfigSwiftRetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _ConfigSwiftRetainLeakSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _ConfigSwiftRetainLeakSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _ConfigSwiftRetainLeakSubject_freeIds.popLast() { - id = recycled - } else { - id = _ConfigSwiftRetainLeakSubject_nextId - _ConfigSwiftRetainLeakSubject_nextId += 1 - _ConfigSwiftRetainLeakSubject_wrapperRefs.append(0) - } - _ConfigSwiftRetainLeakSubject_identityTable[ptr] = id - _ConfigSwiftRetainLeakSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -419,9 +335,9 @@ public func _bjs_ConfigSwiftRetainLeakSubject_deinit(_ pointer: UnsafeMutableRaw @_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_register_wrapper") @_cdecl("bjs_ConfigSwiftRetainLeakSubject_register_wrapper") -public func _bjs_ConfigSwiftRetainLeakSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { +public func _bjs_ConfigSwiftRetainLeakSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { #if arch(wasm32) - _ConfigSwiftRetainLeakSubject_wrapperRefs[Int(id)] = jsRef + _ConfigSwiftRetainLeakSubject_wrapperRefs[pointer] = jsRef #else fatalError("Only available on WebAssembly") #endif @@ -429,17 +345,11 @@ public func _bjs_ConfigSwiftRetainLeakSubject_register_wrapper(_ id: Int32, _ js @_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_release_wrapper") @_cdecl("bjs_ConfigSwiftRetainLeakSubject_release_wrapper") -public func _bjs_ConfigSwiftRetainLeakSubject_release_wrapper(_ id: Int32) -> Void { +public func _bjs_ConfigSwiftRetainLeakSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let slot = Int(id) - let jsRef = _ConfigSwiftRetainLeakSubject_wrapperRefs[slot] - guard jsRef != 0 else { return } - _ConfigSwiftRetainLeakSubject_wrapperRefs[slot] = 0 - if let ptr = _ConfigSwiftRetainLeakSubject_idToPointer.removeValue(forKey: id) { - _ConfigSwiftRetainLeakSubject_identityTable.removeValue(forKey: ptr) - Unmanaged.fromOpaque(ptr).release() - } - _ConfigSwiftRetainLeakSubject_freeIds.append(id) + guard let jsRef = _ConfigSwiftRetainLeakSubject_wrapperRefs.removeValue(forKey: pointer) else { return } + _ConfigSwiftRetainLeakSubject_identityTable.remove(pointer) + Unmanaged.fromOpaque(pointer).release() _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") @@ -450,23 +360,12 @@ extension ConfigSwiftRetainLeakSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if let id = _ConfigSwiftRetainLeakSubject_identityTable[ptr] { - _swift_js_push_i32(id) + if _ConfigSwiftRetainLeakSubject_identityTable.contains(ptr) { _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(self) - let id: Int32 - if let recycled = _ConfigSwiftRetainLeakSubject_freeIds.popLast() { - id = recycled - } else { - id = _ConfigSwiftRetainLeakSubject_nextId - _ConfigSwiftRetainLeakSubject_nextId += 1 - _ConfigSwiftRetainLeakSubject_wrapperRefs.append(0) - } - _ConfigSwiftRetainLeakSubject_identityTable[ptr] = id - _ConfigSwiftRetainLeakSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -495,15 +394,9 @@ fileprivate func _bjs_ConfigSwiftRetainLeakSubject_wrap_extern(_ pointer: Unsafe return _bjs_ConfigSwiftRetainLeakSubject_wrap_extern(pointer) } -nonisolated(unsafe) var _ConfigSwiftChurnSubject_identityTable: [UnsafeMutableRawPointer: Int32] = [:] - -nonisolated(unsafe) var _ConfigSwiftChurnSubject_idToPointer: [Int32: UnsafeMutableRawPointer] = [:] +nonisolated(unsafe) var _ConfigSwiftChurnSubject_identityTable: Set = [] -nonisolated(unsafe) var _ConfigSwiftChurnSubject_wrapperRefs: [Int32] = [] - -nonisolated(unsafe) var _ConfigSwiftChurnSubject_freeIds: [Int32] = [] - -nonisolated(unsafe) var _ConfigSwiftChurnSubject_nextId: Int32 = 0 +nonisolated(unsafe) var _ConfigSwiftChurnSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] @_expose(wasm, "bjs_ConfigSwiftChurnSubject_init") @_cdecl("bjs_ConfigSwiftChurnSubject_init") @@ -512,24 +405,13 @@ public func _bjs_ConfigSwiftChurnSubject_init(_ tag: Int32) -> UnsafeMutableRawP let ret = ConfigSwiftChurnSubject(tag: Int.bridgeJSLiftParameter(tag)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if let id = _ConfigSwiftChurnSubject_identityTable[ptr] { - // Cache hit: do NOT retain. JS keeps the wrapper alive via _wrapperRefs[id]. - _swift_js_push_i32(id) + if _ConfigSwiftChurnSubject_identityTable.contains(ptr) { + // Cache hit: do NOT retain. JS has the wrapper cached. _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(ret) - let id: Int32 - if let recycled = _ConfigSwiftChurnSubject_freeIds.popLast() { - id = recycled - } else { - id = _ConfigSwiftChurnSubject_nextId - _ConfigSwiftChurnSubject_nextId += 1 - _ConfigSwiftChurnSubject_wrapperRefs.append(0) - } - _ConfigSwiftChurnSubject_identityTable[ptr] = id - _ConfigSwiftChurnSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _ConfigSwiftChurnSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } @@ -571,9 +453,9 @@ public func _bjs_ConfigSwiftChurnSubject_deinit(_ pointer: UnsafeMutableRawPoint @_expose(wasm, "bjs_ConfigSwiftChurnSubject_register_wrapper") @_cdecl("bjs_ConfigSwiftChurnSubject_register_wrapper") -public func _bjs_ConfigSwiftChurnSubject_register_wrapper(_ id: Int32, _ jsRef: Int32) -> Void { +public func _bjs_ConfigSwiftChurnSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { #if arch(wasm32) - _ConfigSwiftChurnSubject_wrapperRefs[Int(id)] = jsRef + _ConfigSwiftChurnSubject_wrapperRefs[pointer] = jsRef #else fatalError("Only available on WebAssembly") #endif @@ -581,17 +463,11 @@ public func _bjs_ConfigSwiftChurnSubject_register_wrapper(_ id: Int32, _ jsRef: @_expose(wasm, "bjs_ConfigSwiftChurnSubject_release_wrapper") @_cdecl("bjs_ConfigSwiftChurnSubject_release_wrapper") -public func _bjs_ConfigSwiftChurnSubject_release_wrapper(_ id: Int32) -> Void { +public func _bjs_ConfigSwiftChurnSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let slot = Int(id) - let jsRef = _ConfigSwiftChurnSubject_wrapperRefs[slot] - guard jsRef != 0 else { return } - _ConfigSwiftChurnSubject_wrapperRefs[slot] = 0 - if let ptr = _ConfigSwiftChurnSubject_idToPointer.removeValue(forKey: id) { - _ConfigSwiftChurnSubject_identityTable.removeValue(forKey: ptr) - Unmanaged.fromOpaque(ptr).release() - } - _ConfigSwiftChurnSubject_freeIds.append(id) + guard let jsRef = _ConfigSwiftChurnSubject_wrapperRefs.removeValue(forKey: pointer) else { return } + _ConfigSwiftChurnSubject_identityTable.remove(pointer) + Unmanaged.fromOpaque(pointer).release() _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") @@ -602,23 +478,12 @@ extension ConfigSwiftChurnSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if let id = _ConfigSwiftChurnSubject_identityTable[ptr] { - _swift_js_push_i32(id) + if _ConfigSwiftChurnSubject_identityTable.contains(ptr) { _swift_js_push_i32(0) return ptr } _ = Unmanaged.passRetained(self) - let id: Int32 - if let recycled = _ConfigSwiftChurnSubject_freeIds.popLast() { - id = recycled - } else { - id = _ConfigSwiftChurnSubject_nextId - _ConfigSwiftChurnSubject_nextId += 1 - _ConfigSwiftChurnSubject_wrapperRefs.append(0) - } - _ConfigSwiftChurnSubject_identityTable[ptr] = id - _ConfigSwiftChurnSubject_idToPointer[id] = ptr - _swift_js_push_i32(id) + _ConfigSwiftChurnSubject_identityTable.insert(ptr) _swift_js_push_i32(1) return ptr } diff --git a/Tests/BridgeJSSwiftIdentityTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSSwiftIdentityTests/Generated/JavaScript/BridgeJS.json index 7849a5e5c..9ae527aa3 100644 --- a/Tests/BridgeJSSwiftIdentityTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSSwiftIdentityTests/Generated/JavaScript/BridgeJS.json @@ -274,13 +274,13 @@ } }, { - "abiName" : "bjs_getConfigSwiftNextIdForChurn", + "abiName" : "bjs_getConfigSwiftIdentityTableSizeForChurn", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "getConfigSwiftNextIdForChurn", + "name" : "getConfigSwiftIdentityTableSizeForChurn", "parameters" : [ ], diff --git a/Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs b/Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs index 99b5fc6d1..5af9f8442 100644 --- a/Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs +++ b/Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs @@ -33,7 +33,7 @@ function runSwiftIdentityModeTests(exports) { testConfigSwiftSelfMethodIdentity(exports); testConfigSwiftReleaseFreesHeapObject(exports); testConfigSwiftDoubleReleaseIdempotent(exports); - testConfigSwiftIdRecycling(exports); + testConfigSwiftIdentityTableCleanup(exports); testConfigSwiftArrayCrossElementIdentity(exports); testConfigSwiftGcSurvivability(exports); testConfigSwiftOptionalIdentity(exports); @@ -55,9 +55,9 @@ function testConfigSwiftIdentity(exports) { assert.strictEqual(b, c, "config-swift: re-export identity transitive"); assert.equal(a.currentValue, 7); assert.equal( - typeof a.__swiftIdentityId, - "number", - "config-default `swift` mode should emit __swiftIdentityId — verify BridgeJSLink.shouldUseSwiftIdentityCache picks up the config", + typeof a.__swiftIdentityHasReleased, + "boolean", + "config-default `swift` mode should emit a standalone wrapper with __swiftIdentityHasReleased — verify BridgeJSLink.shouldUseSwiftIdentityCache picks up the config", ); a.release(); @@ -123,12 +123,13 @@ function testConfigSwiftDoubleReleaseIdempotent(exports) { } /** - * (d) Id recycling — nextId does not grow past the pool size. + * (d) Identity-table cleanup — `Set` returns to empty after release + * (post-D18; no ids to recycle, so the analogous check is size-based). * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ -function testConfigSwiftIdRecycling(exports) { - if (typeof exports.getConfigSwiftNextIdForChurn !== "function") { +function testConfigSwiftIdentityTableCleanup(exports) { + if (typeof exports.getConfigSwiftIdentityTableSizeForChurn !== "function") { return; // ENABLE_TEST_INTROSPECTION not defined } @@ -137,21 +138,16 @@ function testConfigSwiftIdRecycling(exports) { for (let i = 0; i < POOL; i++) { first.push(new exports.ConfigSwiftChurnSubject(i)); } - const peakAfterFirst = exports.getConfigSwiftNextIdForChurn(); + assert.strictEqual(exports.getConfigSwiftIdentityTableSizeForChurn(), POOL); for (const o of first) o.release(); + assert.strictEqual(exports.getConfigSwiftIdentityTableSizeForChurn(), 0); const second = []; for (let i = 0; i < POOL; i++) { second.push(new exports.ConfigSwiftChurnSubject(100 + i)); } - const peakAfterSecond = exports.getConfigSwiftNextIdForChurn(); - - assert.strictEqual( - peakAfterSecond, - peakAfterFirst, - `config-swift: id recycling failed — nextId grew from ${peakAfterFirst} to ${peakAfterSecond}`, - ); + assert.strictEqual(exports.getConfigSwiftIdentityTableSizeForChurn(), POOL); for (const o of second) o.release(); } @@ -190,7 +186,7 @@ function testConfigSwiftGcSurvivability(exports) { exports.resetConfigSwiftSubject(); let obj = exports.getConfigSwiftSubject(); - const idBefore = obj.__swiftIdentityId; + const pointerBefore = obj.pointer; const weakProbe = new WeakRef(obj); obj = null; @@ -199,9 +195,9 @@ function testConfigSwiftGcSurvivability(exports) { const again = exports.getConfigSwiftSubject(); assert.strictEqual( - again.__swiftIdentityId, - idBefore, - "config-swift: id stable across GC", + again.pointer, + pointerBefore, + "config-swift: pointer stable across GC", ); assert.strictEqual( weakProbe.deref(), diff --git a/Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift b/Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift index 80c45d5f2..a40454ce7 100644 --- a/Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift +++ b/Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift @@ -94,8 +94,8 @@ nonisolated(unsafe) private var _configSwiftRetainLeakSubject: ConfigSwiftRetain } #if ENABLE_TEST_INTROSPECTION -@JS func getConfigSwiftNextIdForChurn() -> Int { - Int(_ConfigSwiftChurnSubject_nextId) +@JS func getConfigSwiftIdentityTableSizeForChurn() -> Int { + _ConfigSwiftChurnSubject_identityTable.count } #endif From 03df22f3bd74de4ae8bfb83023f5ea607d284206 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Wed, 22 Apr 2026 14:29:11 +0200 Subject: [PATCH 16/18] =?UTF-8?q?refactor:=20drop=20register=5Fwrapper=20c?= =?UTF-8?q?allback=20=E2=80=94=20JS=20owns=20the=20wrapper=20ref?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the pointer-keyed cache simplification, Swift's __wrapperRefs map existed only so release_wrapper could find the retained JS ref to release. But JS's strong Map already keeps the wrapper alive for as long as Swift needs it. Swift doesn't need its own strong reference to the JS wrapper at all. Removed: - Wasm export bjs__register_wrapper(pointer, jsRef) - Swift per-class global __wrapperRefs - JS-side swift.memory.retain(obj) + register_wrapper callback on miss - Swift-side _swift_js_release_ref() call in release_wrapper Release thunk simplifies to: guard __identityTable.remove(pointer) != nil else { return } Unmanaged.fromOpaque(pointer).release() Invariants preserved: === identity, Swift heap-object lifetime (retain on miss balanced by release in release_wrapper), wrapper survives GC while reachable via the strong Map, array-element identity. Performance impact (500k iters, median ms, swift mode only): v2 v3 delta vs v2 vs pointer (1924) passBothWaysRoundtrip 28 27 -4% getPoolRepeated_100 34 34 parity swiftCreatesObject 592 347 -41% -82% churnObjects 438 332 -24% -58% Miss path is now faster than the 'none' baseline (347 vs 507 ms) — the wasm-callback savings on each fresh wrapper compound: one fewer cross- boundary call per allocation. 165/165 tests green. --- Benchmarks/Sources/Generated/BridgeJS.swift | 48 ++----------------- .../Sources/BridgeJSCore/ExportSwift.swift | 38 ++++----------- .../Sources/BridgeJSLink/BridgeJSLink.swift | 19 ++++---- .../IdentityModeSwiftClass.swift | 16 +------ .../IdentityModeClass.ConfigSwift.js | 2 - .../IdentityModeSwiftClass.js | 2 - .../Generated/BridgeJS.swift | 48 ++----------------- .../Generated/BridgeJS.swift | 48 ++----------------- 8 files changed, 28 insertions(+), 193 deletions(-) diff --git a/Benchmarks/Sources/Generated/BridgeJS.swift b/Benchmarks/Sources/Generated/BridgeJS.swift index 0f05eb466..21ef60452 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.swift @@ -1817,8 +1817,6 @@ fileprivate func _bjs_IdentityCacheBenchmarkIdentity_wrap_extern(_ pointer: Unsa nonisolated(unsafe) var _SimpleClassSwiftIdentity_identityTable: Set = [] -nonisolated(unsafe) var _SimpleClassSwiftIdentity_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] - @_expose(wasm, "bjs_SimpleClassSwiftIdentity_init") @_cdecl("bjs_SimpleClassSwiftIdentity_init") public func _bjs_SimpleClassSwiftIdentity_init(_ nameBytes: Int32, _ nameLength: Int32, _ count: Int32, _ flag: Int32, _ rate: Float32, _ precise: Float64) -> UnsafeMutableRawPointer { @@ -1956,24 +1954,12 @@ public func _bjs_SimpleClassSwiftIdentity_deinit(_ pointer: UnsafeMutableRawPoin #endif } -@_expose(wasm, "bjs_SimpleClassSwiftIdentity_register_wrapper") -@_cdecl("bjs_SimpleClassSwiftIdentity_register_wrapper") -public func _bjs_SimpleClassSwiftIdentity_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { - #if arch(wasm32) - _SimpleClassSwiftIdentity_wrapperRefs[pointer] = jsRef - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_SimpleClassSwiftIdentity_release_wrapper") @_cdecl("bjs_SimpleClassSwiftIdentity_release_wrapper") public func _bjs_SimpleClassSwiftIdentity_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - guard let jsRef = _SimpleClassSwiftIdentity_wrapperRefs.removeValue(forKey: pointer) else { return } - _SimpleClassSwiftIdentity_identityTable.remove(pointer) + guard _SimpleClassSwiftIdentity_identityTable.remove(pointer) != nil else { return } Unmanaged.fromOpaque(pointer).release() - _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") #endif @@ -2019,8 +2005,6 @@ fileprivate func _bjs_SimpleClassSwiftIdentity_wrap_extern(_ pointer: UnsafeMuta nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_identityTable: Set = [] -nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] - @_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_init") @_cdecl("bjs_ClassRoundtripSwiftIdentity_init") public func _bjs_ClassRoundtripSwiftIdentity_init() -> UnsafeMutableRawPointer { @@ -2107,24 +2091,12 @@ public func _bjs_ClassRoundtripSwiftIdentity_deinit(_ pointer: UnsafeMutableRawP #endif } -@_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_register_wrapper") -@_cdecl("bjs_ClassRoundtripSwiftIdentity_register_wrapper") -public func _bjs_ClassRoundtripSwiftIdentity_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { - #if arch(wasm32) - _ClassRoundtripSwiftIdentity_wrapperRefs[pointer] = jsRef - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_ClassRoundtripSwiftIdentity_release_wrapper") @_cdecl("bjs_ClassRoundtripSwiftIdentity_release_wrapper") public func _bjs_ClassRoundtripSwiftIdentity_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - guard let jsRef = _ClassRoundtripSwiftIdentity_wrapperRefs.removeValue(forKey: pointer) else { return } - _ClassRoundtripSwiftIdentity_identityTable.remove(pointer) + guard _ClassRoundtripSwiftIdentity_identityTable.remove(pointer) != nil else { return } Unmanaged.fromOpaque(pointer).release() - _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") #endif @@ -2170,8 +2142,6 @@ fileprivate func _bjs_ClassRoundtripSwiftIdentity_wrap_extern(_ pointer: UnsafeM nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_identityTable: Set = [] -nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] - @_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_init") @_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_init") public func _bjs_IdentityCacheBenchmarkSwiftIdentity_init() -> UnsafeMutableRawPointer { @@ -2225,24 +2195,12 @@ public func _bjs_IdentityCacheBenchmarkSwiftIdentity_deinit(_ pointer: UnsafeMut #endif } -@_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_register_wrapper") -@_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_register_wrapper") -public func _bjs_IdentityCacheBenchmarkSwiftIdentity_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { - #if arch(wasm32) - _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs[pointer] = jsRef - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_IdentityCacheBenchmarkSwiftIdentity_release_wrapper") @_cdecl("bjs_IdentityCacheBenchmarkSwiftIdentity_release_wrapper") public func _bjs_IdentityCacheBenchmarkSwiftIdentity_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - guard let jsRef = _IdentityCacheBenchmarkSwiftIdentity_wrapperRefs.removeValue(forKey: pointer) else { return } - _IdentityCacheBenchmarkSwiftIdentity_identityTable.remove(pointer) + guard _IdentityCacheBenchmarkSwiftIdentity_identityTable.remove(pointer) != nil else { return } Unmanaged.fromOpaque(pointer).release() - _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") #endif diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index 459f979f4..72892045d 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -711,20 +711,14 @@ public class ExportSwift { func renderSingleExportedClass(klass: ExportedClass) throws -> [DeclSyntax] { var decls: [DeclSyntax] = [] - // identityMode: "swift" — per-class state. Simpler than the original - // id-based design: the JS-side cache is keyed directly by pointer (as - // a strong Map), so Swift only needs: - // - a Set of pointers that already have a JS wrapper - // - a Map of pointer → JS ref (so Swift can release the JS ref - // when the wrapper is released) - // See DECISIONS.md D18 for why this supersedes the 5-global design. + // identityMode: "swift" — per-class state. Post-D19: Swift no longer + // holds the JS wrapper ref; JS keeps the wrapper alive in its own + // strong `Map`. Swift only tracks "have I already + // issued a wrapper for this pointer?" via a Set. if isSwiftIdentityMode(klass.name) { decls.append( "nonisolated(unsafe) var _\(raw: klass.name)_identityTable: Set = []" ) - decls.append( - "nonisolated(unsafe) var _\(raw: klass.name)_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:]" - ) } if let constructor = klass.constructor { @@ -766,23 +760,11 @@ public class ExportSwift { decls.append(DeclSyntax(funcDecl)) } - // identityMode: "swift" — emit the register/release thunks that pair - // with the JS-side fresh-wrapper handshake. Both thunks are keyed by - // raw pointer — no id indirection. See DECISIONS.md D18. + // identityMode: "swift" — emit the release thunk. Post-D19 there is + // no separate register thunk: Swift does not hold the JS ref, JS does + // (via its `Map`). Release just drops the Set entry + // and deallocates the Swift heap object. if isSwiftIdentityMode(klass.name) { - do { - let registerDecl = SwiftCodePattern.buildExposedFunctionDecl( - abiName: "bjs_\(klass.abiName)_register_wrapper", - signature: SwiftSignatureBuilder.buildABIFunctionSignature( - abiParameters: [("pointer", .pointer), ("jsRef", .i32)], - returnType: nil - ) - ) { printer in - printer.write("_\(klass.name)_wrapperRefs[pointer] = jsRef") - } - decls.append(DeclSyntax(registerDecl)) - } - do { let releaseDecl = SwiftCodePattern.buildExposedFunctionDecl( abiName: "bjs_\(klass.abiName)_release_wrapper", @@ -791,10 +773,8 @@ public class ExportSwift { returnType: nil ) ) { printer in - printer.write("guard let jsRef = _\(klass.name)_wrapperRefs.removeValue(forKey: pointer) else { return }") - printer.write("_\(klass.name)_identityTable.remove(pointer)") + printer.write("guard _\(klass.name)_identityTable.remove(pointer) != nil else { return }") printer.write("Unmanaged<\(klass.swiftCallName)>.fromOpaque(pointer).release()") - printer.write("_swift_js_release_ref(jsRef)") } decls.append(DeclSyntax(releaseDecl)) } diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 4bf3ce056..ca579c88a 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -2060,11 +2060,14 @@ extension BridgeJSLink { dtsExportEntryPrinter.write("\(klass.name): {") if useSwiftIdentity { - // DECISIONS.md D18: the `.swift`-mode class is standalone — it does NOT + // DECISIONS.md D18 + D19: the `.swift`-mode class is standalone — it does NOT // extend `SwiftHeapObject`. It keeps a strong `Map` so - // re-exports of the same Swift pointer get the same JS wrapper. Swift - // signals "cache hit" via a single `freshBit` push on the i32 stack - // (0 = cached, 1 = fresh). No id indirection, no dense array. + // re-exports of the same Swift pointer get the same JS wrapper. + // + // Swift signals "cache hit" via a single `freshBit` push on the i32 stack + // (0 = cached, 1 = fresh). Post-D19 the JS side owns the wrapper lifetime + // entirely — no `swift.memory.retain`, no `register_wrapper` callback. + // Swift only tracks a `Set` of pointers it has retained. jsPrinter.write("class \(klass.name) {") jsPrinter.indent { jsPrinter.write("static __swiftIdentityWrappers = new Map();") @@ -2081,10 +2084,6 @@ extension BridgeJSLink { jsPrinter.write("obj.pointer = pointer;") jsPrinter.write("obj.__swiftIdentityHasReleased = false;") jsPrinter.write("\(klass.name).__swiftIdentityWrappers.set(pointer, obj);") - // Retain the wrapper in swift.memory so Swift can hold it strongly - // via `__wrapperRefs[pointer]` until release_wrapper fires. - jsPrinter.write("const jsRef = swift.memory.retain(obj);") - jsPrinter.write("instance.exports.bjs_\(klass.abiName)_register_wrapper(pointer, jsRef);") jsPrinter.write("return obj;") } jsPrinter.write("}") @@ -2100,9 +2099,9 @@ extension BridgeJSLink { jsPrinter.write("if (this.__swiftIdentityHasReleased) return;") jsPrinter.write("this.__swiftIdentityHasReleased = true;") jsPrinter.write("const pointer = this.pointer;") + // Swift's release_wrapper drops the Set entry + releases the Swift + // heap object. JS drops the Map entry. jsPrinter.write("instance.exports.bjs_\(klass.abiName)_release_wrapper(pointer);") - // Swift's release_wrapper already released the JS ref; clear - // the JS-side map entry. jsPrinter.write("\(klass.name).__swiftIdentityWrappers.delete(pointer);") } jsPrinter.write("}") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift index 9b9579330..8fc5f10cb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift @@ -1,7 +1,5 @@ nonisolated(unsafe) var _SwiftCached_identityTable: Set = [] -nonisolated(unsafe) var _SwiftCached_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] - @_expose(wasm, "bjs_SwiftCached_init") @_cdecl("bjs_SwiftCached_init") public func _bjs_SwiftCached_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { @@ -55,24 +53,12 @@ public func _bjs_SwiftCached_deinit(_ pointer: UnsafeMutableRawPointer) -> Void #endif } -@_expose(wasm, "bjs_SwiftCached_register_wrapper") -@_cdecl("bjs_SwiftCached_register_wrapper") -public func _bjs_SwiftCached_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { - #if arch(wasm32) - _SwiftCached_wrapperRefs[pointer] = jsRef - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_SwiftCached_release_wrapper") @_cdecl("bjs_SwiftCached_release_wrapper") public func _bjs_SwiftCached_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - guard let jsRef = _SwiftCached_wrapperRefs.removeValue(forKey: pointer) else { return } - _SwiftCached_identityTable.remove(pointer) + guard _SwiftCached_identityTable.remove(pointer) != nil else { return } Unmanaged.fromOpaque(pointer).release() - _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") #endif diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js index 5cf4f8f60..b510d8f1b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js @@ -316,8 +316,6 @@ export async function createInstantiator(options, swift) { obj.pointer = pointer; obj.__swiftIdentityHasReleased = false; UncachedModel.__swiftIdentityWrappers.set(pointer, obj); - const jsRef = swift.memory.retain(obj); - instance.exports.bjs_UncachedModel_register_wrapper(pointer, jsRef); return obj; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js index 9f5ea6426..a6524ecf3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js @@ -281,8 +281,6 @@ export async function createInstantiator(options, swift) { obj.pointer = pointer; obj.__swiftIdentityHasReleased = false; SwiftCached.__swiftIdentityWrappers.set(pointer, obj); - const jsRef = swift.memory.retain(obj); - instance.exports.bjs_SwiftCached_register_wrapper(pointer, jsRef); return obj; } diff --git a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift index 10c04b2a5..16bd02520 100644 --- a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift @@ -464,8 +464,6 @@ fileprivate func _bjs_ArrayIdentityElement_wrap_extern(_ pointer: UnsafeMutableR nonisolated(unsafe) var _SwiftIdentityTestSubject_identityTable: Set = [] -nonisolated(unsafe) var _SwiftIdentityTestSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] - @_expose(wasm, "bjs_SwiftIdentityTestSubject_init") @_cdecl("bjs_SwiftIdentityTestSubject_init") public func _bjs_SwiftIdentityTestSubject_init(_ value: Int32) -> UnsafeMutableRawPointer { @@ -552,24 +550,12 @@ public func _bjs_SwiftIdentityTestSubject_deinit(_ pointer: UnsafeMutableRawPoin #endif } -@_expose(wasm, "bjs_SwiftIdentityTestSubject_register_wrapper") -@_cdecl("bjs_SwiftIdentityTestSubject_register_wrapper") -public func _bjs_SwiftIdentityTestSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { - #if arch(wasm32) - _SwiftIdentityTestSubject_wrapperRefs[pointer] = jsRef - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_SwiftIdentityTestSubject_release_wrapper") @_cdecl("bjs_SwiftIdentityTestSubject_release_wrapper") public func _bjs_SwiftIdentityTestSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - guard let jsRef = _SwiftIdentityTestSubject_wrapperRefs.removeValue(forKey: pointer) else { return } - _SwiftIdentityTestSubject_identityTable.remove(pointer) + guard _SwiftIdentityTestSubject_identityTable.remove(pointer) != nil else { return } Unmanaged.fromOpaque(pointer).release() - _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") #endif @@ -615,8 +601,6 @@ fileprivate func _bjs_SwiftIdentityTestSubject_wrap_extern(_ pointer: UnsafeMuta nonisolated(unsafe) var _SwiftRetainLeakSubject_identityTable: Set = [] -nonisolated(unsafe) var _SwiftRetainLeakSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] - @_expose(wasm, "bjs_SwiftRetainLeakSubject_init") @_cdecl("bjs_SwiftRetainLeakSubject_init") public func _bjs_SwiftRetainLeakSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { @@ -670,24 +654,12 @@ public func _bjs_SwiftRetainLeakSubject_deinit(_ pointer: UnsafeMutableRawPointe #endif } -@_expose(wasm, "bjs_SwiftRetainLeakSubject_register_wrapper") -@_cdecl("bjs_SwiftRetainLeakSubject_register_wrapper") -public func _bjs_SwiftRetainLeakSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { - #if arch(wasm32) - _SwiftRetainLeakSubject_wrapperRefs[pointer] = jsRef - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_SwiftRetainLeakSubject_release_wrapper") @_cdecl("bjs_SwiftRetainLeakSubject_release_wrapper") public func _bjs_SwiftRetainLeakSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - guard let jsRef = _SwiftRetainLeakSubject_wrapperRefs.removeValue(forKey: pointer) else { return } - _SwiftRetainLeakSubject_identityTable.remove(pointer) + guard _SwiftRetainLeakSubject_identityTable.remove(pointer) != nil else { return } Unmanaged.fromOpaque(pointer).release() - _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") #endif @@ -733,8 +705,6 @@ fileprivate func _bjs_SwiftRetainLeakSubject_wrap_extern(_ pointer: UnsafeMutabl nonisolated(unsafe) var _SwiftChurnSubject_identityTable: Set = [] -nonisolated(unsafe) var _SwiftChurnSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] - @_expose(wasm, "bjs_SwiftChurnSubject_init") @_cdecl("bjs_SwiftChurnSubject_init") public func _bjs_SwiftChurnSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { @@ -788,24 +758,12 @@ public func _bjs_SwiftChurnSubject_deinit(_ pointer: UnsafeMutableRawPointer) -> #endif } -@_expose(wasm, "bjs_SwiftChurnSubject_register_wrapper") -@_cdecl("bjs_SwiftChurnSubject_register_wrapper") -public func _bjs_SwiftChurnSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { - #if arch(wasm32) - _SwiftChurnSubject_wrapperRefs[pointer] = jsRef - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_SwiftChurnSubject_release_wrapper") @_cdecl("bjs_SwiftChurnSubject_release_wrapper") public func _bjs_SwiftChurnSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - guard let jsRef = _SwiftChurnSubject_wrapperRefs.removeValue(forKey: pointer) else { return } - _SwiftChurnSubject_identityTable.remove(pointer) + guard _SwiftChurnSubject_identityTable.remove(pointer) != nil else { return } Unmanaged.fromOpaque(pointer).release() - _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") #endif diff --git a/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift index 7fe1804e8..296758626 100644 --- a/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift @@ -127,8 +127,6 @@ public func _bjs_maybeConfigSwiftSubject(_ present: Int32) -> Void { nonisolated(unsafe) var _ConfigSwiftSubject_identityTable: Set = [] -nonisolated(unsafe) var _ConfigSwiftSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] - @_expose(wasm, "bjs_ConfigSwiftSubject_init") @_cdecl("bjs_ConfigSwiftSubject_init") public func _bjs_ConfigSwiftSubject_init(_ value: Int32) -> UnsafeMutableRawPointer { @@ -215,24 +213,12 @@ public func _bjs_ConfigSwiftSubject_deinit(_ pointer: UnsafeMutableRawPointer) - #endif } -@_expose(wasm, "bjs_ConfigSwiftSubject_register_wrapper") -@_cdecl("bjs_ConfigSwiftSubject_register_wrapper") -public func _bjs_ConfigSwiftSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { - #if arch(wasm32) - _ConfigSwiftSubject_wrapperRefs[pointer] = jsRef - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_ConfigSwiftSubject_release_wrapper") @_cdecl("bjs_ConfigSwiftSubject_release_wrapper") public func _bjs_ConfigSwiftSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - guard let jsRef = _ConfigSwiftSubject_wrapperRefs.removeValue(forKey: pointer) else { return } - _ConfigSwiftSubject_identityTable.remove(pointer) + guard _ConfigSwiftSubject_identityTable.remove(pointer) != nil else { return } Unmanaged.fromOpaque(pointer).release() - _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") #endif @@ -278,8 +264,6 @@ fileprivate func _bjs_ConfigSwiftSubject_wrap_extern(_ pointer: UnsafeMutableRaw nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_identityTable: Set = [] -nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] - @_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_init") @_cdecl("bjs_ConfigSwiftRetainLeakSubject_init") public func _bjs_ConfigSwiftRetainLeakSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { @@ -333,24 +317,12 @@ public func _bjs_ConfigSwiftRetainLeakSubject_deinit(_ pointer: UnsafeMutableRaw #endif } -@_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_register_wrapper") -@_cdecl("bjs_ConfigSwiftRetainLeakSubject_register_wrapper") -public func _bjs_ConfigSwiftRetainLeakSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { - #if arch(wasm32) - _ConfigSwiftRetainLeakSubject_wrapperRefs[pointer] = jsRef - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_ConfigSwiftRetainLeakSubject_release_wrapper") @_cdecl("bjs_ConfigSwiftRetainLeakSubject_release_wrapper") public func _bjs_ConfigSwiftRetainLeakSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - guard let jsRef = _ConfigSwiftRetainLeakSubject_wrapperRefs.removeValue(forKey: pointer) else { return } - _ConfigSwiftRetainLeakSubject_identityTable.remove(pointer) + guard _ConfigSwiftRetainLeakSubject_identityTable.remove(pointer) != nil else { return } Unmanaged.fromOpaque(pointer).release() - _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") #endif @@ -396,8 +368,6 @@ fileprivate func _bjs_ConfigSwiftRetainLeakSubject_wrap_extern(_ pointer: Unsafe nonisolated(unsafe) var _ConfigSwiftChurnSubject_identityTable: Set = [] -nonisolated(unsafe) var _ConfigSwiftChurnSubject_wrapperRefs: [UnsafeMutableRawPointer: Int32] = [:] - @_expose(wasm, "bjs_ConfigSwiftChurnSubject_init") @_cdecl("bjs_ConfigSwiftChurnSubject_init") public func _bjs_ConfigSwiftChurnSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer { @@ -451,24 +421,12 @@ public func _bjs_ConfigSwiftChurnSubject_deinit(_ pointer: UnsafeMutableRawPoint #endif } -@_expose(wasm, "bjs_ConfigSwiftChurnSubject_register_wrapper") -@_cdecl("bjs_ConfigSwiftChurnSubject_register_wrapper") -public func _bjs_ConfigSwiftChurnSubject_register_wrapper(_ pointer: UnsafeMutableRawPointer, _ jsRef: Int32) -> Void { - #if arch(wasm32) - _ConfigSwiftChurnSubject_wrapperRefs[pointer] = jsRef - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_ConfigSwiftChurnSubject_release_wrapper") @_cdecl("bjs_ConfigSwiftChurnSubject_release_wrapper") public func _bjs_ConfigSwiftChurnSubject_release_wrapper(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - guard let jsRef = _ConfigSwiftChurnSubject_wrapperRefs.removeValue(forKey: pointer) else { return } - _ConfigSwiftChurnSubject_identityTable.remove(pointer) + guard _ConfigSwiftChurnSubject_identityTable.remove(pointer) != nil else { return } Unmanaged.fromOpaque(pointer).release() - _swift_js_release_ref(jsRef) #else fatalError("Only available on WebAssembly") #endif From 37fbaf0ccc4645923fc15055ca6cb193f7346b4f Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Wed, 22 Apr 2026 14:29:36 +0200 Subject: [PATCH 17/18] =?UTF-8?q?refactor:=20drop=20freshBit=20side-channe?= =?UTF-8?q?l=20=E2=80=94=20derive=20hit/miss=20symmetrically?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With Swift's Set and JS's Map updated at the same cache boundaries and keyed identically, the freshBit signal is redundant. Swift can use Set.insert(ptr).inserted to detect a miss in a single op; JS can use Map.get(pointer) and check for undefined. Swift return-lowering simplifies to: let ptr = Unmanaged.passUnretained(ret).toOpaque() if __identityTable.insert(ptr).inserted { _ = Unmanaged.passRetained(ret) } return ptr JS __wrap simplifies to: const cached = __swiftIdentityWrappers.get(pointer) if (cached !== undefined) return cached // build wrapper, insert into Map No stack push/pop per return on the swift-mode path. Swift heap-object lifetime invariants unchanged. Performance (500k iters, median ms, swift mode only): v3 v4 delta vs v3 vs pointer vs none passBothWaysRoundtrip 27 26 -4% -17% -84% getPoolRepeated_100 34 32 -6% -31% -83% swiftCreatesObject 347 593 +71% (CV noise; see below) churnObjects 332 317 -5% -60% -99% swiftConsumesSameObject 17 10 parity parity -42% swift mode is now a strict Pareto improvement over pointer mode on every scenario: faster on hit, faster on miss, faster on churn, parity on the one-way path. The swiftCreatesObject v3→v4 number is noisy across runs (37% CV) — the v3 standalone 347ms and v4 three-way 593ms overlap within CV; both are ~5x faster than pointer mode's 2021ms and within 15-30% of the 'none' baseline (514ms). 165/165 tests green. --- Benchmarks/Sources/Generated/BridgeJS.swift | 69 ++++------------ .../Sources/BridgeJSCore/ExportSwift.swift | 39 ++++------ .../Sources/BridgeJSLink/BridgeJSLink.swift | 23 +++--- .../IdentityModeSwiftClass.swift | 17 +--- .../IdentityModeClass.ConfigSwift.js | 6 +- .../IdentityModeSwiftClass.js | 6 +- .../Generated/BridgeJS.swift | 78 +++++-------------- .../Generated/BridgeJS.swift | 78 +++++-------------- 8 files changed, 84 insertions(+), 232 deletions(-) diff --git a/Benchmarks/Sources/Generated/BridgeJS.swift b/Benchmarks/Sources/Generated/BridgeJS.swift index 21ef60452..2eefa9454 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.swift @@ -1824,14 +1824,9 @@ public func _bjs_SimpleClassSwiftIdentity_init(_ nameBytes: Int32, _ nameLength: let ret = SimpleClassSwiftIdentity(name: String.bridgeJSLiftParameter(nameBytes, nameLength), count: Int.bridgeJSLiftParameter(count), flag: Bool.bridgeJSLiftParameter(flag), rate: Float.bridgeJSLiftParameter(rate), precise: Double.bridgeJSLiftParameter(precise)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SimpleClassSwiftIdentity_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _SimpleClassSwiftIdentity_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _SimpleClassSwiftIdentity_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -1969,13 +1964,9 @@ extension SimpleClassSwiftIdentity { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if _SimpleClassSwiftIdentity_identityTable.contains(ptr) { - _swift_js_push_i32(0) - return ptr + if _SimpleClassSwiftIdentity_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) } - _ = Unmanaged.passRetained(self) - _SimpleClassSwiftIdentity_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } _swift_js_push_pointer(ptr) @@ -2012,14 +2003,9 @@ public func _bjs_ClassRoundtripSwiftIdentity_init() -> UnsafeMutableRawPointer { let ret = ClassRoundtripSwiftIdentity() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ClassRoundtripSwiftIdentity_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _ClassRoundtripSwiftIdentity_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _ClassRoundtripSwiftIdentity_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -2034,14 +2020,9 @@ public func _bjs_ClassRoundtripSwiftIdentity_roundtripSimpleClassSwiftIdentity(_ let ret = ClassRoundtripSwiftIdentity.bridgeJSLiftParameter(_self).roundtripSimpleClassSwiftIdentity(_: SimpleClassSwiftIdentity.bridgeJSLiftParameter(obj)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SimpleClassSwiftIdentity_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _SimpleClassSwiftIdentity_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _SimpleClassSwiftIdentity_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -2056,14 +2037,9 @@ public func _bjs_ClassRoundtripSwiftIdentity_makeSimpleClassSwiftIdentity(_ _sel let ret = ClassRoundtripSwiftIdentity.bridgeJSLiftParameter(_self).makeSimpleClassSwiftIdentity() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SimpleClassSwiftIdentity_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _SimpleClassSwiftIdentity_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _SimpleClassSwiftIdentity_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -2106,13 +2082,9 @@ extension ClassRoundtripSwiftIdentity { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if _ClassRoundtripSwiftIdentity_identityTable.contains(ptr) { - _swift_js_push_i32(0) - return ptr + if _ClassRoundtripSwiftIdentity_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) } - _ = Unmanaged.passRetained(self) - _ClassRoundtripSwiftIdentity_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } _swift_js_push_pointer(ptr) @@ -2149,14 +2121,9 @@ public func _bjs_IdentityCacheBenchmarkSwiftIdentity_init() -> UnsafeMutableRawP let ret = IdentityCacheBenchmarkSwiftIdentity() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _IdentityCacheBenchmarkSwiftIdentity_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _IdentityCacheBenchmarkSwiftIdentity_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _IdentityCacheBenchmarkSwiftIdentity_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -2210,13 +2177,9 @@ extension IdentityCacheBenchmarkSwiftIdentity { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if _IdentityCacheBenchmarkSwiftIdentity_identityTable.contains(ptr) { - _swift_js_push_i32(0) - return ptr + if _IdentityCacheBenchmarkSwiftIdentity_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) } - _ = Unmanaged.passRetained(self) - _IdentityCacheBenchmarkSwiftIdentity_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } _swift_js_push_pointer(ptr) diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index 72892045d..ca837253c 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -352,28 +352,21 @@ public class ExportSwift { """ ) case .swiftHeapObject(let className) where isSwiftIdentityMode(className): - // identityMode: "swift" — Swift tracks which pointers have - // an associated JS wrapper via a per-class Set. On hit, skip - // the passRetained; JS keeps the wrapper alive via its - // strong `Map`. On miss, retain once and - // signal freshBit=1 so JS builds the wrapper. - // - // ABI: one i32 push after the return pointer — `freshBit`. - // JS pops `freshBit` and either returns its cached wrapper - // (0) or builds a fresh one and calls `register_wrapper` to - // give Swift the retained JS ref (1). + // identityMode: "swift" — Swift's per-class Set tracks which + // pointers have been retained. On miss, retain once; on hit, + // skip. No signalling to JS needed: JS checks its own + // `Map` and derives hit/miss symmetrically. + // (See DECISIONS.md D20 for why dropping freshBit is safe: + // the Swift Set and the JS Map stay in lockstep by + // construction — both are keyed by pointer and updated at + // the same cache boundaries.) append( """ return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _\(raw: className)_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _\(raw: className)_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _\(raw: className)_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } """ @@ -781,20 +774,16 @@ public class ExportSwift { // Override the default `_BridgedSwiftHeapObject.bridgeJSStackPush` // so array-element returns (`[SwiftCached]`) go through the same - // identity-cache handshake. See DECISIONS.md D15 (still applies — - // only the internals changed; D18 simplified them). + // identity-cache handshake. Post-D20: no `freshBit` push — JS + // checks its own Map for hit/miss. let stackPushExt: DeclSyntax = """ extension \(raw: klass.swiftCallName) { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if _\(raw: klass.name)_identityTable.contains(ptr) { - _swift_js_push_i32(0) - return ptr + if _\(raw: klass.name)_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) } - _ = Unmanaged.passRetained(self) - _\(raw: klass.name)_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } _swift_js_push_pointer(ptr) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index ca579c88a..93dd57229 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -2060,26 +2060,23 @@ extension BridgeJSLink { dtsExportEntryPrinter.write("\(klass.name): {") if useSwiftIdentity { - // DECISIONS.md D18 + D19: the `.swift`-mode class is standalone — it does NOT - // extend `SwiftHeapObject`. It keeps a strong `Map` so - // re-exports of the same Swift pointer get the same JS wrapper. + // DECISIONS.md D18 + D19 + D20: the `.swift`-mode class is standalone — + // it does NOT extend `SwiftHeapObject`. It keeps a strong + // `Map` so re-exports of the same Swift pointer get the + // same JS wrapper. // - // Swift signals "cache hit" via a single `freshBit` push on the i32 stack - // (0 = cached, 1 = fresh). Post-D19 the JS side owns the wrapper lifetime - // entirely — no `swift.memory.retain`, no `register_wrapper` callback. - // Swift only tracks a `Set` of pointers it has retained. + // D20: no side-channel at all. JS's `Map.get(pointer)` serves as both + // the "is it cached?" test and the lookup: `undefined` ⇒ miss ⇒ build + // wrapper. Swift's per-class `Set` stays in lockstep because + // Swift updates it at the same cache boundaries as JS updates its Map. jsPrinter.write("class \(klass.name) {") jsPrinter.indent { jsPrinter.write("static __swiftIdentityWrappers = new Map();") jsPrinter.nextLine() jsPrinter.write("static __wrap(pointer) {") jsPrinter.indent { - jsPrinter.write("const freshBit = bjs.swift_js_pop_i32();") - jsPrinter.write("if (freshBit === 0) {") - jsPrinter.indent { - jsPrinter.write("return \(klass.name).__swiftIdentityWrappers.get(pointer);") - } - jsPrinter.write("}") + jsPrinter.write("const cached = \(klass.name).__swiftIdentityWrappers.get(pointer);") + jsPrinter.write("if (cached !== undefined) return cached;") jsPrinter.write("const obj = Object.create(\(klass.name).prototype);") jsPrinter.write("obj.pointer = pointer;") jsPrinter.write("obj.__swiftIdentityHasReleased = false;") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift index 8fc5f10cb..c9aa4e657 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift @@ -7,14 +7,9 @@ public func _bjs_SwiftCached_init(_ nameBytes: Int32, _ nameLength: Int32) -> Un let ret = SwiftCached(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftCached_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _SwiftCached_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _SwiftCached_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -68,13 +63,9 @@ extension SwiftCached { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if _SwiftCached_identityTable.contains(ptr) { - _swift_js_push_i32(0) - return ptr + if _SwiftCached_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) } - _ = Unmanaged.passRetained(self) - _SwiftCached_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } _swift_js_push_pointer(ptr) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js index b510d8f1b..5275d1042 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigSwift.js @@ -308,10 +308,8 @@ export async function createInstantiator(options, swift) { static __swiftIdentityWrappers = new Map(); static __wrap(pointer) { - const freshBit = bjs.swift_js_pop_i32(); - if (freshBit === 0) { - return UncachedModel.__swiftIdentityWrappers.get(pointer); - } + const cached = UncachedModel.__swiftIdentityWrappers.get(pointer); + if (cached !== undefined) return cached; const obj = Object.create(UncachedModel.prototype); obj.pointer = pointer; obj.__swiftIdentityHasReleased = false; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js index a6524ecf3..773c8283f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js @@ -273,10 +273,8 @@ export async function createInstantiator(options, swift) { static __swiftIdentityWrappers = new Map(); static __wrap(pointer) { - const freshBit = bjs.swift_js_pop_i32(); - if (freshBit === 0) { - return SwiftCached.__swiftIdentityWrappers.get(pointer); - } + const cached = SwiftCached.__swiftIdentityWrappers.get(pointer); + if (cached !== undefined) return cached; const obj = Object.create(SwiftCached.prototype); obj.pointer = pointer; obj.__swiftIdentityHasReleased = false; diff --git a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift index 16bd02520..291e9b441 100644 --- a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift @@ -140,14 +140,9 @@ public func _bjs_getSharedSwiftSubject() -> UnsafeMutableRawPointer { let ret = getSharedSwiftSubject() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftIdentityTestSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _SwiftIdentityTestSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _SwiftIdentityTestSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -172,14 +167,9 @@ public func _bjs_getRetainLeakSubjectSwift() -> UnsafeMutableRawPointer { let ret = getRetainLeakSubjectSwift() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftRetainLeakSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _SwiftRetainLeakSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _SwiftRetainLeakSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -471,14 +461,9 @@ public func _bjs_SwiftIdentityTestSubject_init(_ value: Int32) -> UnsafeMutableR let ret = SwiftIdentityTestSubject(value: Int.bridgeJSLiftParameter(value)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftIdentityTestSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _SwiftIdentityTestSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _SwiftIdentityTestSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -493,14 +478,9 @@ public func _bjs_SwiftIdentityTestSubject_self_(_ _self: UnsafeMutableRawPointer let ret = SwiftIdentityTestSubject.bridgeJSLiftParameter(_self).self_() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftIdentityTestSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _SwiftIdentityTestSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _SwiftIdentityTestSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -565,13 +545,9 @@ extension SwiftIdentityTestSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if _SwiftIdentityTestSubject_identityTable.contains(ptr) { - _swift_js_push_i32(0) - return ptr + if _SwiftIdentityTestSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) } - _ = Unmanaged.passRetained(self) - _SwiftIdentityTestSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } _swift_js_push_pointer(ptr) @@ -608,14 +584,9 @@ public func _bjs_SwiftRetainLeakSubject_init(_ tag: Int32) -> UnsafeMutableRawPo let ret = SwiftRetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftRetainLeakSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _SwiftRetainLeakSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _SwiftRetainLeakSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -669,13 +640,9 @@ extension SwiftRetainLeakSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if _SwiftRetainLeakSubject_identityTable.contains(ptr) { - _swift_js_push_i32(0) - return ptr + if _SwiftRetainLeakSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) } - _ = Unmanaged.passRetained(self) - _SwiftRetainLeakSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } _swift_js_push_pointer(ptr) @@ -712,14 +679,9 @@ public func _bjs_SwiftChurnSubject_init(_ tag: Int32) -> UnsafeMutableRawPointer let ret = SwiftChurnSubject(tag: Int.bridgeJSLiftParameter(tag)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftChurnSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _SwiftChurnSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _SwiftChurnSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -773,13 +735,9 @@ extension SwiftChurnSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if _SwiftChurnSubject_identityTable.contains(ptr) { - _swift_js_push_i32(0) - return ptr + if _SwiftChurnSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) } - _ = Unmanaged.passRetained(self) - _SwiftChurnSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } _swift_js_push_pointer(ptr) diff --git a/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift index 296758626..2dc793f29 100644 --- a/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift @@ -14,14 +14,9 @@ public func _bjs_getConfigSwiftSubject() -> UnsafeMutableRawPointer { let ret = getConfigSwiftSubject() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _ConfigSwiftSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _ConfigSwiftSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -46,14 +41,9 @@ public func _bjs_getConfigSwiftRetainLeakSubject() -> UnsafeMutableRawPointer { let ret = getConfigSwiftRetainLeakSubject() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftRetainLeakSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -134,14 +124,9 @@ public func _bjs_ConfigSwiftSubject_init(_ value: Int32) -> UnsafeMutableRawPoin let ret = ConfigSwiftSubject(value: Int.bridgeJSLiftParameter(value)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _ConfigSwiftSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _ConfigSwiftSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -156,14 +141,9 @@ public func _bjs_ConfigSwiftSubject_self_(_ _self: UnsafeMutableRawPointer) -> U let ret = ConfigSwiftSubject.bridgeJSLiftParameter(_self).self_() return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _ConfigSwiftSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _ConfigSwiftSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -228,13 +208,9 @@ extension ConfigSwiftSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if _ConfigSwiftSubject_identityTable.contains(ptr) { - _swift_js_push_i32(0) - return ptr + if _ConfigSwiftSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) } - _ = Unmanaged.passRetained(self) - _ConfigSwiftSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } _swift_js_push_pointer(ptr) @@ -271,14 +247,9 @@ public func _bjs_ConfigSwiftRetainLeakSubject_init(_ tag: Int32) -> UnsafeMutabl let ret = ConfigSwiftRetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftRetainLeakSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -332,13 +303,9 @@ extension ConfigSwiftRetainLeakSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if _ConfigSwiftRetainLeakSubject_identityTable.contains(ptr) { - _swift_js_push_i32(0) - return ptr + if _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) } - _ = Unmanaged.passRetained(self) - _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } _swift_js_push_pointer(ptr) @@ -375,14 +342,9 @@ public func _bjs_ConfigSwiftChurnSubject_init(_ tag: Int32) -> UnsafeMutableRawP let ret = ConfigSwiftChurnSubject(tag: Int.bridgeJSLiftParameter(tag)) return withExtendedLifetime(ret) { let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftChurnSubject_identityTable.contains(ptr) { - // Cache hit: do NOT retain. JS has the wrapper cached. - _swift_js_push_i32(0) - return ptr + if _ConfigSwiftChurnSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(ret) } - _ = Unmanaged.passRetained(ret) - _ConfigSwiftChurnSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } #else @@ -436,13 +398,9 @@ extension ConfigSwiftChurnSubject { @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() - if _ConfigSwiftChurnSubject_identityTable.contains(ptr) { - _swift_js_push_i32(0) - return ptr + if _ConfigSwiftChurnSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) } - _ = Unmanaged.passRetained(self) - _ConfigSwiftChurnSubject_identityTable.insert(ptr) - _swift_js_push_i32(1) return ptr } _swift_js_push_pointer(ptr) From 52ec56cf7034bbb0dd56f7b429a6c8cdf7185d6b Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Wed, 22 Apr 2026 18:14:32 +0200 Subject: [PATCH 18/18] feat: preserve identity across all return shapes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Emit a per-class extension override of _BridgedSwiftHeapObject's bridgeJSLowerReturn that routes through the identity cache, symmetric to the existing bridgeJSStackPush override. Without it, Optional returns bypassed the per-class table: _BridgedAsOptional.bridgeJSLowerReturn calls value.bridgeJSLowerReturn() on the inner heap object, and that call previously hit the default implementation (passRetained + bare pointer) instead of our per-method thunk. With this override, scalar, array-element, and Optional returns all route through the same identity handshake. The existing Optional identity test is upgraded from observability-only to strict === . Side effect: the per-method `case .swiftHeapObject where isSwiftIdentityMode` branch in ExportedThunkBuilder.lowerReturnValue is now redundant — ret.bridgeJSLowerReturn() picks up the extension override automatically. The builder's isSwiftIdentityMode predicate is removed; codegen is simpler. Also drops the ENABLE_TEST_INTROSPECTION compile-flag gate on the Task 5 identity-table-size helpers. The generated BridgeJS.swift always declares the Wasm exports for `@JS func` declarations, so a conditional function definition broke the Generated file on toolchains that didn't pick up the target's swiftSettings define. The helpers are trivial and cost nothing to always-emit in test targets that don't ship. 165/165 tests green. --- Benchmarks/Sources/Generated/BridgeJS.swift | 70 ++++++++-------- Package.swift | 10 +-- .../Sources/BridgeJSCore/ExportSwift.swift | 81 ++++++------------- .../BridgeJS/Sources/BridgeJSCore/Misc.swift | 5 +- .../BridgeJSCore/SwiftToSkeleton.swift | 6 +- .../Sources/BridgeJSLink/BridgeJSLink.swift | 69 +++------------- .../IdentityModeSwiftClass.swift | 18 +++-- .../JavaScriptKit/BridgeJSIntrinsics.swift | 16 ---- .../Identity-Modes-For-Exported-Classes.md | 13 ++- Sources/JavaScriptKit/JSIdentityMode.swift | 9 +-- .../Generated/BridgeJS.swift | 78 +++++++++--------- .../IdentityModeTests.swift | 25 +----- .../JavaScript/IdentityModeTests.mjs | 72 +++++------------ .../SwiftIdentityIntrinsicsTests.swift | 17 ---- .../Generated/BridgeJS.swift | 78 +++++++++--------- .../JavaScript/SwiftIdentityModeTests.mjs | 41 +++------- .../SwiftIdentityModeTests.swift | 23 ++---- 17 files changed, 205 insertions(+), 426 deletions(-) delete mode 100644 Tests/BridgeJSIdentityTests/SwiftIdentityIntrinsicsTests.swift diff --git a/Benchmarks/Sources/Generated/BridgeJS.swift b/Benchmarks/Sources/Generated/BridgeJS.swift index 2eefa9454..2bdb9d90b 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.swift @@ -1822,13 +1822,7 @@ nonisolated(unsafe) var _SimpleClassSwiftIdentity_identityTable: Set UnsafeMutableRawPointer { #if arch(wasm32) let ret = SimpleClassSwiftIdentity(name: String.bridgeJSLiftParameter(nameBytes, nameLength), count: Int.bridgeJSLiftParameter(count), flag: Bool.bridgeJSLiftParameter(flag), rate: Float.bridgeJSLiftParameter(rate), precise: Double.bridgeJSLiftParameter(precise)) - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SimpleClassSwiftIdentity_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -1961,6 +1955,16 @@ public func _bjs_SimpleClassSwiftIdentity_release_wrapper(_ pointer: UnsafeMutab } extension SimpleClassSwiftIdentity { + @_spi(BridgeJS) @_transparent + public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + return withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if _SimpleClassSwiftIdentity_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) + } + return ptr + } + } @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() @@ -2001,13 +2005,7 @@ nonisolated(unsafe) var _ClassRoundtripSwiftIdentity_identityTable: Set UnsafeMutableRawPointer { #if arch(wasm32) let ret = ClassRoundtripSwiftIdentity() - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ClassRoundtripSwiftIdentity_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -2018,13 +2016,7 @@ public func _bjs_ClassRoundtripSwiftIdentity_init() -> UnsafeMutableRawPointer { public func _bjs_ClassRoundtripSwiftIdentity_roundtripSimpleClassSwiftIdentity(_ _self: UnsafeMutableRawPointer, _ obj: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = ClassRoundtripSwiftIdentity.bridgeJSLiftParameter(_self).roundtripSimpleClassSwiftIdentity(_: SimpleClassSwiftIdentity.bridgeJSLiftParameter(obj)) - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SimpleClassSwiftIdentity_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -2035,13 +2027,7 @@ public func _bjs_ClassRoundtripSwiftIdentity_roundtripSimpleClassSwiftIdentity(_ public func _bjs_ClassRoundtripSwiftIdentity_makeSimpleClassSwiftIdentity(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = ClassRoundtripSwiftIdentity.bridgeJSLiftParameter(_self).makeSimpleClassSwiftIdentity() - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SimpleClassSwiftIdentity_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -2079,6 +2065,16 @@ public func _bjs_ClassRoundtripSwiftIdentity_release_wrapper(_ pointer: UnsafeMu } extension ClassRoundtripSwiftIdentity { + @_spi(BridgeJS) @_transparent + public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + return withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if _ClassRoundtripSwiftIdentity_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) + } + return ptr + } + } @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() @@ -2119,13 +2115,7 @@ nonisolated(unsafe) var _IdentityCacheBenchmarkSwiftIdentity_identityTable: Set< public func _bjs_IdentityCacheBenchmarkSwiftIdentity_init() -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = IdentityCacheBenchmarkSwiftIdentity() - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _IdentityCacheBenchmarkSwiftIdentity_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -2174,6 +2164,16 @@ public func _bjs_IdentityCacheBenchmarkSwiftIdentity_release_wrapper(_ pointer: } extension IdentityCacheBenchmarkSwiftIdentity { + @_spi(BridgeJS) @_transparent + public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + return withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if _IdentityCacheBenchmarkSwiftIdentity_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) + } + return ptr + } + } @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() diff --git a/Package.swift b/Package.swift index c5576be44..c7e76a08e 100644 --- a/Package.swift +++ b/Package.swift @@ -225,11 +225,7 @@ let package = Package( "Generated/JavaScript", ], swiftSettings: [ - .enableExperimentalFeature("Extern"), - // Exposes gated `@JS func getSwift*ForChurn() -> Int` helpers - // that let Task-5 id-recycling tests read `__nextId`. - // Do NOT export these in non-test builds. - .define("ENABLE_TEST_INTROSPECTION"), + .enableExperimentalFeature("Extern") ], linkerSettings: testingLinkerFlags ), @@ -241,9 +237,7 @@ let package = Package( "Generated/JavaScript", ], swiftSettings: [ - .enableExperimentalFeature("Extern"), - // Same id-recycling introspection knob as BridgeJSIdentityTests. - .define("ENABLE_TEST_INTROSPECTION"), + .enableExperimentalFeature("Extern") ], linkerSettings: testingLinkerFlags ), diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index ca837253c..55574bf93 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -31,16 +31,8 @@ public class ExportSwift { self.skeleton = skeleton } - /// Resolves whether a class is configured for `identityMode: "swift"`. - /// - /// Per-class `@JS(identityMode:)` takes priority over the skeleton-wide - /// default from `bridge-js.config.json`. Matches the resolution order in - /// `BridgeJSLink.shouldUseIdentityCache` but checks for the `"swift"` value - /// rather than `"pointer"`. - /// - /// Looks up by either the `name` or `swiftCallName` of an exported class — - /// the return-type's `.swiftHeapObject(String)` payload can be either - /// depending on how the type was referenced. + /// Whether a class resolves to `identityMode: "swift"`. Per-class annotation + /// wins over the skeleton-wide config default. func isSwiftIdentityMode(_ className: String) -> Bool { guard let klass = skeleton.classes.first(where: { @@ -125,15 +117,9 @@ public class ExportSwift { var abiReturnType: WasmCoreType? var externDecls: [DeclSyntax] = [] let effects: Effects - /// Predicate that resolves whether a class-name corresponds to an - /// `identityMode: "swift"` class. Default: always false. Threaded - /// through from `ExportSwift.isSwiftIdentityMode(_:)` at construction - /// time so return-lowering can emit the per-class cache glue. - let isSwiftIdentityMode: (String) -> Bool - init(effects: Effects, isSwiftIdentityMode: @escaping (String) -> Bool = { _ in false }) { + init(effects: Effects) { self.effects = effects - self.isSwiftIdentityMode = isSwiftIdentityMode } private func append(_ item: CodeBlockItemSyntax) { @@ -351,26 +337,6 @@ public class ExportSwift { } """ ) - case .swiftHeapObject(let className) where isSwiftIdentityMode(className): - // identityMode: "swift" — Swift's per-class Set tracks which - // pointers have been retained. On miss, retain once; on hit, - // skip. No signalling to JS needed: JS checks its own - // `Map` and derives hit/miss symmetrically. - // (See DECISIONS.md D20 for why dropping freshBit is safe: - // the Swift Set and the JS Map stay in lockstep by - // construction — both are keyed by pointer and updated at - // the same cache boundaries.) - append( - """ - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _\(raw: className)_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } - """ - ) default: append("return ret.bridgeJSLowerReturn()") } @@ -506,8 +472,7 @@ public class ExportSwift { let isStatic = context.isStatic let getterBuilder = ExportedThunkBuilder( - effects: Effects(isAsync: false, isThrows: false, isStatic: isStatic), - isSwiftIdentityMode: isSwiftIdentityMode + effects: Effects(isAsync: false, isThrows: false, isStatic: isStatic) ) if !isStatic { @@ -528,8 +493,7 @@ public class ExportSwift { // Generate property setter if not readonly if !property.isReadonly { let setterBuilder = ExportedThunkBuilder( - effects: Effects(isAsync: false, isThrows: false, isStatic: isStatic), - isSwiftIdentityMode: isSwiftIdentityMode + effects: Effects(isAsync: false, isThrows: false, isStatic: isStatic) ) // Lift parameters based on property type @@ -559,7 +523,7 @@ public class ExportSwift { } func renderSingleExportedFunction(function: ExportedFunction) throws -> DeclSyntax { - let builder = ExportedThunkBuilder(effects: function.effects, isSwiftIdentityMode: isSwiftIdentityMode) + let builder = ExportedThunkBuilder(effects: function.effects) for param in function.parameters { try builder.liftParameter(param: param) } @@ -588,7 +552,7 @@ public class ExportSwift { callName: String, returnType: BridgeType ) throws -> DeclSyntax { - let builder = ExportedThunkBuilder(effects: constructor.effects, isSwiftIdentityMode: isSwiftIdentityMode) + let builder = ExportedThunkBuilder(effects: constructor.effects) for param in constructor.parameters { try builder.liftParameter(param: param) } @@ -602,7 +566,7 @@ public class ExportSwift { ownerTypeName: String, instanceSelfType: BridgeType ) throws -> DeclSyntax { - let builder = ExportedThunkBuilder(effects: method.effects, isSwiftIdentityMode: isSwiftIdentityMode) + let builder = ExportedThunkBuilder(effects: method.effects) if !method.effects.isStatic { try builder.liftParameter(param: Parameter(label: nil, name: "_self", type: instanceSelfType)) } @@ -704,10 +668,7 @@ public class ExportSwift { func renderSingleExportedClass(klass: ExportedClass) throws -> [DeclSyntax] { var decls: [DeclSyntax] = [] - // identityMode: "swift" — per-class state. Post-D19: Swift no longer - // holds the JS wrapper ref; JS keeps the wrapper alive in its own - // strong `Map`. Swift only tracks "have I already - // issued a wrapper for this pointer?" via a Set. + // .swift identity mode: Swift tracks which pointers have been retained. if isSwiftIdentityMode(klass.name) { decls.append( "nonisolated(unsafe) var _\(raw: klass.name)_identityTable: Set = []" @@ -753,10 +714,8 @@ public class ExportSwift { decls.append(DeclSyntax(funcDecl)) } - // identityMode: "swift" — emit the release thunk. Post-D19 there is - // no separate register thunk: Swift does not hold the JS ref, JS does - // (via its `Map`). Release just drops the Set entry - // and deallocates the Swift heap object. + // .swift identity mode: release thunk + overrides that route every + // return shape (scalar, array element, Optional) through the cache. if isSwiftIdentityMode(klass.name) { do { let releaseDecl = SwiftCodePattern.buildExposedFunctionDecl( @@ -772,12 +731,18 @@ public class ExportSwift { decls.append(DeclSyntax(releaseDecl)) } - // Override the default `_BridgedSwiftHeapObject.bridgeJSStackPush` - // so array-element returns (`[SwiftCached]`) go through the same - // identity-cache handshake. Post-D20: no `freshBit` push — JS - // checks its own Map for hit/miss. - let stackPushExt: DeclSyntax = """ + let swiftIdentityOverridesExt: DeclSyntax = """ extension \(raw: klass.swiftCallName) { + @_spi(BridgeJS) @_transparent + public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + return withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if _\(raw: klass.name)_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) + } + return ptr + } + } @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() @@ -790,7 +755,7 @@ public class ExportSwift { } } """ - decls.append(stackPushExt) + decls.append(swiftIdentityOverridesExt) } // Generate ConvertibleToJSValue extension diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift index a246fdc92..c28cb0d92 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift @@ -346,10 +346,9 @@ public struct BridgeJSConfig: Codable { /// /// Valid values: `"none"` | `"pointer"` | `"swift"`. /// - /// - `"none"` (or `nil`): No identity tracking. Each boundary crossing produces a fresh JS wrapper. + /// - `"none"` (or `nil`): no identity tracking; each boundary crossing produces a fresh JS wrapper. /// - `"pointer"`: JS-side identity cache keyed by the Swift pointer (weak refs + `FinalizationRegistry`). - /// - `"swift"`: Swift-side identity cache (opt-in; strong retention of the JS wrapper for the - /// lifetime of the Swift heap object). See spec §3. + /// - `"swift"`: Swift-owned strong identity cache; wrappers live until explicit `release()`. /// /// A per-class `@JS(identityMode: ...)` annotation overrides this default. /// diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index 715029142..a4557a305 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -1202,13 +1202,11 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { let identityArg = arguments.first(where: { $0.label?.text == "identityMode" }) else { return nil } let text = identityArg.expression.trimmedDescription - // Enum member-access form (current `JSIdentityMode` API). + // Enum member-access (current API). if text.contains(".swift") { return "swift" } if text.contains(".pointer") { return "pointer" } if text.contains(".none") { return "none" } - // Legacy Bool literals (pre-D8.1 spelling — map for forward compatibility - // during the transition; the macro itself no longer accepts these, but - // fixtures and third-party sources may still spell it this way.) + // Legacy Bool literals, kept for backward compatibility. if text == "true" { return "pointer" } if text == "false" { return "none" } return nil diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 93dd57229..10441833e 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -25,18 +25,9 @@ public struct BridgeJSLink { self.sharedMemory = sharedMemory } - /// The identity mode config default that applies to a given class. - /// - /// Each `BridgeJSSkeleton` corresponds to one module (one `bridge-js.config.json`). - /// When several modules are linked together (e.g. multiple test targets in one - /// `swift test` invocation), their config defaults MUST NOT bleed across module - /// boundaries: `BridgeJSSwiftIdentityTests`' `"swift"` config default must apply - /// only to its own classes, never to classes in `BridgeJSRuntimeTests` or any - /// other module. - /// - /// We locate the owning skeleton by class identity (name + optional namespace) - /// and return its `exported.identityMode` directly. Fall-through default is - /// `"none"` — matching the pre-change baseline for unconfigured modules. + /// Resolves the identity-mode config default for a class by locating its owning + /// skeleton. Per-skeleton so config defaults don't bleed across modules when + /// multiple targets link together. private func configIdentityMode(for klass: ExportedClass) -> String { for unified in skeletons { guard let exported = unified.exported else { continue } @@ -47,24 +38,11 @@ public struct BridgeJSLink { return "none" } - /// Whether a class should use the JS-side pointer identity cache. - /// - /// Resolution order: per-class annotation beats config default. `"swift"` is - /// a *distinct* mode handled by a separate codegen path (see - /// `shouldUseSwiftIdentityCache`) and must NOT trigger the pointer-cache path - /// here — we return `false` for it so the `"pointer"`/`"none"` output remains - /// byte-identical to the pre-change baseline. private func shouldUseIdentityCache(for klass: ExportedClass) -> Bool { let resolved = klass.identityMode ?? configIdentityMode(for: klass) return resolved == "pointer" } - /// Whether a class should use the Swift-owned identity cache (dense-array fast path). - /// - /// Resolution order mirrors `shouldUseIdentityCache`: per-class annotation wins over - /// config default. Returns `true` only when the resolved value is `"swift"`, in which - /// case `renderExportedClass` emits the standalone `SwiftIdentityHeapObject`-style - /// template (no `SwiftHeapObject` inheritance, no `FinalizationRegistry`, no `WeakRef`). private func shouldUseSwiftIdentityCache(for klass: ExportedClass) -> Bool { let resolved = klass.identityMode ?? configIdentityMode(for: klass) return resolved == "swift" @@ -208,16 +186,9 @@ public struct BridgeJSLink { private func collectLinkData() throws -> LinkData { var data = LinkData() - // Swift heap object class definitions. - // - // The JS-side `SwiftHeapObject` base class is only needed for classes that actually - // extend it (the `.none` and `.pointer` identity modes). `.swift`-mode classes are - // standalone and bring their own dense-array fast path, so if the module only has - // `.swift` classes (or no classes at all), we skip emitting `swiftHeapObjectClassJs`. - // - // The `.d.ts` output is kept byte-identical to the pre-change baseline (spec §6.4): - // `SwiftHeapObject` is still declared whenever the module has any class, because - // `.swift`-mode classes still render `extends SwiftHeapObject` in their interface. + // The JS-side SwiftHeapObject base class is only needed for .none and .pointer + // classes; .swift-mode classes are standalone. The .d.ts declaration is still + // emitted whenever any class exists so the interface shape stays stable. let hasAnyPointerOrNoneClass = skeletons.contains { unified in guard let exported = unified.exported else { return false } return exported.classes.contains { klass in @@ -2046,29 +2017,15 @@ extension BridgeJSLink { let dtsTypePrinter = CodeFragmentPrinter() let dtsExportEntryPrinter = CodeFragmentPrinter() - // Per-class identity mode: determine at codegen time which cache strategy to emit. - // - `.pointer` → JS-owned WeakRef/FinalizationRegistry cache keyed by pointer. - // - `.swift` → Swift-owned dense-array cache keyed by id (Task 4, spec §6.2). - // - `.none` → no caching (pre-change baseline). let useIdentity = shouldUseIdentityCache(for: klass) let useSwiftIdentity = shouldUseSwiftIdentityCache(for: klass) - // `.d.ts` output is kept byte-identical across all three modes (spec §6.4): the - // `.swift`-mode class still satisfies the `SwiftHeapObject` interface (it has a - // `release()` method), so the interface declaration stays the same. dtsTypePrinter.write("export interface \(klass.name) extends SwiftHeapObject {") dtsExportEntryPrinter.write("\(klass.name): {") if useSwiftIdentity { - // DECISIONS.md D18 + D19 + D20: the `.swift`-mode class is standalone — - // it does NOT extend `SwiftHeapObject`. It keeps a strong - // `Map` so re-exports of the same Swift pointer get the - // same JS wrapper. - // - // D20: no side-channel at all. JS's `Map.get(pointer)` serves as both - // the "is it cached?" test and the lookup: `undefined` ⇒ miss ⇒ build - // wrapper. Swift's per-class `Set` stays in lockstep because - // Swift updates it at the same cache boundaries as JS updates its Map. + // Standalone wrapper class with a strong pointer-keyed Map. No + // SwiftHeapObject inheritance, no FinalizationRegistry, no WeakRef. jsPrinter.write("class \(klass.name) {") jsPrinter.indent { jsPrinter.write("static __swiftIdentityWrappers = new Map();") @@ -2096,8 +2053,6 @@ extension BridgeJSLink { jsPrinter.write("if (this.__swiftIdentityHasReleased) return;") jsPrinter.write("this.__swiftIdentityHasReleased = true;") jsPrinter.write("const pointer = this.pointer;") - // Swift's release_wrapper drops the Set entry + releases the Swift - // heap object. JS drops the Map entry. jsPrinter.write("instance.exports.bjs_\(klass.abiName)_release_wrapper(pointer);") jsPrinter.write("\(klass.name).__swiftIdentityWrappers.delete(pointer);") } @@ -2221,11 +2176,7 @@ extension BridgeJSLink { effects: method.effects, intrinsicRegistry: intrinsicRegistry ) - // Spec §6.2: for `.swift`-mode classes, every INSTANCE member must - // guard against use-after-release. Static members are exempt because - // `this` is the class, not the released wrapper. The guard is prepended - // to `body` BEFORE lowering/calling so it emits at the top of the - // generated function body. + // Instance methods on .swift-mode classes guard against use-after-release. if useSwiftIdentity { appendUseAfterReleaseGuard(to: thunkBuilder.body, className: klass.name) } @@ -2300,8 +2251,6 @@ extension BridgeJSLink { effects: Effects(isAsync: false, isThrows: false), intrinsicRegistry: intrinsicRegistry ) - // Spec §6.2: instance-property accessors on `.swift`-mode classes must also - // guard against use-after-release. Static accessors are exempt. if !isStatic && useSwiftIdentity { appendUseAfterReleaseGuard(to: getterThunkBuilder.body, className: classJsName) } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift index c9aa4e657..63cf4a685 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeSwiftClass.swift @@ -5,13 +5,7 @@ nonisolated(unsafe) var _SwiftCached_identityTable: Set public func _bjs_SwiftCached_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = SwiftCached(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftCached_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -60,6 +54,16 @@ public func _bjs_SwiftCached_release_wrapper(_ pointer: UnsafeMutableRawPointer) } extension SwiftCached { + @_spi(BridgeJS) @_transparent + public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + return withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if _SwiftCached_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) + } + return ptr + } + } @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() diff --git a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift index f40decac2..867d0e835 100644 --- a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift +++ b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift @@ -1059,22 +1059,6 @@ private func _swift_js_retain_extern(_ id: Int32) -> Int32 { _swift_js_retain_extern(id) } -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_release") -private func _swift_js_release_ref_extern(_ id: Int32) -#else -/// Releases a previously-retained JavaScript object reference, balancing a -/// prior `_swift_js_retain` call. Used by `identityMode: "swift"` classes to -/// drop Swift's strong hold on the JS wrapper ref when the Swift object is -/// released. -private func _swift_js_release_ref_extern(_ id: Int32) { - _onlyAvailableOnWasm() -} -#endif -@_spi(BridgeJS) @inline(never) public func _swift_js_release_ref(_ id: Int32) { - _swift_js_release_ref_extern(id) -} - #if arch(wasm32) @_extern(wasm, module: "bjs", name: "swift_js_return_optional_bool") private func _swift_js_return_optional_bool_extern(_ isSome: Int32, _ value: Int32) diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Identity-Modes-For-Exported-Classes.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Identity-Modes-For-Exported-Classes.md index 2b6a50242..2606b8c59 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Identity-Modes-For-Exported-Classes.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Identity-Modes-For-Exported-Classes.md @@ -69,12 +69,20 @@ The key differences vs `.pointer`: ```javascript const b = exports.getBuilding(); // allocates a wrapper (if fresh) b.name; // stable === with any future getBuilding() that returns the same Swift object -b.release(); // mandatory for swift mode — frees the Swift heap object and the wrapper slot +b.release(); // frees the Swift heap object and the wrapper slot // after release(): b.name throws "Attempted to call a member on a released Building" ``` Double-release is a safe no-op. Static members (class-level methods, constructors) are not affected by release. +### Why `release()` is required + +`.pointer` mode uses a `WeakRef` and a `FinalizationRegistry` to let the JS garbage collector reclaim wrappers whose users have dropped all references. That safety net is exactly what makes `.pointer` mode's miss path expensive — `FinalizationRegistry.register` and `new WeakRef` allocations account for ~88% of the per-miss cost. `.swift` mode removes both, which is where its performance comes from. The tradeoff is that the JS garbage collector no longer has any hook to trigger cleanup; Swift holds a strong retain until you explicitly release. + +In practice this is the same discipline as any manually-managed resource (file handles, network sockets, native-backed buffers). Use `try { … } finally { x.release() }` for scopes that can throw, or wrap long-lived objects in application code that owns their release. + +If you can't live with explicit release, stay on `.pointer` mode. + ## Benchmarks (summary) Full results in [`Benchmarks/results/swift-side-cache/Benchmarks.md`](../../../../../Benchmarks/results/swift-side-cache/Benchmarks.md). Baseline arm64-macOS, Swift 6.3, Node 22, release build, 500k iters per scenario, median ms: @@ -91,8 +99,7 @@ Full results in [`Benchmarks/results/swift-side-cache/Benchmarks.md`](../../../. ## Known limitations -- **Optional identity is not preserved.** If your Swift API returns `SomeClass?`, `.some(x)` produces a fresh wrapper each call even with `.swift` mode. Lifecycle is still correct, but `a === b` where both come from an optional return will be `false`. Workaround: wrap in `[SomeClass]` (array element identity IS preserved). -- **No automatic cleanup.** You must call `release()` explicitly. A future version may add a Swift-side timeout or GC-assisted cleanup. +- **No GC-driven cleanup.** Wrappers live until `release()` is called. Dropping all JS references to a wrapper without releasing leaks the Swift heap object. See "Why `release()` is required" above. - **Wasm-only.** Like all of BridgeJS, identity modes only activate on `wasm32`. On the host, the macro expands to no-op code paths so your test harness can still compile. ## Choosing a mode diff --git a/Sources/JavaScriptKit/JSIdentityMode.swift b/Sources/JavaScriptKit/JSIdentityMode.swift index 51954baa8..1bc7a66de 100644 --- a/Sources/JavaScriptKit/JSIdentityMode.swift +++ b/Sources/JavaScriptKit/JSIdentityMode.swift @@ -1,11 +1,8 @@ /// Per-class identity caching policy for `@JS`-exported classes. /// -/// See `Docs/superpowers/specs/2026-04-21-swift-side-identity-cache-design.md` §3. -/// -/// - `.none`: No identity caching. Each boundary crossing produces a fresh JS wrapper. -/// - `.pointer`: JS-side identity cache keyed by the Swift pointer (weak refs + `FinalizationRegistry`). -/// - `.swift`: Swift-side identity cache (opt-in; strong retention of the JS wrapper for the -/// lifetime of the Swift heap object). +/// - `.none`: no identity caching; each boundary crossing produces a fresh JS wrapper. +/// - `.pointer`: JS-side weak cache keyed by the Swift pointer. +/// - `.swift`: Swift-owned strong cache; wrappers live until explicit `release()`. public enum JSIdentityMode: String, Sendable { case none case pointer diff --git a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift index 291e9b441..ca2fb3688 100644 --- a/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSIdentityTests/Generated/BridgeJS.swift @@ -138,13 +138,7 @@ public func _bjs_clearArrayPool() -> Void { public func _bjs_getSharedSwiftSubject() -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = getSharedSwiftSubject() - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftIdentityTestSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -165,13 +159,7 @@ public func _bjs_resetSharedSwiftSubject() -> Void { public func _bjs_getRetainLeakSubjectSwift() -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = getRetainLeakSubjectSwift() - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftRetainLeakSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -459,13 +447,7 @@ nonisolated(unsafe) var _SwiftIdentityTestSubject_identityTable: Set UnsafeMutableRawPointer { #if arch(wasm32) let ret = SwiftIdentityTestSubject(value: Int.bridgeJSLiftParameter(value)) - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftIdentityTestSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -476,13 +458,7 @@ public func _bjs_SwiftIdentityTestSubject_init(_ value: Int32) -> UnsafeMutableR public func _bjs_SwiftIdentityTestSubject_self_(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = SwiftIdentityTestSubject.bridgeJSLiftParameter(_self).self_() - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftIdentityTestSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -542,6 +518,16 @@ public func _bjs_SwiftIdentityTestSubject_release_wrapper(_ pointer: UnsafeMutab } extension SwiftIdentityTestSubject { + @_spi(BridgeJS) @_transparent + public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + return withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if _SwiftIdentityTestSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) + } + return ptr + } + } @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() @@ -582,13 +568,7 @@ nonisolated(unsafe) var _SwiftRetainLeakSubject_identityTable: Set UnsafeMutableRawPointer { #if arch(wasm32) let ret = SwiftRetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftRetainLeakSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -637,6 +617,16 @@ public func _bjs_SwiftRetainLeakSubject_release_wrapper(_ pointer: UnsafeMutable } extension SwiftRetainLeakSubject { + @_spi(BridgeJS) @_transparent + public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + return withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if _SwiftRetainLeakSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) + } + return ptr + } + } @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() @@ -677,13 +667,7 @@ nonisolated(unsafe) var _SwiftChurnSubject_identityTable: Set UnsafeMutableRawPointer { #if arch(wasm32) let ret = SwiftChurnSubject(tag: Int.bridgeJSLiftParameter(tag)) - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _SwiftChurnSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -732,6 +716,16 @@ public func _bjs_SwiftChurnSubject_release_wrapper(_ pointer: UnsafeMutableRawPo } extension SwiftChurnSubject { + @_spi(BridgeJS) @_transparent + public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + return withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if _SwiftChurnSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) + } + return ptr + } + } @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() diff --git a/Tests/BridgeJSIdentityTests/IdentityModeTests.swift b/Tests/BridgeJSIdentityTests/IdentityModeTests.swift index 049ac4d8f..76c5d0024 100644 --- a/Tests/BridgeJSIdentityTests/IdentityModeTests.swift +++ b/Tests/BridgeJSIdentityTests/IdentityModeTests.swift @@ -113,11 +113,6 @@ nonisolated(unsafe) private var _arrayPool: [ArrayIdentityElement] = [] } // MARK: - identityMode: .swift per-class opt-in (coexists with .pointer classes above) -// -// These classes explicitly opt INTO Swift-owned identity caching. The target's -// bridge-js.config.json default is "pointer", so the existing classes above stay -// on the pointer path; adding these .swift classes verifies mode coexistence. -// See Docs/superpowers/specs/2026-04-21-swift-side-identity-cache-design.md §5, §6.2. @JS(identityMode: .swift) class SwiftIdentityTestSubject { @JS var value: Int @@ -144,8 +139,6 @@ nonisolated(unsafe) private var _sharedSwiftSubject: SwiftIdentityTestSubject? _sharedSwiftSubject = nil } -// Deinit counter used for scenario (b) "explicit release frees heap object" -// and scenario (c) "double release is idempotent". @JS(identityMode: .swift) class SwiftRetainLeakSubject { nonisolated(unsafe) static var deinits: Int = 0 @@ -181,20 +174,10 @@ nonisolated(unsafe) private var _swiftRetainLeakSubject: SwiftRetainLeakSubject? SwiftRetainLeakSubject.deinits = 0 } -// Scenario (d): identity-table size introspection. -// -// Post-D18 the Swift-side state is a Set (no ids). The analogous -// "compactness" check is: after N allocate+release cycles, the Set is empty. -// Gated behind `ENABLE_TEST_INTROSPECTION` so the debug-only getter does not -// become part of the public test surface. -#if ENABLE_TEST_INTROSPECTION @JS func getSwiftIdentityTableSizeForSharedSubject() -> Int { _SwiftIdentityTestSubject_identityTable.count } -#endif -// Scenario (e): array returns — Swift returns `[a, b, a]` so JS can assert -// `result[0] === result[2]` preserves identity across array elements. @JS func makeSwiftIdentityArray( _ a: SwiftIdentityTestSubject, _ b: SwiftIdentityTestSubject @@ -202,8 +185,6 @@ nonisolated(unsafe) private var _swiftRetainLeakSubject: SwiftRetainLeakSubject? return [a, b, a] } -// Scenario (h): optional identity — `.some(x)` returns cached wrapper, `.none` -// returns null. @JS func maybeSwiftSubject(_ present: Bool) -> SwiftIdentityTestSubject? { if _sharedSwiftSubject == nil { _sharedSwiftSubject = SwiftIdentityTestSubject(value: 99) @@ -211,8 +192,8 @@ nonisolated(unsafe) private var _swiftRetainLeakSubject: SwiftRetainLeakSubject? return present ? _sharedSwiftSubject : nil } -// Scenario (d) support: a dedicated "churn" class so id-recycling assertions -// are not perturbed by the shared-subject lifetime used in (a), (f), (h). +// Dedicated churn class so its identity-table assertions aren't perturbed by +// the shared subjects above. @JS(identityMode: .swift) class SwiftChurnSubject { @JS var tag: Int @@ -221,8 +202,6 @@ nonisolated(unsafe) private var _swiftRetainLeakSubject: SwiftRetainLeakSubject? } } -#if ENABLE_TEST_INTROSPECTION @JS func getSwiftIdentityTableSizeForChurn() -> Int { _SwiftChurnSubject_identityTable.count } -#endif diff --git a/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs b/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs index 128829195..fe3e1539e 100644 --- a/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs +++ b/Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs @@ -29,11 +29,7 @@ function runIdentityModeTests(exports) { testArrayElementMatchesSingleGetter(exports); testArrayRetainLeak(exports); - // identityMode: .swift per-class tests (Task 5 Part A). - // - // These exercise the Swift-owned identity cache in coexistence with the - // pointer-mode classes above. Each function is self-contained (resets - // state, releases wrappers) so tests stay independent. + // identityMode: .swift tests (coexist with the pointer-mode classes above). testSwiftModeIdentity(exports); testSwiftModeSelfMethodIdentity(exports); testSwiftModeReleaseFreesHeapObject(exports); @@ -215,16 +211,10 @@ function testDifferentClassesDontCollide(exports) { subject2.release(); } -// ========================================================================= -// identityMode: .swift — per-class opt-in tests (Task 5 Part A) -// -// These tests exercise classes annotated with `@JS(identityMode: .swift)` in -// Tests/BridgeJSIdentityTests/IdentityModeTests.swift. The target's config -// default is "pointer" so any `.swift` annotation is an explicit opt-in. -// ========================================================================= +// ---------- identityMode: .swift tests ---------- /** - * (a) Identity on re-export. + * Identity on re-export. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -264,7 +254,7 @@ function testSwiftModeSelfMethodIdentity(exports) { } /** - * (b) Explicit release frees the underlying Swift heap object. + * Explicit release frees the underlying Swift heap object. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -286,7 +276,7 @@ function testSwiftModeReleaseFreesHeapObject(exports) { } /** - * (c) Double-release is idempotent. No crash, no over-release. + * Double-release is idempotent. No crash, no over-release. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -310,24 +300,13 @@ function testSwiftModeDoubleReleaseIdempotent(exports) { } /** - * (d) Identity-table cleanup — the Swift-side `Set` returns to size 0 - * after allocating N wrappers and releasing all of them. - * - * Post-D18 there is no id allocation to recycle; the equivalent correctness - * check is that `release_wrapper` drops its entry from `__identityTable` - * so the Set doesn't grow unboundedly over a churn loop. - * - * Uses the dedicated SwiftChurnSubject class so this assertion is not - * perturbed by other tests' allocations. + * Identity-table cleanup — the Swift-side Set returns to size 0 + * after allocating N wrappers and releasing all of them, so it can't grow + * unboundedly over a churn loop. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ function testSwiftModeIdentityTableCleanup(exports) { - if (typeof exports.getSwiftIdentityTableSizeForChurn !== "function") { - // ENABLE_TEST_INTROSPECTION not set — skip silently. - return; - } - const POOL = 10; const first = []; for (let i = 0; i < POOL; i++) { @@ -355,7 +334,7 @@ function testSwiftModeIdentityTableCleanup(exports) { } /** - * (e) Array of the same wrapper preserves cross-element identity. + * Array of the same wrapper preserves cross-element identity. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -376,7 +355,7 @@ function testSwiftModeArrayCrossElementIdentity(exports) { } /** - * (f) GC survivability — wrapper survives forced GC because Swift holds a + * GC survivability — wrapper survives forced GC because Swift holds a * strong JS ref via `swift.memory.retain`. * * Requires node to be launched with `--expose-gc`. `make unittest` does so @@ -437,16 +416,7 @@ function testSwiftModeGcSurvivability(exports) { } /** - * (h) Optional identity — `.some(x)` returns a valid wrapper; `.none` → null. - * - * v1 LIMITATION (see DECISIONS.md D16): the scalar Optional - * return path does NOT preserve `===` identity. `.some(x)` returns a fresh JS - * wrapper each time because the Optional bridge calls the default - * `_BridgedSwiftHeapObject.bridgeJSLowerReturn` (passRetained + pointer) - * rather than the per-class identity-cache handshake. Lifecycle is still - * correct; only the strong-cache invariant is relaxed for this specific - * return type. A follow-up can emit a per-class `bridgeJSLowerReturn` - * override to fix this. + * Optional identity — `.some(x)` returns the cached wrapper; `.none` → null. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -455,23 +425,15 @@ function testSwiftModeOptionalIdentity(exports) { const direct = exports.getSharedSwiftSubject(); const viaOptional = exports.maybeSwiftSubject(true); - // v1: only verify the call works and the value is observable — NOT `===`. - assert.ok( - viaOptional != null, - "swift mode: Optional.some returns a wrapper (v1: identity not preserved — see D16)", - ); - assert.equal( - viaOptional.currentValue, - direct.currentValue, - "swift mode: Optional.some wrapper observes the same underlying value", + assert.strictEqual( + direct, + viaOptional, + "swift mode: Optional.some returns the same cached wrapper", ); const absent = exports.maybeSwiftSubject(false); assert.strictEqual(absent, null, "swift mode: Optional.none returns null"); - // The extra wrapper from viaOptional needs its own release since it's - // a fresh id (v1 limitation). - viaOptional.release(); direct.release(); exports.resetSharedSwiftSubject(); } @@ -496,9 +458,11 @@ function testSwiftModeReleaseGuardsMembers(exports) { } /** - * (i) Mode coexistence — .swift class and .pointer class in the same build, + * Mode coexistence — .swift class and .pointer class in the same build, * disjoint tables. * + * Swift-mode and pointer-mode classes coexist without cross-talk. + * * The target's config default is "pointer", so IdentityTestSubject (no * per-class annotation) is a pointer-mode class. SwiftIdentityTestSubject is * explicitly .swift. Both must work simultaneously and their identity diff --git a/Tests/BridgeJSIdentityTests/SwiftIdentityIntrinsicsTests.swift b/Tests/BridgeJSIdentityTests/SwiftIdentityIntrinsicsTests.swift deleted file mode 100644 index adf5d23ee..000000000 --- a/Tests/BridgeJSIdentityTests/SwiftIdentityIntrinsicsTests.swift +++ /dev/null @@ -1,17 +0,0 @@ -import XCTest -@_spi(BridgeJS) import JavaScriptKit - -final class SwiftIdentityIntrinsicsTests: XCTestCase { - func testPushPopIdFreshBitPair() throws { - #if arch(wasm32) - // Swift pushes id=42 then freshBit=1; pops in LIFO order: - // first pop = freshBit, second pop = id. - _swift_js_push_i32(42) - _swift_js_push_i32(1) - XCTAssertEqual(_swift_js_pop_i32(), 1) // freshBit - XCTAssertEqual(_swift_js_pop_i32(), 42) // id - #else - throw XCTSkip("Stack intrinsics are wasm32-only") - #endif - } -} diff --git a/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift b/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift index 2dc793f29..d7c62dd76 100644 --- a/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSSwiftIdentityTests/Generated/BridgeJS.swift @@ -12,13 +12,7 @@ public func _bjs_getConfigSwiftSubject() -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = getConfigSwiftSubject() - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -39,13 +33,7 @@ public func _bjs_resetConfigSwiftSubject() -> Void { public func _bjs_getConfigSwiftRetainLeakSubject() -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = getConfigSwiftRetainLeakSubject() - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -122,13 +110,7 @@ nonisolated(unsafe) var _ConfigSwiftSubject_identityTable: Set UnsafeMutableRawPointer { #if arch(wasm32) let ret = ConfigSwiftSubject(value: Int.bridgeJSLiftParameter(value)) - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -139,13 +121,7 @@ public func _bjs_ConfigSwiftSubject_init(_ value: Int32) -> UnsafeMutableRawPoin public func _bjs_ConfigSwiftSubject_self_(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = ConfigSwiftSubject.bridgeJSLiftParameter(_self).self_() - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -205,6 +181,16 @@ public func _bjs_ConfigSwiftSubject_release_wrapper(_ pointer: UnsafeMutableRawP } extension ConfigSwiftSubject { + @_spi(BridgeJS) @_transparent + public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + return withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if _ConfigSwiftSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) + } + return ptr + } + } @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() @@ -245,13 +231,7 @@ nonisolated(unsafe) var _ConfigSwiftRetainLeakSubject_identityTable: Set UnsafeMutableRawPointer { #if arch(wasm32) let ret = ConfigSwiftRetainLeakSubject(tag: Int.bridgeJSLiftParameter(tag)) - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -300,6 +280,16 @@ public func _bjs_ConfigSwiftRetainLeakSubject_release_wrapper(_ pointer: UnsafeM } extension ConfigSwiftRetainLeakSubject { + @_spi(BridgeJS) @_transparent + public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + return withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if _ConfigSwiftRetainLeakSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) + } + return ptr + } + } @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() @@ -340,13 +330,7 @@ nonisolated(unsafe) var _ConfigSwiftChurnSubject_identityTable: Set UnsafeMutableRawPointer { #if arch(wasm32) let ret = ConfigSwiftChurnSubject(tag: Int.bridgeJSLiftParameter(tag)) - return withExtendedLifetime(ret) { - let ptr = Unmanaged.passUnretained(ret).toOpaque() - if _ConfigSwiftChurnSubject_identityTable.insert(ptr).inserted { - _ = Unmanaged.passRetained(ret) - } - return ptr - } + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -395,6 +379,16 @@ public func _bjs_ConfigSwiftChurnSubject_release_wrapper(_ pointer: UnsafeMutabl } extension ConfigSwiftChurnSubject { + @_spi(BridgeJS) @_transparent + public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + return withExtendedLifetime(self) { + let ptr = Unmanaged.passUnretained(self).toOpaque() + if _ConfigSwiftChurnSubject_identityTable.insert(ptr).inserted { + _ = Unmanaged.passRetained(self) + } + return ptr + } + } @_spi(BridgeJS) public consuming func bridgeJSStackPush() { let ptr: UnsafeMutableRawPointer = withExtendedLifetime(self) { let ptr = Unmanaged.passUnretained(self).toOpaque() diff --git a/Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs b/Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs index 5af9f8442..fd71e525d 100644 --- a/Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs +++ b/Tests/BridgeJSSwiftIdentityTests/JavaScript/SwiftIdentityModeTests.mjs @@ -1,12 +1,7 @@ // @ts-check -// Config-default identity mode test harness (Task 5 Part B). -// -// Parallel of Tests/BridgeJSIdentityTests/JavaScript/IdentityModeTests.mjs, -// but every @JS class in the companion Swift file has NO per-class -// identityMode argument — the `"swift"` mode is inherited from the target's -// bridge-js.config.json. We reuse the same assertions as Part A minus the -// mode-coexistence scenario (only one mode is active in this target). +// Tests for identityMode: "swift" inherited from the target's +// bridge-js.config.json (no per-class annotations). import assert from "node:assert"; @@ -41,7 +36,7 @@ function runSwiftIdentityModeTests(exports) { } /** - * (a) Identity on re-export (config-default swift mode). + * Identity on re-export (config-default swift mode). * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -80,7 +75,7 @@ function testConfigSwiftSelfMethodIdentity(exports) { } /** - * (b) Explicit release frees underlying Swift heap object. + * Explicit release frees underlying Swift heap object. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -100,7 +95,7 @@ function testConfigSwiftReleaseFreesHeapObject(exports) { } /** - * (c) Double-release is idempotent. + * Double-release is idempotent. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -123,16 +118,11 @@ function testConfigSwiftDoubleReleaseIdempotent(exports) { } /** - * (d) Identity-table cleanup — `Set` returns to empty after release - * (post-D18; no ids to recycle, so the analogous check is size-based). + * Identity-table cleanup — Set returns to empty after release. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ function testConfigSwiftIdentityTableCleanup(exports) { - if (typeof exports.getConfigSwiftIdentityTableSizeForChurn !== "function") { - return; // ENABLE_TEST_INTROSPECTION not defined - } - const POOL = 10; const first = []; for (let i = 0; i < POOL; i++) { @@ -153,7 +143,7 @@ function testConfigSwiftIdentityTableCleanup(exports) { } /** - * (e) Array returns preserve cross-element identity. + * Array returns preserve cross-element identity. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -174,7 +164,7 @@ function testConfigSwiftArrayCrossElementIdentity(exports) { } /** - * (f) GC survivability. + * GC survivability. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -210,11 +200,7 @@ function testConfigSwiftGcSurvivability(exports) { } /** - * (h) Optional identity. - * - * v1 LIMITATION (see DECISIONS.md D16): `.some(x)` returns a fresh wrapper — - * the scalar-Optional path bypasses the identity cache. Lifecycle is still - * correct. + * Optional identity — `.some(x)` returns the cached wrapper; `.none` → null. * * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -223,18 +209,11 @@ function testConfigSwiftOptionalIdentity(exports) { const direct = exports.getConfigSwiftSubject(); const viaOptional = exports.maybeConfigSwiftSubject(true); - // v1: only verify the call works (see D16 — identity not preserved for Optional). - assert.ok(viaOptional != null, "config-swift: Optional.some returns a wrapper"); - assert.equal( - viaOptional.currentValue, - direct.currentValue, - "config-swift: Optional.some wrapper observes the same value", - ); + assert.strictEqual(direct, viaOptional, "config-swift: Optional.some preserves identity"); const absent = exports.maybeConfigSwiftSubject(false); assert.strictEqual(absent, null, "config-swift: Optional.none returns null"); - viaOptional.release(); direct.release(); exports.resetConfigSwiftSubject(); } diff --git a/Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift b/Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift index a40454ce7..9fb1c147a 100644 --- a/Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift +++ b/Tests/BridgeJSSwiftIdentityTests/SwiftIdentityModeTests.swift @@ -1,15 +1,9 @@ import XCTest import JavaScriptKit -// Config-default identity mode test target. -// -// The target's bridge-js.config.json sets `"identityMode": "swift"`. Every -// `@JS class` in this file OMITS the per-class `identityMode:` argument so -// we exercise the config-default resolution path in -// `ExportSwift.isSwiftIdentityMode` / `BridgeJSLink.shouldUseSwiftIdentityCache`. -// -// See Docs/superpowers/specs/2026-04-21-swift-side-identity-cache-design.md §3.2 -// and plan Task 5 Part B. +// Tests the config-default identityMode: "swift" resolution path. +// bridge-js.config.json in this target sets the default, and none of the +// @JS class declarations below opt in explicitly. @JSClass struct SwiftIdentityModeTestImports { @JSFunction static func runJsSwiftIdentityModeTests() throws(JSException) @@ -21,7 +15,6 @@ final class SwiftIdentityModeTests: XCTestCase { } } -// NOTE: No `identityMode:` argument — inherits "swift" from bridge-js.config.json. @JS class ConfigSwiftSubject { @JS var value: Int @@ -47,7 +40,7 @@ nonisolated(unsafe) private var _configSwiftSubject: ConfigSwiftSubject? _configSwiftSubject = nil } -// Dedicated class with a deinit counter for scenarios (b), (c). +// Dedicated class with a deinit counter for release-related tests. @JS class ConfigSwiftRetainLeakSubject { nonisolated(unsafe) static var deinits: Int = 0 @@ -83,8 +76,8 @@ nonisolated(unsafe) private var _configSwiftRetainLeakSubject: ConfigSwiftRetain ConfigSwiftRetainLeakSubject.deinits = 0 } -// Scenario (d): dedicated churn class + introspection getter gated behind -// ENABLE_TEST_INTROSPECTION so it is not part of the public test surface. +// Dedicated churn class so its identity-table assertions aren't perturbed by +// the shared subjects above. @JS class ConfigSwiftChurnSubject { @JS var tag: Int @@ -93,13 +86,10 @@ nonisolated(unsafe) private var _configSwiftRetainLeakSubject: ConfigSwiftRetain } } -#if ENABLE_TEST_INTROSPECTION @JS func getConfigSwiftIdentityTableSizeForChurn() -> Int { _ConfigSwiftChurnSubject_identityTable.count } -#endif -// Scenario (e): array returns preserving cross-element identity. @JS func makeConfigSwiftArray( _ a: ConfigSwiftSubject, _ b: ConfigSwiftSubject @@ -107,7 +97,6 @@ nonisolated(unsafe) private var _configSwiftRetainLeakSubject: ConfigSwiftRetain return [a, b, a] } -// Scenario (h): optional identity. @JS func maybeConfigSwiftSubject(_ present: Bool) -> ConfigSwiftSubject? { if _configSwiftSubject == nil { _configSwiftSubject = ConfigSwiftSubject(value: 99)