From 6f4009c27b9cab8fa47d032dc03dfc370fbd9970 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 11 Jun 2026 08:02:25 +0100 Subject: [PATCH 01/20] [codex] update to latest development snapshot toolchain (#763) * Use latest snapshot toolchain * Use native build system for examples * Use native build system in PackageToJS tests * Fix build-examples CI hang * Apply formatter output * Match formatter whitespace --- .github/workflows/test.yml | 12 ++-- Examples/ActorOnWebWorker/build.sh | 2 +- Examples/Basic/build.sh | 2 +- Examples/Embedded/build.sh | 2 +- Examples/Multithreading/build.sh | 2 +- Examples/OffscrenCanvas/build.sh | 2 +- Examples/PlayBridgeJS/build.sh | 2 +- Makefile | 2 +- Plugins/PackageToJS/Tests/ExampleTests.swift | 64 ++++++++++++++----- .../JavaScriptEventLoop+ExecutorFactory.swift | 13 ---- Utilities/build-examples.sh | 14 ++-- 11 files changed, 68 insertions(+), 49 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 58b2eb647..ef72ca352 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: entry: - os: ubuntu-24.04 toolchain: - download-url: https://download.swift.org/development/ubuntu2404/swift-DEVELOPMENT-SNAPSHOT-2025-12-01-a/swift-DEVELOPMENT-SNAPSHOT-2025-12-01-a-ubuntu24.04.tar.gz + download-url: https://download.swift.org/development/ubuntu2404/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu24.04.tar.gz wasi-backend: Node target: "wasm32-unknown-wasip1" env: | @@ -26,7 +26,7 @@ jobs: target: "wasm32-unknown-wasip1" - os: ubuntu-22.04 toolchain: - download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2025-12-01-a/swift-DEVELOPMENT-SNAPSHOT-2025-12-01-a-ubuntu22.04.tar.gz + download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu22.04.tar.gz wasi-backend: Node target: "wasm32-unknown-wasip1-threads" @@ -143,7 +143,7 @@ jobs: - uses: actions/checkout@v6 - uses: ./.github/actions/install-swift with: - download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2025-09-14-a/swift-DEVELOPMENT-SNAPSHOT-2025-09-14-a-ubuntu22.04.tar.gz + download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu22.04.tar.gz - run: make bootstrap - run: ./Utilities/bridge-js-generate.sh - name: Check if BridgeJS generated files are up-to-date @@ -160,16 +160,14 @@ jobs: - uses: actions/checkout@v6 - uses: ./.github/actions/install-swift with: - download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2026-03-09-a/swift-DEVELOPMENT-SNAPSHOT-2026-03-09-a-ubuntu22.04.tar.gz + download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu22.04.tar.gz - uses: swiftwasm/setup-swiftwasm@v2 id: setup-wasm32-unknown-wasip1 with: { target: wasm32-unknown-wasip1 } - uses: swiftwasm/setup-swiftwasm@v2 id: setup-wasm32-unknown-wasip1-threads with: { target: wasm32-unknown-wasip1-threads } - - run: | - swift --version - ./Utilities/build-examples.sh + - run: ./Utilities/build-examples.sh env: SWIFT_SDK_ID_wasm32_unknown_wasip1_threads: ${{ steps.setup-wasm32-unknown-wasip1-threads.outputs.swift-sdk-id }} SWIFT_SDK_ID_wasm32_unknown_wasip1: ${{ steps.setup-wasm32-unknown-wasip1.outputs.swift-sdk-id }} diff --git a/Examples/ActorOnWebWorker/build.sh b/Examples/ActorOnWebWorker/build.sh index 4def77883..66c10a2c4 100755 --- a/Examples/ActorOnWebWorker/build.sh +++ b/Examples/ActorOnWebWorker/build.sh @@ -1,5 +1,5 @@ #!/bin/bash set -euxo pipefail -swift package --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1_threads:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1-threads}}" \ +swift package --build-system native --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1_threads:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1-threads}}" \ plugin --allow-writing-to-package-directory \ js --use-cdn --output ./Bundle -c release diff --git a/Examples/Basic/build.sh b/Examples/Basic/build.sh index 2351f4e2d..07f436c4b 100755 --- a/Examples/Basic/build.sh +++ b/Examples/Basic/build.sh @@ -1,3 +1,3 @@ #!/bin/bash set -euxo pipefail -swift package --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1}}" js --use-cdn -c "${1:-debug}" +swift package --build-system native --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1}}" js --use-cdn -c "${1:-debug}" diff --git a/Examples/Embedded/build.sh b/Examples/Embedded/build.sh index d756d8d1e..486f3581d 100755 --- a/Examples/Embedded/build.sh +++ b/Examples/Embedded/build.sh @@ -1,5 +1,5 @@ #!/bin/bash set -euxo pipefail package_dir="$(cd "$(dirname "$0")" && pwd)" -swift package --package-path "$package_dir" \ +swift package --build-system native --package-path "$package_dir" \ --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1}}-embedded" js -c release diff --git a/Examples/Multithreading/build.sh b/Examples/Multithreading/build.sh index 4def77883..66c10a2c4 100755 --- a/Examples/Multithreading/build.sh +++ b/Examples/Multithreading/build.sh @@ -1,5 +1,5 @@ #!/bin/bash set -euxo pipefail -swift package --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1_threads:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1-threads}}" \ +swift package --build-system native --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1_threads:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1-threads}}" \ plugin --allow-writing-to-package-directory \ js --use-cdn --output ./Bundle -c release diff --git a/Examples/OffscrenCanvas/build.sh b/Examples/OffscrenCanvas/build.sh index 4def77883..66c10a2c4 100755 --- a/Examples/OffscrenCanvas/build.sh +++ b/Examples/OffscrenCanvas/build.sh @@ -1,5 +1,5 @@ #!/bin/bash set -euxo pipefail -swift package --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1_threads:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1-threads}}" \ +swift package --build-system native --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1_threads:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1-threads}}" \ plugin --allow-writing-to-package-directory \ js --use-cdn --output ./Bundle -c release diff --git a/Examples/PlayBridgeJS/build.sh b/Examples/PlayBridgeJS/build.sh index 31c07896c..eb444a899 100755 --- a/Examples/PlayBridgeJS/build.sh +++ b/Examples/PlayBridgeJS/build.sh @@ -1,5 +1,5 @@ #!/bin/bash set -euxo pipefail -swift package --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1}}" \ +swift package --build-system native --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1}}" \ plugin --allow-writing-to-package-directory \ js --use-cdn --output ./Bundle -c "${1:-debug}" diff --git a/Makefile b/Makefile index 270eb9b36..4b174e347 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ unittest: echo "SWIFT_SDK_ID is not set. Run 'swift sdk list' and pass a matching SDK, e.g. 'make unittest SWIFT_SDK_ID='."; \ exit 2; \ } - swift package --swift-sdk "$(SWIFT_SDK_ID)" \ + swift package --build-system native --swift-sdk "$(SWIFT_SDK_ID)" \ $(TRACING_ARGS) \ --disable-sandbox \ js test --prelude ./Tests/prelude.mjs -Xnode --expose-gc diff --git a/Plugins/PackageToJS/Tests/ExampleTests.swift b/Plugins/PackageToJS/Tests/ExampleTests.swift index 1f5bedcdc..d131b329a 100644 --- a/Plugins/PackageToJS/Tests/ExampleTests.swift +++ b/Plugins/PackageToJS/Tests/ExampleTests.swift @@ -246,11 +246,26 @@ extension Trait where Self == ConditionTrait { func basic() throws { let swiftSDKID = try #require(Self.getSwiftSDKID()) try withPackage(at: "Examples/Basic") { packageDir, _, runSwift in - try runSwift(["package", "--swift-sdk", swiftSDKID, "js"], [:]) - try runSwift(["package", "--swift-sdk", swiftSDKID, "js", "--debug-info-format", "dwarf"], [:]) - try runSwift(["package", "--swift-sdk", swiftSDKID, "js", "--debug-info-format", "name"], [:]) + try runSwift(["package", "--build-system", "native", "--swift-sdk", swiftSDKID, "js"], [:]) try runSwift( - ["package", "--swift-sdk", swiftSDKID, "-Xswiftc", "-DJAVASCRIPTKIT_WITHOUT_WEAKREFS", "js"], + [ + "package", "--build-system", "native", "--swift-sdk", swiftSDKID, "js", "--debug-info-format", + "dwarf", + ], + [:] + ) + try runSwift( + [ + "package", "--build-system", "native", "--swift-sdk", swiftSDKID, "js", "--debug-info-format", + "name", + ], + [:] + ) + try runSwift( + [ + "package", "--build-system", "native", "--swift-sdk", swiftSDKID, "-Xswiftc", + "-DJAVASCRIPTKIT_WITHOUT_WEAKREFS", "js", + ], [:] ) } @@ -266,7 +281,10 @@ extension Trait where Self == ConditionTrait { try runProcess(which("npm"), ["install"], [:]) try runProcess(which("npx"), ["playwright", "install", "chromium-headless-shell"], [:]) - try runSwift(["package", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test"], [:]) + try runSwift( + ["package", "--build-system", "native", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test"], + [:] + ) try withTemporaryDirectory(body: { tempDir, _ in let scriptContent = """ const fs = require('fs'); @@ -278,7 +296,8 @@ extension Trait where Self == ConditionTrait { let scriptPath = tempDir.appending(path: "script.js") try runSwift( [ - "package", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test", + "package", "--build-system", "native", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", + "test", "-Xnode=--require=\(scriptPath.path)", ], [:] @@ -291,7 +310,10 @@ extension Trait where Self == ConditionTrait { ) }) try runSwift( - ["package", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test", "--environment", "browser"], + [ + "package", "--build-system", "native", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test", + "--environment", "browser", + ], [:] ) } @@ -303,7 +325,10 @@ extension Trait where Self == ConditionTrait { let swiftPath = try #require(Self.getSwiftPath()) try withPackage(at: "Examples/Testing") { packageDir, runProcess, runSwift in try runSwift( - ["package", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test", "--enable-code-coverage"], + [ + "package", "--build-system", "native", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test", + "--enable-code-coverage", + ], [ "LLVM_PROFDATA_PATH": URL(fileURLWithPath: swiftPath).appending(path: "llvm-profdata").path ] @@ -330,7 +355,7 @@ extension Trait where Self == ConditionTrait { func multithreading() throws { let swiftSDKID = try #require(Self.getSwiftSDKID()) try withPackage(at: "Examples/Multithreading") { packageDir, _, runSwift in - try runSwift(["package", "--swift-sdk", swiftSDKID, "js"], [:]) + try runSwift(["package", "--build-system", "native", "--swift-sdk", swiftSDKID, "js"], [:]) } } @@ -338,7 +363,7 @@ extension Trait where Self == ConditionTrait { func offscreenCanvas() throws { let swiftSDKID = try #require(Self.getSwiftSDKID()) try withPackage(at: "Examples/OffscrenCanvas") { packageDir, _, runSwift in - try runSwift(["package", "--swift-sdk", swiftSDKID, "js"], [:]) + try runSwift(["package", "--build-system", "native", "--swift-sdk", swiftSDKID, "js"], [:]) } } @@ -346,7 +371,7 @@ extension Trait where Self == ConditionTrait { func actorOnWebWorker() throws { let swiftSDKID = try #require(Self.getSwiftSDKID()) try withPackage(at: "Examples/ActorOnWebWorker") { packageDir, _, runSwift in - try runSwift(["package", "--swift-sdk", swiftSDKID, "js"], [:]) + try runSwift(["package", "--build-system", "native", "--swift-sdk", swiftSDKID, "js"], [:]) } } @@ -357,7 +382,7 @@ extension Trait where Self == ConditionTrait { let swiftSDKID = try #require(Self.getEmbeddedSwiftSDKID()) try withPackage(at: "Examples/Embedded") { packageDir, _, runSwift in try runSwift( - ["package", "--swift-sdk", swiftSDKID, "js", "-c", "release"], + ["package", "--build-system", "native", "--swift-sdk", swiftSDKID, "js", "-c", "release"], [ "JAVASCRIPTKIT_EXPERIMENTAL_EMBEDDED_WASM": "true" ] @@ -373,7 +398,10 @@ extension Trait where Self == ConditionTrait { at: "Plugins/PackageToJS/Fixtures/ContinuationLeakInTest/XCTest", assertTerminationStatus: { $0 != 0 } ) { packageDir, _, runSwift in - try runSwift(["package", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test"], [:]) + try runSwift( + ["package", "--build-system", "native", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test"], + [:] + ) } } @@ -385,7 +413,10 @@ extension Trait where Self == ConditionTrait { at: "Plugins/PackageToJS/Fixtures/ContinuationLeakInTest/SwiftTesting", assertTerminationStatus: { $0 != 0 } ) { packageDir, _, runSwift in - try runSwift(["package", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test"], [:]) + try runSwift( + ["package", "--build-system", "native", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test"], + [:] + ) } } @Test(.requireSwiftSDK) @@ -400,7 +431,7 @@ extension Trait where Self == ConditionTrait { try runSwift( ["package", "--disable-sandbox"] + Self.stackSizeLinkerFlags + [ - "--swift-sdk", swiftSDKID, "js", "test", "--environment", "browser", + "--build-system", "native", "--swift-sdk", swiftSDKID, "js", "test", "--environment", "browser", "--playwright-expose", "../expose.js", ], [:] @@ -421,7 +452,8 @@ extension Trait where Self == ConditionTrait { try runSwift( [ - "package", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test", "--environment", "browser", + "package", "--build-system", "native", "--disable-sandbox", "--swift-sdk", swiftSDKID, "js", "test", + "--environment", "browser", "--playwright-expose", "../expose.js", ], [:] diff --git a/Sources/JavaScriptEventLoop/JavaScriptEventLoop+ExecutorFactory.swift b/Sources/JavaScriptEventLoop/JavaScriptEventLoop+ExecutorFactory.swift index 0d2010016..17aedca3b 100644 --- a/Sources/JavaScriptEventLoop/JavaScriptEventLoop+ExecutorFactory.swift +++ b/Sources/JavaScriptEventLoop/JavaScriptEventLoop+ExecutorFactory.swift @@ -57,25 +57,12 @@ extension JavaScriptEventLoop: SchedulingExecutor { #endif // #if compiler(>=6.4) (Embedded) #else // #if hasFeature(Embedded) let duration: Duration - // Handle clocks we know if let _ = clock as? ContinuousClock { duration = delay as! ContinuousClock.Duration } else if let _ = clock as? SuspendingClock { duration = delay as! SuspendingClock.Duration } else { - #if compiler(>=6.4) - // Hand-off the scheduling work to Clock implementation for unknown clocks. - // Clock.enqueue is only available in the development branch (6.4+). - clock.enqueue( - job, - on: self, - at: clock.now.advanced(by: delay), - tolerance: tolerance - ) - return - #else fatalError("Unsupported clock type; only ContinuousClock and SuspendingClock are supported") - #endif // #if compiler(>=6.4) (non-Embedded) } let milliseconds = Self.delayInMilliseconds(from: duration) self.enqueue( diff --git a/Utilities/build-examples.sh b/Utilities/build-examples.sh index bc84e6943..77e923322 100755 --- a/Utilities/build-examples.sh +++ b/Utilities/build-examples.sh @@ -6,12 +6,14 @@ EXCLUDED_EXAMPLES=() for example in Examples/*; do skip_example=false - for excluded in "${EXCLUDED_EXAMPLES[@]}"; do - if [[ "$example" == *"$excluded"* ]]; then - skip_example=true - break - fi - done + if ((${#EXCLUDED_EXAMPLES[@]})); then + for excluded in "${EXCLUDED_EXAMPLES[@]}"; do + if [[ "$example" == *"$excluded"* ]]; then + skip_example=true + break + fi + done + fi if [ "$skip_example" = true ]; then echo "Skipping $example" continue From 3396b5eeda2a979679996bdeeddcf43ad3d26eff Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 11 Jun 2026 08:05:42 +0100 Subject: [PATCH 02/20] [codex] BridgeJS: support associated-value enums in import and async paths (#764) * BridgeJS: support associated-value enums in import and async paths * Format Swift sources * Match Swift 6.1 formatter output --- .../Sources/BridgeJSCore/ImportTS.swift | 14 +- .../Sources/BridgeJSLink/JSGlueGen.swift | 44 +- .../BridgeJSSkeleton/BridgeJSSkeleton.swift | 4 +- .../BridgeJSToolTests/DiagnosticsTests.swift | 13 +- .../MacroSwift/AsyncAssociatedValueEnum.swift | 13 + .../EnumAssociatedValueImport.swift | 14 + .../AsyncAssociatedValueEnum.json | 129 ++++++ .../AsyncAssociatedValueEnum.swift | 116 +++++ .../EnumAssociatedValueImport.json | 194 ++++++++ .../EnumAssociatedValueImport.swift | 112 +++++ .../AsyncAssociatedValueEnum.d.ts | 33 ++ .../AsyncAssociatedValueEnum.js | 414 ++++++++++++++++++ .../EnumAssociatedValueImport.d.ts | 39 ++ .../EnumAssociatedValueImport.js | 323 ++++++++++++++ .../AsyncImportTests.swift | 35 ++ .../BridgeJSRuntimeTests/ExportAPITests.swift | 10 + .../Generated/BridgeJS.swift | 364 +++++++++++++++ .../Generated/JavaScript/BridgeJS.json | 317 ++++++++++++++ .../BridgeJSRuntimeTests/ImportAPITests.swift | 35 ++ .../JavaScript/AsyncImportTests.mjs | 19 +- Tests/prelude.mjs | 6 + 21 files changed, 2196 insertions(+), 52 deletions(-) create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/AsyncAssociatedValueEnum.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/EnumAssociatedValueImport.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.js create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.js diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift index 02c623918..a6a73b8f7 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift @@ -936,12 +936,7 @@ extension BridgeType { let wasmType = rawType.wasmCoreType ?? .i32 return LoweringParameterInfo(loweredParameters: [("value", wasmType)]) case .associatedValueEnum: - switch context { - case .importTS: - throw BridgeJSCoreError("Enum types are not yet supported in TypeScript imports") - case .exportSwift: - return LoweringParameterInfo(loweredParameters: [("caseId", .i32)]) - } + return LoweringParameterInfo(loweredParameters: [("caseId", .i32)]) case .swiftStruct: switch context { case .importTS: @@ -1011,12 +1006,7 @@ extension BridgeType { let wasmType = rawType.wasmCoreType ?? .i32 return LiftingReturnInfo(valueToLift: wasmType) case .associatedValueEnum: - switch context { - case .importTS: - throw BridgeJSCoreError("Enum types are not yet supported in TypeScript imports") - case .exportSwift: - return LiftingReturnInfo(valueToLift: .i32) - } + return LiftingReturnInfo(valueToLift: .i32) case .swiftStruct: switch context { case .importTS: diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift index aed01da5a..ac2144bbc 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift @@ -1422,27 +1422,19 @@ struct IntrinsicJSFragment: Sendable { return try .optionalLiftParameter(wrappedType: wrappedType, kind: kind, context: context) case .rawValueEnum(_, .string): return .stringLiftParameter case .associatedValueEnum(let fullName): - switch context { - case .importTS: - throw BridgeJSLinkError( - message: - "Associated value enums are not supported to be passed as parameters to imported JS functions: \(fullName)" - ) - case .exportSwift: - let base = fullName.components(separatedBy: ".").last ?? fullName - return IntrinsicJSFragment( - parameters: ["caseId"], - printCode: { arguments, context in - let (scope, printer) = (context.scope, context.printer) - let caseId = arguments[0] - let resultVar = scope.variable("enumValue") - printer.write( - "const \(resultVar) = \(JSGlueVariableScope.reservedEnumHelpers).\(base).lift(\(caseId));" - ) - return [resultVar] - } - ) - } + let base = fullName.components(separatedBy: ".").last ?? fullName + return IntrinsicJSFragment( + parameters: ["caseId"], + printCode: { arguments, context in + let (scope, printer) = (context.scope, context.printer) + let caseId = arguments[0] + let resultVar = scope.variable("enumValue") + printer.write( + "const \(resultVar) = \(JSGlueVariableScope.reservedEnumHelpers).\(base).lift(\(caseId));" + ) + return [resultVar] + } + ) case .swiftStruct(let fullName): switch context { case .importTS: @@ -1502,15 +1494,7 @@ struct IntrinsicJSFragment: Sendable { return try .optionalLowerReturn(wrappedType: wrappedType, kind: kind) case .rawValueEnum(_, .string): return .stringLowerReturn case .associatedValueEnum(let fullName): - switch context { - case .importTS: - throw BridgeJSLinkError( - message: - "Associated value enums are not supported to be returned from imported JS functions: \(fullName)" - ) - case .exportSwift: - return associatedValueLowerReturn(fullName: fullName) - } + return associatedValueLowerReturn(fullName: fullName) case .swiftStruct(let fullName): switch context { case .importTS: diff --git a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift index f1e2e80fe..830132481 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift @@ -1611,10 +1611,10 @@ extension BridgeType { /// Whether a value of this type can be passed to a generated `Promise_resolve_` /// settlement helper, i.e. lowered through the imported-parameter ABI. Every `async` /// exported return settles through `_bjs_makePromise`; the few types that cannot be lowered - /// (associated-value enums, protocols, namespace enums, and their compositions) are diagnosed. + /// (protocols, namespace enums, and their compositions) are diagnosed. public var isAsyncResolvable: Bool { switch self { - case .associatedValueEnum, .swiftProtocol, .namespaceEnum: + case .swiftProtocol, .namespaceEnum: return false case .nullable(let wrapped, _): return wrapped.isAsyncResolvable diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift index 82747f74e..ae12b6566 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift @@ -309,15 +309,14 @@ import Testing @Test func asyncReturnOfUnsupportedTypeIsDiagnosed() throws { - // An associated-value enum can be neither lowered through the imported-parameter ABI - // nor settled via `_bjs_makePromise`, so an async return of one must be diagnosed. + // Protocol existentials still can't be lowered through the imported-parameter ABI, so + // an async return of one must still be diagnosed. let source = """ - @JS enum Payload { - case text(String) - case number(Int) + @JS protocol PayloadDelegate { + func notify() } - @JS func loadPayload() async -> Payload { - .number(1) + @JS func loadPayload() async -> PayloadDelegate { + fatalError() } """ let swiftAPI = SwiftToSkeleton( diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/AsyncAssociatedValueEnum.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/AsyncAssociatedValueEnum.swift new file mode 100644 index 000000000..662e01fce --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/AsyncAssociatedValueEnum.swift @@ -0,0 +1,13 @@ +@JS enum AsyncPayloadResult { + case success(String) + case failure(Int) + case idle +} + +@JS func asyncRoundTripAssociatedValueEnum(_ value: AsyncPayloadResult) async -> AsyncPayloadResult { + return value +} + +@JS func asyncRoundTripOptionalAssociatedValueEnum(_ value: AsyncPayloadResult?) async -> AsyncPayloadResult? { + return value +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/EnumAssociatedValueImport.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/EnumAssociatedValueImport.swift new file mode 100644 index 000000000..aa404b72c --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/EnumAssociatedValueImport.swift @@ -0,0 +1,14 @@ +@JS enum PayloadSignal { + case start(String) + case stop(Int) + case idle +} + +// Associated-value enums bridge as their `Int32` case ID plus stack payload in imported +// function parameters and return values. +@JSClass struct PayloadSignalControls { + @JSFunction func send(_ signal: PayloadSignal) throws(JSException) + @JSFunction func current() throws(JSException) -> PayloadSignal + @JSFunction static func roundTrip(_ signal: PayloadSignal) throws(JSException) -> PayloadSignal + @JSFunction func roundTripOptional(_ signal: PayloadSignal?) throws(JSException) -> PayloadSignal? +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.json new file mode 100644 index 000000000..6b0d70453 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.json @@ -0,0 +1,129 @@ +{ + "exported" : { + "classes" : [ + + ], + "enums" : [ + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + + ], + "name" : "idle" + } + ], + "emitStyle" : "const", + "name" : "AsyncPayloadResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "AsyncPayloadResult", + "tsFullPath" : "AsyncPayloadResult" + } + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_asyncRoundTripAssociatedValueEnum", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripAssociatedValueEnum", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + } + }, + { + "abiName" : "bjs_asyncRoundTripOptionalAssociatedValueEnum", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripOptionalAssociatedValueEnum", + "parameters" : [ + { + "label" : "_", + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + }, + "_1" : "null" + } + } + } + ], + "protocols" : [ + + ], + "structs" : [ + + ] + }, + "moduleName" : "TestModule", + "usedExternalModules" : [ + + ] +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.swift new file mode 100644 index 000000000..7ceb8cfe3 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.swift @@ -0,0 +1,116 @@ +extension AsyncPayloadResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> AsyncPayloadResult { + switch caseId { + case 0: + return .success(String.bridgeJSStackPop()) + case 1: + return .failure(Int.bridgeJSStackPop()) + case 2: + return .idle + default: + fatalError("Unknown AsyncPayloadResult 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 .idle: + return Int32(2) + } + } +} + +@_expose(wasm, "bjs_asyncRoundTripAssociatedValueEnum") +@_cdecl("bjs_asyncRoundTripAssociatedValueEnum") +public func _bjs_asyncRoundTripAssociatedValueEnum(_ value: Int32) -> Int32 { + #if arch(wasm32) + let _tmp_value = AsyncPayloadResult.bridgeJSLiftParameter(value) + return _bjs_makePromise(resolve: Promise_resolve_18AsyncPayloadResultO, reject: Promise_reject) { + return await asyncRoundTripAssociatedValueEnum(_: _tmp_value) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripOptionalAssociatedValueEnum") +@_cdecl("bjs_asyncRoundTripOptionalAssociatedValueEnum") +public func _bjs_asyncRoundTripOptionalAssociatedValueEnum(_ valueIsSome: Int32, _ valueCaseId: Int32) -> Int32 { + #if arch(wasm32) + let _tmp_value = Optional.bridgeJSLiftParameter(valueIsSome, valueCaseId) + return _bjs_makePromise(resolve: Promise_resolve_Sq18AsyncPayloadResultO, reject: Promise_reject) { + return await asyncRoundTripOptionalAssociatedValueEnum(_: _tmp_value) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@JSFunction func Promise_reject(_ promise: JSObject, _ value: JSValue) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_reject_TestModule") +fileprivate func promise_reject_TestModule_extern(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void +#else +fileprivate func promise_reject_TestModule_extern(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_reject_TestModule(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void { + return promise_reject_TestModule_extern(promise, valueKind, valuePayload1, valuePayload2) +} + +func _$Promise_reject(_ promise: JSObject, _ value: JSValue) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let (valueKind, valuePayload1, valuePayload2) = value.bridgeJSLowerParameter() + promise_reject_TestModule(promiseValue, valueKind, valuePayload1, valuePayload2) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_18AsyncPayloadResultO(_ promise: JSObject, _ value: AsyncPayloadResult) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_TestModule_18AsyncPayloadResultO") +fileprivate func promise_resolve_TestModule_18AsyncPayloadResultO_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_TestModule_18AsyncPayloadResultO_extern(_ promise: Int32, _ value: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_TestModule_18AsyncPayloadResultO(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_TestModule_18AsyncPayloadResultO_extern(promise, value) +} + +func _$Promise_resolve_18AsyncPayloadResultO(_ promise: JSObject, _ value: AsyncPayloadResult) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueCaseId = value.bridgeJSLowerParameter() + promise_resolve_TestModule_18AsyncPayloadResultO(promiseValue, valueCaseId) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_Sq18AsyncPayloadResultO(_ promise: JSObject, _ value: Optional) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_TestModule_Sq18AsyncPayloadResultO") +fileprivate func promise_resolve_TestModule_Sq18AsyncPayloadResultO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void +#else +fileprivate func promise_resolve_TestModule_Sq18AsyncPayloadResultO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_TestModule_Sq18AsyncPayloadResultO(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void { + return promise_resolve_TestModule_Sq18AsyncPayloadResultO_extern(promise, valueIsSome, valueCaseId) +} + +func _$Promise_resolve_Sq18AsyncPayloadResultO(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let (valueIsSome, valueCaseId) = value.bridgeJSLowerParameter() + promise_resolve_TestModule_Sq18AsyncPayloadResultO(promiseValue, valueIsSome, valueCaseId) + if let error = _swift_js_take_exception() { throw error } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.json new file mode 100644 index 000000000..23cb1b0f0 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.json @@ -0,0 +1,194 @@ +{ + "exported" : { + "classes" : [ + + ], + "enums" : [ + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "start" + }, + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "stop" + }, + { + "associatedValues" : [ + + ], + "name" : "idle" + } + ], + "emitStyle" : "const", + "name" : "PayloadSignal", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "PayloadSignal", + "tsFullPath" : "PayloadSignal" + } + ], + "exposeToGlobal" : false, + "functions" : [ + + ], + "protocols" : [ + + ], + "structs" : [ + + ] + }, + "imported" : { + "children" : [ + { + "functions" : [ + + ], + "types" : [ + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "send", + "parameters" : [ + { + "name" : "signal", + "type" : { + "associatedValueEnum" : { + "_0" : "PayloadSignal" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "current", + "parameters" : [ + + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "PayloadSignal" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "roundTripOptional", + "parameters" : [ + { + "name" : "signal", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "PayloadSignal" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "PayloadSignal" + } + }, + "_1" : "null" + } + } + } + ], + "name" : "PayloadSignalControls", + "setters" : [ + + ], + "staticMethods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "roundTrip", + "parameters" : [ + { + "name" : "signal", + "type" : { + "associatedValueEnum" : { + "_0" : "PayloadSignal" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "PayloadSignal" + } + } + } + ] + } + ] + } + ] + }, + "moduleName" : "TestModule", + "usedExternalModules" : [ + + ] +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.swift new file mode 100644 index 000000000..5e1db5c72 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.swift @@ -0,0 +1,112 @@ +extension PayloadSignal: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> PayloadSignal { + switch caseId { + case 0: + return .start(String.bridgeJSStackPop()) + case 1: + return .stop(Int.bridgeJSStackPop()) + case 2: + return .idle + default: + fatalError("Unknown PayloadSignal case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .start(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .stop(let param0): + param0.bridgeJSStackPush() + return Int32(1) + case .idle: + return Int32(2) + } + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_PayloadSignalControls_roundTrip_static") +fileprivate func bjs_PayloadSignalControls_roundTrip_static_extern(_ signal: Int32) -> Int32 +#else +fileprivate func bjs_PayloadSignalControls_roundTrip_static_extern(_ signal: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_PayloadSignalControls_roundTrip_static(_ signal: Int32) -> Int32 { + return bjs_PayloadSignalControls_roundTrip_static_extern(signal) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_PayloadSignalControls_send") +fileprivate func bjs_PayloadSignalControls_send_extern(_ self: Int32, _ signal: Int32) -> Void +#else +fileprivate func bjs_PayloadSignalControls_send_extern(_ self: Int32, _ signal: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_PayloadSignalControls_send(_ self: Int32, _ signal: Int32) -> Void { + return bjs_PayloadSignalControls_send_extern(self, signal) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_PayloadSignalControls_current") +fileprivate func bjs_PayloadSignalControls_current_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_PayloadSignalControls_current_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_PayloadSignalControls_current(_ self: Int32) -> Int32 { + return bjs_PayloadSignalControls_current_extern(self) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_PayloadSignalControls_roundTripOptional") +fileprivate func bjs_PayloadSignalControls_roundTripOptional_extern(_ self: Int32, _ signalIsSome: Int32, _ signalCaseId: Int32) -> Int32 +#else +fileprivate func bjs_PayloadSignalControls_roundTripOptional_extern(_ self: Int32, _ signalIsSome: Int32, _ signalCaseId: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_PayloadSignalControls_roundTripOptional(_ self: Int32, _ signalIsSome: Int32, _ signalCaseId: Int32) -> Int32 { + return bjs_PayloadSignalControls_roundTripOptional_extern(self, signalIsSome, signalCaseId) +} + +func _$PayloadSignalControls_roundTrip(_ signal: PayloadSignal) throws(JSException) -> PayloadSignal { + let signalCaseId = signal.bridgeJSLowerParameter() + let ret = bjs_PayloadSignalControls_roundTrip_static(signalCaseId) + if let error = _swift_js_take_exception() { + throw error + } + return PayloadSignal.bridgeJSLiftReturn(ret) +} + +func _$PayloadSignalControls_send(_ self: JSObject, _ signal: PayloadSignal) throws(JSException) -> Void { + let selfValue = self.bridgeJSLowerParameter() + let signalCaseId = signal.bridgeJSLowerParameter() + bjs_PayloadSignalControls_send(selfValue, signalCaseId) + if let error = _swift_js_take_exception() { + throw error + } +} + +func _$PayloadSignalControls_current(_ self: JSObject) throws(JSException) -> PayloadSignal { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_PayloadSignalControls_current(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return PayloadSignal.bridgeJSLiftReturn(ret) +} + +func _$PayloadSignalControls_roundTripOptional(_ self: JSObject, _ signal: Optional) throws(JSException) -> Optional { + let selfValue = self.bridgeJSLowerParameter() + let (signalIsSome, signalCaseId) = signal.bridgeJSLowerParameter() + let ret = bjs_PayloadSignalControls_roundTripOptional(selfValue, signalIsSome, signalCaseId) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn(ret) +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.d.ts new file mode 100644 index 000000000..d25336ef7 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.d.ts @@ -0,0 +1,33 @@ +// 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 const AsyncPayloadResultValues: { + readonly Tag: { + readonly Success: 0; + readonly Failure: 1; + readonly Idle: 2; + }; +}; + +export type AsyncPayloadResultTag = + { tag: typeof AsyncPayloadResultValues.Tag.Success; param0: string } | { tag: typeof AsyncPayloadResultValues.Tag.Failure; param0: number } | { tag: typeof AsyncPayloadResultValues.Tag.Idle } + +export type AsyncPayloadResultObject = typeof AsyncPayloadResultValues; + +export type Exports = { + asyncRoundTripAssociatedValueEnum(value: AsyncPayloadResultTag): Promise; + asyncRoundTripOptionalAssociatedValueEnum(value: AsyncPayloadResultTag | null): Promise; + AsyncPayloadResult: AsyncPayloadResultObject +} +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/AsyncAssociatedValueEnum.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.js new file mode 100644 index 000000000..69e4a4928 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.js @@ -0,0 +1,414 @@ +// 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 const AsyncPayloadResultValues = { + Tag: { + Success: 0, + Failure: 1, + Idle: 2, + }, +}; +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 = []; + let taStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + function __bjs_jsValueLower(value) { + let kind; + let payload1; + let payload2; + if (value === null) { + kind = 4; + payload1 = 0; + payload2 = 0; + } else { + switch (typeof value) { + case "boolean": + kind = 0; + payload1 = value ? 1 : 0; + payload2 = 0; + break; + case "number": + kind = 2; + payload1 = 0; + payload2 = value; + break; + case "string": + kind = 1; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "undefined": + kind = 5; + payload1 = 0; + payload2 = 0; + break; + case "object": + kind = 3; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "function": + kind = 3; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "symbol": + kind = 7; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "bigint": + kind = 8; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + default: + throw new TypeError("Unsupported JSValue type"); + } + } + return [kind, payload1, payload2]; + } + function __bjs_jsValueLift(kind, payload1, payload2) { + let jsValue; + switch (kind) { + case 0: + jsValue = payload1 !== 0; + break; + case 1: + jsValue = swift.memory.getObject(payload1); + break; + case 2: + jsValue = payload2; + break; + case 3: + jsValue = swift.memory.getObject(payload1); + break; + case 4: + jsValue = null; + break; + case 5: + jsValue = undefined; + break; + case 7: + jsValue = swift.memory.getObject(payload1); + break; + case 8: + jsValue = swift.memory.getObject(payload1); + break; + default: + throw new TypeError("Unsupported JSValue kind " + kind); + } + return jsValue; + } + + const __bjs_createAsyncPayloadResultValuesHelpers = () => ({ + lower: (value) => { + const enumTag = value.tag; + switch (enumTag) { + case AsyncPayloadResultValues.Tag.Success: { + const bytes = textEncoder.encode(value.param0); + const id = swift.memory.retain(bytes); + i32Stack.push(bytes.length); + i32Stack.push(id); + return AsyncPayloadResultValues.Tag.Success; + } + case AsyncPayloadResultValues.Tag.Failure: { + i32Stack.push((value.param0 | 0)); + return AsyncPayloadResultValues.Tag.Failure; + } + case AsyncPayloadResultValues.Tag.Idle: { + return AsyncPayloadResultValues.Tag.Idle; + } + default: throw new Error("Unknown AsyncPayloadResultValues tag: " + String(enumTag)); + } + }, + lift: (tag) => { + tag = tag | 0; + switch (tag) { + case AsyncPayloadResultValues.Tag.Success: { + const string = strStack.pop(); + return { tag: AsyncPayloadResultValues.Tag.Success, param0: string }; + } + case AsyncPayloadResultValues.Tag.Failure: { + const int = i32Stack.pop(); + return { tag: AsyncPayloadResultValues.Tag.Failure, param0: int }; + } + case AsyncPayloadResultValues.Tag.Idle: return { tag: AsyncPayloadResultValues.Tag.Idle }; + default: throw new Error("Unknown AsyncPayloadResultValues tag returned from Swift: " + String(tag)); + } + } + }); + + 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(); + } + const taCtors = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; + bjs["swift_js_push_typed_array"] = function(kind, ptr, count) { + const Ctor = taCtors[kind]; + const byteLen = count * Ctor.BYTES_PER_ELEMENT; + const copy = memory.buffer.slice(ptr, ptr + byteLen); + taStack.push(Array.from(new Ctor(copy))); + } + const __bjs_promiseSettlers = Symbol("JavaScriptKit.promiseSettlers"); + bjs["swift_js_make_promise"] = function() { + let resolve, reject; + const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); + promise[__bjs_promiseSettlers] = { resolve, reject }; + return swift.memory.retain(promise); + } + bjs["promise_resolve_TestModule_18AsyncPayloadResultO"] = function(promise, value) { + try { + const enumValue = enumHelpers.AsyncPayloadResult.lift(value); + swift.memory.getObject(promise)[__bjs_promiseSettlers].resolve(enumValue); + } catch (error) { + setException(error); + } + } + bjs["promise_resolve_TestModule_Sq18AsyncPayloadResultO"] = function(promise, valueIsSome, valueCaseId) { + try { + let optResult; + if (valueIsSome) { + const enumValue = enumHelpers.AsyncPayloadResult.lift(valueCaseId); + optResult = enumValue; + } else { + optResult = null; + } + swift.memory.getObject(promise)[__bjs_promiseSettlers].resolve(optResult); + } catch (error) { + setException(error); + } + } + bjs["promise_reject_TestModule"] = function(promise, valueKind, valuePayload1, valuePayload2) { + try { + const jsValue = __bjs_jsValueLift(valueKind, valuePayload1, valuePayload2); + swift.memory.getObject(promise)[__bjs_promiseSettlers].reject(jsValue); + } catch (error) { + setException(error); + } + } + 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) {} + }, + 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 AsyncPayloadResultHelpers = __bjs_createAsyncPayloadResultValuesHelpers(); + enumHelpers.AsyncPayloadResult = AsyncPayloadResultHelpers; + + const exports = { + asyncRoundTripAssociatedValueEnum: function bjs_asyncRoundTripAssociatedValueEnum(value) { + const valueCaseId = enumHelpers.AsyncPayloadResult.lower(value); + const ret = instance.exports.bjs_asyncRoundTripAssociatedValueEnum(valueCaseId); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + return ret1; + }, + asyncRoundTripOptionalAssociatedValueEnum: function bjs_asyncRoundTripOptionalAssociatedValueEnum(value) { + const isSome = value != null; + let result; + if (isSome) { + const valueCaseId = enumHelpers.AsyncPayloadResult.lower(value); + result = valueCaseId; + } else { + result = 0; + } + const ret = instance.exports.bjs_asyncRoundTripOptionalAssociatedValueEnum(+isSome, result); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + return ret1; + }, + AsyncPayloadResult: AsyncPayloadResultValues, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.d.ts new file mode 100644 index 000000000..d29256af4 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.d.ts @@ -0,0 +1,39 @@ +// 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 const PayloadSignalValues: { + readonly Tag: { + readonly Start: 0; + readonly Stop: 1; + readonly Idle: 2; + }; +}; + +export type PayloadSignalTag = + { tag: typeof PayloadSignalValues.Tag.Start; param0: string } | { tag: typeof PayloadSignalValues.Tag.Stop; param0: number } | { tag: typeof PayloadSignalValues.Tag.Idle } + +export type PayloadSignalObject = typeof PayloadSignalValues; + +export interface PayloadSignalControls { + send(signal: PayloadSignalTag): void; + current(): PayloadSignalTag; + roundTripOptional(signal: PayloadSignalTag | null): PayloadSignalTag | null; +} +export type Exports = { + PayloadSignal: PayloadSignalObject +} +export type Imports = { + PayloadSignalControls: { + roundTrip(signal: PayloadSignalTag): PayloadSignalTag; + } +} +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/EnumAssociatedValueImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.js new file mode 100644 index 000000000..1688dc94d --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.js @@ -0,0 +1,323 @@ +// 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 const PayloadSignalValues = { + Tag: { + Start: 0, + Stop: 1, + Idle: 2, + }, +}; +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 = []; + let taStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + const __bjs_createPayloadSignalValuesHelpers = () => ({ + lower: (value) => { + const enumTag = value.tag; + switch (enumTag) { + case PayloadSignalValues.Tag.Start: { + const bytes = textEncoder.encode(value.param0); + const id = swift.memory.retain(bytes); + i32Stack.push(bytes.length); + i32Stack.push(id); + return PayloadSignalValues.Tag.Start; + } + case PayloadSignalValues.Tag.Stop: { + i32Stack.push((value.param0 | 0)); + return PayloadSignalValues.Tag.Stop; + } + case PayloadSignalValues.Tag.Idle: { + return PayloadSignalValues.Tag.Idle; + } + default: throw new Error("Unknown PayloadSignalValues tag: " + String(enumTag)); + } + }, + lift: (tag) => { + tag = tag | 0; + switch (tag) { + case PayloadSignalValues.Tag.Start: { + const string = strStack.pop(); + return { tag: PayloadSignalValues.Tag.Start, param0: string }; + } + case PayloadSignalValues.Tag.Stop: { + const int = i32Stack.pop(); + return { tag: PayloadSignalValues.Tag.Stop, param0: int }; + } + case PayloadSignalValues.Tag.Idle: return { tag: PayloadSignalValues.Tag.Idle }; + default: throw new Error("Unknown PayloadSignalValues tag returned from Swift: " + String(tag)); + } + } + }); + + 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(); + } + const taCtors = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; + bjs["swift_js_push_typed_array"] = function(kind, ptr, count) { + const Ctor = taCtors[kind]; + const byteLen = count * Ctor.BYTES_PER_ELEMENT; + const copy = memory.buffer.slice(ptr, ptr + byteLen); + taStack.push(Array.from(new Ctor(copy))); + } + const __bjs_promiseSettlers = Symbol("JavaScriptKit.promiseSettlers"); + bjs["swift_js_make_promise"] = function() { + let resolve, reject; + const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); + promise[__bjs_promiseSettlers] = { resolve, reject }; + return swift.memory.retain(promise); + } + 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) {} + const TestModule = importObject["TestModule"] = importObject["TestModule"] || {}; + TestModule["bjs_PayloadSignalControls_roundTrip_static"] = function bjs_PayloadSignalControls_roundTrip_static(signal) { + try { + const enumValue = enumHelpers.PayloadSignal.lift(signal); + let ret = imports.PayloadSignalControls.roundTrip(enumValue); + const caseId = enumHelpers.PayloadSignal.lower(ret); + return caseId; + } catch (error) { + setException(error); + } + } + TestModule["bjs_PayloadSignalControls_send"] = function bjs_PayloadSignalControls_send(self, signal) { + try { + const enumValue = enumHelpers.PayloadSignal.lift(signal); + swift.memory.getObject(self).send(enumValue); + } catch (error) { + setException(error); + } + } + TestModule["bjs_PayloadSignalControls_current"] = function bjs_PayloadSignalControls_current(self) { + try { + let ret = swift.memory.getObject(self).current(); + const caseId = enumHelpers.PayloadSignal.lower(ret); + return caseId; + } catch (error) { + setException(error); + } + } + TestModule["bjs_PayloadSignalControls_roundTripOptional"] = function bjs_PayloadSignalControls_roundTripOptional(self, signalIsSome, signalCaseId) { + try { + let optResult; + if (signalIsSome) { + const enumValue = enumHelpers.PayloadSignal.lift(signalCaseId); + optResult = enumValue; + } else { + optResult = null; + } + let ret = swift.memory.getObject(self).roundTripOptional(optResult); + const isSome = ret != null; + if (isSome) { + const caseId = enumHelpers.PayloadSignal.lower(ret); + return caseId; + } else { + return -1; + } + } catch (error) { + setException(error); + } + } + }, + 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 PayloadSignalHelpers = __bjs_createPayloadSignalValuesHelpers(); + enumHelpers.PayloadSignal = PayloadSignalHelpers; + + const exports = { + PayloadSignal: PayloadSignalValues, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Tests/BridgeJSRuntimeTests/AsyncImportTests.swift b/Tests/BridgeJSRuntimeTests/AsyncImportTests.swift index 041f251f4..a092d111c 100644 --- a/Tests/BridgeJSRuntimeTests/AsyncImportTests.swift +++ b/Tests/BridgeJSRuntimeTests/AsyncImportTests.swift @@ -1,6 +1,12 @@ import Testing import JavaScriptKit +@JS enum AsyncImportedPayloadResult: Equatable { + case success(String) + case failure(Int) + case idle +} + @JSClass struct AsyncImportImports { @JSFunction static func jsAsyncRoundTripVoid() async throws(JSException) @JSFunction static func jsAsyncRoundTripNumber(_ v: Double) async throws(JSException) -> Double @@ -12,6 +18,12 @@ import JavaScriptKit @JSFunction static func jsAsyncRoundTripIntArray(_ values: [Double]) async throws(JSException) -> [Double] @JSFunction static func jsAsyncRoundTripStringArray(_ values: [String]) async throws(JSException) -> [String] @JSFunction static func jsAsyncRoundTripFeatureFlag(_ v: FeatureFlag) async throws(JSException) -> FeatureFlag + @JSFunction static func jsAsyncRoundTripAssociatedValueEnum( + _ v: AsyncImportedPayloadResult + ) async throws(JSException) -> AsyncImportedPayloadResult + @JSFunction static func jsAsyncRoundTripOptionalAssociatedValueEnum( + _ v: AsyncImportedPayloadResult? + ) async throws(JSException) -> AsyncImportedPayloadResult? } @Suite struct AsyncImportTests { @@ -69,6 +81,29 @@ import JavaScriptKit try #expect(await AsyncImportImports.jsAsyncRoundTripFeatureFlag(v) == v) } + @Test func asyncRoundTripAssociatedValueEnum() async throws { + let values: [AsyncImportedPayloadResult] = [ + .success("ok"), + .failure(7), + .idle, + ] + for value in values { + try #expect(await AsyncImportImports.jsAsyncRoundTripAssociatedValueEnum(value) == value) + } + } + + @Test func asyncRoundTripOptionalAssociatedValueEnum() async throws { + let values: [AsyncImportedPayloadResult?] = [ + .some(.success("ok")), + .some(.failure(7)), + .some(.idle), + nil, + ] + for value in values { + try #expect(await AsyncImportImports.jsAsyncRoundTripOptionalAssociatedValueEnum(value) == value) + } + } + // MARK: - Structured return type @Test func fetchWeatherData() async throws { diff --git a/Tests/BridgeJSRuntimeTests/ExportAPITests.swift b/Tests/BridgeJSRuntimeTests/ExportAPITests.swift index a0453b8f8..282b7cc60 100644 --- a/Tests/BridgeJSRuntimeTests/ExportAPITests.swift +++ b/Tests/BridgeJSRuntimeTests/ExportAPITests.swift @@ -334,6 +334,16 @@ extension StaticCalculator { @JS func asyncRoundTripOptionalFileSize(_ v: FileSize?) async -> FileSize? { v } +@JS enum AsyncPayloadResult: Equatable { + case success(String) + case failure(Int) + case idle +} + +@JS func asyncRoundTripAssociatedValueEnum(_ v: AsyncPayloadResult) async -> AsyncPayloadResult { v } + +@JS func asyncRoundTripOptionalAssociatedValueEnum(_ v: AsyncPayloadResult?) async -> AsyncPayloadResult? { v } + @JS func setHttpStatus(_ status: HttpStatus) -> HttpStatus { return status } diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift index 78bac8952..c02cb72f7 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift @@ -1924,6 +1924,67 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11 #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending AsyncImportedPayloadResult) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0CaseId = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(callbackValue, param0CaseId) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending AsyncImportedPayloadResult) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending AsyncImportedPayloadResult) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending AsyncImportedPayloadResult) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(AsyncImportedPayloadResult.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 @@ -2352,6 +2413,67 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(callback, param0IsSome, param0CaseId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_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, param0CaseId) = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(callbackValue, param0IsSome, param0CaseId) + #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_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Optional) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(Optional.bridgeJSLiftParameter(param0IsSome, param0CaseId)) + #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 @@ -3816,6 +3938,34 @@ public func _bjs_ArraySupportExports_static_multiOptionalArraySecond() -> Void { #endif } +extension AsyncImportedPayloadResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> AsyncImportedPayloadResult { + switch caseId { + case 0: + return .success(String.bridgeJSStackPop()) + case 1: + return .failure(Int.bridgeJSStackPop()) + case 2: + return .idle + default: + fatalError("Unknown AsyncImportedPayloadResult 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 .idle: + return Int32(2) + } + } +} + @_expose(wasm, "bjs_DefaultArgumentExports_static_testStringDefault") @_cdecl("bjs_DefaultArgumentExports_static_testStringDefault") public func _bjs_DefaultArgumentExports_static_testStringDefault(_ messageBytes: Int32, _ messageLength: Int32) -> Void { @@ -4127,6 +4277,34 @@ extension TSDirection: _BridgedSwiftCaseEnum { extension TSTheme: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { } +extension AsyncPayloadResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> AsyncPayloadResult { + switch caseId { + case 0: + return .success(String.bridgeJSStackPop()) + case 1: + return .failure(Int.bridgeJSStackPop()) + case 2: + return .idle + default: + fatalError("Unknown AsyncPayloadResult 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 .idle: + return Int32(2) + } + } +} + @_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 { @@ -4870,6 +5048,34 @@ extension LightColor: _BridgedSwiftCaseEnum { } } +extension ImportedPayloadSignal: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> ImportedPayloadSignal { + switch caseId { + case 0: + return .start(String.bridgeJSStackPop()) + case 1: + return .stop(Int.bridgeJSStackPop()) + case 2: + return .idle + default: + fatalError("Unknown ImportedPayloadSignal case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .start(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .stop(let param0): + param0.bridgeJSStackPush() + return Int32(1) + case .idle: + return Int32(2) + } + } +} + @_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt") @_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt") public func _bjs_IntegerTypesSupportExports_static_roundTripInt(_ v: Int32) -> Int32 { @@ -7543,6 +7749,32 @@ public func _bjs_asyncRoundTripOptionalFileSize(_ vIsSome: Int32, _ vValue: Int6 #endif } +@_expose(wasm, "bjs_asyncRoundTripAssociatedValueEnum") +@_cdecl("bjs_asyncRoundTripAssociatedValueEnum") +public func _bjs_asyncRoundTripAssociatedValueEnum(_ v: Int32) -> Int32 { + #if arch(wasm32) + let _tmp_v = AsyncPayloadResult.bridgeJSLiftParameter(v) + return _bjs_makePromise(resolve: Promise_resolve_18AsyncPayloadResultO, reject: Promise_reject) { + return await asyncRoundTripAssociatedValueEnum(_: _tmp_v) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_asyncRoundTripOptionalAssociatedValueEnum") +@_cdecl("bjs_asyncRoundTripOptionalAssociatedValueEnum") +public func _bjs_asyncRoundTripOptionalAssociatedValueEnum(_ vIsSome: Int32, _ vCaseId: Int32) -> Int32 { + #if arch(wasm32) + let _tmp_v = Optional.bridgeJSLiftParameter(vIsSome, vCaseId) + return _bjs_makePromise(resolve: Promise_resolve_Sq18AsyncPayloadResultO, reject: Promise_reject) { + return await asyncRoundTripOptionalAssociatedValueEnum(_: _tmp_v) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + @_expose(wasm, "bjs_setHttpStatus") @_cdecl("bjs_setHttpStatus") public func _bjs_setHttpStatus(_ status: Int32) -> Int32 { @@ -11797,6 +12029,48 @@ func _$Promise_resolve_Sq8FileSizeO(_ promise: JSObject, _ value: Optional Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO_extern(_ promise: Int32, _ value: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO_extern(promise, value) +} + +func _$Promise_resolve_18AsyncPayloadResultO(_ promise: JSObject, _ value: AsyncPayloadResult) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueCaseId = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO(promiseValue, valueCaseId) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_Sq18AsyncPayloadResultO(_ promise: JSObject, _ value: Optional) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO_extern(promise, valueIsSome, valueCaseId) +} + +func _$Promise_resolve_Sq18AsyncPayloadResultO(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let (valueIsSome, valueCaseId) = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO(promiseValue, valueIsSome, valueCaseId) + if let error = _swift_js_take_exception() { throw error } +} + @JSFunction func Promise_resolve_11PublicPointV(_ promise: JSObject, _ value: PublicPoint) throws(JSException) #if arch(wasm32) @@ -12421,6 +12695,30 @@ fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_exter return bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_extern(resolveRef, rejectRef, vBytes, vLength) } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static_extern(resolveRef, rejectRef, v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vCaseId: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vCaseId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vCaseId: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static_extern(resolveRef, rejectRef, vIsSome, vCaseId) +} + func _$AsyncImportImports_jsAsyncRoundTripVoid() async throws(JSException) -> Void { try await _bjs_awaitPromise(makeResolveClosure: { JSTypedClosure<() -> Void>($0) @@ -12542,6 +12840,30 @@ func _$AsyncImportImports_jsAsyncRoundTripFeatureFlag(_ v: FeatureFlag) async th return resolved } +func _$AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum(_ v: AsyncImportedPayloadResult) async throws(JSException) -> AsyncImportedPayloadResult { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending AsyncImportedPayloadResult) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let vCaseId = v.bridgeJSLowerParameter() + bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static(resolveRef, rejectRef, vCaseId) + } + return resolved +} + +func _$AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum(_ 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, vCaseId) = v.bridgeJSLowerParameter() + bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static(resolveRef, rejectRef, vIsSome, vCaseId) + } + return resolved +} + #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyVoid_static") fileprivate func bjs_ClosureSupportImports_jsApplyVoid_static_extern(_ callback: Int32) -> Void @@ -14079,6 +14401,48 @@ func _$jsRoundTripLightColor(_ value: LightColor) throws(JSException) -> LightCo return LightColor.bridgeJSLiftReturn(ret) } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripImportedPayloadSignal") +fileprivate func bjs_jsRoundTripImportedPayloadSignal_extern(_ value: Int32) -> Int32 +#else +fileprivate func bjs_jsRoundTripImportedPayloadSignal_extern(_ value: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripImportedPayloadSignal(_ value: Int32) -> Int32 { + return bjs_jsRoundTripImportedPayloadSignal_extern(value) +} + +func _$jsRoundTripImportedPayloadSignal(_ value: ImportedPayloadSignal) throws(JSException) -> ImportedPayloadSignal { + let valueCaseId = value.bridgeJSLowerParameter() + let ret = bjs_jsRoundTripImportedPayloadSignal(valueCaseId) + if let error = _swift_js_take_exception() { + throw error + } + return ImportedPayloadSignal.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripOptionalImportedPayloadSignal") +fileprivate func bjs_jsRoundTripOptionalImportedPayloadSignal_extern(_ valueIsSome: Int32, _ valueCaseId: Int32) -> Int32 +#else +fileprivate func bjs_jsRoundTripOptionalImportedPayloadSignal_extern(_ valueIsSome: Int32, _ valueCaseId: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripOptionalImportedPayloadSignal(_ valueIsSome: Int32, _ valueCaseId: Int32) -> Int32 { + return bjs_jsRoundTripOptionalImportedPayloadSignal_extern(valueIsSome, valueCaseId) +} + +func _$jsRoundTripOptionalImportedPayloadSignal(_ value: Optional) throws(JSException) -> Optional { + let (valueIsSome, valueCaseId) = value.bridgeJSLowerParameter() + let ret = bjs_jsRoundTripOptionalImportedPayloadSignal(valueIsSome, valueCaseId) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn(ret) +} + #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 6535e9fc1..a51e6bafd 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json @@ -6550,6 +6550,53 @@ "swiftCallName" : "ArraySupportExports", "tsFullPath" : "ArraySupportExports" }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + + ], + "name" : "idle" + } + ], + "emitStyle" : "const", + "name" : "AsyncImportedPayloadResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "AsyncImportedPayloadResult", + "tsFullPath" : "AsyncImportedPayloadResult" + }, { "cases" : [ @@ -7715,6 +7762,53 @@ "swiftCallName" : "TSTheme", "tsFullPath" : "TSTheme" }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + + ], + "name" : "idle" + } + ], + "emitStyle" : "const", + "name" : "AsyncPayloadResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "AsyncPayloadResult", + "tsFullPath" : "AsyncPayloadResult" + }, { "cases" : [ @@ -9326,6 +9420,53 @@ "swiftCallName" : "LightColor", "tsFullPath" : "LightColor" }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "start" + }, + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "stop" + }, + { + "associatedValues" : [ + + ], + "name" : "idle" + } + ], + "emitStyle" : "const", + "name" : "ImportedPayloadSignal", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "ImportedPayloadSignal", + "tsFullPath" : "ImportedPayloadSignal" + }, { "cases" : [ @@ -12984,6 +13125,66 @@ } } }, + { + "abiName" : "bjs_asyncRoundTripAssociatedValueEnum", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripAssociatedValueEnum", + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + } + }, + { + "abiName" : "bjs_asyncRoundTripOptionalAssociatedValueEnum", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripOptionalAssociatedValueEnum", + "parameters" : [ + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + }, + "_1" : "null" + } + } + }, { "abiName" : "bjs_setHttpStatus", "effects" : { @@ -18442,6 +18643,64 @@ "_1" : "String" } } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripAssociatedValueEnum", + "parameters" : [ + { + "name" : "v", + "type" : { + "associatedValueEnum" : { + "_0" : "AsyncImportedPayloadResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "AsyncImportedPayloadResult" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripOptionalAssociatedValueEnum", + "parameters" : [ + { + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AsyncImportedPayloadResult" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AsyncImportedPayloadResult" + } + }, + "_1" : "null" + } + } } ] } @@ -20406,6 +20665,64 @@ "_0" : "LightColor" } } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripImportedPayloadSignal", + "parameters" : [ + { + "name" : "value", + "type" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalImportedPayloadSignal", + "parameters" : [ + { + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } + }, + "_1" : "null" + } + } } ], "types" : [ diff --git a/Tests/BridgeJSRuntimeTests/ImportAPITests.swift b/Tests/BridgeJSRuntimeTests/ImportAPITests.swift index 2bb9158b9..9cf77ed9d 100644 --- a/Tests/BridgeJSRuntimeTests/ImportAPITests.swift +++ b/Tests/BridgeJSRuntimeTests/ImportAPITests.swift @@ -7,7 +7,19 @@ import JavaScriptKit case green } +@JS enum ImportedPayloadSignal: Equatable { + case start(String) + case stop(Int) + case idle +} + @JSFunction func jsRoundTripLightColor(_ value: LightColor) throws(JSException) -> LightColor +@JSFunction func jsRoundTripImportedPayloadSignal( + _ value: ImportedPayloadSignal +) throws(JSException) -> ImportedPayloadSignal +@JSFunction func jsRoundTripOptionalImportedPayloadSignal( + _ value: ImportedPayloadSignal? +) throws(JSException) -> ImportedPayloadSignal? class ImportAPITests: XCTestCase { func testRoundTripVoid() throws { @@ -80,6 +92,29 @@ class ImportAPITests: XCTestCase { } } + func testRoundTripAssociatedValueEnum() throws { + let values: [ImportedPayloadSignal] = [ + .start("go"), + .stop(42), + .idle, + ] + for value in values { + try XCTAssertEqual(jsRoundTripImportedPayloadSignal(value), value) + } + } + + func testRoundTripOptionalAssociatedValueEnum() throws { + let values: [ImportedPayloadSignal?] = [ + .some(.start("go")), + .some(.stop(42)), + .some(.idle), + nil, + ] + for value in values { + try XCTAssertEqual(jsRoundTripOptionalImportedPayloadSignal(value), value) + } + } + func ensureThrows(_ f: (Bool) throws(JSException) -> T) throws { do { _ = try f(true) diff --git a/Tests/BridgeJSRuntimeTests/JavaScript/AsyncImportTests.mjs b/Tests/BridgeJSRuntimeTests/JavaScript/AsyncImportTests.mjs index 1a767b184..9be7af1be 100644 --- a/Tests/BridgeJSRuntimeTests/JavaScript/AsyncImportTests.mjs +++ b/Tests/BridgeJSRuntimeTests/JavaScript/AsyncImportTests.mjs @@ -1,7 +1,7 @@ // @ts-check import assert from 'node:assert'; -import { ThemeValues, DirectionValues, FileSizeValues } from '../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.js'; +import { ThemeValues, DirectionValues, FileSizeValues, AsyncPayloadResultValues } from '../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.js'; /** * @returns {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Imports["AsyncImportImports"]} @@ -38,6 +38,12 @@ export function getImports(importsContext) { jsAsyncRoundTripFeatureFlag: (v) => { return Promise.resolve(v); }, + jsAsyncRoundTripAssociatedValueEnum: (v) => { + return Promise.resolve(v); + }, + jsAsyncRoundTripOptionalAssociatedValueEnum: (v) => { + return Promise.resolve(v); + }, }; } @@ -124,4 +130,15 @@ export async function runAsyncWorksTests(exports) { assert.equal(await exports.asyncRoundTripFileSize(FileSizeValues.Large), FileSizeValues.Large); assert.equal(await exports.asyncRoundTripOptionalFileSize(FileSizeValues.Tiny), FileSizeValues.Tiny); assert.equal(await exports.asyncRoundTripOptionalFileSize(null), null); + + const asyncPayloadSuccess = { tag: AsyncPayloadResultValues.Tag.Success, param0: "ok" }; + const asyncPayloadFailure = { tag: AsyncPayloadResultValues.Tag.Failure, param0: 7 }; + const asyncPayloadIdle = { tag: AsyncPayloadResultValues.Tag.Idle }; + assert.deepEqual(await exports.asyncRoundTripAssociatedValueEnum(asyncPayloadSuccess), asyncPayloadSuccess); + assert.deepEqual(await exports.asyncRoundTripAssociatedValueEnum(asyncPayloadFailure), asyncPayloadFailure); + assert.deepEqual(await exports.asyncRoundTripAssociatedValueEnum(asyncPayloadIdle), asyncPayloadIdle); + assert.deepEqual(await exports.asyncRoundTripOptionalAssociatedValueEnum(asyncPayloadSuccess), asyncPayloadSuccess); + assert.deepEqual(await exports.asyncRoundTripOptionalAssociatedValueEnum(asyncPayloadFailure), asyncPayloadFailure); + assert.deepEqual(await exports.asyncRoundTripOptionalAssociatedValueEnum(asyncPayloadIdle), asyncPayloadIdle); + assert.equal(await exports.asyncRoundTripOptionalAssociatedValueEnum(null), null); } diff --git a/Tests/prelude.mjs b/Tests/prelude.mjs index 0f83da53c..bf3073c62 100644 --- a/Tests/prelude.mjs +++ b/Tests/prelude.mjs @@ -91,6 +91,12 @@ export async function setupOptions(options, context) { "jsRoundTripLightColor": (value) => { return value; }, + "jsRoundTripImportedPayloadSignal": (value) => { + return value; + }, + "jsRoundTripOptionalImportedPayloadSignal": (value) => { + return value; + }, "jsEchoJSValue": (v) => { return v; }, From fa13f45eae06bcabf1c714bdccc0a0462fd047db Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Thu, 11 Jun 2026 11:42:34 +0200 Subject: [PATCH 03/20] BridgeJS: Support throws and async for closures --- .../Sources/BridgeJSCore/ClosureCodegen.swift | 106 +- .../Sources/BridgeJSCore/ImportTS.swift | 9 +- .../BridgeJSCore/SwiftToSkeleton.swift | 51 +- .../Sources/BridgeJSLink/BridgeJSLink.swift | 6 +- .../BridgeJSSkeleton/BridgeJSSkeleton.swift | 80 +- .../ClosureAsyncDiagnosticsTests.swift | 151 +++ .../ClosureManglingTests.swift | 30 + .../ClosureThrowsDiagnosticsTests.swift | 56 ++ .../Inputs/MacroSwift/SwiftClosure.swift | 11 + .../MacroSwift/SwiftClosureImports.swift | 4 + .../BridgeJSCodegenTests/SwiftClosure.json | 227 +++++ .../BridgeJSCodegenTests/SwiftClosure.swift | 844 ++++++++++++++++ .../SwiftClosureImports.json | 105 ++ .../SwiftClosureImports.swift | 340 +++++++ .../BridgeJSLinkTests/SwiftClosure.d.ts | 6 + .../BridgeJSLinkTests/SwiftClosure.js | 368 +++++++ .../SwiftClosureImports.d.ts | 2 + .../BridgeJSLinkTests/SwiftClosureImports.js | 208 ++++ .../Bringing-Swift-Closures-to-JavaScript.md | 42 + .../Exporting-Swift-Closure.md | 143 ++- .../ClosureAsyncAPIs.swift | 89 ++ .../ClosureThrowsAPIs.swift | 31 + .../Generated/BridgeJS.swift | 922 +++++++++++++++++- .../Generated/JavaScript/BridgeJS.json | 446 +++++++++ .../JavaScript/ClosureAsyncTests.mjs | 137 +++ .../JavaScript/ClosureThrowsTests.mjs | 57 ++ Tests/prelude.mjs | 4 + 27 files changed, 4364 insertions(+), 111 deletions(-) create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncDiagnosticsTests.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureManglingTests.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureThrowsDiagnosticsTests.swift create mode 100644 Tests/BridgeJSRuntimeTests/ClosureAsyncAPIs.swift create mode 100644 Tests/BridgeJSRuntimeTests/ClosureThrowsAPIs.swift create mode 100644 Tests/BridgeJSRuntimeTests/JavaScript/ClosureAsyncTests.mjs create mode 100644 Tests/BridgeJSRuntimeTests/JavaScript/ClosureThrowsTests.mjs diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift index 45cfb73f1..d4e65c631 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift @@ -16,7 +16,7 @@ public struct ClosureCodegen { let closureParams = signature.parameters.map { "\(sendingPrefix)\($0.closureSwiftType)" }.joined( separator: ", " ) - let swiftEffects = (signature.isAsync ? " async" : "") + (signature.isThrows ? " throws" : "") + let swiftEffects = (signature.isAsync ? " async" : "") + (signature.isThrows ? " throws(JSException)" : "") let swiftReturnType = signature.returnType.closureSwiftType return "(\(closureParams))\(swiftEffects) -> \(swiftReturnType)" } @@ -73,7 +73,17 @@ public struct ClosureCodegen { helperEnumDeclPrinter.indent { helperEnumDeclPrinter.write("let callback = JSObject.bridgeJSLiftParameter(callbackId)") let parameters: String - if signature.parameters.isEmpty { + if signature.isThrows || signature.isAsync { + let sendingPrefix = signature.sendingParameters ? "sending " : "" + let typedParams = + signature.parameters.enumerated().map { index, paramType in + "param\(index): \(sendingPrefix)\(paramType.closureSwiftType)" + }.joined(separator: ", ") + let returnType = signature.returnType.closureSwiftType + let effects = + (signature.isAsync ? " async" : "") + (signature.isThrows ? " throws(JSException)" : "") + parameters = " (\(typedParams))\(effects) -> \(returnType)" + } else if signature.parameters.isEmpty { parameters = "" } else if signature.parameters.count == 1 { parameters = " param0" @@ -146,9 +156,17 @@ public struct ClosureCodegen { liftedParams.append("\(paramType.swiftType).bridgeJSLiftParameter(\(argNames.joined(separator: ", ")))") } - let closureCallExpr = ExprSyntax("closure(\(raw: liftedParams.joined(separator: ", ")))") + let tryPrefix = signature.isThrows ? "try " : "" + let closureCallExpr = ExprSyntax("\(raw: tryPrefix)closure(\(raw: liftedParams.joined(separator: ", ")))") + let asyncTryPrefix = (signature.isThrows ? "try " : "") + "await " + let asyncClosureCallExpr = ExprSyntax( + "\(raw: asyncTryPrefix)closure(\(raw: liftedParams.joined(separator: ", ")))" + ) - let abiReturnWasmType = try signature.returnType.loweringReturnInfo().returnType + let abiReturnWasmType = + signature.isAsync + ? try BridgeType.jsObject(nil).loweringReturnInfo().returnType + : try signature.returnType.loweringReturnInfo().returnType // Build signature using SwiftSignatureBuilder let funcSignature = SwiftSignatureBuilder.buildABIFunctionSignature( @@ -156,12 +174,7 @@ public struct ClosureCodegen { returnType: abiReturnWasmType ) - // Build function declaration using helper - let funcDecl = SwiftCodePattern.buildExposedFunctionDecl( - abiName: abiName, - signature: funcSignature - ) { printer in - printer.write("let closure = Unmanaged<\(boxType)>.fromOpaque(boxPtr).takeUnretainedValue().closure") + let emitCallAndLower: (CodeFragmentPrinter) -> Void = { printer in if signature.returnType == .void { printer.write(closureCallExpr.description) } else { @@ -189,6 +202,79 @@ public struct ClosureCodegen { } } + let emitAsyncCallAndLower: (CodeFragmentPrinter) -> Void = { printer in + printer.write("let closure = Unmanaged<\(boxType)>.fromOpaque(boxPtr).takeUnretainedValue().closure") + let resolveType = signature.returnType + let resolveName = "Promise_resolve_\(resolveType.mangleTypeName)" + let rejectName = "Promise_reject" + let closureHead: String + if signature.isThrows { + let returnSpelling = resolveType == .void ? "" : " -> \(resolveType.closureSwiftType)" + closureHead = " () async throws(JSException)\(returnSpelling) in" + } else { + closureHead = "" + } + printer.write("return _bjs_makePromise(resolve: \(resolveName), reject: \(rejectName)) {\(closureHead)") + printer.indent { + if resolveType == .void { + printer.write(asyncClosureCallExpr.description) + } else { + printer.write("return \(asyncClosureCallExpr)") + } + } + printer.write("}") + } + + let catchPlaceholderStmt = abiReturnWasmType?.swiftReturnPlaceholderStmt + + // Build function declaration using helper + let funcDecl = SwiftCodePattern.buildExposedFunctionDecl( + abiName: abiName, + signature: funcSignature + ) { printer in + if signature.isAsync { + emitAsyncCallAndLower(printer) + } else if signature.isThrows { + printer.write( + "let closure = Unmanaged<\(boxType)>.fromOpaque(boxPtr).takeUnretainedValue().closure" + ) + printer.write("do {") + printer.indent { + emitCallAndLower(printer) + } + printer.write("} catch let error {") + printer.indent { + printer.write("if let error = error.thrownValue.object {") + printer.indent { + printer.write("withExtendedLifetime(error) {") + printer.indent { + printer.write("_swift_js_throw(Int32(bitPattern: $0.id))") + } + printer.write("}") + } + printer.write("} else {") + printer.indent { + printer.write("let jsError = JSError(message: error.description)") + printer.write("withExtendedLifetime(jsError.jsObject) {") + printer.indent { + printer.write("_swift_js_throw(Int32(bitPattern: $0.id))") + } + printer.write("}") + } + printer.write("}") + if let catchPlaceholderStmt { + printer.write(catchPlaceholderStmt) + } + } + printer.write("}") + } else { + printer.write( + "let closure = Unmanaged<\(boxType)>.fromOpaque(boxPtr).takeUnretainedValue().closure" + ) + emitCallAndLower(printer) + } + } + return DeclSyntax(funcDecl) } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift index a6a73b8f7..2912ce698 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift @@ -272,9 +272,7 @@ public struct ImportTS { } } - // Add exception check for ImportTS context (skipped for async, where - // errors are funneled through the JS-side reject path) - if !effects.isAsync && context == .importTS { + if !effects.isAsync && (context == .importTS || effects.isThrows) { body.write("if let error = _swift_js_take_exception() { throw error }") } } @@ -323,18 +321,19 @@ public struct ImportTS { let innerBody = body body = CodeFragmentPrinter() + let tryKeyword = effects.isThrows ? "try" : "try!" let rejectFactory = "makeRejectClosure: { JSTypedClosure<(sending JSValue) -> Void>($0) }" if returnType == .void { let resolveFactory = "makeResolveClosure: { JSTypedClosure<() -> Void>($0) }" body.write( - "try await _bjs_awaitPromise(\(resolveFactory), \(rejectFactory)) { resolveRef, rejectRef in" + "\(tryKeyword) await _bjs_awaitPromise(\(resolveFactory), \(rejectFactory)) { resolveRef, rejectRef in" ) } else { let resolveSwiftType = returnType.closureSwiftType let resolveFactory = "makeResolveClosure: { JSTypedClosure<(sending \(resolveSwiftType)) -> Void>($0) }" body.write( - "let resolved = try await _bjs_awaitPromise(\(resolveFactory), \(rejectFactory)) { resolveRef, rejectRef in" + "let resolved = \(tryKeyword) await _bjs_awaitPromise(\(resolveFactory), \(rejectFactory)) { resolveRef, rejectRef in" ) } body.indent { diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index 57b9a57df..18bde3c7f 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -191,7 +191,40 @@ public final class SwiftToSkeleton { } let isAsync = functionType.effectSpecifiers?.asyncSpecifier != nil - let isThrows = functionType.effectSpecifiers?.throwsClause != nil + + if isAsync, !returnType.isAsyncResolvable { + errors.append( + DiagnosticError( + node: functionType, + message: + "Returning '\(returnType.swiftType)' from an async closure is not yet supported", + hint: + "Return a type lowerable through the async resolve ABI " + + "(String/Int/Bool/Double/Float/raw-value or case-only enum/@JS struct/JSObject/Optional/Array/Dictionary), " + + "or make the closure non-async." + ) + ) + return nil + } + + var isThrows = false + if let throwsClause = functionType.effectSpecifiers?.throwsClause { + guard let thrownType = throwsClause.type, + thrownType.trimmedDescription == "JSException" + else { + errors.append( + DiagnosticError( + node: throwsClause, + message: + "Only JSException is supported for thrown type of Swift closures, " + + "got \(throwsClause.type?.trimmedDescription ?? "unspecified")", + hint: "Annotate the closure as `throws(JSException)`" + ) + ) + return nil + } + isThrows = true + } return .closure( ClosureSignature( @@ -1028,22 +1061,6 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { guard let type = resolvedType else { continue // Skip unsupported types } - if case .closure(let signature, _) = type { - if signature.isAsync { - diagnose( - node: param.type, - message: "Async is not supported for Swift closures yet." - ) - continue - } - if signature.isThrows { - diagnose( - node: param.type, - message: "Throws is not supported for Swift closures yet." - ) - continue - } - } if case .nullable(let wrappedType, _) = type, wrappedType.isOptional { diagnoseNestedOptional(node: param.type, type: param.type.trimmedDescription) continue diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 9a8442435..a9acf048e 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -894,7 +894,7 @@ public struct BridgeJSLink { ) throws -> [String] { let printer = CodeFragmentPrinter() let builder = ExportedThunkBuilder( - effects: Effects(isAsync: false, isThrows: true), + effects: Effects(isAsync: signature.isAsync, isThrows: signature.isAsync ? signature.isThrows : true), hasDirectAccessToSwiftClass: false, intrinsicRegistry: intrinsicRegistry ) @@ -3743,7 +3743,9 @@ extension BridgeType { let paramTypes = signature.parameters.enumerated().map { index, param in "arg\(index): \(param.tsType)" }.joined(separator: ", ") - return "(\(paramTypes)) => \(signature.returnType.tsType)" + let returnTS = + signature.isAsync ? "Promise<\(signature.returnType.tsType)>" : signature.returnType.tsType + return "(\(paramTypes)) => \(returnTS)" case .array(let elementType): let inner = elementType.tsType if inner.contains("|") || inner.contains("=>") { diff --git a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift index 830132481..3e95b46a7 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift @@ -157,7 +157,8 @@ public struct ClosureSignature: Codable, Equatable, Hashable, Sendable { ? "y" : parameters.map { $0.mangleTypeName }.joined() let sendingPart = sendingParameters ? "s" : "" - let signaturePart = "\(sendingPart)\(paramPart)_\(returnType.mangleTypeName)" + let effects = (isAsync ? "Ya" : "") + (isThrows ? "K" : "") + let signaturePart = "\(sendingPart)\(effects)\(paramPart)_\(returnType.mangleTypeName)" self.mangleName = "\(moduleName.count)\(moduleName)\(signaturePart)" } } @@ -1049,8 +1050,31 @@ public struct ExportedSkeleton: Codable { for enumDef in enums { for method in enumDef.staticMethods { consider(method.returnType, method.effects) } } + for returnType in asyncClosureResolveReturnTypes { + consider(returnType, Effects(isAsync: true, isThrows: false)) + } return result } + + private var asyncClosureResolveReturnTypes: [BridgeType] { + var collector = AsyncClosureReturnTypeCollector() + var walker = BridgeSkeletonWalker(visitor: collector) + walker.walk(self) + return walker.visitor.returnTypes + } +} + +private struct AsyncClosureReturnTypeCollector: BridgeSkeletonVisitor { + private(set) var returnTypes: [BridgeType] = [] + + mutating func visitClosure( + _ signature: ClosureSignature, + useJSTypedClosure: Bool, + accessLevel: BridgeJSAccessLevel + ) { + guard signature.isAsync else { return } + returnTypes.append(signature.returnType) + } } // MARK: - Imported Skeleton @@ -1424,11 +1448,18 @@ public struct ClosureSignatureCollectorVisitor: BridgeSkeletonVisitor { accessLevel: BridgeJSAccessLevel ) { recordSignature(signature, accessLevel: accessLevel) + + if signature.isAsync { + recordInjectedSignatures( + forReturnType: signature.returnType, + accessLevel: accessLevel + ) + } } /// Insert `signature` at `accessLevel`, or upgrade the existing level to /// the more permissive of the two. Centralizing the merge here keeps - /// `visitClosure` and `recordInjectedSignature` in lockstep — if the + /// `visitClosure` and `recordInjectedSignatures` in lockstep - if the /// merge policy ever needs to change (e.g. adding a diagnostic for /// conflicting levels), there's only one place to update. private mutating func recordSignature( @@ -1444,56 +1475,48 @@ public struct ClosureSignatureCollectorVisitor: BridgeSkeletonVisitor { public mutating func visitImportedFunction(_ function: ImportedFunctionSkeleton) { guard function.effects.isAsync else { return } - // When async imports exist, inject closure signatures for the typed resolve - // and reject callbacks used by _bjs_awaitPromise. - // - Reject always uses (sending JSValue) -> Void - // - Resolve uses a typed closure matching the return type (or () -> Void for void) - // All async callback closures use `sending` parameters so values can be - // transferred through the checked continuation without Sendable constraints. + recordInjectedSignatures( + forReturnType: function.returnType, + accessLevel: function.accessLevel + ) + } + private mutating func recordInjectedSignatures( + forReturnType returnType: BridgeType, + accessLevel: BridgeJSAccessLevel + ) { // Reject callback - recordInjectedSignature( + recordSignature( ClosureSignature( parameters: [.jsValue], returnType: .void, moduleName: moduleName, sendingParameters: true ), - for: function + accessLevel: accessLevel ) // Resolve callback (typed per return type) - if function.returnType == .void { - recordInjectedSignature( + if returnType == .void { + recordSignature( ClosureSignature( parameters: [], returnType: .void, moduleName: moduleName ), - for: function + accessLevel: accessLevel ) } else { - recordInjectedSignature( + recordSignature( ClosureSignature( - parameters: [function.returnType], + parameters: [returnType], returnType: .void, moduleName: moduleName, sendingParameters: true ), - for: function + accessLevel: accessLevel ) } } - - /// Inject a closure signature derived from an async import (e.g. Promise - /// resolve/reject callbacks). The injected signature inherits the access - /// level of the originating function so its synthesized init matches the - /// visibility of the async API surface. - private mutating func recordInjectedSignature( - _ signature: ClosureSignature, - for function: ImportedFunctionSkeleton - ) { - recordSignature(signature, accessLevel: function.accessLevel) - } } // MARK: - Unified Skeleton @@ -1678,7 +1701,8 @@ extension BridgeType { signature.parameters.isEmpty ? "y" : signature.parameters.map { $0.mangleTypeName }.joined() - return "K\(params)_\(signature.returnType.mangleTypeName)\(useJSTypedClosure ? "J" : "")" + let effects = (signature.isAsync ? "Ya" : "") + (signature.isThrows ? "K" : "") + return "K\(effects)\(params)_\(signature.returnType.mangleTypeName)\(useJSTypedClosure ? "J" : "")" case .array(let elementType): // Array mangling: "Sa" prefix followed by element type return "Sa\(elementType.mangleTypeName)" diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncDiagnosticsTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncDiagnosticsTests.swift new file mode 100644 index 000000000..55d9e1bd3 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncDiagnosticsTests.swift @@ -0,0 +1,151 @@ +import Foundation +import SwiftParser +import SwiftSyntax +import Testing + +@testable import BridgeJSCore +@testable import BridgeJSSkeleton + +@Suite struct ClosureAsyncDiagnosticsTests { + @Test + func parsesAsyncClosureParameter() throws { + let app = try resolveApp( + source: """ + @JS public func process(_ cb: (Int) async -> String) {} + """ + ) + let function = try #require(app.exported?.functions.first(where: { $0.name == "process" })) + let parameter = try #require(function.parameters.first) + guard case .closure(let signature, _) = parameter.type else { + Issue.record("Expected closure parameter type, got \(parameter.type)") + return + } + #expect(signature.isAsync) + } + + @Test + func collectsResolveRejectSignaturesForAsyncClosure() throws { + let app = try resolveApp( + source: """ + @JS public func process(_ cb: (Int) async -> String) {} + """ + ) + let signatures = collectSignatures(from: app) + + let reject = ClosureSignature( + parameters: [.jsValue], + returnType: .void, + moduleName: "App", + sendingParameters: true + ) + let resolve = ClosureSignature( + parameters: [.string], + returnType: .void, + moduleName: "App", + sendingParameters: true + ) + + #expect(signatures.contains(reject)) + #expect(signatures.contains(resolve)) + } + + @Test + func collectsVoidResolveSignatureForVoidReturningAsyncClosure() throws { + let app = try resolveApp( + source: """ + @JS public func process(_ cb: (Int) async -> Void) {} + """ + ) + let signatures = collectSignatures(from: app) + + let reject = ClosureSignature( + parameters: [.jsValue], + returnType: .void, + moduleName: "App", + sendingParameters: true + ) + let voidResolve = ClosureSignature( + parameters: [], + returnType: .void, + moduleName: "App" + ) + + #expect(signatures.contains(reject)) + #expect(signatures.contains(voidResolve)) + } + + @Test + func supportsAsyncClosureReturningJSStruct() throws { + let app = try resolveApp( + source: """ + @JS struct Point { var x: Int } + @JS public func makePoint() -> JSTypedClosure<(Int) async -> Point> { + fatalError() + } + """ + ) + let resolveTypes = try #require(app.exported?.asyncPromiseResolveReturnTypes) + #expect(resolveTypes.contains { $0.mangleTypeName == "5PointV" }) + } + + @Test + func supportsAsyncThrowsClosureReturningJSStruct() throws { + let app = try resolveApp( + source: """ + @JS struct Point { var x: Int } + @JS public func makePoint() -> JSTypedClosure<(Int) async throws(JSException) -> Point> { + fatalError() + } + """ + ) + let resolveTypes = try #require(app.exported?.asyncPromiseResolveReturnTypes) + #expect(resolveTypes.contains { $0.mangleTypeName == "5PointV" }) + } + + @Test + func supportsAsyncClosureReturningAssociatedValueEnum() throws { + let app = try resolveApp( + source: """ + @JS enum Shape { case circle(radius: Double); case square(side: Double) } + @JS public func process(_ cb: (Int) async -> Shape) {} + """ + ) + let resolveTypes = try #require(app.exported?.asyncPromiseResolveReturnTypes) + #expect(resolveTypes.contains { $0.mangleTypeName == "5ShapeO" }) + } + + @Test + func supportsAsyncThrowsClosureReturningAssociatedValueEnum() throws { + let app = try resolveApp( + source: """ + @JS enum Shape { case circle(radius: Double); case square(side: Double) } + @JS public func makeShape() -> JSTypedClosure<(Int) async throws(JSException) -> Shape> { + fatalError() + } + """ + ) + let resolveTypes = try #require(app.exported?.asyncPromiseResolveReturnTypes) + #expect(resolveTypes.contains { $0.mangleTypeName == "5ShapeO" }) + } + + // MARK: - Utilities + + private func collectSignatures(from skeleton: BridgeJSSkeleton) -> Set { + let collector = ClosureSignatureCollectorVisitor(moduleName: skeleton.moduleName) + var walker = BridgeSkeletonWalker(visitor: collector) + walker.walk(skeleton) + return walker.visitor.signatures + } + + private func resolveApp(source appSource: String) throws -> BridgeJSSkeleton { + let swiftAPI = SwiftToSkeleton( + progress: .silent, + moduleName: "App", + exposeToGlobal: false, + externalModuleIndex: ExternalModuleIndex(dependencies: []) + ) + let sourceFile = Parser.parse(source: appSource) + swiftAPI.addSourceFile(sourceFile, inputFilePath: "App.swift") + return try swiftAPI.finalize() + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureManglingTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureManglingTests.swift new file mode 100644 index 000000000..3675c805a --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureManglingTests.swift @@ -0,0 +1,30 @@ +import Testing + +@testable import BridgeJSSkeleton + +@Suite struct ClosureManglingTests { + private func sig(async a: Bool, throws t: Bool) -> ClosureSignature { + ClosureSignature( + parameters: [.integer(.int)], + returnType: .integer(.int), + moduleName: "M", + isAsync: a, + isThrows: t + ) + } + + @Test func effectsDisambiguateMangle() { + let plain = sig(async: false, throws: false).mangleName + let thr = sig(async: false, throws: true).mangleName + let asy = sig(async: true, throws: false).mangleName + let both = sig(async: true, throws: true).mangleName + #expect(Set([plain, thr, asy, both]).count == 4) + #expect(thr.contains("K")) + #expect(asy.contains("Ya")) + if let ya = both.range(of: "Ya"), let k = both.range(of: "K") { + #expect(ya.lowerBound < k.lowerBound) + } else { + Issue.record("expected both Ya and K in async-throws mangle") + } + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureThrowsDiagnosticsTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureThrowsDiagnosticsTests.swift new file mode 100644 index 000000000..eb41d0132 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureThrowsDiagnosticsTests.swift @@ -0,0 +1,56 @@ +import Foundation +import SwiftParser +import SwiftSyntax +import Testing + +@testable import BridgeJSCore +@testable import BridgeJSSkeleton + +@Suite struct ClosureThrowsDiagnosticsTests { + @Test + func parsesThrowsJSExceptionClosureParameter() throws { + let app = try resolveApp( + source: """ + @JS public func process(_ cb: (Int) throws(JSException) -> Int) {} + """ + ) + let function = try #require(app.exported?.functions.first(where: { $0.name == "process" })) + let parameter = try #require(function.parameters.first) + guard case .closure(let signature, _) = parameter.type else { + Issue.record("Expected closure parameter type, got \(parameter.type)") + return + } + #expect(signature.isThrows) + #expect(!signature.isAsync) + } + + @Test + func rejectsPlainThrowsClosureParameter() throws { + do { + _ = try resolveApp( + source: """ + @JS public func process(_ cb: (Int) throws -> Int) {} + """ + ) + Issue.record("Expected a plain-throws closure diagnostic, but resolution succeeded") + } catch let error as BridgeJSCoreDiagnosticError { + let combined = error.diagnostics.map(\.diagnostic.message).joined(separator: "\n") + #expect(combined.contains("JSException")) + #expect(!combined.contains("Throws is not supported for Swift closures yet.")) + } + } + + // MARK: - Utilities + + private func resolveApp(source appSource: String) throws -> BridgeJSSkeleton { + let swiftAPI = SwiftToSkeleton( + progress: .silent, + moduleName: "App", + exposeToGlobal: false, + externalModuleIndex: ExternalModuleIndex(dependencies: []) + ) + let sourceFile = Parser.parse(source: appSource) + swiftAPI.addSourceFile(sourceFile, inputFilePath: "App.swift") + return try swiftAPI.finalize() + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosure.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosure.swift index 6872d7989..cdd756d51 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosure.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosure.swift @@ -38,6 +38,17 @@ import JavaScriptKit @JS func roundtripPerson(_ personClosure: (Person) -> Person) -> (Person) -> Person @JS func roundtripOptionalPerson(_ personClosure: (Person?) -> Person?) -> (Person?) -> Person? +@JS func makeThrowingParser() -> JSTypedClosure<(String) throws(JSException) -> Int> +@JS func validateWith(_ validate: (String) throws(JSException) -> Bool) + +@JS func makeFetcher() -> JSTypedClosure<(String) async throws(JSException) -> String> + +@JS func makeAsyncEcho() -> JSTypedClosure<(String) async -> String> + +@JS func makeAnimalLoader() -> JSTypedClosure<(String) async -> Animal> + +@JS func makeResultLoader() -> JSTypedClosure<(Bool) async throws(JSException) -> APIResult> + @JS func roundtripDirection(_ callback: (Direction) -> Direction) -> (Direction) -> Direction @JS func roundtripTheme(_ callback: (Theme) -> Theme) -> (Theme) -> Theme @JS func roundtripHttpStatus(_ callback: (HttpStatus) -> HttpStatus) -> (HttpStatus) -> HttpStatus diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosureImports.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosureImports.swift index d9f92fffb..88be5420e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosureImports.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftClosureImports.swift @@ -1,3 +1,7 @@ @JSFunction func applyInt(_ value: Int, _ transform: (Int) -> Int) throws(JSException) -> Int @JSFunction func makeAdder(_ base: Int) throws(JSException) -> (Int) -> Int + +@JS func runValidator(_ cb: (String) throws(JSException) -> Bool) + +@JS func loadEach(_ fetch: (String) async throws(JSException) -> String) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json index ac18f6dc2..b1e306c07 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json @@ -1330,6 +1330,233 @@ } } }, + { + "abiName" : "bjs_makeThrowingParser", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeThrowingParser", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : true, + "mangleName" : "10TestModuleKSS_Si", + "moduleName" : "TestModule", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_validateWith", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "validateWith", + "parameters" : [ + { + "label" : "_", + "name" : "validate", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : true, + "mangleName" : "10TestModuleKSS_Sb", + "moduleName" : "TestModule", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "bool" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_makeFetcher", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeFetcher", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "10TestModuleYaKSS_SS", + "moduleName" : "TestModule", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_makeAsyncEcho", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAsyncEcho", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : false, + "mangleName" : "10TestModuleYaSS_SS", + "moduleName" : "TestModule", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_makeAnimalLoader", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAnimalLoader", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : false, + "mangleName" : "10TestModuleYaSS_6AnimalV", + "moduleName" : "TestModule", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Animal" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_makeResultLoader", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeResultLoader", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "10TestModuleYaKSb_9APIResultO", + "moduleName" : "TestModule", + "parameters" : [ + { + "bool" : { + + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "APIResult" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, { "abiName" : "bjs_roundtripDirection", "effects" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.swift index 4eb7c8da4..f8f2c76a0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.swift @@ -379,6 +379,172 @@ public func _invoke_swift_closure_TestModule_10TestModule9DirectionO_9DirectionO #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleKSS_Sb") +fileprivate func invoke_js_callback_TestModule_10TestModuleKSS_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleKSS_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuleKSS_Sb(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_TestModule_10TestModuleKSS_Sb_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleKSS_Sb") +fileprivate func make_swift_closure_TestModule_10TestModuleKSS_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleKSS_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuleKSS_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuleKSS_Sb_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModuleKSS_Sb { + static func bridgeJSLift(_ callbackId: Int32) -> (String) throws(JSException) -> Bool { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) throws(JSException) -> Bool in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + let ret = invoke_js_callback_TestModule_10TestModuleKSS_Sb(callbackValue, param0Bytes, param0Length) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) throws(JSException) -> Bool { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) throws(JSException) -> Bool) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleKSS_Sb, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleKSS_Sb") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleKSS_Sb") +public func _invoke_swift_closure_TestModule_10TestModuleKSS_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) throws(JSException) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure + do { + let result = try closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleKSS_Si") +fileprivate func invoke_js_callback_TestModule_10TestModuleKSS_Si_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleKSS_Si_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuleKSS_Si(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_TestModule_10TestModuleKSS_Si_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleKSS_Si") +fileprivate func make_swift_closure_TestModule_10TestModuleKSS_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleKSS_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuleKSS_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuleKSS_Si_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModuleKSS_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (String) throws(JSException) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) throws(JSException) -> Int in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + let ret = invoke_js_callback_TestModule_10TestModuleKSS_Si(callbackValue, param0Bytes, param0Length) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) throws(JSException) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) throws(JSException) -> Int) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleKSS_Si, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleKSS_Si") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleKSS_Si") +public func _invoke_swift_closure_TestModule_10TestModuleKSS_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) throws(JSException) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + do { + let result = try closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + #if arch(wasm32) @_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSS_SS") fileprivate func invoke_js_callback_TestModule_10TestModuleSS_SS_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 @@ -1392,6 +1558,534 @@ public func _invoke_swift_closure_TestModule_10TestModuleSqSi_SqSi(_ boxPtr: Uns #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleYaKSS_SS") +fileprivate func invoke_js_callback_TestModule_10TestModuleYaKSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleYaKSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuleYaKSS_SS(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_TestModule_10TestModuleYaKSS_SS_extern(resolveRef, rejectRef, callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleYaKSS_SS") +fileprivate func make_swift_closure_TestModule_10TestModuleYaKSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleYaKSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuleYaKSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuleYaKSS_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModuleYaKSS_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (String) async throws(JSException) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) async throws(JSException) -> String in + #if arch(wasm32) + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending String) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_TestModule_10TestModuleYaKSS_SS(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) + } + } + return resolved + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) async throws(JSException) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async throws(JSException) -> String) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleYaKSS_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleYaKSS_SS") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleYaKSS_SS") +public func _invoke_swift_closure_TestModule_10TestModuleYaKSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) async throws(JSException) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { () async throws(JSException) -> String in + return try await closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleYaKSb_9APIResultO") +fileprivate func invoke_js_callback_TestModule_10TestModuleYaKSb_9APIResultO_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleYaKSb_9APIResultO_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuleYaKSb_9APIResultO(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_TestModule_10TestModuleYaKSb_9APIResultO_extern(resolveRef, rejectRef, callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleYaKSb_9APIResultO") +fileprivate func make_swift_closure_TestModule_10TestModuleYaKSb_9APIResultO_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleYaKSb_9APIResultO_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuleYaKSb_9APIResultO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuleYaKSb_9APIResultO_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModuleYaKSb_9APIResultO { + static func bridgeJSLift(_ callbackId: Int32) -> (Bool) async throws(JSException) -> APIResult { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: Bool) async throws(JSException) -> APIResult in + #if arch(wasm32) + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending APIResult) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_TestModule_10TestModuleYaKSb_9APIResultO(resolveRef, rejectRef, callbackValue, param0Value) + } + return resolved + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Bool) async throws(JSException) -> APIResult { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Bool) async throws(JSException) -> APIResult) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleYaKSb_9APIResultO, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleYaKSb_9APIResultO") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleYaKSb_9APIResultO") +public func _invoke_swift_closure_TestModule_10TestModuleYaKSb_9APIResultO(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Bool) async throws(JSException) -> APIResult>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_9APIResultO, reject: Promise_reject) { () async throws(JSException) -> APIResult in + return try await closure(Bool.bridgeJSLiftParameter(param0)) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleYaSS_6AnimalV") +fileprivate func invoke_js_callback_TestModule_10TestModuleYaSS_6AnimalV_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleYaSS_6AnimalV_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuleYaSS_6AnimalV(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_TestModule_10TestModuleYaSS_6AnimalV_extern(resolveRef, rejectRef, callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleYaSS_6AnimalV") +fileprivate func make_swift_closure_TestModule_10TestModuleYaSS_6AnimalV_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleYaSS_6AnimalV_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuleYaSS_6AnimalV(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuleYaSS_6AnimalV_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModuleYaSS_6AnimalV { + static func bridgeJSLift(_ callbackId: Int32) -> (String) async -> Animal { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) async -> Animal in + #if arch(wasm32) + let resolved = try! await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending Animal) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_TestModule_10TestModuleYaSS_6AnimalV(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) + } + } + return resolved + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) async -> Animal { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async -> Animal) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleYaSS_6AnimalV, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleYaSS_6AnimalV") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleYaSS_6AnimalV") +public func _invoke_swift_closure_TestModule_10TestModuleYaSS_6AnimalV(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) async -> Animal>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_6AnimalV, reject: Promise_reject) { + return await closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleYaSS_SS") +fileprivate func invoke_js_callback_TestModule_10TestModuleYaSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleYaSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuleYaSS_SS(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_TestModule_10TestModuleYaSS_SS_extern(resolveRef, rejectRef, callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleYaSS_SS") +fileprivate func make_swift_closure_TestModule_10TestModuleYaSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleYaSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuleYaSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuleYaSS_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModuleYaSS_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (String) async -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) async -> String in + #if arch(wasm32) + let resolved = try! await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending String) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_TestModule_10TestModuleYaSS_SS(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) + } + } + return resolved + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) async -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async -> String) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleYaSS_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleYaSS_SS") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleYaSS_SS") +public func _invoke_swift_closure_TestModule_10TestModuleYaSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) async -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { + return await closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModules6AnimalV_y") +fileprivate func invoke_js_callback_TestModule_10TestModules6AnimalV_y_extern(_ callback: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModules6AnimalV_y_extern(_ callback: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModules6AnimalV_y(_ callback: Int32) -> Void { + return invoke_js_callback_TestModule_10TestModules6AnimalV_y_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModules6AnimalV_y") +fileprivate func make_swift_closure_TestModule_10TestModules6AnimalV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModules6AnimalV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModules6AnimalV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModules6AnimalV_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModules6AnimalV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending Animal) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_TestModule_10TestModules6AnimalV_y(callbackValue) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending Animal) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Animal) -> Void) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModules6AnimalV_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModules6AnimalV_y") +@_cdecl("invoke_swift_closure_TestModule_10TestModules6AnimalV_y") +public func _invoke_swift_closure_TestModule_10TestModules6AnimalV_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Animal) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(Animal.bridgeJSLiftParameter()) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModules7JSValueV_y") +fileprivate func invoke_js_callback_TestModule_10TestModules7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModules7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModules7JSValueV_y(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { + return invoke_js_callback_TestModule_10TestModules7JSValueV_y_extern(callback, param0Kind, param0Payload1, param0Payload2) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModules7JSValueV_y") +fileprivate func make_swift_closure_TestModule_10TestModules7JSValueV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModules7JSValueV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModules7JSValueV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModules7JSValueV_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModules7JSValueV_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_TestModule_10TestModules7JSValueV_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_TestModule_10TestModules7JSValueV_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModules7JSValueV_y") +@_cdecl("invoke_swift_closure_TestModule_10TestModules7JSValueV_y") +public func _invoke_swift_closure_TestModule_10TestModules7JSValueV_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_TestModule_10TestModules9APIResultO_y") +fileprivate func invoke_js_callback_TestModule_10TestModules9APIResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModules9APIResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModules9APIResultO_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_TestModule_10TestModules9APIResultO_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModules9APIResultO_y") +fileprivate func make_swift_closure_TestModule_10TestModules9APIResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModules9APIResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModules9APIResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModules9APIResultO_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModules9APIResultO_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending APIResult) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0CaseId = param0.bridgeJSLowerParameter() + invoke_js_callback_TestModule_10TestModules9APIResultO_y(callbackValue, param0CaseId) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending APIResult) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending APIResult) -> Void) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModules9APIResultO_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModules9APIResultO_y") +@_cdecl("invoke_swift_closure_TestModule_10TestModules9APIResultO_y") +public func _invoke_swift_closure_TestModule_10TestModules9APIResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending APIResult) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(APIResult.bridgeJSLiftParameter(param0)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModulesSS_y") +fileprivate func invoke_js_callback_TestModule_10TestModulesSS_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModulesSS_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModulesSS_y(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_TestModule_10TestModulesSS_y_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModulesSS_y") +fileprivate func make_swift_closure_TestModule_10TestModulesSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModulesSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModulesSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModulesSS_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModulesSS_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_TestModule_10TestModulesSS_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_TestModule_10TestModulesSS_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModulesSS_y") +@_cdecl("invoke_swift_closure_TestModule_10TestModulesSS_y") +public func _invoke_swift_closure_TestModule_10TestModulesSS_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 +} + extension Direction: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue @@ -1695,6 +2389,71 @@ public func _bjs_roundtripOptionalPerson(_ personClosure: Int32) -> Int32 { #endif } +@_expose(wasm, "bjs_makeThrowingParser") +@_cdecl("bjs_makeThrowingParser") +public func _bjs_makeThrowingParser() -> Int32 { + #if arch(wasm32) + let ret = makeThrowingParser() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_validateWith") +@_cdecl("bjs_validateWith") +public func _bjs_validateWith(_ validate: Int32) -> Void { + #if arch(wasm32) + validateWith(_: _BJS_Closure_10TestModuleKSS_Sb.bridgeJSLift(validate)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeFetcher") +@_cdecl("bjs_makeFetcher") +public func _bjs_makeFetcher() -> Int32 { + #if arch(wasm32) + let ret = makeFetcher() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAsyncEcho") +@_cdecl("bjs_makeAsyncEcho") +public func _bjs_makeAsyncEcho() -> Int32 { + #if arch(wasm32) + let ret = makeAsyncEcho() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAnimalLoader") +@_cdecl("bjs_makeAnimalLoader") +public func _bjs_makeAnimalLoader() -> Int32 { + #if arch(wasm32) + let ret = makeAnimalLoader() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeResultLoader") +@_cdecl("bjs_makeResultLoader") +public func _bjs_makeResultLoader() -> Int32 { + #if arch(wasm32) + let ret = makeResultLoader() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + @_expose(wasm, "bjs_roundtripDirection") @_cdecl("bjs_roundtripDirection") public func _bjs_roundtripDirection(_ callback: Int32) -> Int32 { @@ -1876,4 +2635,89 @@ fileprivate func _bjs_TestProcessor_wrap_extern(_ pointer: UnsafeMutableRawPoint #endif @inline(never) fileprivate func _bjs_TestProcessor_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { return _bjs_TestProcessor_wrap_extern(pointer) +} + +@JSFunction func Promise_reject(_ promise: JSObject, _ value: JSValue) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_reject_TestModule") +fileprivate func promise_reject_TestModule_extern(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void +#else +fileprivate func promise_reject_TestModule_extern(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_reject_TestModule(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void { + return promise_reject_TestModule_extern(promise, valueKind, valuePayload1, valuePayload2) +} + +func _$Promise_reject(_ promise: JSObject, _ value: JSValue) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let (valueKind, valuePayload1, valuePayload2) = value.bridgeJSLowerParameter() + promise_reject_TestModule(promiseValue, valueKind, valuePayload1, valuePayload2) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_SS(_ promise: JSObject, _ value: String) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_TestModule_SS") +fileprivate func promise_resolve_TestModule_SS_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void +#else +fileprivate func promise_resolve_TestModule_SS_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_TestModule_SS(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + return promise_resolve_TestModule_SS_extern(promise, valueBytes, valueLength) +} + +func _$Promise_resolve_SS(_ promise: JSObject, _ value: String) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + value.bridgeJSWithLoweredParameter { (valueBytes, valueLength) in + promise_resolve_TestModule_SS(promiseValue, valueBytes, valueLength) + } + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_6AnimalV(_ promise: JSObject, _ value: Animal) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_TestModule_6AnimalV") +fileprivate func promise_resolve_TestModule_6AnimalV_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_TestModule_6AnimalV_extern(_ promise: Int32, _ value: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_TestModule_6AnimalV(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_TestModule_6AnimalV_extern(promise, value) +} + +func _$Promise_resolve_6AnimalV(_ promise: JSObject, _ value: Animal) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueObjectId = value.bridgeJSLowerParameter() + promise_resolve_TestModule_6AnimalV(promiseValue, valueObjectId) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_9APIResultO(_ promise: JSObject, _ value: APIResult) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_TestModule_9APIResultO") +fileprivate func promise_resolve_TestModule_9APIResultO_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_TestModule_9APIResultO_extern(_ promise: Int32, _ value: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_TestModule_9APIResultO(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_TestModule_9APIResultO_extern(promise, value) +} + +func _$Promise_resolve_9APIResultO(_ promise: JSObject, _ value: APIResult) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueCaseId = value.bridgeJSLowerParameter() + promise_resolve_TestModule_9APIResultO(promiseValue, valueCaseId) + if let error = _swift_js_take_exception() { throw error } } \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.json index a84441bb4..d1cda5c7d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.json @@ -1,4 +1,109 @@ { + "exported" : { + "classes" : [ + + ], + "enums" : [ + + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_runValidator", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "runValidator", + "parameters" : [ + { + "label" : "_", + "name" : "cb", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : true, + "mangleName" : "10TestModuleKSS_Sb", + "moduleName" : "TestModule", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "bool" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_loadEach", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "loadEach", + "parameters" : [ + { + "label" : "_", + "name" : "fetch", + "type" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "10TestModuleYaKSS_SS", + "moduleName" : "TestModule", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "protocols" : [ + + ], + "structs" : [ + + ] + }, "imported" : { "children" : [ { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.swift index f87c8ecca..93c534c12 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.swift @@ -1,3 +1,86 @@ +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleKSS_Sb") +fileprivate func invoke_js_callback_TestModule_10TestModuleKSS_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleKSS_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuleKSS_Sb(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_TestModule_10TestModuleKSS_Sb_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleKSS_Sb") +fileprivate func make_swift_closure_TestModule_10TestModuleKSS_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleKSS_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuleKSS_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuleKSS_Sb_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModuleKSS_Sb { + static func bridgeJSLift(_ callbackId: Int32) -> (String) throws(JSException) -> Bool { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) throws(JSException) -> Bool in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + let ret = invoke_js_callback_TestModule_10TestModuleKSS_Sb(callbackValue, param0Bytes, param0Length) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) throws(JSException) -> Bool { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) throws(JSException) -> Bool) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleKSS_Sb, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleKSS_Sb") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleKSS_Sb") +public func _invoke_swift_closure_TestModule_10TestModuleKSS_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) throws(JSException) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure + do { + let result = try closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + #if arch(wasm32) @_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleSi_Si") fileprivate func invoke_js_callback_TestModule_10TestModuleSi_Si_extern(_ callback: Int32, _ param0: Int32) -> Int32 @@ -61,6 +144,263 @@ public func _invoke_swift_closure_TestModule_10TestModuleSi_Si(_ boxPtr: UnsafeM #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleYaKSS_SS") +fileprivate func invoke_js_callback_TestModule_10TestModuleYaKSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleYaKSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuleYaKSS_SS(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_TestModule_10TestModuleYaKSS_SS_extern(resolveRef, rejectRef, callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleYaKSS_SS") +fileprivate func make_swift_closure_TestModule_10TestModuleYaKSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleYaKSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuleYaKSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuleYaKSS_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModuleYaKSS_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (String) async throws(JSException) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) async throws(JSException) -> String in + #if arch(wasm32) + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending String) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_TestModule_10TestModuleYaKSS_SS(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) + } + } + return resolved + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) async throws(JSException) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async throws(JSException) -> String) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleYaKSS_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleYaKSS_SS") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleYaKSS_SS") +public func _invoke_swift_closure_TestModule_10TestModuleYaKSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) async throws(JSException) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { () async throws(JSException) -> String in + return try await closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModules7JSValueV_y") +fileprivate func invoke_js_callback_TestModule_10TestModules7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModules7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModules7JSValueV_y(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { + return invoke_js_callback_TestModule_10TestModules7JSValueV_y_extern(callback, param0Kind, param0Payload1, param0Payload2) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModules7JSValueV_y") +fileprivate func make_swift_closure_TestModule_10TestModules7JSValueV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModules7JSValueV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModules7JSValueV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModules7JSValueV_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModules7JSValueV_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_TestModule_10TestModules7JSValueV_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_TestModule_10TestModules7JSValueV_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModules7JSValueV_y") +@_cdecl("invoke_swift_closure_TestModule_10TestModules7JSValueV_y") +public func _invoke_swift_closure_TestModule_10TestModules7JSValueV_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_TestModule_10TestModulesSS_y") +fileprivate func invoke_js_callback_TestModule_10TestModulesSS_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_TestModule_10TestModulesSS_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModulesSS_y(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_TestModule_10TestModulesSS_y_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModulesSS_y") +fileprivate func make_swift_closure_TestModule_10TestModulesSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModulesSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModulesSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModulesSS_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModulesSS_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_TestModule_10TestModulesSS_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_TestModule_10TestModulesSS_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModulesSS_y") +@_cdecl("invoke_swift_closure_TestModule_10TestModulesSS_y") +public func _invoke_swift_closure_TestModule_10TestModulesSS_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 +} + +@_expose(wasm, "bjs_runValidator") +@_cdecl("bjs_runValidator") +public func _bjs_runValidator(_ cb: Int32) -> Void { + #if arch(wasm32) + runValidator(_: _BJS_Closure_10TestModuleKSS_Sb.bridgeJSLift(cb)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_loadEach") +@_cdecl("bjs_loadEach") +public func _bjs_loadEach(_ fetch: Int32) -> Void { + #if arch(wasm32) + loadEach(_: _BJS_Closure_10TestModuleYaKSS_SS.bridgeJSLift(fetch)) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@JSFunction func Promise_reject(_ promise: JSObject, _ value: JSValue) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_reject_TestModule") +fileprivate func promise_reject_TestModule_extern(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void +#else +fileprivate func promise_reject_TestModule_extern(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_reject_TestModule(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void { + return promise_reject_TestModule_extern(promise, valueKind, valuePayload1, valuePayload2) +} + +func _$Promise_reject(_ promise: JSObject, _ value: JSValue) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let (valueKind, valuePayload1, valuePayload2) = value.bridgeJSLowerParameter() + promise_reject_TestModule(promiseValue, valueKind, valuePayload1, valuePayload2) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_SS(_ promise: JSObject, _ value: String) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_TestModule_SS") +fileprivate func promise_resolve_TestModule_SS_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void +#else +fileprivate func promise_resolve_TestModule_SS_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_TestModule_SS(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + return promise_resolve_TestModule_SS_extern(promise, valueBytes, valueLength) +} + +func _$Promise_resolve_SS(_ promise: JSObject, _ value: String) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + value.bridgeJSWithLoweredParameter { (valueBytes, valueLength) in + promise_resolve_TestModule_SS(promiseValue, valueBytes, valueLength) + } + if let error = _swift_js_take_exception() { throw error } +} + #if arch(wasm32) @_extern(wasm, module: "TestModule", name: "bjs_applyInt") fileprivate func bjs_applyInt_extern(_ value: Int32, _ transform: Int32) -> Int32 diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts index d024be7dd..be62eeedd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts @@ -84,6 +84,12 @@ export type Exports = { roundtripOptionalDouble(doubleClosure: (arg0: number | null) => number | null): (arg0: number | null) => number | null; roundtripPerson(personClosure: (arg0: Person) => Person): (arg0: Person) => Person; roundtripOptionalPerson(personClosure: (arg0: Person | null) => Person | null): (arg0: Person | null) => Person | null; + makeThrowingParser(): (arg0: string) => number; + validateWith(validate: (arg0: string) => boolean): void; + makeFetcher(): (arg0: string) => Promise; + makeAsyncEcho(): (arg0: string) => Promise; + makeAnimalLoader(): (arg0: string) => Promise; + makeResultLoader(): (arg0: boolean) => Promise; roundtripDirection(callback: (arg0: DirectionTag) => DirectionTag): (arg0: DirectionTag) => DirectionTag; roundtripTheme(callback: (arg0: ThemeTag) => ThemeTag): (arg0: ThemeTag) => ThemeTag; roundtripHttpStatus(callback: (arg0: HttpStatusTag) => HttpStatusTag): (arg0: HttpStatusTag) => HttpStatusTag; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index cdd80e90a..4f0770092 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -61,6 +61,95 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + function __bjs_jsValueLower(value) { + let kind; + let payload1; + let payload2; + if (value === null) { + kind = 4; + payload1 = 0; + payload2 = 0; + } else { + switch (typeof value) { + case "boolean": + kind = 0; + payload1 = value ? 1 : 0; + payload2 = 0; + break; + case "number": + kind = 2; + payload1 = 0; + payload2 = value; + break; + case "string": + kind = 1; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "undefined": + kind = 5; + payload1 = 0; + payload2 = 0; + break; + case "object": + kind = 3; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "function": + kind = 3; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "symbol": + kind = 7; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "bigint": + kind = 8; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + default: + throw new TypeError("Unsupported JSValue type"); + } + } + return [kind, payload1, payload2]; + } + function __bjs_jsValueLift(kind, payload1, payload2) { + let jsValue; + switch (kind) { + case 0: + jsValue = payload1 !== 0; + break; + case 1: + jsValue = swift.memory.getObject(payload1); + break; + case 2: + jsValue = payload2; + break; + case 3: + jsValue = swift.memory.getObject(payload1); + break; + case 4: + jsValue = null; + break; + case 5: + jsValue = undefined; + break; + case 7: + jsValue = swift.memory.getObject(payload1); + break; + case 8: + jsValue = swift.memory.getObject(payload1); + break; + default: + throw new TypeError("Unsupported JSValue kind " + kind); + } + return jsValue; + } + const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.unregistered) { return; } instance?.exports?.bjs_release_swift_closure(state.pointer); @@ -248,6 +337,39 @@ export async function createInstantiator(options, swift) { promise[__bjs_promiseSettlers] = { resolve, reject }; return swift.memory.retain(promise); } + bjs["promise_resolve_TestModule_SS"] = function(promise, valueBytes, valueCount) { + try { + const string = decodeString(valueBytes, valueCount); + swift.memory.getObject(promise)[__bjs_promiseSettlers].resolve(string); + } catch (error) { + setException(error); + } + } + bjs["promise_resolve_TestModule_6AnimalV"] = function(promise, value) { + try { + const value1 = swift.memory.getObject(value); + swift.memory.release(value); + swift.memory.getObject(promise)[__bjs_promiseSettlers].resolve(value1); + } catch (error) { + setException(error); + } + } + bjs["promise_resolve_TestModule_9APIResultO"] = function(promise, value) { + try { + const enumValue = enumHelpers.APIResult.lift(value); + swift.memory.getObject(promise)[__bjs_promiseSettlers].resolve(enumValue); + } catch (error) { + setException(error); + } + } + bjs["promise_reject_TestModule"] = function(promise, valueKind, valuePayload1, valuePayload2) { + try { + const jsValue = __bjs_jsValueLift(valueKind, valuePayload1, valuePayload2); + swift.memory.getObject(promise)[__bjs_promiseSettlers].reject(jsValue); + } catch (error) { + setException(error); + } + } bjs["swift_js_return_optional_bool"] = function(isSome, value) { if (isSome === 0) { tmpRetOptionalBool = null; @@ -490,6 +612,58 @@ export async function createInstantiator(options, swift) { }; return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModule9DirectionO_9DirectionO); } + bjs["invoke_js_callback_TestModule_10TestModuleKSS_Sb"] = function(callbackId, param0Bytes, param0Count) { + try { + const callback = swift.memory.getObject(callbackId); + const string = decodeString(param0Bytes, param0Count); + let ret = callback(string); + return ret ? 1 : 0; + } catch (error) { + setException(error); + return 0 + } + } + bjs["make_swift_closure_TestModule_10TestModuleKSS_Sb"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleKSS_Sb = function(param0) { + const param0Bytes = textEncoder.encode(param0); + const param0Id = swift.memory.retain(param0Bytes); + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuleKSS_Sb(boxPtr, param0Id, param0Bytes.length); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + return ret !== 0; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleKSS_Sb); + } + bjs["invoke_js_callback_TestModule_10TestModuleKSS_Si"] = function(callbackId, param0Bytes, param0Count) { + try { + const callback = swift.memory.getObject(callbackId); + const string = decodeString(param0Bytes, param0Count); + let ret = callback(string); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + bjs["make_swift_closure_TestModule_10TestModuleKSS_Si"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleKSS_Si = function(param0) { + const param0Bytes = textEncoder.encode(param0); + const param0Id = swift.memory.retain(param0Bytes); + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuleKSS_Si(boxPtr, param0Id, param0Bytes.length); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + return ret; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleKSS_Si); + } bjs["invoke_js_callback_TestModule_10TestModuleSS_SS"] = function(callbackId, param0Bytes, param0Count) { try { const callback = swift.memory.getObject(callbackId); @@ -970,6 +1144,176 @@ export async function createInstantiator(options, swift) { }; return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSqSi_SqSi); } + bjs["invoke_js_callback_TestModule_10TestModuleYaKSS_SS"] = function(resolveRef, rejectRef, callbackId, param0Bytes, param0Count) { + const resolve = swift.memory.getObject(resolveRef); + const reject = swift.memory.getObject(rejectRef); + const callback = swift.memory.getObject(callbackId); + const string = decodeString(param0Bytes, param0Count); + callback(string).then(resolve, reject); + } + bjs["make_swift_closure_TestModule_10TestModuleYaKSS_SS"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleYaKSS_SS = function(param0) { + const param0Bytes = textEncoder.encode(param0); + const param0Id = swift.memory.retain(param0Bytes); + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuleYaKSS_SS(boxPtr, param0Id, param0Bytes.length); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + return ret1; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleYaKSS_SS); + } + bjs["invoke_js_callback_TestModule_10TestModuleYaKSb_9APIResultO"] = function(resolveRef, rejectRef, callbackId, param0) { + const resolve = swift.memory.getObject(resolveRef); + const reject = swift.memory.getObject(rejectRef); + const callback = swift.memory.getObject(callbackId); + callback(param0 !== 0).then(resolve, reject); + } + bjs["make_swift_closure_TestModule_10TestModuleYaKSb_9APIResultO"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleYaKSb_9APIResultO = function(param0) { + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuleYaKSb_9APIResultO(boxPtr, param0); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + return ret1; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleYaKSb_9APIResultO); + } + bjs["invoke_js_callback_TestModule_10TestModuleYaSS_6AnimalV"] = function(resolveRef, rejectRef, callbackId, param0Bytes, param0Count) { + const resolve = swift.memory.getObject(resolveRef); + const reject = swift.memory.getObject(rejectRef); + const callback = swift.memory.getObject(callbackId); + const string = decodeString(param0Bytes, param0Count); + callback(string).then(resolve, reject); + } + bjs["make_swift_closure_TestModule_10TestModuleYaSS_6AnimalV"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleYaSS_6AnimalV = function(param0) { + const param0Bytes = textEncoder.encode(param0); + const param0Id = swift.memory.retain(param0Bytes); + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuleYaSS_6AnimalV(boxPtr, param0Id, param0Bytes.length); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + return ret1; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleYaSS_6AnimalV); + } + bjs["invoke_js_callback_TestModule_10TestModuleYaSS_SS"] = function(resolveRef, rejectRef, callbackId, param0Bytes, param0Count) { + const resolve = swift.memory.getObject(resolveRef); + const reject = swift.memory.getObject(rejectRef); + const callback = swift.memory.getObject(callbackId); + const string = decodeString(param0Bytes, param0Count); + callback(string).then(resolve, reject); + } + bjs["make_swift_closure_TestModule_10TestModuleYaSS_SS"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleYaSS_SS = function(param0) { + const param0Bytes = textEncoder.encode(param0); + const param0Id = swift.memory.retain(param0Bytes); + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuleYaSS_SS(boxPtr, param0Id, param0Bytes.length); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + return ret1; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleYaSS_SS); + } + bjs["invoke_js_callback_TestModule_10TestModules6AnimalV_y"] = function(callbackId) { + try { + const callback = swift.memory.getObject(callbackId); + const structValue = structHelpers.Animal.lift(); + callback(structValue); + } catch (error) { + setException(error); + } + } + bjs["make_swift_closure_TestModule_10TestModules6AnimalV_y"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModules6AnimalV_y = function(param0) { + structHelpers.Animal.lower(param0); + instance.exports.invoke_swift_closure_TestModule_10TestModules6AnimalV_y(boxPtr); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModules6AnimalV_y); + } + bjs["invoke_js_callback_TestModule_10TestModules7JSValueV_y"] = function(callbackId, param0Kind, param0Payload1, param0Payload2) { + try { + const callback = swift.memory.getObject(callbackId); + const jsValue = __bjs_jsValueLift(param0Kind, param0Payload1, param0Payload2); + callback(jsValue); + } catch (error) { + setException(error); + } + } + bjs["make_swift_closure_TestModule_10TestModules7JSValueV_y"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModules7JSValueV_y = function(param0) { + const [param0Kind, param0Payload1, param0Payload2] = __bjs_jsValueLower(param0); + instance.exports.invoke_swift_closure_TestModule_10TestModules7JSValueV_y(boxPtr, param0Kind, param0Payload1, param0Payload2); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModules7JSValueV_y); + } + bjs["invoke_js_callback_TestModule_10TestModules9APIResultO_y"] = function(callbackId, param0) { + try { + const callback = swift.memory.getObject(callbackId); + const enumValue = enumHelpers.APIResult.lift(param0); + callback(enumValue); + } catch (error) { + setException(error); + } + } + bjs["make_swift_closure_TestModule_10TestModules9APIResultO_y"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModules9APIResultO_y = function(param0) { + const param0CaseId = enumHelpers.APIResult.lower(param0); + instance.exports.invoke_swift_closure_TestModule_10TestModules9APIResultO_y(boxPtr, param0CaseId); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModules9APIResultO_y); + } + bjs["invoke_js_callback_TestModule_10TestModulesSS_y"] = function(callbackId, param0Bytes, param0Count) { + try { + const callback = swift.memory.getObject(callbackId); + const string = decodeString(param0Bytes, param0Count); + callback(string); + } catch (error) { + setException(error); + } + } + bjs["make_swift_closure_TestModule_10TestModulesSS_y"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModulesSS_y = function(param0) { + const param0Bytes = textEncoder.encode(param0); + const param0Id = swift.memory.retain(param0Bytes); + instance.exports.invoke_swift_closure_TestModule_10TestModulesSS_y(boxPtr, param0Id, param0Bytes.length); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModulesSS_y); + } // Wrapper functions for module: TestModule if (!importObject["TestModule"]) { importObject["TestModule"] = {}; @@ -1149,6 +1493,30 @@ export async function createInstantiator(options, swift) { const ret = instance.exports.bjs_roundtripOptionalPerson(callbackId); return swift.memory.getObject(ret); }, + makeThrowingParser: function bjs_makeThrowingParser() { + const ret = instance.exports.bjs_makeThrowingParser(); + return swift.memory.getObject(ret); + }, + validateWith: function bjs_validateWith(validate) { + const callbackId = swift.memory.retain(validate); + instance.exports.bjs_validateWith(callbackId); + }, + makeFetcher: function bjs_makeFetcher() { + const ret = instance.exports.bjs_makeFetcher(); + return swift.memory.getObject(ret); + }, + makeAsyncEcho: function bjs_makeAsyncEcho() { + const ret = instance.exports.bjs_makeAsyncEcho(); + return swift.memory.getObject(ret); + }, + makeAnimalLoader: function bjs_makeAnimalLoader() { + const ret = instance.exports.bjs_makeAnimalLoader(); + return swift.memory.getObject(ret); + }, + makeResultLoader: function bjs_makeResultLoader() { + const ret = instance.exports.bjs_makeResultLoader(); + return swift.memory.getObject(ret); + }, roundtripDirection: function bjs_roundtripDirection(callback) { const callbackId = swift.memory.retain(callback); const ret = instance.exports.bjs_roundtripDirection(callbackId); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts index ebf493910..b66f960f8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.d.ts @@ -5,6 +5,8 @@ // `swift package bridge-js`. export type Exports = { + runValidator(cb: (arg0: string) => boolean): void; + loadEach(fetch: (arg0: string) => Promise): void; } export type Imports = { applyInt(value: number, transform: (arg0: number) => number): number; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js index 6fd627dcb..0cc8fd287 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js @@ -31,6 +31,95 @@ export async function createInstantiator(options, swift) { let _exports = null; let bjs = null; + function __bjs_jsValueLower(value) { + let kind; + let payload1; + let payload2; + if (value === null) { + kind = 4; + payload1 = 0; + payload2 = 0; + } else { + switch (typeof value) { + case "boolean": + kind = 0; + payload1 = value ? 1 : 0; + payload2 = 0; + break; + case "number": + kind = 2; + payload1 = 0; + payload2 = value; + break; + case "string": + kind = 1; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "undefined": + kind = 5; + payload1 = 0; + payload2 = 0; + break; + case "object": + kind = 3; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "function": + kind = 3; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "symbol": + kind = 7; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + case "bigint": + kind = 8; + payload1 = swift.memory.retain(value); + payload2 = 0; + break; + default: + throw new TypeError("Unsupported JSValue type"); + } + } + return [kind, payload1, payload2]; + } + function __bjs_jsValueLift(kind, payload1, payload2) { + let jsValue; + switch (kind) { + case 0: + jsValue = payload1 !== 0; + break; + case 1: + jsValue = swift.memory.getObject(payload1); + break; + case 2: + jsValue = payload2; + break; + case 3: + jsValue = swift.memory.getObject(payload1); + break; + case 4: + jsValue = null; + break; + case 5: + jsValue = undefined; + break; + case 7: + jsValue = swift.memory.getObject(payload1); + break; + case 8: + jsValue = swift.memory.getObject(payload1); + break; + default: + throw new TypeError("Unsupported JSValue kind " + kind); + } + return jsValue; + } + const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { if (state.unregistered) { return; } instance?.exports?.bjs_release_swift_closure(state.pointer); @@ -139,6 +228,22 @@ export async function createInstantiator(options, swift) { promise[__bjs_promiseSettlers] = { resolve, reject }; return swift.memory.retain(promise); } + bjs["promise_resolve_TestModule_SS"] = function(promise, valueBytes, valueCount) { + try { + const string = decodeString(valueBytes, valueCount); + swift.memory.getObject(promise)[__bjs_promiseSettlers].resolve(string); + } catch (error) { + setException(error); + } + } + bjs["promise_reject_TestModule"] = function(promise, valueKind, valuePayload1, valuePayload2) { + try { + const jsValue = __bjs_jsValueLift(valueKind, valuePayload1, valuePayload2); + swift.memory.getObject(promise)[__bjs_promiseSettlers].reject(jsValue); + } catch (error) { + setException(error); + } + } bjs["swift_js_return_optional_bool"] = function(isSome, value) { if (isSome === 0) { tmpRetOptionalBool = null; @@ -233,6 +338,32 @@ export async function createInstantiator(options, swift) { const func = swift.memory.getObject(funcRef); func.__unregister(); } + bjs["invoke_js_callback_TestModule_10TestModuleKSS_Sb"] = function(callbackId, param0Bytes, param0Count) { + try { + const callback = swift.memory.getObject(callbackId); + const string = decodeString(param0Bytes, param0Count); + let ret = callback(string); + return ret ? 1 : 0; + } catch (error) { + setException(error); + return 0 + } + } + bjs["make_swift_closure_TestModule_10TestModuleKSS_Sb"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleKSS_Sb = function(param0) { + const param0Bytes = textEncoder.encode(param0); + const param0Id = swift.memory.retain(param0Bytes); + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuleKSS_Sb(boxPtr, param0Id, param0Bytes.length); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + return ret !== 0; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleKSS_Sb); + } bjs["invoke_js_callback_TestModule_10TestModuleSi_Si"] = function(callbackId, param0) { try { const callback = swift.memory.getObject(callbackId); @@ -256,6 +387,75 @@ export async function createInstantiator(options, swift) { }; return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleSi_Si); } + bjs["invoke_js_callback_TestModule_10TestModuleYaKSS_SS"] = function(resolveRef, rejectRef, callbackId, param0Bytes, param0Count) { + const resolve = swift.memory.getObject(resolveRef); + const reject = swift.memory.getObject(rejectRef); + const callback = swift.memory.getObject(callbackId); + const string = decodeString(param0Bytes, param0Count); + callback(string).then(resolve, reject); + } + bjs["make_swift_closure_TestModule_10TestModuleYaKSS_SS"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleYaKSS_SS = function(param0) { + const param0Bytes = textEncoder.encode(param0); + const param0Id = swift.memory.retain(param0Bytes); + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuleYaKSS_SS(boxPtr, param0Id, param0Bytes.length); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + return ret1; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleYaKSS_SS); + } + bjs["invoke_js_callback_TestModule_10TestModules7JSValueV_y"] = function(callbackId, param0Kind, param0Payload1, param0Payload2) { + try { + const callback = swift.memory.getObject(callbackId); + const jsValue = __bjs_jsValueLift(param0Kind, param0Payload1, param0Payload2); + callback(jsValue); + } catch (error) { + setException(error); + } + } + bjs["make_swift_closure_TestModule_10TestModules7JSValueV_y"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModules7JSValueV_y = function(param0) { + const [param0Kind, param0Payload1, param0Payload2] = __bjs_jsValueLower(param0); + instance.exports.invoke_swift_closure_TestModule_10TestModules7JSValueV_y(boxPtr, param0Kind, param0Payload1, param0Payload2); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModules7JSValueV_y); + } + bjs["invoke_js_callback_TestModule_10TestModulesSS_y"] = function(callbackId, param0Bytes, param0Count) { + try { + const callback = swift.memory.getObject(callbackId); + const string = decodeString(param0Bytes, param0Count); + callback(string); + } catch (error) { + setException(error); + } + } + bjs["make_swift_closure_TestModule_10TestModulesSS_y"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModulesSS_y = function(param0) { + const param0Bytes = textEncoder.encode(param0); + const param0Id = swift.memory.retain(param0Bytes); + instance.exports.invoke_swift_closure_TestModule_10TestModulesSS_y(boxPtr, param0Id, param0Bytes.length); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModulesSS_y); + } const TestModule = importObject["TestModule"] = importObject["TestModule"] || {}; TestModule["bjs_applyInt"] = function bjs_applyInt(value, transform) { try { @@ -293,6 +493,14 @@ export async function createInstantiator(options, swift) { createExports: (instance) => { const js = swift.memory.heap; const exports = { + runValidator: function bjs_runValidator(cb) { + const callbackId = swift.memory.retain(cb); + instance.exports.bjs_runValidator(callbackId); + }, + loadEach: function bjs_loadEach(fetch) { + const callbackId = swift.memory.retain(fetch); + instance.exports.bjs_loadEach(callbackId); + }, }; _exports = exports; return exports; diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md index ce1d9d555..2d0c94152 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md @@ -38,6 +38,48 @@ let log = JSTypedClosure<(String) -> Void> { print($0) } defer { log.release() } ``` +## Throwing typed closures + +A ``JSTypedClosure`` signature can be `throws(JSException)`. Exceptions propagate across the boundary: a Swift closure that throws surfaces as a thrown JS error (caught with `try/catch` in JavaScript), and a throwing JS callback surfaces back into Swift as a `JSException`. + +```swift +import JavaScriptKit + +let parse = JSTypedClosure<(String) throws(JSException) -> Int> { text in + guard let value = Int(text) else { + throw JSException(JSError(message: "Not a number: \(text)").jsValue) + } + return value +} +defer { parse.release() } +``` + +Only `throws(JSException)` is supported. Plain `throws` is rejected at build time with a diagnostic, consistent with the rest of BridgeJS (see ). + +## Async typed closures + +A ``JSTypedClosure`` signature can be `async`. JavaScript receives a function that returns a `Promise`, so the TypeScript shape is `(args) => Promise`. Supported return types mirror `async` functions: `ConvertibleToJSValue` types, `@JS struct`, raw-value / case-only enums, `Void`, and their `Optional` / `Array` / `Dictionary` compositions. Unsupported async return types (associated-value enums, protocols, namespace enums) are diagnosed at build time. + +```swift +import JavaScriptKit + +let fetchCount = JSTypedClosure<(String) async -> Int> { endpoint in + try? await Task.sleep(nanoseconds: 10_000_000) + return endpoint.count +} +defer { fetchCount.release() } +``` + +```javascript +const count = await fetchCount("/items"); // Promise +``` + +> Important: Async closures require the JavaScript event loop executor, exactly like `async` functions. Call `JavaScriptEventLoop.installGlobalExecutor()` once during startup before invoking them. There is no special handling for closures. + +**Cancellation is a non-goal.** There is no propagation between a Swift `Task` and a JavaScript `Promise` in either direction. + +> Note: The reject path of async throwing typed closures is affected by a Swift compiler bug ([swiftlang/swift#89320](https://github.com/swiftlang/swift/issues/89320)). See for details. + ## Lifetime and release() A ``JSTypedClosure`` keeps the Swift closure alive and exposes a JavaScript function that calls into it. To avoid leaks and use-after-free: diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md index adb9ab33b..4dd08faa8 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md @@ -103,6 +103,144 @@ This differs from structs and arrays, which use copy semantics and transfer data When you **return** a closure to JavaScript, we recommend using ``JSTypedClosure`` and calling `release()` when the closure is no longer needed, instead of returning a plain closure type. See . +## Throwing closures + +Closures can throw JavaScript errors across the boundary using `throws(JSException)`, in both directions. Exceptions propagate just like they do for throwing functions (see ). + +A Swift closure handed to JavaScript that throws surfaces as a thrown JS error, so JavaScript catches it with `try/catch`: + +```swift +import JavaScriptKit + +@JS func makeParser() -> (String) throws(JSException) -> Int { + return { text in + guard let value = Int(text) else { + throw JSException(JSError(message: "Not a number: \(text)").jsValue) + } + return value + } +} +``` + +```javascript +const parse = exports.makeParser(); +try { + console.log(parse("42")); // 42 + parse("oops"); // throws +} catch (e) { + console.error("parse failed:", e); +} +``` + +A throwing JavaScript callback passed into Swift surfaces back into Swift as a `JSException`, which the Swift call site rethrows: + +```swift +import JavaScriptKit + +@JS func runValidator(_ input: String, validate: (String) throws(JSException) -> Bool) throws(JSException) -> Bool { + return try validate(input) +} +``` + +```javascript +exports.runValidator("ok", (value) => { + if (value.length === 0) { + throw new Error("empty input"); + } + return true; +}); +``` + +Notes: +- Only `throws(JSException)` is supported. Plain `throws` is rejected at build time with a diagnostic. +- Thrown values are surfaced to JS as normal JS exceptions, and JS exceptions thrown by callbacks are surfaced into Swift as a `JSException`. + +## Async closures + +Closures can be `async` in both directions, just like `async` functions (see ). An async closure is exposed to JavaScript as a function that returns a `Promise`, so its TypeScript shape is `(args) => Promise`. + +> Important: Async closures require the JavaScript event loop executor to be installed, exactly like `async` functions. Call `JavaScriptEventLoop.installGlobalExecutor()` once during startup before invoking async closures. + +### Direction A - Swift awaits a JavaScript async callback + +A Swift `@JS func` can take a JavaScript async callback typed as `(A) async throws(JSException) -> R`. Swift `await`s the `Promise` the callback returns. Both resolution and rejection work: a rejected `Promise` surfaces into Swift as a `JSException`. + +```swift +import JavaScriptKit + +@JS func loadAll(_ keys: [String], fetch: (String) async throws(JSException) -> String) async throws(JSException) -> [String] { + var results: [String] = [] + for key in keys { + results.append(try await fetch(key)) + } + return results +} +``` + +```javascript +const values = await exports.loadAll(["a", "b"], async (key) => { + const response = await fetch(`/items/${key}`); + if (!response.ok) throw new Error(`failed: ${key}`); // rejects → JSException in Swift + return response.text(); +}); +``` + +### Direction B - a Swift async closure handed to JavaScript + +A Swift async closure returned to JavaScript (as a plain async closure type or a ``JSTypedClosure``) becomes a function JavaScript `await`s. Supported return types mirror async functions: `ConvertibleToJSValue` types, `@JS struct`, raw-value / case-only enums, `Void`, and their `Optional` / `Array` / `Dictionary` compositions. Unsupported async return types (associated-value enums, protocols, namespace enums) are diagnosed at build time. + +```swift +import JavaScriptKit + +@JS struct Point { + let x: Double + let y: Double +} + +// Async closure returning a @JS struct +@JS func makePointLoader() -> JSTypedClosure<(Double, Double) async -> Point> { + let loader = JSTypedClosure<(Double, Double) async -> Point> { x, y in + try? await Task.sleep(nanoseconds: 10_000_000) + return Point(x: x, y: y) + } + return loader +} + +// Async closure returning Void +@JS func makeLogger() -> JSTypedClosure<(String) async -> Void> { + return JSTypedClosure<(String) async -> Void> { message in + try? await Task.sleep(nanoseconds: 10_000_000) + print(message) + } +} +``` + +```javascript +const loadPoint = exports.makePointLoader(); +const point = await loadPoint(1, 2); // Promise +console.log(point.x, point.y); // 1 2 +loadPoint.release(); + +const log = exports.makeLogger(); +await log("hello"); // Promise +log.release(); +``` + +The generated TypeScript declarations: + +```typescript +export type Exports = { + makePointLoader(): (arg0: number, arg1: number) => Promise; + makeLogger(): (arg0: string) => Promise; +} +``` + +Notes: +- The same `JavaScriptEventLoop.installGlobalExecutor()` requirement applies as for async functions; there is no special handling for closures. +- **Cancellation is a non-goal.** There is no propagation between a Swift `Task` and a JavaScript `Promise` in either direction; cancelling one side does not cancel the other. + +> Warning: When an async throwing closure handed to JavaScript throws, the error is currently lost instead of rejecting the `Promise` with it, due to a Swift compiler bug on `wasm32` ([swiftlang/swift#89320](https://github.com/swiftlang/swift/issues/89320), fix in progress in [swiftlang/swift#89715](https://github.com/swiftlang/swift/pull/89715)). Closures that capture state are unaffected, as are throwing JavaScript callbacks passed into Swift. + ## Supported Features | Swift Feature | Status | @@ -112,8 +250,9 @@ When you **return** a closure to JavaScript, we recommend using ``JSTypedClosure | `@escaping` closures | ✅ | | Optional types in closures | ✅ | | Closure-typed `@JS` properties | ❌ | -| Async closures | ❌ | -| Throwing closures | ❌ | +| Async closures `(A) async -> B` | ✅ | +| Async throwing closures `(A) async throws(JSException) -> B` | ✅ (reject path of closures handed to JS pending [swiftlang/swift#89320](https://github.com/swiftlang/swift/issues/89320)) | +| Throwing closures `(A) throws(JSException) -> B` | ✅ | ## See Also diff --git a/Tests/BridgeJSRuntimeTests/ClosureAsyncAPIs.swift b/Tests/BridgeJSRuntimeTests/ClosureAsyncAPIs.swift new file mode 100644 index 000000000..678981ede --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/ClosureAsyncAPIs.swift @@ -0,0 +1,89 @@ +import XCTest +import JavaScriptKit +import JavaScriptEventLoop + +// MARK: - Direction A: Swift awaits a JS async callback + +@JS func awaitAsyncCallback(_ fetch: (String) async throws(JSException) -> String) async throws(JSException) -> String { + let resolved = try await fetch("request") + return "swift-saw:\(resolved)" +} + +// MARK: - Direction B: a Swift async closure handed to JS + +@JS func makeAsyncParser() -> JSTypedClosure<(String) async throws(JSException) -> String> { + return JSTypedClosure { (text: String) async throws(JSException) -> String in + await Task.yield() + guard let value = Int(text) else { + throw JSException(JSError(message: "AsyncParseError: \(text)").jsValue) + } + return "parsed:\(value)" + } +} + +@JS func makeAsyncEcho() -> JSTypedClosure<(String) async -> String> { + return JSTypedClosure { (text: String) async -> String in + await Task.yield() + return "echo:\(text)" + } +} + +@JS func makeAsyncRecorder() -> JSTypedClosure<(String) async throws(JSException) -> Void> { + return JSTypedClosure { (text: String) async throws(JSException) -> Void in + await Task.yield() + if text == "boom" { + throw JSException(JSError(message: "AsyncRecorderError").jsValue) + } + AsyncRecorderState.lastRecorded = text + } +} + +@JS func lastRecordedValue() -> String { + return AsyncRecorderState.lastRecorded +} + +@JS func makeAsyncPayloadLoader() -> JSTypedClosure<(Bool) async throws(JSException) -> AsyncPayloadResult> { + return JSTypedClosure { (succeed: Bool) async throws(JSException) -> AsyncPayloadResult in + await Task.yield() + return succeed ? .success("loaded") : .failure(42) + } +} + +@JS func awaitPayloadCallback( + _ load: (Bool) async throws(JSException) -> AsyncPayloadResult +) async throws(JSException) -> String { + let first = try await load(true) + let second = try await load(false) + return "\(payloadSummary(first))|\(payloadSummary(second))" +} + +private func payloadSummary(_ result: AsyncPayloadResult) -> String { + switch result { + case .success(let value): return "success:\(value)" + case .failure(let code): return "failure:\(code)" + case .idle: return "idle" + } +} + +@JS func makeAsyncPointMaker() -> JSTypedClosure<(Double) async -> DataPoint> { + return JSTypedClosure { (seed: Double) async -> DataPoint in + await Task.yield() + return DataPoint(x: seed, y: seed * 2, label: "async:\(seed)", optCount: nil, optFlag: nil) + } +} + +enum AsyncRecorderState { + nonisolated(unsafe) static var lastRecorded: String = "" +} + +// MARK: - XCTest entry point + +final class ClosureAsyncTests: XCTestCase { + func testRunJsClosureAsyncTests() async throws { + try await ClosureAsyncImports.runJsClosureAsyncTests() + } +} + +@JSClass struct ClosureAsyncImports { + @JSFunction static func runJsClosureAsyncTests() async throws(JSException) +} diff --git a/Tests/BridgeJSRuntimeTests/ClosureThrowsAPIs.swift b/Tests/BridgeJSRuntimeTests/ClosureThrowsAPIs.swift new file mode 100644 index 000000000..472d57ad6 --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/ClosureThrowsAPIs.swift @@ -0,0 +1,31 @@ +import XCTest +import JavaScriptKit + +// MARK: - Direction B: Swift closure (throws) called from JS + +@JS func makeThrowingParser() -> JSTypedClosure<(String) throws(JSException) -> Int> { + return JSTypedClosure { (text: String) throws(JSException) -> Int in + guard let value = Int(text) else { + throw JSException(JSError(message: "ParseError: \(text)").jsValue) + } + return value + } +} + +// MARK: - Direction A: JS callback (throws) called from Swift + +@JS func runValidator(_ validate: (String) throws(JSException) -> Bool) throws(JSException) -> Bool { + return try validate("input") +} + +// MARK: - XCTest entry point + +final class ClosureThrowsTests: XCTestCase { + func testRunJsClosureThrowsTests() throws { + try ClosureThrowsImports.runJsClosureThrowsTests() + } +} + +@JSClass struct ClosureThrowsImports { + @JSFunction static func runJsClosureThrowsTests() throws(JSException) +} diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift index c02cb72f7..b2afb6d5b 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift @@ -644,6 +644,172 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9Di #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsKSS_Sb { + static func bridgeJSLift(_ callbackId: Int32) -> (String) throws(JSException) -> Bool { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) throws(JSException) -> Bool in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(callbackValue, param0Bytes, param0Length) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) throws(JSException) -> Bool { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) throws(JSException) -> Bool) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) throws(JSException) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure + do { + let result = try closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsKSS_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (String) throws(JSException) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) throws(JSException) -> Int in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(callbackValue, param0Bytes, param0Length) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) throws(JSException) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) throws(JSException) -> Int) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) throws(JSException) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + do { + let result = try closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #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 @@ -1688,26 +1854,370 @@ fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsS @_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 { +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_20BridgeJSRuntimeTestsYaKSS_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(resolveRef, rejectRef, callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsYaKSS_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (String) async throws(JSException) -> String { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) async throws(JSException) -> String in + #if arch(wasm32) + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending String) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) + } + } + return resolved + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) async throws(JSException) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async throws(JSException) -> String) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) async throws(JSException) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { () async throws(JSException) -> String in + return try await closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(resolveRef, rejectRef, callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsYaKSS_y { + static func bridgeJSLift(_ callbackId: Int32) -> (String) async throws(JSException) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) async throws(JSException) -> Void in + #if arch(wasm32) + try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<() -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) + } + } + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) async throws(JSException) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async throws(JSException) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) async throws(JSException) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_y, reject: Promise_reject) { () async throws(JSException) in + try await closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(resolveRef, rejectRef, callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO { + static func bridgeJSLift(_ callbackId: Int32) -> (Bool) async throws(JSException) -> AsyncPayloadResult { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: Bool) async throws(JSException) -> AsyncPayloadResult in + #if arch(wasm32) + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending AsyncPayloadResult) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(resolveRef, rejectRef, callbackValue, param0Value) + } + return resolved + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Bool) async throws(JSException) -> AsyncPayloadResult { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Bool) async throws(JSException) -> AsyncPayloadResult) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Bool) async throws(JSException) -> AsyncPayloadResult>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_18AsyncPayloadResultO, reject: Promise_reject) { () async throws(JSException) -> AsyncPayloadResult in + return try await closure(Bool.bridgeJSLiftParameter(param0)) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(resolveRef, rejectRef, callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_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) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestsSqSS_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { +private enum _BJS_Closure_20BridgeJSRuntimeTestsYaSS_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (String) async -> String { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in + return { [callback] (param0: String) async -> String 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 resolved = try! await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending String) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) + } } - let ret = ret0 - return String.bridgeJSLiftReturn(ret) + return resolved #else fatalError("Only available on WebAssembly") #endif @@ -1715,10 +2225,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsSqSS_SS { } } -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { +extension JSTypedClosure where Signature == (String) async -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async -> String) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSS_SS, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS, body: body, fileID: fileID, line: line @@ -1726,51 +2236,58 @@ extension JSTypedClosure where Signature == (Optional) -> String { } } -@_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 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length)) - return result.bridgeJSLowerReturn() + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) async -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { + return await closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + } #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 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Float64) -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Int32) -> Int32 { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Float64) -> Void { 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) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Float64) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(resolveRef, rejectRef, callback, param0) } #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 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_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 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_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) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestsSqSi_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (Optional) -> String { +private enum _BJS_Closure_20BridgeJSRuntimeTestsYaSd_9DataPointV { + static func bridgeJSLift(_ callbackId: Int32) -> (Double) async -> DataPoint { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in + return { [callback] (param0: Double) async -> DataPoint 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) + let resolved = try! await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending DataPoint) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV(resolveRef, rejectRef, callbackValue, param0Value) + } + return resolved #else fatalError("Only available on WebAssembly") #endif @@ -1778,10 +2295,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsSqSi_SS { } } -extension JSTypedClosure where Signature == (Optional) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Optional) -> String) { +extension JSTypedClosure where Signature == (Double) async -> DataPoint { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Double) async -> DataPoint) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqSi_SS, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV, body: body, fileID: fileID, line: line @@ -1789,13 +2306,14 @@ extension JSTypedClosure where Signature == (Optional) -> String { } } -@_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 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV(_ boxPtr: UnsafeMutableRawPointer, _ param0: Float64) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(Optional) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) - return result.bridgeJSLowerReturn() + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Double) async -> DataPoint>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_9DataPointV, reject: Promise_reject) { + return await closure(Double.bridgeJSLiftParameter(param0)) + } #else fatalError("Only available on WebAssembly") #endif @@ -1924,6 +2442,67 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11 #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending AsyncPayloadResult) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0CaseId = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(callbackValue, param0CaseId) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending AsyncPayloadResult) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending AsyncPayloadResult) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending AsyncPayloadResult) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(AsyncPayloadResult.bridgeJSLiftParameter(param0)) + #else + fatalError("Only available on WebAssembly") + #endif +} + #if arch(wasm32) @_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void @@ -2046,6 +2625,67 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7J #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(_ callback: Int32) -> Void +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(_ callback: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y(_ callback: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestss9DataPointV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending DataPoint) -> Void { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y(callbackValue) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (sending DataPoint) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending DataPoint) -> Void) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending DataPoint) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(DataPoint.bridgeJSLiftParameter()) + #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 @@ -6974,6 +7614,132 @@ public func _bjs_ArrayMembers_firstString() -> Void { #endif } +@_expose(wasm, "bjs_awaitAsyncCallback") +@_cdecl("bjs_awaitAsyncCallback") +public func _bjs_awaitAsyncCallback(_ fetch: Int32) -> Int32 { + #if arch(wasm32) + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { () async throws(JSException) -> String in + return try await awaitAsyncCallback(_: _BJS_Closure_20BridgeJSRuntimeTestsYaKSS_SS.bridgeJSLift(fetch)) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAsyncParser") +@_cdecl("bjs_makeAsyncParser") +public func _bjs_makeAsyncParser() -> Int32 { + #if arch(wasm32) + let ret = makeAsyncParser() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAsyncEcho") +@_cdecl("bjs_makeAsyncEcho") +public func _bjs_makeAsyncEcho() -> Int32 { + #if arch(wasm32) + let ret = makeAsyncEcho() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAsyncRecorder") +@_cdecl("bjs_makeAsyncRecorder") +public func _bjs_makeAsyncRecorder() -> Int32 { + #if arch(wasm32) + let ret = makeAsyncRecorder() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_lastRecordedValue") +@_cdecl("bjs_lastRecordedValue") +public func _bjs_lastRecordedValue() -> Void { + #if arch(wasm32) + let ret = lastRecordedValue() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAsyncPayloadLoader") +@_cdecl("bjs_makeAsyncPayloadLoader") +public func _bjs_makeAsyncPayloadLoader() -> Int32 { + #if arch(wasm32) + let ret = makeAsyncPayloadLoader() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_awaitPayloadCallback") +@_cdecl("bjs_awaitPayloadCallback") +public func _bjs_awaitPayloadCallback(_ load: Int32) -> Int32 { + #if arch(wasm32) + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { () async throws(JSException) -> String in + return try await awaitPayloadCallback(_: _BJS_Closure_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO.bridgeJSLift(load)) + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAsyncPointMaker") +@_cdecl("bjs_makeAsyncPointMaker") +public func _bjs_makeAsyncPointMaker() -> Int32 { + #if arch(wasm32) + let ret = makeAsyncPointMaker() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeThrowingParser") +@_cdecl("bjs_makeThrowingParser") +public func _bjs_makeThrowingParser() -> Int32 { + #if arch(wasm32) + let ret = makeThrowingParser() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_runValidator") +@_cdecl("bjs_runValidator") +public func _bjs_runValidator(_ validate: Int32) -> Int32 { + #if arch(wasm32) + do { + let ret = try runValidator(_: _BJS_Closure_20BridgeJSRuntimeTestsKSS_Sb.bridgeJSLift(validate)) + 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: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + @_expose(wasm, "bjs_roundTripVoid") @_cdecl("bjs_roundTripVoid") public func _bjs_roundTripVoid() -> Void { @@ -12176,6 +12942,27 @@ func _$Promise_resolve_SD11PublicPointV(_ promise: JSObject, _ value: [String: P if let error = _swift_js_take_exception() { throw error } } +@JSFunction func Promise_resolve_9DataPointV(_ promise: JSObject, _ value: DataPoint) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_9DataPointV") +fileprivate func promise_resolve_BridgeJSRuntimeTests_9DataPointV_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_9DataPointV_extern(_ promise: Int32, _ value: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_9DataPointV(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_9DataPointV_extern(promise, value) +} + +func _$Promise_resolve_9DataPointV(_ promise: JSObject, _ value: DataPoint) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueObjectId = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_9DataPointV(promiseValue, valueObjectId) + if let error = _swift_js_take_exception() { throw error } +} + #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayElementObject_init") fileprivate func bjs_ArrayElementObject_init_extern(_ idBytes: Int32, _ idLength: Int32) -> Int32 @@ -12864,6 +13651,28 @@ func _$AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum(_ v: Optio return resolved } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureAsyncImports_runJsClosureAsyncTests_static") +fileprivate func bjs_ClosureAsyncImports_runJsClosureAsyncTests_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void +#else +fileprivate func bjs_ClosureAsyncImports_runJsClosureAsyncTests_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureAsyncImports_runJsClosureAsyncTests_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + return bjs_ClosureAsyncImports_runJsClosureAsyncTests_static_extern(resolveRef, rejectRef) +} + +func _$ClosureAsyncImports_runJsClosureAsyncTests() async throws(JSException) -> Void { + try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<() -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + bjs_ClosureAsyncImports_runJsClosureAsyncTests_static(resolveRef, rejectRef) + } +} + #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyVoid_static") fileprivate func bjs_ClosureSupportImports_jsApplyVoid_static_extern(_ callback: Int32) -> Void @@ -13246,6 +14055,25 @@ func _$ClosureSupportImports_runJsClosureSupportTests() throws(JSException) -> V } } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureThrowsImports_runJsClosureThrowsTests_static") +fileprivate func bjs_ClosureThrowsImports_runJsClosureThrowsTests_static_extern() -> Void +#else +fileprivate func bjs_ClosureThrowsImports_runJsClosureThrowsTests_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureThrowsImports_runJsClosureThrowsTests_static() -> Void { + return bjs_ClosureThrowsImports_runJsClosureThrowsTests_static_extern() +} + +func _$ClosureThrowsImports_runJsClosureThrowsTests() throws(JSException) -> Void { + bjs_ClosureThrowsImports_runJsClosureThrowsTests_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 diff --git a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json index a51e6bafd..297ab5a07 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json @@ -11604,6 +11604,374 @@ ], "exposeToGlobal" : false, "functions" : [ + { + "abiName" : "bjs_awaitAsyncCallback", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "awaitAsyncCallback", + "parameters" : [ + { + "label" : "_", + "name" : "fetch", + "type" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsYaKSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_makeAsyncParser", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAsyncParser", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsYaKSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_makeAsyncEcho", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAsyncEcho", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsYaSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_makeAsyncRecorder", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAsyncRecorder", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsYaKSS_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_lastRecordedValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "lastRecordedValue", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_makeAsyncPayloadLoader", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAsyncPayloadLoader", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "bool" : { + + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_awaitPayloadCallback", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "awaitPayloadCallback", + "parameters" : [ + { + "label" : "_", + "name" : "load", + "type" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "bool" : { + + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_makeAsyncPointMaker", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAsyncPointMaker", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsYaSd_9DataPointV", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "double" : { + + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_makeThrowingParser", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeThrowingParser", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsKSS_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_runValidator", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runValidator", + "parameters" : [ + { + "label" : "_", + "name" : "validate", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsKSS_Sb", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "bool" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, { "abiName" : "bjs_roundTripVoid", "effects" : { @@ -18709,6 +19077,45 @@ { "functions" : [ + ], + "types" : [ + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "ClosureAsyncImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsClosureAsyncTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + }, + { + "functions" : [ + ], "types" : [ { @@ -19527,6 +19934,45 @@ { "functions" : [ + ], + "types" : [ + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "ClosureThrowsImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsClosureThrowsTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + }, + { + "functions" : [ + ], "types" : [ { diff --git a/Tests/BridgeJSRuntimeTests/JavaScript/ClosureAsyncTests.mjs b/Tests/BridgeJSRuntimeTests/JavaScript/ClosureAsyncTests.mjs new file mode 100644 index 000000000..d7f249ec4 --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/JavaScript/ClosureAsyncTests.mjs @@ -0,0 +1,137 @@ +import assert from "node:assert"; +import { AsyncPayloadResultValues } from '../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.js'; + +/** + * @returns {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Imports["ClosureAsyncImports"]} + */ +export function getImports(importsContext) { + return { + runJsClosureAsyncTests: async () => { + const exports = importsContext.getExports(); + if (!exports) { + throw new Error("No exports!?"); + } + await runJsClosureAsyncTests(exports); + }, + }; +} + +/** @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ +export async function runJsClosureAsyncTests(exports) { + assert.equal( + await exports.awaitAsyncCallback(async (req) => { + await Promise.resolve(); + return `js-${req}`; + }), + "swift-saw:js-request", + ); + + let directionAReject = null; + try { + await exports.awaitAsyncCallback(async () => { + throw new Error("CallbackRejected"); + }); + assert.fail("Expected awaitAsyncCallback to reject when the JS callback rejects"); + } catch (error) { + directionAReject = error; + } + assert.notEqual(directionAReject, null); + assert.equal(directionAReject.message, "CallbackRejected"); + + const parser = exports.makeAsyncParser(); + + const parsed = parser("42"); + assert.ok(parsed instanceof Promise, "async closure must return a Promise"); + assert.equal(await parsed, "parsed:42"); + assert.equal(await parser("-7"), "parsed:-7"); + + // Blocked by swiftlang/swift#89320 (wasm32 typed-throws async miscompile for captureless closures); re-enable once swiftlang/swift#89715 lands. + const ASYNC_THROWS_CLOSURE_REJECT_BLOCKED = true; + if (!ASYNC_THROWS_CLOSURE_REJECT_BLOCKED) { + let directionBReject = null; + try { + await parser("not-a-number"); + assert.fail("Expected makeAsyncParser closure to reject for invalid input"); + } catch (error) { + directionBReject = error; + } + assert.notEqual(directionBReject, null); + assert.equal(directionBReject.message, "AsyncParseError: not-a-number"); + } + + assert.equal(await parser("100"), "parsed:100"); + + const echo = exports.makeAsyncEcho(); + const echoed = echo("hi"); + assert.ok(echoed instanceof Promise, "non-throwing async closure must return a Promise"); + assert.equal(await echoed, "echo:hi"); + + const recorder = exports.makeAsyncRecorder(); + const recorded = recorder("logged-value"); + assert.ok(recorded instanceof Promise, "Void async closure must return a Promise"); + assert.equal(await recorded, undefined); + assert.equal(exports.lastRecordedValue(), "logged-value"); + + if (!ASYNC_THROWS_CLOSURE_REJECT_BLOCKED) { + let voidReject = null; + try { + await recorder("boom"); + assert.fail("Expected makeAsyncRecorder closure to reject for 'boom'"); + } catch (error) { + voidReject = error; + } + assert.notEqual(voidReject, null); + assert.equal(voidReject.message, "AsyncRecorderError"); + } + + const payloadLoader = exports.makeAsyncPayloadLoader(); + const payloadPromise = payloadLoader(true); + assert.ok(payloadPromise instanceof Promise, "associated-value enum async closure must return a Promise"); + assert.deepEqual(await payloadPromise, { tag: AsyncPayloadResultValues.Tag.Success, param0: "loaded" }); + assert.deepEqual(await payloadLoader(false), { tag: AsyncPayloadResultValues.Tag.Failure, param0: 42 }); + + assert.equal( + await exports.awaitPayloadCallback(async (succeed) => { + await Promise.resolve(); + return succeed + ? { tag: AsyncPayloadResultValues.Tag.Success, param0: "js" } + : { tag: AsyncPayloadResultValues.Tag.Idle }; + }), + "success:js|idle", + ); + + const pointMaker = exports.makeAsyncPointMaker(); + const pointPromise = pointMaker(3); + assert.ok(pointPromise instanceof Promise, "struct-returning async closure must return a Promise"); + const point = await pointPromise; + assert.equal(point.x, 3); + assert.equal(point.y, 6); + assert.equal(point.label, "async:3.0"); + + { + const racer = exports.makeAsyncEcho(); + const inFlight = racer("race"); + if (typeof racer.release === "function") { + racer.release(); + } + if (typeof global !== "undefined" && typeof global.gc === "function") { + global.gc(); + } + assert.equal(await inFlight, "echo:race"); + } + + { + const concurrent = exports.makeAsyncEcho(); + const promises = []; + for (let i = 0; i < 16; i++) { + promises.push(concurrent("c" + i)); + } + const results = await Promise.all(promises); + for (let i = 0; i < 16; i++) { + assert.equal(results[i], "echo:c" + i); + } + if (typeof concurrent.release === "function") { + concurrent.release(); + } + } +} diff --git a/Tests/BridgeJSRuntimeTests/JavaScript/ClosureThrowsTests.mjs b/Tests/BridgeJSRuntimeTests/JavaScript/ClosureThrowsTests.mjs new file mode 100644 index 000000000..94bd27d5c --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/JavaScript/ClosureThrowsTests.mjs @@ -0,0 +1,57 @@ +import assert from "node:assert"; + +/** + * @returns {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Imports["ClosureThrowsImports"]} + */ +export function getImports(importsContext) { + return { + runJsClosureThrowsTests: () => { + const exports = importsContext.getExports(); + if (!exports) { + throw new Error("No exports!?"); + } + runJsClosureThrowsTests(exports); + }, + }; +} + +/** @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ +export function runJsClosureThrowsTests(exports) { + const parser = exports.makeThrowingParser(); + + assert.equal(parser("42"), 42); + assert.equal(parser("-7"), -7); + + let caught = null; + try { + parser("not-a-number"); + assert.fail("Expected makeThrowingParser closure to throw for invalid input"); + } catch (error) { + caught = error; + } + assert.notEqual(caught, null); + assert.equal(caught.message, "ParseError: not-a-number"); + + assert.equal(parser("100"), 100); + + assert.equal( + exports.runValidator((value) => value === "input"), + true, + ); + assert.equal( + exports.runValidator((value) => value === "something-else"), + false, + ); + + let propagated = null; + try { + exports.runValidator(() => { + throw new Error("ValidatorError"); + }); + assert.fail("Expected runValidator to propagate the JS callback error"); + } catch (error) { + propagated = error; + } + assert.notEqual(propagated, null); + assert.equal(propagated.message, "ValidatorError"); +} diff --git a/Tests/prelude.mjs b/Tests/prelude.mjs index bf3073c62..658bceed9 100644 --- a/Tests/prelude.mjs +++ b/Tests/prelude.mjs @@ -6,6 +6,8 @@ import { import { ImportedFoo } from './BridgeJSRuntimeTests/JavaScript/Types.mjs'; import { runJsOptionalSupportTests } from './BridgeJSRuntimeTests/JavaScript/OptionalSupportTests.mjs'; import { getImports as getClosureSupportImports } from './BridgeJSRuntimeTests/JavaScript/ClosureSupportTests.mjs'; +import { getImports as getClosureThrowsImports } from './BridgeJSRuntimeTests/JavaScript/ClosureThrowsTests.mjs'; +import { getImports as getClosureAsyncImports } from './BridgeJSRuntimeTests/JavaScript/ClosureAsyncTests.mjs'; import { getImports as getSwiftClassSupportImports } from './BridgeJSRuntimeTests/JavaScript/SwiftClassSupportTests.mjs'; import { getImports as getOptionalSupportImports } from './BridgeJSRuntimeTests/JavaScript/OptionalSupportTests.mjs'; import { getImports as getArraySupportImports, ArrayElementObject } from './BridgeJSRuntimeTests/JavaScript/ArraySupportTests.mjs'; @@ -160,6 +162,8 @@ export async function setupOptions(options, context) { runJsOptionalSupportTests(exports); }, ClosureSupportImports: getClosureSupportImports(importsContext), + ClosureThrowsImports: getClosureThrowsImports(importsContext), + ClosureAsyncImports: getClosureAsyncImports(importsContext), SwiftClassSupportImports: getSwiftClassSupportImports(importsContext), OptionalSupportImports: getOptionalSupportImports(importsContext), ArraySupportImports: getArraySupportImports(importsContext), From c02073465631e595fecff9872db7450707b37b49 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Thu, 11 Jun 2026 11:42:34 +0200 Subject: [PATCH 04/20] BridgeJS: Warn on async throwing closures passed to JavaScript --- .../BridgeJS/Sources/BridgeJSCore/Misc.swift | 20 ++- .../BridgeJSCore/SwiftToSkeleton.swift | 53 +++++++- .../Sources/BridgeJSTool/BridgeJSTool.swift | 3 + .../BridgeJSToolInternal.swift | 5 + .../ClosureAsyncThrowsWarningTests.swift | 122 ++++++++++++++++++ .../Bringing-Swift-Closures-to-JavaScript.md | 2 +- .../Exporting-Swift-Closure.md | 2 +- 7 files changed, 197 insertions(+), 10 deletions(-) create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncThrowsWarningTests.swift diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift index 37040d7a6..8d7b7c902 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/Misc.swift @@ -137,14 +137,21 @@ import SwiftSyntax import class Foundation.ProcessInfo public struct DiagnosticError: Error { + public enum Severity: String, Sendable { + case error + case warning + } + public let node: Syntax public let message: String public let hint: String? + public let severity: Severity - public init(node: some SyntaxProtocol, message: String, hint: String? = nil) { + public init(node: some SyntaxProtocol, message: String, hint: String? = nil, severity: Severity = .error) { self.node = Syntax(node) self.message = message self.hint = hint + self.severity = severity } /// Formats the diagnostic error as a string. @@ -166,12 +173,14 @@ public struct DiagnosticError: Error { let lineNumberWidth = max(3, String(lines.count).count) + let severityLabel = severity.rawValue + let severityColor = severity == .warning ? ANSI.boldYellow : ANSI.boldRed let header: String = { guard colorize else { - return "\(displayFileName):\(startLocation.line):\(startLocation.column): error: \(message)" + return "\(displayFileName):\(startLocation.line):\(startLocation.column): \(severityLabel): \(message)" } return - "\(displayFileName):\(startLocation.line):\(startLocation.column): \(ANSI.boldRed)error: \(ANSI.boldDefault)\(message)\(ANSI.reset)" + "\(displayFileName):\(startLocation.line):\(startLocation.column): \(severityColor)\(severityLabel): \(ANSI.boldDefault)\(message)\(ANSI.reset)" }() let highlightStartColumn = min(max(1, startLocation.column), mainLine.utf8.count + 1) @@ -227,8 +236,8 @@ public struct DiagnosticError: Error { let pointerSpacing = max(0, highlightStartColumn - 1) let pointerMessage: String = { let pointer = String(repeating: " ", count: pointerSpacing) + "`- " - guard colorize else { return pointer + "error: \(message)" } - return pointer + "\(ANSI.boldRed)error: \(ANSI.boldDefault)\(message)\(ANSI.reset)" + guard colorize else { return pointer + "\(severityLabel): \(message)" } + return pointer + "\(severityColor)\(severityLabel): \(ANSI.boldDefault)\(message)\(ANSI.reset)" }() descriptionParts.append( Self.formatSourceLine( @@ -304,6 +313,7 @@ public struct BridgeJSCoreDiagnosticError: Swift.Error, CustomStringConvertible private enum ANSI { static let reset = "\u{001B}[0;0m" static let boldRed = "\u{001B}[1;31m" + static let boldYellow = "\u{001B}[1;33m" static let boldDefault = "\u{001B}[1;39m" static let cyan = "\u{001B}[0;36m" static let underline = "\u{001B}[4;39m" diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index 18bde3c7f..ab9175e16 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -24,6 +24,9 @@ public final class SwiftToSkeleton { private var sourceFiles: [(sourceFile: SourceFileSyntax, inputFilePath: String)] = [] private var usedExternalModules = Set() + /// Non-fatal diagnostics collected during `finalize()`. These do not fail the build. + public private(set) var warnings: [(file: String, diagnostic: DiagnosticError)] = [] + public init( progress: ProgressReporting, moduleName: String, @@ -87,10 +90,15 @@ public final class SwiftToSkeleton { ) importCollector.walk(sourceFile) - let importErrorsFatal = importCollector.errors.filter { !$0.message.contains("Unsupported type '") } - if !exportCollector.errors.isEmpty || !importErrorsFatal.isEmpty { + let exportErrors = exportCollector.errors.filter { $0.severity == .error } + let importErrorsFatal = importCollector.errors.filter { + $0.severity == .error && !$0.message.contains("Unsupported type '") + } + let fileWarnings = (exportCollector.errors + importCollector.errors).filter { $0.severity == .warning } + warnings.append(contentsOf: fileWarnings.map { (file: inputFilePath, diagnostic: $0) }) + if !exportErrors.isEmpty || !importErrorsFatal.isEmpty { perSourceErrors.append( - (inputFilePath: inputFilePath, errors: exportCollector.errors + importErrorsFatal) + (inputFilePath: inputFilePath, errors: exportErrors + importErrorsFatal) ) } @@ -602,6 +610,37 @@ private enum ExportSwiftConstants { static let supportedRawTypes = SwiftEnumRawType.supportedTypeNames } +/// Warns about Swift closures handed to JavaScript with an `async throws(JSException)` signature. +/// Captureless closure values lose their thrown error at runtime due to a Swift compiler bug. +private func asyncThrowsClosureWarning(node: some SyntaxProtocol) -> DiagnosticError { + DiagnosticError( + node: node, + message: + "async throwing closures passed to JavaScript may lose thrown errors due to a Swift compiler bug " + + "(swiftlang/swift#89320) unless the closure value captures state", + hint: + "Pass a closure that captures state, or see the BridgeJS closure documentation for details", + severity: .warning + ) +} + +extension BridgeType { + fileprivate var containsAsyncThrowsClosure: Bool { + switch self { + case .closure(let signature, _): + return signature.isAsync && signature.isThrows + case .nullable(let wrapped, _): + return wrapped.containsAsyncThrowsClosure + case .array(let element): + return element.containsAsyncThrowsClosure + case .dictionary(let value): + return value.containsAsyncThrowsClosure + default: + return false + } + } +} + extension AttributeSyntax { /// The attribute name as text when it is a simple identifier (e.g. "JS", "JSFunction"). /// Prefer this over `attributeName.trimmedDescription` for name checks to avoid unnecessary string work. @@ -1194,6 +1233,9 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { guard let type = resolvedType else { return nil } returnType = type + if returnType.containsAsyncThrowsClosure { + errors.append(asyncThrowsClosureWarning(node: returnClause.type)) + } } else { returnType = .void } @@ -2853,6 +2895,11 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { guard let bridgeType = withLookupErrors({ parent.lookupType(for: type, errors: &$0) }) else { return nil } + if case .closure(let signature, useJSTypedClosure: true) = bridgeType, + signature.isAsync, signature.isThrows + { + errors.append(asyncThrowsClosureWarning(node: type)) + } let nameToken = param.secondName ?? param.firstName let name = SwiftToSkeleton.normalizeIdentifier(nameToken.text) let labelToken = param.secondName == nil ? nil : param.firstName diff --git a/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift b/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift index 005af04a8..fa8a0a273 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift @@ -201,6 +201,9 @@ import BridgeJSUtilities let skeleton = try withSpan("SwiftToSkeleton.finalize") { return try swiftToSkeleton.finalize() } + for (file, diagnostic) in swiftToSkeleton.warnings { + printStderr(diagnostic.formattedDescription(fileName: file)) + } var exporter: ExportSwift? if let skeleton = skeleton.exported { diff --git a/Plugins/BridgeJS/Sources/BridgeJSToolInternal/BridgeJSToolInternal.swift b/Plugins/BridgeJS/Sources/BridgeJSToolInternal/BridgeJSToolInternal.swift index f4de24093..4a58f1972 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSToolInternal/BridgeJSToolInternal.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSToolInternal/BridgeJSToolInternal.swift @@ -60,6 +60,11 @@ import ArgumentParser swiftToSkeleton.addSourceFile(sourceFile, inputFilePath: inputFile) } let skeleton = try swiftToSkeleton.finalize() + for (file, diagnostic) in swiftToSkeleton.warnings { + FileHandle.standardError.write( + Data((diagnostic.formattedDescription(fileName: file, colorize: false) + "\n").utf8) + ) + } let encoder = JSONEncoder() encoder.outputFormatting = [.prettyPrinted, .sortedKeys] let skeletonData = try encoder.encode(skeleton) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncThrowsWarningTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncThrowsWarningTests.swift new file mode 100644 index 000000000..4ee9bc5cc --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncThrowsWarningTests.swift @@ -0,0 +1,122 @@ +import Foundation +import SwiftParser +import SwiftSyntax +import Testing + +@testable import BridgeJSCore +@testable import BridgeJSSkeleton + +@Suite struct ClosureAsyncThrowsWarningTests { + @Test + func warnsOnTypedAsyncThrowsClosureReturn() throws { + let result = try resolveApp( + source: """ + @JS public func makeParser() -> JSTypedClosure<(String) async throws(JSException) -> String> { + fatalError() + } + """ + ) + #expect(result.warnings.count == 1) + let warning = try #require(result.warnings.first) + #expect(warning.diagnostic.severity == .warning) + #expect(warning.diagnostic.message.contains("swiftlang/swift#89320")) + } + + @Test + func warnsOnPlainAsyncThrowsClosureReturn() throws { + let result = try resolveApp( + source: """ + @JS public func makeParser() -> (String) async throws(JSException) -> String { + fatalError() + } + """ + ) + #expect(result.warnings.count == 1) + #expect(result.warnings.first?.diagnostic.severity == .warning) + } + + @Test + func doesNotWarnOnAsyncThrowsClosureParameter() throws { + let result = try resolveApp( + source: """ + @JS public func process(_ cb: (String) async throws(JSException) -> String) {} + """ + ) + #expect(result.warnings.isEmpty) + } + + @Test + func doesNotWarnOnNonThrowingAsyncClosureReturn() throws { + let result = try resolveApp( + source: """ + @JS public func makeParser() -> JSTypedClosure<(String) async -> String> { + fatalError() + } + """ + ) + #expect(result.warnings.isEmpty) + } + + @Test + func doesNotWarnOnSyncThrowsClosureReturn() throws { + let result = try resolveApp( + source: """ + @JS public func makeParser() -> JSTypedClosure<(String) throws(JSException) -> String> { + fatalError() + } + """ + ) + #expect(result.warnings.isEmpty) + } + + @Test + func warnsOnTypedAsyncThrowsClosureImportParameter() throws { + let result = try resolveApp( + source: """ + @JSFunction func register( + _ cb: JSTypedClosure<(String) async throws(JSException) -> String> + ) throws(JSException) + """ + ) + #expect(result.warnings.count == 1) + #expect(result.warnings.first?.diagnostic.severity == .warning) + } + + @Test + func warningDoesNotFailSkeletonResolution() throws { + let result = try resolveApp( + source: """ + @JS public func makeParser() -> JSTypedClosure<(String) async throws(JSException) -> String> { + fatalError() + } + """ + ) + let function = try #require(result.skeleton.exported?.functions.first(where: { $0.name == "makeParser" })) + guard case .closure(let signature, true) = function.returnType else { + Issue.record("Expected typed closure return type, got \(function.returnType)") + return + } + #expect(signature.isAsync) + #expect(signature.isThrows) + } + + // MARK: - Utilities + + private struct Resolution { + let skeleton: BridgeJSSkeleton + let warnings: [(file: String, diagnostic: DiagnosticError)] + } + + private func resolveApp(source appSource: String) throws -> Resolution { + let swiftAPI = SwiftToSkeleton( + progress: .silent, + moduleName: "App", + exposeToGlobal: false, + externalModuleIndex: ExternalModuleIndex(dependencies: []) + ) + let sourceFile = Parser.parse(source: appSource) + swiftAPI.addSourceFile(sourceFile, inputFilePath: "App.swift") + let skeleton = try swiftAPI.finalize() + return Resolution(skeleton: skeleton, warnings: swiftAPI.warnings) + } +} diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md index 2d0c94152..81383cb83 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md @@ -78,7 +78,7 @@ const count = await fetchCount("/items"); // Promise **Cancellation is a non-goal.** There is no propagation between a Swift `Task` and a JavaScript `Promise` in either direction. -> Note: The reject path of async throwing typed closures is affected by a Swift compiler bug ([swiftlang/swift#89320](https://github.com/swiftlang/swift/issues/89320)). See for details. +> Note: The reject path of async throwing typed closures is affected by a Swift compiler bug ([swiftlang/swift#89320](https://github.com/swiftlang/swift/issues/89320)); BridgeJS emits a build-time warning for this signature. See for details. ## Lifetime and release() diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md index 4dd08faa8..8e3e70176 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md @@ -239,7 +239,7 @@ Notes: - The same `JavaScriptEventLoop.installGlobalExecutor()` requirement applies as for async functions; there is no special handling for closures. - **Cancellation is a non-goal.** There is no propagation between a Swift `Task` and a JavaScript `Promise` in either direction; cancelling one side does not cancel the other. -> Warning: When an async throwing closure handed to JavaScript throws, the error is currently lost instead of rejecting the `Promise` with it, due to a Swift compiler bug on `wasm32` ([swiftlang/swift#89320](https://github.com/swiftlang/swift/issues/89320), fix in progress in [swiftlang/swift#89715](https://github.com/swiftlang/swift/pull/89715)). Closures that capture state are unaffected, as are throwing JavaScript callbacks passed into Swift. +> Warning: When an async throwing closure handed to JavaScript throws, the error is currently lost instead of rejecting the `Promise` with it, due to a Swift compiler bug on `wasm32` ([swiftlang/swift#89320](https://github.com/swiftlang/swift/issues/89320), fix in progress in [swiftlang/swift#89715](https://github.com/swiftlang/swift/pull/89715)). Closures that capture state are unaffected, as are throwing JavaScript callbacks passed into Swift. BridgeJS emits a build-time warning for this signature. ## Supported Features From d26143ea6797d94f37ff76bc2f242b81c1cc28ad Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Thu, 11 Jun 2026 09:24:29 +0200 Subject: [PATCH 05/20] Box JSException storage in a class to fit the direct typed-error convention --- .../BridgeJSCore/SwiftToSkeleton.swift | 39 ------ .../ClosureAsyncThrowsWarningTests.swift | 122 ------------------ .../Bringing-Swift-Closures-to-JavaScript.md | 1 - .../Exporting-Swift-Closure.md | 4 +- Sources/JavaScriptKit/JSException.swift | 64 ++++++--- .../JavaScript/ClosureAsyncTests.mjs | 6 - .../JSClosure+AsyncTests.swift | 12 ++ 7 files changed, 63 insertions(+), 185 deletions(-) delete mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncThrowsWarningTests.swift diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index ab9175e16..a6afe2779 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -610,37 +610,6 @@ private enum ExportSwiftConstants { static let supportedRawTypes = SwiftEnumRawType.supportedTypeNames } -/// Warns about Swift closures handed to JavaScript with an `async throws(JSException)` signature. -/// Captureless closure values lose their thrown error at runtime due to a Swift compiler bug. -private func asyncThrowsClosureWarning(node: some SyntaxProtocol) -> DiagnosticError { - DiagnosticError( - node: node, - message: - "async throwing closures passed to JavaScript may lose thrown errors due to a Swift compiler bug " - + "(swiftlang/swift#89320) unless the closure value captures state", - hint: - "Pass a closure that captures state, or see the BridgeJS closure documentation for details", - severity: .warning - ) -} - -extension BridgeType { - fileprivate var containsAsyncThrowsClosure: Bool { - switch self { - case .closure(let signature, _): - return signature.isAsync && signature.isThrows - case .nullable(let wrapped, _): - return wrapped.containsAsyncThrowsClosure - case .array(let element): - return element.containsAsyncThrowsClosure - case .dictionary(let value): - return value.containsAsyncThrowsClosure - default: - return false - } - } -} - extension AttributeSyntax { /// The attribute name as text when it is a simple identifier (e.g. "JS", "JSFunction"). /// Prefer this over `attributeName.trimmedDescription` for name checks to avoid unnecessary string work. @@ -1233,9 +1202,6 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { guard let type = resolvedType else { return nil } returnType = type - if returnType.containsAsyncThrowsClosure { - errors.append(asyncThrowsClosureWarning(node: returnClause.type)) - } } else { returnType = .void } @@ -2895,11 +2861,6 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { guard let bridgeType = withLookupErrors({ parent.lookupType(for: type, errors: &$0) }) else { return nil } - if case .closure(let signature, useJSTypedClosure: true) = bridgeType, - signature.isAsync, signature.isThrows - { - errors.append(asyncThrowsClosureWarning(node: type)) - } let nameToken = param.secondName ?? param.firstName let name = SwiftToSkeleton.normalizeIdentifier(nameToken.text) let labelToken = param.secondName == nil ? nil : param.firstName diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncThrowsWarningTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncThrowsWarningTests.swift deleted file mode 100644 index 4ee9bc5cc..000000000 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/ClosureAsyncThrowsWarningTests.swift +++ /dev/null @@ -1,122 +0,0 @@ -import Foundation -import SwiftParser -import SwiftSyntax -import Testing - -@testable import BridgeJSCore -@testable import BridgeJSSkeleton - -@Suite struct ClosureAsyncThrowsWarningTests { - @Test - func warnsOnTypedAsyncThrowsClosureReturn() throws { - let result = try resolveApp( - source: """ - @JS public func makeParser() -> JSTypedClosure<(String) async throws(JSException) -> String> { - fatalError() - } - """ - ) - #expect(result.warnings.count == 1) - let warning = try #require(result.warnings.first) - #expect(warning.diagnostic.severity == .warning) - #expect(warning.diagnostic.message.contains("swiftlang/swift#89320")) - } - - @Test - func warnsOnPlainAsyncThrowsClosureReturn() throws { - let result = try resolveApp( - source: """ - @JS public func makeParser() -> (String) async throws(JSException) -> String { - fatalError() - } - """ - ) - #expect(result.warnings.count == 1) - #expect(result.warnings.first?.diagnostic.severity == .warning) - } - - @Test - func doesNotWarnOnAsyncThrowsClosureParameter() throws { - let result = try resolveApp( - source: """ - @JS public func process(_ cb: (String) async throws(JSException) -> String) {} - """ - ) - #expect(result.warnings.isEmpty) - } - - @Test - func doesNotWarnOnNonThrowingAsyncClosureReturn() throws { - let result = try resolveApp( - source: """ - @JS public func makeParser() -> JSTypedClosure<(String) async -> String> { - fatalError() - } - """ - ) - #expect(result.warnings.isEmpty) - } - - @Test - func doesNotWarnOnSyncThrowsClosureReturn() throws { - let result = try resolveApp( - source: """ - @JS public func makeParser() -> JSTypedClosure<(String) throws(JSException) -> String> { - fatalError() - } - """ - ) - #expect(result.warnings.isEmpty) - } - - @Test - func warnsOnTypedAsyncThrowsClosureImportParameter() throws { - let result = try resolveApp( - source: """ - @JSFunction func register( - _ cb: JSTypedClosure<(String) async throws(JSException) -> String> - ) throws(JSException) - """ - ) - #expect(result.warnings.count == 1) - #expect(result.warnings.first?.diagnostic.severity == .warning) - } - - @Test - func warningDoesNotFailSkeletonResolution() throws { - let result = try resolveApp( - source: """ - @JS public func makeParser() -> JSTypedClosure<(String) async throws(JSException) -> String> { - fatalError() - } - """ - ) - let function = try #require(result.skeleton.exported?.functions.first(where: { $0.name == "makeParser" })) - guard case .closure(let signature, true) = function.returnType else { - Issue.record("Expected typed closure return type, got \(function.returnType)") - return - } - #expect(signature.isAsync) - #expect(signature.isThrows) - } - - // MARK: - Utilities - - private struct Resolution { - let skeleton: BridgeJSSkeleton - let warnings: [(file: String, diagnostic: DiagnosticError)] - } - - private func resolveApp(source appSource: String) throws -> Resolution { - let swiftAPI = SwiftToSkeleton( - progress: .silent, - moduleName: "App", - exposeToGlobal: false, - externalModuleIndex: ExternalModuleIndex(dependencies: []) - ) - let sourceFile = Parser.parse(source: appSource) - swiftAPI.addSourceFile(sourceFile, inputFilePath: "App.swift") - let skeleton = try swiftAPI.finalize() - return Resolution(skeleton: skeleton, warnings: swiftAPI.warnings) - } -} diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md index 81383cb83..7b95feb50 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Bringing-Swift-Closures-to-JavaScript.md @@ -78,7 +78,6 @@ const count = await fetchCount("/items"); // Promise **Cancellation is a non-goal.** There is no propagation between a Swift `Task` and a JavaScript `Promise` in either direction. -> Note: The reject path of async throwing typed closures is affected by a Swift compiler bug ([swiftlang/swift#89320](https://github.com/swiftlang/swift/issues/89320)); BridgeJS emits a build-time warning for this signature. See for details. ## Lifetime and release() diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md index 8e3e70176..9b9f4ab97 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Closure.md @@ -239,7 +239,7 @@ Notes: - The same `JavaScriptEventLoop.installGlobalExecutor()` requirement applies as for async functions; there is no special handling for closures. - **Cancellation is a non-goal.** There is no propagation between a Swift `Task` and a JavaScript `Promise` in either direction; cancelling one side does not cancel the other. -> Warning: When an async throwing closure handed to JavaScript throws, the error is currently lost instead of rejecting the `Promise` with it, due to a Swift compiler bug on `wasm32` ([swiftlang/swift#89320](https://github.com/swiftlang/swift/issues/89320), fix in progress in [swiftlang/swift#89715](https://github.com/swiftlang/swift/pull/89715)). Closures that capture state are unaffected, as are throwing JavaScript callbacks passed into Swift. BridgeJS emits a build-time warning for this signature. + ## Supported Features @@ -251,7 +251,7 @@ Notes: | Optional types in closures | ✅ | | Closure-typed `@JS` properties | ❌ | | Async closures `(A) async -> B` | ✅ | -| Async throwing closures `(A) async throws(JSException) -> B` | ✅ (reject path of closures handed to JS pending [swiftlang/swift#89320](https://github.com/swiftlang/swift/issues/89320)) | +| Async throwing closures `(A) async throws(JSException) -> B` | ✅ | | Throwing closures `(A) throws(JSException) -> B` | ✅ | ## See Also diff --git a/Sources/JavaScriptKit/JSException.swift b/Sources/JavaScriptKit/JSException.swift index 4d95e207d..84232163c 100644 --- a/Sources/JavaScriptKit/JSException.swift +++ b/Sources/JavaScriptKit/JSException.swift @@ -13,38 +13,66 @@ /// } /// ``` public struct JSException: Error, Equatable, CustomStringConvertible { - /// The value thrown from JavaScript. - /// This can be any JavaScript value (error object, string, number, etc.). - public var thrownValue: JSValue { - return _thrownValue + /// Boxes the exception payload in a class so `JSException` stays within the direct + /// typed-error convention on wasm32. + private final class Storage { + /// The actual JavaScript value that was thrown. + let thrownValue: JSValue + + /// A description of the exception. + let description: String + + /// The stack trace of the exception. + let stack: String? + + init(thrownValue: JSValue, description: String, stack: String?) { + self.thrownValue = thrownValue + self.description = description + self.stack = stack + } } - /// The actual JavaScript value that was thrown. + /// The boxed payload of the exception. /// /// Marked as `nonisolated(unsafe)` to satisfy `Sendable` requirement /// from `Error` protocol. - private nonisolated(unsafe) let _thrownValue: JSValue + private nonisolated(unsafe) let storage: Storage + + /// The value thrown from JavaScript. + /// This can be any JavaScript value (error object, string, number, etc.). + public var thrownValue: JSValue { + return storage.thrownValue + } /// A description of the exception. - public let description: String + public var description: String { + return storage.description + } /// The stack trace of the exception. - public let stack: String? + public var stack: String? { + return storage.stack + } /// Initializes a new JSException instance with a value thrown from JavaScript. /// /// Only available within the package. This must be called on the thread where the exception object created. + /// The stringified representation is captured on the object owner thread to bring useful info + /// to the catching thread even if they are different threads. @usableFromInline package init(_ thrownValue: JSValue) { - self._thrownValue = thrownValue - // Capture the stringified representation on the object owner thread - // to bring useful info to the catching thread even if they are different threads. if let errorObject = thrownValue.object, let stack = errorObject.stack.string { - self.description = "JSException(\(stack))" - self.stack = stack + self.storage = Storage( + thrownValue: thrownValue, + description: "JSException(\(stack))", + stack: stack + ) } else { - self.description = "JSException(\(thrownValue))" - self.stack = nil + self.storage = Storage( + thrownValue: thrownValue, + description: "JSException(\(thrownValue))", + stack: nil + ) } } @@ -55,4 +83,10 @@ public struct JSException: Error, Equatable, CustomStringConvertible { public init(message: String) { self.init(JSError(message: message).jsValue) } + + public static func == (lhs: JSException, rhs: JSException) -> Bool { + return lhs.storage.thrownValue == rhs.storage.thrownValue + && lhs.storage.description == rhs.storage.description + && lhs.storage.stack == rhs.storage.stack + } } diff --git a/Tests/BridgeJSRuntimeTests/JavaScript/ClosureAsyncTests.mjs b/Tests/BridgeJSRuntimeTests/JavaScript/ClosureAsyncTests.mjs index d7f249ec4..57a824aa4 100644 --- a/Tests/BridgeJSRuntimeTests/JavaScript/ClosureAsyncTests.mjs +++ b/Tests/BridgeJSRuntimeTests/JavaScript/ClosureAsyncTests.mjs @@ -45,9 +45,6 @@ export async function runJsClosureAsyncTests(exports) { assert.equal(await parsed, "parsed:42"); assert.equal(await parser("-7"), "parsed:-7"); - // Blocked by swiftlang/swift#89320 (wasm32 typed-throws async miscompile for captureless closures); re-enable once swiftlang/swift#89715 lands. - const ASYNC_THROWS_CLOSURE_REJECT_BLOCKED = true; - if (!ASYNC_THROWS_CLOSURE_REJECT_BLOCKED) { let directionBReject = null; try { await parser("not-a-number"); @@ -57,7 +54,6 @@ export async function runJsClosureAsyncTests(exports) { } assert.notEqual(directionBReject, null); assert.equal(directionBReject.message, "AsyncParseError: not-a-number"); - } assert.equal(await parser("100"), "parsed:100"); @@ -72,7 +68,6 @@ export async function runJsClosureAsyncTests(exports) { assert.equal(await recorded, undefined); assert.equal(exports.lastRecordedValue(), "logged-value"); - if (!ASYNC_THROWS_CLOSURE_REJECT_BLOCKED) { let voidReject = null; try { await recorder("boom"); @@ -82,7 +77,6 @@ export async function runJsClosureAsyncTests(exports) { } assert.notEqual(voidReject, null); assert.equal(voidReject.message, "AsyncRecorderError"); - } const payloadLoader = exports.makeAsyncPayloadLoader(); const payloadPromise = payloadLoader(true); diff --git a/Tests/JavaScriptEventLoopTests/JSClosure+AsyncTests.swift b/Tests/JavaScriptEventLoopTests/JSClosure+AsyncTests.swift index e3c19a8e4..f53c7eeb7 100644 --- a/Tests/JavaScriptEventLoopTests/JSClosure+AsyncTests.swift +++ b/Tests/JavaScriptEventLoopTests/JSClosure+AsyncTests.swift @@ -24,6 +24,18 @@ class JSClosureAsyncTests: XCTestCase { XCTAssertEqual(result, 42.0) } + func testAsyncClosureReject() async throws { + let closure = JSClosure.async { (_) async throws(JSException) -> JSValue in + throw JSException(message: "AsyncClosureRejected") + }.jsValue + let result = await JSPromise(from: closure.function!())!.result + guard case .failure(let rejectedValue) = result else { + XCTFail("Expected the async closure promise to reject, got \(result)") + return + } + XCTAssertEqual(rejectedValue.object?.message.string, "AsyncClosureRejected") + } + func testAsyncClosureWithPriority() async throws { let priority = UnsafeSendableBox(nil) let closure = JSClosure.async(priority: .high) { _ in From e3315ec6b1031a1b6d82fd03e48414fdc002f1d8 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Fri, 12 Jun 2026 12:47:00 +0100 Subject: [PATCH 06/20] BridgeJS: Normalize wasm pointer offsets in JS --- .github/workflows/test.yml | 1 + .../Sources/BridgeJSLink/BridgeJSLink.swift | 7 +- .../BridgeJSLinkTests/ArrayTypes.js | 5 +- .../__Snapshots__/BridgeJSLinkTests/Async.js | 4 +- .../AsyncAssociatedValueEnum.js | 4 +- .../BridgeJSLinkTests/AsyncImport.js | 6 +- .../BridgeJSLinkTests/AsyncStaticImport.js | 6 +- .../BridgeJSLinkTests/DefaultParameters.js | 5 +- .../BridgeJSLinkTests/DictionaryTypes.js | 5 +- .../BridgeJSLinkTests/EnumAssociatedValue.js | 5 +- .../EnumAssociatedValueImport.js | 4 +- .../BridgeJSLinkTests/EnumCase.js | 4 +- .../BridgeJSLinkTests/EnumCaseImport.js | 4 +- .../BridgeJSLinkTests/EnumNamespace.Global.js | 5 +- .../BridgeJSLinkTests/EnumNamespace.js | 5 +- .../BridgeJSLinkTests/EnumRawType.js | 4 +- .../BridgeJSLinkTests/FixedWidthIntegers.js | 4 +- .../BridgeJSLinkTests/GlobalGetter.js | 4 +- .../BridgeJSLinkTests/GlobalThisImports.js | 4 +- .../IdentityModeClass.ConfigPointer.js | 5 +- .../IdentityModeClass.PerClass.js | 5 +- .../BridgeJSLinkTests/IdentityModeClass.js | 5 +- .../BridgeJSLinkTests/ImportArray.js | 4 +- .../ImportedTypeInExportedInterface.js | 4 +- .../BridgeJSLinkTests/InvalidPropertyNames.js | 4 +- .../BridgeJSLinkTests/JSClass.js | 4 +- .../JSClassStaticFunctions.js | 4 +- .../BridgeJSLinkTests/JSTypedArrayTypes.js | 4 +- .../BridgeJSLinkTests/JSValue.js | 5 +- .../BridgeJSLinkTests/MixedGlobal.js | 5 +- .../BridgeJSLinkTests/MixedModules.js | 5 +- .../BridgeJSLinkTests/MixedPrivate.js | 5 +- .../BridgeJSLinkTests/Namespaces.Global.js | 5 +- .../BridgeJSLinkTests/Namespaces.js | 5 +- .../BridgeJSLinkTests/NestedType.js | 5 +- .../BridgeJSLinkTests/Optionals.js | 5 +- .../BridgeJSLinkTests/PrimitiveParameters.js | 4 +- .../BridgeJSLinkTests/PrimitiveReturn.js | 4 +- .../BridgeJSLinkTests/PropertyTypes.js | 5 +- .../BridgeJSLinkTests/Protocol.js | 5 +- .../BridgeJSLinkTests/ProtocolInClosure.js | 7 +- .../StaticFunctions.Global.js | 5 +- .../BridgeJSLinkTests/StaticFunctions.js | 5 +- .../StaticProperties.Global.js | 5 +- .../BridgeJSLinkTests/StaticProperties.js | 5 +- .../BridgeJSLinkTests/StringParameter.js | 4 +- .../BridgeJSLinkTests/StringReturn.js | 4 +- .../BridgeJSLinkTests/SwiftClass.js | 5 +- .../BridgeJSLinkTests/SwiftClosure.js | 7 +- .../BridgeJSLinkTests/SwiftClosureImports.js | 6 +- .../BridgeJSLinkTests/SwiftStruct.js | 5 +- .../BridgeJSLinkTests/SwiftStructImports.js | 4 +- .../SwiftTypedClosureAccess.js | 6 +- .../__Snapshots__/BridgeJSLinkTests/Throws.js | 4 +- .../BridgeJSLinkTests/UnsafePointer.js | 4 +- .../VoidParameterVoidReturn.js | 4 +- Runtime/src/index.ts | 26 ++-- Runtime/src/js-value.ts | 26 ++-- Runtime/test/pointer-normalization.test.ts | 114 ++++++++++++++++++ package.json | 1 + 60 files changed, 294 insertions(+), 136 deletions(-) create mode 100644 Runtime/test/pointer-normalization.test.ts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ef72ca352..37e5bce78 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,6 +54,7 @@ jobs: echo "SWIFT_SDK_ID=${{ steps.setup-swiftwasm.outputs.swift-sdk-id }}" >> $GITHUB_ENV echo "SWIFT_BIN_PATH=$(dirname $(which swiftc))" >> $GITHUB_ENV - run: make bootstrap + - run: npm run test:runtime - run: make unittest # Skip unit tests with uwasi because its proc_exit throws # unhandled promise rejection. diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index a9acf048e..8c9c20a14 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -107,6 +107,7 @@ public struct BridgeJSLink { /// Represents a Swift heap object like a class instance or an actor instance. class SwiftHeapObject { static __wrap(pointer, deinit, prototype, identityCache) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; @@ -428,7 +429,7 @@ public struct BridgeJSLink { "\(JSGlueVariableScope.reservedSwift).\(JSGlueVariableScope.reservedMemory).release(sourceId);" ) printer.write( - "const bytes = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, bytesPtr);" + "const bytes = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, bytesPtr >>> 0);" ) printer.write("bytes.set(source);") } @@ -443,7 +444,7 @@ public struct BridgeJSLink { printer.write("bjs[\"swift_js_init_memory_with_result\"] = function(ptr, len) {") printer.indent { printer.write( - "const target = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, ptr, len);" + "const target = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, ptr >>> 0, len >>> 0);" ) printer.write("target.set(\(JSGlueVariableScope.reservedStorageToReturnBytes));") printer.write("\(JSGlueVariableScope.reservedStorageToReturnBytes) = undefined;") @@ -789,7 +790,7 @@ public struct BridgeJSLink { helperPrinter.write("if (state.unregistered) {") helperPrinter.indent { helperPrinter.write( - "const bytes = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, state.file);" + "const bytes = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, state.file >>> 0);" ) helperPrinter.write("let length = 0;") helperPrinter.write("while (bytes[length] !== 0) { length += 1; }") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js index 75d961e98..7978d1522 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js @@ -70,14 +70,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -390,6 +390,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js index 9319cdd7e..680da9c5e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.js @@ -155,14 +155,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.js index 69e4a4928..98c0aff46 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncAssociatedValueEnum.js @@ -178,14 +178,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js index 27e53b8d7..fa50b23f2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncImport.js @@ -128,7 +128,7 @@ export async function createInstantiator(options, swift) { const state = { pointer, file, line, unregistered: false }; const real = (...args) => { if (state.unregistered) { - const bytes = new Uint8Array(memory.buffer, state.file); + const bytes = new Uint8Array(memory.buffer, state.file >>> 0); let length = 0; while (bytes[length] !== 0) { length += 1; } const fileID = decodeString(state.file, length); @@ -160,14 +160,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js index 789379a32..c359886b3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AsyncStaticImport.js @@ -128,7 +128,7 @@ export async function createInstantiator(options, swift) { const state = { pointer, file, line, unregistered: false }; const real = (...args) => { if (state.unregistered) { - const bytes = new Uint8Array(memory.buffer, state.file); + const bytes = new Uint8Array(memory.buffer, state.file >>> 0); let length = 0; while (bytes[length] !== 0) { length += 1; } const fileID = decodeString(state.file, length); @@ -159,14 +159,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index 4b13bb633..0c6bfbec8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -87,14 +87,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -301,6 +301,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js index 2021f1c96..104472a02 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js @@ -86,14 +86,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -310,6 +310,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js index d97e4ef11..35b05fe61 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js @@ -788,14 +788,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -987,6 +987,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.js index 1688dc94d..de374bd70 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValueImport.js @@ -89,14 +89,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js index b4c5870b6..c2ae031bb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.js @@ -69,14 +69,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCaseImport.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCaseImport.js index dc1b3c6b3..f2d6b8750 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCaseImport.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCaseImport.js @@ -50,14 +50,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js index 050c16b18..1a8f5662f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js @@ -89,14 +89,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -293,6 +293,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js index 9f2f4122c..9196e99b3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js @@ -70,14 +70,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -274,6 +274,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js index 2ab98b31b..9e18a8d80 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.js @@ -121,14 +121,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js index 94bfe89cd..a009f8d71 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/FixedWidthIntegers.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js index 174c9b430..b1d830768 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalGetter.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js index e8a89c6e4..6f43c2d9c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/GlobalThisImports.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js index 99c0bb4ea..36728f890 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -245,6 +245,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js index 82458b81a..ed180c1c8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -245,6 +245,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js index 82458b81a..ed180c1c8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -245,6 +245,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js index 8ebcbda28..2ad7251f8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportArray.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js index 710eebe36..4328e4d4e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js @@ -84,14 +84,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js index 605359fb8..8d1ac2698 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js index e24b5dac5..08215f159 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClass.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js index b936636a9..a38b0a391 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSClassStaticFunctions.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSTypedArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSTypedArrayTypes.js index c5c37a512..5c713cc78 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSTypedArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSTypedArrayTypes.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js index e8f617e5b..d47fd3e85 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js @@ -135,14 +135,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -369,6 +369,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js index 3abacf371..577fa0ca7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -237,6 +237,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js index a2dc23d68..e15c7bcfb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -245,6 +245,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js index 7fdf9b4c8..e1605fb10 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -237,6 +237,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js index 09a6ace60..aa5e3dbb4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -249,6 +249,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js index 1c9287a08..9a5c6473e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -249,6 +249,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js index 7c2751964..1fb339f32 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js @@ -70,14 +70,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -280,6 +280,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js index c3c41f332..956582377 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -526,6 +526,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js index 3957b5482..46d57d793 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js index e624ceb1a..bb4e8552d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js index 6e66102e2..0070d0dbe 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -237,6 +237,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js index ac533b6d4..999210eb5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js @@ -102,14 +102,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -597,6 +597,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js index 102ac6020..d9c31ed1d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js @@ -39,7 +39,7 @@ export async function createInstantiator(options, swift) { const state = { pointer, file, line, unregistered: false }; const real = (...args) => { if (state.unregistered) { - const bytes = new Uint8Array(memory.buffer, state.file); + const bytes = new Uint8Array(memory.buffer, state.file >>> 0); let length = 0; while (bytes[length] !== 0) { length += 1; } const fileID = decodeString(state.file, length); @@ -70,14 +70,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -383,6 +383,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js index 5257c9856..d626e9adf 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js @@ -89,14 +89,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -281,6 +281,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js index 91316a8c4..93f1e7ec7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js @@ -89,14 +89,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -281,6 +281,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js index f238551a9..edf069178 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js @@ -50,14 +50,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -242,6 +242,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js index c7f9b4955..64132a3c2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js @@ -50,14 +50,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -242,6 +242,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js index 994e1710a..2c3da5f26 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js index 839e194cf..057bf9658 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js index 5ee56f5bc..7f9fb8a20 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -265,6 +265,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index 4f0770092..f5912b3f5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -158,7 +158,7 @@ export async function createInstantiator(options, swift) { const state = { pointer, file, line, unregistered: false }; const real = (...args) => { if (state.unregistered) { - const bytes = new Uint8Array(memory.buffer, state.file); + const bytes = new Uint8Array(memory.buffer, state.file >>> 0); let length = 0; while (bytes[length] !== 0) { length += 1; } const fileID = decodeString(state.file, length); @@ -262,14 +262,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -1352,6 +1352,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js index 0cc8fd287..d03915f87 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosureImports.js @@ -128,7 +128,7 @@ export async function createInstantiator(options, swift) { const state = { pointer, file, line, unregistered: false }; const real = (...args) => { if (state.unregistered) { - const bytes = new Uint8Array(memory.buffer, state.file); + const bytes = new Uint8Array(memory.buffer, state.file >>> 0); let length = 0; while (bytes[length] !== 0) { length += 1; } const fileID = decodeString(state.file, length); @@ -160,14 +160,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js index aa523be20..b25010a23 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js @@ -258,14 +258,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -506,6 +506,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js index 44b7c5527..523861b9a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStructImports.js @@ -57,14 +57,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftTypedClosureAccess.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftTypedClosureAccess.js index f07b00968..66d6494fd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftTypedClosureAccess.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftTypedClosureAccess.js @@ -39,7 +39,7 @@ export async function createInstantiator(options, swift) { const state = { pointer, file, line, unregistered: false }; const real = (...args) => { if (state.unregistered) { - const bytes = new Uint8Array(memory.buffer, state.file); + const bytes = new Uint8Array(memory.buffer, state.file >>> 0); let length = 0; while (bytes[length] !== 0) { length += 1; } const fileID = decodeString(state.file, length); @@ -70,14 +70,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js index d1036cba4..6ff126525 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js index 54276025b..457bfa973 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.js @@ -62,14 +62,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js index 755165ee1..3c75771c5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js @@ -46,14 +46,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } diff --git a/Runtime/src/index.ts b/Runtime/src/index.ts index 7d75a6801..879774a7d 100644 --- a/Runtime/src/index.ts +++ b/Runtime/src/index.ts @@ -450,31 +450,39 @@ export class SwiftRuntime { const memory = this.memory; const bytes = this.textEncoder.encode(memory.getObject(ref)); const bytes_ptr = memory.retain(bytes); - this.getDataView().setUint32(bytes_ptr_result, bytes_ptr, true); + this.getDataView().setUint32( + bytes_ptr_result >>> 0, + bytes_ptr, + true, + ); return bytes.length; }, swjs_decode_string: // NOTE: TextDecoder can't decode typed arrays backed by SharedArrayBuffer this.options.sharedMemory == true ? (bytes_ptr: pointer, length: number) => { + const bytesOffset = bytes_ptr >>> 0; + const byteLength = length >>> 0; const bytes = this.getUint8Array().slice( - bytes_ptr, - bytes_ptr + length, + bytesOffset, + bytesOffset + byteLength, ); const string = this.textDecoder.decode(bytes); return this.memory.retain(string); } : (bytes_ptr: pointer, length: number) => { + const bytesOffset = bytes_ptr >>> 0; + const byteLength = length >>> 0; const bytes = this.getUint8Array().subarray( - bytes_ptr, - bytes_ptr + length, + bytesOffset, + bytesOffset + byteLength, ); const string = this.textDecoder.decode(bytes); return this.memory.retain(string); }, swjs_load_string: (ref: ref, buffer: pointer) => { const bytes = this.memory.getObject(ref); - this.getUint8Array().set(bytes, buffer); + this.getUint8Array().set(bytes, buffer >>> 0); }, swjs_call_function: ( @@ -741,8 +749,8 @@ export class SwiftRuntime { } const array = new ArrayType( this.wasmMemory!.buffer, - elementsPtr, - length, + elementsPtr >>> 0, + length >>> 0, ); // Call `.slice()` to copy the memory return this.memory.retain(array.slice()); @@ -756,7 +764,7 @@ export class SwiftRuntime { const memory = this.memory; const typedArray = memory.getObject(ref); const bytes = new Uint8Array(typedArray.buffer); - this.getUint8Array().set(bytes, buffer); + this.getUint8Array().set(bytes, buffer >>> 0); }, swjs_release: (ref: ref) => { diff --git a/Runtime/src/js-value.ts b/Runtime/src/js-value.ts index b044e5cbe..407625bb4 100644 --- a/Runtime/src/js-value.ts +++ b/Runtime/src/js-value.ts @@ -60,14 +60,16 @@ export const decodeArray = ( memory: DataView, objectSpace: JSObjectSpace, ) => { + const basePtr = ptr >>> 0; + const count = length >>> 0; // fast path for empty array - if (length === 0) { + if (count === 0) { return []; } let result = []; - for (let index = 0; index < length; index++) { - const base = ptr + 16 * index; + for (let index = 0; index < count; index++) { + const base = basePtr + 16 * index; const kind = memory.getUint32(base, true); const payload1 = memory.getUint32(base + 4, true); const payload2 = memory.getFloat64(base + 8, true); @@ -97,7 +99,7 @@ export const write = ( memory, objectSpace, ); - memory.setUint32(kind_ptr, kind, true); + memory.setUint32(kind_ptr >>> 0, kind, true); }; export const writeAndReturnKindBits = ( @@ -109,23 +111,25 @@ export const writeAndReturnKindBits = ( objectSpace: JSObjectSpace, ): JavaScriptValueKindAndFlags => { const exceptionBit = (is_exception ? 1 : 0) << 31; + const payload1Offset = payload1_ptr >>> 0; + const payload2Offset = payload2_ptr >>> 0; if (value === null) { return exceptionBit | Kind.Null; } const writeRef = (kind: Kind) => { - memory.setUint32(payload1_ptr, objectSpace.retain(value), true); + memory.setUint32(payload1Offset, objectSpace.retain(value), true); return exceptionBit | kind; }; const type = typeof value; switch (type) { case "boolean": { - memory.setUint32(payload1_ptr, value ? 1 : 0, true); + memory.setUint32(payload1Offset, value ? 1 : 0, true); return exceptionBit | Kind.Boolean; } case "number": { - memory.setFloat64(payload2_ptr, value, true); + memory.setFloat64(payload2Offset, value, true); return exceptionBit | Kind.Number; } case "string": { @@ -157,9 +161,11 @@ export function decodeObjectRefs( length: number, memory: DataView, ): ref[] { - const result: ref[] = new Array(length); - for (let i = 0; i < length; i++) { - result[i] = memory.getUint32(ptr + 4 * i, true); + const basePtr = ptr >>> 0; + const count = length >>> 0; + const result: ref[] = new Array(count); + for (let i = 0; i < count; i++) { + result[i] = memory.getUint32(basePtr + 4 * i, true); } return result; } diff --git a/Runtime/test/pointer-normalization.test.ts b/Runtime/test/pointer-normalization.test.ts new file mode 100644 index 000000000..003bbdeb4 --- /dev/null +++ b/Runtime/test/pointer-normalization.test.ts @@ -0,0 +1,114 @@ +import { describe, expect, test } from "vitest"; +import { SwiftRuntime } from "../src/index.js"; +import { decodeArray, decodeObjectRefs, Kind, write } from "../src/js-value.js"; + +// A Wasm pointer is an `i32`. Once the linear memory grows past 2 GiB, valid +// addresses set the high bit and the guest passes them to JavaScript as *negative* +// numbers, which must be normalized with `>>> 0` before being used as memory +// offsets. These tests use a real >2 GiB `WebAssembly.Memory` and a real +// `SwiftRuntime`, exercising the actual code paths at such an address; without the +// normalization each one throws a `RangeError` on the negative offset. +const PAGE_SIZE = 64 * 1024; +const HIGH_OFFSET = 0x8000_0000; // 2 GiB, the first address with the high bit set +const SIGNED_POINTER = HIGH_OFFSET | 0; // how the guest passes that pointer: -2_147_483_648 +const MEMORY_PAGES = HIGH_OFFSET / PAGE_SIZE + 4; // a few pages past the offset + +function makeRuntime(): { runtime: SwiftRuntime; memory: WebAssembly.Memory } { + const memory = new WebAssembly.Memory({ initial: MEMORY_PAGES }); + const runtime = new SwiftRuntime(); + runtime.setInstance({ + exports: { + memory, + swjs_library_version: () => 708, + }, + } as unknown as WebAssembly.Instance); + return { runtime, memory }; +} + +describe("pointer normalization at >2 GiB addresses", () => { + test("swjs_decode_string reads from a high-bit pointer", () => { + const { runtime, memory } = makeRuntime(); + const bytes = new TextEncoder().encode("hello, 🌍"); + new Uint8Array(memory.buffer).set(bytes, HIGH_OFFSET); + + const imports = runtime.wasmImports as any; + const ref = imports.swjs_decode_string(SIGNED_POINTER, bytes.length); + + expect((runtime as any).memory.getObject(ref)).toBe("hello, 🌍"); + }); + + test("swjs_load_string writes to a high-bit pointer", () => { + const { runtime, memory } = makeRuntime(); + const bytes = new TextEncoder().encode("world"); + const ref = (runtime as any).memory.retain(bytes); + + const imports = runtime.wasmImports as any; + imports.swjs_load_string(ref, SIGNED_POINTER); + + const written = new Uint8Array(memory.buffer).slice( + HIGH_OFFSET, + HIGH_OFFSET + bytes.length, + ); + expect(new TextDecoder().decode(written)).toBe("world"); + }); + + test("swjs_create_typed_array copies from a high-bit pointer", () => { + const { runtime, memory } = makeRuntime(); + new Uint8Array(memory.buffer).set([1, 2, 3, 4], HIGH_OFFSET); + + const space = (runtime as any).memory; + const constructorRef = space.retain(Uint8Array); + const imports = runtime.wasmImports as any; + const ref = imports.swjs_create_typed_array( + constructorRef, + SIGNED_POINTER, + 4, + ); + + expect(Array.from(space.getObject(ref))).toEqual([1, 2, 3, 4]); + }); + + test("decodeArray reads JSValue elements from a high-bit pointer", () => { + const { runtime, memory } = makeRuntime(); + const dataView = new DataView(memory.buffer); + dataView.setUint32(HIGH_OFFSET, Kind.Number, true); + dataView.setUint32(HIGH_OFFSET + 4, 0, true); + dataView.setFloat64(HIGH_OFFSET + 8, 42.5, true); + + const values = decodeArray( + SIGNED_POINTER, + 1, + dataView, + (runtime as any).memory, + ); + + expect(values).toEqual([42.5]); + }); + + test("decodeObjectRefs reads refs from a high-bit pointer", () => { + const { memory } = makeRuntime(); + const dataView = new DataView(memory.buffer); + dataView.setUint32(HIGH_OFFSET, 11, true); + dataView.setUint32(HIGH_OFFSET + 4, 22, true); + + expect(decodeObjectRefs(SIGNED_POINTER, 2, dataView)).toEqual([11, 22]); + }); + + test("write stores a JSValue at high-bit pointers", () => { + const { runtime, memory } = makeRuntime(); + const dataView = new DataView(memory.buffer); + + write( + 42.5, + SIGNED_POINTER, + SIGNED_POINTER + 4, + SIGNED_POINTER + 8, + false, + dataView, + (runtime as any).memory, + ); + + expect(dataView.getUint32(HIGH_OFFSET, true)).toBe(Kind.Number); + expect(dataView.getFloat64(HIGH_OFFSET + 8, true)).toBe(42.5); + }); +}); diff --git a/package.json b/package.json index 509cddde2..866b2bb6f 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "build:ts": "cd Runtime; rollup -c", "prepublishOnly": "npm run build", "format": "prettier --write Runtime/src", + "test:runtime": "vitest run Runtime/test", "check:bridgejs-dts": "tsc --project Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/tsconfig.json" }, "keywords": [ From 2fc75d460a7bf74ed259301dd54e34a363a6a392 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jun 2026 17:47:53 +0100 Subject: [PATCH 07/20] Bump actions/checkout from 6 to 7 (#770) Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 37e5bce78..1ce6ebe60 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,7 +35,7 @@ jobs: JAVASCRIPTKIT_WASI_BACKEND: ${{ matrix.entry.wasi-backend }} steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Export matrix env if: ${{ matrix.entry.env != '' && matrix.entry.env != null }} run: | @@ -79,7 +79,7 @@ jobs: container: image: ${{ matrix.entry.image }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Setup Node.js uses: actions/setup-node@v6 with: @@ -105,7 +105,7 @@ jobs: xcode: Xcode_26.0.1 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - run: swift build --product BridgeJSTool env: DEVELOPER_DIR: /Applications/${{ matrix.xcode }}.app/Contents/Developer/ @@ -116,7 +116,7 @@ jobs: prettier: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - uses: actions/setup-node@v6 with: node-version: '20' @@ -128,7 +128,7 @@ jobs: container: image: swift:6.3 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - run: ./Utilities/format.swift - name: Check for formatting changes run: | @@ -141,7 +141,7 @@ jobs: check-bridgejs-generated: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - uses: ./.github/actions/install-swift with: download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu22.04.tar.gz @@ -158,7 +158,7 @@ jobs: build-examples: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - uses: ./.github/actions/install-swift with: download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu22.04.tar.gz From 3c520b0c5ee690f2d441ea78aa3f3758d6f818f3 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Tue, 23 Jun 2026 12:52:28 +0200 Subject: [PATCH 08/20] BridgeJS: Emit static members in declare global class declarations The `declare global { namespace ... }` class stub rendered every method without `static` and filtered properties to instance-only, so a `@JS static func` on a namespaced class was typed as an instance method and a `@JS static var` was omitted from the generated `.d.ts`. This was a type-only defect: the emitted JavaScript already exposes these members statically (and the class's namespace export entry types them correctly), so only TypeScript consumers were affected. Split static and instance members in this path: emit static methods with `static` and include static properties. This has been incorrect since the global namespace class stub was introduced, not a regression. The `Namespaces.Global` snapshot already exercises a namespaced class with `static func`/`static var` but had recorded the wrong output, so it is updated to the corrected declarations. --- .../BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift | 12 +++++++----- .../BridgeJSLinkTests/Namespaces.Global.d.ts | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 8c9c20a14..01c390f26 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -3143,17 +3143,19 @@ extension BridgeJSLink { let sortedMethods = klass.methods.sorted { $0.name < $1.name } for method in sortedMethods { + let staticKeyword = method.effects.isStatic ? "static " : "" let methodSignature = - "\(method.name)\(renderTSSignatureCallback(method.parameters, method.returnType, method.effects));" + "\(staticKeyword)\(method.name)\(renderTSSignatureCallback(method.parameters, method.returnType, method.effects));" printer.write(methodSignature) } - let sortedProperties = klass.properties.filter { !$0.isStatic }.sorted { - $0.name < $1.name - } + let sortedProperties = klass.properties.sorted { $0.name < $1.name } for property in sortedProperties { + let staticKeyword = property.isStatic ? "static " : "" let readonly = property.isReadonly ? "readonly " : "" - printer.write("\(readonly)\(property.name): \(property.type.tsType);") + printer.write( + "\(staticKeyword)\(readonly)\(property.name): \(property.type.tsType);" + ) } printer.write("release(): void;") 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..d9af0c8eb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts @@ -34,7 +34,8 @@ declare global { class Greeter { constructor(name: string); greet(): string; - makeDefault(): Greeter; + static makeDefault(): Greeter; + static readonly defaultGreeting: string; release(): void; } class UUID { From 45088be53a11a96871a261e31bb753fe39bcddac Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Mon, 22 Jun 2026 17:24:51 +0200 Subject: [PATCH 09/20] BridgeJS: Include Swift doc comments in generated d.ts Propagate Swift `///` and `/** */` documentation on exported declarations into the generated TypeScript declarations as JSDoc, so editors surface hover docs for the bridged API. The exporter now captures the leading doc comment for functions, classes, methods, properties, constructors, structs, and enums into the skeleton, and the linker renders it as a single JSDoc block. The Swift DocC field list is mapped as the inverse of the TS2Swift importer: the leading description becomes the JSDoc body, `- Parameters:`/`- Parameter x:` become `@param`, `- Returns:` becomes `@returns`, and `- Throws:` becomes `@throws`. Existing default-value annotations are merged into the same block so a parameter never emits two comment blocks; declarations without doc comments produce byte-identical output to before. --- .../Generated/JavaScript/BridgeJS.json | 1 + .../BridgeJSCore/SwiftToSkeleton.swift | 84 +++- .../Sources/BridgeJSLink/BridgeJSLink.swift | 297 ++++++++++-- .../BridgeJSSkeleton/BridgeJSSkeleton.swift | 45 +- .../Inputs/MacroSwift/DocComments.swift | 91 ++++ .../Inputs/MacroSwift/Namespaces.swift | 5 + .../BridgeJSCodegenTests/DocComments.json | 436 ++++++++++++++++++ .../BridgeJSCodegenTests/DocComments.swift | 317 +++++++++++++ .../Namespaces.Global.json | 3 + .../BridgeJSCodegenTests/Namespaces.json | 3 + .../BridgeJSLinkTests/DocComments.d.ts | 140 ++++++ .../BridgeJSLinkTests/DocComments.js | 421 +++++++++++++++++ .../BridgeJSLinkTests/Namespaces.Global.d.ts | 22 + .../BridgeJSLinkTests/Namespaces.d.ts | 11 + 14 files changed, 1808 insertions(+), 68 deletions(-) create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/DocComments.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.js diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json index 6f1fc940c..c4a3a8c9d 100644 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json +++ b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json @@ -16,6 +16,7 @@ "methods" : [ { "abiName" : "bjs_PlayBridgeJS_updateDetailed", + "documentation" : "Structured entry point used by the playground so JS doesn't need to parse diagnostics.", "effects" : { "isAsync" : false, "isStatic" : false, diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index a6afe2779..ed7ebcd1b 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -1266,10 +1266,56 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { returnType: returnType, effects: effects, namespace: finalNamespace, - staticContext: staticContext + staticContext: staticContext, + documentation: extractDocumentation(from: node) ) } + /// Returns the doc comment (`///` or `/** */`) attached to a declaration, with + /// markers stripped and DocC field lists (`- Parameters:`, `- Returns:`) preserved. + private func extractDocumentation(from node: some SyntaxProtocol) -> String? { + var run: [String] = [] + for piece in node.leadingTrivia { + switch piece { + case .docLineComment(let text): + var line = Substring(text) + if line.hasPrefix("///") { line = line.dropFirst(3) } + if line.first == " " { line = line.dropFirst() } + if line.last == "\r" { line = line.dropLast() } + run.append(String(line)) + case .docBlockComment(let text): + run.append(contentsOf: stripBlockComment(text)) + case .newlines(let count), .carriageReturns(let count), .carriageReturnLineFeeds(let count): + if count >= 2 { run.removeAll() } + case .lineComment, .blockComment: + run.removeAll() + default: + continue + } + } + // Trim boundary blank lines so line (`///`) and block (`/** */`) comments + // produce a consistent skeleton value. + while run.first?.trimmingCharacters(in: .whitespaces).isEmpty == true { run.removeFirst() } + while run.last?.trimmingCharacters(in: .whitespaces).isEmpty == true { run.removeLast() } + return run.isEmpty ? nil : run.joined(separator: "\n") + } + + private func stripBlockComment(_ text: String) -> [String] { + var body = Substring(text) + if body.hasPrefix("/**") { body = body.dropFirst(3) } + if body.hasSuffix("*/") { body = body.dropLast(2) } + return body.split(separator: "\n", omittingEmptySubsequences: false).map { raw -> String in + var line = raw[...] + if line.last == "\r" { line = line.dropLast() } + while let first = line.first, first == " " || first == "\t" { line = line.dropFirst() } + if line.first == "*" { + line = line.dropFirst() + if line.first == " " { line = line.dropFirst() } + } + return String(line) + } + } + private func collectEffects(signature: FunctionSignatureSyntax, isStatic: Bool = false) -> Effects? { let isAsync = signature.effectSpecifiers?.asyncSpecifier != nil var isThrows = false @@ -1360,7 +1406,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { let constructor = ExportedConstructor( abiName: "bjs_\(classAbiName)_init", parameters: parameters, - effects: effects + effects: effects, + documentation: extractDocumentation(from: node) ) exportedClassByName[classKey]?.constructor = constructor @@ -1383,7 +1430,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { let constructor = ExportedConstructor( abiName: "bjs_\(structAbiName)_init", parameters: parameters, - effects: effects + effects: effects, + documentation: extractDocumentation(from: node) ) exportedStructByName[structKey]?.constructor = constructor @@ -1490,7 +1538,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { isReadonly: isReadonly, isStatic: isStatic, namespace: finalNamespace, - staticContext: staticContext + staticContext: staticContext, + documentation: extractDocumentation(from: node) ) if case .enumBody(_, let key) = state { @@ -1537,7 +1586,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { methods: [], properties: [], namespace: effectiveNamespace, - identityMode: classIdentityMode + identityMode: classIdentityMode, + documentation: extractDocumentation(from: node) ) let uniqueKey = makeKey(name: name, namespace: effectiveNamespace) @@ -1657,7 +1707,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { namespace: effectiveNamespace, emitStyle: emitStyle, staticMethods: [], - staticProperties: [] + staticProperties: [], + documentation: extractDocumentation(from: node) ) let enumUniqueKey = makeKey(name: name, namespace: effectiveNamespace) @@ -1774,7 +1825,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { name: name, methods: [], properties: [], - namespace: effectiveNamespace + namespace: effectiveNamespace, + documentation: extractDocumentation(from: node) ) stateStack.push(state: .protocolBody(name: name, key: protocolUniqueKey)) @@ -1798,7 +1850,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { name: name, methods: methods, properties: exportedProtocolByName[protocolUniqueKey]?.properties ?? [], - namespace: effectiveNamespace + namespace: effectiveNamespace, + documentation: extractDocumentation(from: node) ) exportedProtocolByName[protocolUniqueKey] = exportedProtocol @@ -1874,7 +1927,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { isReadonly: true, isStatic: false, namespace: effectiveNamespace, - staticContext: nil + staticContext: nil, + documentation: extractDocumentation(from: varDecl) ) properties.append(property) } @@ -1888,7 +1942,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { explicitAccessControl: explicitAccessControl, properties: properties, methods: [], - namespace: effectiveNamespace + namespace: effectiveNamespace, + documentation: extractDocumentation(from: node) ) exportedStructByName[structUniqueKey] = exportedStruct @@ -1981,7 +2036,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { returnType: returnType, effects: effects, namespace: namespace, - staticContext: nil + staticContext: nil, + documentation: extractDocumentation(from: node) ) } @@ -2022,7 +2078,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { let exportedProperty = ExportedProtocolProperty( name: propertyName, type: propertyType, - isReadonly: isReadonly + isReadonly: isReadonly, + documentation: extractDocumentation(from: node) ) if var currentProtocol = exportedProtocolByName[protocolKey] { @@ -2033,7 +2090,8 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { name: currentProtocol.name, methods: currentProtocol.methods, properties: properties, - namespace: currentProtocol.namespace + namespace: currentProtocol.namespace, + documentation: currentProtocol.documentation ) exportedProtocolByName[protocolKey] = currentProtocol } diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 01c390f26..a24fde09b 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -936,14 +936,19 @@ public struct BridgeJSLink { for skeleton in exportedSkeletons { for proto in skeleton.protocols { + printer.write(lines: renderJSDoc(documentation: proto.documentation, parameters: [])) printer.write("export interface \(proto.name) {") printer.indent { for method in proto.methods { + printer.write( + lines: renderJSDoc(documentation: method.documentation, parameters: method.parameters) + ) printer.write( "\(method.name)\(renderTSSignature(parameters: method.parameters, returnType: method.returnType, effects: method.effects));" ) } for property in proto.properties { + printer.write(lines: renderJSDoc(documentation: property.documentation, parameters: [])) let propertySignature = property.isReadonly ? "readonly \(property.name): \(resolveTypeScriptType(property.type));" @@ -977,12 +982,19 @@ public struct BridgeJSLink { printer.write("export type \(enumObjectName) = typeof \(fullEnumValuesPath) & {") printer.indent { for function in enumDefinition.staticMethods { + printer.write( + lines: renderJSDoc( + documentation: function.documentation, + parameters: function.parameters + ) + ) printer.write( "\(function.name)\(renderTSSignature(parameters: function.parameters, returnType: function.returnType, effects: function.effects));" ) } for property in enumDefinition.staticProperties { let readonly = property.isReadonly ? "readonly " : "" + printer.write(lines: renderJSDoc(documentation: property.documentation, parameters: [])) printer.write("\(readonly)\(property.name): \(resolveTypeScriptType(property.type));") } } @@ -999,6 +1011,9 @@ public struct BridgeJSLink { exportedSkeletons: exportedSkeletons, renderTSSignatureCallback: { parameters, returnType, effects in self.renderTSSignature(parameters: parameters, returnType: returnType, effects: effects) + }, + renderDocCallback: { documentation, parameters in + self.renderJSDoc(documentation: documentation, parameters: parameters) } ) printer.write(lines: namespaceDeclarationsLines) @@ -1014,8 +1029,16 @@ public struct BridgeJSLink { renderClassEntry: { klass in data.namespacedClassDtsExportEntries[klass.name] ?? [] }, - renderFunctionSignature: { function in - "\(function.name)\(self.renderTSSignature(parameters: function.parameters, returnType: function.returnType, effects: function.effects));" + renderFunctionEntry: { function in + self.renderJSDoc(documentation: function.documentation, parameters: function.parameters) + + [ + "\(function.name)\(self.renderTSSignature(parameters: function.parameters, returnType: function.returnType, effects: function.effects));" + ] + }, + renderPropertyEntry: { property in + let readonly = property.isReadonly ? "readonly " : "" + return self.renderJSDoc(documentation: property.documentation, parameters: []) + + ["\(readonly)\(property.name): \(property.type.tsType);"] } ) printer.write("export type Exports = {") @@ -1574,12 +1597,6 @@ public struct BridgeJSLink { .replacingOccurrences(of: "\"", with: "\\\"") } - /// Helper method to append JSDoc comments for parameters with default values - private func appendJSDocIfNeeded(for parameters: [Parameter], to lines: inout [String]) { - let jsDocLines = DefaultValueUtils.formatJSDoc(for: parameters) - lines.append(contentsOf: jsDocLines) - } - func renderExportedStruct( _ structDefinition: ExportedStruct ) throws -> (js: [String], dtsType: [String], dtsExportEntry: [String]) { @@ -1589,15 +1606,24 @@ public struct BridgeJSLink { let staticProperties = structDefinition.properties.filter { $0.isStatic } let dtsTypePrinter = CodeFragmentPrinter() + for line in renderJSDoc(documentation: structDefinition.documentation, parameters: []) { + dtsTypePrinter.write(line) + } dtsTypePrinter.write("export interface \(structName) {") let instanceProps = structDefinition.properties.filter { !$0.isStatic } dtsTypePrinter.indent { for property in instanceProps { let tsType = resolveTypeScriptType(property.type) + for line in renderJSDoc(documentation: property.documentation, parameters: []) { + dtsTypePrinter.write(line) + } dtsTypePrinter.write("\(property.name): \(tsType);") } for method in structDefinition.methods where !method.effects.isStatic { - let jsDocLines = DefaultValueUtils.formatJSDoc(for: method.parameters) + let jsDocLines = renderJSDoc( + documentation: method.documentation, + parameters: method.parameters + ) dtsTypePrinter.write(lines: jsDocLines) let signature = renderTSSignature( parameters: method.parameters, @@ -1659,7 +1685,10 @@ public struct BridgeJSLink { dtsExportEntryPrinter.write("\(structName): {") dtsExportEntryPrinter.indent { if let constructor = structDefinition.constructor { - let jsDocLines = DefaultValueUtils.formatJSDoc(for: constructor.parameters) + let jsDocLines = renderJSDoc( + documentation: constructor.documentation, + parameters: constructor.parameters + ) dtsExportEntryPrinter.write(lines: jsDocLines) dtsExportEntryPrinter.write( "init\(renderTSSignature(parameters: constructor.parameters, returnType: .swiftStruct(structDefinition.swiftCallName), effects: constructor.effects));" @@ -1667,10 +1696,16 @@ public struct BridgeJSLink { } for property in staticProperties { let readonly = property.isReadonly ? "readonly " : "" + for line in renderJSDoc(documentation: property.documentation, parameters: []) { + dtsExportEntryPrinter.write(line) + } dtsExportEntryPrinter.write("\(readonly)\(property.name): \(resolveTypeScriptType(property.type));") } for method in staticMethods { - let jsDocLines = DefaultValueUtils.formatJSDoc(for: method.parameters) + let jsDocLines = renderJSDoc( + documentation: method.documentation, + parameters: method.parameters + ) dtsExportEntryPrinter.write(lines: jsDocLines) dtsExportEntryPrinter.write( "\(method.name)\(renderTSSignature(parameters: method.parameters, returnType: method.returnType, effects: method.effects));" @@ -1770,6 +1805,10 @@ public struct BridgeJSLink { let printer = CodeFragmentPrinter() let enumValuesName = enumDefinition.valuesName + for line in renderJSDoc(documentation: enumDefinition.documentation, parameters: []) { + printer.write(line) + } + switch enumDefinition.emitStyle { case .tsEnum: switch enumDefinition.enumType { @@ -1883,7 +1922,7 @@ extension BridgeJSLink { ) var dtsLines: [String] = [] - appendJSDocIfNeeded(for: function.parameters, to: &dtsLines) + dtsLines.append(contentsOf: renderJSDoc(documentation: function.documentation, parameters: function.parameters)) dtsLines.append( "\(function.name)\(renderTSSignature(parameters: function.parameters, returnType: function.returnType, effects: function.effects));" @@ -1935,7 +1974,7 @@ extension BridgeJSLink { var dtsLines: [String] = [] - appendJSDocIfNeeded(for: function.parameters, to: &dtsLines) + dtsLines.append(contentsOf: renderJSDoc(documentation: function.documentation, parameters: function.parameters)) dtsLines.append( "static \(function.name)\(renderTSSignature(parameters: function.parameters, returnType: function.returnType, effects: function.effects));" @@ -1966,7 +2005,7 @@ extension BridgeJSLink { var dtsLines: [String] = [] - appendJSDocIfNeeded(for: function.parameters, to: &dtsLines) + dtsLines.append(contentsOf: renderJSDoc(documentation: function.documentation, parameters: function.parameters)) dtsLines.append( "\(function.name)\(renderTSSignature(parameters: function.parameters, returnType: function.returnType, effects: function.effects));" @@ -2082,6 +2121,9 @@ extension BridgeJSLink { let dtsTypePrinter = CodeFragmentPrinter() let dtsExportEntryPrinter = CodeFragmentPrinter() + for line in renderJSDoc(documentation: klass.documentation, parameters: []) { + dtsTypePrinter.write(line) + } dtsTypePrinter.write("export interface \(klass.name) extends SwiftHeapObject {") dtsExportEntryPrinter.write("\(klass.name): {") jsPrinter.write("class \(klass.name) extends SwiftHeapObject {") @@ -2134,7 +2176,10 @@ extension BridgeJSLink { } dtsExportEntryPrinter.indent { - let jsDocLines = DefaultValueUtils.formatJSDoc(for: constructor.parameters) + let jsDocLines = renderJSDoc( + documentation: constructor.documentation, + parameters: constructor.parameters + ) for line in jsDocLines { dtsExportEntryPrinter.write(line) } @@ -2167,6 +2212,12 @@ extension BridgeJSLink { } dtsExportEntryPrinter.indent { + for line in renderJSDoc( + documentation: method.documentation, + parameters: method.parameters + ) { + dtsExportEntryPrinter.write(line) + } dtsExportEntryPrinter.write( "\(method.name)\(renderTSSignature(parameters: method.parameters, returnType: method.returnType, effects: method.effects));" ) @@ -2194,6 +2245,12 @@ extension BridgeJSLink { } dtsTypePrinter.indent { + for line in renderJSDoc( + documentation: method.documentation, + parameters: method.parameters + ) { + dtsTypePrinter.write(line) + } dtsTypePrinter.write( "\(method.name)\(renderTSSignature(parameters: method.parameters, returnType: method.returnType, effects: method.effects));" ) @@ -2281,6 +2338,9 @@ extension BridgeJSLink { // Add instance property to TypeScript interface definition let readonly = property.isReadonly ? "readonly " : "" dtsPrinter.indent { + for line in renderJSDoc(documentation: property.documentation, parameters: []) { + dtsPrinter.write(line) + } dtsPrinter.write("\(readonly)\(property.name): \(property.type.tsType);") } } @@ -2708,6 +2768,7 @@ extension BridgeJSLink { var functionDtsLines: [(name: String, lines: [String])] = [] var classDtsLines: [(name: String, lines: [String])] = [] var enumDtsLines: [(name: String, line: String)] = [] + var staticPropertyDtsLines: [(name: String, lines: [String])] = [] var propertyJsLines: [String] = [] } @@ -2791,7 +2852,8 @@ extension BridgeJSLink { fileprivate func buildHierarchicalExportsType( exportedSkeletons: [ExportedSkeleton], renderClassEntry: (ExportedClass) -> [String], - renderFunctionSignature: (ExportedFunction) -> String + renderFunctionEntry: (ExportedFunction) -> [String], + renderPropertyEntry: (ExportedProperty) -> [String] ) -> [String] { let printer = CodeFragmentPrinter() let rootNode = NamespaceNode(name: "") @@ -2802,7 +2864,8 @@ extension BridgeJSLink { populateTypeScriptExportLines( node: node, renderClassEntry: renderClassEntry, - renderFunctionSignature: renderFunctionSignature + renderFunctionEntry: renderFunctionEntry, + renderPropertyEntry: renderPropertyEntry ) } @@ -2814,11 +2877,11 @@ extension BridgeJSLink { private func populateTypeScriptExportLines( node: NamespaceNode, renderClassEntry: (ExportedClass) -> [String], - renderFunctionSignature: (ExportedFunction) -> String + renderFunctionEntry: (ExportedFunction) -> [String], + renderPropertyEntry: (ExportedProperty) -> [String] ) { for function in node.content.functions { - let signature = renderFunctionSignature(function) - node.content.functionDtsLines.append((function.name, [signature])) + node.content.functionDtsLines.append((function.name, renderFunctionEntry(function))) } for klass in node.content.classes { @@ -2826,6 +2889,10 @@ extension BridgeJSLink { node.content.classDtsLines.append((klass.name, entry)) } + for property in node.content.staticProperties { + node.content.staticPropertyDtsLines.append((property.name, renderPropertyEntry(property))) + } + for enumDef in node.content.enums { node.content.enumDtsLines.append((enumDef.name, "\(enumDef.name): \(enumDef.objectTypeName)")) } @@ -2834,7 +2901,8 @@ extension BridgeJSLink { populateTypeScriptExportLines( node: childNode, renderClassEntry: renderClassEntry, - renderFunctionSignature: renderFunctionSignature + renderFunctionEntry: renderFunctionEntry, + renderPropertyEntry: renderPropertyEntry ) } } @@ -2962,9 +3030,8 @@ extension BridgeJSLink { printer.write(line) } - for property in childNode.content.staticProperties.sorted(by: { $0.name < $1.name }) { - let readonly = property.isReadonly ? "readonly " : "" - printer.write("\(readonly)\(property.name): \(property.type.tsType);") + for (_, lines) in childNode.content.staticPropertyDtsLines.sorted(by: { $0.name < $1.name }) { + printer.write(lines: lines) } for (_, lines) in childNode.content.functionDtsLines.sorted(by: { $0.name < $1.name }) { @@ -3030,7 +3097,8 @@ extension BridgeJSLink { /// - Returns: Array of TypeScript declaration lines defining the global namespace structure func namespaceDeclarations( exportedSkeletons: [ExportedSkeleton], - renderTSSignatureCallback: @escaping ([Parameter], BridgeType, Effects) -> String + renderTSSignatureCallback: @escaping ([Parameter], BridgeType, Effects) -> String, + renderDocCallback: @escaping (String?, [Parameter]) -> [String] ) -> [String] { let printer = CodeFragmentPrinter() @@ -3052,7 +3120,8 @@ extension BridgeJSLink { printer: printer, exposeToGlobal: true, exportedSkeletons: exportedSkeletons, - renderTSSignatureCallback: renderTSSignatureCallback + renderTSSignatureCallback: renderTSSignatureCallback, + renderDocCallback: renderDocCallback ) printer.unindent() printer.write("}") @@ -3071,7 +3140,8 @@ extension BridgeJSLink { printer: printer, exposeToGlobal: false, exportedSkeletons: exportedSkeletons, - renderTSSignatureCallback: renderTSSignatureCallback + renderTSSignatureCallback: renderTSSignatureCallback, + renderDocCallback: renderDocCallback ) } } @@ -3085,7 +3155,8 @@ extension BridgeJSLink { printer: CodeFragmentPrinter, exposeToGlobal: Bool, exportedSkeletons: [ExportedSkeleton], - renderTSSignatureCallback: @escaping ([Parameter], BridgeType, Effects) -> String + renderTSSignatureCallback: @escaping ([Parameter], BridgeType, Effects) -> String, + renderDocCallback: @escaping (String?, [Parameter]) -> [String] ) { func hasContent(node: NamespaceNode) -> Bool { // Enums and structs are always included @@ -3129,6 +3200,7 @@ extension BridgeJSLink { if exposeToGlobal { let sortedClasses = childNode.content.classes.sorted { $0.name < $1.name } for klass in sortedClasses { + printer.write(lines: renderDocCallback(klass.documentation, [])) printer.write("class \(klass.name) {") printer.indent { if let constructor = klass.constructor { @@ -3138,6 +3210,9 @@ extension BridgeJSLink { } let constructorSignature = "constructor(\(paramSignatures.joined(separator: ", ")));" + printer.write( + lines: renderDocCallback(constructor.documentation, constructor.parameters) + ) printer.write(constructorSignature) } @@ -3146,6 +3221,7 @@ extension BridgeJSLink { let staticKeyword = method.effects.isStatic ? "static " : "" let methodSignature = "\(staticKeyword)\(method.name)\(renderTSSignatureCallback(method.parameters, method.returnType, method.effects));" + printer.write(lines: renderDocCallback(method.documentation, method.parameters)) printer.write(methodSignature) } @@ -3153,6 +3229,7 @@ extension BridgeJSLink { for property in sortedProperties { let staticKeyword = property.isStatic ? "static " : "" let readonly = property.isReadonly ? "readonly " : "" + printer.write(lines: renderDocCallback(property.documentation, [])) printer.write( "\(staticKeyword)\(readonly)\(property.name): \(property.type.tsType);" ) @@ -3167,6 +3244,7 @@ extension BridgeJSLink { // Generate enum definitions within declare global namespace let sortedEnums = childNode.content.enums.sorted { $0.name < $1.name } for enumDefinition in sortedEnums { + printer.write(lines: renderDocCallback(enumDefinition.documentation, [])) let style: EnumEmitStyle = enumDefinition.emitStyle let enumValuesName = enumDefinition.valuesName switch enumDefinition.enumType { @@ -3275,6 +3353,7 @@ extension BridgeJSLink { let sortedStructs = childNode.content.structs.sorted { $0.name < $1.name } for structDef in sortedStructs { let instanceProps = structDef.properties.filter { !$0.isStatic } + printer.write(lines: renderDocCallback(structDef.documentation, [])) printer.write("export interface \(structDef.name) {") printer.indent { for property in instanceProps { @@ -3282,6 +3361,7 @@ extension BridgeJSLink { property.type, exportedSkeletons: exportedSkeletons ) + printer.write(lines: renderDocCallback(property.documentation, [])) printer.write("\(property.name): \(tsType);") } } @@ -3294,11 +3374,13 @@ extension BridgeJSLink { for function in sortedFunctions { let signature = "function \(function.name)\(renderTSSignatureCallback(function.parameters, function.returnType, function.effects));" + printer.write(lines: renderDocCallback(function.documentation, function.parameters)) printer.write(signature) } let sortedProperties = childNode.content.staticProperties.sorted { $0.name < $1.name } for property in sortedProperties { let readonly = property.isReadonly ? "var " : "let " + printer.write(lines: renderDocCallback(property.documentation, [])) printer.write("\(readonly)\(property.name): \(property.type.tsType);") } } @@ -3309,7 +3391,8 @@ extension BridgeJSLink { printer: printer, exposeToGlobal: exposeToGlobal, exportedSkeletons: exportedSkeletons, - renderTSSignatureCallback: renderTSSignatureCallback + renderTSSignatureCallback: renderTSSignatureCallback, + renderDocCallback: renderDocCallback ) printer.unindent() @@ -3668,24 +3751,6 @@ enum DefaultValueUtils { .replacingOccurrences(of: "\"", with: "\\\"") } - /// Generates JSDoc comment lines for parameters with default values - static func formatJSDoc(for parameters: [Parameter]) -> [String] { - let paramsWithDefaults = parameters.filter { $0.hasDefault } - guard !paramsWithDefaults.isEmpty else { - return [] - } - - var jsDocLines: [String] = ["/**"] - for param in paramsWithDefaults { - if let defaultValue = param.defaultValue { - let defaultDoc = format(defaultValue, as: .typescript) - jsDocLines.append(" * @param \(param.name) - Optional parameter (default: \(defaultDoc))") - } - } - jsDocLines.append(" */") - return jsDocLines - } - /// Generates a JavaScript parameter list with default values static func formatParameterList(_ parameters: [Parameter]) -> String { return parameters.map { param in @@ -3698,6 +3763,144 @@ enum DefaultValueUtils { } } +extension BridgeJSLink { + /// Renders the JSDoc block for an exported declaration, mapping the Swift DocC + /// comment to `@param`/`@returns`/`@throws` and merging any default-value notes. + /// Returns an empty array when there is nothing to document. + fileprivate func renderJSDoc(documentation: String?, parameters: [Parameter]) -> [String] { + let parsed = documentation.map(DocCComment.init(parsing:)) ?? DocCComment() + + var tagLines: [String] = [] + for parameter in parameters { + let docText = parsed.parameter(named: parameter.name) + let defaultValue = parameter.defaultValue.map { DefaultValueUtils.format($0, as: .typescript) } + switch (docText, defaultValue) { + case let (.some(text), .some(value)): + tagLines.append("@param \(parameter.name) \(text) (default: \(value))") + case let (.some(text), .none): + tagLines.append("@param \(parameter.name) \(text)") + case let (.none, .some(value)): + tagLines.append("@param \(parameter.name) - Optional parameter (default: \(value))") + case (.none, .none): + continue + } + } + if let returns = parsed.returns { + tagLines.append(returns.isEmpty ? "@returns" : "@returns \(returns)") + } + if let thrown = parsed.throws { + tagLines.append(thrown.isEmpty ? "@throws" : "@throws \(thrown)") + } + + guard !parsed.description.isEmpty || !tagLines.isEmpty else { return [] } + + // `*/` in the doc text would prematurely close the JSDoc block comment. + func escape(_ text: String) -> String { text.replacingOccurrences(of: "*/", with: "*\\/") } + + var lines: [String] = ["/**"] + lines.append(contentsOf: parsed.description.map { $0.isEmpty ? " *" : " * \(escape($0))" }) + lines.append(contentsOf: tagLines.map { " * \(escape($0))" }) + lines.append(" */") + return lines + } +} + +/// A parsed Swift DocC comment: a description block plus its `- Parameters:`, +/// `- Returns:`, and `- Throws:` field items. +private struct DocCComment { + var description: [String] = [] + var parameters: [(name: String, text: String)] = [] + var returns: String? + var `throws`: String? + + init() {} + + init(parsing text: String) { + enum Target { case description, parameter(Int), returns, `throws`, none } + var target: Target = .description + + func append(continuation line: String) { + let trimmed = line.trimmingCharacters(in: .whitespaces) + switch target { + case .description: description.append(line) + case .parameter(let index) where !trimmed.isEmpty: parameters[index].text += " \(trimmed)" + case .returns where !trimmed.isEmpty: returns = [returns, trimmed].compactMap { $0 }.joined(separator: " ") + case .throws where !trimmed.isEmpty: + `throws` = [`throws`, trimmed].compactMap { $0 }.joined(separator: " ") + default: return + } + } + + func addParameter(_ name: String, _ desc: String) { + parameters.append((name: name, text: desc)) + target = .parameter(parameters.count - 1) + } + + func isInParameterList(_ target: Target) -> Bool { + switch target { + case .none, .parameter: return true + default: return false + } + } + + for rawLine in text.split(separator: "\n", omittingEmptySubsequences: false).map(String.init) { + let trimmed = rawLine.trimmingCharacters(in: .whitespaces) + if trimmed == "- Parameters:" { + target = .none + } else if let (name, desc) = Self.listItem(trimmed, keyword: "Parameter") { + addParameter(name, desc) + } else if let desc = Self.field(trimmed, keyword: "Returns") { + returns = desc + target = .returns + } else if let desc = Self.field(trimmed, keyword: "Throws") { + `throws` = desc + target = .throws + } else if isInParameterList(target), let (name, desc) = Self.bareItem(trimmed) { + addParameter(name, desc) + } else { + append(continuation: rawLine) + } + } + + while description.first?.trimmingCharacters(in: .whitespaces).isEmpty == true { description.removeFirst() } + while description.last?.trimmingCharacters(in: .whitespaces).isEmpty == true { description.removeLast() } + } + + func parameter(named name: String) -> String? { + parameters.first { $0.name == name }?.text + } + + /// Matches `- Keyword name: description`. + private static func listItem(_ line: String, keyword: String) -> (String, String)? { + guard line.hasPrefix("- \(keyword) ") else { return nil } + return splitNameAndDescription(String(line.dropFirst("- \(keyword) ".count))) + } + + /// Matches `- name: description` (a sub-item of a `- Parameters:` block). + private static func bareItem(_ line: String) -> (String, String)? { + guard line.hasPrefix("- ") else { return nil } + guard let (name, desc) = splitNameAndDescription(String(line.dropFirst(2))), !name.contains(" ") else { + return nil + } + return (name, desc) + } + + /// Matches `- Keyword: description`, returning the (possibly empty) description. + private static func field(_ line: String, keyword: String) -> String? { + if line.hasPrefix("- \(keyword): ") { + return String(line.dropFirst("- \(keyword): ".count)).trimmingCharacters(in: .whitespaces) + } + return line == "- \(keyword):" ? "" : nil + } + + private static func splitNameAndDescription(_ rest: String) -> (String, String)? { + guard let colon = rest.firstIndex(of: ":") else { return nil } + let name = String(rest[.. String { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/DocComments.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/DocComments.swift new file mode 100644 index 000000000..8cdc72d4d --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/DocComments.swift @@ -0,0 +1,91 @@ +/// Returns a greeting for a user. +/// - Parameters: +/// - name: The user's name. +/// - greeting: The greeting word to use. +/// - Returns: The composed greeting message. +@JS func greet(name: String, greeting: String = "Hello") -> String { + return "\(greeting), \(name)!" +} + +/// Adds two numbers together. +/// - Parameter a: The first addend. +/// - Parameter b: The second addend. +/// - Returns: The sum of the inputs. +@JS func add(a: Int, b: Int) -> Int { a + b } + +/// +/// Has blank doc lines around the summary; boundaries should be trimmed. +/// +@JS func trimmed() {} + +/** + * Says hello to the world. + * + * Demonstrates that block doc comments are supported too. + */ +@JS func hello() {} + +/// Parses an integer from text. +/// - Parameter text: The text to parse. +/// - Returns: The parsed integer. +/// - Throws: A `JSException` when the text is not a valid integer. +@JS func parseInt(text: String) throws(JSException) -> Int { 0 } + +/// A greeter that keeps the target name. +@JS class Greeter { + /// The configured name. + @JS var name: String + + /// Create a greeter. + /// - Parameter name: The name to greet. + @JS init(name: String) { + self.name = name + } + + /// Returns a greeting for the configured name. + /// - Returns: The greeting message. + @JS func greet() -> String { + return "Hello, " + self.name + "!" + } +} + +/// A 2D point in space. +@JS struct Point { + /// The horizontal position. + let x: Double + /// The vertical position. + let y: Double +} + +/// A primary color channel. +@JS enum Color { + case red + case green + case blue + + /// The default channel. + @JS static var fallback: String { "red" } + + /// Returns the canonical name for a channel label. + /// - Parameter label: The raw label. + /// - Returns: The canonical channel name. + @JS static func canonical(label: String) -> String { label } +} + +/// Receives lifecycle callbacks. +@JS protocol Listener { + /// The listener's display name. + var name: String { get } + + /// Called when an event fires. + /// - Parameter id: The event identifier. + func onEvent(id: Int) +} + +/// Doubles a value, in a namespace. +/// - Parameter value: The value to double. +/// - Returns: Twice the input. +@JS(namespace: "MathUtils") func double(value: Int) -> Int { value * 2 } + +/// Returns the JSDoc terminator */ embedded mid-sentence. +@JS func terminator() -> String { "*/" } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Namespaces.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Namespaces.swift index 7cd63c698..7ad3037b9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Namespaces.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Namespaces.swift @@ -1,7 +1,10 @@ @JS func plainFunction() -> String { "plain" } +/// A namespaced free function. +/// - Returns: A fixed namespaced string. @JS(namespace: "MyModule.Utils") func namespacedFunction() -> String { "namespaced" } +/// A greeter living in a namespace. @JS(namespace: "__Swift.Foundation") class Greeter { var name: String @@ -9,6 +12,8 @@ self.name = name } + /// Produces a greeting for the configured name. + /// - Returns: The greeting message. @JS func greet() -> String { return "Hello, " + self.name + "!" } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.json new file mode 100644 index 000000000..c69fca509 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.json @@ -0,0 +1,436 @@ +{ + "exported" : { + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_Greeter_init", + "documentation" : "Create a greeter.\n- Parameter name: The name to greet.", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ] + }, + "documentation" : "A greeter that keeps the target name.", + "methods" : [ + { + "abiName" : "bjs_Greeter_greet", + "documentation" : "Returns a greeting for the configured name.\n- Returns: The greeting message.", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "greet", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "Greeter", + "properties" : [ + { + "documentation" : "The configured name.", + "isReadonly" : false, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "Greeter" + } + ], + "enums" : [ + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "red" + }, + { + "associatedValues" : [ + + ], + "name" : "green" + }, + { + "associatedValues" : [ + + ], + "name" : "blue" + } + ], + "documentation" : "A primary color channel.", + "emitStyle" : "const", + "name" : "Color", + "staticMethods" : [ + { + "abiName" : "bjs_Color_static_canonical", + "documentation" : "Returns the canonical name for a channel label.\n- Parameter label: The raw label.\n- Returns: The canonical channel name.", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "canonical", + "parameters" : [ + { + "label" : "label", + "name" : "label", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + }, + "staticContext" : { + "enumName" : { + "_0" : "Color" + } + } + } + ], + "staticProperties" : [ + { + "documentation" : "The default channel.", + "isReadonly" : true, + "isStatic" : true, + "name" : "fallback", + "staticContext" : { + "enumName" : { + "_0" : "Color" + } + }, + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "Color", + "tsFullPath" : "Color" + } + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_greet", + "documentation" : "Returns a greeting for a user.\n- Parameters:\n - name: The user's name.\n - greeting: The greeting word to use.\n- Returns: The composed greeting message.", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "greet", + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "defaultValue" : { + "string" : { + "_0" : "Hello" + } + }, + "label" : "greeting", + "name" : "greeting", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_add", + "documentation" : "Adds two numbers together.\n- Parameter a: The first addend.\n- Parameter b: The second addend.\n- Returns: The sum of the inputs.", + "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" + } + } + } + }, + { + "abiName" : "bjs_trimmed", + "documentation" : "Has blank doc lines around the summary; boundaries should be trimmed.", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "trimmed", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_hello", + "documentation" : "Says hello to the world.\n\nDemonstrates that block doc comments are supported too.", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "hello", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, + { + "abiName" : "bjs_parseInt", + "documentation" : "Parses an integer from text.\n- Parameter text: The text to parse.\n- Returns: The parsed integer.\n- Throws: A `JSException` when the text is not a valid integer.", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "parseInt", + "parameters" : [ + { + "label" : "text", + "name" : "text", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_MathUtils_double", + "documentation" : "Doubles a value, in a namespace.\n- Parameter value: The value to double.\n- Returns: Twice the input.", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "double", + "namespace" : [ + "MathUtils" + ], + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_terminator", + "documentation" : "Returns the JSDoc terminator *\/ embedded mid-sentence.", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "terminator", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "protocols" : [ + { + "documentation" : "Receives lifecycle callbacks.", + "methods" : [ + { + "abiName" : "bjs_Listener_onEvent", + "documentation" : "Called when an event fires.\n- Parameter id: The event identifier.", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "onEvent", + "parameters" : [ + { + "label" : "id", + "name" : "id", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + } + ], + "name" : "Listener", + "properties" : [ + { + "documentation" : "The listener's display name.", + "isReadonly" : true, + "name" : "name", + "type" : { + "string" : { + + } + } + } + ] + } + ], + "structs" : [ + { + "documentation" : "A 2D point in space.", + "methods" : [ + + ], + "name" : "Point", + "properties" : [ + { + "documentation" : "The horizontal position.", + "isReadonly" : true, + "isStatic" : false, + "name" : "x", + "type" : { + "double" : { + + } + } + }, + { + "documentation" : "The vertical position.", + "isReadonly" : true, + "isStatic" : false, + "name" : "y", + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "Point" + } + ] + }, + "moduleName" : "TestModule", + "usedExternalModules" : [ + + ] +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.swift new file mode 100644 index 000000000..eaed9e413 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.swift @@ -0,0 +1,317 @@ +struct AnyListener: Listener, _BridgedSwiftProtocolWrapper { + let jsObject: JSObject + + func onEvent(id: Int) -> Void { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let idValue = id.bridgeJSLowerParameter() + _extern_onEvent(jsObjectValue, idValue) + } + + var name: String { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = bjs_Listener_name_get(jsObjectValue) + return String.bridgeJSLiftReturn(ret) + } + } + + static func bridgeJSLiftParameter(_ value: Int32) -> Self { + return AnyListener(jsObject: JSObject(id: UInt32(bitPattern: value))) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Listener_onEvent") +fileprivate func _extern_onEvent_extern(_ jsObject: Int32, _ id: Int32) -> Void +#else +fileprivate func _extern_onEvent_extern(_ jsObject: Int32, _ id: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _extern_onEvent(_ jsObject: Int32, _ id: Int32) -> Void { + return _extern_onEvent_extern(jsObject, id) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Listener_name_get") +fileprivate func bjs_Listener_name_get_extern(_ jsObject: Int32) -> Int32 +#else +fileprivate func bjs_Listener_name_get_extern(_ jsObject: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Listener_name_get(_ jsObject: Int32) -> Int32 { + return bjs_Listener_name_get_extern(jsObject) +} + +extension Color: _BridgedSwiftCaseEnum { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { + return bridgeJSRawValue + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Color { + return bridgeJSLiftParameter(value) + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Color { + return Color(bridgeJSRawValue: value)! + } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { + return bridgeJSLowerParameter() + } + + @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .red + case 1: + self = .green + case 2: + self = .blue + default: + return nil + } + } + + @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { + switch self { + case .red: + return 0 + case .green: + return 1 + case .blue: + return 2 + } + } +} + +@_expose(wasm, "bjs_Color_static_canonical") +@_cdecl("bjs_Color_static_canonical") +public func _bjs_Color_static_canonical(_ labelBytes: Int32, _ labelLength: Int32) -> Void { + #if arch(wasm32) + let ret = Color.canonical(label: String.bridgeJSLiftParameter(labelBytes, labelLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Color_static_fallback_get") +@_cdecl("bjs_Color_static_fallback_get") +public func _bjs_Color_static_fallback_get() -> Void { + #if arch(wasm32) + let ret = Color.fallback + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Point: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Point { + let y = Double.bridgeJSStackPop() + let x = Double.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() +} + +@_expose(wasm, "bjs_greet") +@_cdecl("bjs_greet") +public func _bjs_greet(_ nameBytes: Int32, _ nameLength: Int32, _ greetingBytes: Int32, _ greetingLength: Int32) -> Void { + #if arch(wasm32) + let ret = greet(name: String.bridgeJSLiftParameter(nameBytes, nameLength), greeting: String.bridgeJSLiftParameter(greetingBytes, greetingLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_add") +@_cdecl("bjs_add") +public func _bjs_add(_ a: Int32, _ b: Int32) -> Int32 { + #if arch(wasm32) + let ret = add(a: Int.bridgeJSLiftParameter(a), b: Int.bridgeJSLiftParameter(b)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_trimmed") +@_cdecl("bjs_trimmed") +public func _bjs_trimmed() -> Void { + #if arch(wasm32) + trimmed() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_hello") +@_cdecl("bjs_hello") +public func _bjs_hello() -> Void { + #if arch(wasm32) + hello() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_parseInt") +@_cdecl("bjs_parseInt") +public func _bjs_parseInt(_ textBytes: Int32, _ textLength: Int32) -> Int32 { + #if arch(wasm32) + do { + let ret = try parseInt(text: String.bridgeJSLiftParameter(textBytes, textLength)) + 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: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_MathUtils_double") +@_cdecl("bjs_MathUtils_double") +public func _bjs_MathUtils_double(_ value: Int32) -> Int32 { + #if arch(wasm32) + let ret = double(value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_terminator") +@_cdecl("bjs_terminator") +public func _bjs_terminator() -> Void { + #if arch(wasm32) + let ret = terminator() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_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_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_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 { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Greeter_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_Greeter_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", 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) +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.Global.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.Global.json index 4b6b720f1..ef9e0b758 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.Global.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.Global.json @@ -21,9 +21,11 @@ } ] }, + "documentation" : "A greeter living in a namespace.", "methods" : [ { "abiName" : "bjs___Swift_Foundation_Greeter_greet", + "documentation" : "Produces a greeting for the configured name.\n- Returns: The greeting message.", "effects" : { "isAsync" : false, "isStatic" : false, @@ -262,6 +264,7 @@ }, { "abiName" : "bjs_MyModule_Utils_namespacedFunction", + "documentation" : "A namespaced free function.\n- Returns: A fixed namespaced string.", "effects" : { "isAsync" : false, "isStatic" : false, diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.json index 3c07b7dcf..397d1123c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.json @@ -21,9 +21,11 @@ } ] }, + "documentation" : "A greeter living in a namespace.", "methods" : [ { "abiName" : "bjs___Swift_Foundation_Greeter_greet", + "documentation" : "Produces a greeting for the configured name.\n- Returns: The greeting message.", "effects" : { "isAsync" : false, "isStatic" : false, @@ -262,6 +264,7 @@ }, { "abiName" : "bjs_MyModule_Utils_namespacedFunction", + "documentation" : "A namespaced free function.\n- Returns: A fixed namespaced string.", "effects" : { "isAsync" : false, "isStatic" : false, diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.d.ts new file mode 100644 index 000000000..359d719d1 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.d.ts @@ -0,0 +1,140 @@ +// 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`. + +/** + * Receives lifecycle callbacks. + */ +export interface Listener { + /** + * Called when an event fires. + * @param id The event identifier. + */ + onEvent(id: number): void; + /** + * The listener's display name. + */ + readonly name: string; +} + +/** + * A primary color channel. + */ +export const ColorValues: { + readonly Red: 0; + readonly Green: 1; + readonly Blue: 2; +}; +export type ColorTag = typeof ColorValues[keyof typeof ColorValues]; + +/** + * A 2D point in space. + */ +export interface Point { + /** + * The horizontal position. + */ + x: number; + /** + * The vertical position. + */ + y: number; +} +export type ColorObject = typeof ColorValues & { + /** + * Returns the canonical name for a channel label. + * @param label The raw label. + * @returns The canonical channel name. + */ + canonical(label: string): string; + /** + * The default channel. + */ + readonly fallback: string; +}; + +/// 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; +} +/** + * A greeter that keeps the target name. + */ +export interface Greeter extends SwiftHeapObject { + /** + * Returns a greeting for the configured name. + * @returns The greeting message. + */ + greet(): string; + /** + * The configured name. + */ + name: string; +} +export type Exports = { + Greeter: { + /** + * Create a greeter. + * @param name The name to greet. + */ + new(name: string): Greeter; + } + /** + * Returns a greeting for a user. + * @param name The user's name. + * @param greeting The greeting word to use. (default: "Hello") + * @returns The composed greeting message. + */ + greet(name: string, greeting?: string): string; + /** + * Adds two numbers together. + * @param a The first addend. + * @param b The second addend. + * @returns The sum of the inputs. + */ + add(a: number, b: number): number; + /** + * Has blank doc lines around the summary; boundaries should be trimmed. + */ + trimmed(): void; + /** + * Says hello to the world. + * + * Demonstrates that block doc comments are supported too. + */ + hello(): void; + /** + * Parses an integer from text. + * @param text The text to parse. + * @returns The parsed integer. + * @throws A `JSException` when the text is not a valid integer. + */ + parseInt(text: string): number; + /** + * Returns the JSDoc terminator *\/ embedded mid-sentence. + */ + terminator(): string; + Color: ColorObject + MathUtils: { + /** + * Doubles a value, in a namespace. + * @param value The value to double. + * @returns Twice the input. + */ + double(value: number): number; + }, +} +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/DocComments.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.js new file mode 100644 index 000000000..07e8673bf --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.js @@ -0,0 +1,421 @@ +// 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 const ColorValues = { + Red: 0, + Green: 1, + Blue: 2, +}; + +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 = []; + let taStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + const __bjs_createPointHelpers = () => ({ + lower: (value) => { + f64Stack.push(value.x); + f64Stack.push(value.y); + }, + lift: () => { + const f64 = f64Stack.pop(); + const f641 = f64Stack.pop(); + return { x: f641, y: f64 }; + } + }); + + 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 >>> 0); + 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 >>> 0, len >>> 0); + 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(); + } + const taCtors = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; + bjs["swift_js_push_typed_array"] = function(kind, ptr, count) { + const Ctor = taCtors[kind]; + const byteLen = count * Ctor.BYTES_PER_ELEMENT; + const copy = memory.buffer.slice(ptr, ptr + byteLen); + taStack.push(Array.from(new Ctor(copy))); + } + bjs["swift_js_struct_lower_Point"] = function(objectId) { + structHelpers.Point.lower(swift.memory.getObject(objectId)); + } + bjs["swift_js_struct_lift_Point"] = function() { + const value = structHelpers.Point.lift(); + return swift.memory.retain(value); + } + const __bjs_promiseSettlers = Symbol("JavaScriptKit.promiseSettlers"); + bjs["swift_js_make_promise"] = function() { + let resolve, reject; + const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); + promise[__bjs_promiseSettlers] = { resolve, reject }; + return swift.memory.retain(promise); + } + 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_Greeter_wrap"] = function(pointer) { + const obj = _exports['Greeter'].__construct(pointer); + return swift.memory.retain(obj); + }; + const TestModule = importObject["TestModule"] = importObject["TestModule"] || {}; + TestModule["bjs_Listener_name_get"] = function bjs_Listener_name_get(self) { + try { + let ret = swift.memory.getObject(self).name; + tmpRetBytes = textEncoder.encode(ret); + return tmpRetBytes.length; + } catch (error) { + setException(error); + } + } + TestModule["bjs_Listener_onEvent"] = function bjs_Listener_onEvent(self, id) { + try { + swift.memory.getObject(self).onEvent(id); + } catch (error) { + setException(error); + } + } + }, + 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) { + pointer = pointer >>> 0; + 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 Greeter extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Greeter_deinit, Greeter.prototype, null); + } + + constructor(name) { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + const ret = instance.exports.bjs_Greeter_init(nameId, nameBytes.length); + return Greeter.__construct(ret); + } + greet() { + instance.exports.bjs_Greeter_greet(this.pointer); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + } + get name() { + instance.exports.bjs_Greeter_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_Greeter_name_set(this.pointer, valueId, valueBytes.length); + } + } + const PointHelpers = __bjs_createPointHelpers(); + structHelpers.Point = PointHelpers; + + const exports = { + Greeter, + greet: function bjs_greet(name, greeting = "Hello") { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + const greetingBytes = textEncoder.encode(greeting); + const greetingId = swift.memory.retain(greetingBytes); + instance.exports.bjs_greet(nameId, nameBytes.length, greetingId, greetingBytes.length); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + }, + add: function bjs_add(a, b) { + const ret = instance.exports.bjs_add(a, b); + return ret; + }, + trimmed: function bjs_trimmed() { + instance.exports.bjs_trimmed(); + }, + hello: function bjs_hello() { + instance.exports.bjs_hello(); + }, + parseInt: function bjs_parseInt(text) { + const textBytes = textEncoder.encode(text); + const textId = swift.memory.retain(textBytes); + const ret = instance.exports.bjs_parseInt(textId, textBytes.length); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + return ret; + }, + terminator: function bjs_terminator() { + instance.exports.bjs_terminator(); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + }, + Color: { + ...ColorValues, + canonical: function(label) { + const labelBytes = textEncoder.encode(label); + const labelId = swift.memory.retain(labelBytes); + instance.exports.bjs_Color_static_canonical(labelId, labelBytes.length); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + }, + get fallback() { + instance.exports.bjs_Color_static_fallback_get(); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + } + }, + MathUtils: { + double: function bjs_MathUtils_double(value) { + const ret = instance.exports.bjs_MathUtils_double(value); + return ret; + }, + }, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file 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 d9af0c8eb..ae792be4c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts @@ -17,6 +17,10 @@ declare global { } namespace MyModule { namespace Utils { + /** + * A namespaced free function. + * @returns A fixed namespaced string. + */ function namespacedFunction(): string; } } @@ -31,8 +35,15 @@ declare global { } namespace __Swift { namespace Foundation { + /** + * A greeter living in a namespace. + */ class Greeter { constructor(name: string); + /** + * Produces a greeting for the configured name. + * @returns The greeting message. + */ greet(): string; static makeDefault(): Greeter; static readonly defaultGreeting: string; @@ -53,7 +64,14 @@ export interface SwiftHeapObject { /// Note: Calling this method will release the heap object and it will no longer be accessible. release(): void; } +/** + * A greeter living in a namespace. + */ export interface Greeter extends SwiftHeapObject { + /** + * Produces a greeting for the configured name. + * @returns The greeting message. + */ greet(): string; } export interface Converter extends SwiftHeapObject { @@ -75,6 +93,10 @@ export type Exports = { }, MyModule: { Utils: { + /** + * A namespaced free function. + * @returns A fixed namespaced string. + */ namespacedFunction(): string; }, }, diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts index 6b2d65cd8..4c02c18b3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts @@ -11,7 +11,14 @@ export interface SwiftHeapObject { /// Note: Calling this method will release the heap object and it will no longer be accessible. release(): void; } +/** + * A greeter living in a namespace. + */ export interface Greeter extends SwiftHeapObject { + /** + * Produces a greeting for the configured name. + * @returns The greeting message. + */ greet(): string; } export interface Converter extends SwiftHeapObject { @@ -33,6 +40,10 @@ export type Exports = { }, MyModule: { Utils: { + /** + * A namespaced free function. + * @returns A fixed namespaced string. + */ namespacedFunction(): string; }, }, From 358b38a50f368f42b3aec84db8fa222e14a509d9 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Tue, 23 Jun 2026 19:50:34 +0200 Subject: [PATCH 10/20] CI: Build examples in parallel on pull requests (#782) The `build-examples` job built all examples sequentially in a single job, taking ~57 minutes - each example is its own SwiftPM package that recompiles JavaScriptKit and swift-syntax from scratch, with no sharing between them. Split the job by event: - Pull requests fan out a matrix `build-examples` with one job per example, built in parallel. Wall-clock drops to that of the slowest single example (~10 min). Each example now reports as a separate `build-examples ()` check, so the required status checks need updating (see PR description). - `main` keeps the full release build of all examples plus the GitHub Pages deploy (`build-examples-deploy`), so published artifacts are unchanged. Examples are built in release to match the deploy path, keeping the only behavioral change the parallelism. Each matrix step runs `build.sh` from the example directory (via `working-directory`), mirroring Utilities/build-examples.sh. --- .github/workflows/test.yml | 39 +++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ce6ebe60..e19fed6f2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -155,7 +155,44 @@ jobs: exit 1 } + # Pull requests: compile every example in parallel just to catch breakage. + # One job per example avoids rebuilding JavaScriptKit + swift-syntax 6x in series, + # which collapses the wall-clock time from ~1h to that of the slowest single example. build-examples: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + example: + - ActorOnWebWorker + - Basic + - Embedded + - Multithreading + - OffscrenCanvas + - PlayBridgeJS + steps: + - uses: actions/checkout@v7 + - uses: ./.github/actions/install-swift + with: + download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a/swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a-ubuntu22.04.tar.gz + - uses: swiftwasm/setup-swiftwasm@v2 + id: setup-wasm32-unknown-wasip1 + with: { target: wasm32-unknown-wasip1 } + - uses: swiftwasm/setup-swiftwasm@v2 + id: setup-wasm32-unknown-wasip1-threads + with: { target: wasm32-unknown-wasip1-threads } + # build.sh resolves the package relative to the working directory, so run it + # from the example directory (mirroring Utilities/build-examples.sh's `cd`). + - run: ./build.sh release + working-directory: Examples/${{ matrix.example }} + env: + SWIFT_SDK_ID_wasm32_unknown_wasip1_threads: ${{ steps.setup-wasm32-unknown-wasip1-threads.outputs.swift-sdk-id }} + SWIFT_SDK_ID_wasm32_unknown_wasip1: ${{ steps.setup-wasm32-unknown-wasip1.outputs.swift-sdk-id }} + + # main: build all examples in release and publish them to GitHub Pages. + build-examples-deploy: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -184,7 +221,7 @@ jobs: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - needs: build-examples + needs: build-examples-deploy permissions: pages: write id-token: write From d748e5b1025d36ccb515908bac52b0c34e100086 Mon Sep 17 00:00:00 2001 From: William Taylor Date: Tue, 26 May 2026 10:38:46 +1000 Subject: [PATCH 11/20] BridgeJS: Export types using a separate JS representation --- .../Generated/JavaScript/BridgeJS.json | 3 + .../Generated/JavaScript/BridgeJS.json | 3 + .../Sources/BridgeJSCore/ClosureCodegen.swift | 6 +- .../Sources/BridgeJSCore/ExportSwift.swift | 108 +- .../BridgeJSCore/ExternalModuleIndex.swift | 6 + .../Sources/BridgeJSCore/ImportTS.swift | 21 +- .../BridgeJSCore/SwiftToSkeleton.swift | 135 +- .../Sources/BridgeJSLink/BridgeJSLink.swift | 4 + .../Sources/BridgeJSLink/JSGlueGen.swift | 41 + .../BridgeJSSkeleton/BridgeJSSkeleton.swift | 28 +- .../BridgeJSToolTests/DiagnosticsTests.swift | 72 + .../Inputs/MacroSwift/Alias.swift | 121 + .../Inputs/MacroSwift/AliasInClosure.swift | 22 + .../Inputs/MacroSwift/EnumAlias.swift | 29 + .../BridgeJSCodegenTests/Alias.json | 719 +++ .../BridgeJSCodegenTests/Alias.swift | 389 ++ .../BridgeJSCodegenTests/AliasInClosure.json | 145 + .../BridgeJSCodegenTests/AliasInClosure.swift | 188 + .../BridgeJSCodegenTests/ArrayTypes.json | 3 + .../BridgeJSCodegenTests/Async.json | 3 + .../CrossFileExtension.json | 3 + .../CrossFileFunctionTypes.ReverseOrder.json | 3 + .../CrossFileFunctionTypes.json | 3 + .../CrossFileTypeResolution.ReverseOrder.json | 3 + .../CrossFileTypeResolution.json | 3 + .../DefaultParameters.json | 3 + .../BridgeJSCodegenTests/DictionaryTypes.json | 3 + .../BridgeJSCodegenTests/EnumAlias.json | 96 + .../BridgeJSCodegenTests/EnumAlias.swift | 52 + .../EnumAssociatedValue.json | 3 + .../BridgeJSCodegenTests/EnumCase.json | 3 + .../EnumNamespace.Global.json | 3 + .../BridgeJSCodegenTests/EnumNamespace.json | 3 + .../BridgeJSCodegenTests/EnumRawType.json | 3 + .../FixedWidthIntegers.json | 3 + .../IdentityModeClass.json | 3 + .../ImportedTypeInExportedInterface.json | 3 + .../JSTypedArrayTypes.json | 3 + .../BridgeJSCodegenTests/JSValue.json | 3 + .../BridgeJSCodegenTests/MixedGlobal.json | 3 + .../BridgeJSCodegenTests/MixedPrivate.json | 3 + .../Namespaces.Global.json | 3 + .../BridgeJSCodegenTests/Namespaces.json | 3 + .../BridgeJSCodegenTests/NestedType.json | 3 + .../BridgeJSCodegenTests/Optionals.json | 3 + .../PrimitiveParameters.json | 3 + .../BridgeJSCodegenTests/PrimitiveReturn.json | 3 + .../BridgeJSCodegenTests/PropertyTypes.json | 3 + .../BridgeJSCodegenTests/Protocol.json | 3 + .../ProtocolInClosure.json | 3 + .../StaticFunctions.Global.json | 3 + .../BridgeJSCodegenTests/StaticFunctions.json | 3 + .../StaticProperties.Global.json | 3 + .../StaticProperties.json | 3 + .../BridgeJSCodegenTests/StringParameter.json | 3 + .../BridgeJSCodegenTests/StringReturn.json | 3 + .../BridgeJSCodegenTests/SwiftClass.json | 3 + .../BridgeJSCodegenTests/SwiftClosure.json | 3 + .../BridgeJSCodegenTests/SwiftStruct.json | 3 + .../SwiftStructImports.json | 3 + .../BridgeJSCodegenTests/Throws.json | 3 + .../BridgeJSCodegenTests/UnsafePointer.json | 3 + .../VoidParameterVoidReturn.json | 3 + .../BridgeJSLinkTests/Alias.d.ts | 71 + .../__Snapshots__/BridgeJSLinkTests/Alias.js | 517 ++ .../BridgeJSLinkTests/AliasInClosure.d.ts | 31 + .../BridgeJSLinkTests/AliasInClosure.js | 372 ++ .../BridgeJSLinkTests/EnumAlias.d.ts | 30 + .../BridgeJSLinkTests/EnumAlias.js | 295 ++ Sources/JavaScriptKit/Macros.swift | 8 +- .../Generated/JavaScript/BridgeJS.json | 3 + .../Generated/JavaScript/BridgeJS.json | 3 + Tests/BridgeJSRuntimeTests/AliasAPIs.swift | 401 ++ Tests/BridgeJSRuntimeTests/AliasTests.swift | 72 + .../Generated/BridgeJS.Macros.swift | 2 + .../Generated/BridgeJS.swift | 4024 ++++++---------- .../Generated/JavaScript/BridgeJS.json | 4180 +++++++++-------- .../JavaScript/AliasTests.mjs | 357 ++ Tests/BridgeJSRuntimeTests/bridge-js.d.ts | 2 + Tests/prelude.mjs | 18 + 80 files changed, 8274 insertions(+), 4429 deletions(-) create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Alias.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/AliasInClosure.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/EnumAlias.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js create mode 100644 Tests/BridgeJSRuntimeTests/AliasAPIs.swift create mode 100644 Tests/BridgeJSRuntimeTests/AliasTests.swift create mode 100644 Tests/BridgeJSRuntimeTests/JavaScript/AliasTests.mjs diff --git a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json index 7209c62f7..124e817ba 100644 --- a/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json +++ b/Benchmarks/Sources/Generated/JavaScript/BridgeJS.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json index c4a3a8c9d..9beee9031 100644 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json +++ b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift index d4e65c631..317bd0b4f 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift @@ -153,7 +153,8 @@ public struct ClosureCodegen { let argNames = liftInfo.parameters.map { (argName, _) in liftInfo.parameters.count > 1 ? "\(paramName)\(argName.capitalizedFirstLetter)" : paramName } - liftedParams.append("\(paramType.swiftType).bridgeJSLiftParameter(\(argNames.joined(separator: ", ")))") + let liftCall = "\(paramType.unaliased.swiftType).bridgeJSLiftParameter(\(argNames.joined(separator: ", ")))" + liftedParams.append(paramType.liftAliases(expression: liftCall)) } let tryPrefix = signature.isThrows ? "try " : "" @@ -197,7 +198,8 @@ public struct ClosureCodegen { } printer.write("}") default: - printer.write("return result.bridgeJSLowerReturn()") + let lowered = signature.returnType.lowerAliases(expression: "result") + printer.write("return \(lowered).bridgeJSLowerReturn()") } } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index 90c572b9d..cdbd3970f 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -227,15 +227,15 @@ public class ExportSwift { } else { optionalSwiftType = "JSUndefinedOr" } - typeNameForIntrinsic = "\(optionalSwiftType)<\(wrappedType.swiftType)>" - liftingExpr = ExprSyntax( - "\(raw: typeNameForIntrinsic).bridgeJSLiftParameter(\(raw: argumentsToLift.joined(separator: ", ")))" - ) + typeNameForIntrinsic = "\(optionalSwiftType)<\(wrappedType.unaliased.swiftType)>" + let liftCall = + "\(typeNameForIntrinsic).bridgeJSLiftParameter(\(argumentsToLift.joined(separator: ", ")))" + liftingExpr = "\(raw: param.type.liftAliases(expression: liftCall))" default: - typeNameForIntrinsic = param.type.swiftType - liftingExpr = ExprSyntax( - "\(raw: typeNameForIntrinsic).bridgeJSLiftParameter(\(raw: argumentsToLift.joined(separator: ", ")))" - ) + typeNameForIntrinsic = param.type.unaliased.swiftType + let liftCall = + "\(typeNameForIntrinsic).bridgeJSLiftParameter(\(argumentsToLift.joined(separator: ", ")))" + liftingExpr = "\(raw: param.type.liftAliases(expression: liftCall))" } liftedParameterExprs.append(liftingExpr) @@ -280,7 +280,8 @@ public class ExportSwift { } if effects.isAsync, returnType != .void { - return CodeBlockItemSyntax(item: .init(StmtSyntax("return \(raw: callExpr)"))) + let lowered = returnType.lowerAliases(expression: callExpr.description) + return CodeBlockItemSyntax(item: .init(StmtSyntax("return \(raw: lowered)"))) } if returnType == .void { @@ -393,17 +394,18 @@ public class ExportSwift { return } + let returnAccessor = returnType.lowerAliases(expression: "ret") switch returnType { case .closure(_, useJSTypedClosure: false): append("return JSTypedClosure(ret).bridgeJSLowerReturn()") case .array, .nullable(.array, _): let stackCodegen = StackCodegen() - for stmt in stackCodegen.lowerStatements(for: returnType, accessor: "ret", varPrefix: "ret") { + for stmt in stackCodegen.lowerStatements(for: returnType, accessor: returnAccessor, varPrefix: "ret") { append(stmt) } case .dictionary(.swiftProtocol): let stackCodegen = StackCodegen() - for stmt in stackCodegen.lowerStatements(for: returnType, accessor: "ret", varPrefix: "ret") { + for stmt in stackCodegen.lowerStatements(for: returnType, accessor: returnAccessor, varPrefix: "ret") { append(stmt) } case .swiftProtocol: @@ -419,7 +421,7 @@ public class ExportSwift { """ ) default: - append("return ret.bridgeJSLowerReturn()") + append("return \(raw: returnAccessor).bridgeJSLowerReturn()") } } @@ -877,8 +879,8 @@ struct StackCodegen { switch type { case .string, .integer, .bool, .float, .double, .jsObject(nil), .jsValue, .swiftStruct, .swiftHeapObject, .unsafePointer, - .swiftProtocol, .caseEnum, .associatedValueEnum, .rawValueEnum, .array, .dictionary: - return "\(raw: type.swiftType).bridgeJSStackPop()" + .swiftProtocol, .caseEnum, .associatedValueEnum, .rawValueEnum, .array, .dictionary, .alias: + return "\(raw: type.liftAliases(expression: "\(type.unaliased.swiftType).bridgeJSStackPop()"))" case .jsObject(let className?): return "\(raw: className)(unsafelyWrapping: JSObject.bridgeJSStackPop())" case .nullable(let wrappedType, let kind): @@ -895,8 +897,10 @@ struct StackCodegen { switch wrappedType { case .string, .integer, .bool, .float, .double, .jsObject(nil), .jsValue, .swiftStruct, .swiftHeapObject, .caseEnum, .associatedValueEnum, .rawValueEnum, - .array, .dictionary: - return "\(raw: typeName)<\(raw: wrappedType.swiftType)>.bridgeJSStackPop()" + .array, .dictionary, .alias: + let popCall = "\(typeName)<\(wrappedType.unaliased.swiftType)>.bridgeJSStackPop()" + let nullableType = BridgeType.nullable(wrappedType, kind) + return "\(raw: nullableType.liftAliases(expression: popCall))" case .jsObject(let className?): return "\(raw: typeName).bridgeJSStackPop().map { \(raw: className)(unsafelyWrapping: $0) }" case .nullable, .void, .namespaceEnum, .closure, .unsafePointer, .swiftProtocol: @@ -918,7 +922,7 @@ struct StackCodegen { switch type { case .string, .integer, .bool, .float, .double, .jsValue, .jsObject(nil), .swiftHeapObject, .unsafePointer, .closure, - .caseEnum, .rawValueEnum, .associatedValueEnum, .swiftStruct, .nullable: + .caseEnum, .rawValueEnum, .associatedValueEnum, .swiftStruct, .nullable, .alias: return ["\(raw: accessor).bridgeJSStackPush()"] case .jsObject(_?): return ["\(raw: accessor).jsObject.bridgeJSStackPush()"] @@ -1204,9 +1208,10 @@ struct EnumCodegen { ) { for (index, associatedValue) in associatedValues.enumerated() { let paramName = associatedValue.label ?? "param\(index)" + let accessor = associatedValue.type.lowerAliases(expression: paramName) let statements = stackCodegen.lowerStatements( for: associatedValue.type, - accessor: paramName, + accessor: accessor, varPrefix: paramName ) for statement in statements { @@ -1339,7 +1344,7 @@ struct StructCodegen { let instanceProps = structDef.properties.filter { !$0.isStatic } for property in instanceProps { - let accessor = "self.\(property.name)" + let accessor = property.type.lowerAliases(expression: "self.\(property.name)") let statements = stackCodegen.lowerStatements( for: property.type, accessor: accessor, @@ -1565,6 +1570,64 @@ extension UnsafePointerType { } extension BridgeType { + var unaliased: BridgeType { + switch self { + case .alias(_, let underlying): return underlying.unaliased + case .nullable(let wrapped, let kind): return .nullable(wrapped.unaliased, kind) + case .array(let element): return .array(element.unaliased) + case .dictionary(let value): return .dictionary(value.unaliased) + case .bool, .integer, .float, .double, .string, .jsValue, .jsObject, + .swiftHeapObject, .unsafePointer, .swiftProtocol, .void, + .caseEnum, .rawValueEnum, .associatedValueEnum, .swiftStruct, + .namespaceEnum, .closure: + return self + } + } + + /// If this type contains an alias, convert the expression with a type of the alias to the underlying type. + func liftAliases(expression: String) -> String { + switch self { + case .alias(let name, _): + return "\(name).bridgeFromJS(\(expression))" + case .nullable(let wrapped, _): + let lifted = wrapped.liftAliases(expression: "$0") + return lifted == "$0" ? expression : "\(expression).map { \(lifted) }" + case .array(let element): + let lifted = element.liftAliases(expression: "$0") + return lifted == "$0" ? expression : "\(expression).map { \(lifted) }" + case .dictionary(let value): + let lifted = value.liftAliases(expression: "$0") + return lifted == "$0" ? expression : "\(expression).mapValues { \(lifted) }" + case .bool, .integer, .float, .double, .string, .jsValue, .jsObject, + .swiftHeapObject, .unsafePointer, .swiftProtocol, .void, + .caseEnum, .rawValueEnum, .associatedValueEnum, .swiftStruct, + .namespaceEnum, .closure: + return expression + } + } + + /// Opposite of `liftAliases`: if this type contains an alias, convert the expression with a type of the underlying to the alias type. + func lowerAliases(expression: String) -> String { + switch self { + case .alias: + return "\(expression).bridgeToJS()" + case .nullable(let wrapped, _): + let lowered = wrapped.lowerAliases(expression: "$0") + return lowered == "$0" ? expression : "\(expression).map { \(lowered) }" + case .array(let element): + let lowered = element.lowerAliases(expression: "$0") + return lowered == "$0" ? expression : "\(expression).map { \(lowered) }" + case .dictionary(let value): + let lowered = value.lowerAliases(expression: "$0") + return lowered == "$0" ? expression : "\(expression).mapValues { \(lowered) }" + case .bool, .integer, .float, .double, .string, .jsValue, .jsObject, + .swiftHeapObject, .unsafePointer, .swiftProtocol, .void, + .caseEnum, .rawValueEnum, .associatedValueEnum, .swiftStruct, + .namespaceEnum, .closure: + return expression + } + } + var swiftType: String { switch self { case .bool: return "Bool" @@ -1593,6 +1656,7 @@ extension BridgeType { let effectsStr = (signature.isAsync ? " async" : "") + (signature.isThrows ? " throws" : "") let closureType = "(\(paramTypes))\(effectsStr) -> \(signature.returnType.swiftType)" return useJSTypedClosure ? "JSTypedClosure<\(closureType)>" : closureType + case .alias(let name, _): return name } } @@ -1617,6 +1681,8 @@ extension BridgeType { return true case .nullable(let wrapped, _): return wrapped.isStackUsingParameter + case .alias(_, let underlying): + return underlying.isStackUsingParameter default: return false } @@ -1675,6 +1741,8 @@ extension BridgeType { return LiftingIntrinsicInfo(parameters: [("callbackId", .i32)]) case .array, .dictionary: return LiftingIntrinsicInfo(parameters: []) + case .alias(_, let underlying): + return try underlying.liftParameterInfo() } } @@ -1726,6 +1794,8 @@ extension BridgeType { return .jsObject case .array, .dictionary: return .array + case .alias(_, let underlying): + return try underlying.loweringReturnInfo() } } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExternalModuleIndex.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExternalModuleIndex.swift index 91fd4388a..33a27d087 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExternalModuleIndex.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExternalModuleIndex.swift @@ -63,6 +63,12 @@ public struct ExternalModuleIndex { for proto in exported.protocols { register(dotPath: proto.name, bridgeType: .swiftProtocol(proto.name)) } + for alias in exported.aliases { + register( + dotPath: alias.swiftCallName, + bridgeType: .alias(name: alias.swiftCallName, underlying: alias.underlying) + ) + } entriesByModule[moduleName] = moduleEntries } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift index 2912ce698..9fd2af08e 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift @@ -172,7 +172,8 @@ public struct ImportTS { if loweringInfo.useBorrowing { let returnVariableName = "ret\(borrowedArguments.count)" let assign = needsReturnVariable ? "let \(returnVariableName) = " : "" - body.write("\(assign)\(param.name).bridgeJSWithLoweredParameter { \(pattern) in") + let loweredAlias = param.type.lowerAliases(expression: param.name) + body.write("\(assign)\(loweredAlias).bridgeJSWithLoweredParameter { \(pattern) in") body.indent() borrowedArguments.append( BorrowedArgument( @@ -203,7 +204,8 @@ public struct ImportTS { "(\(raw: param.name) as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()" ) } else { - initializerExpr = ExprSyntax("\(raw: param.name).bridgeJSLowerParameter()") + let loweredAlias = param.type.lowerAliases(expression: param.name) + initializerExpr = ExprSyntax("\(raw: loweredAlias).bridgeJSLowerParameter()") } if loweringInfo.loweredParameters.isEmpty { @@ -294,18 +296,21 @@ public struct ImportTS { if returnType.usesSideChannelForOptionalReturn() { // Side channel returns: extern function returns Void, value is retrieved via side channel - body.write("return \(returnType.swiftType).bridgeJSLiftReturnFromSideChannel()") + let liftCall = "\(returnType.unaliased.swiftType).bridgeJSLiftReturnFromSideChannel()" + body.write("return \(returnType.liftAliases(expression: liftCall))") } else { let liftExpr: String switch returnType { case .closure(let signature, _): liftExpr = "_BJS_Closure_\(signature.mangleName).bridgeJSLift(ret)" default: + let liftCall: String if liftingInfo.valueToLift != nil { - liftExpr = "\(returnType.swiftType).bridgeJSLiftReturn(ret)" + liftCall = "\(returnType.unaliased.swiftType).bridgeJSLiftReturn(ret)" } else { - liftExpr = "\(returnType.swiftType).bridgeJSLiftReturn()" + liftCall = "\(returnType.unaliased.swiftType).bridgeJSLiftReturn()" } + liftExpr = returnType.liftAliases(expression: liftCall) } body.write("return \(liftExpr)") } @@ -957,6 +962,8 @@ extension BridgeType { return LoweringParameterInfo(loweredParameters: params, useBorrowing: wrappedInfo.useBorrowing) case .array, .dictionary: return LoweringParameterInfo(loweredParameters: []) + case .alias(_, let underlying): + return try underlying.loweringParameterInfo(context: context) } } @@ -1019,7 +1026,7 @@ extension BridgeType { case .nullable(let wrappedType, _): // jsObject and `@JS struct` use the stack ABI for optionals — the thunk returns // void and the value (plus isSome discriminator) flows through the stacks. - if case .jsObject = wrappedType { + if case .jsObject = wrappedType.unaliased { return LiftingReturnInfo(valueToLift: nil) } if case .swiftStruct = wrappedType, context == .importTS { @@ -1029,6 +1036,8 @@ extension BridgeType { return LiftingReturnInfo(valueToLift: wrappedInfo.valueToLift) case .array, .dictionary: return LiftingReturnInfo(valueToLift: nil) + case .alias(_, let underlying): + return try underlying.liftingReturnInfo(context: context) } } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index ed7ebcd1b..8b4e79d64 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -399,6 +399,11 @@ public final class SwiftToSkeleton { if let enumDecl = typeDecl.as(EnumDeclSyntax.self) { let swiftCallName = SwiftToSkeleton.computeSwiftCallName(for: enumDecl, itemName: enumDecl.name.text) + if let jsAttribute = enumDecl.attributes.firstJSAttribute, + let aliasTarget = extractAliasTarget(from: jsAttribute) + { + return aliasType(target: aliasTarget, swiftCallName: swiftCallName, errors: &errors) + } let rawTypeString = enumDecl.inheritanceClause?.inheritedTypes.first { inheritedType in let typeName = inheritedType.type.trimmedDescription return ExportSwiftConstants.supportedRawTypes.contains(typeName) @@ -439,6 +444,11 @@ public final class SwiftToSkeleton { if structDecl.attributes.hasAttribute(name: "JSClass") { return .jsObject(swiftCallName) } + if let jsAttribute = structDecl.attributes.firstJSAttribute, + let aliasTarget = extractAliasTarget(from: jsAttribute) + { + return aliasType(target: aliasTarget, swiftCallName: swiftCallName, errors: &errors) + } return .swiftStruct(swiftCallName) } @@ -456,6 +466,13 @@ public final class SwiftToSkeleton { return .jsObject(swiftCallName) } + if let classDecl = typeDecl.as(ClassDeclSyntax.self), + let jsAttribute = classDecl.attributes.firstJSAttribute, + let aliasTarget = extractAliasTarget(from: jsAttribute) + { + return aliasType(target: aliasTarget, swiftCallName: swiftCallName, errors: &errors) + } + return .swiftHeapObject(swiftCallName) } @@ -517,6 +534,50 @@ public final class SwiftToSkeleton { } } + fileprivate func extractAliasTarget(from jsAttribute: AttributeSyntax) -> TypeSyntax? { + guard + let arguments = jsAttribute.arguments?.as(LabeledExprListSyntax.self), + let asArg = arguments.first(where: { $0.label?.text == "as" }), + let memberAccess = asArg.expression.as(MemberAccessExprSyntax.self), + memberAccess.declName.baseName.text == "self", + let base = memberAccess.base + else { + return nil + } + return TypeSyntax(stringLiteral: base.trimmedDescription) + } + + fileprivate func aliasType( + target aliasTarget: TypeSyntax, + swiftCallName: String, + errors: inout [DiagnosticError] + ) -> BridgeType? { + if let targetDecl = typeDeclResolver.resolve(aliasTarget), + let targetJSAttribute = targetDecl.attributes.firstJSAttribute, + extractAliasTarget(from: targetJSAttribute) != nil + { + errors.append( + DiagnosticError( + node: aliasTarget, + message: "`@JS(as:)` target must be a `@JS` type, not another `@JS(as:)` type", + hint: "Use the underlying `@JS` type directly" + ) + ) + return nil + } + guard let targetType = lookupType(for: aliasTarget, errors: &errors) else { return nil } + if case .swiftProtocol = targetType { + errors.append( + DiagnosticError( + node: aliasTarget, + message: "`@JS(as:)` cannot target a `@JS protocol`" + ) + ) + return nil + } + return .alias(name: swiftCallName, underlying: targetType) + } + fileprivate static func parseUnsafePointerType(_ type: TypeSyntax) -> UnsafePointerType? { func parse(baseName: String, genericArg: TypeSyntax?) -> UnsafePointerType? { let pointee = genericArg?.trimmedDescription @@ -650,6 +711,7 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { /// The names of the exported structs, in the order they were written in the source file var exportedStructNames: [String] = [] var exportedStructByName: [String: ExportedStruct] = [:] + var exportedAliases: [ExportedAlias] = [] var errors: [DiagnosticError] = [] /// Extensions collected during the walk, to be resolved after all files have been walked var deferredExtensions: [ExtensionDeclSyntax] = [] @@ -660,6 +722,7 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { result.enums.append(contentsOf: exportedEnumNames.map { exportedEnumByName[$0]! }) result.structs.append(contentsOf: exportedStructNames.map { exportedStructByName[$0]! }) result.protocols.append(contentsOf: exportedProtocolNames.map { exportedProtocolByName[$0]! }) + result.aliases.append(contentsOf: exportedAliases) } /// Creates a unique key by combining name and namespace @@ -1564,6 +1627,11 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { return .skipChildren } + if let aliasTarget = parent.extractAliasTarget(from: jsAttribute) { + recordAlias(node: node, aliasTarget: aliasTarget) + return .skipChildren + } + let namespaceResult = resolveNamespace(from: jsAttribute, for: node, declarationType: "class") guard namespaceResult.isValid else { return .skipChildren @@ -1662,11 +1730,38 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { return true } + private func recordAlias( + node: some SyntaxProtocol & NamedDeclSyntax, + aliasTarget: TypeSyntax + ) { + let swiftCallName = SwiftToSkeleton.computeSwiftCallName(for: node, itemName: node.name.text) + var lookupErrors: [DiagnosticError] = [] + guard + let aliasBridgeType = parent.aliasType( + target: aliasTarget, + swiftCallName: swiftCallName, + errors: &lookupErrors + ), + case .alias(_, let underlying) = aliasBridgeType + else { + errors.append(contentsOf: lookupErrors) + return + } + exportedAliases.append( + ExportedAlias(swiftCallName: swiftCallName, underlying: underlying) + ) + } + override func visit(_ node: EnumDeclSyntax) -> SyntaxVisitorContinueKind { guard let jsAttribute = node.attributes.firstJSAttribute else { return .skipChildren } + if let aliasTarget = parent.extractAliasTarget(from: jsAttribute) { + recordAlias(node: node, aliasTarget: aliasTarget) + return .skipChildren + } + let name = node.name.text let rawType: String? = node.inheritanceClause?.inheritedTypes.first { inheritedType in @@ -1767,24 +1862,7 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { } for enumCase in exportedEnum.cases { for associatedValue in enumCase.associatedValues { - switch associatedValue.type { - case .string, .integer, .float, .double, .bool, .caseEnum, .rawValueEnum, - .swiftStruct, .swiftHeapObject, .jsObject, .associatedValueEnum, .array: - break - case .nullable(let wrappedType, _): - switch wrappedType { - case .string, .integer, .float, .double, .bool, .caseEnum, .rawValueEnum, - .swiftStruct, .swiftHeapObject, .jsObject, .associatedValueEnum, .array: - break - default: - diagnose( - node: node, - message: "Unsupported associated value type: \(associatedValue.type.swiftType)", - hint: - "Only primitive types, enums, structs, classes, JSObject, arrays, and their optionals are supported in associated-value enums" - ) - } - default: + if !associatedValue.type.isSupportedAsAssociatedValue() { diagnose( node: node, message: "Unsupported associated value type: \(associatedValue.type.swiftType)", @@ -1867,6 +1945,11 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { return .skipChildren } + if let aliasTarget = parent.extractAliasTarget(from: jsAttribute) { + recordAlias(node: node, aliasTarget: aliasTarget) + return .skipChildren + } + let name = node.name.text let namespaceResult = resolveNamespace(from: jsAttribute, for: node, declarationType: "struct") @@ -2971,6 +3054,22 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor { } } +extension BridgeType { + fileprivate func isSupportedAsAssociatedValue(allowNullable: Bool = true) -> Bool { + switch self { + case .string, .integer, .float, .double, .bool, .caseEnum, .rawValueEnum, + .swiftStruct, .swiftHeapObject, .jsObject, .associatedValueEnum, .array: + return true + case .alias(_, let underlying): + return underlying.isSupportedAsAssociatedValue(allowNullable: false) + case .nullable(let wrapped, _) where allowNullable: + return wrapped.isSupportedAsAssociatedValue(allowNullable: false) + default: + return false + } + } +} + extension GenericArgumentListSyntax { /// Compatibility helper for accessing the first argument as a TypeSyntax /// diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index a24fde09b..ed9eb950f 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -1550,6 +1550,8 @@ public struct BridgeJSLink { } } return type.tsType + case .alias(_, let underlying): + return resolveTypeScriptType(underlying, exportedSkeletons: exportedSkeletons) case .nullable(let wrapped, let kind): let base = resolveTypeScriptType(wrapped, exportedSkeletons: exportedSkeletons) return "\(base) | \(kind.absenceLiteral)" @@ -3960,6 +3962,8 @@ extension BridgeType { return "\(inner)[]" case .dictionary(let valueType): return "Record" + case .alias(_, let underlying): + return underlying.tsType } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift index ac2144bbc..c6ac936cd 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift @@ -651,6 +651,9 @@ struct IntrinsicJSFragment: Sendable { kind: JSOptionalKind, context bridgeContext: BridgeContext = .importTS ) throws -> IntrinsicJSFragment { + if case .alias(_, let underlying) = wrappedType { + return try optionalLiftParameter(wrappedType: underlying, kind: kind, context: bridgeContext) + } if wrappedType.isSingleParamScalar { let coerce = wrappedType.liftCoerce return IntrinsicJSFragment( @@ -739,6 +742,9 @@ struct IntrinsicJSFragment: Sendable { wrappedType: BridgeType, kind: JSOptionalKind ) throws -> IntrinsicJSFragment { + if case .alias(_, let underlying) = wrappedType { + return try optionalLowerParameter(wrappedType: underlying, kind: kind) + } if wrappedType.isSingleParamScalar { let wasmType = wrappedType.wasmParams[0].type let coerce = wrappedType.lowerCoerce @@ -967,6 +973,9 @@ struct IntrinsicJSFragment: Sendable { wrappedType: BridgeType, kind: JSOptionalKind ) -> IntrinsicJSFragment { + if case .alias(_, let underlying) = wrappedType { + return optionalLiftReturn(wrappedType: underlying, kind: kind) + } if let scalarKind = wrappedType.optionalScalarKind { return optionalLiftReturnFromStorage(storage: scalarKind.storageName) } @@ -1064,6 +1073,9 @@ struct IntrinsicJSFragment: Sendable { } static func optionalLowerReturn(wrappedType: BridgeType, kind: JSOptionalKind) throws -> IntrinsicJSFragment { + if case .alias(_, let underlying) = wrappedType { + return try optionalLowerReturn(wrappedType: underlying, kind: kind) + } switch wrappedType { case .void, .nullable, .namespaceEnum, .closure: throw BridgeJSLinkError(message: "Unsupported optional wrapped type for protocol export: \(wrappedType)") @@ -1188,6 +1200,9 @@ struct IntrinsicJSFragment: Sendable { // MARK: - Protocol Support static func protocolPropertyOptionalToSideChannel(wrappedType: BridgeType) throws -> IntrinsicJSFragment { + if case .alias(_, let underlying) = wrappedType { + return try protocolPropertyOptionalToSideChannel(wrappedType: underlying) + } if let scalarKind = wrappedType.optionalScalarKind { let storage = scalarKind.storageName return IntrinsicJSFragment( @@ -1323,6 +1338,8 @@ struct IntrinsicJSFragment: Sendable { return try arrayLower(elementType: elementType) case .dictionary(let valueType): return try dictionaryLower(valueType: valueType) + case .alias(_, let underlying): + return try lowerParameter(type: underlying) default: throw BridgeJSLinkError(message: "Unhandled type in lowerParameter: \(type)") } @@ -1380,6 +1397,8 @@ struct IntrinsicJSFragment: Sendable { return try arrayLift(elementType: elementType) case .dictionary(let valueType): return try dictionaryLift(valueType: valueType) + case .alias(_, let underlying): + return try liftReturn(type: underlying) default: throw BridgeJSLinkError(message: "Unhandled type in liftReturn: \(type)") } @@ -1470,6 +1489,8 @@ struct IntrinsicJSFragment: Sendable { return try arrayLift(elementType: elementType) case .dictionary(let valueType): return try dictionaryLift(valueType: valueType) + case .alias(_, let underlying): + return try liftParameter(type: underlying, context: context) default: throw BridgeJSLinkError(message: "Unhandled type in liftParameter: \(type)") } @@ -1524,6 +1545,8 @@ struct IntrinsicJSFragment: Sendable { return try arrayLower(elementType: elementType) case .dictionary(let valueType): return try dictionaryLower(valueType: valueType) + case .alias(_, let underlying): + return try lowerReturn(type: underlying, context: context) default: throw BridgeJSLinkError(message: "Unhandled type in lowerReturn: \(type)") } @@ -1941,6 +1964,9 @@ struct IntrinsicJSFragment: Sendable { } private static func stackLiftFragment(elementType: BridgeType) throws -> IntrinsicJSFragment { + if case .alias(_, let underlying) = elementType { + return try stackLiftFragment(elementType: underlying) + } if case .nullable(let wrappedType, let kind) = elementType { return try optionalElementRaiseFragment(wrappedType: wrappedType, kind: kind) } @@ -2068,6 +2094,9 @@ struct IntrinsicJSFragment: Sendable { } private static func stackLowerFragment(elementType: BridgeType) throws -> IntrinsicJSFragment { + if case .alias(_, let underlying) = elementType { + return try stackLowerFragment(elementType: underlying) + } if case .nullable(let wrappedType, let kind) = elementType { return try optionalElementLowerFragment(wrappedType: wrappedType, kind: kind) } @@ -2192,6 +2221,9 @@ struct IntrinsicJSFragment: Sendable { wrappedType: BridgeType, kind: JSOptionalKind ) throws -> IntrinsicJSFragment { + if case .alias(_, let underlying) = wrappedType { + return try optionalElementRaiseFragment(wrappedType: underlying, kind: kind) + } if case .associatedValueEnum(let fullName) = wrappedType { let base = fullName.components(separatedBy: ".").last ?? fullName let absenceLiteral = kind.absenceLiteral @@ -2258,6 +2290,9 @@ struct IntrinsicJSFragment: Sendable { wrappedType: BridgeType, kind: JSOptionalKind ) throws -> IntrinsicJSFragment { + if case .alias(_, let underlying) = wrappedType { + return try optionalElementLowerFragment(wrappedType: underlying, kind: kind) + } if case .associatedValueEnum(let fullName) = wrappedType { let base = fullName.components(separatedBy: ".").last ?? fullName return IntrinsicJSFragment( @@ -2680,6 +2715,8 @@ private extension BridgeType { return .stackABI case .nullable(let wrapped, _): return wrapped.optionalConvention + case .alias(_, let underlying): + return underlying.optionalConvention } } @@ -2711,6 +2748,8 @@ private extension BridgeType { return .i32(-1) case .nullable(let wrapped, _): return wrapped.nilSentinel + case .alias(_, let underlying): + return underlying.nilSentinel default: return .none } @@ -2776,6 +2815,8 @@ private extension BridgeType { return [] case .nullable(let wrapped, _): return wrapped.wasmParams + case .alias(_, let underlying): + return underlying.wasmParams } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift index 436c40ab7..4d1ebbbc1 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift @@ -274,6 +274,7 @@ public enum BridgeType: Codable, Equatable, Hashable, Sendable { case swiftProtocol(String) case swiftStruct(String) indirect case closure(ClosureSignature, useJSTypedClosure: Bool) + indirect case alias(name: String, underlying: BridgeType) } public enum WasmCoreType: String, Codable, Sendable { @@ -1007,12 +1008,23 @@ public struct ExportedProperty: Codable, Equatable, Sendable { } } +public struct ExportedAlias: Codable { + public let swiftCallName: String + public let underlying: BridgeType + + public init(swiftCallName: String, underlying: BridgeType) { + self.swiftCallName = swiftCallName + self.underlying = underlying + } +} + public struct ExportedSkeleton: Codable { public var functions: [ExportedFunction] public var classes: [ExportedClass] public var enums: [ExportedEnum] public var structs: [ExportedStruct] public var protocols: [ExportedProtocol] + public var aliases: [ExportedAlias] /// Whether to expose exported APIs to the global namespace. /// /// When `true`, exported functions, classes, and namespaces are available @@ -1032,6 +1044,7 @@ public struct ExportedSkeleton: Codable { enums: [ExportedEnum], structs: [ExportedStruct] = [], protocols: [ExportedProtocol] = [], + aliases: [ExportedAlias] = [], exposeToGlobal: Bool, identityMode: String? = nil ) { @@ -1040,6 +1053,7 @@ public struct ExportedSkeleton: Codable { self.enums = enums self.structs = structs self.protocols = protocols + self.aliases = aliases self.exposeToGlobal = exposeToGlobal self.identityMode = identityMode } @@ -1050,12 +1064,13 @@ public struct ExportedSkeleton: Codable { self.enums.append(contentsOf: other.enums) self.structs.append(contentsOf: other.structs) self.protocols.append(contentsOf: other.protocols) + self.aliases.append(contentsOf: other.aliases) assert(self.exposeToGlobal == other.exposeToGlobal) assert(self.identityMode == other.identityMode) } public var isEmpty: Bool { - functions.isEmpty && classes.isEmpty && enums.isEmpty && structs.isEmpty && protocols.isEmpty + functions.isEmpty && classes.isEmpty && enums.isEmpty && structs.isEmpty && protocols.isEmpty && aliases.isEmpty } /// Distinct `async` return types needing a `Promise_resolve_` helper, deduplicated @@ -1651,6 +1666,8 @@ extension BridgeType { case .dictionary: // Dictionaries use stack-based return with entry count (no direct WASM return type) return nil + case .alias(_, let underlying): + return underlying.abiReturnType } } @@ -1738,6 +1755,8 @@ extension BridgeType { case .dictionary(let valueType): // Dictionary mangling: "SD" prefix followed by value type (key is always String) return "SD\(valueType.mangleTypeName)" + case .alias(let name, _): + return "Al\(name.count)\(name)" } } @@ -1749,8 +1768,11 @@ extension BridgeType { guard case .nullable(let wrappedType, _) = self else { return false } + return wrappedType.requiresSideChannelForOptionalReturnIfWrapped + } - switch wrappedType { + private var requiresSideChannelForOptionalReturnIfWrapped: Bool { + switch self { case .string, .integer, .float, .double, .swiftProtocol: return true case .rawValueEnum(_, let rawType): @@ -1764,6 +1786,8 @@ extension BridgeType { } case .bool, .caseEnum, .swiftHeapObject, .associatedValueEnum, .jsObject: return false + case .alias(_, let underlying): + return underlying.requiresSideChannelForOptionalReturnIfWrapped default: return false } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift index ae12b6566..2db9ac2d7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift @@ -354,6 +354,78 @@ import Testing #expect(try exportSwift.finalize() != nil) } + @Test + func chainedJSAsDiagnostic() throws { + let source = """ + @JS(as: B.self) struct A { + consuming func bridgeToJS() -> B { fatalError() } + static func bridgeFromJS(_ value: consuming B) -> A { fatalError() } + } + @JS(as: C.self) struct B { + consuming func bridgeToJS() -> C { fatalError() } + static func bridgeFromJS(_ value: consuming C) -> B { fatalError() } + } + @JS class C { @JS init() {} } + """ + let swiftAPI = SwiftToSkeleton( + progress: .silent, + moduleName: "TestModule", + exposeToGlobal: false, + externalModuleIndex: .empty + ) + swiftAPI.addSourceFile(Parser.parse(source: source), inputFilePath: "test.swift") + #expect(throws: BridgeJSCoreDiagnosticError.self) { + _ = try swiftAPI.finalize() + } + } + + @Test + func cyclicJSAsDiagnostic() throws { + let source = """ + @JS(as: B.self) struct A { + consuming func bridgeToJS() -> B { fatalError() } + static func bridgeFromJS(_ value: consuming B) -> A { fatalError() } + } + @JS(as: A.self) struct B { + consuming func bridgeToJS() -> A { fatalError() } + static func bridgeFromJS(_ value: consuming A) -> B { fatalError() } + } + """ + let swiftAPI = SwiftToSkeleton( + progress: .silent, + moduleName: "TestModule", + exposeToGlobal: false, + externalModuleIndex: .empty + ) + swiftAPI.addSourceFile(Parser.parse(source: source), inputFilePath: "test.swift") + #expect(throws: BridgeJSCoreDiagnosticError.self) { + _ = try swiftAPI.finalize() + } + } + + @Test + func jsAsProtocolTargetDiagnostic() throws { + let source = """ + @JS protocol Audible { + func play() + } + @JS(as: Audible.self) struct AudibleTag { + consuming func bridgeToJS() -> any Audible { fatalError() } + static func bridgeFromJS(_ value: consuming any Audible) -> AudibleTag { fatalError() } + } + """ + let swiftAPI = SwiftToSkeleton( + progress: .silent, + moduleName: "TestModule", + exposeToGlobal: false, + externalModuleIndex: .empty + ) + swiftAPI.addSourceFile(Parser.parse(source: source), inputFilePath: "test.swift") + #expect(throws: BridgeJSCoreDiagnosticError.self) { + _ = try swiftAPI.finalize() + } + } + @Test func omitsNextLineWhenErrorIsOnLastLine() throws { let source = """ diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Alias.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Alias.swift new file mode 100644 index 000000000..f4d56653f --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/Alias.swift @@ -0,0 +1,121 @@ +@JS(as: PolygonReference.self) struct Polygon { + var vertices: [Double] + + consuming func bridgeToJS() -> PolygonReference { + return PolygonReference(underlying: self) + } + + static func bridgeFromJS(_ value: consuming PolygonReference) -> Polygon { + return value.underlying + } +} + +@JS final class PolygonReference { + var underlying: Polygon + + @JS init(underlying: Polygon) { + self.underlying = underlying + } + + @JS func snapshot() -> Polygon + @JS func merge(_ other: Polygon) -> Polygon + @JS static func origin() -> Polygon +} + +@JS(as: TagReference.self) struct Tag { + var name: String + + consuming func bridgeToJS() -> TagReference { + return TagReference(underlying: self) + } + + static func bridgeFromJS(_ value: consuming TagReference) -> Tag { + return value.underlying + } +} + +@JS final class TagReference { + var underlying: Tag + + @JS init(underlying: Tag) { + self.underlying = underlying + } +} + +@JS func roundtripPolygon(_ polygon: Polygon) -> Polygon + +@JS func optionalPolygon(_ polygon: Polygon?) -> Polygon? + +@JS func polygonArray(_ polygons: [Polygon]) -> [Polygon] + +@JS func validatePolygon(_ polygon: Polygon) throws(JSException) -> Polygon + +@JS func makeTag(_ name: String) -> Tag + +@JS(as: String.self) struct Tagged { + var raw: String + + consuming func bridgeToJS() -> String { + return raw + } + + static func bridgeFromJS(_ value: consuming String) -> Tagged { + return Tagged(raw: value) + } +} + +@JSFunction func acceptTagged(_ tagged: Tagged) throws(JSException) -> Void +@JSFunction func acceptOptionalTagged(_ tagged: Tagged?) throws(JSException) -> Void +@JSFunction func roundtripTagged(_ tagged: Tagged) throws(JSException) -> Tagged + +@JSClass class Surface { + @JSFunction init() throws(JSException) + @JSGetter var label: String +} + +@JS(as: Surface.self) struct Canvas { + consuming func bridgeToJS() -> Surface { + fatalError("test stub") + } + + static func bridgeFromJS(_ value: consuming Surface) -> Canvas { + return Canvas() + } +} + +@JSFunction func produceOptionalCanvas() throws(JSException) -> Canvas? + +@JS enum InnerTag { + case payload(Int) + case empty +} + +@JS(as: InnerTag.self) struct AliasedTag { + consuming func bridgeToJS() -> InnerTag { + return .empty + } + + static func bridgeFromJS(_ value: consuming InnerTag) -> AliasedTag { + return AliasedTag() + } +} + +@JS func roundtripTags(_ xs: [AliasedTag?]) -> [AliasedTag?] + +@JS(as: Int.self) struct UserId { + var rawValue: Int + + consuming func bridgeToJS() -> Int { + return rawValue + } + + static func bridgeFromJS(_ value: consuming Int) -> UserId { + return UserId(rawValue: value) + } +} + +@JS protocol HasOptionalUserId { + var userId: UserId? { get } +} + +@JS func describeUser(_ owner: HasOptionalUserId) -> HasOptionalUserId diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/AliasInClosure.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/AliasInClosure.swift new file mode 100644 index 000000000..384481c5c --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/AliasInClosure.swift @@ -0,0 +1,22 @@ +@JS(as: PolygonReference.self) struct Polygon { + var sides: Int + + consuming func bridgeToJS() -> PolygonReference { + return PolygonReference(sides: sides) + } + + static func bridgeFromJS(_ value: consuming PolygonReference) -> Polygon { + return Polygon(sides: value.sides) + } +} + +@JS final class PolygonReference { + var sides: Int + + @JS init(sides: Int) { + self.sides = sides + } +} + +@JS func makePolygonFactory() -> () -> Polygon +@JS func makePolygonInspector() -> (Polygon) -> Int diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/EnumAlias.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/EnumAlias.swift new file mode 100644 index 000000000..7da395c2a --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/EnumAlias.swift @@ -0,0 +1,29 @@ +@JS(as: ColorBox.self) enum Color { + case red, green, blue + + consuming func bridgeToJS() -> ColorBox { + switch self { + case .red: return ColorBox(name: "red") + case .green: return ColorBox(name: "green") + case .blue: return ColorBox(name: "blue") + } + } + + static func bridgeFromJS(_ value: consuming ColorBox) -> Color { + switch value.name { + case "green": return .green + case "blue": return .blue + default: return .red + } + } +} + +@JS final class ColorBox { + var name: String + + @JS init(name: String) { + self.name = name + } +} + +@JS func roundtripColor(_ color: Color) -> Color diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.json new file mode 100644 index 000000000..bcdc43375 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.json @@ -0,0 +1,719 @@ +{ + "exported" : { + "aliases" : [ + { + "swiftCallName" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + }, + { + "swiftCallName" : "Tag", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TagReference" + } + } + }, + { + "swiftCallName" : "Tagged", + "underlying" : { + "string" : { + + } + } + }, + { + "swiftCallName" : "Canvas", + "underlying" : { + "jsObject" : { + "_0" : "Surface" + } + } + }, + { + "swiftCallName" : "AliasedTag", + "underlying" : { + "associatedValueEnum" : { + "_0" : "InnerTag" + } + } + }, + { + "swiftCallName" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_PolygonReference_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "underlying", + "name" : "underlying", + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_PolygonReference_snapshot", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "snapshot", + "parameters" : [ + + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + }, + { + "abiName" : "bjs_PolygonReference_merge", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "merge", + "parameters" : [ + { + "label" : "_", + "name" : "other", + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + }, + { + "abiName" : "bjs_PolygonReference_static_origin", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "origin", + "parameters" : [ + + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + }, + "staticContext" : { + "className" : { + "_0" : "PolygonReference" + } + } + } + ], + "name" : "PolygonReference", + "properties" : [ + + ], + "swiftCallName" : "PolygonReference" + }, + { + "constructor" : { + "abiName" : "bjs_TagReference_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "underlying", + "name" : "underlying", + "type" : { + "alias" : { + "name" : "Tag", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TagReference" + } + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "TagReference", + "properties" : [ + + ], + "swiftCallName" : "TagReference" + } + ], + "enums" : [ + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "payload" + }, + { + "associatedValues" : [ + + ], + "name" : "empty" + } + ], + "emitStyle" : "const", + "name" : "InnerTag", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "InnerTag", + "tsFullPath" : "InnerTag" + } + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_roundtripPolygon", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripPolygon", + "parameters" : [ + { + "label" : "_", + "name" : "polygon", + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + }, + { + "abiName" : "bjs_optionalPolygon", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "optionalPolygon", + "parameters" : [ + { + "label" : "_", + "name" : "polygon", + "type" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_polygonArray", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "polygonArray", + "parameters" : [ + { + "label" : "_", + "name" : "polygons", + "type" : { + "array" : { + "_0" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + } + } + }, + { + "abiName" : "bjs_validatePolygon", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "validatePolygon", + "parameters" : [ + { + "label" : "_", + "name" : "polygon", + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + }, + { + "abiName" : "bjs_makeTag", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeTag", + "parameters" : [ + { + "label" : "_", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Tag", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TagReference" + } + } + } + } + }, + { + "abiName" : "bjs_roundtripTags", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripTags", + "parameters" : [ + { + "label" : "_", + "name" : "xs", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "AliasedTag", + "underlying" : { + "associatedValueEnum" : { + "_0" : "InnerTag" + } + } + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "AliasedTag", + "underlying" : { + "associatedValueEnum" : { + "_0" : "InnerTag" + } + } + } + }, + "_1" : "null" + } + } + } + } + }, + { + "abiName" : "bjs_describeUser", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "describeUser", + "parameters" : [ + { + "label" : "_", + "name" : "owner", + "type" : { + "swiftProtocol" : { + "_0" : "HasOptionalUserId" + } + } + } + ], + "returnType" : { + "swiftProtocol" : { + "_0" : "HasOptionalUserId" + } + } + } + ], + "protocols" : [ + { + "methods" : [ + + ], + "name" : "HasOptionalUserId", + "properties" : [ + { + "isReadonly" : true, + "name" : "userId", + "type" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" + } + } + } + ] + } + ], + "structs" : [ + + ] + }, + "imported" : { + "children" : [ + { + "functions" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "acceptTagged", + "parameters" : [ + { + "name" : "tagged", + "type" : { + "alias" : { + "name" : "Tagged", + "underlying" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "acceptOptionalTagged", + "parameters" : [ + { + "name" : "tagged", + "type" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Tagged", + "underlying" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "void" : { + + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "roundtripTagged", + "parameters" : [ + { + "name" : "tagged", + "type" : { + "alias" : { + "name" : "Tagged", + "underlying" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Tagged", + "underlying" : { + "string" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "produceOptionalCanvas", + "parameters" : [ + + ], + "returnType" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Canvas", + "underlying" : { + "jsObject" : { + "_0" : "Surface" + } + } + } + }, + "_1" : "null" + } + } + } + ], + "types" : [ + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + + ] + }, + "getters" : [ + { + "accessLevel" : "internal", + "name" : "label", + "type" : { + "string" : { + + } + } + } + ], + "methods" : [ + + ], + "name" : "Surface", + "setters" : [ + + ], + "staticMethods" : [ + + ] + } + ] + } + ] + }, + "moduleName" : "TestModule", + "usedExternalModules" : [ + + ] +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.swift new file mode 100644 index 000000000..1a31905f3 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.swift @@ -0,0 +1,389 @@ +struct AnyHasOptionalUserId: HasOptionalUserId, _BridgedSwiftProtocolWrapper { + let jsObject: JSObject + + var userId: Optional { + get { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + bjs_HasOptionalUserId_userId_get(jsObjectValue) + return Optional.bridgeJSLiftReturnFromSideChannel().map { UserId.bridgeFromJS($0) } + } + } + + static func bridgeJSLiftParameter(_ value: Int32) -> Self { + return AnyHasOptionalUserId(jsObject: JSObject(id: UInt32(bitPattern: value))) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_HasOptionalUserId_userId_get") +fileprivate func bjs_HasOptionalUserId_userId_get_extern(_ jsObject: Int32) -> Void +#else +fileprivate func bjs_HasOptionalUserId_userId_get_extern(_ jsObject: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_HasOptionalUserId_userId_get(_ jsObject: Int32) -> Void { + return bjs_HasOptionalUserId_userId_get_extern(jsObject) +} + +extension InnerTag: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> InnerTag { + switch caseId { + case 0: + return .payload(Int.bridgeJSStackPop()) + case 1: + return .empty + default: + fatalError("Unknown InnerTag case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .payload(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .empty: + return Int32(1) + } + } +} + +@_expose(wasm, "bjs_roundtripPolygon") +@_cdecl("bjs_roundtripPolygon") +public func _bjs_roundtripPolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundtripPolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) + return ret.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_optionalPolygon") +@_cdecl("bjs_optionalPolygon") +public func _bjs_optionalPolygon(_ polygonIsSome: Int32, _ polygonValue: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = optionalPolygon(_: Optional.bridgeJSLiftParameter(polygonIsSome, polygonValue).map { Polygon.bridgeFromJS($0) }) + return ret.map { $0.bridgeToJS() }.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_polygonArray") +@_cdecl("bjs_polygonArray") +public func _bjs_polygonArray() -> Void { + #if arch(wasm32) + let ret = polygonArray(_: [PolygonReference].bridgeJSStackPop().map { Polygon.bridgeFromJS($0) }) + ret.map { $0.bridgeToJS() }.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_validatePolygon") +@_cdecl("bjs_validatePolygon") +public func _bjs_validatePolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + do { + let ret = try validatePolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) + return ret.bridgeToJS().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_makeTag") +@_cdecl("bjs_makeTag") +public func _bjs_makeTag(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = makeTag(_: String.bridgeJSLiftParameter(nameBytes, nameLength)) + return ret.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundtripTags") +@_cdecl("bjs_roundtripTags") +public func _bjs_roundtripTags() -> Void { + #if arch(wasm32) + let ret = roundtripTags(_: [Optional].bridgeJSStackPop().map { $0.map { AliasedTag.bridgeFromJS($0) } }) + ret.map { $0.map { $0.bridgeToJS() } }.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_describeUser") +@_cdecl("bjs_describeUser") +public func _bjs_describeUser(_ owner: Int32) -> Int32 { + #if arch(wasm32) + let ret = describeUser(_: AnyHasOptionalUserId.bridgeJSLiftParameter(owner)) as! _BridgedSwiftProtocolExportable + return ret.bridgeJSLowerAsProtocolReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PolygonReference_init") +@_cdecl("bjs_PolygonReference_init") +public func _bjs_PolygonReference_init(_ underlying: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = PolygonReference(underlying: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(underlying))) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PolygonReference_snapshot") +@_cdecl("bjs_PolygonReference_snapshot") +public func _bjs_PolygonReference_snapshot(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = PolygonReference.bridgeJSLiftParameter(_self).snapshot() + return ret.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PolygonReference_merge") +@_cdecl("bjs_PolygonReference_merge") +public func _bjs_PolygonReference_merge(_ _self: UnsafeMutableRawPointer, _ other: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = PolygonReference.bridgeJSLiftParameter(_self).merge(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(other))) + return ret.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PolygonReference_static_origin") +@_cdecl("bjs_PolygonReference_static_origin") +public func _bjs_PolygonReference_static_origin() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = PolygonReference.origin() + return ret.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PolygonReference_deinit") +@_cdecl("bjs_PolygonReference_deinit") +public func _bjs_PolygonReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension PolygonReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_PolygonReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_PolygonReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_PolygonReference_wrap") +fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_PolygonReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_PolygonReference_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_TagReference_init") +@_cdecl("bjs_TagReference_init") +public func _bjs_TagReference_init(_ underlying: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = TagReference(underlying: Tag.bridgeFromJS(TagReference.bridgeJSLiftParameter(underlying))) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_TagReference_deinit") +@_cdecl("bjs_TagReference_deinit") +public func _bjs_TagReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension TagReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_TagReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_TagReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_TagReference_wrap") +fileprivate func _bjs_TagReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_TagReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_TagReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_TagReference_wrap_extern(pointer) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_acceptTagged") +fileprivate func bjs_acceptTagged_extern(_ taggedBytes: Int32, _ taggedLength: Int32) -> Void +#else +fileprivate func bjs_acceptTagged_extern(_ taggedBytes: Int32, _ taggedLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_acceptTagged(_ taggedBytes: Int32, _ taggedLength: Int32) -> Void { + return bjs_acceptTagged_extern(taggedBytes, taggedLength) +} + +func _$acceptTagged(_ tagged: Tagged) throws(JSException) -> Void { + tagged.bridgeToJS().bridgeJSWithLoweredParameter { (taggedBytes, taggedLength) in + bjs_acceptTagged(taggedBytes, taggedLength) + } + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_acceptOptionalTagged") +fileprivate func bjs_acceptOptionalTagged_extern(_ taggedIsSome: Int32, _ taggedBytes: Int32, _ taggedLength: Int32) -> Void +#else +fileprivate func bjs_acceptOptionalTagged_extern(_ taggedIsSome: Int32, _ taggedBytes: Int32, _ taggedLength: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_acceptOptionalTagged(_ taggedIsSome: Int32, _ taggedBytes: Int32, _ taggedLength: Int32) -> Void { + return bjs_acceptOptionalTagged_extern(taggedIsSome, taggedBytes, taggedLength) +} + +func _$acceptOptionalTagged(_ tagged: Optional) throws(JSException) -> Void { + tagged.map { + $0.bridgeToJS() + } .bridgeJSWithLoweredParameter { (taggedIsSome, taggedBytes, taggedLength) in + bjs_acceptOptionalTagged(taggedIsSome, taggedBytes, taggedLength) + } + if let error = _swift_js_take_exception() { + throw error + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_roundtripTagged") +fileprivate func bjs_roundtripTagged_extern(_ taggedBytes: Int32, _ taggedLength: Int32) -> Int32 +#else +fileprivate func bjs_roundtripTagged_extern(_ taggedBytes: Int32, _ taggedLength: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_roundtripTagged(_ taggedBytes: Int32, _ taggedLength: Int32) -> Int32 { + return bjs_roundtripTagged_extern(taggedBytes, taggedLength) +} + +func _$roundtripTagged(_ tagged: Tagged) throws(JSException) -> Tagged { + let ret0 = tagged.bridgeToJS().bridgeJSWithLoweredParameter { (taggedBytes, taggedLength) in + let ret = bjs_roundtripTagged(taggedBytes, taggedLength) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return Tagged.bridgeFromJS(String.bridgeJSLiftReturn(ret)) +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_produceOptionalCanvas") +fileprivate func bjs_produceOptionalCanvas_extern() -> Void +#else +fileprivate func bjs_produceOptionalCanvas_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_produceOptionalCanvas() -> Void { + return bjs_produceOptionalCanvas_extern() +} + +func _$produceOptionalCanvas() throws(JSException) -> Optional { + bjs_produceOptionalCanvas() + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn().map { + Canvas.bridgeFromJS($0) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Surface_init") +fileprivate func bjs_Surface_init_extern() -> Int32 +#else +fileprivate func bjs_Surface_init_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Surface_init() -> Int32 { + return bjs_Surface_init_extern() +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Surface_label_get") +fileprivate func bjs_Surface_label_get_extern(_ self: Int32) -> Int32 +#else +fileprivate func bjs_Surface_label_get_extern(_ self: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_Surface_label_get(_ self: Int32) -> Int32 { + return bjs_Surface_label_get_extern(self) +} + +func _$Surface_init() throws(JSException) -> JSObject { + let ret = bjs_Surface_init() + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) +} + +func _$Surface_label_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Surface_label_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.json new file mode 100644 index 000000000..d76761e0b --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.json @@ -0,0 +1,145 @@ +{ + "exported" : { + "aliases" : [ + { + "swiftCallName" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + ], + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_PolygonReference_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "sides", + "name" : "sides", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "PolygonReference", + "properties" : [ + + ], + "swiftCallName" : "PolygonReference" + } + ], + "enums" : [ + + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_makePolygonFactory", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makePolygonFactory", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuley_Al7Polygon", + "moduleName" : "TestModule", + "parameters" : [ + + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + }, + { + "abiName" : "bjs_makePolygonInspector", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makePolygonInspector", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "10TestModuleAl7Polygon_Si", + "moduleName" : "TestModule", + "parameters" : [ + { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "protocols" : [ + + ], + "structs" : [ + + ] + }, + "moduleName" : "TestModule", + "usedExternalModules" : [ + + ] +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.swift new file mode 100644 index 000000000..3613ead7e --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.swift @@ -0,0 +1,188 @@ +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuleAl7Polygon_Si") +fileprivate func invoke_js_callback_TestModule_10TestModuleAl7Polygon_Si_extern(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func invoke_js_callback_TestModule_10TestModuleAl7Polygon_Si_extern(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuleAl7Polygon_Si(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 { + return invoke_js_callback_TestModule_10TestModuleAl7Polygon_Si_extern(callback, param0) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuleAl7Polygon_Si") +fileprivate func make_swift_closure_TestModule_10TestModuleAl7Polygon_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuleAl7Polygon_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuleAl7Polygon_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuleAl7Polygon_Si_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModuleAl7Polygon_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (Polygon) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] param0 in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let param0Pointer = param0.bridgeToJS().bridgeJSLowerParameter() + let ret = invoke_js_callback_TestModule_10TestModuleAl7Polygon_Si(callbackValue, param0Pointer) + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (Polygon) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Polygon) -> Int) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuleAl7Polygon_Si, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuleAl7Polygon_Si") +@_cdecl("invoke_swift_closure_TestModule_10TestModuleAl7Polygon_Si") +public func _invoke_swift_closure_TestModule_10TestModuleAl7Polygon_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Polygon) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(param0))) + return result.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_TestModule_10TestModuley_Al7Polygon") +fileprivate func invoke_js_callback_TestModule_10TestModuley_Al7Polygon_extern(_ callback: Int32) -> UnsafeMutableRawPointer +#else +fileprivate func invoke_js_callback_TestModule_10TestModuley_Al7Polygon_extern(_ callback: Int32) -> UnsafeMutableRawPointer { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_TestModule_10TestModuley_Al7Polygon(_ callback: Int32) -> UnsafeMutableRawPointer { + return invoke_js_callback_TestModule_10TestModuley_Al7Polygon_extern(callback) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_TestModule_10TestModuley_Al7Polygon") +fileprivate func make_swift_closure_TestModule_10TestModuley_Al7Polygon_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_TestModule_10TestModuley_Al7Polygon_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_TestModule_10TestModuley_Al7Polygon(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_TestModule_10TestModuley_Al7Polygon_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_10TestModuley_Al7Polygon { + static func bridgeJSLift(_ callbackId: Int32) -> () -> Polygon { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret = invoke_js_callback_TestModule_10TestModuley_Al7Polygon(callbackValue) + return Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftReturn(ret)) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == () -> Polygon { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> Polygon) { + self.init( + makeClosure: make_swift_closure_TestModule_10TestModuley_Al7Polygon, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_TestModule_10TestModuley_Al7Polygon") +@_cdecl("invoke_swift_closure_TestModule_10TestModuley_Al7Polygon") +public func _invoke_swift_closure_TestModule_10TestModuley_Al7Polygon(_ boxPtr: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<() -> Polygon>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure() + return result.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makePolygonFactory") +@_cdecl("bjs_makePolygonFactory") +public func _bjs_makePolygonFactory() -> Int32 { + #if arch(wasm32) + let ret = makePolygonFactory() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makePolygonInspector") +@_cdecl("bjs_makePolygonInspector") +public func _bjs_makePolygonInspector() -> Int32 { + #if arch(wasm32) + let ret = makePolygonInspector() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PolygonReference_init") +@_cdecl("bjs_PolygonReference_init") +public func _bjs_PolygonReference_init(_ sides: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = PolygonReference(sides: Int.bridgeJSLiftParameter(sides)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PolygonReference_deinit") +@_cdecl("bjs_PolygonReference_deinit") +public func _bjs_PolygonReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension PolygonReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_PolygonReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_PolygonReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_PolygonReference_wrap") +fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_PolygonReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_PolygonReference_wrap_extern(pointer) +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ArrayTypes.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ArrayTypes.json index d4ac7a15f..0fac3bf21 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ArrayTypes.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ArrayTypes.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "methods" : [ diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Async.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Async.json index 8684291f0..41cbc5017 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Async.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Async.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileExtension.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileExtension.json index 4c8d575b0..bfa71444c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileExtension.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileExtension.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileFunctionTypes.ReverseOrder.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileFunctionTypes.ReverseOrder.json index 6c589de87..053757256 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileFunctionTypes.ReverseOrder.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileFunctionTypes.ReverseOrder.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileFunctionTypes.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileFunctionTypes.json index 9bec040f1..41aa858ac 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileFunctionTypes.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileFunctionTypes.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileTypeResolution.ReverseOrder.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileTypeResolution.ReverseOrder.json index edf8177c1..49d656dcd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileTypeResolution.ReverseOrder.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileTypeResolution.ReverseOrder.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "methods" : [ diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileTypeResolution.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileTypeResolution.json index 58bfadab7..377e875bd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileTypeResolution.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/CrossFileTypeResolution.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DefaultParameters.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DefaultParameters.json index e7874c072..40e3672b7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DefaultParameters.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DefaultParameters.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DictionaryTypes.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DictionaryTypes.json index b1185c644..6830240eb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DictionaryTypes.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DictionaryTypes.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "methods" : [ diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.json new file mode 100644 index 000000000..0d63db899 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.json @@ -0,0 +1,96 @@ +{ + "exported" : { + "aliases" : [ + { + "swiftCallName" : "Color", + "underlying" : { + "swiftHeapObject" : { + "_0" : "ColorBox" + } + } + } + ], + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_ColorBox_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "ColorBox", + "properties" : [ + + ], + "swiftCallName" : "ColorBox" + } + ], + "enums" : [ + + ], + "exposeToGlobal" : false, + "functions" : [ + { + "abiName" : "bjs_roundtripColor", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundtripColor", + "parameters" : [ + { + "label" : "_", + "name" : "color", + "type" : { + "alias" : { + "name" : "Color", + "underlying" : { + "swiftHeapObject" : { + "_0" : "ColorBox" + } + } + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Color", + "underlying" : { + "swiftHeapObject" : { + "_0" : "ColorBox" + } + } + } + } + } + ], + "protocols" : [ + + ], + "structs" : [ + + ] + }, + "moduleName" : "TestModule", + "usedExternalModules" : [ + + ] +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.swift new file mode 100644 index 000000000..615110c90 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.swift @@ -0,0 +1,52 @@ +@_expose(wasm, "bjs_roundtripColor") +@_cdecl("bjs_roundtripColor") +public func _bjs_roundtripColor(_ color: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundtripColor(_: Color.bridgeFromJS(ColorBox.bridgeJSLiftParameter(color))) + return ret.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ColorBox_init") +@_cdecl("bjs_ColorBox_init") +public func _bjs_ColorBox_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = ColorBox(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_ColorBox_deinit") +@_cdecl("bjs_ColorBox_deinit") +public func _bjs_ColorBox_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension ColorBox: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_ColorBox_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_ColorBox_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_ColorBox_wrap") +fileprivate func _bjs_ColorBox_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_ColorBox_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_ColorBox_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ColorBox_wrap_extern(pointer) +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValue.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValue.json index 873c5c49f..39b9d7211 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValue.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValue.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "methods" : [ diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumCase.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumCase.json index c4095b502..8fbb08f28 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumCase.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumCase.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumNamespace.Global.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumNamespace.Global.json index 103a67999..be74590c6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumNamespace.Global.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumNamespace.Global.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumNamespace.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumNamespace.json index f9890d36b..175c4fa03 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumNamespace.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumNamespace.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumRawType.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumRawType.json index 1cf99cd39..2adb178a3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumRawType.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumRawType.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/FixedWidthIntegers.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/FixedWidthIntegers.json index 1186ad27d..0844c7475 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/FixedWidthIntegers.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/FixedWidthIntegers.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json index f4a4440c6..bca32c30d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/IdentityModeClass.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ImportedTypeInExportedInterface.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ImportedTypeInExportedInterface.json index 600ae8c89..e4d10d07b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ImportedTypeInExportedInterface.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ImportedTypeInExportedInterface.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSTypedArrayTypes.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSTypedArrayTypes.json index a7b9c8623..5d4425096 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSTypedArrayTypes.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSTypedArrayTypes.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSValue.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSValue.json index f0cd29565..eba5d34fb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSValue.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSValue.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/MixedGlobal.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/MixedGlobal.json index 0d30063ee..05279a762 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/MixedGlobal.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/MixedGlobal.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/MixedPrivate.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/MixedPrivate.json index e6bcf2e5c..0f46b4ddb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/MixedPrivate.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/MixedPrivate.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.Global.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.Global.json index ef9e0b758..243f3c885 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.Global.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.Global.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.json index 397d1123c..7823e5fdc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Namespaces.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NestedType.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NestedType.json index f924b3eba..c741304a7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NestedType.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/NestedType.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "methods" : [ diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Optionals.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Optionals.json index e9d78cbbc..d86d06f86 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Optionals.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Optionals.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PrimitiveParameters.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PrimitiveParameters.json index 320499ff3..8b7ee7338 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PrimitiveParameters.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PrimitiveParameters.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PrimitiveReturn.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PrimitiveReturn.json index 414fedbbd..a2b08f4c6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PrimitiveReturn.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PrimitiveReturn.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PropertyTypes.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PropertyTypes.json index 281538dd6..8e6496336 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PropertyTypes.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/PropertyTypes.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Protocol.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Protocol.json index feca4615b..bc443c6c0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Protocol.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Protocol.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolInClosure.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolInClosure.json index 70273f8b3..56f8e26e0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolInClosure.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ProtocolInClosure.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticFunctions.Global.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticFunctions.Global.json index 800018440..c023fd8ab 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticFunctions.Global.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticFunctions.Global.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticFunctions.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticFunctions.json index 36110488c..c80a6bb3e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticFunctions.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticFunctions.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticProperties.Global.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticProperties.Global.json index 1cbe44619..7935c2aa1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticProperties.Global.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticProperties.Global.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticProperties.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticProperties.json index 8fc0667b0..35a94cddd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticProperties.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StaticProperties.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StringParameter.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StringParameter.json index d9dc0ec43..68b13c0b0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StringParameter.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StringParameter.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StringReturn.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StringReturn.json index e2cf9ffac..f1e2ccbfd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StringReturn.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StringReturn.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClass.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClass.json index a3ddab63e..e1bb767c1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClass.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClass.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json index b1e306c07..0085dd6c4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosure.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.json index bfde01318..d1a4b6882 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStructImports.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStructImports.json index a9b0d22bf..ba5aa11de 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStructImports.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStructImports.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Throws.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Throws.json index 942e5fb45..0e45eefca 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Throws.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Throws.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/UnsafePointer.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/UnsafePointer.json index a382778e9..1b1a1088b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/UnsafePointer.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/UnsafePointer.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/VoidParameterVoidReturn.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/VoidParameterVoidReturn.json index d31f775fb..4fef14d6a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/VoidParameterVoidReturn.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/VoidParameterVoidReturn.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.d.ts new file mode 100644 index 000000000..3ee338254 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.d.ts @@ -0,0 +1,71 @@ +// 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 interface HasOptionalUserId { + readonly userId: number | null; +} + +export const InnerTagValues: { + readonly Tag: { + readonly Payload: 0; + readonly Empty: 1; + }; +}; + +export type InnerTagTag = + { tag: typeof InnerTagValues.Tag.Payload; param0: number } | { tag: typeof InnerTagValues.Tag.Empty } + +export type InnerTagObject = typeof InnerTagValues; + +/// 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 PolygonReference extends SwiftHeapObject { + snapshot(): PolygonReference; + merge(other: PolygonReference): PolygonReference; +} +export interface TagReference extends SwiftHeapObject { +} +export interface Surface { + readonly label: string; +} +export type Exports = { + PolygonReference: { + new(underlying: PolygonReference): PolygonReference; + origin(): PolygonReference; + } + TagReference: { + new(underlying: TagReference): TagReference; + } + roundtripPolygon(polygon: PolygonReference): PolygonReference; + optionalPolygon(polygon: PolygonReference | null): PolygonReference | null; + polygonArray(polygons: PolygonReference[]): PolygonReference[]; + validatePolygon(polygon: PolygonReference): PolygonReference; + makeTag(name: string): TagReference; + roundtripTags(xs: (InnerTagTag | null)[]): (InnerTagTag | null)[]; + describeUser(owner: HasOptionalUserId): HasOptionalUserId; + InnerTag: InnerTagObject +} +export type Imports = { + acceptTagged(tagged: string): void; + acceptOptionalTagged(tagged: string | null): void; + roundtripTagged(tagged: string): string; + produceOptionalCanvas(): Surface | null; + Surface: { + new(): Surface; + } +} +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/Alias.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js new file mode 100644 index 000000000..c55e429d5 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js @@ -0,0 +1,517 @@ +// 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 const InnerTagValues = { + Tag: { + Payload: 0, + Empty: 1, + }, +}; +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 = []; + let taStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + const __bjs_createInnerTagValuesHelpers = () => ({ + lower: (value) => { + const enumTag = value.tag; + switch (enumTag) { + case InnerTagValues.Tag.Payload: { + i32Stack.push((value.param0 | 0)); + return InnerTagValues.Tag.Payload; + } + case InnerTagValues.Tag.Empty: { + return InnerTagValues.Tag.Empty; + } + default: throw new Error("Unknown InnerTagValues tag: " + String(enumTag)); + } + }, + lift: (tag) => { + tag = tag | 0; + switch (tag) { + case InnerTagValues.Tag.Payload: { + const int = i32Stack.pop(); + return { tag: InnerTagValues.Tag.Payload, param0: int }; + } + case InnerTagValues.Tag.Empty: return { tag: InnerTagValues.Tag.Empty }; + default: throw new Error("Unknown InnerTagValues tag returned from Swift: " + String(tag)); + } + } + }); + + return { + /** + * @param {WebAssembly.Imports} importObject + */ + addImports: (importObject, importsContext) => { + bjs = {}; + importObject["bjs"] = bjs; + const imports = options.getImports(importsContext); + 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(); + } + const taCtors = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; + bjs["swift_js_push_typed_array"] = function(kind, ptr, count) { + const Ctor = taCtors[kind]; + const byteLen = count * Ctor.BYTES_PER_ELEMENT; + const copy = memory.buffer.slice(ptr, ptr + byteLen); + taStack.push(Array.from(new Ctor(copy))); + } + 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_PolygonReference_wrap"] = function(pointer) { + const obj = _exports['PolygonReference'].__construct(pointer); + return swift.memory.retain(obj); + }; + importObject["TestModule"]["bjs_TagReference_wrap"] = function(pointer) { + const obj = _exports['TagReference'].__construct(pointer); + return swift.memory.retain(obj); + }; + const TestModule = importObject["TestModule"] = importObject["TestModule"] || {}; + TestModule["bjs_acceptTagged"] = function bjs_acceptTagged(taggedBytes, taggedCount) { + try { + const string = decodeString(taggedBytes, taggedCount); + imports.acceptTagged(string); + } catch (error) { + setException(error); + } + } + TestModule["bjs_acceptOptionalTagged"] = function bjs_acceptOptionalTagged(taggedIsSome, taggedBytes, taggedCount) { + try { + let optResult; + if (taggedIsSome) { + const string = decodeString(taggedBytes, taggedCount); + optResult = string; + } else { + optResult = null; + } + imports.acceptOptionalTagged(optResult); + } catch (error) { + setException(error); + } + } + TestModule["bjs_roundtripTagged"] = function bjs_roundtripTagged(taggedBytes, taggedCount) { + try { + const string = decodeString(taggedBytes, taggedCount); + let ret = imports.roundtripTagged(string); + tmpRetBytes = textEncoder.encode(ret); + return tmpRetBytes.length; + } catch (error) { + setException(error); + } + } + TestModule["bjs_produceOptionalCanvas"] = function bjs_produceOptionalCanvas() { + try { + let ret = imports.produceOptionalCanvas(); + const isSome = ret != null; + if (isSome) { + const objId = swift.memory.retain(ret); + i32Stack.push(objId); + } + i32Stack.push(isSome ? 1 : 0); + } catch (error) { + setException(error); + } + } + TestModule["bjs_Surface_init"] = function bjs_Surface_init() { + try { + return swift.memory.retain(new imports.Surface()); + } catch (error) { + setException(error); + return 0 + } + } + TestModule["bjs_Surface_label_get"] = function bjs_Surface_label_get(self) { + try { + let ret = swift.memory.getObject(self).label; + tmpRetBytes = textEncoder.encode(ret); + return tmpRetBytes.length; + } catch (error) { + setException(error); + } + } + TestModule["bjs_HasOptionalUserId_userId_get"] = function bjs_HasOptionalUserId_userId_get(self) { + try { + let ret = swift.memory.getObject(self).userId; + tmpRetOptionalInt = ret; + } catch (error) { + setException(error); + } + } + }, + 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 PolygonReference extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PolygonReference_deinit, PolygonReference.prototype, null); + } + + constructor(underlying) { + const ret = instance.exports.bjs_PolygonReference_init(underlying.pointer); + return PolygonReference.__construct(ret); + } + snapshot() { + const ret = instance.exports.bjs_PolygonReference_snapshot(this.pointer); + return PolygonReference.__construct(ret); + } + merge(other) { + const ret = instance.exports.bjs_PolygonReference_merge(this.pointer, other.pointer); + return PolygonReference.__construct(ret); + } + static origin() { + const ret = instance.exports.bjs_PolygonReference_static_origin(); + return PolygonReference.__construct(ret); + } + } + class TagReference extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_TagReference_deinit, TagReference.prototype, null); + } + + constructor(underlying) { + const ret = instance.exports.bjs_TagReference_init(underlying.pointer); + return TagReference.__construct(ret); + } + } + const InnerTagHelpers = __bjs_createInnerTagValuesHelpers(); + enumHelpers.InnerTag = InnerTagHelpers; + + const exports = { + PolygonReference, + TagReference, + roundtripPolygon: function bjs_roundtripPolygon(polygon) { + const ret = instance.exports.bjs_roundtripPolygon(polygon.pointer); + return PolygonReference.__construct(ret); + }, + optionalPolygon: function bjs_optionalPolygon(polygon) { + const isSome = polygon != null; + let result; + if (isSome) { + result = polygon.pointer; + } else { + result = 0; + } + instance.exports.bjs_optionalPolygon(+isSome, result); + const pointer = tmpRetOptionalHeapObject; + tmpRetOptionalHeapObject = undefined; + const optResult = pointer === null ? null : PolygonReference.__construct(pointer); + return optResult; + }, + polygonArray: function bjs_polygonArray(polygons) { + for (const elem of polygons) { + ptrStack.push(elem.pointer); + } + i32Stack.push(polygons.length); + instance.exports.bjs_polygonArray(); + const arrayLen = i32Stack.pop(); + let arrayResult; + if (arrayLen === -1) { + arrayResult = taStack.pop(); + } else { + arrayResult = []; + for (let i = 0; i < arrayLen; i++) { + const ptr = ptrStack.pop(); + const obj = PolygonReference.__construct(ptr); + arrayResult.push(obj); + } + arrayResult.reverse(); + } + return arrayResult; + }, + validatePolygon: function bjs_validatePolygon(polygon) { + const ret = instance.exports.bjs_validatePolygon(polygon.pointer); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + return PolygonReference.__construct(ret); + }, + makeTag: function bjs_makeTag(name) { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + const ret = instance.exports.bjs_makeTag(nameId, nameBytes.length); + return TagReference.__construct(ret); + }, + roundtripTags: function bjs_roundtripTags(xs) { + for (const elem of xs) { + const isSome = elem != null ? 1 : 0; + if (isSome) { + const caseId = enumHelpers.InnerTag.lower(elem); + i32Stack.push(caseId); + } else { + i32Stack.push(-1); + } + } + i32Stack.push(xs.length); + instance.exports.bjs_roundtripTags(); + const arrayLen = i32Stack.pop(); + let arrayResult; + if (arrayLen === -1) { + arrayResult = taStack.pop(); + } else { + arrayResult = []; + for (let i = 0; i < arrayLen; i++) { + const caseId1 = i32Stack.pop(); + let optValue; + if (caseId1 === -1) { + optValue = null; + } else { + optValue = enumHelpers.InnerTag.lift(caseId1); + } + arrayResult.push(optValue); + } + arrayResult.reverse(); + } + return arrayResult; + }, + describeUser: function bjs_describeUser(owner) { + const ret = instance.exports.bjs_describeUser(swift.memory.retain(owner)); + const ret1 = swift.memory.getObject(ret); + swift.memory.release(ret); + return ret1; + }, + InnerTag: InnerTagValues, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.d.ts new file mode 100644 index 000000000..f1d5d5fa9 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.d.ts @@ -0,0 +1,31 @@ +// 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 PolygonReference extends SwiftHeapObject { +} +export type Exports = { + PolygonReference: { + new(sides: number): PolygonReference; + } + makePolygonFactory(): () => PolygonReference; + makePolygonInspector(): (arg0: PolygonReference) => number; +} +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/AliasInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js new file mode 100644 index 000000000..21c96aed6 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js @@ -0,0 +1,372 @@ +// 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 = []; + let taStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + const swiftClosureRegistry = (typeof FinalizationRegistry === "undefined") ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((state) => { + if (state.unregistered) { return; } + instance?.exports?.bjs_release_swift_closure(state.pointer); + }); + const makeClosure = (pointer, file, line, func) => { + const state = { pointer, file, line, unregistered: false }; + const real = (...args) => { + if (state.unregistered) { + const bytes = new Uint8Array(memory.buffer, state.file); + let length = 0; + while (bytes[length] !== 0) { length += 1; } + const fileID = decodeString(state.file, length); + throw new Error(`Attempted to call a released JSTypedClosure created at ${fileID}:${state.line}`); + } + return func(...args); + }; + real.__unregister = () => { + if (state.unregistered) { return; } + state.unregistered = true; + swiftClosureRegistry.unregister(state); + }; + swiftClosureRegistry.register(real, state, state); + return swift.memory.retain(real); + }; + + + 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(); + } + const taCtors = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; + bjs["swift_js_push_typed_array"] = function(kind, ptr, count) { + const Ctor = taCtors[kind]; + const byteLen = count * Ctor.BYTES_PER_ELEMENT; + const copy = memory.buffer.slice(ptr, ptr + byteLen); + taStack.push(Array.from(new Ctor(copy))); + } + 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) {} + bjs["swift_js_closure_unregister"] = function(funcRef) { + const func = swift.memory.getObject(funcRef); + func.__unregister(); + } + bjs["invoke_js_callback_TestModule_10TestModuleAl7Polygon_Si"] = function(callbackId, param0) { + try { + const callback = swift.memory.getObject(callbackId); + let ret = callback(_exports['PolygonReference'].__construct(param0)); + return ret; + } catch (error) { + setException(error); + return 0 + } + } + bjs["make_swift_closure_TestModule_10TestModuleAl7Polygon_Si"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuleAl7Polygon_Si = function(param0) { + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuleAl7Polygon_Si(boxPtr, param0.pointer); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + return ret; + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuleAl7Polygon_Si); + } + bjs["invoke_js_callback_TestModule_10TestModuley_Al7Polygon"] = function(callbackId) { + try { + const callback = swift.memory.getObject(callbackId); + let ret = callback(); + return ret.pointer; + } catch (error) { + setException(error); + return 0 + } + } + bjs["make_swift_closure_TestModule_10TestModuley_Al7Polygon"] = function(boxPtr, file, line) { + const lower_closure_TestModule_10TestModuley_Al7Polygon = function() { + const ret = instance.exports.invoke_swift_closure_TestModule_10TestModuley_Al7Polygon(boxPtr); + if (tmpRetException) { + const error = swift.memory.getObject(tmpRetException); + swift.memory.release(tmpRetException); + tmpRetException = undefined; + throw error; + } + return _exports['PolygonReference'].__construct(ret); + }; + return makeClosure(boxPtr, file, line, lower_closure_TestModule_10TestModuley_Al7Polygon); + } + // Wrapper functions for module: TestModule + if (!importObject["TestModule"]) { + importObject["TestModule"] = {}; + } + importObject["TestModule"]["bjs_PolygonReference_wrap"] = function(pointer) { + const obj = _exports['PolygonReference'].__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 PolygonReference extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_PolygonReference_deinit, PolygonReference.prototype, null); + } + + constructor(sides) { + const ret = instance.exports.bjs_PolygonReference_init(sides); + return PolygonReference.__construct(ret); + } + } + const exports = { + PolygonReference, + makePolygonFactory: function bjs_makePolygonFactory() { + const ret = instance.exports.bjs_makePolygonFactory(); + return swift.memory.getObject(ret); + }, + makePolygonInspector: function bjs_makePolygonInspector() { + const ret = instance.exports.bjs_makePolygonInspector(); + return swift.memory.getObject(ret); + }, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.d.ts new file mode 100644 index 000000000..9525038e6 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.d.ts @@ -0,0 +1,30 @@ +// 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 ColorBox extends SwiftHeapObject { +} +export type Exports = { + ColorBox: { + new(name: string): ColorBox; + } + roundtripColor(color: ColorBox): ColorBox; +} +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/EnumAlias.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js new file mode 100644 index 000000000..01f0472ab --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js @@ -0,0 +1,295 @@ +// 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 = []; + let taStack = []; + 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(); + } + const taCtors = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; + bjs["swift_js_push_typed_array"] = function(kind, ptr, count) { + const Ctor = taCtors[kind]; + const byteLen = count * Ctor.BYTES_PER_ELEMENT; + const copy = memory.buffer.slice(ptr, ptr + byteLen); + taStack.push(Array.from(new Ctor(copy))); + } + 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_ColorBox_wrap"] = function(pointer) { + const obj = _exports['ColorBox'].__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 ColorBox extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_ColorBox_deinit, ColorBox.prototype, null); + } + + constructor(name) { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + const ret = instance.exports.bjs_ColorBox_init(nameId, nameBytes.length); + return ColorBox.__construct(ret); + } + } + const exports = { + ColorBox, + roundtripColor: function bjs_roundtripColor(color) { + const ret = instance.exports.bjs_roundtripColor(color.pointer); + return ColorBox.__construct(ret); + }, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Sources/JavaScriptKit/Macros.swift b/Sources/JavaScriptKit/Macros.swift index 3189cdeab..191cf15d6 100644 --- a/Sources/JavaScriptKit/Macros.swift +++ b/Sources/JavaScriptKit/Macros.swift @@ -113,8 +113,12 @@ 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) = - Builtin.ExternalMacro +public macro JS( + as aliasOf: Any.Type? = nil, + 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/BridgeJSGlobalTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSGlobalTests/Generated/JavaScript/BridgeJS.json index 5e9626840..48c0904bf 100644 --- a/Tests/BridgeJSGlobalTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSGlobalTests/Generated/JavaScript/BridgeJS.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json index 56db0a3ed..53d837ece 100644 --- a/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSIdentityTests/Generated/JavaScript/BridgeJS.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Tests/BridgeJSRuntimeTests/AliasAPIs.swift b/Tests/BridgeJSRuntimeTests/AliasAPIs.swift new file mode 100644 index 000000000..bd6737b77 --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/AliasAPIs.swift @@ -0,0 +1,401 @@ +import JavaScriptKit + +@JS(as: PolygonReference.self) struct Polygon { + var vertices: [Double] + var label: String + + consuming func bridgeToJS() -> PolygonReference { + return PolygonReference(underlying: self) + } + + static func bridgeFromJS(_ value: consuming PolygonReference) -> Polygon { + return value.underlying + } +} + +@JS final class PolygonReference { + var underlying: Polygon + + @JS init(verticesData: [Double], label: String) { + self.underlying = Polygon(vertices: verticesData, label: label) + } + + init(underlying: Polygon) { + self.underlying = underlying + } + + @JS func vertexCount() -> Int { + return underlying.vertices.count + } + + @JS func summary() -> String { + return "\(underlying.label)(\(underlying.vertices.count))" + } + + @JS func snapshot() -> Polygon { + return underlying + } + + @JS func merge(_ other: Polygon) -> Polygon { + var combined = underlying + combined.vertices.append(contentsOf: other.vertices) + return combined + } + + @JS static func origin(label: String) -> Polygon { + return Polygon(vertices: [], label: label) + } +} + +@JS(as: TagReference.self) struct Tag { + var name: String + + consuming func bridgeToJS() -> TagReference { + return TagReference(underlying: self) + } + + static func bridgeFromJS(_ value: consuming TagReference) -> Tag { + return value.underlying + } +} + +@JS final class TagReference { + var underlying: Tag + + init(underlying: Tag) { + self.underlying = underlying + } + + @JS func describe() -> String { + return "tag:\(underlying.name)" + } +} + +@JS func makeTag(_ name: String) -> Tag { + return Tag(name: name) +} + +@JS func roundTripPolygon(_ polygon: Polygon) -> Polygon { + return polygon +} + +@JS func appendVertex(_ polygon: Polygon, _ value: Double) -> Polygon { + var copy = polygon + copy.vertices.append(value) + return copy +} + +@JS func optionalRoundTripPolygon(_ polygon: Polygon?) -> Polygon? { + return polygon +} + +@JS func polygonVertexCount(_ polygon: Polygon) -> Int { + return polygon.vertices.count +} + +@JS func roundTripPolygonArray(_ polygons: [Polygon]) -> [Polygon] { + return polygons +} + +@JS func concatPolygons(_ polygons: [Polygon]) -> Polygon { + var combined = Polygon(vertices: [], label: "concat") + for p in polygons { + combined.vertices.append(contentsOf: p.vertices) + } + return combined +} + +@JS func validatePolygon(_ polygon: Polygon) throws(JSException) -> Polygon { + if polygon.vertices.isEmpty { + throw JSException(JSError(message: "empty polygon").jsValue) + } + return polygon +} + +@JS func splitPolygon(_ polygon: Polygon) -> [Polygon] { + return polygon.vertices.map { Polygon(vertices: [$0], label: polygon.label) } +} + +@JS(as: TokenReference.self) struct Token: ~Copyable { + let value: Int + + consuming func bridgeToJS() -> TokenReference { + return TokenReference(value: value) + } + + static func bridgeFromJS(_ value: consuming TokenReference) -> Token { + return Token(value: value.value) + } +} + +@JS final class TokenReference { + let value: Int + + @JS init(value: Int) { + self.value = value + } + + @JS func read() -> Int { + return value + } +} + +@JS func incrementToken(_ token: borrowing Token) -> Token { + return Token(value: token.value + 1) +} + +@JS func makeToken(_ value: Int) -> Token { + return Token(value: value) +} + +@JS func makePolygonInspector() -> (Polygon) -> Int { + return { polygon in polygon.vertices.count } +} + +@JS func asyncMakePolygon(_ label: String) async -> Polygon { + return Polygon(vertices: [9, 9], label: label) +} + +@JS func roundTripOptionalPolygonArray(_ polygons: [Polygon?]) -> [Polygon?] { + return polygons +} + +@JS(as: TagHolderReference.self) struct TagHolder { + var tag: Tag + var version: Int + + consuming func bridgeToJS() -> TagHolderReference { + return TagHolderReference(tag: tag, version: version) + } + + static func bridgeFromJS(_ value: consuming TagHolderReference) -> TagHolder { + return TagHolder(tag: value.tag, version: value.version) + } +} + +@JS final class TagHolderReference { + @JS var tag: Tag + @JS var version: Int + + @JS init(tag: Tag, version: Int) { + self.tag = tag + self.version = version + } + + @JS func describe() -> String { + return "holder(\(tag.name), v\(version))" + } +} + +@JS func makeTagHolder(_ name: String, _ version: Int) -> TagHolder { + return TagHolder(tag: Tag(name: name), version: version) +} + +@JS(as: JSCoordinate.self) struct Coordinate { + var latitude: Double + var longitude: Double + + var hemisphere: String { + latitude >= 0 ? "northern" : "southern" + } + + consuming func bridgeToJS() -> JSCoordinate { + return JSCoordinate(latitude: latitude, longitude: longitude) + } + + static func bridgeFromJS(_ value: consuming JSCoordinate) -> Coordinate { + return Coordinate(latitude: value.latitude, longitude: value.longitude) + } +} + +@JS struct JSCoordinate { + var latitude: Double + var longitude: Double + + @JS init(latitude: Double, longitude: Double) { + self.latitude = latitude + self.longitude = longitude + } +} + +@JS func roundTripCoordinate(_ coordinate: Coordinate) -> Coordinate { + return coordinate +} + +@JS(as: PriorityReference.self) enum Priority { + case low, medium, high + + consuming func bridgeToJS() -> PriorityReference { + return PriorityReference(underlying: self) + } + + static func bridgeFromJS(_ value: consuming PriorityReference) -> Priority { + return value.underlying + } +} + +@JS final class PriorityReference { + let underlying: Priority + + init(underlying: Priority) { + self.underlying = underlying + } + + @JS func describe() -> String { + switch underlying { + case .low: return "low" + case .medium: return "medium" + case .high: return "high" + } + } + + @JS func weight() -> Int { + switch underlying { + case .low: return 1 + case .medium: return 5 + case .high: return 10 + } + } + + @JS static func low() -> Priority { return .low } + @JS static func medium() -> Priority { return .medium } + @JS static func high() -> Priority { return .high } +} + +@JS func roundTripPriority(_ priority: Priority) -> Priority { + return priority +} + +@JS(as: Severity.self) struct Alert { + let level: Severity + + var requiresImmediateAction: Bool { + level == .error + } + + consuming func bridgeToJS() -> Severity { + return level + } + + static func bridgeFromJS(_ value: consuming Severity) -> Alert { + return Alert(level: value) + } +} + +@JS enum Severity { + case notice, warning, error +} + +@JS func roundTripAlert(_ alert: Alert) -> Alert { + return alert +} + +@JS func makeAlert(_ level: Severity) -> Alert { + return Alert(level: level) +} + +@JS(as: SessionState.self) class Session { + var token: String + + init(token: String) { + self.token = token + } + + consuming func bridgeToJS() -> SessionState { + return SessionState(token: token) + } + + static func bridgeFromJS(_ value: consuming SessionState) -> Session { + return Session(token: value.token) + } +} + +@JS struct SessionState { + var token: String + + @JS init(token: String) { + self.token = token + } +} + +@JS func roundTripSession(_ session: Session) -> Session { + return session +} + +@JS func makeSession(_ token: String) -> Session { + return Session(token: token) +} + +@JS enum Shape { + case polygon(Polygon) + case empty +} + +@JS func roundTripShape(_ s: Shape) -> Shape { + return s +} + +@JS func makeShapePolygon(_ polygon: Polygon) -> Shape { + return .polygon(polygon) +} + +@JS func makeShapeEmpty() -> Shape { + return .empty +} + +// MARK: - Imports + +@JS(as: String.self) struct Tagged { + var raw: String + + consuming func bridgeToJS() -> String { + return raw + } + + static func bridgeFromJS(_ value: consuming String) -> Tagged { + return Tagged(raw: value) + } +} + +@JSClass struct Surface { + @JSFunction init(_ label: String) throws(JSException) + @JSGetter var label: String +} + +@JS(as: Surface.self) struct Canvas { + var label: String + + consuming func bridgeToJS() -> Surface { + return try! Surface(label) + } + + static func bridgeFromJS(_ value: consuming Surface) -> Canvas { + return Canvas(label: (try? value.label) ?? "") + } +} + +@JS enum InnerTag { + case payload(Int) + case empty +} + +@JS(as: InnerTag.self) struct AliasedTag { + var underlying: InnerTag + + consuming func bridgeToJS() -> InnerTag { + return underlying + } + + static func bridgeFromJS(_ value: consuming InnerTag) -> AliasedTag { + return AliasedTag(underlying: value) + } +} + +@JSClass struct AliasImports { + @JSFunction static func jsRoundTripTagged(_ value: Tagged) throws(JSException) -> Tagged + @JSFunction static func jsRoundTripOptionalTagged(_ value: Tagged?) throws(JSException) -> Tagged? + @JSFunction static func jsProduceOptionalCanvas(_ label: String?) throws(JSException) -> Canvas? + @JSFunction static func jsRoundTripAliasedTags(_ values: [AliasedTag?]) throws(JSException) -> [AliasedTag?] + @JSFunction static func jsRoundTripPolygon(_ value: Polygon) throws(JSException) -> Polygon + @JSFunction static func jsRoundTripCoordinate(_ value: Coordinate) throws(JSException) -> Coordinate +} diff --git a/Tests/BridgeJSRuntimeTests/AliasTests.swift b/Tests/BridgeJSRuntimeTests/AliasTests.swift new file mode 100644 index 000000000..2e4548ec9 --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/AliasTests.swift @@ -0,0 +1,72 @@ +import XCTest +import JavaScriptKit + +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "runAliasWorks") +@_extern(c) +func runAliasWorks() -> Void + +final class AliasTests: XCTestCase { + func testAliasEndToEnd() { + runAliasWorks() + } + + func testAliasAsyncEndToEnd() async throws { + try await runAliasAsyncWorks() + } + + // MARK: - Imports + + func testRoundTripTagged() throws { + let result = try AliasImports.jsRoundTripTagged(Tagged(raw: "hello")) + XCTAssertEqual(result.raw, "hello") + } + + func testRoundTripOptionalTagged() throws { + XCTAssertNil(try AliasImports.jsRoundTripOptionalTagged(nil)) + let echoed = try AliasImports.jsRoundTripOptionalTagged(Tagged(raw: "present")) + XCTAssertEqual(echoed?.raw, "present") + } + + func testProduceOptionalCanvas() throws { + XCTAssertNil(try AliasImports.jsProduceOptionalCanvas(nil)) + let canvas = try AliasImports.jsProduceOptionalCanvas("hello") + XCTAssertEqual(canvas?.label, "hello") + } + + func testRoundTripAliasedTagArray() throws { + let inputs: [AliasedTag?] = [ + AliasedTag(underlying: .payload(7)), + nil, + AliasedTag(underlying: .empty), + nil, + ] + let echoed = try AliasImports.jsRoundTripAliasedTags(inputs) + XCTAssertEqual(echoed.count, 4) + if case .payload(let n) = echoed[0]?.underlying { + XCTAssertEqual(n, 7) + } else { + XCTFail("expected .payload(7) at index 0") + } + XCTAssertNil(echoed[1]) + if case .empty = echoed[2]?.underlying { + // ok + } else { + XCTFail("expected .empty at index 2") + } + XCTAssertNil(echoed[3]) + } + + func testRoundTripPolygonImport() throws { + let polygon = Polygon(vertices: [1, 2, 3], label: "import") + let echoed = try AliasImports.jsRoundTripPolygon(polygon) + XCTAssertEqual(echoed.label, "import") + XCTAssertEqual(echoed.vertices, [1, 2, 3]) + } + + func testRoundTripCoordinateImport() throws { + let coordinate = Coordinate(latitude: 12.5, longitude: -34.25) + let echoed = try AliasImports.jsRoundTripCoordinate(coordinate) + XCTAssertEqual(echoed.latitude, 12.5) + XCTAssertEqual(echoed.longitude, -34.25) + } +} diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift index 08d0db2a7..b2f7795cc 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift @@ -44,6 +44,8 @@ extension FeatureFlag: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum {} @JSFunction func runAsyncWorks() async throws(JSException) -> Void +@JSFunction func runAliasAsyncWorks() async throws(JSException) -> Void + @JSFunction func fetchWeatherData(_ city: String) async throws(JSException) -> WeatherData @JSClass struct WeatherData { diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift index b2afb6d5b..1192d4b33 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift @@ -645,126 +645,37 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTests9Di } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si_extern(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si_extern(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(callback, param0Bytes, param0Length) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si(_ callback: Int32, _ param0: UnsafeMutableRawPointer) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si_extern(callback, param0) } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(boxPtr, file, line) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestsKSS_Sb { - static func bridgeJSLift(_ callbackId: Int32) -> (String) throws(JSException) -> Bool { +private enum _BJS_Closure_20BridgeJSRuntimeTestsAl7Polygon_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (Polygon) -> Int { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] (param0: String) throws(JSException) -> Bool in - #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(callbackValue, param0Bytes, param0Length) - return ret - } - let ret = ret0 - if let error = _swift_js_take_exception() { - throw error - } - return Bool.bridgeJSLiftReturn(ret) - #else - fatalError("Only available on WebAssembly") - #endif - } - } -} - -extension JSTypedClosure where Signature == (String) throws(JSException) -> Bool { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) throws(JSException) -> Bool) { - self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) throws(JSException) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure - do { - let result = try closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) - return result.bridgeJSLowerReturn() - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: error.description) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return 0 - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(callback, param0Bytes, param0Length) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestsKSS_Si { - static func bridgeJSLift(_ callbackId: Int32) -> (String) throws(JSException) -> Int { - let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] (param0: String) throws(JSException) -> Int in + return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(callbackValue, param0Bytes, param0Length) - return ret - } - let ret = ret0 - if let error = _swift_js_take_exception() { - throw error - } + let param0Pointer = param0.bridgeToJS().bridgeJSLowerParameter() + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si(callbackValue, param0Pointer) return Int.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") @@ -773,10 +684,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsKSS_Si { } } -extension JSTypedClosure where Signature == (String) throws(JSException) -> Int { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) throws(JSException) -> Int) { +extension JSTypedClosure where Signature == (Polygon) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Polygon) -> Int) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si, body: body, fileID: fileID, line: line @@ -784,27 +695,13 @@ extension JSTypedClosure where Signature == (String) throws(JSException) -> Int } } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) throws(JSException) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure - do { - let result = try closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) - return result.bridgeJSLowerReturn() - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: error.description) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return 0 - } + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Polygon) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + let result = closure(Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(param0))) + return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -1968,45 +1865,38 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqS } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +@_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_20BridgeJSRuntimeTestsYaKSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +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_20BridgeJSRuntimeTestsYaKSS_SS(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(resolveRef, rejectRef, callback, param0Bytes, param0Length) +@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_20BridgeJSRuntimeTestsYaKSS_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestsYaKSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestsYaKSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestsYaKSS_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (String) async throws(JSException) -> String { +private enum _BJS_Closure_20BridgeJSRuntimeTestss11FeatureFlagO_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending FeatureFlag) -> Void { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] (param0: String) async throws(JSException) -> String in + return { [callback] param0 in #if arch(wasm32) - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending String) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let callbackValue = callback.bridgeJSLowerParameter() - param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) - } + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(callbackValue, param0Bytes, param0Length) } - return resolved #else fatalError("Only available on WebAssembly") #endif @@ -2014,10 +1904,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsYaKSS_SS { } } -extension JSTypedClosure where Signature == (String) async throws(JSException) -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async throws(JSException) -> String) { +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_20BridgeJSRuntimeTestsYaKSS_SS, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y, body: body, fileID: fileID, line: line @@ -2025,58 +1915,49 @@ extension JSTypedClosure where Signature == (String) async throws(JSException) - } } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { +@_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<(String) async throws(JSException) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { () async throws(JSException) -> String in - return try await closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) - } + 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_20BridgeJSRuntimeTestsYaKSS_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +@_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_20BridgeJSRuntimeTestsYaKSS_y_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +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_20BridgeJSRuntimeTestsYaKSS_y(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(resolveRef, rejectRef, callback, param0Bytes, param0Length) +@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_20BridgeJSRuntimeTestsYaKSS_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestsYaKSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestsYaKSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestsYaKSS_y { - static func bridgeJSLift(_ callbackId: Int32) -> (String) async throws(JSException) -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestss11WeatherDataC_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending WeatherData) -> Void { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] (param0: String) async throws(JSException) -> Void in + return { [callback] param0 in #if arch(wasm32) - try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<() -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let callbackValue = callback.bridgeJSLowerParameter() - param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) - } - } + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(callbackValue, param0Value) #else fatalError("Only available on WebAssembly") #endif @@ -2084,10 +1965,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsYaKSS_y { } } -extension JSTypedClosure where Signature == (String) async throws(JSException) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async throws(JSException) -> Void) { +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_20BridgeJSRuntimeTestsYaKSS_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y, body: body, fileID: fileID, line: line @@ -2095,58 +1976,49 @@ extension JSTypedClosure where Signature == (String) async throws(JSException) - } } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { +@_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<(String) async throws(JSException) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - return _bjs_makePromise(resolve: Promise_resolve_y, reject: Promise_reject) { () async throws(JSException) in - try await closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) - } + 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_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> Void +@_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_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> Void { +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_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(resolveRef, rejectRef, callback, param0) +@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_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO { - static func bridgeJSLift(_ callbackId: Int32) -> (Bool) async throws(JSException) -> AsyncPayloadResult { +private enum _BJS_Closure_20BridgeJSRuntimeTestss7JSValueV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending JSValue) -> Void { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] (param0: Bool) async throws(JSException) -> AsyncPayloadResult in + return { [callback] param0 in #if arch(wasm32) - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending AsyncPayloadResult) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(resolveRef, rejectRef, callbackValue, param0Value) - } - return resolved + 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 @@ -2154,10 +2026,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO { } } -extension JSTypedClosure where Signature == (Bool) async throws(JSException) -> AsyncPayloadResult { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Bool) async throws(JSException) -> AsyncPayloadResult) { +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_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y, body: body, fileID: fileID, line: line @@ -2165,59 +2037,50 @@ extension JSTypedClosure where Signature == (Bool) async throws(JSException) -> } } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { +@_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<(Bool) async throws(JSException) -> AsyncPayloadResult>>.fromOpaque(boxPtr).takeUnretainedValue().closure - return _bjs_makePromise(resolve: Promise_resolve_18AsyncPayloadResultO, reject: Promise_reject) { () async throws(JSException) -> AsyncPayloadResult in - return try await closure(Bool.bridgeJSLiftParameter(param0)) - } + 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_20BridgeJSRuntimeTestsYaSS_SS") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +@_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_20BridgeJSRuntimeTestsYaSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +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_20BridgeJSRuntimeTestsYaSS_SS(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(resolveRef, rejectRef, callback, param0Bytes, param0Length) +@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_20BridgeJSRuntimeTestsYaSS_SS") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestsYaSS_SS_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestsYaSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestsYaSS_SS { - static func bridgeJSLift(_ callbackId: Int32) -> (String) async -> String { +private enum _BJS_Closure_20BridgeJSRuntimeTestssSS_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending String) -> Void { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] (param0: String) async -> String in + return { [callback] param0 in #if arch(wasm32) - let resolved = try! await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending String) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let callbackValue = callback.bridgeJSLowerParameter() - param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) - } + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(callbackValue, param0Bytes, param0Length) } - return resolved #else fatalError("Only available on WebAssembly") #endif @@ -2225,10 +2088,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsYaSS_SS { } } -extension JSTypedClosure where Signature == (String) async -> String { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async -> String) { +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_20BridgeJSRuntimeTestsYaSS_SS, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y, body: body, fileID: fileID, line: line @@ -2236,58 +2099,49 @@ extension JSTypedClosure where Signature == (String) async -> String { } } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { +@_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<(String) async -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure - return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { - return await closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) - } + 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_20BridgeJSRuntimeTestsYaSd_9DataPointV") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Float64) -> Void +@_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_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Float64) -> Void { +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_20BridgeJSRuntimeTestsYaSd_9DataPointV(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Float64) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(resolveRef, rejectRef, callback, param0) +@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_20BridgeJSRuntimeTestsYaSd_9DataPointV") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestsYaSd_9DataPointV(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestsYaSd_9DataPointV { - static func bridgeJSLift(_ callbackId: Int32) -> (Double) async -> DataPoint { +private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSS_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending [String]) -> Void { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] (param0: Double) async -> DataPoint in + return { [callback] param0 in #if arch(wasm32) - let resolved = try! await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending DataPoint) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV(resolveRef, rejectRef, callbackValue, param0Value) - } - return resolved + let callbackValue = callback.bridgeJSLowerParameter() + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(callbackValue) #else fatalError("Only available on WebAssembly") #endif @@ -2295,10 +2149,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsYaSd_9DataPointV { } } -extension JSTypedClosure where Signature == (Double) async -> DataPoint { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Double) async -> DataPoint) { +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_20BridgeJSRuntimeTestsYaSd_9DataPointV, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y, body: body, fileID: fileID, line: line @@ -2306,52 +2160,49 @@ extension JSTypedClosure where Signature == (Double) async -> DataPoint { } } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV(_ boxPtr: UnsafeMutableRawPointer, _ param0: Float64) -> Int32 { +@_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<(Double) async -> DataPoint>>.fromOpaque(boxPtr).takeUnretainedValue().closure - return _bjs_makePromise(resolve: Promise_resolve_9DataPointV, reject: Promise_reject) { - return await closure(Double.bridgeJSLiftParameter(param0)) - } + 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_20BridgeJSRuntimeTestss11FeatureFlagO_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +@_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_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +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_20BridgeJSRuntimeTestss11FeatureFlagO_y(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(callback, param0Bytes, param0Length) +@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_20BridgeJSRuntimeTestss11FeatureFlagO_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestss11FeatureFlagO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestss11FeatureFlagO_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending FeatureFlag) -> Void { +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() - param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(callbackValue, param0Bytes, param0Length) - } + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y(callbackValue) #else fatalError("Only available on WebAssembly") #endif @@ -2359,10 +2210,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestss11FeatureFlagO_y { } } -extension JSTypedClosure where Signature == (sending FeatureFlag) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending FeatureFlag) -> Void) { +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_20BridgeJSRuntimeTestss11FeatureFlagO_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y, body: body, fileID: fileID, line: line @@ -2370,49 +2221,49 @@ extension JSTypedClosure where Signature == (sending FeatureFlag) -> Void { } } -@_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 { +@_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 FeatureFlag) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(FeatureFlag.bridgeJSLiftParameter(param0Bytes, param0Length)) + 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_20BridgeJSRuntimeTestss11WeatherDataC_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ callback: Int32, _ param0: Int32) -> Void +@_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_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ callback: Int32, _ param0: Int32) -> Void { +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_20BridgeJSRuntimeTestss11WeatherDataC_y(_ callback: Int32, _ param0: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(callback, param0) +@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_20BridgeJSRuntimeTestss11WeatherDataC_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestss11WeatherDataC_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestss11WeatherDataC_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending WeatherData) -> Void { +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 param0Value = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(callbackValue, param0Value) + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y(callbackValue) #else fatalError("Only available on WebAssembly") #endif @@ -2420,10 +2271,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestss11WeatherDataC_y { } } -extension JSTypedClosure where Signature == (sending WeatherData) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending WeatherData) -> Void) { +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_20BridgeJSRuntimeTestss11WeatherDataC_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y, body: body, fileID: fileID, line: line @@ -2431,49 +2282,49 @@ extension JSTypedClosure where Signature == (sending WeatherData) -> Void { } } -@_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 { +@_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 WeatherData) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(WeatherData.bridgeJSLiftParameter(param0)) + 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_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void +@_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_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void { +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_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(_ callback: Int32, _ param0: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(callback, param0) +@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_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending AsyncPayloadResult) -> Void { +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 param0CaseId = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(callbackValue, param0CaseId) + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y(callbackValue, param0Value) #else fatalError("Only available on WebAssembly") #endif @@ -2481,10 +2332,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y { } } -extension JSTypedClosure where Signature == (sending AsyncPayloadResult) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending AsyncPayloadResult) -> Void) { +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_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y, body: body, fileID: fileID, line: line @@ -2492,49 +2343,49 @@ extension JSTypedClosure where Signature == (sending AsyncPayloadResult) -> Void } } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { +@_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 AsyncPayloadResult) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(AsyncPayloadResult.bridgeJSLiftParameter(param0)) + 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_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void +@_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_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void { +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_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(_ callback: Int32, _ param0: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(callback, param0) +@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_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending AsyncImportedPayloadResult) -> Void { +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 param0CaseId = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(callbackValue, param0CaseId) + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y(callbackValue, param0Value) #else fatalError("Only available on WebAssembly") #endif @@ -2542,10 +2393,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y } } -extension JSTypedClosure where Signature == (sending AsyncImportedPayloadResult) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending AsyncImportedPayloadResult) -> Void) { +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_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y, body: body, fileID: fileID, line: line @@ -2553,49 +2404,50 @@ extension JSTypedClosure where Signature == (sending AsyncImportedPayloadResult) } } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { +@_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 AsyncImportedPayloadResult) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(AsyncImportedPayloadResult.bridgeJSLiftParameter(param0)) + 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_20BridgeJSRuntimeTestss7JSValueV_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void +@_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_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { +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_20BridgeJSRuntimeTestss7JSValueV_y(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(callback, param0Kind, param0Payload1, param0Payload2) +@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_20BridgeJSRuntimeTestss7JSValueV_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestss7JSValueV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestss7JSValueV_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending JSValue) -> Void { +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() - let (param0Kind, param0Payload1, param0Payload2) = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y(callbackValue, param0Kind, param0Payload1, param0Payload2) + param0.bridgeJSWithLoweredParameter { (param0IsSome, param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y(callbackValue, param0IsSome, param0Bytes, param0Length) + } #else fatalError("Only available on WebAssembly") #endif @@ -2603,10 +2455,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestss7JSValueV_y { } } -extension JSTypedClosure where Signature == (sending JSValue) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending JSValue) -> Void) { +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_20BridgeJSRuntimeTestss7JSValueV_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y, body: body, fileID: fileID, line: line @@ -2614,49 +2466,49 @@ extension JSTypedClosure where Signature == (sending JSValue) -> Void { } } -@_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 { +@_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 JSValue) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(JSValue.bridgeJSLiftParameter(param0Kind, param0Payload1, param0Payload2)) + 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_20BridgeJSRuntimeTestss9DataPointV_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(_ callback: Int32) -> Void +@_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_20BridgeJSRuntimeTestss9DataPointV_y_extern(_ callback: Int32) -> Void { +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_20BridgeJSRuntimeTestss9DataPointV_y(_ callback: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(callback) +@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_20BridgeJSRuntimeTestss9DataPointV_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestss9DataPointV_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestss9DataPointV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestss9DataPointV_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending DataPoint) -> Void { +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 _ = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y(callbackValue) + let (param0IsSome, param0Value) = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y(callbackValue, param0IsSome, param0Value) #else fatalError("Only available on WebAssembly") #endif @@ -2664,10 +2516,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestss9DataPointV_y { } } -extension JSTypedClosure where Signature == (sending DataPoint) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending DataPoint) -> Void) { +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_20BridgeJSRuntimeTestss9DataPointV_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y, body: body, fileID: fileID, line: line @@ -2675,50 +2527,49 @@ extension JSTypedClosure where Signature == (sending DataPoint) -> Void { } } -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { +@_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 DataPoint) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(DataPoint.bridgeJSLiftParameter()) + 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_20BridgeJSRuntimeTestssSS_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void +@_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_20BridgeJSRuntimeTestssSS_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +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_20BridgeJSRuntimeTestssSS_y(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(callback, param0Bytes, param0Length) +@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_20BridgeJSRuntimeTestssSS_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestssSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestssSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestssSS_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending String) -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestsy_13DataProcessorP { + static func bridgeJSLift(_ callbackId: Int32) -> () -> any DataProcessor { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in + return { [callback] in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(callbackValue, param0Bytes, param0Length) - } + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP(callbackValue) + return AnyDataProcessor.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -2726,10 +2577,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestssSS_y { } } -extension JSTypedClosure where Signature == (sending String) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending String) -> Void) { +extension JSTypedClosure where Signature == () -> any DataProcessor { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> any DataProcessor) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP, body: body, fileID: fileID, line: line @@ -2737,49 +2588,50 @@ extension JSTypedClosure where Signature == (sending String) -> Void { } } -@_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 { +@_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<(sending String) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + 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_20BridgeJSRuntimeTestssSaSS_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(_ callback: Int32) -> Void +@_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_20BridgeJSRuntimeTestssSaSS_y_extern(_ callback: Int32) -> Void { +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_20BridgeJSRuntimeTestssSaSS_y(_ callback: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(callback) +@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_20BridgeJSRuntimeTestssSaSS_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestssSaSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestssSaSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestssSaSS_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending [String]) -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestsy_Sb { + static func bridgeJSLift(_ callbackId: Int32) -> () -> Bool { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in + return { [callback] in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - let _ = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(callbackValue) + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb(callbackValue) + return Bool.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -2787,10 +2639,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSS_y { } } -extension JSTypedClosure where Signature == (sending [String]) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending [String]) -> Void) { +extension JSTypedClosure where Signature == () -> Bool { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> Bool) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb, body: body, fileID: fileID, line: line @@ -2798,574 +2650,23 @@ extension JSTypedClosure where Signature == (sending [String]) -> Void { } } -@_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 { +@_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<(sending [String]) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure([String].bridgeJSLiftParameter()) + 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_20BridgeJSRuntimeTestssSaSb_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(_ callback: Int32) -> Void +@_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_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_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void -#else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(callback, param0IsSome, param0CaseId) -} - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 -#else -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(boxPtr, file, line) -} - -private enum _BJS_Closure_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_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, param0CaseId) = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(callbackValue, param0IsSome, param0CaseId) - #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_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y, - body: body, - fileID: fileID, - line: line - ) - } -} - -@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") -@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") -public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { - #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Optional) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(Optional.bridgeJSLiftParameter(param0IsSome, param0CaseId)) - #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 { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ callback: Int32) -> UnsafeMutableRawPointer { fatalError("Only available on WebAssembly") } #endif @@ -4094,6 +3395,91 @@ fileprivate func bjs_DataProcessor_optionalHelper_set_extern(_ jsObject: Int32, return bjs_DataProcessor_optionalHelper_set_extern(jsObject, newValueIsSome, newValuePointer) } +extension Severity: _BridgedSwiftCaseEnum { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { + return bridgeJSRawValue + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Severity { + return bridgeJSLiftParameter(value) + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Severity { + return Severity(bridgeJSRawValue: value)! + } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { + return bridgeJSLowerParameter() + } + + @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .notice + case 1: + self = .warning + case 2: + self = .error + default: + return nil + } + } + + @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { + switch self { + case .notice: + return 0 + case .warning: + return 1 + case .error: + return 2 + } + } +} + +extension Shape: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> Shape { + switch caseId { + case 0: + return .polygon(Polygon.bridgeFromJS(PolygonReference.bridgeJSStackPop())) + case 1: + return .empty + default: + fatalError("Unknown Shape case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .polygon(let param0): + param0.bridgeToJS().bridgeJSStackPush() + return Int32(0) + case .empty: + return Int32(1) + } + } +} + +extension InnerTag: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> InnerTag { + switch caseId { + case 0: + return .payload(Int.bridgeJSStackPop()) + case 1: + return .empty + default: + fatalError("Unknown InnerTag case ID: \(caseId)") + } + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + switch self { + case .payload(let param0): + param0.bridgeJSStackPush() + return Int32(0) + case .empty: + return Int32(1) + } + } +} + @_expose(wasm, "bjs_ArraySupportExports_static_roundTripIntArray") @_cdecl("bjs_ArraySupportExports_static_roundTripIntArray") public func _bjs_ArraySupportExports_static_roundTripIntArray() -> Void { @@ -4565,47 +3951,19 @@ public func _bjs_ArraySupportExports_static_multiOptionalArrayFirst() -> Void { #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 -} - -extension AsyncImportedPayloadResult: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> AsyncImportedPayloadResult { - switch caseId { - case 0: - return .success(String.bridgeJSStackPop()) - case 1: - return .failure(Int.bridgeJSStackPop()) - case 2: - return .idle - default: - fatalError("Unknown AsyncImportedPayloadResult 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 .idle: - return Int32(2) - } - } -} - +@_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 { @@ -4917,34 +4275,6 @@ extension TSDirection: _BridgedSwiftCaseEnum { extension TSTheme: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { } -extension AsyncPayloadResult: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> AsyncPayloadResult { - switch caseId { - case 0: - return .success(String.bridgeJSStackPop()) - case 1: - return .failure(Int.bridgeJSStackPop()) - case 2: - return .idle - default: - fatalError("Unknown AsyncPayloadResult 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 .idle: - return Int32(2) - } - } -} - @_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 { @@ -5649,73 +4979,6 @@ public func _bjs_NestedStructGroupB_static_roundtripMetadata() -> Void { #endif } -extension LightColor: _BridgedSwiftCaseEnum { - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { - return bridgeJSRawValue - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> LightColor { - return bridgeJSLiftParameter(value) - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> LightColor { - return LightColor(bridgeJSRawValue: value)! - } - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { - return bridgeJSLowerParameter() - } - - @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .red - case 1: - self = .yellow - case 2: - self = .green - default: - return nil - } - } - - @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { - switch self { - case .red: - return 0 - case .yellow: - return 1 - case .green: - return 2 - } - } -} - -extension ImportedPayloadSignal: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> ImportedPayloadSignal { - switch caseId { - case 0: - return .start(String.bridgeJSStackPop()) - case 1: - return .stop(Int.bridgeJSStackPop()) - case 2: - return .idle - default: - fatalError("Unknown ImportedPayloadSignal case ID: \(caseId)") - } - } - - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { - switch self { - case .start(let param0): - param0.bridgeJSStackPush() - return Int32(0) - case .stop(let param0): - param0.bridgeJSStackPush() - return Int32(1) - case .idle: - return Int32(2) - } - } -} - @_expose(wasm, "bjs_IntegerTypesSupportExports_static_roundTripInt") @_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt") public func _bjs_IntegerTypesSupportExports_static_roundTripInt(_ v: Int32) -> Int32 { @@ -6270,6 +5533,122 @@ extension APIOptionalResult: _BridgedSwiftAssociatedValueEnum { } } +extension JSCoordinate: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> JSCoordinate { + let longitude = Double.bridgeJSStackPop() + let latitude = Double.bridgeJSStackPop() + return JSCoordinate(latitude: latitude, longitude: longitude) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.latitude.bridgeJSStackPush() + self.longitude.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_JSCoordinate(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_JSCoordinate())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_JSCoordinate") +fileprivate func _bjs_struct_lower_JSCoordinate_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_JSCoordinate_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_JSCoordinate(_ objectId: Int32) -> Void { + return _bjs_struct_lower_JSCoordinate_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_JSCoordinate") +fileprivate func _bjs_struct_lift_JSCoordinate_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_JSCoordinate_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_JSCoordinate() -> Int32 { + return _bjs_struct_lift_JSCoordinate_extern() +} + +@_expose(wasm, "bjs_JSCoordinate_init") +@_cdecl("bjs_JSCoordinate_init") +public func _bjs_JSCoordinate_init(_ latitude: Float64, _ longitude: Float64) -> Void { + #if arch(wasm32) + let ret = JSCoordinate(latitude: Double.bridgeJSLiftParameter(latitude), longitude: Double.bridgeJSLiftParameter(longitude)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension SessionState: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> SessionState { + let token = String.bridgeJSStackPop() + return SessionState(token: token) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.token.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_SessionState(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_SessionState())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_SessionState") +fileprivate func _bjs_struct_lower_SessionState_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_SessionState_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_SessionState(_ objectId: Int32) -> Void { + return _bjs_struct_lower_SessionState_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_SessionState") +fileprivate func _bjs_struct_lift_SessionState_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_SessionState_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_SessionState() -> Int32 { + return _bjs_struct_lift_SessionState_extern() +} + +@_expose(wasm, "bjs_SessionState_init") +@_cdecl("bjs_SessionState_init") +public func _bjs_SessionState_init(_ tokenBytes: Int32, _ tokenLength: Int32) -> Void { + #if arch(wasm32) + let ret = SessionState(token: String.bridgeJSLiftParameter(tokenBytes, tokenLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + extension NestedStructGroupA.Metadata: _BridgedSwiftStruct { @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> NestedStructGroupA.Metadata { let count = Int.bridgeJSStackPop() @@ -7544,197 +6923,351 @@ fileprivate func _bjs_struct_lift_FooContainer_extern() -> 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() - } +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_makeTag") +@_cdecl("bjs_makeTag") +public func _bjs_makeTag(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = makeTag(_: String.bridgeJSLiftParameter(nameBytes, nameLength)) + return ret.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripPolygon") +@_cdecl("bjs_roundTripPolygon") +public func _bjs_roundTripPolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundTripPolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) + return ret.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_appendVertex") +@_cdecl("bjs_appendVertex") +public func _bjs_appendVertex(_ polygon: UnsafeMutableRawPointer, _ value: Float64) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = appendVertex(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon)), _: Double.bridgeJSLiftParameter(value)) + return ret.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_optionalRoundTripPolygon") +@_cdecl("bjs_optionalRoundTripPolygon") +public func _bjs_optionalRoundTripPolygon(_ polygonIsSome: Int32, _ polygonValue: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = optionalRoundTripPolygon(_: Optional.bridgeJSLiftParameter(polygonIsSome, polygonValue).map { Polygon.bridgeFromJS($0) }) + return ret.map { $0.bridgeToJS() }.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_polygonVertexCount") +@_cdecl("bjs_polygonVertexCount") +public func _bjs_polygonVertexCount(_ polygon: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = polygonVertexCount(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripPolygonArray") +@_cdecl("bjs_roundTripPolygonArray") +public func _bjs_roundTripPolygonArray() -> Void { + #if arch(wasm32) + let ret = roundTripPolygonArray(_: [PolygonReference].bridgeJSStackPop().map { Polygon.bridgeFromJS($0) }) + ret.map { $0.bridgeToJS() }.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_ArrayMembers(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } +@_expose(wasm, "bjs_concatPolygons") +@_cdecl("bjs_concatPolygons") +public func _bjs_concatPolygons() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = concatPolygons(_: [PolygonReference].bridgeJSStackPop().map { Polygon.bridgeFromJS($0) }) + return ret.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_ArrayMembers())) +@_expose(wasm, "bjs_validatePolygon") +@_cdecl("bjs_validatePolygon") +public func _bjs_validatePolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + do { + let ret = try validatePolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) + return ret.bridgeToJS().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 } -#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 { +@_expose(wasm, "bjs_splitPolygon") +@_cdecl("bjs_splitPolygon") +public func _bjs_splitPolygon(_ polygon: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = splitPolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) + ret.map { $0.bridgeToJS() }.bridgeJSStackPush() + #else fatalError("Only available on WebAssembly") + #endif } -#endif -@inline(never) fileprivate func _bjs_struct_lower_ArrayMembers(_ objectId: Int32) -> Void { - return _bjs_struct_lower_ArrayMembers_extern(objectId) + +@_expose(wasm, "bjs_incrementToken") +@_cdecl("bjs_incrementToken") +public func _bjs_incrementToken(_ token: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = incrementToken(_: Token.bridgeFromJS(TokenReference.bridgeJSLiftParameter(token))) + return ret.bridgeToJS().bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif } -#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 { +@_expose(wasm, "bjs_makeToken") +@_cdecl("bjs_makeToken") +public func _bjs_makeToken(_ value: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = makeToken(_: Int.bridgeJSLiftParameter(value)) + return ret.bridgeToJS().bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") + #endif } -#endif -@inline(never) fileprivate func _bjs_struct_lift_ArrayMembers() -> Int32 { - return _bjs_struct_lift_ArrayMembers_extern() + +@_expose(wasm, "bjs_makePolygonInspector") +@_cdecl("bjs_makePolygonInspector") +public func _bjs_makePolygonInspector() -> Int32 { + #if arch(wasm32) + let ret = makePolygonInspector() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif } -@_expose(wasm, "bjs_ArrayMembers_sumValues") -@_cdecl("bjs_ArrayMembers_sumValues") -public func _bjs_ArrayMembers_sumValues() -> Int32 { +@_expose(wasm, "bjs_asyncMakePolygon") +@_cdecl("bjs_asyncMakePolygon") +public func _bjs_asyncMakePolygon(_ labelBytes: Int32, _ labelLength: Int32) -> Int32 { #if arch(wasm32) - let ret = ArrayMembers.bridgeJSLiftParameter().sumValues(_: [Int].bridgeJSStackPop()) + let ret = JSPromise.async { + return await asyncMakePolygon(_: String.bridgeJSLiftParameter(labelBytes, labelLength)).bridgeToJS().jsValue + }.jsObject 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 { +@_expose(wasm, "bjs_roundTripOptionalPolygonArray") +@_cdecl("bjs_roundTripOptionalPolygonArray") +public func _bjs_roundTripOptionalPolygonArray() -> Void { #if arch(wasm32) - let ret = ArrayMembers.bridgeJSLiftParameter().firstString(_: [String].bridgeJSStackPop()) - return ret.bridgeJSLowerReturn() + let ret = roundTripOptionalPolygonArray(_: [Optional].bridgeJSStackPop().map { $0.map { Polygon.bridgeFromJS($0) } }) + ret.map { $0.map { $0.bridgeToJS() } }.bridgeJSStackPush() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_awaitAsyncCallback") -@_cdecl("bjs_awaitAsyncCallback") -public func _bjs_awaitAsyncCallback(_ fetch: Int32) -> Int32 { +@_expose(wasm, "bjs_makeTagHolder") +@_cdecl("bjs_makeTagHolder") +public func _bjs_makeTagHolder(_ nameBytes: Int32, _ nameLength: Int32, _ version: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { () async throws(JSException) -> String in - return try await awaitAsyncCallback(_: _BJS_Closure_20BridgeJSRuntimeTestsYaKSS_SS.bridgeJSLift(fetch)) - } + let ret = makeTagHolder(_: String.bridgeJSLiftParameter(nameBytes, nameLength), _: Int.bridgeJSLiftParameter(version)) + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAsyncParser") -@_cdecl("bjs_makeAsyncParser") -public func _bjs_makeAsyncParser() -> Int32 { +@_expose(wasm, "bjs_roundTripCoordinate") +@_cdecl("bjs_roundTripCoordinate") +public func _bjs_roundTripCoordinate() -> Void { #if arch(wasm32) - let ret = makeAsyncParser() - return ret.bridgeJSLowerReturn() + let ret = roundTripCoordinate(_: Coordinate.bridgeFromJS(JSCoordinate.bridgeJSLiftParameter())) + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAsyncEcho") -@_cdecl("bjs_makeAsyncEcho") -public func _bjs_makeAsyncEcho() -> Int32 { +@_expose(wasm, "bjs_roundTripPriority") +@_cdecl("bjs_roundTripPriority") +public func _bjs_roundTripPriority(_ priority: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = makeAsyncEcho() - return ret.bridgeJSLowerReturn() + let ret = roundTripPriority(_: Priority.bridgeFromJS(PriorityReference.bridgeJSLiftParameter(priority))) + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAsyncRecorder") -@_cdecl("bjs_makeAsyncRecorder") -public func _bjs_makeAsyncRecorder() -> Int32 { +@_expose(wasm, "bjs_roundTripAlert") +@_cdecl("bjs_roundTripAlert") +public func _bjs_roundTripAlert(_ alert: Int32) -> Int32 { #if arch(wasm32) - let ret = makeAsyncRecorder() - return ret.bridgeJSLowerReturn() + let ret = roundTripAlert(_: Alert.bridgeFromJS(Severity.bridgeJSLiftParameter(alert))) + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_lastRecordedValue") -@_cdecl("bjs_lastRecordedValue") -public func _bjs_lastRecordedValue() -> Void { +@_expose(wasm, "bjs_makeAlert") +@_cdecl("bjs_makeAlert") +public func _bjs_makeAlert(_ level: Int32) -> Int32 { #if arch(wasm32) - let ret = lastRecordedValue() - return ret.bridgeJSLowerReturn() + let ret = makeAlert(_: Severity.bridgeJSLiftParameter(level)) + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAsyncPayloadLoader") -@_cdecl("bjs_makeAsyncPayloadLoader") -public func _bjs_makeAsyncPayloadLoader() -> Int32 { +@_expose(wasm, "bjs_roundTripSession") +@_cdecl("bjs_roundTripSession") +public func _bjs_roundTripSession() -> Void { #if arch(wasm32) - let ret = makeAsyncPayloadLoader() - return ret.bridgeJSLowerReturn() + let ret = roundTripSession(_: Session.bridgeFromJS(SessionState.bridgeJSLiftParameter())) + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_awaitPayloadCallback") -@_cdecl("bjs_awaitPayloadCallback") -public func _bjs_awaitPayloadCallback(_ load: Int32) -> Int32 { +@_expose(wasm, "bjs_makeSession") +@_cdecl("bjs_makeSession") +public func _bjs_makeSession(_ tokenBytes: Int32, _ tokenLength: Int32) -> Void { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { () async throws(JSException) -> String in - return try await awaitPayloadCallback(_: _BJS_Closure_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO.bridgeJSLift(load)) - } + let ret = makeSession(_: String.bridgeJSLiftParameter(tokenBytes, tokenLength)) + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAsyncPointMaker") -@_cdecl("bjs_makeAsyncPointMaker") -public func _bjs_makeAsyncPointMaker() -> Int32 { +@_expose(wasm, "bjs_roundTripShape") +@_cdecl("bjs_roundTripShape") +public func _bjs_roundTripShape(_ s: Int32) -> Void { #if arch(wasm32) - let ret = makeAsyncPointMaker() + let ret = roundTripShape(_: Shape.bridgeJSLiftParameter(s)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeThrowingParser") -@_cdecl("bjs_makeThrowingParser") -public func _bjs_makeThrowingParser() -> Int32 { +@_expose(wasm, "bjs_makeShapePolygon") +@_cdecl("bjs_makeShapePolygon") +public func _bjs_makeShapePolygon(_ polygon: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = makeThrowingParser() + let ret = makeShapePolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_runValidator") -@_cdecl("bjs_runValidator") -public func _bjs_runValidator(_ validate: Int32) -> Int32 { +@_expose(wasm, "bjs_makeShapeEmpty") +@_cdecl("bjs_makeShapeEmpty") +public func _bjs_makeShapeEmpty() -> Void { #if arch(wasm32) - do { - let ret = try runValidator(_: _BJS_Closure_20BridgeJSRuntimeTestsKSS_Sb.bridgeJSLift(validate)) - 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: error.description) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return 0 - } + let ret = makeShapeEmpty() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -7939,7 +7472,7 @@ public func _bjs_makeImportedFoo(_ valueBytes: Int32, _ valueLength: Int32) -> I _swift_js_throw(Int32(bitPattern: $0.id)) } } else { - let jsError = JSError(message: error.description) + let jsError = JSError(message: String(describing: error)) withExtendedLifetime(jsError.jsObject) { _swift_js_throw(Int32(bitPattern: $0.id)) } @@ -7951,17 +7484,6 @@ public func _bjs_makeImportedFoo(_ valueBytes: Int32, _ valueLength: Int32) -> I #endif } -@_expose(wasm, "bjs_roundTripOptionalImportedClass") -@_cdecl("bjs_roundTripOptionalImportedClass") -public func _bjs_roundTripOptionalImportedClass(_ vIsSome: Int32, _ vValue: Int32) -> Void { - #if arch(wasm32) - let ret = roundTripOptionalImportedClass(v: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_throwsSwiftError") @_cdecl("bjs_throwsSwiftError") public func _bjs_throwsSwiftError(_ shouldThrow: Int32) -> Void { @@ -7974,7 +7496,7 @@ public func _bjs_throwsSwiftError(_ shouldThrow: Int32) -> Void { _swift_js_throw(Int32(bitPattern: $0.id)) } } else { - let jsError = JSError(message: error.description) + let jsError = JSError(message: String(describing: error)) withExtendedLifetime(jsError.jsObject) { _swift_js_throw(Int32(bitPattern: $0.id)) } @@ -7999,7 +7521,7 @@ public func _bjs_throwsWithIntResult() -> Int32 { _swift_js_throw(Int32(bitPattern: $0.id)) } } else { - let jsError = JSError(message: error.description) + let jsError = JSError(message: String(describing: error)) withExtendedLifetime(jsError.jsObject) { _swift_js_throw(Int32(bitPattern: $0.id)) } @@ -8024,7 +7546,7 @@ public func _bjs_throwsWithStringResult() -> Void { _swift_js_throw(Int32(bitPattern: $0.id)) } } else { - let jsError = JSError(message: error.description) + let jsError = JSError(message: String(describing: error)) withExtendedLifetime(jsError.jsObject) { _swift_js_throw(Int32(bitPattern: $0.id)) } @@ -8049,7 +7571,7 @@ public func _bjs_throwsWithBoolResult() -> Int32 { _swift_js_throw(Int32(bitPattern: $0.id)) } } else { - let jsError = JSError(message: error.description) + let jsError = JSError(message: String(describing: error)) withExtendedLifetime(jsError.jsObject) { _swift_js_throw(Int32(bitPattern: $0.id)) } @@ -8074,7 +7596,7 @@ public func _bjs_throwsWithFloatResult() -> Float32 { _swift_js_throw(Int32(bitPattern: $0.id)) } } else { - let jsError = JSError(message: error.description) + let jsError = JSError(message: String(describing: error)) withExtendedLifetime(jsError.jsObject) { _swift_js_throw(Int32(bitPattern: $0.id)) } @@ -8099,7 +7621,7 @@ public func _bjs_throwsWithDoubleResult() -> Float64 { _swift_js_throw(Int32(bitPattern: $0.id)) } } else { - let jsError = JSError(message: error.description) + let jsError = JSError(message: String(describing: error)) withExtendedLifetime(jsError.jsObject) { _swift_js_throw(Int32(bitPattern: $0.id)) } @@ -8124,7 +7646,7 @@ public func _bjs_throwsWithSwiftHeapObjectResult() -> UnsafeMutableRawPointer { _swift_js_throw(Int32(bitPattern: $0.id)) } } else { - let jsError = JSError(message: error.description) + let jsError = JSError(message: String(describing: error)) withExtendedLifetime(jsError.jsObject) { _swift_js_throw(Int32(bitPattern: $0.id)) } @@ -8149,7 +7671,7 @@ public func _bjs_throwsWithJSObjectResult() -> Int32 { _swift_js_throw(Int32(bitPattern: $0.id)) } } else { - let jsError = JSError(message: error.description) + let jsError = JSError(message: String(describing: error)) withExtendedLifetime(jsError.jsObject) { _swift_js_throw(Int32(bitPattern: $0.id)) } @@ -8161,27 +7683,14 @@ public func _bjs_throwsWithJSObjectResult() -> Int32 { #endif } -@_expose(wasm, "bjs_zeroArgAsyncThrows") -@_cdecl("bjs_zeroArgAsyncThrows") -public func _bjs_zeroArgAsyncThrows() -> Int32 { - #if arch(wasm32) - let __bjs_capture = 0 - return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { [__bjs_capture] () async throws(JSException) -> String in - _ = __bjs_capture - return try await zeroArgAsyncThrows() - } - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_asyncRoundTripVoid") @_cdecl("bjs_asyncRoundTripVoid") public func _bjs_asyncRoundTripVoid() -> Int32 { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_y, reject: Promise_reject) { + let ret = JSPromise.async { await asyncRoundTripVoid() - } + }.jsObject + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -8191,9 +7700,10 @@ public func _bjs_asyncRoundTripVoid() -> Int32 { @_cdecl("bjs_asyncRoundTripInt") public func _bjs_asyncRoundTripInt(_ v: Int32) -> Int32 { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_Si, reject: Promise_reject) { - return await asyncRoundTripInt(v: Int.bridgeJSLiftParameter(v)) - } + let ret = JSPromise.async { + return await asyncRoundTripInt(v: Int.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -8203,9 +7713,10 @@ public func _bjs_asyncRoundTripInt(_ v: Int32) -> Int32 { @_cdecl("bjs_asyncRoundTripFloat") public func _bjs_asyncRoundTripFloat(_ v: Float32) -> Int32 { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_Sf, reject: Promise_reject) { - return await asyncRoundTripFloat(v: Float.bridgeJSLiftParameter(v)) - } + let ret = JSPromise.async { + return await asyncRoundTripFloat(v: Float.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -8215,9 +7726,10 @@ public func _bjs_asyncRoundTripFloat(_ v: Float32) -> Int32 { @_cdecl("bjs_asyncRoundTripDouble") public func _bjs_asyncRoundTripDouble(_ v: Float64) -> Int32 { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_Sd, reject: Promise_reject) { - return await asyncRoundTripDouble(v: Double.bridgeJSLiftParameter(v)) - } + let ret = JSPromise.async { + return await asyncRoundTripDouble(v: Double.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -8227,9 +7739,10 @@ public func _bjs_asyncRoundTripDouble(_ v: Float64) -> Int32 { @_cdecl("bjs_asyncRoundTripBool") public func _bjs_asyncRoundTripBool(_ v: Int32) -> Int32 { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_Sb, reject: Promise_reject) { - return await asyncRoundTripBool(v: Bool.bridgeJSLiftParameter(v)) - } + let ret = JSPromise.async { + return await asyncRoundTripBool(v: Bool.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -8239,9 +7752,10 @@ public func _bjs_asyncRoundTripBool(_ v: Int32) -> Int32 { @_cdecl("bjs_asyncRoundTripString") public func _bjs_asyncRoundTripString(_ vBytes: Int32, _ vLength: Int32) -> Int32 { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { - return await asyncRoundTripString(v: String.bridgeJSLiftParameter(vBytes, vLength)) - } + let ret = JSPromise.async { + return await asyncRoundTripString(v: String.bridgeJSLiftParameter(vBytes, vLength)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -8251,9 +7765,10 @@ public func _bjs_asyncRoundTripString(_ vBytes: Int32, _ vLength: Int32) -> Int3 @_cdecl("bjs_asyncRoundTripSwiftHeapObject") public func _bjs_asyncRoundTripSwiftHeapObject(_ v: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_7GreeterC, reject: Promise_reject) { - return await asyncRoundTripSwiftHeapObject(v: Greeter.bridgeJSLiftParameter(v)) - } + let ret = JSPromise.async { + return await asyncRoundTripSwiftHeapObject(v: Greeter.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -8263,9 +7778,10 @@ public func _bjs_asyncRoundTripSwiftHeapObject(_ v: UnsafeMutableRawPointer) -> @_cdecl("bjs_asyncRoundTripJSObject") public func _bjs_asyncRoundTripJSObject(_ v: Int32) -> Int32 { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_8JSObjectC, reject: Promise_reject) { - return await asyncRoundTripJSObject(v: JSObject.bridgeJSLiftParameter(v)) - } + let ret = JSPromise.async { + return await asyncRoundTripJSObject(v: JSObject.bridgeJSLiftParameter(v)).jsValue + }.jsObject + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -8303,239 +7819,89 @@ public func _bjs_useCalculator(_ calc: UnsafeMutableRawPointer, _ x: Int32, _ y: #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_asyncRoundTripTheme") -@_cdecl("bjs_asyncRoundTripTheme") -public func _bjs_asyncRoundTripTheme(_ vBytes: Int32, _ vLength: Int32) -> Int32 { - #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_5ThemeO, reject: Promise_reject) { - return await asyncRoundTripTheme(_: Theme.bridgeJSLiftParameter(vBytes, vLength)) - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripDirection") -@_cdecl("bjs_asyncRoundTripDirection") -public func _bjs_asyncRoundTripDirection(_ v: Int32) -> Int32 { - #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_9DirectionO, reject: Promise_reject) { - return await asyncRoundTripDirection(_: Direction.bridgeJSLiftParameter(v)) - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripOptionalTheme") -@_cdecl("bjs_asyncRoundTripOptionalTheme") -public func _bjs_asyncRoundTripOptionalTheme(_ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Int32 { - #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_Sq5ThemeO, reject: Promise_reject) { - return await asyncRoundTripOptionalTheme(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripOptionalDirection") -@_cdecl("bjs_asyncRoundTripOptionalDirection") -public func _bjs_asyncRoundTripOptionalDirection(_ vIsSome: Int32, _ vValue: Int32) -> Int32 { - #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_Sq9DirectionO, reject: Promise_reject) { - return await asyncRoundTripOptionalDirection(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_asyncRoundTripDirectionArray") -@_cdecl("bjs_asyncRoundTripDirectionArray") -public func _bjs_asyncRoundTripDirectionArray() -> Int32 { +@_expose(wasm, "bjs_testGreeterToJSValue") +@_cdecl("bjs_testGreeterToJSValue") +public func _bjs_testGreeterToJSValue() -> Int32 { #if arch(wasm32) - let _tmp_v = [Direction].bridgeJSStackPop() - return _bjs_makePromise(resolve: Promise_resolve_Sa9DirectionO, reject: Promise_reject) { - return await asyncRoundTripDirectionArray(_: _tmp_v) - } + let ret = testGreeterToJSValue() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripDirectionDict") -@_cdecl("bjs_asyncRoundTripDirectionDict") -public func _bjs_asyncRoundTripDirectionDict() -> Int32 { +@_expose(wasm, "bjs_testCalculatorToJSValue") +@_cdecl("bjs_testCalculatorToJSValue") +public func _bjs_testCalculatorToJSValue() -> Int32 { #if arch(wasm32) - let _tmp_v = [String: Direction].bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_SD9DirectionO, reject: Promise_reject) { - return await asyncRoundTripDirectionDict(_: _tmp_v) - } + let ret = testCalculatorToJSValue() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripThemeArray") -@_cdecl("bjs_asyncRoundTripThemeArray") -public func _bjs_asyncRoundTripThemeArray() -> Int32 { +@_expose(wasm, "bjs_testSwiftClassAsJSValue") +@_cdecl("bjs_testSwiftClassAsJSValue") +public func _bjs_testSwiftClassAsJSValue(_ greeter: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let _tmp_v = [Theme].bridgeJSStackPop() - return _bjs_makePromise(resolve: Promise_resolve_Sa5ThemeO, reject: Promise_reject) { - return await asyncRoundTripThemeArray(_: _tmp_v) - } + let ret = testSwiftClassAsJSValue(greeter: Greeter.bridgeJSLiftParameter(greeter)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripThemeDict") -@_cdecl("bjs_asyncRoundTripThemeDict") -public func _bjs_asyncRoundTripThemeDict() -> Int32 { +@_expose(wasm, "bjs_setDirection") +@_cdecl("bjs_setDirection") +public func _bjs_setDirection(_ direction: Int32) -> Int32 { #if arch(wasm32) - let _tmp_v = [String: Theme].bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_SD5ThemeO, reject: Promise_reject) { - return await asyncRoundTripThemeDict(_: _tmp_v) - } + let ret = setDirection(_: Direction.bridgeJSLiftParameter(direction)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripFileSize") -@_cdecl("bjs_asyncRoundTripFileSize") -public func _bjs_asyncRoundTripFileSize(_ v: Int64) -> Int32 { +@_expose(wasm, "bjs_getDirection") +@_cdecl("bjs_getDirection") +public func _bjs_getDirection() -> Int32 { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_8FileSizeO, reject: Promise_reject) { - return await asyncRoundTripFileSize(_: FileSize.bridgeJSLiftParameter(v)) - } + let ret = getDirection() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripOptionalFileSize") -@_cdecl("bjs_asyncRoundTripOptionalFileSize") -public func _bjs_asyncRoundTripOptionalFileSize(_ vIsSome: Int32, _ vValue: Int64) -> Int32 { +@_expose(wasm, "bjs_processDirection") +@_cdecl("bjs_processDirection") +public func _bjs_processDirection(_ input: Int32) -> Int32 { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_Sq8FileSizeO, reject: Promise_reject) { - return await asyncRoundTripOptionalFileSize(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) - } + let ret = processDirection(_: Direction.bridgeJSLiftParameter(input)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripAssociatedValueEnum") -@_cdecl("bjs_asyncRoundTripAssociatedValueEnum") -public func _bjs_asyncRoundTripAssociatedValueEnum(_ v: Int32) -> Int32 { +@_expose(wasm, "bjs_setTheme") +@_cdecl("bjs_setTheme") +public func _bjs_setTheme(_ themeBytes: Int32, _ themeLength: Int32) -> Void { #if arch(wasm32) - let _tmp_v = AsyncPayloadResult.bridgeJSLiftParameter(v) - return _bjs_makePromise(resolve: Promise_resolve_18AsyncPayloadResultO, reject: Promise_reject) { - return await asyncRoundTripAssociatedValueEnum(_: _tmp_v) - } + let ret = setTheme(_: Theme.bridgeJSLiftParameter(themeBytes, themeLength)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripOptionalAssociatedValueEnum") -@_cdecl("bjs_asyncRoundTripOptionalAssociatedValueEnum") -public func _bjs_asyncRoundTripOptionalAssociatedValueEnum(_ vIsSome: Int32, _ vCaseId: Int32) -> Int32 { +@_expose(wasm, "bjs_getTheme") +@_cdecl("bjs_getTheme") +public func _bjs_getTheme() -> Void { #if arch(wasm32) - let _tmp_v = Optional.bridgeJSLiftParameter(vIsSome, vCaseId) - return _bjs_makePromise(resolve: Promise_resolve_Sq18AsyncPayloadResultO, reject: Promise_reject) { - return await asyncRoundTripOptionalAssociatedValueEnum(_: _tmp_v) - } + let ret = getTheme() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -8974,474 +8340,743 @@ public func _bjs_makeUtilitiesResultFailure(_ errorBytes: Int32, _ errorLength: @_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)) + 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_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_makeAPINetworkingResultSuccess") -@_cdecl("bjs_makeAPINetworkingResultSuccess") -public func _bjs_makeAPINetworkingResultSuccess(_ messageBytes: Int32, _ messageLength: Int32) -> Void { +@_expose(wasm, "bjs_roundTripContact") +@_cdecl("bjs_roundTripContact") +public func _bjs_roundTripContact() -> Void { #if arch(wasm32) - let ret = makeAPINetworkingResultSuccess(_: String.bridgeJSLiftParameter(messageBytes, messageLength)) + let ret = roundTripContact(_: Contact.bridgeJSLiftParameter()) 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 { +@_expose(wasm, "bjs_roundTripConfig") +@_cdecl("bjs_roundTripConfig") +public func _bjs_roundTripConfig() -> Void { #if arch(wasm32) - let ret = makeAPINetworkingResultFailure(_: String.bridgeJSLiftParameter(errorBytes, errorLength), _: Int.bridgeJSLiftParameter(code)) + let ret = roundTripConfig(_: Config.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundtripUtilitiesResult") -@_cdecl("bjs_roundtripUtilitiesResult") -public func _bjs_roundtripUtilitiesResult(_ result: Int32) -> Void { +@_expose(wasm, "bjs_roundTripSessionData") +@_cdecl("bjs_roundTripSessionData") +public func _bjs_roundTripSessionData() -> Void { #if arch(wasm32) - let ret = roundtripUtilitiesResult(_: Utilities.Result.bridgeJSLiftParameter(result)) + let ret = roundTripSessionData(_: SessionData.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundtripAPINetworkingResult") -@_cdecl("bjs_roundtripAPINetworkingResult") -public func _bjs_roundtripAPINetworkingResult(_ result: Int32) -> Void { +@_expose(wasm, "bjs_roundTripValidationReport") +@_cdecl("bjs_roundTripValidationReport") +public func _bjs_roundTripValidationReport() -> Void { #if arch(wasm32) - let ret = roundtripAPINetworkingResult(_: API.NetworkingResult.bridgeJSLiftParameter(result)) + let ret = roundTripValidationReport(_: ValidationReport.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripAllTypesResult") -@_cdecl("bjs_roundTripAllTypesResult") -public func _bjs_roundTripAllTypesResult(_ result: Int32) -> Void { +@_expose(wasm, "bjs_roundTripAdvancedConfig") +@_cdecl("bjs_roundTripAdvancedConfig") +public func _bjs_roundTripAdvancedConfig() -> Void { #if arch(wasm32) - let ret = roundTripAllTypesResult(_: AllTypesResult.bridgeJSLiftParameter(result)) + let ret = roundTripAdvancedConfig(_: AdvancedConfig.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripTypedPayloadResult") -@_cdecl("bjs_roundTripTypedPayloadResult") -public func _bjs_roundTripTypedPayloadResult(_ result: Int32) -> Void { +@_expose(wasm, "bjs_roundTripMeasurementConfig") +@_cdecl("bjs_roundTripMeasurementConfig") +public func _bjs_roundTripMeasurementConfig() -> Void { #if arch(wasm32) - let ret = roundTripTypedPayloadResult(_: TypedPayloadResult.bridgeJSLiftParameter(result)) + let ret = roundTripMeasurementConfig(_: MeasurementConfig.bridgeJSLiftParameter()) 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 { +@_expose(wasm, "bjs_updateValidationReport") +@_cdecl("bjs_updateValidationReport") +public func _bjs_updateValidationReport(_ newResultIsSome: Int32, _ newResultCaseId: Int32) -> Void { #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)) + 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_testPropertyHolder") -@_cdecl("bjs_testPropertyHolder") -public func _bjs_testPropertyHolder(_ holder: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_testContainerWithStruct") +@_cdecl("bjs_testContainerWithStruct") +public func _bjs_testContainerWithStruct() -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = testPropertyHolder(holder: PropertyHolder.bridgeJSLiftParameter(holder)) + let ret = testContainerWithStruct(_: DataPoint.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_resetObserverCounts") -@_cdecl("bjs_resetObserverCounts") -public func _bjs_resetObserverCounts() -> Void { +@_expose(wasm, "bjs_roundTripJSObjectContainer") +@_cdecl("bjs_roundTripJSObjectContainer") +public func _bjs_roundTripJSObjectContainer() -> Void { #if arch(wasm32) - resetObserverCounts() + let ret = roundTripJSObjectContainer(_: JSObjectContainer.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_getObserverStats") -@_cdecl("bjs_getObserverStats") -public func _bjs_getObserverStats() -> Void { +@_expose(wasm, "bjs_roundTripFooContainer") +@_cdecl("bjs_roundTripFooContainer") +public func _bjs_roundTripFooContainer() -> Void { #if arch(wasm32) - let ret = getObserverStats() + let ret = roundTripFooContainer(_: FooContainer.bridgeJSLiftParameter()) 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 { +@_expose(wasm, "bjs_roundTripArrayMembers") +@_cdecl("bjs_roundTripArrayMembers") +public func _bjs_roundTripArrayMembers() -> Void { #if arch(wasm32) - let ret = formatName(_: String.bridgeJSLiftParameter(nameBytes, nameLength), transform: _BJS_Closure_20BridgeJSRuntimeTestsSS_SS.bridgeJSLift(transform)) + let ret = roundTripArrayMembers(_: ArrayMembers.bridgeJSLiftParameter()) 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 { +@_expose(wasm, "bjs_arrayMembersSum") +@_cdecl("bjs_arrayMembersSum") +public func _bjs_arrayMembersSum() -> Int32 { #if arch(wasm32) - let ret = makeFormatter(prefix: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) - return JSTypedClosure(ret).bridgeJSLowerReturn() + 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_makeAdder") -@_cdecl("bjs_makeAdder") -public func _bjs_makeAdder(_ base: Int32) -> Int32 { +@_expose(wasm, "bjs_arrayMembersFirst") +@_cdecl("bjs_arrayMembersFirst") +public func _bjs_arrayMembersFirst() -> Void { #if arch(wasm32) - let ret = makeAdder(base: Int.bridgeJSLiftParameter(base)) - return JSTypedClosure(ret).bridgeJSLowerReturn() + 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_roundTripPointerFields") -@_cdecl("bjs_roundTripPointerFields") -public func _bjs_roundTripPointerFields() -> Void { +@_expose(wasm, "bjs_PolygonReference_init") +@_cdecl("bjs_PolygonReference_init") +public func _bjs_PolygonReference_init(_ labelBytes: Int32, _ labelLength: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripPointerFields(_: PointerFields.bridgeJSLiftParameter()) + let ret = PolygonReference(verticesData: [Double].bridgeJSStackPop(), label: String.bridgeJSLiftParameter(labelBytes, labelLength)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_testStructDefault") -@_cdecl("bjs_testStructDefault") -public func _bjs_testStructDefault() -> Void { +@_expose(wasm, "bjs_PolygonReference_vertexCount") +@_cdecl("bjs_PolygonReference_vertexCount") +public func _bjs_PolygonReference_vertexCount(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = testStructDefault(point: DataPoint.bridgeJSLiftParameter()) + let ret = PolygonReference.bridgeJSLiftParameter(_self).vertexCount() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_cartToJSObject") -@_cdecl("bjs_cartToJSObject") -public func _bjs_cartToJSObject() -> Int32 { +@_expose(wasm, "bjs_PolygonReference_summary") +@_cdecl("bjs_PolygonReference_summary") +public func _bjs_PolygonReference_summary(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = cartToJSObject(_: CopyableCart.bridgeJSLiftParameter()) + let ret = PolygonReference.bridgeJSLiftParameter(_self).summary() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_nestedCartToJSObject") -@_cdecl("bjs_nestedCartToJSObject") -public func _bjs_nestedCartToJSObject() -> Int32 { +@_expose(wasm, "bjs_PolygonReference_snapshot") +@_cdecl("bjs_PolygonReference_snapshot") +public func _bjs_PolygonReference_snapshot(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = nestedCartToJSObject(_: CopyableNestedCart.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + let ret = PolygonReference.bridgeJSLiftParameter(_self).snapshot() + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripDataPoint") -@_cdecl("bjs_roundTripDataPoint") -public func _bjs_roundTripDataPoint() -> Void { +@_expose(wasm, "bjs_PolygonReference_merge") +@_cdecl("bjs_PolygonReference_merge") +public func _bjs_PolygonReference_merge(_ _self: UnsafeMutableRawPointer, _ other: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripDataPoint(_: DataPoint.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + let ret = PolygonReference.bridgeJSLiftParameter(_self).merge(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(other))) + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripPublicPoint") -@_cdecl("bjs_roundTripPublicPoint") -public func _bjs_roundTripPublicPoint() -> Void { +@_expose(wasm, "bjs_PolygonReference_static_origin") +@_cdecl("bjs_PolygonReference_static_origin") +public func _bjs_PolygonReference_static_origin(_ labelBytes: Int32, _ labelLength: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripPublicPoint(_: PublicPoint.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + let ret = PolygonReference.origin(label: String.bridgeJSLiftParameter(labelBytes, labelLength)) + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripPublicPoint") -@_cdecl("bjs_asyncRoundTripPublicPoint") -public func _bjs_asyncRoundTripPublicPoint() -> Int32 { +@_expose(wasm, "bjs_PolygonReference_deinit") +@_cdecl("bjs_PolygonReference_deinit") +public func _bjs_PolygonReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let _tmp_point = PublicPoint.bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { - return await asyncRoundTripPublicPoint(_: _tmp_point) - } + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripPublicPointThrows") -@_cdecl("bjs_asyncRoundTripPublicPointThrows") -public func _bjs_asyncRoundTripPublicPointThrows() -> Int32 { - #if arch(wasm32) - let _tmp_point = PublicPoint.bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { () async throws(JSException) -> PublicPoint in - return try await asyncRoundTripPublicPointThrows(_: _tmp_point) +extension PolygonReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_PolygonReference_wrap(Unmanaged.passRetained(self).toOpaque())))) } - #else + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_PolygonReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PolygonReference_wrap") +fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func _bjs_PolygonReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_PolygonReference_wrap_extern(pointer) } -@_expose(wasm, "bjs_asyncStructOrThrow") -@_cdecl("bjs_asyncStructOrThrow") -public func _bjs_asyncStructOrThrow(_ shouldThrow: Int32) -> Int32 { +@_expose(wasm, "bjs_TagReference_describe") +@_cdecl("bjs_TagReference_describe") +public func _bjs_TagReference_describe(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { () async throws(JSException) -> PublicPoint in - return try await asyncStructOrThrow(_: Bool.bridgeJSLiftParameter(shouldThrow)) - } + let ret = TagReference.bridgeJSLiftParameter(_self).describe() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncCombinePublicPoints") -@_cdecl("bjs_asyncCombinePublicPoints") -public func _bjs_asyncCombinePublicPoints() -> Int32 { +@_expose(wasm, "bjs_TagReference_deinit") +@_cdecl("bjs_TagReference_deinit") +public func _bjs_TagReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let _tmp_b = PublicPoint.bridgeJSLiftParameter() - let _tmp_a = PublicPoint.bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { - return await asyncCombinePublicPoints(_: _tmp_a, _: _tmp_b) - } + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripContact") -@_cdecl("bjs_asyncRoundTripContact") -public func _bjs_asyncRoundTripContact() -> Int32 { - #if arch(wasm32) - let _tmp_contact = Contact.bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_7ContactV, reject: Promise_reject) { - return await asyncRoundTripContact(_: _tmp_contact) +extension TagReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_TagReference_wrap(Unmanaged.passRetained(self).toOpaque())))) } - #else + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_TagReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TagReference_wrap") +fileprivate func _bjs_TagReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_TagReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func _bjs_TagReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_TagReference_wrap_extern(pointer) } -@_expose(wasm, "bjs_asyncRoundTripPublicPointArray") -@_cdecl("bjs_asyncRoundTripPublicPointArray") -public func _bjs_asyncRoundTripPublicPointArray() -> Int32 { +@_expose(wasm, "bjs_TokenReference_init") +@_cdecl("bjs_TokenReference_init") +public func _bjs_TokenReference_init(_ value: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let _tmp_points = [PublicPoint].bridgeJSStackPop() - return _bjs_makePromise(resolve: Promise_resolve_Sa11PublicPointV, reject: Promise_reject) { - return await asyncRoundTripPublicPointArray(_: _tmp_points) - } + let ret = TokenReference(value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripOptionalPublicPoint") -@_cdecl("bjs_asyncRoundTripOptionalPublicPoint") -public func _bjs_asyncRoundTripOptionalPublicPoint() -> Int32 { +@_expose(wasm, "bjs_TokenReference_read") +@_cdecl("bjs_TokenReference_read") +public func _bjs_TokenReference_read(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let _tmp_point = Optional.bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_Sq11PublicPointV, reject: Promise_reject) { - return await asyncRoundTripOptionalPublicPoint(_: _tmp_point) - } + let ret = TokenReference.bridgeJSLiftParameter(_self).read() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripPublicPointDict") -@_cdecl("bjs_asyncRoundTripPublicPointDict") -public func _bjs_asyncRoundTripPublicPointDict() -> Int32 { +@_expose(wasm, "bjs_TokenReference_deinit") +@_cdecl("bjs_TokenReference_deinit") +public func _bjs_TokenReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let _tmp_points = [String: PublicPoint].bridgeJSLiftParameter() - return _bjs_makePromise(resolve: Promise_resolve_SD11PublicPointV, reject: Promise_reject) { - return await asyncRoundTripPublicPointDict(_: _tmp_points) - } + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripContact") -@_cdecl("bjs_roundTripContact") -public func _bjs_roundTripContact() -> Void { +extension TokenReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_TokenReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_TokenReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TokenReference_wrap") +fileprivate func _bjs_TokenReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_TokenReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_TokenReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_TokenReference_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_TagHolderReference_init") +@_cdecl("bjs_TagHolderReference_init") +public func _bjs_TagHolderReference_init(_ tag: UnsafeMutableRawPointer, _ version: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripContact(_: Contact.bridgeJSLiftParameter()) + let ret = TagHolderReference(tag: Tag.bridgeFromJS(TagReference.bridgeJSLiftParameter(tag)), version: Int.bridgeJSLiftParameter(version)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripConfig") -@_cdecl("bjs_roundTripConfig") -public func _bjs_roundTripConfig() -> Void { +@_expose(wasm, "bjs_TagHolderReference_describe") +@_cdecl("bjs_TagHolderReference_describe") +public func _bjs_TagHolderReference_describe(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = roundTripConfig(_: Config.bridgeJSLiftParameter()) + let ret = TagHolderReference.bridgeJSLiftParameter(_self).describe() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripSessionData") -@_cdecl("bjs_roundTripSessionData") -public func _bjs_roundTripSessionData() -> Void { +@_expose(wasm, "bjs_TagHolderReference_tag_get") +@_cdecl("bjs_TagHolderReference_tag_get") +public func _bjs_TagHolderReference_tag_get(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripSessionData(_: SessionData.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + let ret = TagHolderReference.bridgeJSLiftParameter(_self).tag + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripValidationReport") -@_cdecl("bjs_roundTripValidationReport") -public func _bjs_roundTripValidationReport() -> Void { +@_expose(wasm, "bjs_TagHolderReference_tag_set") +@_cdecl("bjs_TagHolderReference_tag_set") +public func _bjs_TagHolderReference_tag_set(_ _self: UnsafeMutableRawPointer, _ value: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = roundTripValidationReport(_: ValidationReport.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + TagHolderReference.bridgeJSLiftParameter(_self).tag = Tag.bridgeFromJS(TagReference.bridgeJSLiftParameter(value)) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripAdvancedConfig") -@_cdecl("bjs_roundTripAdvancedConfig") -public func _bjs_roundTripAdvancedConfig() -> Void { +@_expose(wasm, "bjs_TagHolderReference_version_get") +@_cdecl("bjs_TagHolderReference_version_get") +public func _bjs_TagHolderReference_version_get(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = roundTripAdvancedConfig(_: AdvancedConfig.bridgeJSLiftParameter()) + let ret = TagHolderReference.bridgeJSLiftParameter(_self).version return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripMeasurementConfig") -@_cdecl("bjs_roundTripMeasurementConfig") -public func _bjs_roundTripMeasurementConfig() -> Void { +@_expose(wasm, "bjs_TagHolderReference_version_set") +@_cdecl("bjs_TagHolderReference_version_set") +public func _bjs_TagHolderReference_version_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { #if arch(wasm32) - let ret = roundTripMeasurementConfig(_: MeasurementConfig.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + TagHolderReference.bridgeJSLiftParameter(_self).version = Int.bridgeJSLiftParameter(value) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_updateValidationReport") -@_cdecl("bjs_updateValidationReport") -public func _bjs_updateValidationReport(_ newResultIsSome: Int32, _ newResultCaseId: Int32) -> Void { +@_expose(wasm, "bjs_TagHolderReference_deinit") +@_cdecl("bjs_TagHolderReference_deinit") +public func _bjs_TagHolderReference_deinit(_ pointer: UnsafeMutableRawPointer) -> 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() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_testContainerWithStruct") -@_cdecl("bjs_testContainerWithStruct") -public func _bjs_testContainerWithStruct() -> UnsafeMutableRawPointer { +extension TagHolderReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_TagHolderReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_TagHolderReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TagHolderReference_wrap") +fileprivate func _bjs_TagHolderReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_TagHolderReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_TagHolderReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_TagHolderReference_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_PriorityReference_describe") +@_cdecl("bjs_PriorityReference_describe") +public func _bjs_PriorityReference_describe(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = testContainerWithStruct(_: DataPoint.bridgeJSLiftParameter()) + let ret = PriorityReference.bridgeJSLiftParameter(_self).describe() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripJSObjectContainer") -@_cdecl("bjs_roundTripJSObjectContainer") -public func _bjs_roundTripJSObjectContainer() -> Void { +@_expose(wasm, "bjs_PriorityReference_weight") +@_cdecl("bjs_PriorityReference_weight") +public func _bjs_PriorityReference_weight(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = roundTripJSObjectContainer(_: JSObjectContainer.bridgeJSLiftParameter()) + let ret = PriorityReference.bridgeJSLiftParameter(_self).weight() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripFooContainer") -@_cdecl("bjs_roundTripFooContainer") -public func _bjs_roundTripFooContainer() -> Void { +@_expose(wasm, "bjs_PriorityReference_static_low") +@_cdecl("bjs_PriorityReference_static_low") +public func _bjs_PriorityReference_static_low() -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripFooContainer(_: FooContainer.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + let ret = PriorityReference.low() + return ret.bridgeToJS().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() +@_expose(wasm, "bjs_PriorityReference_static_medium") +@_cdecl("bjs_PriorityReference_static_medium") +public func _bjs_PriorityReference_static_medium() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = PriorityReference.medium() + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_arrayMembersSum") -@_cdecl("bjs_arrayMembersSum") -public func _bjs_arrayMembersSum() -> Int32 { +@_expose(wasm, "bjs_PriorityReference_static_high") +@_cdecl("bjs_PriorityReference_static_high") +public func _bjs_PriorityReference_static_high() -> UnsafeMutableRawPointer { #if arch(wasm32) - let _tmp_values = [Int].bridgeJSStackPop() - let _tmp_value = ArrayMembers.bridgeJSLiftParameter() - let ret = arrayMembersSum(_: _tmp_value, _: _tmp_values) - return ret.bridgeJSLowerReturn() + let ret = PriorityReference.high() + return ret.bridgeToJS().bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_arrayMembersFirst") -@_cdecl("bjs_arrayMembersFirst") -public func _bjs_arrayMembersFirst() -> Void { +@_expose(wasm, "bjs_PriorityReference_deinit") +@_cdecl("bjs_PriorityReference_deinit") +public func _bjs_PriorityReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let _tmp_values = [String].bridgeJSStackPop() - let _tmp_value = ArrayMembers.bridgeJSLiftParameter() - let ret = arrayMembersFirst(_: _tmp_value, _: _tmp_values) - return ret.bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } +extension PriorityReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_PriorityReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_PriorityReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PriorityReference_wrap") +fileprivate func _bjs_PriorityReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_PriorityReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_PriorityReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_PriorityReference_wrap_extern(pointer) +} + @_expose(wasm, "bjs_ClosureSupportExports_static_makeIntToInt") @_cdecl("bjs_ClosureSupportExports_static_makeIntToInt") public func _bjs_ClosureSupportExports_static_makeIntToInt(_ base: Int32) -> Int32 { @@ -9902,18 +9537,6 @@ public func _bjs_Calculator_add(_ _self: UnsafeMutableRawPointer, _ a: Int32, _ #endif } -@_expose(wasm, "bjs_Calculator_asyncMakePoint") -@_cdecl("bjs_Calculator_asyncMakePoint") -public func _bjs_Calculator_asyncMakePoint(_ _self: UnsafeMutableRawPointer, _ x: Int32, _ y: Int32) -> Int32 { - #if arch(wasm32) - return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { - return await Calculator.bridgeJSLiftParameter(_self).asyncMakePoint(x: Int.bridgeJSLiftParameter(x), y: Int.bridgeJSLiftParameter(y)) - } - #else - fatalError("Only available on WebAssembly") - #endif -} - @_expose(wasm, "bjs_Calculator_deinit") @_cdecl("bjs_Calculator_deinit") public func _bjs_Calculator_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { @@ -12328,639 +11951,260 @@ public func _bjs_Container_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { 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) -} - -@JSFunction func Promise_reject(_ promise: JSObject, _ value: JSValue) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_reject_BridgeJSRuntimeTests") -fileprivate func promise_reject_BridgeJSRuntimeTests_extern(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void -#else -fileprivate func promise_reject_BridgeJSRuntimeTests_extern(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_reject_BridgeJSRuntimeTests(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void { - return promise_reject_BridgeJSRuntimeTests_extern(promise, valueKind, valuePayload1, valuePayload2) -} - -func _$Promise_reject(_ promise: JSObject, _ value: JSValue) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let (valueKind, valuePayload1, valuePayload2) = value.bridgeJSLowerParameter() - promise_reject_BridgeJSRuntimeTests(promiseValue, valueKind, valuePayload1, valuePayload2) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_SS(_ promise: JSObject, _ value: String) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_SS") -fileprivate func promise_resolve_BridgeJSRuntimeTests_SS_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_SS_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_SS(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_SS_extern(promise, valueBytes, valueLength) -} - -func _$Promise_resolve_SS(_ promise: JSObject, _ value: String) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - value.bridgeJSWithLoweredParameter { (valueBytes, valueLength) in - promise_resolve_BridgeJSRuntimeTests_SS(promiseValue, valueBytes, valueLength) - } - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_y(_ promise: JSObject) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_y") -fileprivate func promise_resolve_BridgeJSRuntimeTests_y_extern(_ promise: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_y_extern(_ promise: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_y(_ promise: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_y_extern(promise) -} - -func _$Promise_resolve_y(_ promise: JSObject) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_y(promiseValue) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_Si(_ promise: JSObject, _ value: Int) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Si") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Si_extern(_ promise: Int32, _ value: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Si_extern(_ promise: Int32, _ value: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Si(_ promise: Int32, _ value: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Si_extern(promise, value) -} - -func _$Promise_resolve_Si(_ promise: JSObject, _ value: Int) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueValue = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_Si(promiseValue, valueValue) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_Sf(_ promise: JSObject, _ value: Float) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sf") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sf_extern(_ promise: Int32, _ value: Float32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sf_extern(_ promise: Int32, _ value: Float32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sf(_ promise: Int32, _ value: Float32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Sf_extern(promise, value) -} - -func _$Promise_resolve_Sf(_ promise: JSObject, _ value: Float) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueValue = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_Sf(promiseValue, valueValue) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_Sd(_ promise: JSObject, _ value: Double) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sd") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sd_extern(_ promise: Int32, _ value: Float64) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sd_extern(_ promise: Int32, _ value: Float64) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sd(_ promise: Int32, _ value: Float64) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Sd_extern(promise, value) -} - -func _$Promise_resolve_Sd(_ promise: JSObject, _ value: Double) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueValue = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_Sd(promiseValue, valueValue) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_Sb(_ promise: JSObject, _ value: Bool) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sb") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sb_extern(_ promise: Int32, _ value: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sb_extern(_ promise: Int32, _ value: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sb(_ promise: Int32, _ value: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Sb_extern(promise, value) -} - -func _$Promise_resolve_Sb(_ promise: JSObject, _ value: Bool) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueValue = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_Sb(promiseValue, valueValue) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_7GreeterC(_ promise: JSObject, _ value: Greeter) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_7GreeterC") -fileprivate func promise_resolve_BridgeJSRuntimeTests_7GreeterC_extern(_ promise: Int32, _ value: UnsafeMutableRawPointer) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_7GreeterC_extern(_ promise: Int32, _ value: UnsafeMutableRawPointer) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_7GreeterC(_ promise: Int32, _ value: UnsafeMutableRawPointer) -> Void { - return promise_resolve_BridgeJSRuntimeTests_7GreeterC_extern(promise, value) -} - -func _$Promise_resolve_7GreeterC(_ promise: JSObject, _ value: Greeter) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valuePointer = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_7GreeterC(promiseValue, valuePointer) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_8JSObjectC(_ promise: JSObject, _ value: JSObject) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_8JSObjectC") -fileprivate func promise_resolve_BridgeJSRuntimeTests_8JSObjectC_extern(_ promise: Int32, _ value: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_8JSObjectC_extern(_ promise: Int32, _ value: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_8JSObjectC(_ promise: Int32, _ value: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_8JSObjectC_extern(promise, value) -} - -func _$Promise_resolve_8JSObjectC(_ promise: JSObject, _ value: JSObject) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueValue = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_8JSObjectC(promiseValue, valueValue) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_5ThemeO(_ promise: JSObject, _ value: Theme) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_5ThemeO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_5ThemeO_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_5ThemeO_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_5ThemeO(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_5ThemeO_extern(promise, valueBytes, valueLength) -} - -func _$Promise_resolve_5ThemeO(_ promise: JSObject, _ value: Theme) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - value.bridgeJSWithLoweredParameter { (valueBytes, valueLength) in - promise_resolve_BridgeJSRuntimeTests_5ThemeO(promiseValue, valueBytes, valueLength) - } - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_9DirectionO(_ promise: JSObject, _ value: Direction) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_9DirectionO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_9DirectionO_extern(_ promise: Int32, _ value: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_9DirectionO_extern(_ promise: Int32, _ value: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_9DirectionO(_ promise: Int32, _ value: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_9DirectionO_extern(promise, value) -} - -func _$Promise_resolve_9DirectionO(_ promise: JSObject, _ value: Direction) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueValue = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_9DirectionO(promiseValue, valueValue) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_Sq5ThemeO(_ promise: JSObject, _ value: Optional) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO(_ promise: Int32, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO_extern(promise, valueIsSome, valueBytes, valueLength) -} - -func _$Promise_resolve_Sq5ThemeO(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - value.bridgeJSWithLoweredParameter { (valueIsSome, valueBytes, valueLength) in - promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO(promiseValue, valueIsSome, valueBytes, valueLength) - } - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_Sq9DirectionO(_ promise: JSObject, _ value: Optional) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO_extern(promise, valueIsSome, valueValue) -} - -func _$Promise_resolve_Sq9DirectionO(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let (valueIsSome, valueValue) = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO(promiseValue, valueIsSome, valueValue) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_Sa9DirectionO(_ promise: JSObject, _ value: [Direction]) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO_extern(_ promise: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO_extern(_ promise: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO(_ promise: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO_extern(promise) -} - -func _$Promise_resolve_Sa9DirectionO(_ promise: JSObject, _ value: [Direction]) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let _ = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO(promiseValue) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_SD9DirectionO(_ promise: JSObject, _ value: [String: Direction]) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_SD9DirectionO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_SD9DirectionO_extern(_ promise: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_SD9DirectionO_extern(_ promise: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_SD9DirectionO(_ promise: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_SD9DirectionO_extern(promise) + #endif } -func _$Promise_resolve_SD9DirectionO(_ promise: JSObject, _ value: [String: Direction]) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let _ = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_SD9DirectionO(promiseValue) - if let error = _swift_js_take_exception() { throw error } +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()) + } } -@JSFunction func Promise_resolve_Sa5ThemeO(_ promise: JSObject, _ value: [Theme]) throws(JSException) - #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO_extern(_ promise: Int32) -> Void +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Container_wrap") +fileprivate func _bjs_Container_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO_extern(_ promise: Int32) -> Void { +fileprivate func _bjs_Container_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO(_ promise: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO_extern(promise) +@inline(never) fileprivate func _bjs_Container_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Container_wrap_extern(pointer) } -func _$Promise_resolve_Sa5ThemeO(_ promise: JSObject, _ value: [Theme]) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let _ = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO(promiseValue) - if let error = _swift_js_take_exception() { throw error } +@_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 } -@JSFunction func Promise_resolve_SD5ThemeO(_ promise: JSObject, _ value: [String: Theme]) throws(JSException) - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_SD5ThemeO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_SD5ThemeO_extern(_ promise: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_SD5ThemeO_extern(_ promise: Int32) -> Void { +@_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 -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_SD5ThemeO(_ promise: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_SD5ThemeO_extern(promise) + #endif } -func _$Promise_resolve_SD5ThemeO(_ promise: JSObject, _ value: [String: Theme]) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let _ = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_SD5ThemeO(promiseValue) - if let error = _swift_js_take_exception() { throw error } +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()) + } } -@JSFunction func Promise_resolve_8FileSizeO(_ promise: JSObject, _ value: FileSize) throws(JSException) - #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_8FileSizeO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_8FileSizeO_extern(_ promise: Int32, _ value: Int64) -> Void +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_LeakCheck_wrap") +fileprivate func _bjs_LeakCheck_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func promise_resolve_BridgeJSRuntimeTests_8FileSizeO_extern(_ promise: Int32, _ value: Int64) -> Void { +fileprivate func _bjs_LeakCheck_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_8FileSizeO(_ promise: Int32, _ value: Int64) -> Void { - return promise_resolve_BridgeJSRuntimeTests_8FileSizeO_extern(promise, value) -} - -func _$Promise_resolve_8FileSizeO(_ promise: JSObject, _ value: FileSize) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueValue = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_8FileSizeO(promiseValue, valueValue) - if let error = _swift_js_take_exception() { throw error } +@inline(never) fileprivate func _bjs_LeakCheck_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_LeakCheck_wrap_extern(pointer) } -@JSFunction func Promise_resolve_Sq8FileSizeO(_ promise: JSObject, _ value: Optional) throws(JSException) - #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int64) -> Void +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Surface_init") +fileprivate func bjs_Surface_init_extern(_ labelBytes: Int32, _ labelLength: Int32) -> Int32 #else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int64) -> Void { +fileprivate func bjs_Surface_init_extern(_ labelBytes: Int32, _ labelLength: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int64) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO_extern(promise, valueIsSome, valueValue) -} - -func _$Promise_resolve_Sq8FileSizeO(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let (valueIsSome, valueValue) = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO(promiseValue, valueIsSome, valueValue) - if let error = _swift_js_take_exception() { throw error } +@inline(never) fileprivate func bjs_Surface_init(_ labelBytes: Int32, _ labelLength: Int32) -> Int32 { + return bjs_Surface_init_extern(labelBytes, labelLength) } -@JSFunction func Promise_resolve_18AsyncPayloadResultO(_ promise: JSObject, _ value: AsyncPayloadResult) throws(JSException) - #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO_extern(_ promise: Int32, _ value: Int32) -> Void +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Surface_label_get") +fileprivate func bjs_Surface_label_get_extern(_ self: Int32) -> Int32 #else -fileprivate func promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO_extern(_ promise: Int32, _ value: Int32) -> Void { +fileprivate func bjs_Surface_label_get_extern(_ self: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO(_ promise: Int32, _ value: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO_extern(promise, value) +@inline(never) fileprivate func bjs_Surface_label_get(_ self: Int32) -> Int32 { + return bjs_Surface_label_get_extern(self) } -func _$Promise_resolve_18AsyncPayloadResultO(_ promise: JSObject, _ value: AsyncPayloadResult) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueCaseId = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO(promiseValue, valueCaseId) - if let error = _swift_js_take_exception() { throw error } +func _$Surface_init(_ label: String) throws(JSException) -> JSObject { + let ret0 = label.bridgeJSWithLoweredParameter { (labelBytes, labelLength) in + let ret = bjs_Surface_init(labelBytes, labelLength) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return JSObject.bridgeJSLiftReturn(ret) } -@JSFunction func Promise_resolve_Sq18AsyncPayloadResultO(_ promise: JSObject, _ value: Optional) throws(JSException) +func _$Surface_label_get(_ self: JSObject) throws(JSException) -> String { + let selfValue = self.bridgeJSLowerParameter() + let ret = bjs_Surface_label_get(selfValue) + if let error = _swift_js_take_exception() { + throw error + } + return String.bridgeJSLiftReturn(ret) +} #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AliasImports_jsRoundTripTagged_static") +fileprivate func bjs_AliasImports_jsRoundTripTagged_static_extern(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 #else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void { +fileprivate func bjs_AliasImports_jsRoundTripTagged_static_extern(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO_extern(promise, valueIsSome, valueCaseId) -} - -func _$Promise_resolve_Sq18AsyncPayloadResultO(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let (valueIsSome, valueCaseId) = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO(promiseValue, valueIsSome, valueCaseId) - if let error = _swift_js_take_exception() { throw error } +@inline(never) fileprivate func bjs_AliasImports_jsRoundTripTagged_static(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 { + return bjs_AliasImports_jsRoundTripTagged_static_extern(valueBytes, valueLength) } -@JSFunction func Promise_resolve_11PublicPointV(_ promise: JSObject, _ value: PublicPoint) throws(JSException) - #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_11PublicPointV") -fileprivate func promise_resolve_BridgeJSRuntimeTests_11PublicPointV_extern(_ promise: Int32, _ value: Int32) -> Void +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AliasImports_jsRoundTripOptionalTagged_static") +fileprivate func bjs_AliasImports_jsRoundTripOptionalTagged_static_extern(_ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void #else -fileprivate func promise_resolve_BridgeJSRuntimeTests_11PublicPointV_extern(_ promise: Int32, _ value: Int32) -> Void { +fileprivate func bjs_AliasImports_jsRoundTripOptionalTagged_static_extern(_ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_11PublicPointV(_ promise: Int32, _ value: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_11PublicPointV_extern(promise, value) -} - -func _$Promise_resolve_11PublicPointV(_ promise: JSObject, _ value: PublicPoint) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueObjectId = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_11PublicPointV(promiseValue, valueObjectId) - if let error = _swift_js_take_exception() { throw error } +@inline(never) fileprivate func bjs_AliasImports_jsRoundTripOptionalTagged_static(_ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + return bjs_AliasImports_jsRoundTripOptionalTagged_static_extern(valueIsSome, valueBytes, valueLength) } -@JSFunction func Promise_resolve_7ContactV(_ promise: JSObject, _ value: Contact) throws(JSException) - #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_7ContactV") -fileprivate func promise_resolve_BridgeJSRuntimeTests_7ContactV_extern(_ promise: Int32, _ value: Int32) -> Void +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AliasImports_jsProduceOptionalCanvas_static") +fileprivate func bjs_AliasImports_jsProduceOptionalCanvas_static_extern(_ labelIsSome: Int32, _ labelBytes: Int32, _ labelLength: Int32) -> Void #else -fileprivate func promise_resolve_BridgeJSRuntimeTests_7ContactV_extern(_ promise: Int32, _ value: Int32) -> Void { +fileprivate func bjs_AliasImports_jsProduceOptionalCanvas_static_extern(_ labelIsSome: Int32, _ labelBytes: Int32, _ labelLength: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_7ContactV(_ promise: Int32, _ value: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_7ContactV_extern(promise, value) -} - -func _$Promise_resolve_7ContactV(_ promise: JSObject, _ value: Contact) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueObjectId = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_7ContactV(promiseValue, valueObjectId) - if let error = _swift_js_take_exception() { throw error } +@inline(never) fileprivate func bjs_AliasImports_jsProduceOptionalCanvas_static(_ labelIsSome: Int32, _ labelBytes: Int32, _ labelLength: Int32) -> Void { + return bjs_AliasImports_jsProduceOptionalCanvas_static_extern(labelIsSome, labelBytes, labelLength) } -@JSFunction func Promise_resolve_Sa11PublicPointV(_ promise: JSObject, _ value: [PublicPoint]) throws(JSException) - #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV_extern(_ promise: Int32) -> Void +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AliasImports_jsRoundTripAliasedTags_static") +fileprivate func bjs_AliasImports_jsRoundTripAliasedTags_static_extern() -> Void #else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV_extern(_ promise: Int32) -> Void { +fileprivate func bjs_AliasImports_jsRoundTripAliasedTags_static_extern() -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV(_ promise: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV_extern(promise) +@inline(never) fileprivate func bjs_AliasImports_jsRoundTripAliasedTags_static() -> Void { + return bjs_AliasImports_jsRoundTripAliasedTags_static_extern() } -func _$Promise_resolve_Sa11PublicPointV(_ promise: JSObject, _ value: [PublicPoint]) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let _ = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV(promiseValue) - if let error = _swift_js_take_exception() { throw error } -} - -@JSFunction func Promise_resolve_Sq11PublicPointV(_ promise: JSObject, _ value: Optional) throws(JSException) - #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV") -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV_extern(_ promise: Int32, _ value: Int32) -> Void +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AliasImports_jsRoundTripPolygon_static") +fileprivate func bjs_AliasImports_jsRoundTripPolygon_static_extern(_ value: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer #else -fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV_extern(_ promise: Int32, _ value: Int32) -> Void { +fileprivate func bjs_AliasImports_jsRoundTripPolygon_static_extern(_ value: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV(_ promise: Int32, _ value: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV_extern(promise, value) -} - -func _$Promise_resolve_Sq11PublicPointV(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueIsSome = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV(promiseValue, valueIsSome) - if let error = _swift_js_take_exception() { throw error } +@inline(never) fileprivate func bjs_AliasImports_jsRoundTripPolygon_static(_ value: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + return bjs_AliasImports_jsRoundTripPolygon_static_extern(value) } -@JSFunction func Promise_resolve_SD11PublicPointV(_ promise: JSObject, _ value: [String: PublicPoint]) throws(JSException) - #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV") -fileprivate func promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV_extern(_ promise: Int32) -> Void +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AliasImports_jsRoundTripCoordinate_static") +fileprivate func bjs_AliasImports_jsRoundTripCoordinate_static_extern(_ value: Int32) -> Int32 #else -fileprivate func promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV_extern(_ promise: Int32) -> Void { +fileprivate func bjs_AliasImports_jsRoundTripCoordinate_static_extern(_ value: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV(_ promise: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV_extern(promise) +@inline(never) fileprivate func bjs_AliasImports_jsRoundTripCoordinate_static(_ value: Int32) -> Int32 { + return bjs_AliasImports_jsRoundTripCoordinate_static_extern(value) +} + +func _$AliasImports_jsRoundTripTagged(_ value: Tagged) throws(JSException) -> Tagged { + let ret0 = value.bridgeToJS().bridgeJSWithLoweredParameter { (valueBytes, valueLength) in + let ret = bjs_AliasImports_jsRoundTripTagged_static(valueBytes, valueLength) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return Tagged.bridgeFromJS(String.bridgeJSLiftReturn(ret)) } -func _$Promise_resolve_SD11PublicPointV(_ promise: JSObject, _ value: [String: PublicPoint]) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let _ = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV(promiseValue) - if let error = _swift_js_take_exception() { throw error } +func _$AliasImports_jsRoundTripOptionalTagged(_ value: Optional) throws(JSException) -> Optional { + value.map { + $0.bridgeToJS() + } .bridgeJSWithLoweredParameter { (valueIsSome, valueBytes, valueLength) in + bjs_AliasImports_jsRoundTripOptionalTagged_static(valueIsSome, valueBytes, valueLength) + } + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturnFromSideChannel().map { + Tagged.bridgeFromJS($0) + } } -@JSFunction func Promise_resolve_9DataPointV(_ promise: JSObject, _ value: DataPoint) throws(JSException) +func _$AliasImports_jsProduceOptionalCanvas(_ label: Optional) throws(JSException) -> Optional { + label.bridgeJSWithLoweredParameter { (labelIsSome, labelBytes, labelLength) in + bjs_AliasImports_jsProduceOptionalCanvas_static(labelIsSome, labelBytes, labelLength) + } + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn().map { + Canvas.bridgeFromJS($0) + } +} -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_9DataPointV") -fileprivate func promise_resolve_BridgeJSRuntimeTests_9DataPointV_extern(_ promise: Int32, _ value: Int32) -> Void -#else -fileprivate func promise_resolve_BridgeJSRuntimeTests_9DataPointV_extern(_ promise: Int32, _ value: Int32) -> Void { - fatalError("Only available on WebAssembly") +func _$AliasImports_jsRoundTripAliasedTags(_ values: [Optional]) throws(JSException) -> [Optional] { + let _ = values.map { + $0.map { + $0.bridgeToJS() + } + } .bridgeJSLowerParameter() + bjs_AliasImports_jsRoundTripAliasedTags_static() + if let error = _swift_js_take_exception() { + throw error + } + return [Optional].bridgeJSLiftReturn().map { + $0.map { + AliasedTag.bridgeFromJS($0) + } + } } -#endif -@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_9DataPointV(_ promise: Int32, _ value: Int32) -> Void { - return promise_resolve_BridgeJSRuntimeTests_9DataPointV_extern(promise, value) + +func _$AliasImports_jsRoundTripPolygon(_ value: Polygon) throws(JSException) -> Polygon { + let valuePointer = value.bridgeToJS().bridgeJSLowerParameter() + let ret = bjs_AliasImports_jsRoundTripPolygon_static(valuePointer) + if let error = _swift_js_take_exception() { + throw error + } + return Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftReturn(ret)) } -func _$Promise_resolve_9DataPointV(_ promise: JSObject, _ value: DataPoint) throws(JSException) -> Void { - let promiseValue = promise.bridgeJSLowerParameter() - let valueObjectId = value.bridgeJSLowerParameter() - promise_resolve_BridgeJSRuntimeTests_9DataPointV(promiseValue, valueObjectId) - if let error = _swift_js_take_exception() { throw error } +func _$AliasImports_jsRoundTripCoordinate(_ value: Coordinate) throws(JSException) -> Coordinate { + let valueObjectId = value.bridgeToJS().bridgeJSLowerParameter() + let ret = bjs_AliasImports_jsRoundTripCoordinate_static(valueObjectId) + if let error = _swift_js_take_exception() { + throw error + } + return Coordinate.bridgeFromJS(JSCoordinate.bridgeJSLiftReturn(ret)) } #if arch(wasm32) @@ -13482,30 +12726,6 @@ fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_exter return bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_extern(resolveRef, rejectRef, vBytes, vLength) } -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static_extern(resolveRef, rejectRef, v) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static") -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vCaseId: Int32) -> Void -#else -fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vCaseId: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vCaseId: Int32) -> Void { - return bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static_extern(resolveRef, rejectRef, vIsSome, vCaseId) -} - func _$AsyncImportImports_jsAsyncRoundTripVoid() async throws(JSException) -> Void { try await _bjs_awaitPromise(makeResolveClosure: { JSTypedClosure<() -> Void>($0) @@ -13627,52 +12847,6 @@ func _$AsyncImportImports_jsAsyncRoundTripFeatureFlag(_ v: FeatureFlag) async th return resolved } -func _$AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum(_ v: AsyncImportedPayloadResult) async throws(JSException) -> AsyncImportedPayloadResult { - let resolved = try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<(sending AsyncImportedPayloadResult) -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - let vCaseId = v.bridgeJSLowerParameter() - bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static(resolveRef, rejectRef, vCaseId) - } - return resolved -} - -func _$AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum(_ 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, vCaseId) = v.bridgeJSLowerParameter() - bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static(resolveRef, rejectRef, vIsSome, vCaseId) - } - return resolved -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureAsyncImports_runJsClosureAsyncTests_static") -fileprivate func bjs_ClosureAsyncImports_runJsClosureAsyncTests_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void -#else -fileprivate func bjs_ClosureAsyncImports_runJsClosureAsyncTests_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureAsyncImports_runJsClosureAsyncTests_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - return bjs_ClosureAsyncImports_runJsClosureAsyncTests_static_extern(resolveRef, rejectRef) -} - -func _$ClosureAsyncImports_runJsClosureAsyncTests() async throws(JSException) -> Void { - try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<() -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - bjs_ClosureAsyncImports_runJsClosureAsyncTests_static(resolveRef, rejectRef) - } -} - #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyVoid_static") fileprivate func bjs_ClosureSupportImports_jsApplyVoid_static_extern(_ callback: Int32) -> Void @@ -14055,25 +13229,6 @@ func _$ClosureSupportImports_runJsClosureSupportTests() throws(JSException) -> V } } -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureThrowsImports_runJsClosureThrowsTests_static") -fileprivate func bjs_ClosureThrowsImports_runJsClosureThrowsTests_static_extern() -> Void -#else -fileprivate func bjs_ClosureThrowsImports_runJsClosureThrowsTests_static_extern() -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_ClosureThrowsImports_runJsClosureThrowsTests_static() -> Void { - return bjs_ClosureThrowsImports_runJsClosureThrowsTests_static_extern() -} - -func _$ClosureThrowsImports_runJsClosureThrowsTests() throws(JSException) -> Void { - bjs_ClosureThrowsImports_runJsClosureThrowsTests_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 @@ -14519,6 +13674,28 @@ func _$runAsyncWorks() async throws(JSException) -> Void { } } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_runAliasAsyncWorks") +fileprivate func bjs_runAliasAsyncWorks_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void +#else +fileprivate func bjs_runAliasAsyncWorks_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_runAliasAsyncWorks(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + return bjs_runAliasAsyncWorks_extern(resolveRef, rejectRef) +} + +func _$runAliasAsyncWorks() async throws(JSException) -> Void { + try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<() -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + bjs_runAliasAsyncWorks(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 @@ -15208,69 +14385,6 @@ func _$Animal_getIsCat(_ self: JSObject) throws(JSException) -> Bool { return Bool.bridgeJSLiftReturn(ret) } -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripLightColor") -fileprivate func bjs_jsRoundTripLightColor_extern(_ value: Int32) -> Int32 -#else -fileprivate func bjs_jsRoundTripLightColor_extern(_ value: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsRoundTripLightColor(_ value: Int32) -> Int32 { - return bjs_jsRoundTripLightColor_extern(value) -} - -func _$jsRoundTripLightColor(_ value: LightColor) throws(JSException) -> LightColor { - let valueValue = value.bridgeJSLowerParameter() - let ret = bjs_jsRoundTripLightColor(valueValue) - if let error = _swift_js_take_exception() { - throw error - } - return LightColor.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripImportedPayloadSignal") -fileprivate func bjs_jsRoundTripImportedPayloadSignal_extern(_ value: Int32) -> Int32 -#else -fileprivate func bjs_jsRoundTripImportedPayloadSignal_extern(_ value: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsRoundTripImportedPayloadSignal(_ value: Int32) -> Int32 { - return bjs_jsRoundTripImportedPayloadSignal_extern(value) -} - -func _$jsRoundTripImportedPayloadSignal(_ value: ImportedPayloadSignal) throws(JSException) -> ImportedPayloadSignal { - let valueCaseId = value.bridgeJSLowerParameter() - let ret = bjs_jsRoundTripImportedPayloadSignal(valueCaseId) - if let error = _swift_js_take_exception() { - throw error - } - return ImportedPayloadSignal.bridgeJSLiftReturn(ret) -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripOptionalImportedPayloadSignal") -fileprivate func bjs_jsRoundTripOptionalImportedPayloadSignal_extern(_ valueIsSome: Int32, _ valueCaseId: Int32) -> Int32 -#else -fileprivate func bjs_jsRoundTripOptionalImportedPayloadSignal_extern(_ valueIsSome: Int32, _ valueCaseId: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsRoundTripOptionalImportedPayloadSignal(_ valueIsSome: Int32, _ valueCaseId: Int32) -> Int32 { - return bjs_jsRoundTripOptionalImportedPayloadSignal_extern(valueIsSome, valueCaseId) -} - -func _$jsRoundTripOptionalImportedPayloadSignal(_ value: Optional) throws(JSException) -> Optional { - let (valueIsSome, valueCaseId) = value.bridgeJSLowerParameter() - let ret = bjs_jsRoundTripOptionalImportedPayloadSignal(valueIsSome, valueCaseId) - if let error = _swift_js_take_exception() { - throw error - } - return Optional.bridgeJSLiftReturn(ret) -} - #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsTranslatePoint") fileprivate func bjs_jsTranslatePoint_extern(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 @@ -15294,27 +14408,6 @@ func _$jsTranslatePoint(_ point: Point, _ dx: Int, _ dy: Int) throws(JSException return Point.bridgeJSLiftReturn(ret) } -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripOptionalPoint") -fileprivate func bjs_jsRoundTripOptionalPoint_extern(_ point: Int32) -> Void -#else -fileprivate func bjs_jsRoundTripOptionalPoint_extern(_ point: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_jsRoundTripOptionalPoint(_ point: Int32) -> Void { - return bjs_jsRoundTripOptionalPoint_extern(point) -} - -func _$jsRoundTripOptionalPoint(_ point: Optional) throws(JSException) -> Optional { - let pointIsSome = point.bridgeJSLowerParameter() - bjs_jsRoundTripOptionalPoint(pointIsSome) - if let error = _swift_js_take_exception() { - throw error - } - return Optional.bridgeJSLiftReturn() -} - #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt_static") fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt_static_extern(_ v: Int32) -> Int32 @@ -16112,18 +15205,6 @@ fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDic return bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static_extern(v) } -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static") -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void -#else -fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { - return bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static_extern(valueIsSome, valueValue) -} - #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_runJsOptionalSupportTests_static") fileprivate func bjs_OptionalSupportImports_runJsOptionalSupportTests_static_extern() -> Void @@ -16210,15 +15291,6 @@ func _$OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefin return JSUndefinedOr<[String: String]>.bridgeJSLiftReturn() } -func _$OptionalSupportImports_jsRoundTripOptionalJSObjectNull(_ value: Optional) throws(JSException) -> Optional { - let (valueIsSome, valueValue) = value.bridgeJSLowerParameter() - bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static(valueIsSome, valueValue) - if let error = _swift_js_take_exception() { - throw error - } - return Optional.bridgeJSLiftReturn() -} - func _$OptionalSupportImports_runJsOptionalSupportTests() throws(JSException) -> Void { bjs_OptionalSupportImports_runJsOptionalSupportTests_static() if let error = _swift_js_take_exception() { diff --git a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json index 297ab5a07..fb6286e97 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json @@ -1,6 +1,559 @@ { "exported" : { + "aliases" : [ + { + "swiftCallName" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + }, + { + "swiftCallName" : "Tag", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TagReference" + } + } + }, + { + "swiftCallName" : "Token", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TokenReference" + } + } + }, + { + "swiftCallName" : "TagHolder", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TagHolderReference" + } + } + }, + { + "swiftCallName" : "Coordinate", + "underlying" : { + "swiftStruct" : { + "_0" : "JSCoordinate" + } + } + }, + { + "swiftCallName" : "Priority", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PriorityReference" + } + } + }, + { + "swiftCallName" : "Alert", + "underlying" : { + "caseEnum" : { + "_0" : "Severity" + } + } + }, + { + "swiftCallName" : "Session", + "underlying" : { + "swiftStruct" : { + "_0" : "SessionState" + } + } + }, + { + "swiftCallName" : "Tagged", + "underlying" : { + "string" : { + + } + } + }, + { + "swiftCallName" : "Canvas", + "underlying" : { + "jsObject" : { + "_0" : "Surface" + } + } + }, + { + "swiftCallName" : "AliasedTag", + "underlying" : { + "associatedValueEnum" : { + "_0" : "InnerTag" + } + } + } + ], "classes" : [ + { + "constructor" : { + "abiName" : "bjs_PolygonReference_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "verticesData", + "name" : "verticesData", + "type" : { + "array" : { + "_0" : { + "double" : { + + } + } + } + } + }, + { + "label" : "label", + "name" : "label", + "type" : { + "string" : { + + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_PolygonReference_vertexCount", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "vertexCount", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_PolygonReference_summary", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "summary", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_PolygonReference_snapshot", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "snapshot", + "parameters" : [ + + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + }, + { + "abiName" : "bjs_PolygonReference_merge", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "merge", + "parameters" : [ + { + "label" : "_", + "name" : "other", + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + }, + { + "abiName" : "bjs_PolygonReference_static_origin", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "origin", + "parameters" : [ + { + "label" : "label", + "name" : "label", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + }, + "staticContext" : { + "className" : { + "_0" : "PolygonReference" + } + } + } + ], + "name" : "PolygonReference", + "properties" : [ + + ], + "swiftCallName" : "PolygonReference" + }, + { + "methods" : [ + { + "abiName" : "bjs_TagReference_describe", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "describe", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "TagReference", + "properties" : [ + + ], + "swiftCallName" : "TagReference" + }, + { + "constructor" : { + "abiName" : "bjs_TokenReference_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "value", + "name" : "value", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_TokenReference_read", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "read", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "TokenReference", + "properties" : [ + + ], + "swiftCallName" : "TokenReference" + }, + { + "constructor" : { + "abiName" : "bjs_TagHolderReference_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "tag", + "name" : "tag", + "type" : { + "alias" : { + "name" : "Tag", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TagReference" + } + } + } + } + }, + { + "label" : "version", + "name" : "version", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_TagHolderReference_describe", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "describe", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "TagHolderReference", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "tag", + "type" : { + "alias" : { + "name" : "Tag", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TagReference" + } + } + } + } + }, + { + "isReadonly" : false, + "isStatic" : false, + "name" : "version", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "TagHolderReference" + }, + { + "methods" : [ + { + "abiName" : "bjs_PriorityReference_describe", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "describe", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_PriorityReference_weight", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "weight", + "parameters" : [ + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "abiName" : "bjs_PriorityReference_static_low", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "low", + "parameters" : [ + + ], + "returnType" : { + "alias" : { + "name" : "Priority", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PriorityReference" + } + } + } + }, + "staticContext" : { + "className" : { + "_0" : "PriorityReference" + } + } + }, + { + "abiName" : "bjs_PriorityReference_static_medium", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "medium", + "parameters" : [ + + ], + "returnType" : { + "alias" : { + "name" : "Priority", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PriorityReference" + } + } + } + }, + "staticContext" : { + "className" : { + "_0" : "PriorityReference" + } + } + }, + { + "abiName" : "bjs_PriorityReference_static_high", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "high", + "parameters" : [ + + ], + "returnType" : { + "alias" : { + "name" : "Priority", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PriorityReference" + } + } + } + }, + "staticContext" : { + "className" : { + "_0" : "PriorityReference" + } + } + } + ], + "name" : "PriorityReference", + "properties" : [ + + ], + "swiftCallName" : "PriorityReference" + }, { "methods" : [ { @@ -908,46 +1461,6 @@ } } } - }, - { - "abiName" : "bjs_Calculator_asyncMakePoint", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncMakePoint", - "parameters" : [ - { - "label" : "x", - "name" : "x", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "y", - "name" : "y", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - } } ], "name" : "Calculator", @@ -4423,32 +4936,136 @@ } } ], - "swiftCallName" : "Container" + "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" : [ + { + "associatedValues" : [ + + ], + "name" : "notice" + }, + { + "associatedValues" : [ + + ], + "name" : "warning" + }, + { + "associatedValues" : [ + + ], + "name" : "error" + } + ], + "emitStyle" : "const", + "name" : "Severity", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Severity", + "tsFullPath" : "Severity" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + } + ], + "name" : "polygon" + }, + { + "associatedValues" : [ + + ], + "name" : "empty" + } + ], + "emitStyle" : "const", + "name" : "Shape", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Shape", + "tsFullPath" : "Shape" }, { - "constructor" : { - "abiName" : "bjs_LeakCheck_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "payload" }, - "parameters" : [ + { + "associatedValues" : [ - ] - }, - "explicitAccessControl" : "public", - "methods" : [ + ], + "name" : "empty" + } + ], + "emitStyle" : "const", + "name" : "InnerTag", + "staticMethods" : [ ], - "name" : "LeakCheck", - "properties" : [ + "staticProperties" : [ ], - "swiftCallName" : "LeakCheck" - } - ], - "enums" : [ + "swiftCallName" : "InnerTag", + "tsFullPath" : "InnerTag" + }, { "cases" : [ @@ -6550,53 +7167,6 @@ "swiftCallName" : "ArraySupportExports", "tsFullPath" : "ArraySupportExports" }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "name" : "failure" - }, - { - "associatedValues" : [ - - ], - "name" : "idle" - } - ], - "emitStyle" : "const", - "name" : "AsyncImportedPayloadResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "AsyncImportedPayloadResult", - "tsFullPath" : "AsyncImportedPayloadResult" - }, { "cases" : [ @@ -7762,53 +8332,6 @@ "swiftCallName" : "TSTheme", "tsFullPath" : "TSTheme" }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "success" - }, - { - "associatedValues" : [ - { - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "name" : "failure" - }, - { - "associatedValues" : [ - - ], - "name" : "idle" - } - ], - "emitStyle" : "const", - "name" : "AsyncPayloadResult", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "AsyncPayloadResult", - "tsFullPath" : "AsyncPayloadResult" - }, { "cases" : [ @@ -9388,85 +9911,6 @@ "swiftCallName" : "NestedStructGroupB", "tsFullPath" : "NestedStructGroupB" }, - { - "cases" : [ - { - "associatedValues" : [ - - ], - "name" : "red" - }, - { - "associatedValues" : [ - - ], - "name" : "yellow" - }, - { - "associatedValues" : [ - - ], - "name" : "green" - } - ], - "emitStyle" : "const", - "name" : "LightColor", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "LightColor", - "tsFullPath" : "LightColor" - }, - { - "cases" : [ - { - "associatedValues" : [ - { - "type" : { - "string" : { - - } - } - } - ], - "name" : "start" - }, - { - "associatedValues" : [ - { - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "name" : "stop" - }, - { - "associatedValues" : [ - - ], - "name" : "idle" - } - ], - "emitStyle" : "const", - "name" : "ImportedPayloadSignal", - "staticMethods" : [ - - ], - "staticProperties" : [ - - ], - "swiftCallName" : "ImportedPayloadSignal", - "tsFullPath" : "ImportedPayloadSignal" - }, { "cases" : [ @@ -11605,1074 +12049,1166 @@ "exposeToGlobal" : false, "functions" : [ { - "abiName" : "bjs_awaitAsyncCallback", + "abiName" : "bjs_makeTag", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "awaitAsyncCallback", + "name" : "makeTag", "parameters" : [ { "label" : "_", - "name" : "fetch", + "name" : "name", "type" : { - "closure" : { - "_0" : { - "isAsync" : true, - "isThrows" : true, - "mangleName" : "20BridgeJSRuntimeTestsYaKSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "string" : { + "string" : { - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false } } } ], "returnType" : { - "string" : { - + "alias" : { + "name" : "Tag", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TagReference" + } + } } } }, { - "abiName" : "bjs_makeAsyncParser", + "abiName" : "bjs_roundTripPolygon", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "makeAsyncParser", + "name" : "roundTripPolygon", "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : true, - "isThrows" : true, - "mangleName" : "20BridgeJSRuntimeTestsYaKSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - + { + "label" : "_", + "name" : "polygon", + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" } } - ], - "returnType" : { - "string" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } } } }, { - "abiName" : "bjs_makeAsyncEcho", + "abiName" : "bjs_appendVertex", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "makeAsyncEcho", + "name" : "appendVertex", "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : true, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsYaSS_SS", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - + { + "label" : "_", + "name" : "polygon", + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" } } - ], - "returnType" : { - "string" : { + } + } + }, + { + "label" : "_", + "name" : "value", + "type" : { + "double" : { - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } } } }, { - "abiName" : "bjs_makeAsyncRecorder", + "abiName" : "bjs_optionalRoundTripPolygon", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "makeAsyncRecorder", + "name" : "optionalRoundTripPolygon", "parameters" : [ - + { + "label" : "_", + "name" : "polygon", + "type" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + }, + "_1" : "null" + } + } + } ], "returnType" : { - "closure" : { + "nullable" : { "_0" : { - "isAsync" : true, - "isThrows" : true, - "mangleName" : "20BridgeJSRuntimeTestsYaKSS_y", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" } } - ], - "returnType" : { - "void" : { - - } - }, - "sendingParameters" : false + } }, - "useJSTypedClosure" : true + "_1" : "null" } } }, { - "abiName" : "bjs_lastRecordedValue", + "abiName" : "bjs_polygonVertexCount", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "lastRecordedValue", + "name" : "polygonVertexCount", "parameters" : [ - + { + "label" : "_", + "name" : "polygon", + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + } ], "returnType" : { - "string" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_makeAsyncPayloadLoader", + "abiName" : "bjs_roundTripPolygonArray", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "makeAsyncPayloadLoader", + "name" : "roundTripPolygonArray", "parameters" : [ - + { + "label" : "_", + "name" : "polygons", + "type" : { + "array" : { + "_0" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + } + } + } ], "returnType" : { - "closure" : { + "array" : { "_0" : { - "isAsync" : true, - "isThrows" : true, - "mangleName" : "20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "bool" : { - + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" } } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "AsyncPayloadResult" - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + } + } } } }, { - "abiName" : "bjs_awaitPayloadCallback", + "abiName" : "bjs_concatPolygons", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "awaitPayloadCallback", + "name" : "concatPolygons", "parameters" : [ { "label" : "_", - "name" : "load", + "name" : "polygons", "type" : { - "closure" : { + "array" : { "_0" : { - "isAsync" : true, - "isThrows" : true, - "mangleName" : "20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "bool" : { - + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" } } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "AsyncPayloadResult" - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false + } + } } } } ], "returnType" : { - "string" : { - + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } } } }, { - "abiName" : "bjs_makeAsyncPointMaker", + "abiName" : "bjs_validatePolygon", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "makeAsyncPointMaker", + "name" : "validatePolygon", "parameters" : [ - - ], - "returnType" : { - "closure" : { - "_0" : { - "isAsync" : true, - "isThrows" : false, - "mangleName" : "20BridgeJSRuntimeTestsYaSd_9DataPointV", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "double" : { - + { + "label" : "_", + "name" : "polygon", + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" } } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "DataPoint" - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + } + } } - } - }, - { - "abiName" : "bjs_makeThrowingParser", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeThrowingParser", - "parameters" : [ - ], "returnType" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : true, - "mangleName" : "20BridgeJSRuntimeTestsKSS_Si", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : true + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } } } }, { - "abiName" : "bjs_runValidator", + "abiName" : "bjs_splitPolygon", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "runValidator", + "name" : "splitPolygon", "parameters" : [ { "label" : "_", - "name" : "validate", + "name" : "polygon", "type" : { - "closure" : { - "_0" : { - "isAsync" : false, - "isThrows" : true, - "mangleName" : "20BridgeJSRuntimeTestsKSS_Sb", - "moduleName" : "BridgeJSRuntimeTests", - "parameters" : [ - { - "string" : { - - } - } - ], - "returnType" : { - "bool" : { - - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } } } } ], "returnType" : { - "bool" : { - + "array" : { + "_0" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } } } }, { - "abiName" : "bjs_roundTripVoid", + "abiName" : "bjs_incrementToken", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripVoid", + "name" : "incrementToken", "parameters" : [ - + { + "label" : "_", + "name" : "token", + "type" : { + "alias" : { + "name" : "Token", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TokenReference" + } + } + } + } + } ], "returnType" : { - "void" : { - + "alias" : { + "name" : "Token", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TokenReference" + } + } } } }, { - "abiName" : "bjs_roundTripFloat", + "abiName" : "bjs_makeToken", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripFloat", + "name" : "makeToken", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "value", "type" : { - "float" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "float" : { - + "alias" : { + "name" : "Token", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TokenReference" + } + } } } }, { - "abiName" : "bjs_roundTripDouble", + "abiName" : "bjs_makePolygonInspector", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripDouble", + "name" : "makePolygonInspector", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "double" : { - } - } - } ], "returnType" : { - "double" : { - + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsAl7Polygon_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false } } }, { - "abiName" : "bjs_roundTripBool", + "abiName" : "bjs_asyncMakePolygon", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripBool", + "name" : "asyncMakePolygon", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "label", "type" : { - "bool" : { + "string" : { } } } ], "returnType" : { - "bool" : { - + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } } } }, { - "abiName" : "bjs_roundTripString", + "abiName" : "bjs_roundTripOptionalPolygonArray", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripString", + "name" : "roundTripOptionalPolygonArray", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "polygons", "type" : { - "string" : { - + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + }, + "_1" : "null" + } + } } } } ], "returnType" : { - "string" : { - + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } + }, + "_1" : "null" + } + } } } }, { - "abiName" : "bjs_roundTripSwiftHeapObject", + "abiName" : "bjs_makeTagHolder", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripSwiftHeapObject", + "name" : "makeTagHolder", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "name", "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "string" : { + + } + } + }, + { + "label" : "_", + "name" : "version", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "alias" : { + "name" : "TagHolder", + "underlying" : { + "swiftHeapObject" : { + "_0" : "TagHolderReference" + } + } } } }, { - "abiName" : "bjs_roundTripUnsafeRawPointer", + "abiName" : "bjs_roundTripCoordinate", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripUnsafeRawPointer", + "name" : "roundTripCoordinate", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "coordinate", "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeRawPointer" + "alias" : { + "name" : "Coordinate", + "underlying" : { + "swiftStruct" : { + "_0" : "JSCoordinate" + } } } } } ], "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeRawPointer" + "alias" : { + "name" : "Coordinate", + "underlying" : { + "swiftStruct" : { + "_0" : "JSCoordinate" + } } } } }, { - "abiName" : "bjs_roundTripUnsafeMutableRawPointer", + "abiName" : "bjs_roundTripPriority", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripUnsafeMutableRawPointer", + "name" : "roundTripPriority", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "priority", "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutableRawPointer" + "alias" : { + "name" : "Priority", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PriorityReference" + } } } } } ], "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutableRawPointer" + "alias" : { + "name" : "Priority", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PriorityReference" + } } } } }, { - "abiName" : "bjs_roundTripOpaquePointer", + "abiName" : "bjs_roundTripAlert", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripOpaquePointer", + "name" : "roundTripAlert", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "alert", "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" + "alias" : { + "name" : "Alert", + "underlying" : { + "caseEnum" : { + "_0" : "Severity" + } } } } } ], "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" + "alias" : { + "name" : "Alert", + "underlying" : { + "caseEnum" : { + "_0" : "Severity" + } } } } }, { - "abiName" : "bjs_roundTripUnsafePointer", + "abiName" : "bjs_makeAlert", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripUnsafePointer", + "name" : "makeAlert", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "level", "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" - } + "caseEnum" : { + "_0" : "Severity" } } } ], "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" + "alias" : { + "name" : "Alert", + "underlying" : { + "caseEnum" : { + "_0" : "Severity" + } } } } }, { - "abiName" : "bjs_roundTripUnsafeMutablePointer", + "abiName" : "bjs_roundTripSession", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripUnsafeMutablePointer", + "name" : "roundTripSession", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "session", "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" + "alias" : { + "name" : "Session", + "underlying" : { + "swiftStruct" : { + "_0" : "SessionState" + } } } } } ], "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" + "alias" : { + "name" : "Session", + "underlying" : { + "swiftStruct" : { + "_0" : "SessionState" + } } } } }, { - "abiName" : "bjs_roundTripJSObject", + "abiName" : "bjs_makeSession", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripJSObject", + "name" : "makeSession", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "token", "type" : { - "jsObject" : { + "string" : { } } } ], "returnType" : { - "jsObject" : { - + "alias" : { + "name" : "Session", + "underlying" : { + "swiftStruct" : { + "_0" : "SessionState" + } + } } } }, { - "abiName" : "bjs_roundTripDictionaryExport", + "abiName" : "bjs_roundTripShape", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripDictionaryExport", + "name" : "roundTripShape", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "s", "type" : { - "dictionary" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } + "associatedValueEnum" : { + "_0" : "Shape" } } } ], - "returnType" : { - "dictionary" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } + "returnType" : { + "associatedValueEnum" : { + "_0" : "Shape" } } }, { - "abiName" : "bjs_roundTripOptionalDictionaryExport", + "abiName" : "bjs_makeShapePolygon", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripOptionalDictionaryExport", + "name" : "makeShapePolygon", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "polygon", "type" : { - "nullable" : { - "_0" : { - "dictionary" : { - "_0" : { - "string" : { - - } - } + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" } - }, - "_1" : "null" + } } } } ], "returnType" : { - "nullable" : { - "_0" : { - "dictionary" : { - "_0" : { - "string" : { - - } - } - } - }, - "_1" : "null" + "associatedValueEnum" : { + "_0" : "Shape" } } }, { - "abiName" : "bjs_roundTripJSValue", + "abiName" : "bjs_makeShapeEmpty", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripJSValue", + "name" : "makeShapeEmpty", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "jsValue" : { - } - } - } ], "returnType" : { - "jsValue" : { - + "associatedValueEnum" : { + "_0" : "Shape" } } }, { - "abiName" : "bjs_roundTripOptionalJSValue", + "abiName" : "bjs_roundTripVoid", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripOptionalJSValue", + "name" : "roundTripVoid", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "jsValue" : { - } - }, - "_1" : "null" - } - } - } ], "returnType" : { - "nullable" : { - "_0" : { - "jsValue" : { + "void" : { - } - }, - "_1" : "null" } } }, { - "abiName" : "bjs_roundTripOptionalJSValueArray", + "abiName" : "bjs_roundTripFloat", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripOptionalJSValueArray", + "name" : "roundTripFloat", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "jsValue" : { + "float" : { - } - } - } - }, - "_1" : "null" } } } ], "returnType" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "jsValue" : { + "float" : { - } - } - } - }, - "_1" : "null" } } }, { - "abiName" : "bjs_makeImportedFoo", + "abiName" : "bjs_roundTripDouble", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "makeImportedFoo", + "name" : "roundTripDouble", "parameters" : [ { - "label" : "value", - "name" : "value", + "label" : "v", + "name" : "v", "type" : { - "string" : { + "double" : { } } } ], "returnType" : { - "jsObject" : { - "_0" : "Foo" + "double" : { + } } }, { - "abiName" : "bjs_roundTripOptionalImportedClass", + "abiName" : "bjs_roundTripBool", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripOptionalImportedClass", + "name" : "roundTripBool", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "nullable" : { - "_0" : { - "jsObject" : { - "_0" : "Foo" - } - }, - "_1" : "null" + "bool" : { + } } } ], "returnType" : { - "nullable" : { - "_0" : { - "jsObject" : { - "_0" : "Foo" - } - }, - "_1" : "null" + "bool" : { + } } }, { - "abiName" : "bjs_throwsSwiftError", + "abiName" : "bjs_roundTripString", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsSwiftError", + "name" : "roundTripString", "parameters" : [ { - "label" : "shouldThrow", - "name" : "shouldThrow", + "label" : "v", + "name" : "v", "type" : { - "bool" : { + "string" : { } } } ], "returnType" : { - "void" : { + "string" : { } } }, { - "abiName" : "bjs_throwsWithIntResult", + "abiName" : "bjs_roundTripSwiftHeapObject", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithIntResult", + "name" : "roundTripSwiftHeapObject", "parameters" : [ - + { + "label" : "v", + "name" : "v", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } ], "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "swiftHeapObject" : { + "_0" : "Greeter" } } }, { - "abiName" : "bjs_throwsWithStringResult", + "abiName" : "bjs_roundTripUnsafeRawPointer", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithStringResult", + "name" : "roundTripUnsafeRawPointer", "parameters" : [ - + { + "label" : "v", + "name" : "v", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeRawPointer" + } + } + } + } ], "returnType" : { - "string" : { - + "unsafePointer" : { + "_0" : { + "kind" : "unsafeRawPointer" + } } } }, { - "abiName" : "bjs_throwsWithBoolResult", + "abiName" : "bjs_roundTripUnsafeMutableRawPointer", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithBoolResult", + "name" : "roundTripUnsafeMutableRawPointer", "parameters" : [ - + { + "label" : "v", + "name" : "v", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutableRawPointer" + } + } + } + } ], "returnType" : { - "bool" : { - + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutableRawPointer" + } } } }, { - "abiName" : "bjs_throwsWithFloatResult", + "abiName" : "bjs_roundTripOpaquePointer", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithFloatResult", + "name" : "roundTripOpaquePointer", "parameters" : [ - + { + "label" : "v", + "name" : "v", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "opaquePointer" + } + } + } + } ], "returnType" : { - "float" : { - + "unsafePointer" : { + "_0" : { + "kind" : "opaquePointer" + } } } }, { - "abiName" : "bjs_throwsWithDoubleResult", + "abiName" : "bjs_roundTripUnsafePointer", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithDoubleResult", + "name" : "roundTripUnsafePointer", "parameters" : [ - + { + "label" : "v", + "name" : "v", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafePointer", + "pointee" : "UInt8" + } + } + } + } ], "returnType" : { - "double" : { - + "unsafePointer" : { + "_0" : { + "kind" : "unsafePointer", + "pointee" : "UInt8" + } } } }, { - "abiName" : "bjs_throwsWithSwiftHeapObjectResult", + "abiName" : "bjs_roundTripUnsafeMutablePointer", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithSwiftHeapObjectResult", + "name" : "roundTripUnsafeMutablePointer", "parameters" : [ - + { + "label" : "v", + "name" : "v", + "type" : { + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutablePointer", + "pointee" : "UInt8" + } + } + } + } ], "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "unsafePointer" : { + "_0" : { + "kind" : "unsafeMutablePointer", + "pointee" : "UInt8" + } } } }, { - "abiName" : "bjs_throwsWithJSObjectResult", + "abiName" : "bjs_roundTripJSObject", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithJSObjectResult", + "name" : "roundTripJSObject", "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "jsObject" : { + } + } + } ], "returnType" : { "jsObject" : { @@ -12681,331 +13217,353 @@ } }, { - "abiName" : "bjs_zeroArgAsyncThrows", + "abiName" : "bjs_roundTripDictionaryExport", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "zeroArgAsyncThrows", + "name" : "roundTripDictionaryExport", "parameters" : [ - + { + "label" : "v", + "name" : "v", + "type" : { + "dictionary" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } ], "returnType" : { - "string" : { - + "dictionary" : { + "_0" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } } } }, { - "abiName" : "bjs_asyncRoundTripVoid", + "abiName" : "bjs_roundTripOptionalDictionaryExport", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripVoid", + "name" : "roundTripOptionalDictionaryExport", "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "dictionary" : { + "_0" : { + "string" : { + } + } + } + }, + "_1" : "null" + } + } + } ], "returnType" : { - "void" : { + "nullable" : { + "_0" : { + "dictionary" : { + "_0" : { + "string" : { + } + } + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_asyncRoundTripInt", + "abiName" : "bjs_roundTripJSValue", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripInt", + "name" : "roundTripJSValue", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "jsValue" : { + } } } ], "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "jsValue" : { + } } }, { - "abiName" : "bjs_asyncRoundTripFloat", + "abiName" : "bjs_roundTripOptionalJSValue", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripFloat", + "name" : "roundTripOptionalJSValue", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "float" : { + "nullable" : { + "_0" : { + "jsValue" : { + } + }, + "_1" : "null" } } } ], "returnType" : { - "float" : { + "nullable" : { + "_0" : { + "jsValue" : { + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_asyncRoundTripDouble", + "abiName" : "bjs_roundTripOptionalJSValueArray", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripDouble", + "name" : "roundTripOptionalJSValueArray", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "double" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsValue" : { + } + } + } + }, + "_1" : "null" } } } ], "returnType" : { - "double" : { + "nullable" : { + "_0" : { + "array" : { + "_0" : { + "jsValue" : { + } + } + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_asyncRoundTripBool", + "abiName" : "bjs_makeImportedFoo", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "asyncRoundTripBool", + "name" : "makeImportedFoo", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "value", + "name" : "value", "type" : { - "bool" : { + "string" : { } } } ], "returnType" : { - "bool" : { - + "jsObject" : { + "_0" : "Foo" } } }, { - "abiName" : "bjs_asyncRoundTripString", + "abiName" : "bjs_throwsSwiftError", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "asyncRoundTripString", + "name" : "throwsSwiftError", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "shouldThrow", + "name" : "shouldThrow", "type" : { - "string" : { + "bool" : { } } } ], "returnType" : { - "string" : { + "void" : { } } }, { - "abiName" : "bjs_asyncRoundTripSwiftHeapObject", + "abiName" : "bjs_throwsWithIntResult", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "asyncRoundTripSwiftHeapObject", + "name" : "throwsWithIntResult", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } + + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" } } + } + }, + { + "abiName" : "bjs_throwsWithStringResult", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsWithStringResult", + "parameters" : [ + ], "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "string" : { + } } }, { - "abiName" : "bjs_asyncRoundTripJSObject", + "abiName" : "bjs_throwsWithBoolResult", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "asyncRoundTripJSObject", + "name" : "throwsWithBoolResult", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "jsObject" : { - } - } - } ], "returnType" : { - "jsObject" : { + "bool" : { } } }, { - "abiName" : "bjs_takeGreeter", + "abiName" : "bjs_throwsWithFloatResult", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "takeGreeter", + "name" : "throwsWithFloatResult", "parameters" : [ - { - "label" : "g", - "name" : "g", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "label" : "name", - "name" : "name", - "type" : { - "string" : { - } - } - } ], "returnType" : { - "void" : { + "float" : { } } }, { - "abiName" : "bjs_createCalculator", + "abiName" : "bjs_throwsWithDoubleResult", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "createCalculator", + "name" : "throwsWithDoubleResult", "parameters" : [ ], "returnType" : { - "swiftHeapObject" : { - "_0" : "Calculator" + "double" : { + } } }, { - "abiName" : "bjs_useCalculator", + "abiName" : "bjs_throwsWithSwiftHeapObjectResult", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "useCalculator", + "name" : "throwsWithSwiftHeapObjectResult", "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" - } + "swiftHeapObject" : { + "_0" : "Greeter" } } }, { - "abiName" : "bjs_testGreeterToJSValue", + "abiName" : "bjs_throwsWithJSObjectResult", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "testGreeterToJSValue", + "name" : "throwsWithJSObjectResult", "parameters" : [ ], @@ -13016,540 +13574,474 @@ } }, { - "abiName" : "bjs_testCalculatorToJSValue", + "abiName" : "bjs_asyncRoundTripVoid", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "testCalculatorToJSValue", + "name" : "asyncRoundTripVoid", "parameters" : [ ], "returnType" : { - "jsObject" : { + "void" : { } } }, { - "abiName" : "bjs_testSwiftClassAsJSValue", + "abiName" : "bjs_asyncRoundTripInt", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "testSwiftClassAsJSValue", + "name" : "asyncRoundTripInt", "parameters" : [ { - "label" : "greeter", - "name" : "greeter", + "label" : "v", + "name" : "v", "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "jsObject" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_setDirection", + "abiName" : "bjs_asyncRoundTripFloat", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "setDirection", + "name" : "asyncRoundTripFloat", "parameters" : [ { - "label" : "_", - "name" : "direction", + "label" : "v", + "name" : "v", "type" : { - "caseEnum" : { - "_0" : "Direction" + "float" : { + } } } ], "returnType" : { - "caseEnum" : { - "_0" : "Direction" + "float" : { + } } }, { - "abiName" : "bjs_getDirection", + "abiName" : "bjs_asyncRoundTripDouble", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "getDirection", + "name" : "asyncRoundTripDouble", "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "double" : { + } + } + } ], "returnType" : { - "caseEnum" : { - "_0" : "Direction" + "double" : { + } } }, { - "abiName" : "bjs_processDirection", + "abiName" : "bjs_asyncRoundTripBool", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "processDirection", + "name" : "asyncRoundTripBool", "parameters" : [ { - "label" : "_", - "name" : "input", + "label" : "v", + "name" : "v", "type" : { - "caseEnum" : { - "_0" : "Direction" + "bool" : { + } } } ], "returnType" : { - "caseEnum" : { - "_0" : "Status" + "bool" : { + } } }, { - "abiName" : "bjs_setTheme", + "abiName" : "bjs_asyncRoundTripString", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "setTheme", + "name" : "asyncRoundTripString", "parameters" : [ { - "label" : "_", - "name" : "theme", + "label" : "v", + "name" : "v", "type" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" + "string" : { + } } } ], "returnType" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" + "string" : { + } } }, { - "abiName" : "bjs_getTheme", + "abiName" : "bjs_asyncRoundTripSwiftHeapObject", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "getTheme", + "name" : "asyncRoundTripSwiftHeapObject", "parameters" : [ - + { + "label" : "v", + "name" : "v", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } ], "returnType" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" + "swiftHeapObject" : { + "_0" : "Greeter" } } }, { - "abiName" : "bjs_asyncRoundTripTheme", + "abiName" : "bjs_asyncRoundTripJSObject", "effects" : { "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripTheme", + "name" : "asyncRoundTripJSObject", "parameters" : [ { - "label" : "_", + "label" : "v", "name" : "v", "type" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" + "jsObject" : { + } } } ], "returnType" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" + "jsObject" : { + } } }, { - "abiName" : "bjs_asyncRoundTripDirection", + "abiName" : "bjs_takeGreeter", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripDirection", + "name" : "takeGreeter", "parameters" : [ { - "label" : "_", - "name" : "v", + "label" : "g", + "name" : "g", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "label" : "name", + "name" : "name", "type" : { - "caseEnum" : { - "_0" : "Direction" + "string" : { + } } } ], "returnType" : { - "caseEnum" : { - "_0" : "Direction" + "void" : { + } } }, { - "abiName" : "bjs_asyncRoundTripOptionalTheme", + "abiName" : "bjs_createCalculator", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripOptionalTheme", + "name" : "createCalculator", "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" - } - } - } + ], "returnType" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - }, - "_1" : "null" + "swiftHeapObject" : { + "_0" : "Calculator" } } }, { - "abiName" : "bjs_asyncRoundTripOptionalDirection", + "abiName" : "bjs_useCalculator", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripOptionalDirection", + "name" : "useCalculator", "parameters" : [ { - "label" : "_", - "name" : "v", + "label" : "calc", + "name" : "calc", "type" : { - "nullable" : { + "swiftHeapObject" : { + "_0" : "Calculator" + } + } + }, + { + "label" : "x", + "name" : "x", + "type" : { + "integer" : { "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "y", + "name" : "y", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "nullable" : { + "integer" : { "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - }, - "_1" : "null" + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_asyncRoundTripDirectionArray", + "abiName" : "bjs_testGreeterToJSValue", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripDirectionArray", + "name" : "testGreeterToJSValue", "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "array" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - } + ], "returnType" : { - "array" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } + "jsObject" : { + } } }, { - "abiName" : "bjs_asyncRoundTripDirectionDict", + "abiName" : "bjs_testCalculatorToJSValue", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripDirectionDict", + "name" : "testCalculatorToJSValue", "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "dictionary" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } - } - } - } + ], "returnType" : { - "dictionary" : { - "_0" : { - "caseEnum" : { - "_0" : "Direction" - } - } + "jsObject" : { + } } }, { - "abiName" : "bjs_asyncRoundTripThemeArray", + "abiName" : "bjs_testSwiftClassAsJSValue", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripThemeArray", + "name" : "testSwiftClassAsJSValue", "parameters" : [ { - "label" : "_", - "name" : "v", + "label" : "greeter", + "name" : "greeter", "type" : { - "array" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } + "swiftHeapObject" : { + "_0" : "Greeter" } } } ], "returnType" : { - "array" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } + "jsObject" : { + } } }, { - "abiName" : "bjs_asyncRoundTripThemeDict", + "abiName" : "bjs_setDirection", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripThemeDict", + "name" : "setDirection", "parameters" : [ { "label" : "_", - "name" : "v", + "name" : "direction", "type" : { - "dictionary" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } + "caseEnum" : { + "_0" : "Direction" } } } ], "returnType" : { - "dictionary" : { - "_0" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" - } - } + "caseEnum" : { + "_0" : "Direction" } } }, { - "abiName" : "bjs_asyncRoundTripFileSize", + "abiName" : "bjs_getDirection", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripFileSize", + "name" : "getDirection", "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - } - } + ], "returnType" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" + "caseEnum" : { + "_0" : "Direction" } } }, { - "abiName" : "bjs_asyncRoundTripOptionalFileSize", + "abiName" : "bjs_processDirection", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripOptionalFileSize", + "name" : "processDirection", "parameters" : [ { "label" : "_", - "name" : "v", + "name" : "input", "type" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - }, - "_1" : "null" + "caseEnum" : { + "_0" : "Direction" } } } ], "returnType" : { - "nullable" : { - "_0" : { - "rawValueEnum" : { - "_0" : "FileSize", - "_1" : "Int64" - } - }, - "_1" : "null" + "caseEnum" : { + "_0" : "Status" } } }, { - "abiName" : "bjs_asyncRoundTripAssociatedValueEnum", + "abiName" : "bjs_setTheme", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripAssociatedValueEnum", + "name" : "setTheme", "parameters" : [ { "label" : "_", - "name" : "v", + "name" : "theme", "type" : { - "associatedValueEnum" : { - "_0" : "AsyncPayloadResult" + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" } } } ], "returnType" : { - "associatedValueEnum" : { - "_0" : "AsyncPayloadResult" + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" } } }, { - "abiName" : "bjs_asyncRoundTripOptionalAssociatedValueEnum", + "abiName" : "bjs_getTheme", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripOptionalAssociatedValueEnum", + "name" : "getTheme", "parameters" : [ - { - "label" : "_", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "AsyncPayloadResult" - } - }, - "_1" : "null" - } - } - } + ], "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "AsyncPayloadResult" - } - }, - "_1" : "null" + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" } } }, @@ -15138,445 +15630,210 @@ "integer" : { "_0" : { "isSigned" : true, - "width" : "word" - } - } - }, - "sendingParameters" : false - }, - "useJSTypedClosure" : false - } - } - }, - { - "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_asyncRoundTripPublicPoint", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripPublicPoint", - "parameters" : [ - { - "label" : "_", - "name" : "point", - "type" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - } - } - ], - "returnType" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false } } }, { - "abiName" : "bjs_asyncRoundTripPublicPointThrows", + "abiName" : "bjs_roundTripPointerFields", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "asyncRoundTripPublicPointThrows", + "name" : "roundTripPointerFields", "parameters" : [ { "label" : "_", - "name" : "point", + "name" : "value", "type" : { "swiftStruct" : { - "_0" : "PublicPoint" + "_0" : "PointerFields" } } } ], "returnType" : { "swiftStruct" : { - "_0" : "PublicPoint" + "_0" : "PointerFields" } } }, { - "abiName" : "bjs_asyncStructOrThrow", + "abiName" : "bjs_testStructDefault", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "asyncStructOrThrow", + "name" : "testStructDefault", "parameters" : [ { - "label" : "_", - "name" : "shouldThrow", - "type" : { - "bool" : { + "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" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "string" : { + } } }, { - "abiName" : "bjs_asyncCombinePublicPoints", + "abiName" : "bjs_cartToJSObject", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncCombinePublicPoints", + "name" : "cartToJSObject", "parameters" : [ { "label" : "_", - "name" : "a", - "type" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - } - }, - { - "label" : "_", - "name" : "b", + "name" : "cart", "type" : { "swiftStruct" : { - "_0" : "PublicPoint" + "_0" : "CopyableCart" } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "jsObject" : { + } } }, { - "abiName" : "bjs_asyncRoundTripContact", + "abiName" : "bjs_nestedCartToJSObject", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripContact", + "name" : "nestedCartToJSObject", "parameters" : [ { "label" : "_", - "name" : "contact", + "name" : "cart", "type" : { "swiftStruct" : { - "_0" : "Contact" + "_0" : "CopyableNestedCart" } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "Contact" + "jsObject" : { + } } }, { - "abiName" : "bjs_asyncRoundTripPublicPointArray", + "abiName" : "bjs_roundTripDataPoint", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripPublicPointArray", + "name" : "roundTripDataPoint", "parameters" : [ { "label" : "_", - "name" : "points", + "name" : "data", "type" : { - "array" : { - "_0" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - } + "swiftStruct" : { + "_0" : "DataPoint" } } } ], "returnType" : { - "array" : { - "_0" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - } + "swiftStruct" : { + "_0" : "DataPoint" } } }, { - "abiName" : "bjs_asyncRoundTripOptionalPublicPoint", + "abiName" : "bjs_roundTripPublicPoint", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripOptionalPublicPoint", + "name" : "roundTripPublicPoint", "parameters" : [ { "label" : "_", "name" : "point", "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { "swiftStruct" : { "_0" : "PublicPoint" } - }, - "_1" : "null" - } - } - }, - { - "abiName" : "bjs_asyncRoundTripPublicPointDict", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncRoundTripPublicPointDict", - "parameters" : [ - { - "label" : "_", - "name" : "points", - "type" : { - "dictionary" : { - "_0" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - } - } } } ], "returnType" : { - "dictionary" : { - "_0" : { - "swiftStruct" : { - "_0" : "PublicPoint" - } - } + "swiftStruct" : { + "_0" : "PublicPoint" } } }, @@ -16363,25 +16620,120 @@ "_0" : "Greeter" } } - }, + }, + { + "isReadonly" : false, + "name" : "optionalHelper", + "type" : { + "nullable" : { + "_0" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + }, + "_1" : "null" + } + } + } + ] + } + ], + "structs" : [ + { + "constructor" : { + "abiName" : "bjs_JSCoordinate_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "latitude", + "name" : "latitude", + "type" : { + "double" : { + + } + } + }, + { + "label" : "longitude", + "name" : "longitude", + "type" : { + "double" : { + + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "JSCoordinate", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "latitude", + "type" : { + "double" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "longitude", + "type" : { + "double" : { + + } + } + } + ], + "swiftCallName" : "JSCoordinate" + }, + { + "constructor" : { + "abiName" : "bjs_SessionState_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "token", + "name" : "token", + "type" : { + "string" : { + + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "SessionState", + "properties" : [ { - "isReadonly" : false, - "name" : "optionalHelper", + "isReadonly" : true, + "isStatic" : false, + "name" : "token", "type" : { - "nullable" : { - "_0" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - }, - "_1" : "null" + "string" : { + } } } - ] - } - ], - "structs" : [ + ], + "swiftCallName" : "SessionState" + }, { "methods" : [ @@ -17970,104 +18322,400 @@ "_0" : { "integer" : { "_0" : { - "isSigned" : true, - "width" : "word" - } + "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" : [ + { + "accessLevel" : "internal", + "constructor" : { + "accessLevel" : "internal", + "parameters" : [ + { + "name" : "label", + "type" : { + "string" : { + + } + } + } + ] + }, + "getters" : [ + { + "accessLevel" : "internal", + "name" : "label", + "type" : { + "string" : { + + } + } + } + ], + "methods" : [ + + ], + "name" : "Surface", + "setters" : [ + + ], + "staticMethods" : [ + + ] + }, + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "AliasImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripTagged", + "parameters" : [ + { + "name" : "value", + "type" : { + "alias" : { + "name" : "Tagged", + "underlying" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Tagged", + "underlying" : { + "string" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalTagged", + "parameters" : [ + { + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Tagged", + "underlying" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Tagged", + "underlying" : { + "string" : { + + } + } + } + }, + "_1" : "null" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsProduceOptionalCanvas", + "parameters" : [ + { + "name" : "label", + "type" : { + "nullable" : { + "_0" : { + "string" : { + + } + }, + "_1" : "null" } } } + ], + "returnType" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Canvas", + "underlying" : { + "jsObject" : { + "_0" : "Surface" + } + } + } + }, + "_1" : "null" + } } - } - ], - "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" : { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripAliasedTags", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "AliasedTag", + "underlying" : { + "associatedValueEnum" : { + "_0" : "InnerTag" + } + } + } + }, + "_1" : "null" + } + } + } + } + } + ], + "returnType" : { "array" : { "_0" : { - "string" : { - + "nullable" : { + "_0" : { + "alias" : { + "name" : "AliasedTag", + "underlying" : { + "associatedValueEnum" : { + "_0" : "InnerTag" + } + } + } + }, + "_1" : "null" } } } } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "string" : { - - } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true }, - "_1" : "null" - } - } - } - ], - "name" : "ArrayMembers", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "ints", - "type" : { - "array" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" + "name" : "jsRoundTripPolygon", + "parameters" : [ + { + "name" : "value", + "type" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" + } + } + } } } - } - } - } - }, - { - "isReadonly" : true, - "isStatic" : false, - "name" : "optStrings", - "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "string" : { - + ], + "returnType" : { + "alias" : { + "name" : "Polygon", + "underlying" : { + "swiftHeapObject" : { + "_0" : "PolygonReference" } } } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true }, - "_1" : "null" + "name" : "jsRoundTripCoordinate", + "parameters" : [ + { + "name" : "value", + "type" : { + "alias" : { + "name" : "Coordinate", + "underlying" : { + "swiftStruct" : { + "_0" : "JSCoordinate" + } + } + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "Coordinate", + "underlying" : { + "swiftStruct" : { + "_0" : "JSCoordinate" + } + } + } + } } - } + ] } - ], - "swiftCallName" : "ArrayMembers" - } - ] - }, - "imported" : { - "children" : [ + ] + }, { "functions" : [ @@ -18961,137 +19609,31 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsAsyncRoundTripStringArray", - "parameters" : [ - { - "name" : "values", - "type" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - } - ], - "returnType" : { - "array" : { - "_0" : { - "string" : { - - } - } - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripFeatureFlag", - "parameters" : [ - { - "name" : "v", - "type" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" - } - } - } - ], - "returnType" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripAssociatedValueEnum", - "parameters" : [ - { - "name" : "v", - "type" : { - "associatedValueEnum" : { - "_0" : "AsyncImportedPayloadResult" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "AsyncImportedPayloadResult" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsAsyncRoundTripOptionalAssociatedValueEnum", + "name" : "jsAsyncRoundTripStringArray", "parameters" : [ { - "name" : "v", + "name" : "values", "type" : { - "nullable" : { + "array" : { "_0" : { - "associatedValueEnum" : { - "_0" : "AsyncImportedPayloadResult" + "string" : { + } - }, - "_1" : "null" + } } } } ], "returnType" : { - "nullable" : { + "array" : { "_0" : { - "associatedValueEnum" : { - "_0" : "AsyncImportedPayloadResult" + "string" : { + } - }, - "_1" : "null" + } } } - } - ] - } - ] - }, - { - "functions" : [ - - ], - "types" : [ - { - "accessLevel" : "internal", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "ClosureAsyncImports", - "setters" : [ - - ], - "staticMethods" : [ + }, { "accessLevel" : "internal", "effects" : { @@ -19099,13 +19641,22 @@ "isStatic" : false, "isThrows" : true }, - "name" : "runJsClosureAsyncTests", + "name" : "jsAsyncRoundTripFeatureFlag", "parameters" : [ - + { + "name" : "v", + "type" : { + "rawValueEnum" : { + "_0" : "FeatureFlag", + "_1" : "String" + } + } + } ], "returnType" : { - "void" : { - + "rawValueEnum" : { + "_0" : "FeatureFlag", + "_1" : "String" } } } @@ -19934,45 +20485,6 @@ { "functions" : [ - ], - "types" : [ - { - "accessLevel" : "internal", - "getters" : [ - - ], - "methods" : [ - - ], - "name" : "ClosureThrowsImports", - "setters" : [ - - ], - "staticMethods" : [ - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runJsClosureThrowsTests", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - } - ] - } - ] - }, - { - "functions" : [ - ], "types" : [ { @@ -20535,6 +21047,23 @@ } } }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runAliasAsyncWorks", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + }, { "accessLevel" : "internal", "effects" : { @@ -21086,95 +21615,6 @@ } ] }, - { - "functions" : [ - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripLightColor", - "parameters" : [ - { - "name" : "value", - "type" : { - "caseEnum" : { - "_0" : "LightColor" - } - } - } - ], - "returnType" : { - "caseEnum" : { - "_0" : "LightColor" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripImportedPayloadSignal", - "parameters" : [ - { - "name" : "value", - "type" : { - "associatedValueEnum" : { - "_0" : "ImportedPayloadSignal" - } - } - } - ], - "returnType" : { - "associatedValueEnum" : { - "_0" : "ImportedPayloadSignal" - } - } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalImportedPayloadSignal", - "parameters" : [ - { - "name" : "value", - "type" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "ImportedPayloadSignal" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "associatedValueEnum" : { - "_0" : "ImportedPayloadSignal" - } - }, - "_1" : "null" - } - } - } - ], - "types" : [ - - ] - }, { "functions" : [ { @@ -21222,40 +21662,6 @@ "_0" : "Point" } } - }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalPoint", - "parameters" : [ - { - "name" : "point", - "type" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "Point" - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "swiftStruct" : { - "_0" : "Point" - } - }, - "_1" : "null" - } - } } ], "types" : [ @@ -22523,40 +22929,6 @@ } } }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : true - }, - "name" : "jsRoundTripOptionalJSObjectNull", - "parameters" : [ - { - "name" : "value", - "type" : { - "nullable" : { - "_0" : { - "jsObject" : { - - } - }, - "_1" : "null" - } - } - } - ], - "returnType" : { - "nullable" : { - "_0" : { - "jsObject" : { - - } - }, - "_1" : "null" - } - } - }, { "accessLevel" : "internal", "effects" : { diff --git a/Tests/BridgeJSRuntimeTests/JavaScript/AliasTests.mjs b/Tests/BridgeJSRuntimeTests/JavaScript/AliasTests.mjs new file mode 100644 index 000000000..db6225b21 --- /dev/null +++ b/Tests/BridgeJSRuntimeTests/JavaScript/AliasTests.mjs @@ -0,0 +1,357 @@ +// @ts-check +import assert from "node:assert"; + +export class Surface { + constructor(label) { + this.label = label; + } +}; + +/** + * @returns {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Imports["AliasImports"]} + */ +export function getImports(importsContext) { + return { + jsRoundTripTagged: (value) => { + return value; + }, + jsRoundTripOptionalTagged: (value) => { + return value ?? null; + }, + jsProduceOptionalCanvas: (label) => { + if (label === null || label === undefined) return null; + return new Surface(label); + }, + jsRoundTripAliasedTags: (values) => { + return values.map((tag) => tag ?? null); + }, + jsRoundTripPolygon: (value) => { + return value; + }, + jsRoundTripCoordinate: (value) => { + return { ...value }; + }, + }; +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +export function runAliasWorks(exports) { + runBasicRoundTrip(exports); + runOptional(exports); + runMethodsOnTarget(exports); + runStaticReturn(exports); + runMultipleAliases(exports); + runArrays(exports); + runThrows(exports); + runNonCopyable(exports); + runClosureWithAliasParameter(exports); + runOptionalInArray(exports); + runClassPropertyAndInitWithAlias(exports); + runAssociatedValueEnumPayload(exports); + runStructToStructAlias(exports); + runStructToEnumAlias(exports); + runClassToStructAlias(exports); + runEnumToClassAlias(exports); +} + +export async function runAliasAsyncWorks(exports) { + await runAsyncReturningAlias(exports); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runBasicRoundTrip(exports) { + const seed = new exports.PolygonReference([1, 2, 3], "seed"); + assert.equal(seed.vertexCount(), 3); + assert.equal(seed.summary(), "seed(3)"); + + const roundtrip = exports.roundTripPolygon(seed); + assert.equal(roundtrip.vertexCount(), 3); + assert.equal(roundtrip.summary(), "seed(3)"); + + assert.equal(exports.polygonVertexCount(seed), 3); + + const appended = exports.appendVertex(seed, 4); + assert.equal(appended.vertexCount(), 4); + assert.equal(appended.summary(), "seed(4)"); + + seed.release(); + roundtrip.release(); + appended.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runOptional(exports) { + assert.equal(exports.optionalRoundTripPolygon(null), null); + + const original = new exports.PolygonReference([7, 8, 9], "opt"); + const echoed = exports.optionalRoundTripPolygon(original); + assert.notEqual(echoed, null); + if (echoed) { + assert.equal(echoed.vertexCount(), 3); + echoed.release(); + } + original.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runMethodsOnTarget(exports) { + const a = new exports.PolygonReference([1, 2], "a"); + + const snap = a.snapshot(); + assert.equal(snap.summary(), "a(2)"); + + const b = new exports.PolygonReference([3, 4, 5], "b"); + const merged = a.merge(b); + assert.equal(merged.vertexCount(), 5); + assert.equal(merged.summary(), "a(5)"); + + a.release(); + b.release(); + snap.release(); + merged.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runStaticReturn(exports) { + const o = exports.PolygonReference.origin("o"); + assert.equal(o.vertexCount(), 0); + assert.equal(o.summary(), "o(0)"); + o.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runMultipleAliases(exports) { + const tag = exports.makeTag("hello"); + assert.equal(tag.describe(), "tag:hello"); + tag.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runArrays(exports) { + const a = new exports.PolygonReference([1], "a"); + const b = new exports.PolygonReference([2, 3], "b"); + const c = new exports.PolygonReference([4, 5, 6], "c"); + + const roundtripped = exports.roundTripPolygonArray([a, b, c]); + assert.equal(roundtripped.length, 3); + assert.equal(roundtripped[0].vertexCount(), 1); + assert.equal(roundtripped[1].vertexCount(), 2); + assert.equal(roundtripped[2].vertexCount(), 3); + assert.equal(roundtripped[0].summary(), "a(1)"); + assert.equal(roundtripped[1].summary(), "b(2)"); + assert.equal(roundtripped[2].summary(), "c(3)"); + + const combined = exports.concatPolygons([a, b, c]); + assert.equal(combined.vertexCount(), 6); + assert.equal(combined.summary(), "concat(6)"); + + const empty = exports.roundTripPolygonArray([]); + assert.equal(empty.length, 0); + + const split = exports.splitPolygon(combined); + assert.equal(split.length, 6); + for (const piece of split) { + assert.equal(piece.vertexCount(), 1); + piece.release(); + } + + a.release(); + b.release(); + c.release(); + combined.release(); + for (const r of roundtripped) r.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runThrows(exports) { + const valid = new exports.PolygonReference([1, 2], "v"); + const echoed = exports.validatePolygon(valid); + assert.equal(echoed.summary(), "v(2)"); + echoed.release(); + valid.release(); + + const empty = new exports.PolygonReference([], "empty"); + assert.throws(() => exports.validatePolygon(empty), /empty polygon/); + empty.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runNonCopyable(exports) { + const seed = exports.makeToken(7); + assert.equal(seed.read(), 7); + + const next = exports.incrementToken(seed); + assert.equal(next.read(), 8); + + next.release(); + seed.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runClosureWithAliasParameter(exports) { + const inspector = exports.makePolygonInspector(); + const poly = new exports.PolygonReference([10, 20, 30, 40], "inspect"); + assert.equal(inspector(poly), 4); + poly.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runOptionalInArray(exports) { + const a = new exports.PolygonReference([1], "a"); + const b = new exports.PolygonReference([2, 3], "b"); + + const echoed = exports.roundTripOptionalPolygonArray([a, null, b, null]); + assert.equal(echoed.length, 4); + assert.notEqual(echoed[0], null); + assert.equal(echoed[1], null); + assert.notEqual(echoed[2], null); + assert.equal(echoed[3], null); + if (echoed[0]) { + assert.equal(echoed[0].vertexCount(), 1); + } + if (echoed[2]) { + assert.equal(echoed[2].vertexCount(), 2); + } + + a.release(); + b.release(); + for (const e of echoed) { + if (e) { + e.release(); + } + } +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runClassPropertyAndInitWithAlias(exports) { + const made = exports.makeTagHolder("origin", 1); + assert.equal(made.describe(), "holder(origin, v1)"); + const initial = made.tag; + assert.equal(initial.describe(), "tag:origin"); + + const replacement = exports.makeTag("renamed"); + made.tag = replacement; + assert.equal(made.describe(), "holder(renamed, v1)"); + made.version = 7; + assert.equal(made.describe(), "holder(renamed, v7)"); + + const fresh = exports.makeTag("constructed"); + const ctor = new exports.TagHolderReference(fresh, 99); + assert.equal(ctor.describe(), "holder(constructed, v99)"); + + initial.release(); + replacement.release(); + fresh.release(); + made.release(); + ctor.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runAssociatedValueEnumPayload(exports) { + const poly = new exports.PolygonReference([1, 2, 3], "shape"); + const wrapped = exports.makeShapePolygon(poly); + assert.equal(wrapped.tag, exports.Shape.Tag.Polygon); + if (wrapped.tag === exports.Shape.Tag.Polygon) { + assert.equal(wrapped.param0.vertexCount(), 3); + } + + const echoed = exports.roundTripShape(wrapped); + assert.equal(echoed.tag, exports.Shape.Tag.Polygon); + if (echoed.tag === exports.Shape.Tag.Polygon) { + assert.equal(echoed.param0.vertexCount(), 3); + echoed.param0.release(); + } + + const empty = exports.makeShapeEmpty(); + assert.equal(empty.tag, exports.Shape.Tag.Empty); + const emptyEcho = exports.roundTripShape(empty); + assert.equal(emptyEcho.tag, exports.Shape.Tag.Empty); + + if (wrapped.tag === exports.Shape.Tag.Polygon) { + wrapped.param0.release(); + } + poly.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runStructToStructAlias(exports) { + const seed = { latitude: 45.5, longitude: -73.5 }; + const echoed = exports.roundTripCoordinate(seed); + assert.deepStrictEqual(echoed, seed); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runStructToEnumAlias(exports) { + const made = exports.makeAlert(exports.Severity.Warning); + assert.equal(made, exports.Severity.Warning); + + const echoed = exports.roundTripAlert(exports.Severity.Error); + assert.equal(echoed, exports.Severity.Error); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runClassToStructAlias(exports) { + const made = exports.makeSession("hello"); + assert.deepStrictEqual(made, { token: "hello" }); + + const echoed = exports.roundTripSession({ token: "world" }); + assert.deepStrictEqual(echoed, { token: "world" }); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runEnumToClassAlias(exports) { + const seed = exports.PriorityReference.medium(); + assert.equal(seed.describe(), "medium"); + assert.equal(seed.weight(), 5); + + const echoed = exports.roundTripPriority(seed); + assert.equal(echoed.describe(), "medium"); + assert.equal(echoed.weight(), 5); + + seed.release(); + echoed.release(); +} + +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +async function runAsyncReturningAlias(exports) { + const result = await exports.asyncMakePolygon("async"); + assert.equal(result.vertexCount(), 2); + assert.equal(result.summary(), "async(2)"); + result.release(); +} diff --git a/Tests/BridgeJSRuntimeTests/bridge-js.d.ts b/Tests/BridgeJSRuntimeTests/bridge-js.d.ts index 9fef391c1..582113df1 100644 --- a/Tests/BridgeJSRuntimeTests/bridge-js.d.ts +++ b/Tests/BridgeJSRuntimeTests/bridge-js.d.ts @@ -26,6 +26,8 @@ export class JsGreeter { export function runAsyncWorks(): Promise; +export function runAliasAsyncWorks(): Promise; + export interface WeatherData { temperature: number; description: string; diff --git a/Tests/prelude.mjs b/Tests/prelude.mjs index 658bceed9..5b6f8b39f 100644 --- a/Tests/prelude.mjs +++ b/Tests/prelude.mjs @@ -5,6 +5,7 @@ import { } from '../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.js'; import { ImportedFoo } from './BridgeJSRuntimeTests/JavaScript/Types.mjs'; import { runJsOptionalSupportTests } from './BridgeJSRuntimeTests/JavaScript/OptionalSupportTests.mjs'; +import { runAliasWorks, runAliasAsyncWorks, getImports as getAliasImports, Surface } from './BridgeJSRuntimeTests/JavaScript/AliasTests.mjs'; import { getImports as getClosureSupportImports } from './BridgeJSRuntimeTests/JavaScript/ClosureSupportTests.mjs'; import { getImports as getClosureThrowsImports } from './BridgeJSRuntimeTests/JavaScript/ClosureThrowsTests.mjs'; import { getImports as getClosureAsyncImports } from './BridgeJSRuntimeTests/JavaScript/ClosureAsyncTests.mjs'; @@ -107,6 +108,7 @@ export async function setupOptions(options, context) { }, ArrayElementObject, JSClassWithArrayMembers, + Surface, JsGreeter: class { /** * @param {string} name @@ -141,6 +143,14 @@ export async function setupOptions(options, context) { await runAsyncWorksTests(exports); return; }, + runAliasAsyncWorks: async () => { + const exports = importsContext.getExports(); + if (!exports) { + throw new Error("No exports!?"); + } + await runAliasAsyncWorks(exports); + return; + }, AsyncImportImports: getAsyncImportImports(importsContext), fetchWeatherData: (city) => { return Promise.resolve({ @@ -173,6 +183,7 @@ export async function setupOptions(options, context) { IntegerTypesSupportImports: getIntegerTypesSupportImports(importsContext), JSTypedArrayImports: getJSTypedArrayImports(importsContext), IdentityModeTestImports: getIdentityModeTestImports(importsContext), + AliasImports: getAliasImports(importsContext), }; }, addToCoreImports(importObject, importsContext) { @@ -196,6 +207,13 @@ export async function setupOptions(options, context) { } return BridgeJSRuntimeTests_runJsStructWorks(exports); } + bridgeJSRuntimeTests["runAliasWorks"] = () => { + const exports = getExports(); + if (!exports) { + throw new Error("No exports!?"); + } + runAliasWorks(exports); + } const bridgeJSGlobalTests = importObject["BridgeJSGlobalTests"] || {}; bridgeJSGlobalTests["runJsWorksGlobal"] = () => { return BridgeJSGlobalTests_runJsWorksGlobal(); From fce419345ba1ec28505f9ba52f233ffc98c5e872 Mon Sep 17 00:00:00 2001 From: William Taylor Date: Fri, 12 Jun 2026 12:09:56 +1000 Subject: [PATCH 12/20] BridgeJS: Remove insertion of bridging calls for aliases --- .../Sources/BridgeJSCore/ClosureCodegen.swift | 8 +- .../Sources/BridgeJSCore/ExportSwift.swift | 126 +- .../Sources/BridgeJSCore/ImportTS.swift | 29 +- .../BridgeJSCore/SwiftToSkeleton.swift | 24 +- .../Sources/BridgeJSLink/JSGlueGen.swift | 62 +- .../BridgeJSSkeleton/BridgeJSSkeleton.swift | 16 +- .../CrossModuleResolutionTests.swift | 30 + .../BridgeJSCodegenTests/Alias.swift | 64 +- .../BridgeJSCodegenTests/AliasInClosure.swift | 12 +- .../AsyncAssociatedValueEnum.json | 3 + .../BridgeJSCodegenTests/EnumAlias.swift | 8 +- .../EnumAssociatedValueImport.json | 3 + .../BridgeJSCodegenTests/EnumCaseImport.json | 3 + .../SwiftClosureImports.json | 3 + .../__Snapshots__/BridgeJSLinkTests/Alias.js | 7 + .../BridgeJSLinkTests/AliasInClosure.js | 7 + .../BridgeJSLinkTests/EnumAlias.js | 7 + .../JavaScriptKit/BridgeJSIntrinsics.swift | 288 + Tests/BridgeJSRuntimeTests/AliasAPIs.swift | 114 +- Tests/BridgeJSRuntimeTests/AliasTests.swift | 15 +- .../Generated/BridgeJS.Macros.swift | 2 - .../Generated/BridgeJS.swift | 12189 +++++++++------- .../Generated/JavaScript/BridgeJS.json | 3216 ++-- .../JavaScript/AliasTests.mjs | 62 +- Tests/BridgeJSRuntimeTests/bridge-js.d.ts | 2 - Tests/prelude.mjs | 10 +- 26 files changed, 10085 insertions(+), 6225 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift index 317bd0b4f..969b3c01e 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift @@ -153,8 +153,9 @@ public struct ClosureCodegen { let argNames = liftInfo.parameters.map { (argName, _) in liftInfo.parameters.count > 1 ? "\(paramName)\(argName.capitalizedFirstLetter)" : paramName } - let liftCall = "\(paramType.unaliased.swiftType).bridgeJSLiftParameter(\(argNames.joined(separator: ", ")))" - liftedParams.append(paramType.liftAliases(expression: liftCall)) + liftedParams.append( + "\(paramType.swiftType).bridgeJSLiftParameter(\(argNames.joined(separator: ", ")))" + ) } let tryPrefix = signature.isThrows ? "try " : "" @@ -198,8 +199,7 @@ public struct ClosureCodegen { } printer.write("}") default: - let lowered = signature.returnType.lowerAliases(expression: "result") - printer.write("return \(lowered).bridgeJSLowerReturn()") + printer.write("return result.bridgeJSLowerReturn()") } } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index cdbd3970f..663c2362e 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -100,6 +100,15 @@ public class ExportSwift { } } } + + withSpan("Render Aliases") { [self] in + let aliasCodegen = AliasCodegen() + for alias in skeleton.aliases { + if let aliasExtension = aliasCodegen.renderAliasConformance(alias) { + decls.append(aliasExtension) + } + } + } return withSpan("Format Export Glue") { return decls.map { $0.description }.joined(separator: "\n\n") } @@ -227,15 +236,15 @@ public class ExportSwift { } else { optionalSwiftType = "JSUndefinedOr" } - typeNameForIntrinsic = "\(optionalSwiftType)<\(wrappedType.unaliased.swiftType)>" - let liftCall = - "\(typeNameForIntrinsic).bridgeJSLiftParameter(\(argumentsToLift.joined(separator: ", ")))" - liftingExpr = "\(raw: param.type.liftAliases(expression: liftCall))" + typeNameForIntrinsic = "\(optionalSwiftType)<\(wrappedType.swiftType)>" + liftingExpr = ExprSyntax( + "\(raw: typeNameForIntrinsic).bridgeJSLiftParameter(\(raw: argumentsToLift.joined(separator: ", ")))" + ) default: - typeNameForIntrinsic = param.type.unaliased.swiftType - let liftCall = - "\(typeNameForIntrinsic).bridgeJSLiftParameter(\(argumentsToLift.joined(separator: ", ")))" - liftingExpr = "\(raw: param.type.liftAliases(expression: liftCall))" + typeNameForIntrinsic = param.type.swiftType + liftingExpr = ExprSyntax( + "\(raw: typeNameForIntrinsic).bridgeJSLiftParameter(\(raw: argumentsToLift.joined(separator: ", ")))" + ) } liftedParameterExprs.append(liftingExpr) @@ -280,8 +289,7 @@ public class ExportSwift { } if effects.isAsync, returnType != .void { - let lowered = returnType.lowerAliases(expression: callExpr.description) - return CodeBlockItemSyntax(item: .init(StmtSyntax("return \(raw: lowered)"))) + return CodeBlockItemSyntax(item: .init(StmtSyntax("return \(raw: callExpr)"))) } if returnType == .void { @@ -394,18 +402,17 @@ public class ExportSwift { return } - let returnAccessor = returnType.lowerAliases(expression: "ret") switch returnType { case .closure(_, useJSTypedClosure: false): append("return JSTypedClosure(ret).bridgeJSLowerReturn()") case .array, .nullable(.array, _): let stackCodegen = StackCodegen() - for stmt in stackCodegen.lowerStatements(for: returnType, accessor: returnAccessor, varPrefix: "ret") { + for stmt in stackCodegen.lowerStatements(for: returnType, accessor: "ret", varPrefix: "ret") { append(stmt) } case .dictionary(.swiftProtocol): let stackCodegen = StackCodegen() - for stmt in stackCodegen.lowerStatements(for: returnType, accessor: returnAccessor, varPrefix: "ret") { + for stmt in stackCodegen.lowerStatements(for: returnType, accessor: "ret", varPrefix: "ret") { append(stmt) } case .swiftProtocol: @@ -421,7 +428,7 @@ public class ExportSwift { """ ) default: - append("return \(raw: returnAccessor).bridgeJSLowerReturn()") + append("return ret.bridgeJSLowerReturn()") } } @@ -880,7 +887,7 @@ struct StackCodegen { case .string, .integer, .bool, .float, .double, .jsObject(nil), .jsValue, .swiftStruct, .swiftHeapObject, .unsafePointer, .swiftProtocol, .caseEnum, .associatedValueEnum, .rawValueEnum, .array, .dictionary, .alias: - return "\(raw: type.liftAliases(expression: "\(type.unaliased.swiftType).bridgeJSStackPop()"))" + return "\(raw: type.swiftType).bridgeJSStackPop()" case .jsObject(let className?): return "\(raw: className)(unsafelyWrapping: JSObject.bridgeJSStackPop())" case .nullable(let wrappedType, let kind): @@ -898,9 +905,7 @@ struct StackCodegen { case .string, .integer, .bool, .float, .double, .jsObject(nil), .jsValue, .swiftStruct, .swiftHeapObject, .caseEnum, .associatedValueEnum, .rawValueEnum, .array, .dictionary, .alias: - let popCall = "\(typeName)<\(wrappedType.unaliased.swiftType)>.bridgeJSStackPop()" - let nullableType = BridgeType.nullable(wrappedType, kind) - return "\(raw: nullableType.liftAliases(expression: popCall))" + return "\(raw: typeName)<\(raw: wrappedType.swiftType)>.bridgeJSStackPop()" case .jsObject(let className?): return "\(raw: typeName).bridgeJSStackPop().map { \(raw: className)(unsafelyWrapping: $0) }" case .nullable, .void, .namespaceEnum, .closure, .unsafePointer, .swiftProtocol: @@ -1208,10 +1213,9 @@ struct EnumCodegen { ) { for (index, associatedValue) in associatedValues.enumerated() { let paramName = associatedValue.label ?? "param\(index)" - let accessor = associatedValue.type.lowerAliases(expression: paramName) let statements = stackCodegen.lowerStatements( for: associatedValue.type, - accessor: accessor, + accessor: paramName, varPrefix: paramName ) for statement in statements { @@ -1344,10 +1348,9 @@ struct StructCodegen { let instanceProps = structDef.properties.filter { !$0.isStatic } for property in instanceProps { - let accessor = property.type.lowerAliases(expression: "self.\(property.name)") let statements = stackCodegen.lowerStatements( for: property.type, - accessor: accessor, + accessor: "self.\(property.name)", varPrefix: property.name ) for statement in statements { @@ -1359,6 +1362,18 @@ struct StructCodegen { } } +// MARK: - AliasCodegen + +struct AliasCodegen { + func renderAliasConformance(_ alias: ExportedAlias) -> DeclSyntax? { + guard let protocols = alias.underlying.aliasConformanceProtocols else { + return nil + } + let conformances = (["_BridgedSwiftAlias"] + protocols).joined(separator: ", ") + return "extension \(raw: alias.swiftCallName): \(raw: conformances) {}" + } +} + // MARK: - ProtocolCodegen struct ProtocolCodegen { @@ -1570,61 +1585,20 @@ extension UnsafePointerType { } extension BridgeType { - var unaliased: BridgeType { - switch self { - case .alias(_, let underlying): return underlying.unaliased - case .nullable(let wrapped, let kind): return .nullable(wrapped.unaliased, kind) - case .array(let element): return .array(element.unaliased) - case .dictionary(let value): return .dictionary(value.unaliased) - case .bool, .integer, .float, .double, .string, .jsValue, .jsObject, - .swiftHeapObject, .unsafePointer, .swiftProtocol, .void, - .caseEnum, .rawValueEnum, .associatedValueEnum, .swiftStruct, - .namespaceEnum, .closure: - return self - } - } - - /// If this type contains an alias, convert the expression with a type of the alias to the underlying type. - func liftAliases(expression: String) -> String { - switch self { - case .alias(let name, _): - return "\(name).bridgeFromJS(\(expression))" - case .nullable(let wrapped, _): - let lifted = wrapped.liftAliases(expression: "$0") - return lifted == "$0" ? expression : "\(expression).map { \(lifted) }" - case .array(let element): - let lifted = element.liftAliases(expression: "$0") - return lifted == "$0" ? expression : "\(expression).map { \(lifted) }" - case .dictionary(let value): - let lifted = value.liftAliases(expression: "$0") - return lifted == "$0" ? expression : "\(expression).mapValues { \(lifted) }" - case .bool, .integer, .float, .double, .string, .jsValue, .jsObject, - .swiftHeapObject, .unsafePointer, .swiftProtocol, .void, - .caseEnum, .rawValueEnum, .associatedValueEnum, .swiftStruct, - .namespaceEnum, .closure: - return expression - } - } - - /// Opposite of `liftAliases`: if this type contains an alias, convert the expression with a type of the underlying to the alias type. - func lowerAliases(expression: String) -> String { + var aliasConformanceProtocols: [String]? { switch self { - case .alias: - return "\(expression).bridgeToJS()" - case .nullable(let wrapped, _): - let lowered = wrapped.lowerAliases(expression: "$0") - return lowered == "$0" ? expression : "\(expression).map { \(lowered) }" - case .array(let element): - let lowered = element.lowerAliases(expression: "$0") - return lowered == "$0" ? expression : "\(expression).map { \(lowered) }" - case .dictionary(let value): - let lowered = value.lowerAliases(expression: "$0") - return lowered == "$0" ? expression : "\(expression).mapValues { \(lowered) }" - case .bool, .integer, .float, .double, .string, .jsValue, .jsObject, - .swiftHeapObject, .unsafePointer, .swiftProtocol, .void, - .caseEnum, .rawValueEnum, .associatedValueEnum, .swiftStruct, - .namespaceEnum, .closure: - return expression + case .swiftHeapObject, .jsObject, .integer, .float, .double, .bool, .string, .jsValue: + return ["_BridgedSwiftStackType"] + case .swiftStruct: + return ["_BridgedSwiftStruct"] + case .caseEnum: + return ["_BridgedSwiftCaseEnum"] + case .associatedValueEnum: + return ["_BridgedSwiftAssociatedValueEnum"] + case .rawValueEnum, .void, .unsafePointer, .namespaceEnum, + .swiftProtocol, .closure, .nullable, .array, .dictionary, .alias: + // Not supported yet. + return nil } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift index 9fd2af08e..c15d974f8 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift @@ -172,8 +172,7 @@ public struct ImportTS { if loweringInfo.useBorrowing { let returnVariableName = "ret\(borrowedArguments.count)" let assign = needsReturnVariable ? "let \(returnVariableName) = " : "" - let loweredAlias = param.type.lowerAliases(expression: param.name) - body.write("\(assign)\(loweredAlias).bridgeJSWithLoweredParameter { \(pattern) in") + body.write("\(assign)\(param.name).bridgeJSWithLoweredParameter { \(pattern) in") body.indent() borrowedArguments.append( BorrowedArgument( @@ -204,8 +203,7 @@ public struct ImportTS { "(\(raw: param.name) as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()" ) } else { - let loweredAlias = param.type.lowerAliases(expression: param.name) - initializerExpr = ExprSyntax("\(raw: loweredAlias).bridgeJSLowerParameter()") + initializerExpr = ExprSyntax("\(raw: param.name).bridgeJSLowerParameter()") } if loweringInfo.loweredParameters.isEmpty { @@ -296,21 +294,18 @@ public struct ImportTS { if returnType.usesSideChannelForOptionalReturn() { // Side channel returns: extern function returns Void, value is retrieved via side channel - let liftCall = "\(returnType.unaliased.swiftType).bridgeJSLiftReturnFromSideChannel()" - body.write("return \(returnType.liftAliases(expression: liftCall))") + body.write("return \(returnType.swiftType).bridgeJSLiftReturnFromSideChannel()") } else { let liftExpr: String switch returnType { case .closure(let signature, _): liftExpr = "_BJS_Closure_\(signature.mangleName).bridgeJSLift(ret)" default: - let liftCall: String if liftingInfo.valueToLift != nil { - liftCall = "\(returnType.unaliased.swiftType).bridgeJSLiftReturn(ret)" + liftExpr = "\(returnType.swiftType).bridgeJSLiftReturn(ret)" } else { - liftCall = "\(returnType.unaliased.swiftType).bridgeJSLiftReturn()" + liftExpr = "\(returnType.swiftType).bridgeJSLiftReturn()" } - liftExpr = returnType.liftAliases(expression: liftCall) } body.write("return \(liftExpr)") } @@ -908,7 +903,7 @@ extension BridgeType { } func loweringParameterInfo(context: BridgeContext = .importTS) throws -> LoweringParameterInfo { - switch self { + switch self.unaliased { case .bool: return .bool case .integer(let t): return LoweringParameterInfo(loweredParameters: [("value", t.wasmCoreType)]) case .float: return .float @@ -962,8 +957,8 @@ extension BridgeType { return LoweringParameterInfo(loweredParameters: params, useBorrowing: wrappedInfo.useBorrowing) case .array, .dictionary: return LoweringParameterInfo(loweredParameters: []) - case .alias(_, let underlying): - return try underlying.loweringParameterInfo(context: context) + case .alias: + preconditionFailure() } } @@ -983,7 +978,7 @@ extension BridgeType { func liftingReturnInfo( context: BridgeContext = .importTS ) throws -> LiftingReturnInfo { - switch self { + switch self.unaliased { case .bool: return .bool case .integer(let t): return LiftingReturnInfo(valueToLift: t.wasmCoreType) case .float: return .float @@ -1026,7 +1021,7 @@ extension BridgeType { case .nullable(let wrappedType, _): // jsObject and `@JS struct` use the stack ABI for optionals — the thunk returns // void and the value (plus isSome discriminator) flows through the stacks. - if case .jsObject = wrappedType.unaliased { + if case .jsObject = wrappedType { return LiftingReturnInfo(valueToLift: nil) } if case .swiftStruct = wrappedType, context == .importTS { @@ -1036,8 +1031,8 @@ extension BridgeType { return LiftingReturnInfo(valueToLift: wrappedInfo.valueToLift) case .array, .dictionary: return LiftingReturnInfo(valueToLift: nil) - case .alias(_, let underlying): - return try underlying.liftingReturnInfo(context: context) + case .alias: + preconditionFailure() } } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index 8b4e79d64..36ff44cbc 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -552,10 +552,7 @@ public final class SwiftToSkeleton { swiftCallName: String, errors: inout [DiagnosticError] ) -> BridgeType? { - if let targetDecl = typeDeclResolver.resolve(aliasTarget), - let targetJSAttribute = targetDecl.attributes.firstJSAttribute, - extractAliasTarget(from: targetJSAttribute) != nil - { + func diagnoseChainedAlias() -> BridgeType? { errors.append( DiagnosticError( node: aliasTarget, @@ -565,7 +562,17 @@ public final class SwiftToSkeleton { ) return nil } + if let targetDecl = typeDeclResolver.resolve(aliasTarget), + let targetJSAttribute = targetDecl.attributes.firstJSAttribute, + extractAliasTarget(from: targetJSAttribute) != nil + { + return diagnoseChainedAlias() + } guard let targetType = lookupType(for: aliasTarget, errors: &errors) else { return nil } + if case .alias = targetType { + // Alias declared in another module. + return diagnoseChainedAlias() + } if case .swiftProtocol = targetType { errors.append( DiagnosticError( @@ -1747,6 +1754,15 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { errors.append(contentsOf: lookupErrors) return } + guard underlying.aliasConformanceProtocols != nil else { + errors.append( + DiagnosticError( + node: aliasTarget, + message: "Representation \(underlying.swiftType) is not supported" + ) + ) + return + } exportedAliases.append( ExportedAlias(swiftCallName: swiftCallName, underlying: underlying) ) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift index c6ac936cd..a94c780ed 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift @@ -651,9 +651,6 @@ struct IntrinsicJSFragment: Sendable { kind: JSOptionalKind, context bridgeContext: BridgeContext = .importTS ) throws -> IntrinsicJSFragment { - if case .alias(_, let underlying) = wrappedType { - return try optionalLiftParameter(wrappedType: underlying, kind: kind, context: bridgeContext) - } if wrappedType.isSingleParamScalar { let coerce = wrappedType.liftCoerce return IntrinsicJSFragment( @@ -742,9 +739,6 @@ struct IntrinsicJSFragment: Sendable { wrappedType: BridgeType, kind: JSOptionalKind ) throws -> IntrinsicJSFragment { - if case .alias(_, let underlying) = wrappedType { - return try optionalLowerParameter(wrappedType: underlying, kind: kind) - } if wrappedType.isSingleParamScalar { let wasmType = wrappedType.wasmParams[0].type let coerce = wrappedType.lowerCoerce @@ -973,9 +967,6 @@ struct IntrinsicJSFragment: Sendable { wrappedType: BridgeType, kind: JSOptionalKind ) -> IntrinsicJSFragment { - if case .alias(_, let underlying) = wrappedType { - return optionalLiftReturn(wrappedType: underlying, kind: kind) - } if let scalarKind = wrappedType.optionalScalarKind { return optionalLiftReturnFromStorage(storage: scalarKind.storageName) } @@ -1073,9 +1064,6 @@ struct IntrinsicJSFragment: Sendable { } static func optionalLowerReturn(wrappedType: BridgeType, kind: JSOptionalKind) throws -> IntrinsicJSFragment { - if case .alias(_, let underlying) = wrappedType { - return try optionalLowerReturn(wrappedType: underlying, kind: kind) - } switch wrappedType { case .void, .nullable, .namespaceEnum, .closure: throw BridgeJSLinkError(message: "Unsupported optional wrapped type for protocol export: \(wrappedType)") @@ -1200,9 +1188,7 @@ struct IntrinsicJSFragment: Sendable { // MARK: - Protocol Support static func protocolPropertyOptionalToSideChannel(wrappedType: BridgeType) throws -> IntrinsicJSFragment { - if case .alias(_, let underlying) = wrappedType { - return try protocolPropertyOptionalToSideChannel(wrappedType: underlying) - } + let wrappedType = wrappedType.unaliased if let scalarKind = wrappedType.optionalScalarKind { let storage = scalarKind.storageName return IntrinsicJSFragment( @@ -1299,7 +1285,7 @@ struct IntrinsicJSFragment: Sendable { /// Returns a fragment that lowers a JS value to Wasm core values for parameters static func lowerParameter(type: BridgeType) throws -> IntrinsicJSFragment { - switch type { + switch type.unaliased { case .bool, .integer, .float, .double, .unsafePointer, .caseEnum: return .identity case .rawValueEnum(_, let rawType) where rawType != .string: @@ -1338,8 +1324,6 @@ struct IntrinsicJSFragment: Sendable { return try arrayLower(elementType: elementType) case .dictionary(let valueType): return try dictionaryLower(valueType: valueType) - case .alias(_, let underlying): - return try lowerParameter(type: underlying) default: throw BridgeJSLinkError(message: "Unhandled type in lowerParameter: \(type)") } @@ -1347,7 +1331,7 @@ struct IntrinsicJSFragment: Sendable { /// Returns a fragment that lifts a Wasm core value to a JS value for return values static func liftReturn(type: BridgeType) throws -> IntrinsicJSFragment { - switch type { + switch type.unaliased { case .bool, .rawValueEnum(_, .bool): return .boolLiftReturn case .integer(let t) where !t.is64Bit && !t.isSigned: @@ -1397,8 +1381,6 @@ struct IntrinsicJSFragment: Sendable { return try arrayLift(elementType: elementType) case .dictionary(let valueType): return try dictionaryLift(valueType: valueType) - case .alias(_, let underlying): - return try liftReturn(type: underlying) default: throw BridgeJSLinkError(message: "Unhandled type in liftReturn: \(type)") } @@ -1408,7 +1390,7 @@ struct IntrinsicJSFragment: Sendable { /// Returns a fragment that lifts Wasm core values to JS values for parameters static func liftParameter(type: BridgeType, context: BridgeContext = .importTS) throws -> IntrinsicJSFragment { - switch type { + switch type.unaliased { case .bool, .rawValueEnum(_, .bool): return .boolLiftParameter case .integer(let t) where !t.is64Bit && !t.isSigned: @@ -1489,8 +1471,6 @@ struct IntrinsicJSFragment: Sendable { return try arrayLift(elementType: elementType) case .dictionary(let valueType): return try dictionaryLift(valueType: valueType) - case .alias(_, let underlying): - return try liftParameter(type: underlying, context: context) default: throw BridgeJSLinkError(message: "Unhandled type in liftParameter: \(type)") } @@ -1498,7 +1478,7 @@ struct IntrinsicJSFragment: Sendable { /// Returns a fragment that lowers a JS value to Wasm core values for return values static func lowerReturn(type: BridgeType, context: BridgeContext = .importTS) throws -> IntrinsicJSFragment { - switch type { + switch type.unaliased { case .bool, .rawValueEnum(_, .bool): return .boolLowerReturn case .integer, .float, .double, .unsafePointer, .caseEnum: @@ -1545,8 +1525,6 @@ struct IntrinsicJSFragment: Sendable { return try arrayLower(elementType: elementType) case .dictionary(let valueType): return try dictionaryLower(valueType: valueType) - case .alias(_, let underlying): - return try lowerReturn(type: underlying, context: context) default: throw BridgeJSLinkError(message: "Unhandled type in lowerReturn: \(type)") } @@ -1782,6 +1760,7 @@ struct IntrinsicJSFragment: Sendable { } private static func associatedValuePushPayload(type: BridgeType) throws -> IntrinsicJSFragment { + let type = type.unaliased switch type { case .nullable(let wrappedType, let kind): return try optionalElementLowerFragment(wrappedType: wrappedType, kind: kind) @@ -1791,6 +1770,7 @@ struct IntrinsicJSFragment: Sendable { } private static func associatedValuePopPayload(type: BridgeType) throws -> IntrinsicJSFragment { + let type = type.unaliased switch type { case .nullable(let wrappedType, let kind): return try optionalElementRaiseFragment(wrappedType: wrappedType, kind: kind) @@ -1964,9 +1944,6 @@ struct IntrinsicJSFragment: Sendable { } private static func stackLiftFragment(elementType: BridgeType) throws -> IntrinsicJSFragment { - if case .alias(_, let underlying) = elementType { - return try stackLiftFragment(elementType: underlying) - } if case .nullable(let wrappedType, let kind) = elementType { return try optionalElementRaiseFragment(wrappedType: wrappedType, kind: kind) } @@ -2094,9 +2071,6 @@ struct IntrinsicJSFragment: Sendable { } private static func stackLowerFragment(elementType: BridgeType) throws -> IntrinsicJSFragment { - if case .alias(_, let underlying) = elementType { - return try stackLowerFragment(elementType: underlying) - } if case .nullable(let wrappedType, let kind) = elementType { return try optionalElementLowerFragment(wrappedType: wrappedType, kind: kind) } @@ -2221,9 +2195,6 @@ struct IntrinsicJSFragment: Sendable { wrappedType: BridgeType, kind: JSOptionalKind ) throws -> IntrinsicJSFragment { - if case .alias(_, let underlying) = wrappedType { - return try optionalElementRaiseFragment(wrappedType: underlying, kind: kind) - } if case .associatedValueEnum(let fullName) = wrappedType { let base = fullName.components(separatedBy: ".").last ?? fullName let absenceLiteral = kind.absenceLiteral @@ -2290,9 +2261,6 @@ struct IntrinsicJSFragment: Sendable { wrappedType: BridgeType, kind: JSOptionalKind ) throws -> IntrinsicJSFragment { - if case .alias(_, let underlying) = wrappedType { - return try optionalElementLowerFragment(wrappedType: underlying, kind: kind) - } if case .associatedValueEnum(let fullName) = wrappedType { let base = fullName.components(separatedBy: ".").last ?? fullName return IntrinsicJSFragment( @@ -2499,6 +2467,7 @@ struct IntrinsicJSFragment: Sendable { fieldName: String, allStructs: [ExportedStruct] ) throws -> IntrinsicJSFragment { + let type = type.unaliased switch type { case .jsValue: preconditionFailure("Struct field of JSValue is not supported yet") @@ -2560,7 +2529,8 @@ struct IntrinsicJSFragment: Sendable { field: ExportedProperty, allStructs: [ExportedStruct] ) throws -> IntrinsicJSFragment { - switch field.type { + let fieldType = field.type.unaliased + switch fieldType { case .jsValue: preconditionFailure("Struct field of JSValue is not supported yet") case .nullable(let wrappedType, let kind): @@ -2611,7 +2581,7 @@ struct IntrinsicJSFragment: Sendable { } ) default: - return try stackLiftFragment(elementType: field.type) + return try stackLiftFragment(elementType: fieldType) } } } @@ -2715,8 +2685,8 @@ private extension BridgeType { return .stackABI case .nullable(let wrapped, _): return wrapped.optionalConvention - case .alias(_, let underlying): - return underlying.optionalConvention + case .alias: + preconditionFailure() } } @@ -2748,8 +2718,6 @@ private extension BridgeType { return .i32(-1) case .nullable(let wrapped, _): return wrapped.nilSentinel - case .alias(_, let underlying): - return underlying.nilSentinel default: return .none } @@ -2815,8 +2783,8 @@ private extension BridgeType { return [] case .nullable(let wrapped, _): return wrapped.wasmParams - case .alias(_, let underlying): - return underlying.wasmParams + case .alias: + preconditionFailure() } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift index 4d1ebbbc1..d2c506e6a 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift @@ -1008,7 +1008,7 @@ public struct ExportedProperty: Codable, Equatable, Sendable { } } -public struct ExportedAlias: Codable { +public struct ExportedAlias: Codable, Equatable, Sendable { public let swiftCallName: String public let underlying: BridgeType @@ -1626,6 +1626,20 @@ extension BridgeType { } } + public var unaliased: BridgeType { + switch self { + case .alias(_, let underlying): return underlying.unaliased + case .nullable(let wrapped, let kind): return .nullable(wrapped.unaliased, kind) + case .array(let element): return .array(element.unaliased) + case .dictionary(let value): return .dictionary(value.unaliased) + case .bool, .integer, .float, .double, .string, .jsValue, .jsObject, + .swiftHeapObject, .unsafePointer, .swiftProtocol, .void, + .caseEnum, .rawValueEnum, .associatedValueEnum, .swiftStruct, + .namespaceEnum, .closure: + return self + } + } + public var abiReturnType: WasmCoreType? { switch self { case .void: return nil diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/CrossModuleResolutionTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/CrossModuleResolutionTests.swift index 4f12a88fa..3f0ee88db 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/CrossModuleResolutionTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/CrossModuleResolutionTests.swift @@ -457,6 +457,36 @@ import Testing } } + @Test + func crossModuleChainedJSAsDiagnostic() throws { + let core = try buildDependencySkeleton( + moduleName: "Core", + source: """ + @JS(as: Box.self) public struct Wrapped { + public consuming func bridgeToJS() -> Box { fatalError() } + public static func bridgeFromJS(_ value: consuming Box) -> Wrapped { fatalError() } + } + @JS public final class Box { @JS public init() {} } + """ + ) + do { + _ = try resolveApp( + source: """ + import Core + @JS(as: Wrapped.self) public struct Doubly { + public consuming func bridgeToJS() -> Wrapped { fatalError() } + public static func bridgeFromJS(_ value: consuming Wrapped) -> Doubly { fatalError() } + } + """, + dependencies: [(moduleName: "Core", skeleton: core)] + ) + Issue.record("Expected chained-alias diagnostic for cross-module `@JS(as:)` target") + } catch let error as BridgeJSCoreDiagnosticError { + let combinedMessages = error.diagnostics.map(\.diagnostic.message).joined(separator: "\n") + #expect(combinedMessages.contains("not another `@JS(as:)` type")) + } + } + // MARK: - Utillites private func resolveApp( diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.swift index 1a31905f3..a9252e57f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Alias.swift @@ -5,7 +5,7 @@ struct AnyHasOptionalUserId: HasOptionalUserId, _BridgedSwiftProtocolWrapper { get { let jsObjectValue = jsObject.bridgeJSLowerParameter() bjs_HasOptionalUserId_userId_get(jsObjectValue) - return Optional.bridgeJSLiftReturnFromSideChannel().map { UserId.bridgeFromJS($0) } + return Optional.bridgeJSLiftReturnFromSideChannel() } } @@ -53,8 +53,8 @@ extension InnerTag: _BridgedSwiftAssociatedValueEnum { @_cdecl("bjs_roundtripPolygon") public func _bjs_roundtripPolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundtripPolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = roundtripPolygon(_: Polygon.bridgeJSLiftParameter(polygon)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -64,8 +64,8 @@ public func _bjs_roundtripPolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeM @_cdecl("bjs_optionalPolygon") public func _bjs_optionalPolygon(_ polygonIsSome: Int32, _ polygonValue: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = optionalPolygon(_: Optional.bridgeJSLiftParameter(polygonIsSome, polygonValue).map { Polygon.bridgeFromJS($0) }) - return ret.map { $0.bridgeToJS() }.bridgeJSLowerReturn() + let ret = optionalPolygon(_: Optional.bridgeJSLiftParameter(polygonIsSome, polygonValue)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -75,8 +75,8 @@ public func _bjs_optionalPolygon(_ polygonIsSome: Int32, _ polygonValue: UnsafeM @_cdecl("bjs_polygonArray") public func _bjs_polygonArray() -> Void { #if arch(wasm32) - let ret = polygonArray(_: [PolygonReference].bridgeJSStackPop().map { Polygon.bridgeFromJS($0) }) - ret.map { $0.bridgeToJS() }.bridgeJSStackPush() + let ret = polygonArray(_: [Polygon].bridgeJSStackPop()) + ret.bridgeJSStackPush() #else fatalError("Only available on WebAssembly") #endif @@ -87,15 +87,15 @@ public func _bjs_polygonArray() -> Void { public func _bjs_validatePolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) do { - let ret = try validatePolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = try validatePolygon(_: Polygon.bridgeJSLiftParameter(polygon)) + 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)) + let jsError = JSError(message: error.description) withExtendedLifetime(jsError.jsObject) { _swift_js_throw(Int32(bitPattern: $0.id)) } @@ -112,7 +112,7 @@ public func _bjs_validatePolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMu public func _bjs_makeTag(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = makeTag(_: String.bridgeJSLiftParameter(nameBytes, nameLength)) - return ret.bridgeToJS().bridgeJSLowerReturn() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -122,8 +122,8 @@ public func _bjs_makeTag(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutab @_cdecl("bjs_roundtripTags") public func _bjs_roundtripTags() -> Void { #if arch(wasm32) - let ret = roundtripTags(_: [Optional].bridgeJSStackPop().map { $0.map { AliasedTag.bridgeFromJS($0) } }) - ret.map { $0.map { $0.bridgeToJS() } }.bridgeJSStackPush() + let ret = roundtripTags(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() #else fatalError("Only available on WebAssembly") #endif @@ -144,7 +144,7 @@ public func _bjs_describeUser(_ owner: Int32) -> Int32 { @_cdecl("bjs_PolygonReference_init") public func _bjs_PolygonReference_init(_ underlying: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = PolygonReference(underlying: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(underlying))) + let ret = PolygonReference(underlying: Polygon.bridgeJSLiftParameter(underlying)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -156,7 +156,7 @@ public func _bjs_PolygonReference_init(_ underlying: UnsafeMutableRawPointer) -> public func _bjs_PolygonReference_snapshot(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = PolygonReference.bridgeJSLiftParameter(_self).snapshot() - return ret.bridgeToJS().bridgeJSLowerReturn() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -166,8 +166,8 @@ public func _bjs_PolygonReference_snapshot(_ _self: UnsafeMutableRawPointer) -> @_cdecl("bjs_PolygonReference_merge") public func _bjs_PolygonReference_merge(_ _self: UnsafeMutableRawPointer, _ other: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = PolygonReference.bridgeJSLiftParameter(_self).merge(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(other))) - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = PolygonReference.bridgeJSLiftParameter(_self).merge(_: Polygon.bridgeJSLiftParameter(other)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -178,7 +178,7 @@ public func _bjs_PolygonReference_merge(_ _self: UnsafeMutableRawPointer, _ othe public func _bjs_PolygonReference_static_origin() -> UnsafeMutableRawPointer { #if arch(wasm32) let ret = PolygonReference.origin() - return ret.bridgeToJS().bridgeJSLowerReturn() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -219,7 +219,7 @@ fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPo @_cdecl("bjs_TagReference_init") public func _bjs_TagReference_init(_ underlying: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = TagReference(underlying: Tag.bridgeFromJS(TagReference.bridgeJSLiftParameter(underlying))) + let ret = TagReference(underlying: Tag.bridgeJSLiftParameter(underlying)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -257,6 +257,18 @@ fileprivate func _bjs_TagReference_wrap_extern(_ pointer: UnsafeMutableRawPointe return _bjs_TagReference_wrap_extern(pointer) } +extension Polygon: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +extension Tag: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +extension Tagged: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +extension Canvas: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +extension AliasedTag: _BridgedSwiftAlias, _BridgedSwiftAssociatedValueEnum {} + +extension UserId: _BridgedSwiftAlias, _BridgedSwiftStackType {} + #if arch(wasm32) @_extern(wasm, module: "TestModule", name: "bjs_acceptTagged") fileprivate func bjs_acceptTagged_extern(_ taggedBytes: Int32, _ taggedLength: Int32) -> Void @@ -270,7 +282,7 @@ fileprivate func bjs_acceptTagged_extern(_ taggedBytes: Int32, _ taggedLength: I } func _$acceptTagged(_ tagged: Tagged) throws(JSException) -> Void { - tagged.bridgeToJS().bridgeJSWithLoweredParameter { (taggedBytes, taggedLength) in + tagged.bridgeJSWithLoweredParameter { (taggedBytes, taggedLength) in bjs_acceptTagged(taggedBytes, taggedLength) } if let error = _swift_js_take_exception() { @@ -291,9 +303,7 @@ fileprivate func bjs_acceptOptionalTagged_extern(_ taggedIsSome: Int32, _ tagged } func _$acceptOptionalTagged(_ tagged: Optional) throws(JSException) -> Void { - tagged.map { - $0.bridgeToJS() - } .bridgeJSWithLoweredParameter { (taggedIsSome, taggedBytes, taggedLength) in + tagged.bridgeJSWithLoweredParameter { (taggedIsSome, taggedBytes, taggedLength) in bjs_acceptOptionalTagged(taggedIsSome, taggedBytes, taggedLength) } if let error = _swift_js_take_exception() { @@ -314,7 +324,7 @@ fileprivate func bjs_roundtripTagged_extern(_ taggedBytes: Int32, _ taggedLength } func _$roundtripTagged(_ tagged: Tagged) throws(JSException) -> Tagged { - let ret0 = tagged.bridgeToJS().bridgeJSWithLoweredParameter { (taggedBytes, taggedLength) in + let ret0 = tagged.bridgeJSWithLoweredParameter { (taggedBytes, taggedLength) in let ret = bjs_roundtripTagged(taggedBytes, taggedLength) return ret } @@ -322,7 +332,7 @@ func _$roundtripTagged(_ tagged: Tagged) throws(JSException) -> Tagged { if let error = _swift_js_take_exception() { throw error } - return Tagged.bridgeFromJS(String.bridgeJSLiftReturn(ret)) + return Tagged.bridgeJSLiftReturn(ret) } #if arch(wasm32) @@ -342,9 +352,7 @@ func _$produceOptionalCanvas() throws(JSException) -> Optional { if let error = _swift_js_take_exception() { throw error } - return Optional.bridgeJSLiftReturn().map { - Canvas.bridgeFromJS($0) - } + return Optional.bridgeJSLiftReturn() } #if arch(wasm32) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.swift index 3613ead7e..38cc900ae 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AliasInClosure.swift @@ -28,7 +28,7 @@ private enum _BJS_Closure_10TestModuleAl7Polygon_Si { return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - let param0Pointer = param0.bridgeToJS().bridgeJSLowerParameter() + let param0Pointer = param0.bridgeJSLowerParameter() let ret = invoke_js_callback_TestModule_10TestModuleAl7Polygon_Si(callbackValue, param0Pointer) return Int.bridgeJSLiftReturn(ret) #else @@ -54,7 +54,7 @@ extension JSTypedClosure where Signature == (Polygon) -> Int { public func _invoke_swift_closure_TestModule_10TestModuleAl7Polygon_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) let closure = Unmanaged<_BridgeJSTypedClosureBox<(Polygon) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(param0))) + let result = closure(Polygon.bridgeJSLiftParameter(param0)) return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") @@ -92,7 +92,7 @@ private enum _BJS_Closure_10TestModuley_Al7Polygon { #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() let ret = invoke_js_callback_TestModule_10TestModuley_Al7Polygon(callbackValue) - return Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftReturn(ret)) + return Polygon.bridgeJSLiftReturn(ret) #else fatalError("Only available on WebAssembly") #endif @@ -117,7 +117,7 @@ public func _invoke_swift_closure_TestModule_10TestModuley_Al7Polygon(_ boxPtr: #if arch(wasm32) let closure = Unmanaged<_BridgeJSTypedClosureBox<() -> Polygon>>.fromOpaque(boxPtr).takeUnretainedValue().closure let result = closure() - return result.bridgeToJS().bridgeJSLowerReturn() + return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -185,4 +185,6 @@ fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPo #endif @inline(never) fileprivate func _bjs_PolygonReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { return _bjs_PolygonReference_wrap_extern(pointer) -} \ No newline at end of file +} + +extension Polygon: _BridgedSwiftAlias, _BridgedSwiftStackType {} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.json index 6b0d70453..b69bf4012 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/AsyncAssociatedValueEnum.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.swift index 615110c90..1e74a127b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAlias.swift @@ -2,8 +2,8 @@ @_cdecl("bjs_roundtripColor") public func _bjs_roundtripColor(_ color: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundtripColor(_: Color.bridgeFromJS(ColorBox.bridgeJSLiftParameter(color))) - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = roundtripColor(_: Color.bridgeJSLiftParameter(color)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif @@ -49,4 +49,6 @@ fileprivate func _bjs_ColorBox_wrap_extern(_ pointer: UnsafeMutableRawPointer) - #endif @inline(never) fileprivate func _bjs_ColorBox_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { return _bjs_ColorBox_wrap_extern(pointer) -} \ No newline at end of file +} + +extension Color: _BridgedSwiftAlias, _BridgedSwiftStackType {} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.json index 23cb1b0f0..6ba934220 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValueImport.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumCaseImport.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumCaseImport.json index 71bf8679e..f0d534425 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumCaseImport.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumCaseImport.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.json index d1cda5c7d..0d93a993f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftClosureImports.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ ], diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js index c55e429d5..a24c0754b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js @@ -139,6 +139,13 @@ export async function createInstantiator(options, swift) { const copy = memory.buffer.slice(ptr, ptr + byteLen); taStack.push(Array.from(new Ctor(copy))); } + const __bjs_promiseSettlers = Symbol("JavaScriptKit.promiseSettlers"); + bjs["swift_js_make_promise"] = function() { + let resolve, reject; + const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); + promise[__bjs_promiseSettlers] = { resolve, reject }; + return swift.memory.retain(promise); + } bjs["swift_js_return_optional_bool"] = function(isSome, value) { if (isSome === 0) { tmpRetOptionalBool = null; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js index 21c96aed6..dc6e6ccd3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js @@ -131,6 +131,13 @@ export async function createInstantiator(options, swift) { const copy = memory.buffer.slice(ptr, ptr + byteLen); taStack.push(Array.from(new Ctor(copy))); } + const __bjs_promiseSettlers = Symbol("JavaScriptKit.promiseSettlers"); + bjs["swift_js_make_promise"] = function() { + let resolve, reject; + const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); + promise[__bjs_promiseSettlers] = { resolve, reject }; + return swift.memory.retain(promise); + } bjs["swift_js_return_optional_bool"] = function(isSome, value) { if (isSome === 0) { tmpRetOptionalBool = null; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js index 01f0472ab..2a2e89f8c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js @@ -106,6 +106,13 @@ export async function createInstantiator(options, swift) { const copy = memory.buffer.slice(ptr, ptr + byteLen); taStack.push(Array.from(new Ctor(copy))); } + const __bjs_promiseSettlers = Symbol("JavaScriptKit.promiseSettlers"); + bjs["swift_js_make_promise"] = function() { + let resolve, reject; + const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); + promise[__bjs_promiseSettlers] = { resolve, reject }; + return swift.memory.retain(promise); + } bjs["swift_js_return_optional_bool"] = function(isSome, value) { if (isSome === 0) { tmpRetOptionalBool = null; diff --git a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift index bbf8c8f2e..1fbdff0b8 100644 --- a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift +++ b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift @@ -217,6 +217,294 @@ extension Optional: _BridgedAsOptional { public init(optional: Wrapped?) { self = optional } } +// MARK: - _BridgedSwiftAlias + +/// Types that are bridged using a separate JavaScript representation (`@JS(as:)`). +public protocol _BridgedSwiftAlias { + associatedtype JSRepresentation + consuming func bridgeToJS() -> JSRepresentation + static func bridgeFromJS(_ value: consuming JSRepresentation) -> Self +} + +extension _BridgedSwiftAlias where JSRepresentation: _BridgedSwiftHeapObject { + // MARK: ImportTS + @_spi(BridgeJS) public consuming func bridgeJSLowerParameter() -> UnsafeMutableRawPointer { + bridgeToJS().bridgeJSLowerParameter() + } + @_spi(BridgeJS) public static func bridgeJSLiftReturn(_ pointer: UnsafeMutableRawPointer) -> Self { + bridgeFromJS(JSRepresentation.bridgeJSLiftReturn(pointer)) + } + // MARK: ExportSwift + @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ pointer: UnsafeMutableRawPointer) -> Self { + bridgeFromJS(JSRepresentation.bridgeJSLiftParameter(pointer)) + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> UnsafeMutableRawPointer { + bridgeToJS().bridgeJSLowerReturn() + } + // MARK: Stack ABI + @_spi(BridgeJS) public static func bridgeJSStackPop() -> Self { + bridgeFromJS(JSRepresentation.bridgeJSStackPop()) + } + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + bridgeToJS().bridgeJSStackPush() + } +} + +extension _BridgedAsOptional where Wrapped: _BridgedSwiftAlias, Wrapped.JSRepresentation: _BridgedSwiftHeapObject { + @_spi(BridgeJS) public consuming func bridgeJSLowerParameter() -> ( + isSome: Int32, pointer: UnsafeMutableRawPointer + ) { + asOptional.map { $0.bridgeToJS() }.bridgeJSLowerParameter() + } + + @_spi(BridgeJS) public static func bridgeJSLiftReturn(_ pointer: UnsafeMutableRawPointer) -> Self { + Self(optional: Optional.bridgeJSLiftReturn(pointer).map { Wrapped.bridgeFromJS($0) }) + } + + @_spi(BridgeJS) public static func bridgeJSLiftParameter( + _ isSome: Int32, + _ pointer: UnsafeMutableRawPointer + ) -> Self { + Self( + optional: Optional.bridgeJSLiftParameter(isSome, pointer) + .map { Wrapped.bridgeFromJS($0) } + ) + } + + @_spi(BridgeJS) public static func bridgeJSLiftReturnFromSideChannel() -> Self { + Self( + optional: Optional.bridgeJSLiftReturnFromSideChannel() + .map { Wrapped.bridgeFromJS($0) } + ) + } + + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void { + asOptional.map { $0.bridgeToJS() }.bridgeJSLowerReturn() + } +} + +extension _BridgedSwiftAlias where JSRepresentation: _JSBridgedClass { + // MARK: ImportTS + @_spi(BridgeJS) public consuming func bridgeJSLowerParameter() -> Int32 { + bridgeToJS().bridgeJSLowerParameter() + } + @_spi(BridgeJS) public static func bridgeJSLiftReturn(_ id: Int32) -> Self { + bridgeFromJS(JSRepresentation.bridgeJSLiftReturn(id)) + } + // MARK: ExportSwift + @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ id: Int32) -> Self { + bridgeFromJS(JSRepresentation.bridgeJSLiftParameter(id)) + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Int32 { + bridgeToJS().bridgeJSLowerReturn() + } + // MARK: Stack ABI + @_spi(BridgeJS) public static func bridgeJSStackPop() -> Self { + bridgeFromJS(JSRepresentation.bridgeJSStackPop()) + } + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + bridgeToJS().bridgeJSStackPush() + } +} + +extension _BridgedSwiftAlias where JSRepresentation: _BridgedSwiftTypeLoweredIntoSingleWasmCoreType { + // MARK: ImportTS + @_spi(BridgeJS) public consuming func bridgeJSLowerParameter() -> JSRepresentation.WasmCoreType { + bridgeToJS().bridgeJSLowerParameter() + } + @_spi(BridgeJS) public static func bridgeJSLiftReturn(_ value: JSRepresentation.WasmCoreType) -> Self { + bridgeFromJS(JSRepresentation.bridgeJSLiftReturn(value)) + } + // MARK: ExportSwift + @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ value: JSRepresentation.WasmCoreType) -> Self { + bridgeFromJS(JSRepresentation.bridgeJSLiftParameter(value)) + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> JSRepresentation.WasmCoreType { + bridgeToJS().bridgeJSLowerReturn() + } +} + +extension _BridgedSwiftAlias +where + JSRepresentation: _BridgedSwiftTypeLoweredIntoSingleWasmCoreType, JSRepresentation: _BridgedSwiftStackType, + JSRepresentation.StackLiftResult == JSRepresentation +{ + @_spi(BridgeJS) public static func bridgeJSStackPop() -> Self { + bridgeFromJS(JSRepresentation.bridgeJSStackPop()) + } + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + bridgeToJS().bridgeJSStackPush() + } +} + +extension _BridgedAsOptional +where Wrapped: _BridgedSwiftAlias, Wrapped.JSRepresentation: _BridgedSwiftOptionalScalarBridge { + @_spi(BridgeJS) public consuming func bridgeJSLowerParameter() -> ( + isSome: Int32, value: Wrapped.JSRepresentation.WasmCoreType + ) { + asOptional.map { $0.bridgeToJS() }.bridgeJSLowerParameter() + } + @_spi(BridgeJS) public static func bridgeJSLiftParameter( + _ isSome: Int32, + _ value: Wrapped.JSRepresentation.WasmCoreType + ) -> Self { + Self( + optional: Optional.bridgeJSLiftParameter(isSome, value) + .map { Wrapped.bridgeFromJS($0) } + ) + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void { + asOptional.map { $0.bridgeToJS() }.bridgeJSLowerReturn() + } +} + +extension _BridgedAsOptional +where Wrapped: _BridgedSwiftAlias, Wrapped.JSRepresentation: _BridgedSwiftOptionalScalarSideChannelBridge { + @_spi(BridgeJS) public static func bridgeJSLiftReturnFromSideChannel() -> Self { + Self( + optional: Optional.bridgeJSLiftReturnFromSideChannel() + .map { Wrapped.bridgeFromJS($0) } + ) + } +} + +extension _BridgedSwiftAlias where JSRepresentation: _BridgedSwiftStruct { + // MARK: ExportSwift + @_spi(BridgeJS) public static func bridgeJSStackPop() -> Self { + bridgeFromJS(JSRepresentation.bridgeJSStackPop()) + } + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + bridgeToJS().bridgeJSStackPush() + } + + public init(unsafelyCopying jsObject: JSObject) { + self = Self.bridgeFromJS(JSRepresentation(unsafelyCopying: jsObject)) + } + public func toJSObject() -> JSObject { + return self.bridgeToJS().toJSObject() + } +} + +extension _BridgedSwiftAlias where JSRepresentation: _BridgedSwiftCaseEnum { + // MARK: ImportTS + @_spi(BridgeJS) public consuming func bridgeJSLowerParameter() -> Int32 { + bridgeToJS().bridgeJSLowerParameter() + } + @_spi(BridgeJS) public static func bridgeJSLiftReturn(_ value: Int32) -> Self { + bridgeFromJS(JSRepresentation.bridgeJSLiftReturn(value)) + } + // MARK: ExportSwift + @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ value: Int32) -> Self { + bridgeFromJS(JSRepresentation.bridgeJSLiftParameter(value)) + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Int32 { + bridgeToJS().bridgeJSLowerReturn() + } +} + +extension _BridgedSwiftAlias where JSRepresentation: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) public static func bridgeJSStackPopPayload(_ caseId: Int32) -> Self { + bridgeFromJS(JSRepresentation.bridgeJSStackPopPayload(caseId)) + } + @_spi(BridgeJS) public consuming func bridgeJSStackPushPayload() -> Int32 { + bridgeToJS().bridgeJSStackPushPayload() + } +} + +extension _BridgedSwiftAlias where JSRepresentation == String { + // MARK: ImportTS + @_spi(BridgeJS) public consuming func bridgeJSWithLoweredParameter(_ body: (Int32, Int32) -> T) -> T { + bridgeToJS().bridgeJSWithLoweredParameter(body) + } + @_spi(BridgeJS) public static func bridgeJSLiftReturn(_ bytesCount: Int32) -> Self { + bridgeFromJS(String.bridgeJSLiftReturn(bytesCount)) + } + // MARK: ExportSwift + @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ bytes: Int32, _ count: Int32) -> Self { + bridgeFromJS(String.bridgeJSLiftParameter(bytes, count)) + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void { + bridgeToJS().bridgeJSLowerReturn() + } + // MARK: Stack ABI + @_spi(BridgeJS) public static func bridgeJSStackPop() -> Self { + bridgeFromJS(String.bridgeJSStackPop()) + } + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + bridgeToJS().bridgeJSStackPush() + } +} + +extension _BridgedAsOptional where Wrapped: _BridgedSwiftAlias, Wrapped.JSRepresentation == String { + @_spi(BridgeJS) public consuming func bridgeJSWithLoweredParameter( + _ body: (Int32, Int32, Int32) -> T + ) -> T { + asOptional.map { $0.bridgeToJS() }.bridgeJSWithLoweredParameter(body) + } + @_spi(BridgeJS) public static func bridgeJSLiftParameter( + _ isSome: Int32, + _ bytes: Int32, + _ count: Int32 + ) -> Self { + Self(optional: Optional.bridgeJSLiftParameter(isSome, bytes, count).map { Wrapped.bridgeFromJS($0) }) + } + @_spi(BridgeJS) public static func bridgeJSLiftReturnFromSideChannel() -> Self { + Self(optional: Optional.bridgeJSLiftReturnFromSideChannel().map { Wrapped.bridgeFromJS($0) }) + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void { + asOptional.map { $0.bridgeToJS() }.bridgeJSLowerReturn() + } +} + +extension _BridgedSwiftAlias where JSRepresentation == JSValue { + // MARK: ImportTS + @_spi(BridgeJS) public consuming func bridgeJSLowerParameter() -> (kind: Int32, payload1: Int32, payload2: Double) { + bridgeToJS().bridgeJSLowerParameter() + } + @_spi(BridgeJS) public static func bridgeJSLiftReturn() -> Self { + bridgeFromJS(JSValue.bridgeJSLiftReturn()) + } + // MARK: ExportSwift + @_spi(BridgeJS) public static func bridgeJSLiftParameter( + _ kind: Int32, + _ payload1: Int32, + _ payload2: Double + ) -> Self { + bridgeFromJS(JSValue.bridgeJSLiftParameter(kind, payload1, payload2)) + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void { + bridgeToJS().bridgeJSLowerReturn() + } + @_spi(BridgeJS) public static func bridgeJSStackPop() -> Self { + bridgeFromJS(JSValue.bridgeJSStackPop()) + } + @_spi(BridgeJS) public consuming func bridgeJSStackPush() { + bridgeToJS().bridgeJSStackPush() + } +} + +extension _BridgedAsOptional where Wrapped: _BridgedSwiftAlias, Wrapped.JSRepresentation == JSValue { + @_spi(BridgeJS) public consuming func bridgeJSLowerParameter() -> ( + isSome: Int32, kind: Int32, payload1: Int32, payload2: Double + ) { + asOptional.map { $0.bridgeToJS() }.bridgeJSLowerParameter() + } + @_spi(BridgeJS) public static func bridgeJSLiftParameter( + _ isSome: Int32, + _ kind: Int32, + _ payload1: Int32, + _ payload2: Double + ) -> Self { + Self( + optional: Optional.bridgeJSLiftParameter(isSome, kind, payload1, payload2) + .map { Wrapped.bridgeFromJS($0) } + ) + } + @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() -> Void { + asOptional.map { $0.bridgeToJS() }.bridgeJSLowerReturn() + } +} + extension Bool: _BridgedSwiftTypeLoweredIntoSingleWasmCoreType, _BridgedSwiftStackType { // MARK: ImportTS @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { diff --git a/Tests/BridgeJSRuntimeTests/AliasAPIs.swift b/Tests/BridgeJSRuntimeTests/AliasAPIs.swift index bd6737b77..b6d637966 100644 --- a/Tests/BridgeJSRuntimeTests/AliasAPIs.swift +++ b/Tests/BridgeJSRuntimeTests/AliasAPIs.swift @@ -116,46 +116,10 @@ import JavaScriptKit return polygon.vertices.map { Polygon(vertices: [$0], label: polygon.label) } } -@JS(as: TokenReference.self) struct Token: ~Copyable { - let value: Int - - consuming func bridgeToJS() -> TokenReference { - return TokenReference(value: value) - } - - static func bridgeFromJS(_ value: consuming TokenReference) -> Token { - return Token(value: value.value) - } -} - -@JS final class TokenReference { - let value: Int - - @JS init(value: Int) { - self.value = value - } - - @JS func read() -> Int { - return value - } -} - -@JS func incrementToken(_ token: borrowing Token) -> Token { - return Token(value: token.value + 1) -} - -@JS func makeToken(_ value: Int) -> Token { - return Token(value: value) -} - @JS func makePolygonInspector() -> (Polygon) -> Int { return { polygon in polygon.vertices.count } } -@JS func asyncMakePolygon(_ label: String) async -> Polygon { - return Polygon(vertices: [9, 9], label: label) -} - @JS func roundTripOptionalPolygonArray(_ polygons: [Polygon?]) -> [Polygon?] { return polygons } @@ -294,38 +258,6 @@ import JavaScriptKit return Alert(level: level) } -@JS(as: SessionState.self) class Session { - var token: String - - init(token: String) { - self.token = token - } - - consuming func bridgeToJS() -> SessionState { - return SessionState(token: token) - } - - static func bridgeFromJS(_ value: consuming SessionState) -> Session { - return Session(token: value.token) - } -} - -@JS struct SessionState { - var token: String - - @JS init(token: String) { - self.token = token - } -} - -@JS func roundTripSession(_ session: Session) -> Session { - return session -} - -@JS func makeSession(_ token: String) -> Session { - return Session(token: token) -} - @JS enum Shape { case polygon(Polygon) case empty @@ -343,6 +275,30 @@ import JavaScriptKit return .empty } +@JS(as: Int.self) struct UserId { + var rawValue: Int + + consuming func bridgeToJS() -> Int { + return rawValue + } + + static func bridgeFromJS(_ value: consuming Int) -> UserId { + return UserId(rawValue: value) + } +} + +@JS func roundTripUserId(_ id: UserId) -> UserId { + return id +} + +@JS func roundTripOptionalUserId(_ id: UserId?) -> UserId? { + return id +} + +@JS func roundTripUserIdArray(_ ids: [UserId]) -> [UserId] { + return ids +} + // MARK: - Imports @JS(as: String.self) struct Tagged { @@ -391,6 +347,26 @@ import JavaScriptKit } } +@JS(as: JSValue.self) struct Boxed { + var value: JSValue + + consuming func bridgeToJS() -> JSValue { + return value + } + + static func bridgeFromJS(_ value: consuming JSValue) -> Boxed { + return Boxed(value: value) + } +} + +@JS func roundTripBoxed(_ boxed: Boxed) -> Boxed { + return boxed +} + +@JS func roundTripOptionalBoxed(_ boxed: Boxed?) -> Boxed? { + return boxed +} + @JSClass struct AliasImports { @JSFunction static func jsRoundTripTagged(_ value: Tagged) throws(JSException) -> Tagged @JSFunction static func jsRoundTripOptionalTagged(_ value: Tagged?) throws(JSException) -> Tagged? @@ -398,4 +374,6 @@ import JavaScriptKit @JSFunction static func jsRoundTripAliasedTags(_ values: [AliasedTag?]) throws(JSException) -> [AliasedTag?] @JSFunction static func jsRoundTripPolygon(_ value: Polygon) throws(JSException) -> Polygon @JSFunction static func jsRoundTripCoordinate(_ value: Coordinate) throws(JSException) -> Coordinate + @JSFunction static func jsRoundTripUserId(_ value: UserId) throws(JSException) -> UserId + @JSFunction static func jsRoundTripOptionalUserId(_ value: UserId?) throws(JSException) -> UserId? } diff --git a/Tests/BridgeJSRuntimeTests/AliasTests.swift b/Tests/BridgeJSRuntimeTests/AliasTests.swift index 2e4548ec9..d1f0b40a8 100644 --- a/Tests/BridgeJSRuntimeTests/AliasTests.swift +++ b/Tests/BridgeJSRuntimeTests/AliasTests.swift @@ -10,10 +10,6 @@ final class AliasTests: XCTestCase { runAliasWorks() } - func testAliasAsyncEndToEnd() async throws { - try await runAliasAsyncWorks() - } - // MARK: - Imports func testRoundTripTagged() throws { @@ -69,4 +65,15 @@ final class AliasTests: XCTestCase { XCTAssertEqual(echoed.latitude, 12.5) XCTAssertEqual(echoed.longitude, -34.25) } + + func testRoundTripUserIdImport() throws { + let echoed = try AliasImports.jsRoundTripUserId(UserId(rawValue: 42)) + XCTAssertEqual(echoed.rawValue, 42) + } + + func testRoundTripOptionalUserIdImport() throws { + XCTAssertNil(try AliasImports.jsRoundTripOptionalUserId(nil)) + XCTAssertEqual(try AliasImports.jsRoundTripOptionalUserId(UserId(rawValue: 0))?.rawValue, 0) + XCTAssertEqual(try AliasImports.jsRoundTripOptionalUserId(UserId(rawValue: 7))?.rawValue, 7) + } } diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift index b2f7795cc..08d0db2a7 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift @@ -44,8 +44,6 @@ extension FeatureFlag: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum {} @JSFunction func runAsyncWorks() async throws(JSException) -> Void -@JSFunction func runAliasAsyncWorks() async throws(JSException) -> Void - @JSFunction func fetchWeatherData(_ city: String) async throws(JSException) -> WeatherData @JSClass struct WeatherData { diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift index 1192d4b33..8968773a4 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift @@ -674,7 +674,7 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsAl7Polygon_Si { return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - let param0Pointer = param0.bridgeToJS().bridgeJSLowerParameter() + let param0Pointer = param0.bridgeJSLowerParameter() let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si(callbackValue, param0Pointer) return Int.bridgeJSLiftReturn(ret) #else @@ -700,13 +700,179 @@ extension JSTypedClosure where Signature == (Polygon) -> Int { public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsAl7Polygon_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) let closure = Unmanaged<_BridgeJSTypedClosureBox<(Polygon) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure(Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(param0))) + let result = closure(Polygon.bridgeJSLiftParameter(param0)) return result.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsKSS_Sb { + static func bridgeJSLift(_ callbackId: Int32) -> (String) throws(JSException) -> Bool { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) throws(JSException) -> Bool in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(callbackValue, param0Bytes, param0Length) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return Bool.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) throws(JSException) -> Bool { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) throws(JSException) -> Bool) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Sb(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) throws(JSException) -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure + do { + let result = try closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 +#else +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(callback, param0Bytes, param0Length) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +#else +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si_extern(boxPtr, file, line) +} + +private enum _BJS_Closure_20BridgeJSRuntimeTestsKSS_Si { + static func bridgeJSLift(_ callbackId: Int32) -> (String) throws(JSException) -> Int { + let callback = JSObject.bridgeJSLiftParameter(callbackId) + return { [callback] (param0: String) throws(JSException) -> Int in + #if arch(wasm32) + let callbackValue = callback.bridgeJSLowerParameter() + let ret0 = param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(callbackValue, param0Bytes, param0Length) + return ret + } + let ret = ret0 + if let error = _swift_js_take_exception() { + throw error + } + return Int.bridgeJSLiftReturn(ret) + #else + fatalError("Only available on WebAssembly") + #endif + } + } +} + +extension JSTypedClosure where Signature == (String) throws(JSException) -> Int { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) throws(JSException) -> Int) { + self.init( + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si, + body: body, + fileID: fileID, + line: line + ) + } +} + +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsKSS_Si(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) throws(JSException) -> Int>>.fromOpaque(boxPtr).takeUnretainedValue().closure + do { + let result = try closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + return result.bridgeJSLowerReturn() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #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 @@ -1865,38 +2031,45 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsSqS } #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 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ 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) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(resolveRef, rejectRef, 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 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_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 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_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) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestss11FeatureFlagO_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending FeatureFlag) -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestsYaKSS_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (String) async throws(JSException) -> String { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in + return { [callback] (param0: String) async throws(JSException) -> String in #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(callbackValue, param0Bytes, param0Length) + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending String) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) + } } + return resolved #else fatalError("Only available on WebAssembly") #endif @@ -1904,10 +2077,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestss11FeatureFlagO_y { } } -extension JSTypedClosure where Signature == (sending FeatureFlag) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending FeatureFlag) -> Void) { +extension JSTypedClosure where Signature == (String) async throws(JSException) -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async throws(JSException) -> String) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS, body: body, fileID: fileID, line: line @@ -1915,49 +2088,58 @@ extension JSTypedClosure where Signature == (sending FeatureFlag) -> Void { } } -@_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 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending FeatureFlag) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(FeatureFlag.bridgeJSLiftParameter(param0Bytes, param0Length)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) async throws(JSException) -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { () async throws(JSException) -> String in + return try await closure(String.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 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ callback: Int32, _ param0: Int32) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: 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) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(resolveRef, rejectRef, callback, param0Bytes, param0Length) } #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 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_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 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_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) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestss11WeatherDataC_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending WeatherData) -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestsYaKSS_y { + static func bridgeJSLift(_ callbackId: Int32) -> (String) async throws(JSException) -> Void { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in + return { [callback] (param0: String) async throws(JSException) -> Void in #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let param0Value = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(callbackValue, param0Value) + try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<() -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) + } + } #else fatalError("Only available on WebAssembly") #endif @@ -1965,10 +2147,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestss11WeatherDataC_y { } } -extension JSTypedClosure where Signature == (sending WeatherData) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending WeatherData) -> Void) { +extension JSTypedClosure where Signature == (String) async throws(JSException) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async throws(JSException) -> Void) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y, body: body, fileID: fileID, line: line @@ -1976,49 +2158,58 @@ extension JSTypedClosure where Signature == (sending WeatherData) -> Void { } } -@_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 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSS_y(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending WeatherData) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(WeatherData.bridgeJSLiftParameter(param0)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) async throws(JSException) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_y, reject: Promise_reject) { () async throws(JSException) in + try await closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + } #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 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> 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) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(resolveRef, rejectRef, callback, param0) } #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 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_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 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_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) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestss7JSValueV_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending JSValue) -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO { + static func bridgeJSLift(_ callbackId: Int32) -> (Bool) async throws(JSException) -> AsyncPayloadResult { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in + return { [callback] (param0: Bool) async throws(JSException) -> AsyncPayloadResult in #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let (param0Kind, param0Payload1, param0Payload2) = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y(callbackValue, param0Kind, param0Payload1, param0Payload2) + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending AsyncPayloadResult) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(resolveRef, rejectRef, callbackValue, param0Value) + } + return resolved #else fatalError("Only available on WebAssembly") #endif @@ -2026,10 +2217,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestss7JSValueV_y { } } -extension JSTypedClosure where Signature == (sending JSValue) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending JSValue) -> Void) { +extension JSTypedClosure where Signature == (Bool) async throws(JSException) -> AsyncPayloadResult { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Bool) async throws(JSException) -> AsyncPayloadResult) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO, body: body, fileID: fileID, line: line @@ -2037,50 +2228,59 @@ extension JSTypedClosure where Signature == (sending JSValue) -> Void { } } -@_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 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending JSValue) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(JSValue.bridgeJSLiftParameter(param0Kind, param0Payload1, param0Payload2)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Bool) async throws(JSException) -> AsyncPayloadResult>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_18AsyncPayloadResultO, reject: Promise_reject) { () async throws(JSException) -> AsyncPayloadResult in + return try await closure(Bool.bridgeJSLiftParameter(param0)) + } #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 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y_extern(_ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ 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) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(resolveRef, rejectRef, 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 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_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 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_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) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestssSS_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending String) -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestsYaSS_SS { + static func bridgeJSLift(_ callbackId: Int32) -> (String) async -> String { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in + return { [callback] (param0: String) async -> String in #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(callbackValue, param0Bytes, param0Length) + let resolved = try! await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending String) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS(resolveRef, rejectRef, callbackValue, param0Bytes, param0Length) + } } + return resolved #else fatalError("Only available on WebAssembly") #endif @@ -2088,10 +2288,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestssSS_y { } } -extension JSTypedClosure where Signature == (sending String) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending String) -> Void) { +extension JSTypedClosure where Signature == (String) async -> String { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (String) async -> String) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS, body: body, fileID: fileID, line: line @@ -2099,49 +2299,58 @@ extension JSTypedClosure where Signature == (sending String) -> Void { } } -@_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 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSS_SS(_ boxPtr: UnsafeMutableRawPointer, _ param0Bytes: Int32, _ param0Length: Int32) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending String) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(String.bridgeJSLiftParameter(param0Bytes, param0Length)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(String) async -> String>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { + return await 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 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Float64) -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y_extern(_ callback: Int32) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Float64) -> 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) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV(_ resolveRef: Int32, _ rejectRef: Int32, _ callback: Int32, _ param0: Float64) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(resolveRef, rejectRef, callback, param0) } #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 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_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 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_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) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSS_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending [String]) -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestsYaSd_9DataPointV { + static func bridgeJSLift(_ callbackId: Int32) -> (Double) async -> DataPoint { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] param0 in + return { [callback] (param0: Double) async -> DataPoint in #if arch(wasm32) - let callbackValue = callback.bridgeJSLowerParameter() - let _ = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(callbackValue) + let resolved = try! await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending DataPoint) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let callbackValue = callback.bridgeJSLowerParameter() + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV(resolveRef, rejectRef, callbackValue, param0Value) + } + return resolved #else fatalError("Only available on WebAssembly") #endif @@ -2149,10 +2358,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSS_y { } } -extension JSTypedClosure where Signature == (sending [String]) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending [String]) -> Void) { +extension JSTypedClosure where Signature == (Double) async -> DataPoint { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (Double) async -> DataPoint) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV, body: body, fileID: fileID, line: line @@ -2160,49 +2369,52 @@ extension JSTypedClosure where Signature == (sending [String]) -> Void { } } -@_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 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsYaSd_9DataPointV(_ boxPtr: UnsafeMutableRawPointer, _ param0: Float64) -> Int32 { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending [String]) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure([String].bridgeJSLiftParameter()) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(Double) async -> DataPoint>>.fromOpaque(boxPtr).takeUnretainedValue().closure + return _bjs_makePromise(resolve: Promise_resolve_9DataPointV, reject: Promise_reject) { + return await closure(Double.bridgeJSLiftParameter(param0)) + } #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 +@_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_20BridgeJSRuntimeTestssSaSb_y_extern(_ callback: Int32) -> Void { +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_20BridgeJSRuntimeTestssSaSb_y(_ callback: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(callback) +@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_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 { +@_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_20BridgeJSRuntimeTestssSaSb_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestssSaSb_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending [Bool]) -> Void { +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() - let _ = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y(callbackValue) + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y(callbackValue, param0Bytes, param0Length) + } #else fatalError("Only available on WebAssembly") #endif @@ -2210,10 +2422,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSb_y { } } -extension JSTypedClosure where Signature == (sending [Bool]) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending [Bool]) -> Void) { +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_20BridgeJSRuntimeTestssSaSb_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11FeatureFlagO_y, body: body, fileID: fileID, line: line @@ -2221,49 +2433,49 @@ extension JSTypedClosure where Signature == (sending [Bool]) -> Void { } } -@_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 { +@_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 [Bool]) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure([Bool].bridgeJSLiftParameter()) + 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_20BridgeJSRuntimeTestssSaSd_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(_ callback: Int32) -> Void +@_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_20BridgeJSRuntimeTestssSaSd_y_extern(_ callback: Int32) -> Void { +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_20BridgeJSRuntimeTestssSaSd_y(_ callback: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(callback) +@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_20BridgeJSRuntimeTestssSaSd_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestssSaSd_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestssSaSd_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestssSaSd_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending [Double]) -> Void { +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 _ = param0.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y(callbackValue) + let param0Value = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(callbackValue, param0Value) #else fatalError("Only available on WebAssembly") #endif @@ -2271,10 +2483,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSd_y { } } -extension JSTypedClosure where Signature == (sending [Double]) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending [Double]) -> Void) { +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_20BridgeJSRuntimeTestssSaSd_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y, body: body, fileID: fileID, line: line @@ -2282,49 +2494,49 @@ extension JSTypedClosure where Signature == (sending [Double]) -> Void { } } -@_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 { +@_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 [Double]) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure([Double].bridgeJSLiftParameter()) + 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_20BridgeJSRuntimeTestssSb_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(_ callback: Int32, _ param0: Int32) -> Void +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y_extern(_ callback: Int32, _ param0: Int32) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_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) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_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 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_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 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_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) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestssSb_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending Bool) -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending AsyncPayloadResult) -> 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) + let param0CaseId = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(callbackValue, param0CaseId) #else fatalError("Only available on WebAssembly") #endif @@ -2332,10 +2544,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestssSb_y { } } -extension JSTypedClosure where Signature == (sending Bool) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Bool) -> Void) { +extension JSTypedClosure where Signature == (sending AsyncPayloadResult) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending AsyncPayloadResult) -> Void) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSb_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y, body: body, fileID: fileID, line: line @@ -2343,49 +2555,49 @@ extension JSTypedClosure where Signature == (sending Bool) -> Void { } } -@_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 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss18AsyncPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Bool) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(Bool.bridgeJSLiftParameter(param0)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending AsyncPayloadResult) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(AsyncPayloadResult.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 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(_ callback: Int32, _ param0: Float64) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0: Int32) -> 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) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(_ callback: Int32, _ param0: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_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 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_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 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_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) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestssSd_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending Double) -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending AsyncImportedPayloadResult) -> 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) + let param0CaseId = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(callbackValue, param0CaseId) #else fatalError("Only available on WebAssembly") #endif @@ -2393,10 +2605,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestssSd_y { } } -extension JSTypedClosure where Signature == (sending Double) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Double) -> Void) { +extension JSTypedClosure where Signature == (sending AsyncImportedPayloadResult) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending AsyncImportedPayloadResult) -> Void) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y, body: body, fileID: fileID, line: line @@ -2404,50 +2616,49 @@ extension JSTypedClosure where Signature == (sending Double) -> Void { } } -@_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 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Double) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(Double.bridgeJSLiftParameter(param0)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending AsyncImportedPayloadResult) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(AsyncImportedPayloadResult.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 +@_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_20BridgeJSRuntimeTestssSqSS_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { +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_20BridgeJSRuntimeTestssSqSS_y(_ callback: Int32, _ param0IsSome: Int32, _ param0Bytes: Int32, _ param0Length: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(callback, param0IsSome, param0Bytes, param0Length) +@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_20BridgeJSRuntimeTestssSqSS_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestssSqSS_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestssSqSS_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestssSqSS_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending Optional) -> Void { +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() - param0.bridgeJSWithLoweredParameter { (param0IsSome, param0Bytes, param0Length) in - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSS_y(callbackValue, param0IsSome, param0Bytes, param0Length) - } + let (param0Kind, param0Payload1, param0Payload2) = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y(callbackValue, param0Kind, param0Payload1, param0Payload2) #else fatalError("Only available on WebAssembly") #endif @@ -2455,10 +2666,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestssSqSS_y { } } -extension JSTypedClosure where Signature == (sending Optional) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Optional) -> Void) { +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_20BridgeJSRuntimeTestssSqSS_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y, body: body, fileID: fileID, line: line @@ -2466,49 +2677,49 @@ extension JSTypedClosure where Signature == (sending Optional) -> Void { } } -@_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 { +@_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 Optional) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Bytes, param0Length)) + 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_20BridgeJSRuntimeTestssSqSd_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float64) -> Void +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(_ callback: Int32) -> Void #else -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0Value: Float64) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(_ callback: Int32) -> 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) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y(_ callback: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(callback) } #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 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_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 { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_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) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y_extern(boxPtr, file, line) } -private enum _BJS_Closure_20BridgeJSRuntimeTestssSqSd_y { - static func bridgeJSLift(_ callbackId: Int32) -> (sending Optional) -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestss9DataPointV_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending DataPoint) -> 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) + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y(callbackValue) #else fatalError("Only available on WebAssembly") #endif @@ -2516,10 +2727,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestssSqSd_y { } } -extension JSTypedClosure where Signature == (sending Optional) -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending Optional) -> Void) { +extension JSTypedClosure where Signature == (sending DataPoint) -> Void { + init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending DataPoint) -> Void) { self.init( - makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSqSd_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y, body: body, fileID: fileID, line: line @@ -2527,49 +2738,50 @@ extension JSTypedClosure where Signature == (sending Optional) -> Void { } } -@_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 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss9DataPointV_y(_ boxPtr: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Optional) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure(Optional.bridgeJSLiftParameter(param0IsSome, param0Value)) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending DataPoint) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(DataPoint.bridgeJSLiftParameter()) #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 +@_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_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ callback: Int32) -> Int32 { +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_20BridgeJSRuntimeTestsy_13DataProcessorP(_ callback: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(callback) +@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_20BridgeJSRuntimeTestsy_13DataProcessorP") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestsy_13DataProcessorP(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestsy_13DataProcessorP { - static func bridgeJSLift(_ callbackId: Int32) -> () -> any DataProcessor { +private enum _BJS_Closure_20BridgeJSRuntimeTestssSS_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending String) -> Void { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] in + return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP(callbackValue) - return AnyDataProcessor.bridgeJSLiftReturn(ret) + param0.bridgeJSWithLoweredParameter { (param0Bytes, param0Length) in + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y(callbackValue, param0Bytes, param0Length) + } #else fatalError("Only available on WebAssembly") #endif @@ -2577,10 +2789,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsy_13DataProcessorP { } } -extension JSTypedClosure where Signature == () -> any DataProcessor { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> any DataProcessor) { +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_20BridgeJSRuntimeTestsy_13DataProcessorP, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSS_y, body: body, fileID: fileID, line: line @@ -2588,50 +2800,49 @@ extension JSTypedClosure where Signature == () -> any DataProcessor { } } -@_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 { +@_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<() -> any DataProcessor>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure() - return (result as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn() + 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_20BridgeJSRuntimeTestsy_Sb") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(_ callback: Int32) -> Int32 +@_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_20BridgeJSRuntimeTestsy_Sb_extern(_ callback: Int32) -> Int32 { +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_20BridgeJSRuntimeTestsy_Sb(_ callback: Int32) -> Int32 { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(callback) +@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_20BridgeJSRuntimeTestsy_Sb") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestsy_Sb_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestsy_Sb(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestsy_Sb { - static func bridgeJSLift(_ callbackId: Int32) -> () -> Bool { +private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSS_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending [String]) -> Void { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] in + return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb(callbackValue) - return Bool.bridgeJSLiftReturn(ret) + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y(callbackValue) #else fatalError("Only available on WebAssembly") #endif @@ -2639,10 +2850,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsy_Sb { } } -extension JSTypedClosure where Signature == () -> Bool { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> Bool) { +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_20BridgeJSRuntimeTestsy_Sb, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSS_y, body: body, fileID: fileID, line: line @@ -2650,50 +2861,49 @@ extension JSTypedClosure where Signature == () -> Bool { } } -@_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 { +@_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<() -> Bool>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure() - return result.bridgeJSLowerReturn() + 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_20BridgeJSRuntimeTestsy_Sq7GreeterC") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ callback: Int32) -> UnsafeMutableRawPointer +@_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_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ callback: Int32) -> UnsafeMutableRawPointer { +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_20BridgeJSRuntimeTestsy_Sq7GreeterC(_ callback: Int32) -> UnsafeMutableRawPointer { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(callback) +@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_20BridgeJSRuntimeTestsy_Sq7GreeterC") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestsy_Sq7GreeterC(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestsy_Sq7GreeterC { - static func bridgeJSLift(_ callbackId: Int32) -> () -> Optional { +private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSb_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending [Bool]) -> Void { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] in + return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - let ret = invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC(callbackValue) - return Optional.bridgeJSLiftReturn(ret) + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y(callbackValue) #else fatalError("Only available on WebAssembly") #endif @@ -2701,10 +2911,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsy_Sq7GreeterC { } } -extension JSTypedClosure where Signature == () -> Optional { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> Optional) { +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_20BridgeJSRuntimeTestsy_Sq7GreeterC, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSb_y, body: body, fileID: fileID, line: line @@ -2712,49 +2922,49 @@ extension JSTypedClosure where Signature == () -> Optional { } } -@_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 { +@_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<() -> Optional>>.fromOpaque(boxPtr).takeUnretainedValue().closure - let result = closure() - return result.bridgeJSLowerReturn() + 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_20BridgeJSRuntimeTestsy_y") -fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(_ callback: Int32) -> Void +@_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_20BridgeJSRuntimeTestsy_y_extern(_ callback: Int32) -> Void { +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_20BridgeJSRuntimeTestsy_y(_ callback: Int32) -> Void { - return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(callback) +@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_20BridgeJSRuntimeTestsy_y") -fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 +@_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_20BridgeJSRuntimeTestsy_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { +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_20BridgeJSRuntimeTestsy_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { - return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(boxPtr, file, line) +@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_20BridgeJSRuntimeTestsy_y { - static func bridgeJSLift(_ callbackId: Int32) -> () -> Void { +private enum _BJS_Closure_20BridgeJSRuntimeTestssSaSd_y { + static func bridgeJSLift(_ callbackId: Int32) -> (sending [Double]) -> Void { let callback = JSObject.bridgeJSLiftParameter(callbackId) - return { [callback] in + return { [callback] param0 in #if arch(wasm32) let callbackValue = callback.bridgeJSLowerParameter() - invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y(callbackValue) + let _ = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y(callbackValue) #else fatalError("Only available on WebAssembly") #endif @@ -2762,10 +2972,10 @@ private enum _BJS_Closure_20BridgeJSRuntimeTestsy_y { } } -extension JSTypedClosure where Signature == () -> Void { - init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping () -> Void) { +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_20BridgeJSRuntimeTestsy_y, + makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSaSd_y, body: body, fileID: fileID, line: line @@ -2773,683 +2983,1235 @@ extension JSTypedClosure where Signature == () -> Void { } } -@_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 { +@_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<() -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure - closure() + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending [Double]) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure([Double].bridgeJSLiftParameter()) #else fatalError("Only available on WebAssembly") #endif } -struct AnyArrayElementProtocol: ArrayElementProtocol, _BridgedSwiftProtocolWrapper { - let jsObject: JSObject +#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) +} - 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) +#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 } } +} - static func bridgeJSLiftParameter(_ value: Int32) -> Self { - return AnyArrayElementProtocol(jsObject: JSObject(id: UInt32(bitPattern: value))) +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: "BridgeJSRuntimeTests", name: "bjs_ArrayElementProtocol_value_get") -fileprivate func bjs_ArrayElementProtocol_value_get_extern(_ jsObject: Int32) -> Int32 +@_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 bjs_ArrayElementProtocol_value_get_extern(_ jsObject: Int32) -> Int32 { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSd_y_extern(_ callback: Int32, _ param0: Float64) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func bjs_ArrayElementProtocol_value_get(_ jsObject: Int32) -> Int32 { - return bjs_ArrayElementProtocol_value_get_extern(jsObject) +@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: "BridgeJSRuntimeTests", name: "bjs_ArrayElementProtocol_value_set") -fileprivate func bjs_ArrayElementProtocol_value_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void +@_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 bjs_ArrayElementProtocol_value_set_extern(_ jsObject: Int32, _ newValue: Int32) -> Void { +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 bjs_ArrayElementProtocol_value_set(_ jsObject: Int32, _ newValue: Int32) -> Void { - return bjs_ArrayElementProtocol_value_set_extern(jsObject, newValue) +@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) } -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) - } +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 } } +} - 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))) +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 + ) } } -#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 { +@_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 -@inline(never) fileprivate func _extern_increment(_ jsObject: Int32, _ amount: Int32) -> Void { - return _extern_increment_extern(jsObject, amount) + #endif } #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_getValue") -fileprivate func _extern_getValue_extern(_ jsObject: Int32) -> Int32 +@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void #else -fileprivate func _extern_getValue_extern(_ jsObject: Int32) -> Int32 { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _extern_getValue(_ jsObject: Int32) -> Int32 { - return _extern_getValue_extern(jsObject) +@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(_ callback: Int32, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { + return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(callback, param0IsSome, param0CaseId) } #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 +@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 #else -fileprivate func _extern_setLabelElements_extern(_ jsObject: Int32, _ labelPrefixBytes: Int32, _ labelPrefixLength: Int32, _ labelSuffixBytes: Int32, _ labelSuffixLength: Int32) -> Void { +fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { 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) +@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer, _ line: UInt32) -> Int32 { + return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y_extern(boxPtr, file, line) } -#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") +private enum _BJS_Closure_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_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, param0CaseId) = param0.bridgeJSLowerParameter() + invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(callbackValue, param0IsSome, param0CaseId) + #else + fatalError("Only available on WebAssembly") + #endif + } + } } -#endif -@inline(never) fileprivate func _extern_getLabel(_ jsObject: Int32) -> Int32 { - return _extern_getLabel_extern(jsObject) + +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_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y, + body: body, + fileID: fileID, + line: line + ) + } } -#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 { +@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") +@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y") +public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestssSq26AsyncImportedPayloadResultO_y(_ boxPtr: UnsafeMutableRawPointer, _ param0IsSome: Int32, _ param0CaseId: Int32) -> Void { + #if arch(wasm32) + let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending Optional) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure + closure(Optional.bridgeJSLiftParameter(param0IsSome, param0CaseId)) + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _extern_isEven(_ jsObject: Int32) -> Int32 { - return _extern_isEven_extern(jsObject) + #endif } #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_processGreeter") -fileprivate func _extern_processGreeter_extern(_ jsObject: Int32, _ greeter: UnsafeMutableRawPointer) -> Int32 +@_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 _extern_processGreeter_extern(_ jsObject: Int32, _ greeter: UnsafeMutableRawPointer) -> Int32 { +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 _extern_processGreeter(_ jsObject: Int32, _ greeter: UnsafeMutableRawPointer) -> Int32 { - return _extern_processGreeter_extern(jsObject, greeter) +@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: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_createGreeter") -fileprivate func _extern_createGreeter_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer +@_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 _extern_createGreeter_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer { +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 _extern_createGreeter(_ jsObject: Int32) -> UnsafeMutableRawPointer { - return _extern_createGreeter_extern(jsObject) +@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) } -#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") +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 + } + } } -#endif -@inline(never) fileprivate func _extern_processOptionalGreeter(_ jsObject: Int32, _ greeterIsSome: Int32, _ greeterPointer: UnsafeMutableRawPointer) -> Int32 { - return _extern_processOptionalGreeter_extern(jsObject, greeterIsSome, greeterPointer) + +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 + ) + } } -#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 { +@_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 -@inline(never) fileprivate func _extern_createOptionalGreeter(_ jsObject: Int32) -> UnsafeMutableRawPointer { - return _extern_createOptionalGreeter_extern(jsObject) + #endif } #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_handleAPIResult") -fileprivate func _extern_handleAPIResult_extern(_ jsObject: Int32, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void +@_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 _extern_handleAPIResult_extern(_ jsObject: Int32, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void { +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 _extern_handleAPIResult(_ jsObject: Int32, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void { - return _extern_handleAPIResult_extern(jsObject, resultIsSome, resultCaseId) +@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: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_getAPIResult") -fileprivate func _extern_getAPIResult_extern(_ jsObject: Int32) -> Int32 +@_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 _extern_getAPIResult_extern(_ jsObject: Int32) -> Int32 { +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 _extern_getAPIResult(_ jsObject: Int32) -> Int32 { - return _extern_getAPIResult_extern(jsObject) +@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) } -#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") +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 + } + } } -#endif -@inline(never) fileprivate func bjs_DataProcessor_count_get(_ jsObject: Int32) -> Int32 { - return bjs_DataProcessor_count_get_extern(jsObject) + +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 + ) + } } -#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 { +@_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 -@inline(never) fileprivate func bjs_DataProcessor_count_set(_ jsObject: Int32, _ newValue: Int32) -> Void { - return bjs_DataProcessor_count_set_extern(jsObject, newValue) + #endif } #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_name_get") -fileprivate func bjs_DataProcessor_name_get_extern(_ jsObject: Int32) -> Int32 +@_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 bjs_DataProcessor_name_get_extern(_ jsObject: Int32) -> Int32 { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_13DataProcessorP_extern(_ callback: 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) +@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: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalTag_get") -fileprivate func bjs_DataProcessor_optionalTag_get_extern(_ jsObject: Int32) -> Void +@_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 bjs_DataProcessor_optionalTag_get_extern(_ jsObject: Int32) -> Void { +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 bjs_DataProcessor_optionalTag_get(_ jsObject: Int32) -> Void { - return bjs_DataProcessor_optionalTag_get_extern(jsObject) +@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: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalTag_set") -fileprivate func bjs_DataProcessor_optionalTag_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void +@_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 bjs_DataProcessor_optionalTag_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sb_extern(_ callback: Int32) -> Int32 { 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) +@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: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalCount_get") -fileprivate func bjs_DataProcessor_optionalCount_get_extern(_ jsObject: Int32) -> Void +@_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 bjs_DataProcessor_optionalCount_get_extern(_ jsObject: Int32) -> Void { +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 bjs_DataProcessor_optionalCount_get(_ jsObject: Int32) -> Void { - return bjs_DataProcessor_optionalCount_get_extern(jsObject) +@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: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_optionalCount_set") -fileprivate func bjs_DataProcessor_optionalCount_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void +@_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 bjs_DataProcessor_optionalCount_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_Sq7GreeterC_extern(_ callback: Int32) -> UnsafeMutableRawPointer { 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) +@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: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_direction_get") -fileprivate func bjs_DataProcessor_direction_get_extern(_ jsObject: Int32) -> Int32 +@_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 bjs_DataProcessor_direction_get_extern(_ jsObject: Int32) -> Int32 { +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 bjs_DataProcessor_direction_get(_ jsObject: Int32) -> Int32 { - return bjs_DataProcessor_direction_get_extern(jsObject) +@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) } -#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) +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 + } + } } -#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) +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 + ) + } } -#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 { +@_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 -@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) + #endif } #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_httpStatus_get") -fileprivate func bjs_DataProcessor_httpStatus_get_extern(_ jsObject: Int32) -> Void +@_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 bjs_DataProcessor_httpStatus_get_extern(_ jsObject: Int32) -> Void { +fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestsy_y_extern(_ callback: 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) +@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: "BridgeJSRuntimeTests", name: "bjs_DataProcessor_httpStatus_set") -fileprivate func bjs_DataProcessor_httpStatus_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void +@_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 bjs_DataProcessor_httpStatus_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { +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 bjs_DataProcessor_httpStatus_set(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValueValue: Int32) -> Void { - return bjs_DataProcessor_httpStatus_set_extern(jsObject, newValueIsSome, newValueValue) +@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) } -#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) +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 + } + } } -#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) +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 + ) + } } -#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 { +@_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 -@inline(never) fileprivate func bjs_DataProcessor_helper_get(_ jsObject: Int32) -> UnsafeMutableRawPointer { - return bjs_DataProcessor_helper_get_extern(jsObject) + #endif } -#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) +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_DataProcessor_optionalHelper_get") -fileprivate func bjs_DataProcessor_optionalHelper_get_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ArrayElementProtocol_value_get") +fileprivate func bjs_ArrayElementProtocol_value_get_extern(_ jsObject: Int32) -> Int32 #else -fileprivate func bjs_DataProcessor_optionalHelper_get_extern(_ jsObject: Int32) -> UnsafeMutableRawPointer { +fileprivate func bjs_ArrayElementProtocol_value_get_extern(_ jsObject: Int32) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func bjs_DataProcessor_optionalHelper_get(_ jsObject: Int32) -> UnsafeMutableRawPointer { - return bjs_DataProcessor_optionalHelper_get_extern(jsObject) +@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_DataProcessor_optionalHelper_set") -fileprivate func bjs_DataProcessor_optionalHelper_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValuePointer: UnsafeMutableRawPointer) -> Void +@_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_DataProcessor_optionalHelper_set_extern(_ jsObject: Int32, _ newValueIsSome: Int32, _ newValuePointer: UnsafeMutableRawPointer) -> Void { +fileprivate func bjs_ArrayElementProtocol_value_set_extern(_ jsObject: Int32, _ newValue: Int32) -> 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) +@inline(never) fileprivate func bjs_ArrayElementProtocol_value_set(_ jsObject: Int32, _ newValue: Int32) -> Void { + return bjs_ArrayElementProtocol_value_set_extern(jsObject, newValue) } -extension Severity: _BridgedSwiftCaseEnum { - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { - return bridgeJSRawValue - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Severity { - return bridgeJSLiftParameter(value) - } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Severity { - return Severity(bridgeJSRawValue: value)! +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) } - @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { - return bridgeJSLowerParameter() + + func getValue() -> Int { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = _extern_getValue(jsObjectValue) + return Int.bridgeJSLiftReturn(ret) } - @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .notice - case 1: - self = .warning - case 2: - self = .error - default: - return nil + 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) + } } } - @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { - switch self { - case .notice: - return 0 - case .warning: - return 1 - case .error: - return 2 - } + func getLabel() -> String { + let jsObjectValue = jsObject.bridgeJSLowerParameter() + let ret = _extern_getLabel(jsObjectValue) + return String.bridgeJSLiftReturn(ret) } -} -extension Shape: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> Shape { - switch caseId { - case 0: - return .polygon(Polygon.bridgeFromJS(PolygonReference.bridgeJSStackPop())) - case 1: - return .empty - default: - fatalError("Unknown Shape case ID: \(caseId)") - } + 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) +} + +extension Severity: _BridgedSwiftCaseEnum { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { + return bridgeJSRawValue + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Severity { + return bridgeJSLiftParameter(value) + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Severity { + return Severity(bridgeJSRawValue: value)! + } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { + return bridgeJSLowerParameter() + } + + @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .notice + case 1: + self = .warning + case 2: + self = .error + default: + return nil + } + } + + @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { + switch self { + case .notice: + return 0 + case .warning: + return 1 + case .error: + return 2 + } + } +} + +extension Shape: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> Shape { + switch caseId { + case 0: + return .polygon(Polygon.bridgeJSStackPop()) + case 1: + return .empty + default: + fatalError("Unknown Shape case ID: \(caseId)") + } } @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { switch self { case .polygon(let param0): - param0.bridgeToJS().bridgeJSStackPush() + param0.bridgeJSStackPush() return Int32(0) case .empty: return Int32(1) @@ -3964,6 +4726,34 @@ public func _bjs_ArraySupportExports_static_multiOptionalArraySecond() -> Void { #endif } +extension AsyncImportedPayloadResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> AsyncImportedPayloadResult { + switch caseId { + case 0: + return .success(String.bridgeJSStackPop()) + case 1: + return .failure(Int.bridgeJSStackPop()) + case 2: + return .idle + default: + fatalError("Unknown AsyncImportedPayloadResult 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 .idle: + return Int32(2) + } + } +} + @_expose(wasm, "bjs_DefaultArgumentExports_static_testStringDefault") @_cdecl("bjs_DefaultArgumentExports_static_testStringDefault") public func _bjs_DefaultArgumentExports_static_testStringDefault(_ messageBytes: Int32, _ messageLength: Int32) -> Void { @@ -4052,192 +4842,621 @@ public func _bjs_DefaultArgumentExports_static_testRawStringEnumDefault(_ themeB #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_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() + } + + @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .north + case 1: + self = .south + case 2: + self = .east + case 3: + self = .west + default: + return nil + } + } + + @_spi(BridgeJS) @usableFromInline 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() + } + + @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .loading + case 1: + self = .success + case 2: + self = .error + default: + return nil + } + } + + @_spi(BridgeJS) @usableFromInline 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() + } + + @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .north + case 1: + self = .south + case 2: + self = .east + case 3: + self = .west + default: + return nil + } + } + + @_spi(BridgeJS) @usableFromInline 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 { +} + +extension AsyncPayloadResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> AsyncPayloadResult { + switch caseId { + case 0: + return .success(String.bridgeJSStackPop()) + case 1: + return .failure(Int.bridgeJSStackPop()) + case 2: + return .idle + default: + fatalError("Unknown AsyncPayloadResult case ID: \(caseId)") + } + } -@_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 + @_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 .idle: + return Int32(2) + } + } } -@_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 { +@_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 = 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)) + let ret = Utils.StringUtils.uppercase(_: String.bridgeJSLiftParameter(textBytes, textLength)) 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 { +@_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 = DefaultArgumentExports.describeConstructorDefaults(_: DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(value)) + let ret = Utils.StringUtils.lowercase(_: String.bridgeJSLiftParameter(textBytes, textLength)) 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 +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() + } + + @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .get + case 1: + self = .post + case 2: + self = .put + case 3: + self = .delete + default: + return nil + } + } + + @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { + switch self { + case .get: + return 0 + case .post: + return 1 + case .put: + return 2 + case .delete: + return 3 + } + } } -@_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 +extension Configuration.LogLevel: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { } -@_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 Configuration.Port: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { } -extension Direction: _BridgedSwiftCaseEnum { +extension Internal.SupportedMethod: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Direction { + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Internal.SupportedMethod { return bridgeJSLiftParameter(value) } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Direction { - return Direction(bridgeJSRawValue: 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() } - @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { + @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { + case 0: + self = .get + case 1: + self = .post + default: + return nil + } + } + + @_spi(BridgeJS) @usableFromInline 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: - self = .north + return .success(String.bridgeJSStackPop()) case 1: - self = .south + return .failure(String.bridgeJSStackPop(), Int.bridgeJSStackPop()) case 2: - self = .east - case 3: - self = .west + return .status(Bool.bridgeJSStackPop(), Int.bridgeJSStackPop(), String.bridgeJSStackPop()) default: - return nil + fatalError("Unknown Utilities.Result case ID: \(caseId)") } } - @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { switch self { - case .north: - return 0 - case .south: - return 1 - case .east: - return 2 - case .west: - return 3 + 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 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)! +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 bridgeJSLowerReturn() -> Int32 { - return bridgeJSLowerParameter() + + @_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) + } } +} - @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { +extension AllTypesResult: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> AllTypesResult { + switch caseId { case 0: - self = .loading + return .structPayload(Address.bridgeJSStackPop()) case 1: - self = .success + return .classPayload(Greeter.bridgeJSStackPop()) case 2: - self = .error + 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: - return nil + fatalError("Unknown AllTypesResult case ID: \(caseId)") } } - @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { switch self { - case .loading: - return 0 - case .success: - return 1 - case .error: - return 2 + 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 Theme: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension HttpStatus: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension FileSize: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension SessionId: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} - -extension Precision: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { -} +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)") + } + } -extension Ratio: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { + @_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 TSDirection: _BridgedSwiftCaseEnum { +extension StaticCalculator: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> TSDirection { + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> StaticCalculator { return bridgeJSLiftParameter(value) } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> TSDirection { - return TSDirection(bridgeJSRawValue: 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() @@ -4246,13 +5465,9 @@ extension TSDirection: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { switch bridgeJSRawValue { case 0: - self = .north + self = .scientific case 1: - self = .south - case 2: - self = .east - case 3: - self = .west + self = .basic default: return nil } @@ -4260,52 +5475,89 @@ extension TSDirection: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { switch self { - case .north: + case .scientific: return 0 - case .south: + case .basic: return 1 - case .east: - return 2 - case .west: - return 3 } } } -extension TSTheme: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +@_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_Utils_StringUtils_static_uppercase") -@_cdecl("bjs_Utils_StringUtils_static_uppercase") -public func _bjs_Utils_StringUtils_static_uppercase(_ textBytes: Int32, _ textLength: Int32) -> Void { +@_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 = Utils.StringUtils.uppercase(_: String.bridgeJSLiftParameter(textBytes, textLength)) + let ret = StaticCalculator.doubleValue(_: Int.bridgeJSLiftParameter(value)) 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 { +@_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 = Utils.StringUtils.lowercase(_: String.bridgeJSLiftParameter(textBytes, textLength)) + 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 Networking.API.Method: _BridgedSwiftCaseEnum { +extension StaticPropertyEnum: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue } - @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Networking.API.Method { + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> StaticPropertyEnum { 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 static func bridgeJSLiftParameter(_ value: Int32) -> StaticPropertyEnum { + return StaticPropertyEnum(bridgeJSRawValue: value)! } @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { return bridgeJSLowerParameter() @@ -4314,13 +5566,9 @@ extension Networking.API.Method: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { switch bridgeJSRawValue { case 0: - self = .get + self = .option1 case 1: - self = .post - case 2: - self = .put - case 3: - self = .delete + self = .option2 default: return nil } @@ -4328,2762 +5576,3040 @@ extension Networking.API.Method: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { switch self { - case .get: + case .option1: return 0 - case .post: + case .option2: return 1 - case .put: - return 2 - case .delete: - return 3 } } } -extension Configuration.LogLevel: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +@_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 } -extension Configuration.Port: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +@_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 } -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() - } +@_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 +} - @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .get - case 1: - self = .post - default: - return nil - } - } +@_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 +} - @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { - switch self { - case .get: - return 0 - case .post: - return 1 - } - } +@_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 } -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)") - } - } +@_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 +} - @_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) - } - } +@_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 } -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)") - } - } +@_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 +} - @_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) - } - } +@_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 } -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)") - } - } +@_expose(wasm, "bjs_NestedStructGroupA_static_roundtripMetadata") +@_cdecl("bjs_NestedStructGroupA_static_roundtripMetadata") +public func _bjs_NestedStructGroupA_static_roundtripMetadata() -> Void { + #if arch(wasm32) + let ret = NestedStructGroupA.roundtripMetadata(_: NestedStructGroupA.Metadata.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} - @_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) - } - } +@_expose(wasm, "bjs_NestedStructGroupB_static_roundtripMetadata") +@_cdecl("bjs_NestedStructGroupB_static_roundtripMetadata") +public func _bjs_NestedStructGroupB_static_roundtripMetadata() -> Void { + #if arch(wasm32) + let ret = NestedStructGroupB.roundtripMetadata(_: NestedStructGroupB.Metadata.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif } -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)") - } +extension LightColor: _BridgedSwiftCaseEnum { + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { + return bridgeJSRawValue } - - @_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) - } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> LightColor { + return bridgeJSLiftParameter(value) + } + @_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> LightColor { + return LightColor(bridgeJSRawValue: value)! + } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 { + return bridgeJSLowerParameter() } -} -extension AllTypesResult: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> AllTypesResult { - switch caseId { + @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { + switch bridgeJSRawValue { case 0: - return .structPayload(Address.bridgeJSStackPop()) + self = .red case 1: - return .classPayload(Greeter.bridgeJSStackPop()) + self = .yellow 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 + self = .green default: - fatalError("Unknown AllTypesResult case ID: \(caseId)") + return nil } } - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { + @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: 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) + case .red: + return 0 + case .yellow: + return 1 + case .green: + return 2 } } } -extension TypedPayloadResult: _BridgedSwiftAssociatedValueEnum { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> TypedPayloadResult { +extension ImportedPayloadSignal: _BridgedSwiftAssociatedValueEnum { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPopPayload(_ caseId: Int32) -> ImportedPayloadSignal { switch caseId { case 0: - return .precision(Precision.bridgeJSStackPop()) + return .start(String.bridgeJSStackPop()) case 1: - return .direction(Direction.bridgeJSStackPop()) + return .stop(Int.bridgeJSStackPop()) case 2: - return .optPrecision(Optional.bridgeJSStackPop()) - case 3: - return .optDirection(Optional.bridgeJSStackPop()) - case 4: - return .empty + return .idle default: - fatalError("Unknown TypedPayloadResult case ID: \(caseId)") + fatalError("Unknown ImportedPayloadSignal case ID: \(caseId)") } } @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPushPayload() -> Int32 { switch self { - case .precision(let param0): + case .start(let param0): param0.bridgeJSStackPush() return Int32(0) - case .direction(let param0): + case .stop(let param0): param0.bridgeJSStackPush() return Int32(1) - case .optPrecision(let param0): - param0.bridgeJSStackPush() + case .idle: 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() - } +@_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 +} - @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .scientific - case 1: - self = .basic - default: - return nil - } - } +@_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 +} - @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { - switch self { - case .scientific: - return 0 - case .basic: - return 1 - } - } +@_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_StaticCalculator_static_roundtrip") -@_cdecl("bjs_StaticCalculator_static_roundtrip") -public func _bjs_StaticCalculator_static_roundtrip(_ value: Int32) -> Int32 { +@_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 = StaticCalculator.roundtrip(_: Int.bridgeJSLiftParameter(value)) + let ret = IntegerTypesSupportExports.roundTripUInt16(_: UInt16.bridgeJSLiftParameter(v)) 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 { +@_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 = StaticCalculator.doubleValue(_: Int.bridgeJSLiftParameter(value)) + let ret = IntegerTypesSupportExports.roundTripInt32(_: Int32.bridgeJSLiftParameter(v)) 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 { +@_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 = StaticCalculator.version + let ret = IntegerTypesSupportExports.roundTripUInt32(_: UInt32.bridgeJSLiftParameter(v)) 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 { +@_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 = StaticUtils.Nested.roundtrip(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) + let ret = IntegerTypesSupportExports.roundTripInt64(_: Int64.bridgeJSLiftParameter(v)) 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 { +@_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 = GraphOperations.createGraph(rootId: Int.bridgeJSLiftParameter(rootId)) + let ret = IntegerTypesSupportExports.roundTripUInt64(_: UInt64.bridgeJSLiftParameter(v)) 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 { +@_expose(wasm, "bjs_JSTypedArrayExports_static_roundTripUint8Array") +@_cdecl("bjs_JSTypedArrayExports_static_roundTripUint8Array") +public func _bjs_JSTypedArrayExports_static_roundTripUint8Array(_ v: Int32) -> Int32 { #if arch(wasm32) - let ret = GraphOperations.nodeCount(graphId: Int.bridgeJSLiftParameter(graphId)) + let ret = JSTypedArrayExports.roundTripUint8Array(_: JSUint8Array.bridgeJSLiftParameter(v)) 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() - } +@_expose(wasm, "bjs_JSTypedArrayExports_static_roundTripFloat32Array") +@_cdecl("bjs_JSTypedArrayExports_static_roundTripFloat32Array") +public func _bjs_JSTypedArrayExports_static_roundTripFloat32Array(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = JSTypedArrayExports.roundTripFloat32Array(_: JSFloat32Array.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} - @_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) { - switch bridgeJSRawValue { - case 0: - self = .option1 - case 1: - self = .option2 - default: - return nil - } - } +@_expose(wasm, "bjs_JSTypedArrayExports_static_roundTripFloat64Array") +@_cdecl("bjs_JSTypedArrayExports_static_roundTripFloat64Array") +public func _bjs_JSTypedArrayExports_static_roundTripFloat64Array(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = JSTypedArrayExports.roundTripFloat64Array(_: JSFloat64Array.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} - @_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 { - switch self { - case .option1: - return 0 - case .option2: - return 1 - } - } +@_expose(wasm, "bjs_JSTypedArrayExports_static_roundTripInt32Array") +@_cdecl("bjs_JSTypedArrayExports_static_roundTripInt32Array") +public func _bjs_JSTypedArrayExports_static_roundTripInt32Array(_ v: Int32) -> Int32 { + #if arch(wasm32) + let ret = JSTypedArrayExports.roundTripInt32Array(_: JSInt32Array.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif } -@_expose(wasm, "bjs_StaticPropertyEnum_static_enumProperty_get") -@_cdecl("bjs_StaticPropertyEnum_static_enumProperty_get") -public func _bjs_StaticPropertyEnum_static_enumProperty_get() -> Void { +@_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 = StaticPropertyEnum.enumProperty + let ret = OptionalSupportExports.roundTripOptionalString(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) 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 { +@_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) - StaticPropertyEnum.enumProperty = String.bridgeJSLiftParameter(valueBytes, valueLength) + let ret = OptionalSupportExports.roundTripOptionalInt(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() #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 { +@_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 = StaticPropertyEnum.enumConstant + let ret = OptionalSupportExports.roundTripOptionalBool(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) 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 { +@_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 = StaticPropertyEnum.enumBool + let ret = OptionalSupportExports.roundTripOptionalFloat(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) 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 { +@_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) - StaticPropertyEnum.enumBool = Bool.bridgeJSLiftParameter(value) + let ret = OptionalSupportExports.roundTripOptionalDouble(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() #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 { +@_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 = StaticPropertyEnum.enumVariable + let ret = OptionalSupportExports.roundTripOptionalSyntax(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) 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 { +@_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) - StaticPropertyEnum.enumVariable = Int.bridgeJSLiftParameter(value) + let ret = OptionalSupportExports.roundTripOptionalCaseEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() #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 { +@_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 = StaticPropertyEnum.computedReadonly + let ret = OptionalSupportExports.roundTripOptionalStringRawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) 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 { +@_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 = StaticPropertyEnum.computedReadWrite + let ret = OptionalSupportExports.roundTripOptionalIntRawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) 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 { +@_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) - StaticPropertyEnum.computedReadWrite = String.bridgeJSLiftParameter(valueBytes, valueLength) + let ret = OptionalSupportExports.roundTripOptionalInt64RawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() #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 { +@_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 = StaticPropertyNamespace.namespaceProperty + let ret = OptionalSupportExports.roundTripOptionalUInt64RawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) 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 { +@_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) - StaticPropertyNamespace.namespaceProperty = String.bridgeJSLiftParameter(valueBytes, valueLength) + let ret = OptionalSupportExports.roundTripOptionalTSEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() #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 { +@_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 = StaticPropertyNamespace.namespaceConstant + let ret = OptionalSupportExports.roundTripOptionalTSStringEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) 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 { +@_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 = StaticPropertyNamespace.NestedProperties.nestedProperty + let ret = OptionalSupportExports.roundTripOptionalNamespacedEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) 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 { +@_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) - StaticPropertyNamespace.NestedProperties.nestedProperty = Int.bridgeJSLiftParameter(value) + let ret = OptionalSupportExports.roundTripOptionalSwiftClass(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() #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 { +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalIntArray") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalIntArray") +public func _bjs_OptionalSupportExports_static_roundTripOptionalIntArray() -> Void { #if arch(wasm32) - let ret = StaticPropertyNamespace.NestedProperties.nestedConstant - return ret.bridgeJSLowerReturn() + let ret = OptionalSupportExports.roundTripOptionalIntArray(_: Optional<[Int]>.bridgeJSLiftParameter()) + ret.bridgeJSStackPush() #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 { +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalStringArray") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalStringArray") +public func _bjs_OptionalSupportExports_static_roundTripOptionalStringArray() -> Void { #if arch(wasm32) - let ret = StaticPropertyNamespace.NestedProperties.nestedDouble - return ret.bridgeJSLowerReturn() + let ret = OptionalSupportExports.roundTripOptionalStringArray(_: Optional<[String]>.bridgeJSLiftParameter()) + ret.bridgeJSStackPush() #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 { +@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalSwiftClassArray") +@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalSwiftClassArray") +public func _bjs_OptionalSupportExports_static_roundTripOptionalSwiftClassArray() -> Void { #if arch(wasm32) - StaticPropertyNamespace.NestedProperties.nestedDouble = Double.bridgeJSLiftParameter(value) + let ret = OptionalSupportExports.roundTripOptionalSwiftClassArray(_: Optional<[Greeter]>.bridgeJSLiftParameter()) + ret.bridgeJSStackPush() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_NestedStructGroupA_static_roundtripMetadata") -@_cdecl("bjs_NestedStructGroupA_static_roundtripMetadata") -public func _bjs_NestedStructGroupA_static_roundtripMetadata() -> Void { +@_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 = NestedStructGroupA.roundtripMetadata(_: NestedStructGroupA.Metadata.bridgeJSLiftParameter()) + let ret = OptionalSupportExports.roundTripOptionalAPIResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_NestedStructGroupB_static_roundtripMetadata") -@_cdecl("bjs_NestedStructGroupB_static_roundtripMetadata") -public func _bjs_NestedStructGroupB_static_roundtripMetadata() -> Void { +@_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 = NestedStructGroupB.roundtripMetadata(_: NestedStructGroupB.Metadata.bridgeJSLiftParameter()) + let ret = OptionalSupportExports.roundTripOptionalTypedPayloadResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) return ret.bridgeJSLowerReturn() #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 { +@_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 = IntegerTypesSupportExports.roundTripInt(_: Int.bridgeJSLiftParameter(v)) + let ret = OptionalSupportExports.roundTripOptionalComplexResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) 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 { +@_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 = IntegerTypesSupportExports.roundTripUInt(_: UInt.bridgeJSLiftParameter(v)) + let ret = OptionalSupportExports.roundTripOptionalAllTypesResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) 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 { +@_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 = IntegerTypesSupportExports.roundTripInt8(_: Int8.bridgeJSLiftParameter(v)) + let ret = OptionalSupportExports.roundTripOptionalPayloadResult(_: OptionalAllTypesResult.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 { +@_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 = IntegerTypesSupportExports.roundTripUInt8(_: UInt8.bridgeJSLiftParameter(v)) + let ret = OptionalSupportExports.roundTripOptionalPayloadResultOpt(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) 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 { +@_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 = IntegerTypesSupportExports.roundTripInt16(_: Int16.bridgeJSLiftParameter(v)) + let ret = OptionalSupportExports.roundTripOptionalAPIOptionalResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) 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 { +@_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) - let ret = IntegerTypesSupportExports.roundTripUInt16(_: UInt16.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() + OptionalSupportExports.takeOptionalJSObject(_: Optional.bridgeJSLiftParameter(valueIsSome, valueValue)) #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 { +@_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 = IntegerTypesSupportExports.roundTripInt32(_: Int32.bridgeJSLiftParameter(v)) + 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_IntegerTypesSupportExports_static_roundTripUInt32") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripUInt32") -public func _bjs_IntegerTypesSupportExports_static_roundTripUInt32(_ v: Int32) -> Int32 { +@_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 = IntegerTypesSupportExports.roundTripUInt32(_: UInt32.bridgeJSLiftParameter(v)) + 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_IntegerTypesSupportExports_static_roundTripInt64") -@_cdecl("bjs_IntegerTypesSupportExports_static_roundTripInt64") -public func _bjs_IntegerTypesSupportExports_static_roundTripInt64(_ v: Int64) -> Int64 { +@_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 ret = IntegerTypesSupportExports.roundTripInt64(_: Int64.bridgeJSLiftParameter(v)) + 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 } -@_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 +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 JSCoordinate: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> JSCoordinate { + let longitude = Double.bridgeJSStackPop() + let latitude = Double.bridgeJSStackPop() + return JSCoordinate(latitude: latitude, longitude: longitude) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.latitude.bridgeJSStackPush() + self.longitude.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_JSCoordinate(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_JSCoordinate())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_JSCoordinate") +fileprivate func _bjs_struct_lower_JSCoordinate_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_JSCoordinate_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_JSCoordinate(_ objectId: Int32) -> Void { + return _bjs_struct_lower_JSCoordinate_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_JSCoordinate") +fileprivate func _bjs_struct_lift_JSCoordinate_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_JSCoordinate_extern() -> Int32 { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_JSCoordinate() -> Int32 { + return _bjs_struct_lift_JSCoordinate_extern() } -@_expose(wasm, "bjs_JSTypedArrayExports_static_roundTripUint8Array") -@_cdecl("bjs_JSTypedArrayExports_static_roundTripUint8Array") -public func _bjs_JSTypedArrayExports_static_roundTripUint8Array(_ v: Int32) -> Int32 { +@_expose(wasm, "bjs_JSCoordinate_init") +@_cdecl("bjs_JSCoordinate_init") +public func _bjs_JSCoordinate_init(_ latitude: Float64, _ longitude: Float64) -> Void { #if arch(wasm32) - let ret = JSTypedArrayExports.roundTripUint8Array(_: JSUint8Array.bridgeJSLiftParameter(v)) + let ret = JSCoordinate(latitude: Double.bridgeJSLiftParameter(latitude), longitude: Double.bridgeJSLiftParameter(longitude)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_JSTypedArrayExports_static_roundTripFloat32Array") -@_cdecl("bjs_JSTypedArrayExports_static_roundTripFloat32Array") -public func _bjs_JSTypedArrayExports_static_roundTripFloat32Array(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = JSTypedArrayExports.roundTripFloat32Array(_: JSFloat32Array.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif +extension NestedStructGroupA.Metadata: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> NestedStructGroupA.Metadata { + let count = Int.bridgeJSStackPop() + let label = String.bridgeJSStackPop() + return NestedStructGroupA.Metadata(label: label, count: count) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.label.bridgeJSStackPush() + self.count.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_NestedStructGroupA_Metadata(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_NestedStructGroupA_Metadata())) + } } -@_expose(wasm, "bjs_JSTypedArrayExports_static_roundTripFloat64Array") -@_cdecl("bjs_JSTypedArrayExports_static_roundTripFloat64Array") -public func _bjs_JSTypedArrayExports_static_roundTripFloat64Array(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = JSTypedArrayExports.roundTripFloat64Array(_: JSFloat64Array.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_NestedStructGroupA_Metadata") +fileprivate func _bjs_struct_lower_NestedStructGroupA_Metadata_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_NestedStructGroupA_Metadata_extern(_ objectId: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_NestedStructGroupA_Metadata(_ objectId: Int32) -> Void { + return _bjs_struct_lower_NestedStructGroupA_Metadata_extern(objectId) } -@_expose(wasm, "bjs_JSTypedArrayExports_static_roundTripInt32Array") -@_cdecl("bjs_JSTypedArrayExports_static_roundTripInt32Array") -public func _bjs_JSTypedArrayExports_static_roundTripInt32Array(_ v: Int32) -> Int32 { - #if arch(wasm32) - let ret = JSTypedArrayExports.roundTripInt32Array(_: JSInt32Array.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() - #else +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_NestedStructGroupA_Metadata") +fileprivate func _bjs_struct_lift_NestedStructGroupA_Metadata_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_NestedStructGroupA_Metadata_extern() -> Int32 { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_NestedStructGroupA_Metadata() -> Int32 { + return _bjs_struct_lift_NestedStructGroupA_Metadata_extern() } -@_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 +extension NestedStructGroupB.Metadata: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> NestedStructGroupB.Metadata { + let value = Double.bridgeJSStackPop() + let tag = String.bridgeJSStackPop() + return NestedStructGroupB.Metadata(tag: tag, value: value) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.tag.bridgeJSStackPush() + self.value.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_NestedStructGroupB_Metadata(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_NestedStructGroupB_Metadata())) + } } -@_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 +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_NestedStructGroupB_Metadata") +fileprivate func _bjs_struct_lower_NestedStructGroupB_Metadata_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_NestedStructGroupB_Metadata_extern(_ objectId: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_NestedStructGroupB_Metadata(_ objectId: Int32) -> Void { + return _bjs_struct_lower_NestedStructGroupB_Metadata_extern(objectId) } -@_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 +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_NestedStructGroupB_Metadata") +fileprivate func _bjs_struct_lift_NestedStructGroupB_Metadata_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_NestedStructGroupB_Metadata_extern() -> Int32 { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_NestedStructGroupB_Metadata() -> Int32 { + return _bjs_struct_lift_NestedStructGroupB_Metadata_extern() } -@_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 +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())) + } } -@_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 +#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 +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Point_extern(objectId) } -@_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 +#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 +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Point() -> Int32 { + return _bjs_struct_lift_Point_extern() } -@_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 +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())) + } } -@_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 +#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 +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_PointerFields(_ objectId: Int32) -> Void { + return _bjs_struct_lower_PointerFields_extern(objectId) } -@_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 +#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 +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_PointerFields() -> Int32 { + return _bjs_struct_lift_PointerFields_extern() } -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalInt64RawValueEnum") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalInt64RawValueEnum") -public func _bjs_OptionalSupportExports_static_roundTripOptionalInt64RawValueEnum(_ vIsSome: Int32, _ vValue: Int64) -> Void { +@_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 = OptionalSupportExports.roundTripOptionalInt64RawValueEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + 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 } -@_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 +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())) + } } -@_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 +#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 +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_DataPoint(_ objectId: Int32) -> Void { + return _bjs_struct_lower_DataPoint_extern(objectId) } -@_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 +#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 +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_DataPoint() -> Int32 { + return _bjs_struct_lift_DataPoint_extern() } -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalNamespacedEnum") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalNamespacedEnum") -public func _bjs_OptionalSupportExports_static_roundTripOptionalNamespacedEnum(_ vIsSome: Int32, _ vValue: Int32) -> Void { +@_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 = OptionalSupportExports.roundTripOptionalNamespacedEnum(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + 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_OptionalSupportExports_static_roundTripOptionalSwiftClass") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalSwiftClass") -public func _bjs_OptionalSupportExports_static_roundTripOptionalSwiftClass(_ vIsSome: Int32, _ vValue: UnsafeMutableRawPointer) -> Void { +@_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 = OptionalSupportExports.roundTripOptionalSwiftClass(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + let ret = DataPoint.dimensions 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 { +@_expose(wasm, "bjs_DataPoint_static_origin") +@_cdecl("bjs_DataPoint_static_origin") +public func _bjs_DataPoint_static_origin() -> Void { #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalIntArray(_: Optional<[Int]>.bridgeJSLiftParameter()) - ret.bridgeJSStackPush() + let ret = DataPoint.origin() + return ret.bridgeJSLowerReturn() #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 -} +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) + } -@_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 + @_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())) + } } -@_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 +#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 +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_PublicPoint(_ objectId: Int32) -> Void { + return _bjs_struct_lower_PublicPoint_extern(objectId) } -@_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 +#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 +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_PublicPoint() -> Int32 { + return _bjs_struct_lift_PublicPoint_extern() } -@_expose(wasm, "bjs_OptionalSupportExports_static_roundTripOptionalComplexResult") -@_cdecl("bjs_OptionalSupportExports_static_roundTripOptionalComplexResult") -public func _bjs_OptionalSupportExports_static_roundTripOptionalComplexResult(_ vIsSome: Int32, _ vCaseId: Int32) -> Void { +@_expose(wasm, "bjs_PublicPoint_init") +@_cdecl("bjs_PublicPoint_init") +public func _bjs_PublicPoint_init(_ x: Int32, _ y: Int32) -> Void { #if arch(wasm32) - let ret = OptionalSupportExports.roundTripOptionalComplexResult(_: Optional.bridgeJSLiftParameter(vIsSome, vCaseId)) + let ret = PublicPoint(x: Int.bridgeJSLiftParameter(x), y: Int.bridgeJSLiftParameter(y)) 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 +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())) + } } -@_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 +#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 } - -@_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 +#endif +@inline(never) fileprivate func _bjs_struct_lower_Address(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Address_extern(objectId) } -@_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 +#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 } - -@_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 +#endif +@inline(never) fileprivate func _bjs_struct_lift_Address() -> Int32 { + return _bjs_struct_lift_Address_extern() } -@_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 +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())) + } } -@_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 +#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 +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Contact(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Contact_extern(objectId) } -@_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 +#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 +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Contact() -> Int32 { + return _bjs_struct_lift_Contact_extern() } -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)") - } +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 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) - } + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.name.bridgeJSStackPush() + self.theme.bridgeJSStackPush() + self.direction.bridgeJSStackPush() + self.status.bridgeJSStackPush() } -} -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)") - } + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Config(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() } - @_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) - } + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Config())) } } -extension JSCoordinate: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> JSCoordinate { - let longitude = Double.bridgeJSStackPop() - let latitude = Double.bridgeJSStackPop() - return JSCoordinate(latitude: latitude, longitude: longitude) +#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.latitude.bridgeJSStackPush() - self.longitude.bridgeJSStackPush() + self.id.bridgeJSStackPush() + self.owner.bridgeJSStackPush() } init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_JSCoordinate(jsObject.bridgeJSLowerParameter()) + _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_JSCoordinate())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_SessionData())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_JSCoordinate") -fileprivate func _bjs_struct_lower_JSCoordinate_extern(_ objectId: Int32) -> Void +@_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_JSCoordinate_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_SessionData_extern(_ objectId: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lower_JSCoordinate(_ objectId: Int32) -> Void { - return _bjs_struct_lower_JSCoordinate_extern(objectId) +@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_JSCoordinate") -fileprivate func _bjs_struct_lift_JSCoordinate_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_SessionData") +fileprivate func _bjs_struct_lift_SessionData_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_JSCoordinate_extern() -> Int32 { +fileprivate func _bjs_struct_lift_SessionData_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_JSCoordinate() -> Int32 { - return _bjs_struct_lift_JSCoordinate_extern() -} - -@_expose(wasm, "bjs_JSCoordinate_init") -@_cdecl("bjs_JSCoordinate_init") -public func _bjs_JSCoordinate_init(_ latitude: Float64, _ longitude: Float64) -> Void { - #if arch(wasm32) - let ret = JSCoordinate(latitude: Double.bridgeJSLiftParameter(latitude), longitude: Double.bridgeJSLiftParameter(longitude)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif +@inline(never) fileprivate func _bjs_struct_lift_SessionData() -> Int32 { + return _bjs_struct_lift_SessionData_extern() } -extension SessionState: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> SessionState { - let token = String.bridgeJSStackPop() - return SessionState(token: token) +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.token.bridgeJSStackPush() + self.id.bridgeJSStackPush() + self.result.bridgeJSStackPush() + self.status.bridgeJSStackPush() + self.outcome.bridgeJSStackPush() } init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_SessionState(jsObject.bridgeJSLowerParameter()) + _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_SessionState())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_ValidationReport())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_SessionState") -fileprivate func _bjs_struct_lower_SessionState_extern(_ objectId: Int32) -> Void +@_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_SessionState_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_ValidationReport_extern(_ objectId: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lower_SessionState(_ objectId: Int32) -> Void { - return _bjs_struct_lower_SessionState_extern(objectId) +@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_SessionState") -fileprivate func _bjs_struct_lift_SessionState_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_ValidationReport") +fileprivate func _bjs_struct_lift_ValidationReport_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_SessionState_extern() -> Int32 { +fileprivate func _bjs_struct_lift_ValidationReport_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_SessionState() -> Int32 { - return _bjs_struct_lift_SessionState_extern() -} - -@_expose(wasm, "bjs_SessionState_init") -@_cdecl("bjs_SessionState_init") -public func _bjs_SessionState_init(_ tokenBytes: Int32, _ tokenLength: Int32) -> Void { - #if arch(wasm32) - let ret = SessionState(token: String.bridgeJSLiftParameter(tokenBytes, tokenLength)) - return ret.bridgeJSLowerReturn() - #else - fatalError("Only available on WebAssembly") - #endif +@inline(never) fileprivate func _bjs_struct_lift_ValidationReport() -> Int32 { + return _bjs_struct_lift_ValidationReport_extern() } -extension NestedStructGroupA.Metadata: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> NestedStructGroupA.Metadata { - let count = Int.bridgeJSStackPop() - let label = String.bridgeJSStackPop() - return NestedStructGroupA.Metadata(label: label, count: count) +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.label.bridgeJSStackPush() - self.count.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_NestedStructGroupA_Metadata(jsObject.bridgeJSLowerParameter()) + _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_NestedStructGroupA_Metadata())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_AdvancedConfig())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_NestedStructGroupA_Metadata") -fileprivate func _bjs_struct_lower_NestedStructGroupA_Metadata_extern(_ objectId: Int32) -> Void +@_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_NestedStructGroupA_Metadata_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_AdvancedConfig_extern(_ objectId: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lower_NestedStructGroupA_Metadata(_ objectId: Int32) -> Void { - return _bjs_struct_lower_NestedStructGroupA_Metadata_extern(objectId) +@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_NestedStructGroupA_Metadata") -fileprivate func _bjs_struct_lift_NestedStructGroupA_Metadata_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_AdvancedConfig") +fileprivate func _bjs_struct_lift_AdvancedConfig_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_NestedStructGroupA_Metadata_extern() -> Int32 { +fileprivate func _bjs_struct_lift_AdvancedConfig_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_NestedStructGroupA_Metadata() -> Int32 { - return _bjs_struct_lift_NestedStructGroupA_Metadata_extern() +@inline(never) fileprivate func _bjs_struct_lift_AdvancedConfig() -> Int32 { + return _bjs_struct_lift_AdvancedConfig_extern() } -extension NestedStructGroupB.Metadata: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> NestedStructGroupB.Metadata { - let value = Double.bridgeJSStackPop() - let tag = String.bridgeJSStackPop() - return NestedStructGroupB.Metadata(tag: tag, value: value) +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.tag.bridgeJSStackPush() - self.value.bridgeJSStackPush() + self.precision.bridgeJSStackPush() + self.ratio.bridgeJSStackPush() + self.optionalPrecision.bridgeJSStackPush() + self.optionalRatio.bridgeJSStackPush() } init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_NestedStructGroupB_Metadata(jsObject.bridgeJSLowerParameter()) + _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_NestedStructGroupB_Metadata())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_MeasurementConfig())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_NestedStructGroupB_Metadata") -fileprivate func _bjs_struct_lower_NestedStructGroupB_Metadata_extern(_ objectId: Int32) -> Void +@_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_NestedStructGroupB_Metadata_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_MeasurementConfig_extern(_ objectId: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lower_NestedStructGroupB_Metadata(_ objectId: Int32) -> Void { - return _bjs_struct_lower_NestedStructGroupB_Metadata_extern(objectId) +@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_NestedStructGroupB_Metadata") -fileprivate func _bjs_struct_lift_NestedStructGroupB_Metadata_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_MeasurementConfig") +fileprivate func _bjs_struct_lift_MeasurementConfig_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_NestedStructGroupB_Metadata_extern() -> Int32 { +fileprivate func _bjs_struct_lift_MeasurementConfig_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_NestedStructGroupB_Metadata() -> Int32 { - return _bjs_struct_lift_NestedStructGroupB_Metadata_extern() +@inline(never) fileprivate func _bjs_struct_lift_MeasurementConfig() -> Int32 { + return _bjs_struct_lift_MeasurementConfig_extern() } -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) +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.x.bridgeJSStackPush() - self.y.bridgeJSStackPush() + self.baseValue.bridgeJSStackPush() } init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter()) + _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_Point())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_MathOperations())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Point") -fileprivate func _bjs_struct_lower_Point_extern(_ objectId: Int32) -> Void +@_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_Point_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_MathOperations_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) +@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_Point") -fileprivate func _bjs_struct_lift_Point_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_MathOperations") +fileprivate func _bjs_struct_lift_MathOperations_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_Point_extern() -> Int32 { +fileprivate func _bjs_struct_lift_MathOperations_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_Point() -> Int32 { - return _bjs_struct_lift_Point_extern() +@inline(never) fileprivate func _bjs_struct_lift_MathOperations() -> Int32 { + return _bjs_struct_lift_MathOperations_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) +@_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.raw.bridgeJSStackPush() - self.mutRaw.bridgeJSStackPush() - self.opaque.bridgeJSStackPush() - self.ptr.bridgeJSStackPush() - self.mutPtr.bridgeJSStackPush() + self.x.bridgeJSStackPush() + self.note.bridgeJSStackPush() } init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_PointerFields(jsObject.bridgeJSLowerParameter()) + _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_PointerFields())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_CopyableCart())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_PointerFields") -fileprivate func _bjs_struct_lower_PointerFields_extern(_ objectId: Int32) -> Void +@_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_PointerFields_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_CopyableCart_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) +@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_PointerFields") -fileprivate func _bjs_struct_lift_PointerFields_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_CopyableCart") +fileprivate func _bjs_struct_lift_CopyableCart_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_PointerFields_extern() -> Int32 { +fileprivate func _bjs_struct_lift_CopyableCart_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_PointerFields() -> Int32 { - return _bjs_struct_lift_PointerFields_extern() +@inline(never) fileprivate func _bjs_struct_lift_CopyableCart() -> Int32 { + return _bjs_struct_lift_CopyableCart_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 { +@_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 = PointerFields(raw: UnsafeRawPointer.bridgeJSLiftParameter(raw), mutRaw: UnsafeMutableRawPointer.bridgeJSLiftParameter(mutRaw), opaque: OpaquePointer.bridgeJSLiftParameter(opaque), ptr: UnsafePointer.bridgeJSLiftParameter(ptr), mutPtr: UnsafeMutablePointer.bridgeJSLiftParameter(mutPtr)) + let ret = CopyableCart.fromJSObject(_: JSObject.bridgeJSLiftParameter(object)) 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) +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.x.bridgeJSStackPush() - self.y.bridgeJSStackPush() - self.label.bridgeJSStackPush() - self.optCount.bridgeJSStackPush() - self.optFlag.bridgeJSStackPush() + self.sku.bridgeJSStackPush() + self.quantity.bridgeJSStackPush() } init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_DataPoint(jsObject.bridgeJSLowerParameter()) + _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_DataPoint())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_CopyableCartItem())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_DataPoint") -fileprivate func _bjs_struct_lower_DataPoint_extern(_ objectId: Int32) -> Void +@_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_DataPoint_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_CopyableCartItem_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) +@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_DataPoint") -fileprivate func _bjs_struct_lift_DataPoint_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_CopyableCartItem") +fileprivate func _bjs_struct_lift_CopyableCartItem_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_DataPoint_extern() -> Int32 { +fileprivate func _bjs_struct_lift_CopyableCartItem_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 +@inline(never) fileprivate func _bjs_struct_lift_CopyableCartItem() -> Int32 { + return _bjs_struct_lift_CopyableCartItem_extern() } -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) +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.x.bridgeJSStackPush() - self.y.bridgeJSStackPush() + self.id.bridgeJSStackPush() + self.item.bridgeJSStackPush() + self.shippingAddress.bridgeJSStackPush() } - public init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_PublicPoint(jsObject.bridgeJSLowerParameter()) + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_CopyableNestedCart(jsObject.bridgeJSLowerParameter()) self = Self.bridgeJSStackPop() } - public func toJSObject() -> JSObject { + func toJSObject() -> JSObject { let __bjs_self = self __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_PublicPoint())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_CopyableNestedCart())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_PublicPoint") -fileprivate func _bjs_struct_lower_PublicPoint_extern(_ objectId: Int32) -> Void +@_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_PublicPoint_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_CopyableNestedCart_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) +@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_PublicPoint") -fileprivate func _bjs_struct_lift_PublicPoint_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_CopyableNestedCart") +fileprivate func _bjs_struct_lift_CopyableNestedCart_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_PublicPoint_extern() -> Int32 { +fileprivate func _bjs_struct_lift_CopyableNestedCart_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_PublicPoint() -> Int32 { - return _bjs_struct_lift_PublicPoint_extern() +@inline(never) fileprivate func _bjs_struct_lift_CopyableNestedCart() -> Int32 { + return _bjs_struct_lift_CopyableNestedCart_extern() } -@_expose(wasm, "bjs_PublicPoint_init") -@_cdecl("bjs_PublicPoint_init") -public func _bjs_PublicPoint_init(_ x: Int32, _ y: Int32) -> Void { +@_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 = PublicPoint(x: Int.bridgeJSLiftParameter(x), y: Int.bridgeJSLiftParameter(y)) + let ret = CopyableNestedCart.fromJSObject(_: JSObject.bridgeJSLiftParameter(object)) 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) +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.street.bridgeJSStackPush() - self.city.bridgeJSStackPush() - self.zipCode.bridgeJSStackPush() + self.name.bridgeJSStackPush() + self.value.bridgeJSStackPush() } init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_Address(jsObject.bridgeJSLowerParameter()) + _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_Address())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_ConfigStruct())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Address") -fileprivate func _bjs_struct_lower_Address_extern(_ objectId: Int32) -> Void +@_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_Address_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_ConfigStruct_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) +@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_Address") -fileprivate func _bjs_struct_lift_Address_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_ConfigStruct") +fileprivate func _bjs_struct_lift_ConfigStruct_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_Address_extern() -> Int32 { +fileprivate func _bjs_struct_lift_ConfigStruct_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_Address() -> Int32 { - return _bjs_struct_lift_Address_extern() +@inline(never) fileprivate func _bjs_struct_lift_ConfigStruct() -> Int32 { + return _bjs_struct_lift_ConfigStruct_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() - } +@_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 +} - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_Contact(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } +@_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 +} - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Contact())) - } +@_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 } -#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 { +@_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 -@inline(never) fileprivate func _bjs_struct_lower_Contact(_ objectId: Int32) -> Void { - return _bjs_struct_lower_Contact_extern(objectId) + #endif } -#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 { +@_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 } -#endif -@inline(never) fileprivate func _bjs_struct_lift_Contact() -> Int32 { - return _bjs_struct_lift_Contact_extern() + +@_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 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) +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.name.bridgeJSStackPush() - self.theme.bridgeJSStackPush() - self.direction.bridgeJSStackPush() - self.status.bridgeJSStackPush() + self.dx.bridgeJSStackPush() + self.dy.bridgeJSStackPush() } init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_Config(jsObject.bridgeJSLowerParameter()) + _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_Config())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Vector2D())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Config") -fileprivate func _bjs_struct_lower_Config_extern(_ objectId: Int32) -> Void +@_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_Config_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_Vector2D_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) +@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_Config") -fileprivate func _bjs_struct_lift_Config_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Vector2D") +fileprivate func _bjs_struct_lift_Vector2D_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_Config_extern() -> Int32 { +fileprivate func _bjs_struct_lift_Vector2D_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_Config() -> Int32 { - return _bjs_struct_lift_Config_extern() +@inline(never) fileprivate func _bjs_struct_lift_Vector2D() -> Int32 { + return _bjs_struct_lift_Vector2D_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())) - } +@_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 } -#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 { +@_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 -@inline(never) fileprivate func _bjs_struct_lower_SessionData(_ objectId: Int32) -> Void { - return _bjs_struct_lower_SessionData_extern(objectId) + #endif } -#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 { +@_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 -@inline(never) fileprivate func _bjs_struct_lift_SessionData() -> Int32 { - return _bjs_struct_lift_SessionData_extern() + #endif } -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) +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.id.bridgeJSStackPush() - self.result.bridgeJSStackPush() - self.status.bridgeJSStackPush() - self.outcome.bridgeJSStackPush() + self.object.bridgeJSStackPush() + self.optionalObject.bridgeJSStackPush() } init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_ValidationReport(jsObject.bridgeJSLowerParameter()) + _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_ValidationReport())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_JSObjectContainer())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_ValidationReport") -fileprivate func _bjs_struct_lower_ValidationReport_extern(_ objectId: Int32) -> Void +@_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_ValidationReport_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_JSObjectContainer_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) +@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_ValidationReport") -fileprivate func _bjs_struct_lift_ValidationReport_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_JSObjectContainer") +fileprivate func _bjs_struct_lift_JSObjectContainer_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_ValidationReport_extern() -> Int32 { +fileprivate func _bjs_struct_lift_JSObjectContainer_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_ValidationReport() -> Int32 { - return _bjs_struct_lift_ValidationReport_extern() +@inline(never) fileprivate func _bjs_struct_lift_JSObjectContainer() -> Int32 { + return _bjs_struct_lift_JSObjectContainer_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) +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.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() + self.foo.jsObject.bridgeJSStackPush() + self.optionalFoo.bridgeJSStackPush() } init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_AdvancedConfig(jsObject.bridgeJSLowerParameter()) + _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_AdvancedConfig())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_FooContainer())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_AdvancedConfig") -fileprivate func _bjs_struct_lower_AdvancedConfig_extern(_ objectId: Int32) -> Void +@_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_AdvancedConfig_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_FooContainer_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) +@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_AdvancedConfig") -fileprivate func _bjs_struct_lift_AdvancedConfig_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_FooContainer") +fileprivate func _bjs_struct_lift_FooContainer_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_AdvancedConfig_extern() -> Int32 { +fileprivate func _bjs_struct_lift_FooContainer_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_AdvancedConfig() -> Int32 { - return _bjs_struct_lift_AdvancedConfig_extern() +@inline(never) fileprivate func _bjs_struct_lift_FooContainer() -> Int32 { + return _bjs_struct_lift_FooContainer_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) +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.precision.bridgeJSStackPush() - self.ratio.bridgeJSStackPush() - self.optionalPrecision.bridgeJSStackPush() - self.optionalRatio.bridgeJSStackPush() + self.ints.bridgeJSStackPush() + self.optStrings.bridgeJSStackPush() } init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_MeasurementConfig(jsObject.bridgeJSLowerParameter()) + _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_MeasurementConfig())) + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_ArrayMembers())) } } #if arch(wasm32) -@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_MeasurementConfig") -fileprivate func _bjs_struct_lower_MeasurementConfig_extern(_ objectId: Int32) -> Void +@_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_MeasurementConfig_extern(_ objectId: Int32) -> Void { +fileprivate func _bjs_struct_lower_ArrayMembers_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) +@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_MeasurementConfig") -fileprivate func _bjs_struct_lift_MeasurementConfig_extern() -> Int32 +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_ArrayMembers") +fileprivate func _bjs_struct_lift_ArrayMembers_extern() -> Int32 #else -fileprivate func _bjs_struct_lift_MeasurementConfig_extern() -> Int32 { +fileprivate func _bjs_struct_lift_ArrayMembers_extern() -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_struct_lift_MeasurementConfig() -> Int32 { - return _bjs_struct_lift_MeasurementConfig_extern() +@inline(never) fileprivate func _bjs_struct_lift_ArrayMembers() -> Int32 { + return _bjs_struct_lift_ArrayMembers_extern() } -extension MathOperations: _BridgedSwiftStruct { - @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> MathOperations { - let baseValue = Double.bridgeJSStackPop() - return MathOperations(baseValue: baseValue) - } +@_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 +} - @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { - self.baseValue.bridgeJSStackPush() - } +@_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 +} - init(unsafelyCopying jsObject: JSObject) { - _bjs_struct_lower_MathOperations(jsObject.bridgeJSLowerParameter()) - self = Self.bridgeJSStackPop() - } +@_expose(wasm, "bjs_makeTag") +@_cdecl("bjs_makeTag") +public func _bjs_makeTag(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = makeTag(_: String.bridgeJSLiftParameter(nameBytes, nameLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} - func toJSObject() -> JSObject { - let __bjs_self = self - __bjs_self.bridgeJSStackPush() - return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_MathOperations())) +@_expose(wasm, "bjs_roundTripPolygon") +@_cdecl("bjs_roundTripPolygon") +public func _bjs_roundTripPolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundTripPolygon(_: Polygon.bridgeJSLiftParameter(polygon)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_appendVertex") +@_cdecl("bjs_appendVertex") +public func _bjs_appendVertex(_ polygon: UnsafeMutableRawPointer, _ value: Float64) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = appendVertex(_: Polygon.bridgeJSLiftParameter(polygon), _: Double.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_optionalRoundTripPolygon") +@_cdecl("bjs_optionalRoundTripPolygon") +public func _bjs_optionalRoundTripPolygon(_ polygonIsSome: Int32, _ polygonValue: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = optionalRoundTripPolygon(_: Optional.bridgeJSLiftParameter(polygonIsSome, polygonValue)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_polygonVertexCount") +@_cdecl("bjs_polygonVertexCount") +public func _bjs_polygonVertexCount(_ polygon: UnsafeMutableRawPointer) -> Int32 { + #if arch(wasm32) + let ret = polygonVertexCount(_: Polygon.bridgeJSLiftParameter(polygon)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripPolygonArray") +@_cdecl("bjs_roundTripPolygonArray") +public func _bjs_roundTripPolygonArray() -> Void { + #if arch(wasm32) + let ret = roundTripPolygonArray(_: [Polygon].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_concatPolygons") +@_cdecl("bjs_concatPolygons") +public func _bjs_concatPolygons() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = concatPolygons(_: [Polygon].bridgeJSStackPop()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_validatePolygon") +@_cdecl("bjs_validatePolygon") +public func _bjs_validatePolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + do { + let ret = try validatePolygon(_: Polygon.bridgeJSLiftParameter(polygon)) + 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: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return UnsafeMutableRawPointer(bitPattern: -1).unsafelyUnwrapped } + #else + fatalError("Only available on WebAssembly") + #endif } -#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 { +@_expose(wasm, "bjs_splitPolygon") +@_cdecl("bjs_splitPolygon") +public func _bjs_splitPolygon(_ polygon: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = splitPolygon(_: Polygon.bridgeJSLiftParameter(polygon)) + ret.bridgeJSStackPush() + #else fatalError("Only available on WebAssembly") + #endif } -#endif -@inline(never) fileprivate func _bjs_struct_lower_MathOperations(_ objectId: Int32) -> Void { - return _bjs_struct_lower_MathOperations_extern(objectId) + +@_expose(wasm, "bjs_makePolygonInspector") +@_cdecl("bjs_makePolygonInspector") +public func _bjs_makePolygonInspector() -> Int32 { + #if arch(wasm32) + let ret = makePolygonInspector() + return JSTypedClosure(ret).bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif } -#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 { +@_expose(wasm, "bjs_roundTripOptionalPolygonArray") +@_cdecl("bjs_roundTripOptionalPolygonArray") +public func _bjs_roundTripOptionalPolygonArray() -> Void { + #if arch(wasm32) + let ret = roundTripOptionalPolygonArray(_: [Optional].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeTagHolder") +@_cdecl("bjs_makeTagHolder") +public func _bjs_makeTagHolder(_ nameBytes: Int32, _ nameLength: Int32, _ version: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = makeTagHolder(_: String.bridgeJSLiftParameter(nameBytes, nameLength), _: Int.bridgeJSLiftParameter(version)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripCoordinate") +@_cdecl("bjs_roundTripCoordinate") +public func _bjs_roundTripCoordinate() -> Void { + #if arch(wasm32) + let ret = roundTripCoordinate(_: Coordinate.bridgeJSLiftParameter()) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripPriority") +@_cdecl("bjs_roundTripPriority") +public func _bjs_roundTripPriority(_ priority: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = roundTripPriority(_: Priority.bridgeJSLiftParameter(priority)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripAlert") +@_cdecl("bjs_roundTripAlert") +public func _bjs_roundTripAlert(_ alert: Int32) -> Int32 { + #if arch(wasm32) + let ret = roundTripAlert(_: Alert.bridgeJSLiftParameter(alert)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_makeAlert") +@_cdecl("bjs_makeAlert") +public func _bjs_makeAlert(_ level: Int32) -> Int32 { + #if arch(wasm32) + let ret = makeAlert(_: Severity.bridgeJSLiftParameter(level)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_roundTripShape") +@_cdecl("bjs_roundTripShape") +public func _bjs_roundTripShape(_ s: Int32) -> Void { + #if arch(wasm32) + let ret = roundTripShape(_: Shape.bridgeJSLiftParameter(s)) + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_MathOperations() -> Int32 { - return _bjs_struct_lift_MathOperations_extern() + #endif } -@_expose(wasm, "bjs_MathOperations_init") -@_cdecl("bjs_MathOperations_init") -public func _bjs_MathOperations_init(_ baseValue: Float64) -> Void { +@_expose(wasm, "bjs_makeShapePolygon") +@_cdecl("bjs_makeShapePolygon") +public func _bjs_makeShapePolygon(_ polygon: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = MathOperations(baseValue: Double.bridgeJSLiftParameter(baseValue)) + let ret = makeShapePolygon(_: Polygon.bridgeJSLiftParameter(polygon)) 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 { +@_expose(wasm, "bjs_makeShapeEmpty") +@_cdecl("bjs_makeShapeEmpty") +public func _bjs_makeShapeEmpty() -> Void { #if arch(wasm32) - let ret = MathOperations.bridgeJSLiftParameter().add(a: Double.bridgeJSLiftParameter(a), b: Double.bridgeJSLiftParameter(b)) + let ret = makeShapeEmpty() 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 { +@_expose(wasm, "bjs_roundTripUserId") +@_cdecl("bjs_roundTripUserId") +public func _bjs_roundTripUserId(_ id: Int32) -> Int32 { #if arch(wasm32) - let ret = MathOperations.bridgeJSLiftParameter().multiply(a: Double.bridgeJSLiftParameter(a), b: Double.bridgeJSLiftParameter(b)) + let ret = roundTripUserId(_: UserId.bridgeJSLiftParameter(id)) 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 { +@_expose(wasm, "bjs_roundTripOptionalUserId") +@_cdecl("bjs_roundTripOptionalUserId") +public func _bjs_roundTripOptionalUserId(_ idIsSome: Int32, _ idValue: Int32) -> Void { #if arch(wasm32) - let ret = MathOperations.subtract(a: Double.bridgeJSLiftParameter(a), b: Double.bridgeJSLiftParameter(b)) + let ret = roundTripOptionalUserId(_: Optional.bridgeJSLiftParameter(idIsSome, idValue)) 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 { +@_expose(wasm, "bjs_roundTripUserIdArray") +@_cdecl("bjs_roundTripUserIdArray") +public func _bjs_roundTripUserIdArray() -> Void { + #if arch(wasm32) + let ret = roundTripUserIdArray(_: [UserId].bridgeJSStackPop()) + ret.bridgeJSStackPush() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_CopyableCart(_ objectId: Int32) -> Void { - return _bjs_struct_lower_CopyableCart_extern(objectId) + #endif } -#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 { +@_expose(wasm, "bjs_roundTripBoxed") +@_cdecl("bjs_roundTripBoxed") +public func _bjs_roundTripBoxed(_ boxedKind: Int32, _ boxedPayload1: Int32, _ boxedPayload2: Float64) -> Void { + #if arch(wasm32) + let ret = roundTripBoxed(_: Boxed.bridgeJSLiftParameter(boxedKind, boxedPayload1, boxedPayload2)) + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_CopyableCart() -> Int32 { - return _bjs_struct_lift_CopyableCart_extern() + #endif } -@_expose(wasm, "bjs_CopyableCart_static_fromJSObject") -@_cdecl("bjs_CopyableCart_static_fromJSObject") -public func _bjs_CopyableCart_static_fromJSObject(_ object: Int32) -> Void { +@_expose(wasm, "bjs_roundTripOptionalBoxed") +@_cdecl("bjs_roundTripOptionalBoxed") +public func _bjs_roundTripOptionalBoxed(_ boxedIsSome: Int32, _ boxedKind: Int32, _ boxedPayload1: Int32, _ boxedPayload2: Float64) -> Void { #if arch(wasm32) - let ret = CopyableCart.fromJSObject(_: JSObject.bridgeJSLiftParameter(object)) + let ret = roundTripOptionalBoxed(_: Optional.bridgeJSLiftParameter(boxedIsSome, boxedKind, boxedPayload1, boxedPayload2)) 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())) +@_expose(wasm, "bjs_awaitAsyncCallback") +@_cdecl("bjs_awaitAsyncCallback") +public func _bjs_awaitAsyncCallback(_ fetch: Int32) -> Int32 { + #if arch(wasm32) + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { () async throws(JSException) -> String in + return try await awaitAsyncCallback(_: _BJS_Closure_20BridgeJSRuntimeTestsYaKSS_SS.bridgeJSLift(fetch)) } -} - -#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 { + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_CopyableCartItem(_ objectId: Int32) -> Void { - return _bjs_struct_lower_CopyableCartItem_extern(objectId) + #endif } -#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 { +@_expose(wasm, "bjs_makeAsyncParser") +@_cdecl("bjs_makeAsyncParser") +public func _bjs_makeAsyncParser() -> Int32 { + #if arch(wasm32) + let ret = makeAsyncParser() + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") + #endif } -#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())) - } +@_expose(wasm, "bjs_makeAsyncEcho") +@_cdecl("bjs_makeAsyncEcho") +public func _bjs_makeAsyncEcho() -> Int32 { + #if arch(wasm32) + let ret = makeAsyncEcho() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif } -#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 { +@_expose(wasm, "bjs_makeAsyncRecorder") +@_cdecl("bjs_makeAsyncRecorder") +public func _bjs_makeAsyncRecorder() -> Int32 { + #if arch(wasm32) + let ret = makeAsyncRecorder() + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_CopyableNestedCart(_ objectId: Int32) -> Void { - return _bjs_struct_lower_CopyableNestedCart_extern(objectId) + #endif } -#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 { +@_expose(wasm, "bjs_lastRecordedValue") +@_cdecl("bjs_lastRecordedValue") +public func _bjs_lastRecordedValue() -> Void { + #if arch(wasm32) + let ret = lastRecordedValue() + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_CopyableNestedCart() -> Int32 { - return _bjs_struct_lift_CopyableNestedCart_extern() + #endif } -@_expose(wasm, "bjs_CopyableNestedCart_static_fromJSObject") -@_cdecl("bjs_CopyableNestedCart_static_fromJSObject") -public func _bjs_CopyableNestedCart_static_fromJSObject(_ object: Int32) -> Void { +@_expose(wasm, "bjs_makeAsyncPayloadLoader") +@_cdecl("bjs_makeAsyncPayloadLoader") +public func _bjs_makeAsyncPayloadLoader() -> Int32 { #if arch(wasm32) - let ret = CopyableNestedCart.fromJSObject(_: JSObject.bridgeJSLiftParameter(object)) + let ret = makeAsyncPayloadLoader() 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())) +@_expose(wasm, "bjs_awaitPayloadCallback") +@_cdecl("bjs_awaitPayloadCallback") +public func _bjs_awaitPayloadCallback(_ load: Int32) -> Int32 { + #if arch(wasm32) + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { () async throws(JSException) -> String in + return try await awaitPayloadCallback(_: _BJS_Closure_20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO.bridgeJSLift(load)) } + #else + fatalError("Only available on WebAssembly") + #endif } -#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 { +@_expose(wasm, "bjs_makeAsyncPointMaker") +@_cdecl("bjs_makeAsyncPointMaker") +public func _bjs_makeAsyncPointMaker() -> Int32 { + #if arch(wasm32) + let ret = makeAsyncPointMaker() + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lower_ConfigStruct(_ objectId: Int32) -> Void { - return _bjs_struct_lower_ConfigStruct_extern(objectId) + #endif } -#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 { +@_expose(wasm, "bjs_makeThrowingParser") +@_cdecl("bjs_makeThrowingParser") +public func _bjs_makeThrowingParser() -> Int32 { + #if arch(wasm32) + let ret = makeThrowingParser() + return ret.bridgeJSLowerReturn() + #else fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_struct_lift_ConfigStruct() -> Int32 { - return _bjs_struct_lift_ConfigStruct_extern() + #endif } -@_expose(wasm, "bjs_ConfigStruct_static_defaultConfig_get") -@_cdecl("bjs_ConfigStruct_static_defaultConfig_get") -public func _bjs_ConfigStruct_static_defaultConfig_get() -> Void { +@_expose(wasm, "bjs_runValidator") +@_cdecl("bjs_runValidator") +public func _bjs_runValidator(_ validate: Int32) -> Int32 { #if arch(wasm32) - let ret = ConfigStruct.defaultConfig - return ret.bridgeJSLowerReturn() + do { + let ret = try runValidator(_: _BJS_Closure_20BridgeJSRuntimeTestsKSS_Sb.bridgeJSLift(validate)) + 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: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } #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 { +@_expose(wasm, "bjs_roundTripVoid") +@_cdecl("bjs_roundTripVoid") +public func _bjs_roundTripVoid() -> Void { #if arch(wasm32) - ConfigStruct.defaultConfig = String.bridgeJSLiftParameter(valueBytes, valueLength) + roundTripVoid() #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 { +@_expose(wasm, "bjs_roundTripFloat") +@_cdecl("bjs_roundTripFloat") +public func _bjs_roundTripFloat(_ v: Float32) -> Float32 { #if arch(wasm32) - let ret = ConfigStruct.maxRetries + let ret = roundTripFloat(v: Float.bridgeJSLiftParameter(v)) 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 { +@_expose(wasm, "bjs_roundTripDouble") +@_cdecl("bjs_roundTripDouble") +public func _bjs_roundTripDouble(_ v: Float64) -> Float64 { #if arch(wasm32) - let ret = ConfigStruct.timeout + let ret = roundTripDouble(v: Double.bridgeJSLiftParameter(v)) 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 { +@_expose(wasm, "bjs_roundTripBool") +@_cdecl("bjs_roundTripBool") +public func _bjs_roundTripBool(_ v: Int32) -> Int32 { #if arch(wasm32) - ConfigStruct.timeout = Double.bridgeJSLiftParameter(value) + let ret = roundTripBool(v: Bool.bridgeJSLiftParameter(v)) + return ret.bridgeJSLowerReturn() #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 { +@_expose(wasm, "bjs_roundTripString") +@_cdecl("bjs_roundTripString") +public func _bjs_roundTripString(_ vBytes: Int32, _ vLength: Int32) -> Void { #if arch(wasm32) - let ret = ConfigStruct.computedSetting + let ret = roundTripString(v: String.bridgeJSLiftParameter(vBytes, vLength)) 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 { +@_expose(wasm, "bjs_roundTripSwiftHeapObject") +@_cdecl("bjs_roundTripSwiftHeapObject") +public func _bjs_roundTripSwiftHeapObject(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = Vector2D(dx: Double.bridgeJSLiftParameter(dx), dy: Double.bridgeJSLiftParameter(dy)) + let ret = roundTripSwiftHeapObject(v: Greeter.bridgeJSLiftParameter(v)) 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 { +@_expose(wasm, "bjs_roundTripUnsafeRawPointer") +@_cdecl("bjs_roundTripUnsafeRawPointer") +public func _bjs_roundTripUnsafeRawPointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = Vector2D.bridgeJSLiftParameter().magnitude() + let ret = roundTripUnsafeRawPointer(v: UnsafeRawPointer.bridgeJSLiftParameter(v)) 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 { +@_expose(wasm, "bjs_roundTripUnsafeMutableRawPointer") +@_cdecl("bjs_roundTripUnsafeMutableRawPointer") +public func _bjs_roundTripUnsafeMutableRawPointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = Vector2D.bridgeJSLiftParameter().scaled(by: Double.bridgeJSLiftParameter(factor)) + let ret = roundTripUnsafeMutableRawPointer(v: UnsafeMutableRawPointer.bridgeJSLiftParameter(v)) 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 { +@_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 -@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())) - } + #endif } -#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 { +@_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 -@inline(never) fileprivate func _bjs_struct_lower_FooContainer(_ objectId: Int32) -> Void { - return _bjs_struct_lower_FooContainer_extern(objectId) + #endif } -#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 { +@_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 } -#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())) - } +@_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 } -#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 { +@_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 -@inline(never) fileprivate func _bjs_struct_lower_ArrayMembers(_ objectId: Int32) -> Void { - return _bjs_struct_lower_ArrayMembers_extern(objectId) + #endif } -#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 { +@_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 -@inline(never) fileprivate func _bjs_struct_lift_ArrayMembers() -> Int32 { - return _bjs_struct_lift_ArrayMembers_extern() + #endif } -@_expose(wasm, "bjs_ArrayMembers_sumValues") -@_cdecl("bjs_ArrayMembers_sumValues") -public func _bjs_ArrayMembers_sumValues() -> Int32 { +@_expose(wasm, "bjs_roundTripJSValue") +@_cdecl("bjs_roundTripJSValue") +public func _bjs_roundTripJSValue(_ vKind: Int32, _ vPayload1: Int32, _ vPayload2: Float64) -> Void { #if arch(wasm32) - let ret = ArrayMembers.bridgeJSLiftParameter().sumValues(_: [Int].bridgeJSStackPop()) + let ret = roundTripJSValue(v: JSValue.bridgeJSLiftParameter(vKind, vPayload1, vPayload2)) 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 { +@_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 = ArrayMembers.bridgeJSLiftParameter().firstString(_: [String].bridgeJSStackPop()) + let ret = roundTripOptionalJSValue(v: Optional.bridgeJSLiftParameter(vIsSome, vKind, vPayload1, vPayload2)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeTag") -@_cdecl("bjs_makeTag") -public func _bjs_makeTag(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_roundTripOptionalJSValueArray") +@_cdecl("bjs_roundTripOptionalJSValueArray") +public func _bjs_roundTripOptionalJSValueArray() -> Void { #if arch(wasm32) - let ret = makeTag(_: String.bridgeJSLiftParameter(nameBytes, nameLength)) - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = roundTripOptionalJSValueArray(v: Optional<[JSValue]>.bridgeJSLiftParameter()) + ret.bridgeJSStackPush() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripPolygon") -@_cdecl("bjs_roundTripPolygon") -public func _bjs_roundTripPolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_makeImportedFoo") +@_cdecl("bjs_makeImportedFoo") +public func _bjs_makeImportedFoo(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripPolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) - return ret.bridgeToJS().bridgeJSLowerReturn() + 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: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_appendVertex") -@_cdecl("bjs_appendVertex") -public func _bjs_appendVertex(_ polygon: UnsafeMutableRawPointer, _ value: Float64) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_roundTripOptionalImportedClass") +@_cdecl("bjs_roundTripOptionalImportedClass") +public func _bjs_roundTripOptionalImportedClass(_ vIsSome: Int32, _ vValue: Int32) -> Void { #if arch(wasm32) - let ret = appendVertex(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon)), _: Double.bridgeJSLiftParameter(value)) - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = roundTripOptionalImportedClass(v: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_optionalRoundTripPolygon") -@_cdecl("bjs_optionalRoundTripPolygon") -public func _bjs_optionalRoundTripPolygon(_ polygonIsSome: Int32, _ polygonValue: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_throwsSwiftError") +@_cdecl("bjs_throwsSwiftError") +public func _bjs_throwsSwiftError(_ shouldThrow: Int32) -> Void { #if arch(wasm32) - let ret = optionalRoundTripPolygon(_: Optional.bridgeJSLiftParameter(polygonIsSome, polygonValue).map { Polygon.bridgeFromJS($0) }) - return ret.map { $0.bridgeToJS() }.bridgeJSLowerReturn() + 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: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_polygonVertexCount") -@_cdecl("bjs_polygonVertexCount") -public func _bjs_polygonVertexCount(_ polygon: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_throwsWithIntResult") +@_cdecl("bjs_throwsWithIntResult") +public func _bjs_throwsWithIntResult() -> Int32 { #if arch(wasm32) - let ret = polygonVertexCount(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) - return ret.bridgeJSLowerReturn() + 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: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripPolygonArray") -@_cdecl("bjs_roundTripPolygonArray") -public func _bjs_roundTripPolygonArray() -> Void { +@_expose(wasm, "bjs_throwsWithStringResult") +@_cdecl("bjs_throwsWithStringResult") +public func _bjs_throwsWithStringResult() -> Void { #if arch(wasm32) - let ret = roundTripPolygonArray(_: [PolygonReference].bridgeJSStackPop().map { Polygon.bridgeFromJS($0) }) - ret.map { $0.bridgeToJS() }.bridgeJSStackPush() + 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: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_concatPolygons") -@_cdecl("bjs_concatPolygons") -public func _bjs_concatPolygons() -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_throwsWithBoolResult") +@_cdecl("bjs_throwsWithBoolResult") +public func _bjs_throwsWithBoolResult() -> Int32 { #if arch(wasm32) - let ret = concatPolygons(_: [PolygonReference].bridgeJSStackPop().map { Polygon.bridgeFromJS($0) }) - return ret.bridgeToJS().bridgeJSLowerReturn() + 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: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_validatePolygon") -@_cdecl("bjs_validatePolygon") -public func _bjs_validatePolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_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: error.description) + 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: error.description) + 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 validatePolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) - return ret.bridgeToJS().bridgeJSLowerReturn() + 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)) + let jsError = JSError(message: error.description) withExtendedLifetime(jsError.jsObject) { _swift_js_throw(Int32(bitPattern: $0.id)) } @@ -7095,3771 +8621,3869 @@ public func _bjs_validatePolygon(_ polygon: UnsafeMutableRawPointer) -> UnsafeMu #endif } -@_expose(wasm, "bjs_splitPolygon") -@_cdecl("bjs_splitPolygon") -public func _bjs_splitPolygon(_ polygon: UnsafeMutableRawPointer) -> Void { +@_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: error.description) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return 0 + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_zeroArgAsyncThrows") +@_cdecl("bjs_zeroArgAsyncThrows") +public func _bjs_zeroArgAsyncThrows() -> Int32 { #if arch(wasm32) - let ret = splitPolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) - ret.map { $0.bridgeToJS() }.bridgeJSStackPush() + let __bjs_capture = 0 + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { [__bjs_capture] () async throws(JSException) -> String in + _ = __bjs_capture + return try await zeroArgAsyncThrows() + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_incrementToken") -@_cdecl("bjs_incrementToken") -public func _bjs_incrementToken(_ token: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_asyncRoundTripVoid") +@_cdecl("bjs_asyncRoundTripVoid") +public func _bjs_asyncRoundTripVoid() -> Int32 { #if arch(wasm32) - let ret = incrementToken(_: Token.bridgeFromJS(TokenReference.bridgeJSLiftParameter(token))) - return ret.bridgeToJS().bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_y, reject: Promise_reject) { + await asyncRoundTripVoid() + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeToken") -@_cdecl("bjs_makeToken") -public func _bjs_makeToken(_ value: Int32) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_asyncRoundTripInt") +@_cdecl("bjs_asyncRoundTripInt") +public func _bjs_asyncRoundTripInt(_ v: Int32) -> Int32 { #if arch(wasm32) - let ret = makeToken(_: Int.bridgeJSLiftParameter(value)) - return ret.bridgeToJS().bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_Si, reject: Promise_reject) { + return await asyncRoundTripInt(v: Int.bridgeJSLiftParameter(v)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makePolygonInspector") -@_cdecl("bjs_makePolygonInspector") -public func _bjs_makePolygonInspector() -> Int32 { +@_expose(wasm, "bjs_asyncRoundTripFloat") +@_cdecl("bjs_asyncRoundTripFloat") +public func _bjs_asyncRoundTripFloat(_ v: Float32) -> Int32 { #if arch(wasm32) - let ret = makePolygonInspector() - return JSTypedClosure(ret).bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_Sf, reject: Promise_reject) { + return await asyncRoundTripFloat(v: Float.bridgeJSLiftParameter(v)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncMakePolygon") -@_cdecl("bjs_asyncMakePolygon") -public func _bjs_asyncMakePolygon(_ labelBytes: Int32, _ labelLength: Int32) -> Int32 { +@_expose(wasm, "bjs_asyncRoundTripDouble") +@_cdecl("bjs_asyncRoundTripDouble") +public func _bjs_asyncRoundTripDouble(_ v: Float64) -> Int32 { #if arch(wasm32) - let ret = JSPromise.async { - return await asyncMakePolygon(_: String.bridgeJSLiftParameter(labelBytes, labelLength)).bridgeToJS().jsValue - }.jsObject - return ret.bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_Sd, reject: Promise_reject) { + return await asyncRoundTripDouble(v: Double.bridgeJSLiftParameter(v)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripOptionalPolygonArray") -@_cdecl("bjs_roundTripOptionalPolygonArray") -public func _bjs_roundTripOptionalPolygonArray() -> Void { +@_expose(wasm, "bjs_asyncRoundTripBool") +@_cdecl("bjs_asyncRoundTripBool") +public func _bjs_asyncRoundTripBool(_ v: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripOptionalPolygonArray(_: [Optional].bridgeJSStackPop().map { $0.map { Polygon.bridgeFromJS($0) } }) - ret.map { $0.map { $0.bridgeToJS() } }.bridgeJSStackPush() + return _bjs_makePromise(resolve: Promise_resolve_Sb, reject: Promise_reject) { + return await asyncRoundTripBool(v: Bool.bridgeJSLiftParameter(v)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeTagHolder") -@_cdecl("bjs_makeTagHolder") -public func _bjs_makeTagHolder(_ nameBytes: Int32, _ nameLength: Int32, _ version: Int32) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_asyncRoundTripString") +@_cdecl("bjs_asyncRoundTripString") +public func _bjs_asyncRoundTripString(_ vBytes: Int32, _ vLength: Int32) -> Int32 { #if arch(wasm32) - let ret = makeTagHolder(_: String.bridgeJSLiftParameter(nameBytes, nameLength), _: Int.bridgeJSLiftParameter(version)) - return ret.bridgeToJS().bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_SS, reject: Promise_reject) { + return await asyncRoundTripString(v: String.bridgeJSLiftParameter(vBytes, vLength)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripCoordinate") -@_cdecl("bjs_roundTripCoordinate") -public func _bjs_roundTripCoordinate() -> Void { +@_expose(wasm, "bjs_asyncRoundTripSwiftHeapObject") +@_cdecl("bjs_asyncRoundTripSwiftHeapObject") +public func _bjs_asyncRoundTripSwiftHeapObject(_ v: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = roundTripCoordinate(_: Coordinate.bridgeFromJS(JSCoordinate.bridgeJSLiftParameter())) - return ret.bridgeToJS().bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_7GreeterC, reject: Promise_reject) { + return await asyncRoundTripSwiftHeapObject(v: Greeter.bridgeJSLiftParameter(v)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripPriority") -@_cdecl("bjs_roundTripPriority") -public func _bjs_roundTripPriority(_ priority: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_asyncRoundTripJSObject") +@_cdecl("bjs_asyncRoundTripJSObject") +public func _bjs_asyncRoundTripJSObject(_ v: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripPriority(_: Priority.bridgeFromJS(PriorityReference.bridgeJSLiftParameter(priority))) - return ret.bridgeToJS().bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_8JSObjectC, reject: Promise_reject) { + return await asyncRoundTripJSObject(v: JSObject.bridgeJSLiftParameter(v)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripAlert") -@_cdecl("bjs_roundTripAlert") -public func _bjs_roundTripAlert(_ alert: Int32) -> Int32 { +@_expose(wasm, "bjs_takeGreeter") +@_cdecl("bjs_takeGreeter") +public func _bjs_takeGreeter(_ g: UnsafeMutableRawPointer, _ nameBytes: Int32, _ nameLength: Int32) -> Void { #if arch(wasm32) - let ret = roundTripAlert(_: Alert.bridgeFromJS(Severity.bridgeJSLiftParameter(alert))) - return ret.bridgeToJS().bridgeJSLowerReturn() + takeGreeter(g: Greeter.bridgeJSLiftParameter(g), name: String.bridgeJSLiftParameter(nameBytes, nameLength)) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAlert") -@_cdecl("bjs_makeAlert") -public func _bjs_makeAlert(_ level: Int32) -> Int32 { +@_expose(wasm, "bjs_createCalculator") +@_cdecl("bjs_createCalculator") +public func _bjs_createCalculator() -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = makeAlert(_: Severity.bridgeJSLiftParameter(level)) - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = createCalculator() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripSession") -@_cdecl("bjs_roundTripSession") -public func _bjs_roundTripSession() -> Void { +@_expose(wasm, "bjs_useCalculator") +@_cdecl("bjs_useCalculator") +public func _bjs_useCalculator(_ calc: UnsafeMutableRawPointer, _ x: Int32, _ y: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripSession(_: Session.bridgeFromJS(SessionState.bridgeJSLiftParameter())) - return ret.bridgeToJS().bridgeJSLowerReturn() + 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_makeSession") -@_cdecl("bjs_makeSession") -public func _bjs_makeSession(_ tokenBytes: Int32, _ tokenLength: Int32) -> Void { +@_expose(wasm, "bjs_testGreeterToJSValue") +@_cdecl("bjs_testGreeterToJSValue") +public func _bjs_testGreeterToJSValue() -> Int32 { #if arch(wasm32) - let ret = makeSession(_: String.bridgeJSLiftParameter(tokenBytes, tokenLength)) - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = testGreeterToJSValue() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripShape") -@_cdecl("bjs_roundTripShape") -public func _bjs_roundTripShape(_ s: Int32) -> Void { +@_expose(wasm, "bjs_testCalculatorToJSValue") +@_cdecl("bjs_testCalculatorToJSValue") +public func _bjs_testCalculatorToJSValue() -> Int32 { #if arch(wasm32) - let ret = roundTripShape(_: Shape.bridgeJSLiftParameter(s)) + let ret = testCalculatorToJSValue() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeShapePolygon") -@_cdecl("bjs_makeShapePolygon") -public func _bjs_makeShapePolygon(_ polygon: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_testSwiftClassAsJSValue") +@_cdecl("bjs_testSwiftClassAsJSValue") +public func _bjs_testSwiftClassAsJSValue(_ greeter: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = makeShapePolygon(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(polygon))) + let ret = testSwiftClassAsJSValue(greeter: Greeter.bridgeJSLiftParameter(greeter)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeShapeEmpty") -@_cdecl("bjs_makeShapeEmpty") -public func _bjs_makeShapeEmpty() -> Void { +@_expose(wasm, "bjs_setDirection") +@_cdecl("bjs_setDirection") +public func _bjs_setDirection(_ direction: Int32) -> Int32 { #if arch(wasm32) - let ret = makeShapeEmpty() + let ret = setDirection(_: Direction.bridgeJSLiftParameter(direction)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripVoid") -@_cdecl("bjs_roundTripVoid") -public func _bjs_roundTripVoid() -> Void { +@_expose(wasm, "bjs_getDirection") +@_cdecl("bjs_getDirection") +public func _bjs_getDirection() -> Int32 { #if arch(wasm32) - roundTripVoid() + let ret = getDirection() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripFloat") -@_cdecl("bjs_roundTripFloat") -public func _bjs_roundTripFloat(_ v: Float32) -> Float32 { +@_expose(wasm, "bjs_processDirection") +@_cdecl("bjs_processDirection") +public func _bjs_processDirection(_ input: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripFloat(v: Float.bridgeJSLiftParameter(v)) + let ret = processDirection(_: Direction.bridgeJSLiftParameter(input)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripDouble") -@_cdecl("bjs_roundTripDouble") -public func _bjs_roundTripDouble(_ v: Float64) -> Float64 { +@_expose(wasm, "bjs_setTheme") +@_cdecl("bjs_setTheme") +public func _bjs_setTheme(_ themeBytes: Int32, _ themeLength: Int32) -> Void { #if arch(wasm32) - let ret = roundTripDouble(v: Double.bridgeJSLiftParameter(v)) + let ret = setTheme(_: Theme.bridgeJSLiftParameter(themeBytes, themeLength)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripBool") -@_cdecl("bjs_roundTripBool") -public func _bjs_roundTripBool(_ v: Int32) -> Int32 { +@_expose(wasm, "bjs_getTheme") +@_cdecl("bjs_getTheme") +public func _bjs_getTheme() -> Void { #if arch(wasm32) - let ret = roundTripBool(v: Bool.bridgeJSLiftParameter(v)) + let ret = getTheme() 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 { +@_expose(wasm, "bjs_asyncRoundTripTheme") +@_cdecl("bjs_asyncRoundTripTheme") +public func _bjs_asyncRoundTripTheme(_ vBytes: Int32, _ vLength: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripString(v: String.bridgeJSLiftParameter(vBytes, vLength)) - return ret.bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_5ThemeO, reject: Promise_reject) { + return await asyncRoundTripTheme(_: Theme.bridgeJSLiftParameter(vBytes, vLength)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripSwiftHeapObject") -@_cdecl("bjs_roundTripSwiftHeapObject") -public func _bjs_roundTripSwiftHeapObject(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_asyncRoundTripDirection") +@_cdecl("bjs_asyncRoundTripDirection") +public func _bjs_asyncRoundTripDirection(_ v: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripSwiftHeapObject(v: Greeter.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_9DirectionO, reject: Promise_reject) { + return await asyncRoundTripDirection(_: Direction.bridgeJSLiftParameter(v)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripUnsafeRawPointer") -@_cdecl("bjs_roundTripUnsafeRawPointer") -public func _bjs_roundTripUnsafeRawPointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_asyncRoundTripOptionalTheme") +@_cdecl("bjs_asyncRoundTripOptionalTheme") +public func _bjs_asyncRoundTripOptionalTheme(_ vIsSome: Int32, _ vBytes: Int32, _ vLength: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripUnsafeRawPointer(v: UnsafeRawPointer.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_Sq5ThemeO, reject: Promise_reject) { + return await asyncRoundTripOptionalTheme(_: Optional.bridgeJSLiftParameter(vIsSome, vBytes, vLength)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripUnsafeMutableRawPointer") -@_cdecl("bjs_roundTripUnsafeMutableRawPointer") -public func _bjs_roundTripUnsafeMutableRawPointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_asyncRoundTripOptionalDirection") +@_cdecl("bjs_asyncRoundTripOptionalDirection") +public func _bjs_asyncRoundTripOptionalDirection(_ vIsSome: Int32, _ vValue: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripUnsafeMutableRawPointer(v: UnsafeMutableRawPointer.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_Sq9DirectionO, reject: Promise_reject) { + return await asyncRoundTripOptionalDirection(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripOpaquePointer") -@_cdecl("bjs_roundTripOpaquePointer") -public func _bjs_roundTripOpaquePointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_asyncRoundTripDirectionArray") +@_cdecl("bjs_asyncRoundTripDirectionArray") +public func _bjs_asyncRoundTripDirectionArray() -> Int32 { #if arch(wasm32) - let ret = roundTripOpaquePointer(v: OpaquePointer.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() + let _tmp_v = [Direction].bridgeJSStackPop() + return _bjs_makePromise(resolve: Promise_resolve_Sa9DirectionO, reject: Promise_reject) { + return await asyncRoundTripDirectionArray(_: _tmp_v) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripUnsafePointer") -@_cdecl("bjs_roundTripUnsafePointer") -public func _bjs_roundTripUnsafePointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_asyncRoundTripDirectionDict") +@_cdecl("bjs_asyncRoundTripDirectionDict") +public func _bjs_asyncRoundTripDirectionDict() -> Int32 { #if arch(wasm32) - let ret = roundTripUnsafePointer(v: UnsafePointer.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() + let _tmp_v = [String: Direction].bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_SD9DirectionO, reject: Promise_reject) { + return await asyncRoundTripDirectionDict(_: _tmp_v) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripUnsafeMutablePointer") -@_cdecl("bjs_roundTripUnsafeMutablePointer") -public func _bjs_roundTripUnsafeMutablePointer(_ v: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_asyncRoundTripThemeArray") +@_cdecl("bjs_asyncRoundTripThemeArray") +public func _bjs_asyncRoundTripThemeArray() -> Int32 { #if arch(wasm32) - let ret = roundTripUnsafeMutablePointer(v: UnsafeMutablePointer.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() + let _tmp_v = [Theme].bridgeJSStackPop() + return _bjs_makePromise(resolve: Promise_resolve_Sa5ThemeO, reject: Promise_reject) { + return await asyncRoundTripThemeArray(_: _tmp_v) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripJSObject") -@_cdecl("bjs_roundTripJSObject") -public func _bjs_roundTripJSObject(_ v: Int32) -> Int32 { +@_expose(wasm, "bjs_asyncRoundTripThemeDict") +@_cdecl("bjs_asyncRoundTripThemeDict") +public func _bjs_asyncRoundTripThemeDict() -> Int32 { #if arch(wasm32) - let ret = roundTripJSObject(v: JSObject.bridgeJSLiftParameter(v)) - return ret.bridgeJSLowerReturn() + let _tmp_v = [String: Theme].bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_SD5ThemeO, reject: Promise_reject) { + return await asyncRoundTripThemeDict(_: _tmp_v) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripDictionaryExport") -@_cdecl("bjs_roundTripDictionaryExport") -public func _bjs_roundTripDictionaryExport() -> Void { +@_expose(wasm, "bjs_asyncRoundTripFileSize") +@_cdecl("bjs_asyncRoundTripFileSize") +public func _bjs_asyncRoundTripFileSize(_ v: Int64) -> Int32 { #if arch(wasm32) - let ret = roundTripDictionaryExport(v: [String: Int].bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_8FileSizeO, reject: Promise_reject) { + return await asyncRoundTripFileSize(_: FileSize.bridgeJSLiftParameter(v)) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripOptionalDictionaryExport") -@_cdecl("bjs_roundTripOptionalDictionaryExport") -public func _bjs_roundTripOptionalDictionaryExport() -> Void { +@_expose(wasm, "bjs_asyncRoundTripOptionalFileSize") +@_cdecl("bjs_asyncRoundTripOptionalFileSize") +public func _bjs_asyncRoundTripOptionalFileSize(_ vIsSome: Int32, _ vValue: Int64) -> Int32 { #if arch(wasm32) - let ret = roundTripOptionalDictionaryExport(v: Optional<[String: String]>.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_Sq8FileSizeO, reject: Promise_reject) { + return await asyncRoundTripOptionalFileSize(_: Optional.bridgeJSLiftParameter(vIsSome, vValue)) + } #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 { +@_expose(wasm, "bjs_asyncRoundTripAssociatedValueEnum") +@_cdecl("bjs_asyncRoundTripAssociatedValueEnum") +public func _bjs_asyncRoundTripAssociatedValueEnum(_ v: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripJSValue(v: JSValue.bridgeJSLiftParameter(vKind, vPayload1, vPayload2)) - return ret.bridgeJSLowerReturn() + let _tmp_v = AsyncPayloadResult.bridgeJSLiftParameter(v) + return _bjs_makePromise(resolve: Promise_resolve_18AsyncPayloadResultO, reject: Promise_reject) { + return await asyncRoundTripAssociatedValueEnum(_: _tmp_v) + } #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 { +@_expose(wasm, "bjs_asyncRoundTripOptionalAssociatedValueEnum") +@_cdecl("bjs_asyncRoundTripOptionalAssociatedValueEnum") +public func _bjs_asyncRoundTripOptionalAssociatedValueEnum(_ vIsSome: Int32, _ vCaseId: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripOptionalJSValue(v: Optional.bridgeJSLiftParameter(vIsSome, vKind, vPayload1, vPayload2)) - return ret.bridgeJSLowerReturn() + let _tmp_v = Optional.bridgeJSLiftParameter(vIsSome, vCaseId) + return _bjs_makePromise(resolve: Promise_resolve_Sq18AsyncPayloadResultO, reject: Promise_reject) { + return await asyncRoundTripOptionalAssociatedValueEnum(_: _tmp_v) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripOptionalJSValueArray") -@_cdecl("bjs_roundTripOptionalJSValueArray") -public func _bjs_roundTripOptionalJSValueArray() -> Void { +@_expose(wasm, "bjs_setHttpStatus") +@_cdecl("bjs_setHttpStatus") +public func _bjs_setHttpStatus(_ status: Int32) -> Int32 { #if arch(wasm32) - let ret = roundTripOptionalJSValueArray(v: Optional<[JSValue]>.bridgeJSLiftParameter()) - ret.bridgeJSStackPush() + let ret = setHttpStatus(_: HttpStatus.bridgeJSLiftParameter(status)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeImportedFoo") -@_cdecl("bjs_makeImportedFoo") -public func _bjs_makeImportedFoo(_ valueBytes: Int32, _ valueLength: Int32) -> Int32 { +@_expose(wasm, "bjs_getHttpStatus") +@_cdecl("bjs_getHttpStatus") +public func _bjs_getHttpStatus() -> 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 - } + let ret = getHttpStatus() + return ret.bridgeJSLowerReturn() #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 - } + +@_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_throwsWithIntResult") -@_cdecl("bjs_throwsWithIntResult") -public func _bjs_throwsWithIntResult() -> Int32 { +@_expose(wasm, "bjs_getFileSize") +@_cdecl("bjs_getFileSize") +public func _bjs_getFileSize() -> Int64 { #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 - } + let ret = getFileSize() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_throwsWithStringResult") -@_cdecl("bjs_throwsWithStringResult") -public func _bjs_throwsWithStringResult() -> Void { +@_expose(wasm, "bjs_setSessionId") +@_cdecl("bjs_setSessionId") +public func _bjs_setSessionId(_ session: Int64) -> Int64 { #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 - } + let ret = setSessionId(_: SessionId.bridgeJSLiftParameter(session)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_throwsWithBoolResult") -@_cdecl("bjs_throwsWithBoolResult") -public func _bjs_throwsWithBoolResult() -> Int32 { +@_expose(wasm, "bjs_getSessionId") +@_cdecl("bjs_getSessionId") +public func _bjs_getSessionId() -> Int64 { #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 - } + let ret = getSessionId() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_throwsWithFloatResult") -@_cdecl("bjs_throwsWithFloatResult") -public func _bjs_throwsWithFloatResult() -> Float32 { +@_expose(wasm, "bjs_processTheme") +@_cdecl("bjs_processTheme") +public func _bjs_processTheme(_ themeBytes: Int32, _ themeLength: Int32) -> Int32 { #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 - } + let ret = processTheme(_: Theme.bridgeJSLiftParameter(themeBytes, themeLength)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_throwsWithDoubleResult") -@_cdecl("bjs_throwsWithDoubleResult") -public func _bjs_throwsWithDoubleResult() -> Float64 { +@_expose(wasm, "bjs_setTSDirection") +@_cdecl("bjs_setTSDirection") +public func _bjs_setTSDirection(_ direction: Int32) -> Int32 { #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 - } + let ret = setTSDirection(_: TSDirection.bridgeJSLiftParameter(direction)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_throwsWithSwiftHeapObjectResult") -@_cdecl("bjs_throwsWithSwiftHeapObjectResult") -public func _bjs_throwsWithSwiftHeapObjectResult() -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_getTSDirection") +@_cdecl("bjs_getTSDirection") +public func _bjs_getTSDirection() -> Int32 { #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 - } + let ret = getTSDirection() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_throwsWithJSObjectResult") -@_cdecl("bjs_throwsWithJSObjectResult") -public func _bjs_throwsWithJSObjectResult() -> Int32 { +@_expose(wasm, "bjs_setTSTheme") +@_cdecl("bjs_setTSTheme") +public func _bjs_setTSTheme(_ themeBytes: Int32, _ themeLength: Int32) -> Void { #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 - } + let ret = setTSTheme(_: TSTheme.bridgeJSLiftParameter(themeBytes, themeLength)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripVoid") -@_cdecl("bjs_asyncRoundTripVoid") -public func _bjs_asyncRoundTripVoid() -> Int32 { +@_expose(wasm, "bjs_getTSTheme") +@_cdecl("bjs_getTSTheme") +public func _bjs_getTSTheme() -> Void { #if arch(wasm32) - let ret = JSPromise.async { - await asyncRoundTripVoid() - }.jsObject + let ret = getTSTheme() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripInt") -@_cdecl("bjs_asyncRoundTripInt") -public func _bjs_asyncRoundTripInt(_ v: Int32) -> Int32 { +@_expose(wasm, "bjs_createConverter") +@_cdecl("bjs_createConverter") +public func _bjs_createConverter() -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripInt(v: Int.bridgeJSLiftParameter(v)).jsValue - }.jsObject + let ret = createConverter() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripFloat") -@_cdecl("bjs_asyncRoundTripFloat") -public func _bjs_asyncRoundTripFloat(_ v: Float32) -> Int32 { +@_expose(wasm, "bjs_useConverter") +@_cdecl("bjs_useConverter") +public func _bjs_useConverter(_ converter: UnsafeMutableRawPointer, _ value: Int32) -> Void { #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripFloat(v: Float.bridgeJSLiftParameter(v)).jsValue - }.jsObject + 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_asyncRoundTripDouble") -@_cdecl("bjs_asyncRoundTripDouble") -public func _bjs_asyncRoundTripDouble(_ v: Float64) -> Int32 { +@_expose(wasm, "bjs_roundTripConverterArray") +@_cdecl("bjs_roundTripConverterArray") +public func _bjs_roundTripConverterArray() -> Void { #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripDouble(v: Double.bridgeJSLiftParameter(v)).jsValue - }.jsObject - return ret.bridgeJSLowerReturn() + let ret = roundTripConverterArray(_: [Utils.Converter].bridgeJSStackPop()) + ret.bridgeJSStackPush() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripBool") -@_cdecl("bjs_asyncRoundTripBool") -public func _bjs_asyncRoundTripBool(_ v: Int32) -> Int32 { +@_expose(wasm, "bjs_createHTTPServer") +@_cdecl("bjs_createHTTPServer") +public func _bjs_createHTTPServer() -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripBool(v: Bool.bridgeJSLiftParameter(v)).jsValue - }.jsObject + let ret = createHTTPServer() 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 { +@_expose(wasm, "bjs_createUUID") +@_cdecl("bjs_createUUID") +public func _bjs_createUUID(_ valueBytes: Int32, _ valueLength: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripString(v: String.bridgeJSLiftParameter(vBytes, vLength)).jsValue - }.jsObject + let ret = createUUID(value: String.bridgeJSLiftParameter(valueBytes, valueLength)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripSwiftHeapObject") -@_cdecl("bjs_asyncRoundTripSwiftHeapObject") -public func _bjs_asyncRoundTripSwiftHeapObject(_ v: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_roundTripUUID") +@_cdecl("bjs_roundTripUUID") +public func _bjs_roundTripUUID(_ uuid: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripSwiftHeapObject(v: Greeter.bridgeJSLiftParameter(v)).jsValue - }.jsObject + let ret = roundTripUUID(_: UUID.bridgeJSLiftParameter(uuid)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_asyncRoundTripJSObject") -@_cdecl("bjs_asyncRoundTripJSObject") -public func _bjs_asyncRoundTripJSObject(_ v: Int32) -> Int32 { +@_expose(wasm, "bjs_roundtripNetworkingAPIMethod") +@_cdecl("bjs_roundtripNetworkingAPIMethod") +public func _bjs_roundtripNetworkingAPIMethod(_ method: Int32) -> Int32 { #if arch(wasm32) - let ret = JSPromise.async { - return await asyncRoundTripJSObject(v: JSObject.bridgeJSLiftParameter(v)).jsValue - }.jsObject + let ret = roundtripNetworkingAPIMethod(_: Networking.API.Method.bridgeJSLiftParameter(method)) 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 { +@_expose(wasm, "bjs_roundtripConfigurationLogLevel") +@_cdecl("bjs_roundtripConfigurationLogLevel") +public func _bjs_roundtripConfigurationLogLevel(_ levelBytes: Int32, _ levelLength: Int32) -> Void { #if arch(wasm32) - takeGreeter(g: Greeter.bridgeJSLiftParameter(g), name: String.bridgeJSLiftParameter(nameBytes, nameLength)) + let ret = roundtripConfigurationLogLevel(_: Configuration.LogLevel.bridgeJSLiftParameter(levelBytes, levelLength)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_createCalculator") -@_cdecl("bjs_createCalculator") -public func _bjs_createCalculator() -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_roundtripConfigurationPort") +@_cdecl("bjs_roundtripConfigurationPort") +public func _bjs_roundtripConfigurationPort(_ port: Int32) -> Int32 { #if arch(wasm32) - let ret = createCalculator() + let ret = roundtripConfigurationPort(_: Configuration.Port.bridgeJSLiftParameter(port)) 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 { +@_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 = useCalculator(calc: Calculator.bridgeJSLiftParameter(calc), x: Int.bridgeJSLiftParameter(x), y: Int.bridgeJSLiftParameter(y)) + let ret = roundtripInternalSupportedMethod(_: Internal.SupportedMethod.bridgeJSLiftParameter(method)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_testGreeterToJSValue") -@_cdecl("bjs_testGreeterToJSValue") -public func _bjs_testGreeterToJSValue() -> Int32 { +@_expose(wasm, "bjs_roundtripAPIResult") +@_cdecl("bjs_roundtripAPIResult") +public func _bjs_roundtripAPIResult(_ result: Int32) -> Void { #if arch(wasm32) - let ret = testGreeterToJSValue() + let ret = roundtripAPIResult(result: APIResult.bridgeJSLiftParameter(result)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_testCalculatorToJSValue") -@_cdecl("bjs_testCalculatorToJSValue") -public func _bjs_testCalculatorToJSValue() -> Int32 { +@_expose(wasm, "bjs_makeAPIResultSuccess") +@_cdecl("bjs_makeAPIResultSuccess") +public func _bjs_makeAPIResultSuccess(_ valueBytes: Int32, _ valueLength: Int32) -> Void { #if arch(wasm32) - let ret = testCalculatorToJSValue() + let ret = makeAPIResultSuccess(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_testSwiftClassAsJSValue") -@_cdecl("bjs_testSwiftClassAsJSValue") -public func _bjs_testSwiftClassAsJSValue(_ greeter: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_makeAPIResultFailure") +@_cdecl("bjs_makeAPIResultFailure") +public func _bjs_makeAPIResultFailure(_ value: Int32) -> Void { #if arch(wasm32) - let ret = testSwiftClassAsJSValue(greeter: Greeter.bridgeJSLiftParameter(greeter)) + let ret = makeAPIResultFailure(_: Int.bridgeJSLiftParameter(value)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_setDirection") -@_cdecl("bjs_setDirection") -public func _bjs_setDirection(_ direction: Int32) -> Int32 { +@_expose(wasm, "bjs_makeAPIResultInfo") +@_cdecl("bjs_makeAPIResultInfo") +public func _bjs_makeAPIResultInfo() -> Void { #if arch(wasm32) - let ret = setDirection(_: Direction.bridgeJSLiftParameter(direction)) + let ret = makeAPIResultInfo() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_getDirection") -@_cdecl("bjs_getDirection") -public func _bjs_getDirection() -> Int32 { +@_expose(wasm, "bjs_makeAPIResultFlag") +@_cdecl("bjs_makeAPIResultFlag") +public func _bjs_makeAPIResultFlag(_ value: Int32) -> Void { #if arch(wasm32) - let ret = getDirection() + let ret = makeAPIResultFlag(_: Bool.bridgeJSLiftParameter(value)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_processDirection") -@_cdecl("bjs_processDirection") -public func _bjs_processDirection(_ input: Int32) -> Int32 { +@_expose(wasm, "bjs_makeAPIResultRate") +@_cdecl("bjs_makeAPIResultRate") +public func _bjs_makeAPIResultRate(_ value: Float32) -> Void { #if arch(wasm32) - let ret = processDirection(_: Direction.bridgeJSLiftParameter(input)) + let ret = makeAPIResultRate(_: Float.bridgeJSLiftParameter(value)) 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 { +@_expose(wasm, "bjs_makeAPIResultPrecise") +@_cdecl("bjs_makeAPIResultPrecise") +public func _bjs_makeAPIResultPrecise(_ value: Float64) -> Void { #if arch(wasm32) - let ret = setTheme(_: Theme.bridgeJSLiftParameter(themeBytes, themeLength)) + let ret = makeAPIResultPrecise(_: Double.bridgeJSLiftParameter(value)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_getTheme") -@_cdecl("bjs_getTheme") -public func _bjs_getTheme() -> Void { +@_expose(wasm, "bjs_roundtripComplexResult") +@_cdecl("bjs_roundtripComplexResult") +public func _bjs_roundtripComplexResult(_ result: Int32) -> Void { #if arch(wasm32) - let ret = getTheme() + let ret = roundtripComplexResult(_: ComplexResult.bridgeJSLiftParameter(result)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_setHttpStatus") -@_cdecl("bjs_setHttpStatus") -public func _bjs_setHttpStatus(_ status: Int32) -> Int32 { +@_expose(wasm, "bjs_makeComplexResultSuccess") +@_cdecl("bjs_makeComplexResultSuccess") +public func _bjs_makeComplexResultSuccess(_ valueBytes: Int32, _ valueLength: Int32) -> Void { #if arch(wasm32) - let ret = setHttpStatus(_: HttpStatus.bridgeJSLiftParameter(status)) + let ret = makeComplexResultSuccess(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_getHttpStatus") -@_cdecl("bjs_getHttpStatus") -public func _bjs_getHttpStatus() -> Int32 { +@_expose(wasm, "bjs_makeComplexResultError") +@_cdecl("bjs_makeComplexResultError") +public func _bjs_makeComplexResultError(_ messageBytes: Int32, _ messageLength: Int32, _ code: Int32) -> Void { #if arch(wasm32) - let ret = getHttpStatus() + let ret = makeComplexResultError(_: String.bridgeJSLiftParameter(messageBytes, messageLength), _: Int.bridgeJSLiftParameter(code)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_setFileSize") -@_cdecl("bjs_setFileSize") -public func _bjs_setFileSize(_ size: Int64) -> Int64 { +@_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 = setFileSize(_: FileSize.bridgeJSLiftParameter(size)) + 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_getFileSize") -@_cdecl("bjs_getFileSize") -public func _bjs_getFileSize() -> Int64 { +@_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 = getFileSize() + 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_setSessionId") -@_cdecl("bjs_setSessionId") -public func _bjs_setSessionId(_ session: Int64) -> Int64 { +@_expose(wasm, "bjs_makeComplexResultCoordinates") +@_cdecl("bjs_makeComplexResultCoordinates") +public func _bjs_makeComplexResultCoordinates(_ x: Float64, _ y: Float64, _ z: Float64) -> Void { #if arch(wasm32) - let ret = setSessionId(_: SessionId.bridgeJSLiftParameter(session)) + 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_getSessionId") -@_cdecl("bjs_getSessionId") -public func _bjs_getSessionId() -> Int64 { +@_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 = getSessionId() + 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_processTheme") -@_cdecl("bjs_processTheme") -public func _bjs_processTheme(_ themeBytes: Int32, _ themeLength: Int32) -> Int32 { +@_expose(wasm, "bjs_makeComplexResultInfo") +@_cdecl("bjs_makeComplexResultInfo") +public func _bjs_makeComplexResultInfo() -> Void { #if arch(wasm32) - let ret = processTheme(_: Theme.bridgeJSLiftParameter(themeBytes, themeLength)) + let ret = makeComplexResultInfo() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_setTSDirection") -@_cdecl("bjs_setTSDirection") -public func _bjs_setTSDirection(_ direction: Int32) -> Int32 { +@_expose(wasm, "bjs_makeUtilitiesResultSuccess") +@_cdecl("bjs_makeUtilitiesResultSuccess") +public func _bjs_makeUtilitiesResultSuccess(_ messageBytes: Int32, _ messageLength: Int32) -> Void { #if arch(wasm32) - let ret = setTSDirection(_: TSDirection.bridgeJSLiftParameter(direction)) + let ret = makeUtilitiesResultSuccess(_: String.bridgeJSLiftParameter(messageBytes, messageLength)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_getTSDirection") -@_cdecl("bjs_getTSDirection") -public func _bjs_getTSDirection() -> Int32 { +@_expose(wasm, "bjs_makeUtilitiesResultFailure") +@_cdecl("bjs_makeUtilitiesResultFailure") +public func _bjs_makeUtilitiesResultFailure(_ errorBytes: Int32, _ errorLength: Int32, _ code: Int32) -> Void { #if arch(wasm32) - let ret = getTSDirection() + let ret = makeUtilitiesResultFailure(_: String.bridgeJSLiftParameter(errorBytes, errorLength), _: Int.bridgeJSLiftParameter(code)) 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 { +@_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 = setTSTheme(_: TSTheme.bridgeJSLiftParameter(themeBytes, themeLength)) + 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_getTSTheme") -@_cdecl("bjs_getTSTheme") -public func _bjs_getTSTheme() -> Void { +@_expose(wasm, "bjs_makeAPINetworkingResultSuccess") +@_cdecl("bjs_makeAPINetworkingResultSuccess") +public func _bjs_makeAPINetworkingResultSuccess(_ messageBytes: Int32, _ messageLength: Int32) -> Void { #if arch(wasm32) - let ret = getTSTheme() + let ret = makeAPINetworkingResultSuccess(_: String.bridgeJSLiftParameter(messageBytes, messageLength)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_createConverter") -@_cdecl("bjs_createConverter") -public func _bjs_createConverter() -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_makeAPINetworkingResultFailure") +@_cdecl("bjs_makeAPINetworkingResultFailure") +public func _bjs_makeAPINetworkingResultFailure(_ errorBytes: Int32, _ errorLength: Int32, _ code: Int32) -> Void { #if arch(wasm32) - let ret = createConverter() + let ret = makeAPINetworkingResultFailure(_: String.bridgeJSLiftParameter(errorBytes, errorLength), _: Int.bridgeJSLiftParameter(code)) 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 { +@_expose(wasm, "bjs_roundtripUtilitiesResult") +@_cdecl("bjs_roundtripUtilitiesResult") +public func _bjs_roundtripUtilitiesResult(_ result: Int32) -> Void { #if arch(wasm32) - let ret = useConverter(converter: Utils.Converter.bridgeJSLiftParameter(converter), value: Int.bridgeJSLiftParameter(value)) + let ret = roundtripUtilitiesResult(_: Utilities.Result.bridgeJSLiftParameter(result)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripConverterArray") -@_cdecl("bjs_roundTripConverterArray") -public func _bjs_roundTripConverterArray() -> Void { +@_expose(wasm, "bjs_roundtripAPINetworkingResult") +@_cdecl("bjs_roundtripAPINetworkingResult") +public func _bjs_roundtripAPINetworkingResult(_ result: Int32) -> Void { #if arch(wasm32) - let ret = roundTripConverterArray(_: [Utils.Converter].bridgeJSStackPop()) - ret.bridgeJSStackPush() + let ret = roundtripAPINetworkingResult(_: API.NetworkingResult.bridgeJSLiftParameter(result)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_createHTTPServer") -@_cdecl("bjs_createHTTPServer") -public func _bjs_createHTTPServer() -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_roundTripAllTypesResult") +@_cdecl("bjs_roundTripAllTypesResult") +public func _bjs_roundTripAllTypesResult(_ result: Int32) -> Void { #if arch(wasm32) - let ret = createHTTPServer() + let ret = roundTripAllTypesResult(_: AllTypesResult.bridgeJSLiftParameter(result)) 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 { +@_expose(wasm, "bjs_roundTripTypedPayloadResult") +@_cdecl("bjs_roundTripTypedPayloadResult") +public func _bjs_roundTripTypedPayloadResult(_ result: Int32) -> Void { #if arch(wasm32) - let ret = createUUID(value: String.bridgeJSLiftParameter(valueBytes, valueLength)) + let ret = roundTripTypedPayloadResult(_: TypedPayloadResult.bridgeJSLiftParameter(result)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripUUID") -@_cdecl("bjs_roundTripUUID") -public func _bjs_roundTripUUID(_ uuid: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_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 = roundTripUUID(_: UUID.bridgeJSLiftParameter(uuid)) + 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_roundtripNetworkingAPIMethod") -@_cdecl("bjs_roundtripNetworkingAPIMethod") -public func _bjs_roundtripNetworkingAPIMethod(_ method: Int32) -> Int32 { +@_expose(wasm, "bjs_testPropertyHolder") +@_cdecl("bjs_testPropertyHolder") +public func _bjs_testPropertyHolder(_ holder: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = roundtripNetworkingAPIMethod(_: Networking.API.Method.bridgeJSLiftParameter(method)) + let ret = testPropertyHolder(holder: PropertyHolder.bridgeJSLiftParameter(holder)) 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 { +@_expose(wasm, "bjs_resetObserverCounts") +@_cdecl("bjs_resetObserverCounts") +public func _bjs_resetObserverCounts() -> Void { #if arch(wasm32) - let ret = roundtripConfigurationLogLevel(_: Configuration.LogLevel.bridgeJSLiftParameter(levelBytes, levelLength)) - return ret.bridgeJSLowerReturn() + resetObserverCounts() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundtripConfigurationPort") -@_cdecl("bjs_roundtripConfigurationPort") -public func _bjs_roundtripConfigurationPort(_ port: Int32) -> Int32 { +@_expose(wasm, "bjs_getObserverStats") +@_cdecl("bjs_getObserverStats") +public func _bjs_getObserverStats() -> Void { #if arch(wasm32) - let ret = roundtripConfigurationPort(_: Configuration.Port.bridgeJSLiftParameter(port)) + let ret = getObserverStats() 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 { +@_expose(wasm, "bjs_formatName") +@_cdecl("bjs_formatName") +public func _bjs_formatName(_ nameBytes: Int32, _ nameLength: Int32, _ transform: Int32) -> Void { #if arch(wasm32) - let ret = processConfigurationLogLevel(_: Configuration.LogLevel.bridgeJSLiftParameter(levelBytes, levelLength)) + 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_roundtripInternalSupportedMethod") -@_cdecl("bjs_roundtripInternalSupportedMethod") -public func _bjs_roundtripInternalSupportedMethod(_ method: Int32) -> Int32 { +@_expose(wasm, "bjs_makeFormatter") +@_cdecl("bjs_makeFormatter") +public func _bjs_makeFormatter(_ prefixBytes: Int32, _ prefixLength: Int32) -> Int32 { #if arch(wasm32) - let ret = roundtripInternalSupportedMethod(_: Internal.SupportedMethod.bridgeJSLiftParameter(method)) - return ret.bridgeJSLowerReturn() + let ret = makeFormatter(prefix: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundtripAPIResult") -@_cdecl("bjs_roundtripAPIResult") -public func _bjs_roundtripAPIResult(_ result: Int32) -> Void { +@_expose(wasm, "bjs_makeAdder") +@_cdecl("bjs_makeAdder") +public func _bjs_makeAdder(_ base: Int32) -> Int32 { #if arch(wasm32) - let ret = roundtripAPIResult(result: APIResult.bridgeJSLiftParameter(result)) - return ret.bridgeJSLowerReturn() + let ret = makeAdder(base: Int.bridgeJSLiftParameter(base)) + return JSTypedClosure(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 { +@_expose(wasm, "bjs_roundTripPointerFields") +@_cdecl("bjs_roundTripPointerFields") +public func _bjs_roundTripPointerFields() -> Void { #if arch(wasm32) - let ret = makeAPIResultSuccess(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) + let ret = roundTripPointerFields(_: PointerFields.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAPIResultFailure") -@_cdecl("bjs_makeAPIResultFailure") -public func _bjs_makeAPIResultFailure(_ value: Int32) -> Void { +@_expose(wasm, "bjs_testStructDefault") +@_cdecl("bjs_testStructDefault") +public func _bjs_testStructDefault() -> Void { #if arch(wasm32) - let ret = makeAPIResultFailure(_: Int.bridgeJSLiftParameter(value)) + let ret = testStructDefault(point: DataPoint.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAPIResultInfo") -@_cdecl("bjs_makeAPIResultInfo") -public func _bjs_makeAPIResultInfo() -> Void { +@_expose(wasm, "bjs_cartToJSObject") +@_cdecl("bjs_cartToJSObject") +public func _bjs_cartToJSObject() -> Int32 { #if arch(wasm32) - let ret = makeAPIResultInfo() + let ret = cartToJSObject(_: CopyableCart.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAPIResultFlag") -@_cdecl("bjs_makeAPIResultFlag") -public func _bjs_makeAPIResultFlag(_ value: Int32) -> Void { +@_expose(wasm, "bjs_nestedCartToJSObject") +@_cdecl("bjs_nestedCartToJSObject") +public func _bjs_nestedCartToJSObject() -> Int32 { #if arch(wasm32) - let ret = makeAPIResultFlag(_: Bool.bridgeJSLiftParameter(value)) + let ret = nestedCartToJSObject(_: CopyableNestedCart.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAPIResultRate") -@_cdecl("bjs_makeAPIResultRate") -public func _bjs_makeAPIResultRate(_ value: Float32) -> Void { +@_expose(wasm, "bjs_roundTripDataPoint") +@_cdecl("bjs_roundTripDataPoint") +public func _bjs_roundTripDataPoint() -> Void { #if arch(wasm32) - let ret = makeAPIResultRate(_: Float.bridgeJSLiftParameter(value)) + let ret = roundTripDataPoint(_: DataPoint.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAPIResultPrecise") -@_cdecl("bjs_makeAPIResultPrecise") -public func _bjs_makeAPIResultPrecise(_ value: Float64) -> Void { +@_expose(wasm, "bjs_roundTripPublicPoint") +@_cdecl("bjs_roundTripPublicPoint") +public func _bjs_roundTripPublicPoint() -> Void { #if arch(wasm32) - let ret = makeAPIResultPrecise(_: Double.bridgeJSLiftParameter(value)) + let ret = roundTripPublicPoint(_: PublicPoint.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundtripComplexResult") -@_cdecl("bjs_roundtripComplexResult") -public func _bjs_roundtripComplexResult(_ result: Int32) -> Void { +@_expose(wasm, "bjs_asyncRoundTripPublicPoint") +@_cdecl("bjs_asyncRoundTripPublicPoint") +public func _bjs_asyncRoundTripPublicPoint() -> Int32 { #if arch(wasm32) - let ret = roundtripComplexResult(_: ComplexResult.bridgeJSLiftParameter(result)) - return ret.bridgeJSLowerReturn() + let _tmp_point = PublicPoint.bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { + return await asyncRoundTripPublicPoint(_: _tmp_point) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeComplexResultSuccess") -@_cdecl("bjs_makeComplexResultSuccess") -public func _bjs_makeComplexResultSuccess(_ valueBytes: Int32, _ valueLength: Int32) -> Void { +@_expose(wasm, "bjs_asyncRoundTripPublicPointThrows") +@_cdecl("bjs_asyncRoundTripPublicPointThrows") +public func _bjs_asyncRoundTripPublicPointThrows() -> Int32 { #if arch(wasm32) - let ret = makeComplexResultSuccess(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) - return ret.bridgeJSLowerReturn() + let _tmp_point = PublicPoint.bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { () async throws(JSException) -> PublicPoint in + return try await asyncRoundTripPublicPointThrows(_: _tmp_point) + } #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 { +@_expose(wasm, "bjs_asyncStructOrThrow") +@_cdecl("bjs_asyncStructOrThrow") +public func _bjs_asyncStructOrThrow(_ shouldThrow: Int32) -> Int32 { #if arch(wasm32) - let ret = makeComplexResultError(_: String.bridgeJSLiftParameter(messageBytes, messageLength), _: Int.bridgeJSLiftParameter(code)) - return ret.bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { () async throws(JSException) -> PublicPoint in + return try await asyncStructOrThrow(_: Bool.bridgeJSLiftParameter(shouldThrow)) + } #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 { +@_expose(wasm, "bjs_asyncCombinePublicPoints") +@_cdecl("bjs_asyncCombinePublicPoints") +public func _bjs_asyncCombinePublicPoints() -> Int32 { #if arch(wasm32) - let ret = makeComplexResultLocation(_: Double.bridgeJSLiftParameter(lat), _: Double.bridgeJSLiftParameter(lng), _: String.bridgeJSLiftParameter(nameBytes, nameLength)) - return ret.bridgeJSLowerReturn() + let _tmp_b = PublicPoint.bridgeJSLiftParameter() + let _tmp_a = PublicPoint.bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { + return await asyncCombinePublicPoints(_: _tmp_a, _: _tmp_b) + } #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 { +@_expose(wasm, "bjs_asyncRoundTripContact") +@_cdecl("bjs_asyncRoundTripContact") +public func _bjs_asyncRoundTripContact() -> Int32 { #if arch(wasm32) - let ret = makeComplexResultStatus(_: Bool.bridgeJSLiftParameter(active), _: Int.bridgeJSLiftParameter(code), _: String.bridgeJSLiftParameter(messageBytes, messageLength)) - return ret.bridgeJSLowerReturn() + let _tmp_contact = Contact.bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_7ContactV, reject: Promise_reject) { + return await asyncRoundTripContact(_: _tmp_contact) + } #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 { +@_expose(wasm, "bjs_asyncRoundTripPublicPointArray") +@_cdecl("bjs_asyncRoundTripPublicPointArray") +public func _bjs_asyncRoundTripPublicPointArray() -> Int32 { #if arch(wasm32) - let ret = makeComplexResultCoordinates(_: Double.bridgeJSLiftParameter(x), _: Double.bridgeJSLiftParameter(y), _: Double.bridgeJSLiftParameter(z)) - return ret.bridgeJSLowerReturn() + let _tmp_points = [PublicPoint].bridgeJSStackPop() + return _bjs_makePromise(resolve: Promise_resolve_Sa11PublicPointV, reject: Promise_reject) { + return await asyncRoundTripPublicPointArray(_: _tmp_points) + } #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 { +@_expose(wasm, "bjs_asyncRoundTripOptionalPublicPoint") +@_cdecl("bjs_asyncRoundTripOptionalPublicPoint") +public func _bjs_asyncRoundTripOptionalPublicPoint() -> Int32 { #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() + let _tmp_point = Optional.bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_Sq11PublicPointV, reject: Promise_reject) { + return await asyncRoundTripOptionalPublicPoint(_: _tmp_point) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeComplexResultInfo") -@_cdecl("bjs_makeComplexResultInfo") -public func _bjs_makeComplexResultInfo() -> Void { +@_expose(wasm, "bjs_asyncRoundTripPublicPointDict") +@_cdecl("bjs_asyncRoundTripPublicPointDict") +public func _bjs_asyncRoundTripPublicPointDict() -> Int32 { #if arch(wasm32) - let ret = makeComplexResultInfo() - return ret.bridgeJSLowerReturn() + let _tmp_points = [String: PublicPoint].bridgeJSLiftParameter() + return _bjs_makePromise(resolve: Promise_resolve_SD11PublicPointV, reject: Promise_reject) { + return await asyncRoundTripPublicPointDict(_: _tmp_points) + } #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeUtilitiesResultSuccess") -@_cdecl("bjs_makeUtilitiesResultSuccess") -public func _bjs_makeUtilitiesResultSuccess(_ messageBytes: Int32, _ messageLength: Int32) -> Void { +@_expose(wasm, "bjs_roundTripContact") +@_cdecl("bjs_roundTripContact") +public func _bjs_roundTripContact() -> Void { #if arch(wasm32) - let ret = makeUtilitiesResultSuccess(_: String.bridgeJSLiftParameter(messageBytes, messageLength)) + let ret = roundTripContact(_: Contact.bridgeJSLiftParameter()) 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 { +@_expose(wasm, "bjs_roundTripConfig") +@_cdecl("bjs_roundTripConfig") +public func _bjs_roundTripConfig() -> Void { #if arch(wasm32) - let ret = makeUtilitiesResultFailure(_: String.bridgeJSLiftParameter(errorBytes, errorLength), _: Int.bridgeJSLiftParameter(code)) + let ret = roundTripConfig(_: Config.bridgeJSLiftParameter()) 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 { +@_expose(wasm, "bjs_roundTripSessionData") +@_cdecl("bjs_roundTripSessionData") +public func _bjs_roundTripSessionData() -> Void { #if arch(wasm32) - let ret = makeUtilitiesResultStatus(_: Bool.bridgeJSLiftParameter(active), _: Int.bridgeJSLiftParameter(code), _: String.bridgeJSLiftParameter(messageBytes, messageLength)) + let ret = roundTripSessionData(_: SessionData.bridgeJSLiftParameter()) 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 { +@_expose(wasm, "bjs_roundTripValidationReport") +@_cdecl("bjs_roundTripValidationReport") +public func _bjs_roundTripValidationReport() -> Void { #if arch(wasm32) - let ret = makeAPINetworkingResultSuccess(_: String.bridgeJSLiftParameter(messageBytes, messageLength)) + let ret = roundTripValidationReport(_: ValidationReport.bridgeJSLiftParameter()) 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 { +@_expose(wasm, "bjs_roundTripAdvancedConfig") +@_cdecl("bjs_roundTripAdvancedConfig") +public func _bjs_roundTripAdvancedConfig() -> Void { #if arch(wasm32) - let ret = makeAPINetworkingResultFailure(_: String.bridgeJSLiftParameter(errorBytes, errorLength), _: Int.bridgeJSLiftParameter(code)) + let ret = roundTripAdvancedConfig(_: AdvancedConfig.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundtripUtilitiesResult") -@_cdecl("bjs_roundtripUtilitiesResult") -public func _bjs_roundtripUtilitiesResult(_ result: Int32) -> Void { +@_expose(wasm, "bjs_roundTripMeasurementConfig") +@_cdecl("bjs_roundTripMeasurementConfig") +public func _bjs_roundTripMeasurementConfig() -> Void { #if arch(wasm32) - let ret = roundtripUtilitiesResult(_: Utilities.Result.bridgeJSLiftParameter(result)) + let ret = roundTripMeasurementConfig(_: MeasurementConfig.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundtripAPINetworkingResult") -@_cdecl("bjs_roundtripAPINetworkingResult") -public func _bjs_roundtripAPINetworkingResult(_ result: Int32) -> Void { +@_expose(wasm, "bjs_updateValidationReport") +@_cdecl("bjs_updateValidationReport") +public func _bjs_updateValidationReport(_ newResultIsSome: Int32, _ newResultCaseId: Int32) -> Void { #if arch(wasm32) - let ret = roundtripAPINetworkingResult(_: API.NetworkingResult.bridgeJSLiftParameter(result)) + 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_roundTripAllTypesResult") -@_cdecl("bjs_roundTripAllTypesResult") -public func _bjs_roundTripAllTypesResult(_ result: Int32) -> Void { +@_expose(wasm, "bjs_testContainerWithStruct") +@_cdecl("bjs_testContainerWithStruct") +public func _bjs_testContainerWithStruct() -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripAllTypesResult(_: AllTypesResult.bridgeJSLiftParameter(result)) + let ret = testContainerWithStruct(_: DataPoint.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripTypedPayloadResult") -@_cdecl("bjs_roundTripTypedPayloadResult") -public func _bjs_roundTripTypedPayloadResult(_ result: Int32) -> Void { +@_expose(wasm, "bjs_roundTripJSObjectContainer") +@_cdecl("bjs_roundTripJSObjectContainer") +public func _bjs_roundTripJSObjectContainer() -> Void { #if arch(wasm32) - let ret = roundTripTypedPayloadResult(_: TypedPayloadResult.bridgeJSLiftParameter(result)) + let ret = roundTripJSObjectContainer(_: JSObjectContainer.bridgeJSLiftParameter()) 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 { +@_expose(wasm, "bjs_roundTripFooContainer") +@_cdecl("bjs_roundTripFooContainer") +public func _bjs_roundTripFooContainer() -> Void { #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)) + let ret = roundTripFooContainer(_: FooContainer.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_testPropertyHolder") -@_cdecl("bjs_testPropertyHolder") -public func _bjs_testPropertyHolder(_ holder: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_roundTripArrayMembers") +@_cdecl("bjs_roundTripArrayMembers") +public func _bjs_roundTripArrayMembers() -> Void { #if arch(wasm32) - let ret = testPropertyHolder(holder: PropertyHolder.bridgeJSLiftParameter(holder)) + let ret = roundTripArrayMembers(_: ArrayMembers.bridgeJSLiftParameter()) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_resetObserverCounts") -@_cdecl("bjs_resetObserverCounts") -public func _bjs_resetObserverCounts() -> Void { +@_expose(wasm, "bjs_arrayMembersSum") +@_cdecl("bjs_arrayMembersSum") +public func _bjs_arrayMembersSum() -> Int32 { #if arch(wasm32) - resetObserverCounts() + 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_getObserverStats") -@_cdecl("bjs_getObserverStats") -public func _bjs_getObserverStats() -> Void { +@_expose(wasm, "bjs_arrayMembersFirst") +@_cdecl("bjs_arrayMembersFirst") +public func _bjs_arrayMembersFirst() -> Void { #if arch(wasm32) - let ret = getObserverStats() + 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_formatName") -@_cdecl("bjs_formatName") -public func _bjs_formatName(_ nameBytes: Int32, _ nameLength: Int32, _ transform: Int32) -> Void { +@_expose(wasm, "bjs_PolygonReference_init") +@_cdecl("bjs_PolygonReference_init") +public func _bjs_PolygonReference_init(_ labelBytes: Int32, _ labelLength: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = formatName(_: String.bridgeJSLiftParameter(nameBytes, nameLength), transform: _BJS_Closure_20BridgeJSRuntimeTestsSS_SS.bridgeJSLift(transform)) + let ret = PolygonReference(verticesData: [Double].bridgeJSStackPop(), label: String.bridgeJSLiftParameter(labelBytes, labelLength)) 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 { +@_expose(wasm, "bjs_PolygonReference_vertexCount") +@_cdecl("bjs_PolygonReference_vertexCount") +public func _bjs_PolygonReference_vertexCount(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = makeFormatter(prefix: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) - return JSTypedClosure(ret).bridgeJSLowerReturn() + let ret = PolygonReference.bridgeJSLiftParameter(_self).vertexCount() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_makeAdder") -@_cdecl("bjs_makeAdder") -public func _bjs_makeAdder(_ base: Int32) -> Int32 { +@_expose(wasm, "bjs_PolygonReference_summary") +@_cdecl("bjs_PolygonReference_summary") +public func _bjs_PolygonReference_summary(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = makeAdder(base: Int.bridgeJSLiftParameter(base)) - return JSTypedClosure(ret).bridgeJSLowerReturn() + let ret = PolygonReference.bridgeJSLiftParameter(_self).summary() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripPointerFields") -@_cdecl("bjs_roundTripPointerFields") -public func _bjs_roundTripPointerFields() -> Void { +@_expose(wasm, "bjs_PolygonReference_snapshot") +@_cdecl("bjs_PolygonReference_snapshot") +public func _bjs_PolygonReference_snapshot(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripPointerFields(_: PointerFields.bridgeJSLiftParameter()) + let ret = PolygonReference.bridgeJSLiftParameter(_self).snapshot() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_testStructDefault") -@_cdecl("bjs_testStructDefault") -public func _bjs_testStructDefault() -> Void { +@_expose(wasm, "bjs_PolygonReference_merge") +@_cdecl("bjs_PolygonReference_merge") +public func _bjs_PolygonReference_merge(_ _self: UnsafeMutableRawPointer, _ other: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = testStructDefault(point: DataPoint.bridgeJSLiftParameter()) + let ret = PolygonReference.bridgeJSLiftParameter(_self).merge(_: Polygon.bridgeJSLiftParameter(other)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_cartToJSObject") -@_cdecl("bjs_cartToJSObject") -public func _bjs_cartToJSObject() -> Int32 { +@_expose(wasm, "bjs_PolygonReference_static_origin") +@_cdecl("bjs_PolygonReference_static_origin") +public func _bjs_PolygonReference_static_origin(_ labelBytes: Int32, _ labelLength: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = cartToJSObject(_: CopyableCart.bridgeJSLiftParameter()) + let ret = PolygonReference.origin(label: String.bridgeJSLiftParameter(labelBytes, labelLength)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_nestedCartToJSObject") -@_cdecl("bjs_nestedCartToJSObject") -public func _bjs_nestedCartToJSObject() -> Int32 { +@_expose(wasm, "bjs_PolygonReference_deinit") +@_cdecl("bjs_PolygonReference_deinit") +public func _bjs_PolygonReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = nestedCartToJSObject(_: CopyableNestedCart.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripDataPoint") -@_cdecl("bjs_roundTripDataPoint") -public func _bjs_roundTripDataPoint() -> Void { +extension PolygonReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_PolygonReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_PolygonReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PolygonReference_wrap") +fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_PolygonReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_PolygonReference_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_TagReference_describe") +@_cdecl("bjs_TagReference_describe") +public func _bjs_TagReference_describe(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = roundTripDataPoint(_: DataPoint.bridgeJSLiftParameter()) + let ret = TagReference.bridgeJSLiftParameter(_self).describe() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripPublicPoint") -@_cdecl("bjs_roundTripPublicPoint") -public func _bjs_roundTripPublicPoint() -> Void { +@_expose(wasm, "bjs_TagReference_deinit") +@_cdecl("bjs_TagReference_deinit") +public func _bjs_TagReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = roundTripPublicPoint(_: PublicPoint.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripContact") -@_cdecl("bjs_roundTripContact") -public func _bjs_roundTripContact() -> Void { +extension TagReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_TagReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_TagReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TagReference_wrap") +fileprivate func _bjs_TagReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_TagReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_TagReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_TagReference_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_TagHolderReference_init") +@_cdecl("bjs_TagHolderReference_init") +public func _bjs_TagHolderReference_init(_ tag: UnsafeMutableRawPointer, _ version: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripContact(_: Contact.bridgeJSLiftParameter()) + let ret = TagHolderReference(tag: Tag.bridgeJSLiftParameter(tag), version: Int.bridgeJSLiftParameter(version)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripConfig") -@_cdecl("bjs_roundTripConfig") -public func _bjs_roundTripConfig() -> Void { +@_expose(wasm, "bjs_TagHolderReference_describe") +@_cdecl("bjs_TagHolderReference_describe") +public func _bjs_TagHolderReference_describe(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = roundTripConfig(_: Config.bridgeJSLiftParameter()) + let ret = TagHolderReference.bridgeJSLiftParameter(_self).describe() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripSessionData") -@_cdecl("bjs_roundTripSessionData") -public func _bjs_roundTripSessionData() -> Void { +@_expose(wasm, "bjs_TagHolderReference_tag_get") +@_cdecl("bjs_TagHolderReference_tag_get") +public func _bjs_TagHolderReference_tag_get(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripSessionData(_: SessionData.bridgeJSLiftParameter()) + let ret = TagHolderReference.bridgeJSLiftParameter(_self).tag return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripValidationReport") -@_cdecl("bjs_roundTripValidationReport") -public func _bjs_roundTripValidationReport() -> Void { +@_expose(wasm, "bjs_TagHolderReference_tag_set") +@_cdecl("bjs_TagHolderReference_tag_set") +public func _bjs_TagHolderReference_tag_set(_ _self: UnsafeMutableRawPointer, _ value: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = roundTripValidationReport(_: ValidationReport.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + TagHolderReference.bridgeJSLiftParameter(_self).tag = Tag.bridgeJSLiftParameter(value) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripAdvancedConfig") -@_cdecl("bjs_roundTripAdvancedConfig") -public func _bjs_roundTripAdvancedConfig() -> Void { +@_expose(wasm, "bjs_TagHolderReference_version_get") +@_cdecl("bjs_TagHolderReference_version_get") +public func _bjs_TagHolderReference_version_get(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = roundTripAdvancedConfig(_: AdvancedConfig.bridgeJSLiftParameter()) + let ret = TagHolderReference.bridgeJSLiftParameter(_self).version return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripMeasurementConfig") -@_cdecl("bjs_roundTripMeasurementConfig") -public func _bjs_roundTripMeasurementConfig() -> Void { +@_expose(wasm, "bjs_TagHolderReference_version_set") +@_cdecl("bjs_TagHolderReference_version_set") +public func _bjs_TagHolderReference_version_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { #if arch(wasm32) - let ret = roundTripMeasurementConfig(_: MeasurementConfig.bridgeJSLiftParameter()) - return ret.bridgeJSLowerReturn() + TagHolderReference.bridgeJSLiftParameter(_self).version = Int.bridgeJSLiftParameter(value) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_updateValidationReport") -@_cdecl("bjs_updateValidationReport") -public func _bjs_updateValidationReport(_ newResultIsSome: Int32, _ newResultCaseId: Int32) -> Void { +@_expose(wasm, "bjs_TagHolderReference_deinit") +@_cdecl("bjs_TagHolderReference_deinit") +public func _bjs_TagHolderReference_deinit(_ pointer: UnsafeMutableRawPointer) -> 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() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_testContainerWithStruct") -@_cdecl("bjs_testContainerWithStruct") -public func _bjs_testContainerWithStruct() -> UnsafeMutableRawPointer { +extension TagHolderReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_TagHolderReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_TagHolderReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TagHolderReference_wrap") +fileprivate func _bjs_TagHolderReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_TagHolderReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_TagHolderReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_TagHolderReference_wrap_extern(pointer) +} + +@_expose(wasm, "bjs_PriorityReference_describe") +@_cdecl("bjs_PriorityReference_describe") +public func _bjs_PriorityReference_describe(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = testContainerWithStruct(_: DataPoint.bridgeJSLiftParameter()) + let ret = PriorityReference.bridgeJSLiftParameter(_self).describe() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripJSObjectContainer") -@_cdecl("bjs_roundTripJSObjectContainer") -public func _bjs_roundTripJSObjectContainer() -> Void { +@_expose(wasm, "bjs_PriorityReference_weight") +@_cdecl("bjs_PriorityReference_weight") +public func _bjs_PriorityReference_weight(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = roundTripJSObjectContainer(_: JSObjectContainer.bridgeJSLiftParameter()) + let ret = PriorityReference.bridgeJSLiftParameter(_self).weight() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripFooContainer") -@_cdecl("bjs_roundTripFooContainer") -public func _bjs_roundTripFooContainer() -> Void { +@_expose(wasm, "bjs_PriorityReference_static_low") +@_cdecl("bjs_PriorityReference_static_low") +public func _bjs_PriorityReference_static_low() -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripFooContainer(_: FooContainer.bridgeJSLiftParameter()) + let ret = PriorityReference.low() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_roundTripArrayMembers") -@_cdecl("bjs_roundTripArrayMembers") -public func _bjs_roundTripArrayMembers() -> Void { +@_expose(wasm, "bjs_PriorityReference_static_medium") +@_cdecl("bjs_PriorityReference_static_medium") +public func _bjs_PriorityReference_static_medium() -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = roundTripArrayMembers(_: ArrayMembers.bridgeJSLiftParameter()) + let ret = PriorityReference.medium() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_arrayMembersSum") -@_cdecl("bjs_arrayMembersSum") -public func _bjs_arrayMembersSum() -> Int32 { +@_expose(wasm, "bjs_PriorityReference_static_high") +@_cdecl("bjs_PriorityReference_static_high") +public func _bjs_PriorityReference_static_high() -> UnsafeMutableRawPointer { #if arch(wasm32) - let _tmp_values = [Int].bridgeJSStackPop() - let _tmp_value = ArrayMembers.bridgeJSLiftParameter() - let ret = arrayMembersSum(_: _tmp_value, _: _tmp_values) + let ret = PriorityReference.high() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_arrayMembersFirst") -@_cdecl("bjs_arrayMembersFirst") -public func _bjs_arrayMembersFirst() -> Void { +@_expose(wasm, "bjs_PriorityReference_deinit") +@_cdecl("bjs_PriorityReference_deinit") +public func _bjs_PriorityReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let _tmp_values = [String].bridgeJSStackPop() - let _tmp_value = ArrayMembers.bridgeJSLiftParameter() - let ret = arrayMembersFirst(_: _tmp_value, _: _tmp_values) - return ret.bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PolygonReference_init") -@_cdecl("bjs_PolygonReference_init") -public func _bjs_PolygonReference_init(_ labelBytes: Int32, _ labelLength: Int32) -> UnsafeMutableRawPointer { +extension PriorityReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_PriorityReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_PriorityReference_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PriorityReference_wrap") +fileprivate func _bjs_PriorityReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_PriorityReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_PriorityReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_PriorityReference_wrap_extern(pointer) +} + +@_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 = PolygonReference(verticesData: [Double].bridgeJSStackPop(), label: String.bridgeJSLiftParameter(labelBytes, labelLength)) - return ret.bridgeJSLowerReturn() + let ret = ClosureSupportExports.makeIntToInt(_: Int.bridgeJSLiftParameter(base)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PolygonReference_vertexCount") -@_cdecl("bjs_PolygonReference_vertexCount") -public func _bjs_PolygonReference_vertexCount(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_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 = PolygonReference.bridgeJSLiftParameter(_self).vertexCount() - return ret.bridgeJSLowerReturn() + let ret = ClosureSupportExports.makeDoubleToDouble(_: Double.bridgeJSLiftParameter(base)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PolygonReference_summary") -@_cdecl("bjs_PolygonReference_summary") -public func _bjs_PolygonReference_summary(_ _self: UnsafeMutableRawPointer) -> Void { +@_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 = PolygonReference.bridgeJSLiftParameter(_self).summary() - return ret.bridgeJSLowerReturn() + let ret = ClosureSupportExports.makeStringToString(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PolygonReference_snapshot") -@_cdecl("bjs_PolygonReference_snapshot") -public func _bjs_PolygonReference_snapshot(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_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 = PolygonReference.bridgeJSLiftParameter(_self).snapshot() - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = ClosureSupportExports.makeJSIntToInt(_: Int.bridgeJSLiftParameter(base)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PolygonReference_merge") -@_cdecl("bjs_PolygonReference_merge") -public func _bjs_PolygonReference_merge(_ _self: UnsafeMutableRawPointer, _ other: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_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 = PolygonReference.bridgeJSLiftParameter(_self).merge(_: Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftParameter(other))) - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = ClosureSupportExports.makeJSDoubleToDouble(_: Double.bridgeJSLiftParameter(base)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PolygonReference_static_origin") -@_cdecl("bjs_PolygonReference_static_origin") -public func _bjs_PolygonReference_static_origin(_ labelBytes: Int32, _ labelLength: Int32) -> UnsafeMutableRawPointer { +@_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 = PolygonReference.origin(label: String.bridgeJSLiftParameter(labelBytes, labelLength)) - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = ClosureSupportExports.makeJSStringToString(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PolygonReference_deinit") -@_cdecl("bjs_PolygonReference_deinit") -public func _bjs_PolygonReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_ClosureSupportExports_deinit") +@_cdecl("bjs_ClosureSupportExports_deinit") +public func _bjs_ClosureSupportExports_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -extension PolygonReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { +extension ClosureSupportExports: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_PolygonReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + return .object(JSObject(id: UInt32(bitPattern: _bjs_ClosureSupportExports_wrap(Unmanaged.passRetained(self).toOpaque())))) } consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_PolygonReference_wrap(Unmanaged.passRetained(self).toOpaque()) + _bjs_ClosureSupportExports_wrap(Unmanaged.passRetained(self).toOpaque()) } } #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PolygonReference_wrap") -fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportExports_wrap") +fileprivate func _bjs_ClosureSupportExports_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func _bjs_PolygonReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func _bjs_ClosureSupportExports_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_PolygonReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_PolygonReference_wrap_extern(pointer) +@inline(never) fileprivate func _bjs_ClosureSupportExports_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ClosureSupportExports_wrap_extern(pointer) } -@_expose(wasm, "bjs_TagReference_describe") -@_cdecl("bjs_TagReference_describe") -public func _bjs_TagReference_describe(_ _self: UnsafeMutableRawPointer) -> Void { +@_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 = TagReference.bridgeJSLiftParameter(_self).describe() + 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_TagReference_deinit") -@_cdecl("bjs_TagReference_deinit") -public func _bjs_TagReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_describe") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_describe") +public func _bjs_DefaultArgumentConstructorDefaults_describe(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).describe() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -extension TagReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_TagReference_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_TagReference_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TagReference_wrap") -fileprivate func _bjs_TagReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_TagReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_TagReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_TagReference_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_TokenReference_init") -@_cdecl("bjs_TokenReference_init") -public func _bjs_TokenReference_init(_ value: Int32) -> UnsafeMutableRawPointer { +@_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 = TokenReference(value: Int.bridgeJSLiftParameter(value)) + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).name return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TokenReference_read") -@_cdecl("bjs_TokenReference_read") -public func _bjs_TokenReference_read(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_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) - let ret = TokenReference.bridgeJSLiftParameter(_self).read() - return ret.bridgeJSLowerReturn() + DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TokenReference_deinit") -@_cdecl("bjs_TokenReference_deinit") -public func _bjs_TokenReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_count_get") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_count_get") +public func _bjs_DefaultArgumentConstructorDefaults_count_get(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).count + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -extension TokenReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_TokenReference_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_TokenReference_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TokenReference_wrap") -fileprivate func _bjs_TokenReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_TokenReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +@_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 -@inline(never) fileprivate func _bjs_TokenReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_TokenReference_wrap_extern(pointer) + #endif } -@_expose(wasm, "bjs_TagHolderReference_init") -@_cdecl("bjs_TagHolderReference_init") -public func _bjs_TagHolderReference_init(_ tag: UnsafeMutableRawPointer, _ version: Int32) -> UnsafeMutableRawPointer { +@_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 = TagHolderReference(tag: Tag.bridgeFromJS(TagReference.bridgeJSLiftParameter(tag)), version: Int.bridgeJSLiftParameter(version)) + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).enabled return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TagHolderReference_describe") -@_cdecl("bjs_TagHolderReference_describe") -public func _bjs_TagHolderReference_describe(_ _self: UnsafeMutableRawPointer) -> Void { +@_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) - let ret = TagHolderReference.bridgeJSLiftParameter(_self).describe() - return ret.bridgeJSLowerReturn() + DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).enabled = Bool.bridgeJSLiftParameter(value) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TagHolderReference_tag_get") -@_cdecl("bjs_TagHolderReference_tag_get") -public func _bjs_TagHolderReference_tag_get(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_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 = TagHolderReference.bridgeJSLiftParameter(_self).tag - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).status + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TagHolderReference_tag_set") -@_cdecl("bjs_TagHolderReference_tag_set") -public func _bjs_TagHolderReference_tag_set(_ _self: UnsafeMutableRawPointer, _ value: UnsafeMutableRawPointer) -> Void { +@_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) - TagHolderReference.bridgeJSLiftParameter(_self).tag = Tag.bridgeFromJS(TagReference.bridgeJSLiftParameter(value)) + DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).status = Status.bridgeJSLiftParameter(value) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TagHolderReference_version_get") -@_cdecl("bjs_TagHolderReference_version_get") -public func _bjs_TagHolderReference_version_get(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_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 = TagHolderReference.bridgeJSLiftParameter(_self).version + let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).tag return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TagHolderReference_version_set") -@_cdecl("bjs_TagHolderReference_version_set") -public func _bjs_TagHolderReference_version_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { +@_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) - TagHolderReference.bridgeJSLiftParameter(_self).version = Int.bridgeJSLiftParameter(value) + DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).tag = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TagHolderReference_deinit") -@_cdecl("bjs_TagHolderReference_deinit") -public func _bjs_TagHolderReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_deinit") +@_cdecl("bjs_DefaultArgumentConstructorDefaults_deinit") +public func _bjs_DefaultArgumentConstructorDefaults_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -extension TagHolderReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { +extension DefaultArgumentConstructorDefaults: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_TagHolderReference_wrap(Unmanaged.passRetained(self).toOpaque())))) + return .object(JSObject(id: UInt32(bitPattern: _bjs_DefaultArgumentConstructorDefaults_wrap(Unmanaged.passRetained(self).toOpaque())))) } consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_TagHolderReference_wrap(Unmanaged.passRetained(self).toOpaque()) + _bjs_DefaultArgumentConstructorDefaults_wrap(Unmanaged.passRetained(self).toOpaque()) } } #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TagHolderReference_wrap") -fileprivate func _bjs_TagHolderReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_DefaultArgumentConstructorDefaults_wrap") +fileprivate func _bjs_DefaultArgumentConstructorDefaults_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func _bjs_TagHolderReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func _bjs_DefaultArgumentConstructorDefaults_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_TagHolderReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_TagHolderReference_wrap_extern(pointer) +@inline(never) fileprivate func _bjs_DefaultArgumentConstructorDefaults_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_DefaultArgumentConstructorDefaults_wrap_extern(pointer) } -@_expose(wasm, "bjs_PriorityReference_describe") -@_cdecl("bjs_PriorityReference_describe") -public func _bjs_PriorityReference_describe(_ _self: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_Greeter_init") +@_cdecl("bjs_Greeter_init") +public func _bjs_Greeter_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = PriorityReference.bridgeJSLiftParameter(_self).describe() + let ret = Greeter(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PriorityReference_weight") -@_cdecl("bjs_PriorityReference_weight") -public func _bjs_PriorityReference_weight(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_Greeter_greet") +@_cdecl("bjs_Greeter_greet") +public func _bjs_Greeter_greet(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = PriorityReference.bridgeJSLiftParameter(_self).weight() + let ret = Greeter.bridgeJSLiftParameter(_self).greet() return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PriorityReference_static_low") -@_cdecl("bjs_PriorityReference_static_low") -public func _bjs_PriorityReference_static_low() -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_Greeter_changeName") +@_cdecl("bjs_Greeter_changeName") +public func _bjs_Greeter_changeName(_ _self: UnsafeMutableRawPointer, _ nameBytes: Int32, _ nameLength: Int32) -> Void { #if arch(wasm32) - let ret = PriorityReference.low() - return ret.bridgeToJS().bridgeJSLowerReturn() + Greeter.bridgeJSLiftParameter(_self).changeName(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PriorityReference_static_medium") -@_cdecl("bjs_PriorityReference_static_medium") -public func _bjs_PriorityReference_static_medium() -> UnsafeMutableRawPointer { +@_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 = PriorityReference.medium() - return ret.bridgeToJS().bridgeJSLowerReturn() + 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_PriorityReference_static_high") -@_cdecl("bjs_PriorityReference_static_high") -public func _bjs_PriorityReference_static_high() -> UnsafeMutableRawPointer { +@_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 = PriorityReference.high() - return ret.bridgeToJS().bridgeJSLowerReturn() + let ret = Greeter.bridgeJSLiftParameter(_self).makeCustomGreeter() + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PriorityReference_deinit") -@_cdecl("bjs_PriorityReference_deinit") -public func _bjs_PriorityReference_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_Greeter_greetEnthusiastically") +@_cdecl("bjs_Greeter_greetEnthusiastically") +public func _bjs_Greeter_greetEnthusiastically(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + let ret = Greeter.bridgeJSLiftParameter(_self).greetEnthusiastically() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -extension PriorityReference: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { - var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_PriorityReference_wrap(Unmanaged.passRetained(self).toOpaque())))) - } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_PriorityReference_wrap(Unmanaged.passRetained(self).toOpaque()) - } -} - -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PriorityReference_wrap") -fileprivate func _bjs_PriorityReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 -#else -fileprivate func _bjs_PriorityReference_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func _bjs_PriorityReference_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_PriorityReference_wrap_extern(pointer) -} - -@_expose(wasm, "bjs_ClosureSupportExports_static_makeIntToInt") -@_cdecl("bjs_ClosureSupportExports_static_makeIntToInt") -public func _bjs_ClosureSupportExports_static_makeIntToInt(_ base: Int32) -> Int32 { +@_expose(wasm, "bjs_Greeter_static_greetAnonymously") +@_cdecl("bjs_Greeter_static_greetAnonymously") +public func _bjs_Greeter_static_greetAnonymously() -> Void { #if arch(wasm32) - let ret = ClosureSupportExports.makeIntToInt(_: Int.bridgeJSLiftParameter(base)) - return JSTypedClosure(ret).bridgeJSLowerReturn() + let ret = Greeter.greetAnonymously() + return 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 { +@_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 = ClosureSupportExports.makeDoubleToDouble(_: Double.bridgeJSLiftParameter(base)) - return JSTypedClosure(ret).bridgeJSLowerReturn() + let ret = Greeter.bridgeJSLiftParameter(_self).name + return 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 { +@_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) - let ret = ClosureSupportExports.makeStringToString(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) - return JSTypedClosure(ret).bridgeJSLowerReturn() + Greeter.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) #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 { +@_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 = ClosureSupportExports.makeJSIntToInt(_: Int.bridgeJSLiftParameter(base)) + let ret = Greeter.bridgeJSLiftParameter(_self).prefix 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 { +@_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 = ClosureSupportExports.makeJSDoubleToDouble(_: Double.bridgeJSLiftParameter(base)) + let ret = Greeter.bridgeJSLiftParameter(_self).nameCount 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 { +@_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 = ClosureSupportExports.makeJSStringToString(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength)) + let ret = Greeter.defaultGreeting 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 { +@_expose(wasm, "bjs_Greeter_deinit") +@_cdecl("bjs_Greeter_deinit") +public func _bjs_Greeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + 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())))) +extension Greeter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + public var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Greeter_wrap(Unmanaged.passRetained(self).toOpaque())))) } - consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_ClosureSupportExports_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_ClosureSupportExports_wrap") -fileprivate func _bjs_ClosureSupportExports_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Greeter_wrap") +fileprivate func _bjs_Greeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func _bjs_ClosureSupportExports_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func _bjs_Greeter_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) +@inline(never) fileprivate func _bjs_Greeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Greeter_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 { +@_expose(wasm, "bjs_Calculator_square") +@_cdecl("bjs_Calculator_square") +public func _bjs_Calculator_square(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Int32 { #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)) + let ret = Calculator.bridgeJSLiftParameter(_self).square(value: Int.bridgeJSLiftParameter(value)) 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 { +@_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 = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).describe() + 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_DefaultArgumentConstructorDefaults_name_get") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_name_get") -public func _bjs_DefaultArgumentConstructorDefaults_name_get(_ _self: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_Calculator_asyncMakePoint") +@_cdecl("bjs_Calculator_asyncMakePoint") +public func _bjs_Calculator_asyncMakePoint(_ _self: UnsafeMutableRawPointer, _ x: Int32, _ y: Int32) -> Int32 { #if arch(wasm32) - let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).name - return ret.bridgeJSLowerReturn() + return _bjs_makePromise(resolve: Promise_resolve_11PublicPointV, reject: Promise_reject) { + return await Calculator.bridgeJSLiftParameter(_self).asyncMakePoint(x: Int.bridgeJSLiftParameter(x), y: Int.bridgeJSLiftParameter(y)) + } #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 { +@_expose(wasm, "bjs_Calculator_deinit") +@_cdecl("bjs_Calculator_deinit") +public func _bjs_Calculator_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) + Unmanaged.fromOpaque(pointer).release() #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 +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 +} +#endif +@inline(never) fileprivate func _bjs_Calculator_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Calculator_wrap_extern(pointer) } -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_count_set") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_count_set") -public func _bjs_DefaultArgumentConstructorDefaults_count_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { +@_expose(wasm, "bjs_InternalGreeter_deinit") +@_cdecl("bjs_InternalGreeter_deinit") +public func _bjs_InternalGreeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).count = Int.bridgeJSLiftParameter(value) + Unmanaged.fromOpaque(pointer).release() #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 { +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) - let ret = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).enabled - return ret.bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() #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 { +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) - DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).enabled = Bool.bridgeJSLiftParameter(value) + Unmanaged.fromOpaque(pointer).release() #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 { +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 = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).status + let ret = Utils.Converter() 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 { +@_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) - DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).status = Status.bridgeJSLiftParameter(value) + let ret = Utils.Converter.bridgeJSLiftParameter(_self).toString(value: Int.bridgeJSLiftParameter(value)) + return ret.bridgeJSLowerReturn() #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 { +@_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 = DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).tag + let ret = Utils.Converter.bridgeJSLiftParameter(_self).precision 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 { +@_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) - DefaultArgumentConstructorDefaults.bridgeJSLiftParameter(_self).tag = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) + Utils.Converter.bridgeJSLiftParameter(_self).precision = Int.bridgeJSLiftParameter(value) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_DefaultArgumentConstructorDefaults_deinit") -@_cdecl("bjs_DefaultArgumentConstructorDefaults_deinit") -public func _bjs_DefaultArgumentConstructorDefaults_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_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() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -extension DefaultArgumentConstructorDefaults: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { +extension Utils.Converter: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_DefaultArgumentConstructorDefaults_wrap(Unmanaged.passRetained(self).toOpaque())))) + return .object(JSObject(id: UInt32(bitPattern: _bjs_Utils_Converter_wrap(Unmanaged.passRetained(self).toOpaque())))) } consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_DefaultArgumentConstructorDefaults_wrap(Unmanaged.passRetained(self).toOpaque()) + _bjs_Utils_Converter_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 +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Utils_Converter_wrap") +fileprivate func _bjs_Utils_Converter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func _bjs_DefaultArgumentConstructorDefaults_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func _bjs_Utils_Converter_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) +@inline(never) fileprivate func _bjs_Utils_Converter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Utils_Converter_wrap_extern(pointer) } -@_expose(wasm, "bjs_Greeter_init") -@_cdecl("bjs_Greeter_init") -public func _bjs_Greeter_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { +@_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 = Greeter(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) + let ret = Networking.API.HTTPServer() 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 { +@_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) - let ret = Greeter.bridgeJSLiftParameter(_self).greet() - return ret.bridgeJSLowerReturn() + Networking.API.HTTPServer.bridgeJSLiftParameter(_self).call(_: Networking.API.Method.bridgeJSLiftParameter(method)) #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 { +@_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) - Greeter.bridgeJSLiftParameter(_self).changeName(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) + Unmanaged.fromOpaque(pointer).release() #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 +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()) + } } -@_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 +#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 } - -@_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 +#endif +@inline(never) fileprivate func _bjs_Networking_API_HTTPServer_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Networking_API_HTTPServer_wrap_extern(pointer) } -@_expose(wasm, "bjs_Greeter_makeCustomGreeter") -@_cdecl("bjs_Greeter_makeCustomGreeter") -public func _bjs_Greeter_makeCustomGreeter(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_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 = Greeter.bridgeJSLiftParameter(_self).makeCustomGreeter() - return JSTypedClosure(ret).bridgeJSLowerReturn() + let ret = UUID(value: String.bridgeJSLiftParameter(valueBytes, valueLength)) + return 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 { +@_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 = Greeter.bridgeJSLiftParameter(_self).greetEnthusiastically() + let ret = UUID.bridgeJSLiftParameter(_self).uuidString() 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 { +@_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 = Greeter.greetAnonymously() + let ret = UUID.fromValue(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) 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 { +@_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 = Greeter.bridgeJSLiftParameter(_self).name + let ret = UUID.placeholder 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 { +@_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) - Greeter.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) + Unmanaged.fromOpaque(pointer).release() #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 +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 +} +#endif +@inline(never) fileprivate func _bjs___Swift_Foundation_UUID_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs___Swift_Foundation_UUID_wrap_extern(pointer) } -@_expose(wasm, "bjs_Greeter_nameCount_get") -@_cdecl("bjs_Greeter_nameCount_get") -public func _bjs_Greeter_nameCount_get(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_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 = Greeter.bridgeJSLiftParameter(_self).nameCount + let ret = Internal.TestServer() 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 { +@_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) - let ret = Greeter.defaultGreeting - return ret.bridgeJSLowerReturn() + Internal.TestServer.bridgeJSLiftParameter(_self).call(_: Internal.SupportedMethod.bridgeJSLiftParameter(method)) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_Greeter_deinit") -@_cdecl("bjs_Greeter_deinit") -public func _bjs_Greeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_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() + 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())))) +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())))) } - public consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_Greeter_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_Greeter_wrap") -fileprivate func _bjs_Greeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +@_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_Greeter_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func _bjs_Networking_APIV2_Internal_TestServer_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) +@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_Calculator_square") -@_cdecl("bjs_Calculator_square") -public func _bjs_Calculator_square(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Int32 { +@_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 = Calculator.bridgeJSLiftParameter(_self).square(value: Int.bridgeJSLiftParameter(value)) + let ret = SimplePropertyHolder.bridgeJSLiftParameter(_self).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 { +@_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) - let ret = Calculator.bridgeJSLiftParameter(_self).add(a: Int.bridgeJSLiftParameter(a), b: Int.bridgeJSLiftParameter(b)) - return ret.bridgeJSLowerReturn() + SimplePropertyHolder.bridgeJSLiftParameter(_self).value = Int.bridgeJSLiftParameter(value) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_Calculator_deinit") -@_cdecl("bjs_Calculator_deinit") -public func _bjs_Calculator_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_SimplePropertyHolder_deinit") +@_cdecl("bjs_SimplePropertyHolder_deinit") +public func _bjs_SimplePropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -extension Calculator: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { +extension SimplePropertyHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_Calculator_wrap(Unmanaged.passRetained(self).toOpaque())))) + return .object(JSObject(id: UInt32(bitPattern: _bjs_SimplePropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) } consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_Calculator_wrap(Unmanaged.passRetained(self).toOpaque()) + _bjs_SimplePropertyHolder_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 +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_SimplePropertyHolder_wrap") +fileprivate func _bjs_SimplePropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func _bjs_Calculator_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func _bjs_SimplePropertyHolder_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) +@inline(never) fileprivate func _bjs_SimplePropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_SimplePropertyHolder_wrap_extern(pointer) } -@_expose(wasm, "bjs_InternalGreeter_deinit") -@_cdecl("bjs_InternalGreeter_deinit") -public func _bjs_InternalGreeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_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) - Unmanaged.fromOpaque(pointer).release() + 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 } -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()) - } +@_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 } -#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 { +@_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 -@inline(never) fileprivate func _bjs_InternalGreeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_InternalGreeter_wrap_extern(pointer) + #endif } -@_expose(wasm, "bjs_PublicGreeter_deinit") -@_cdecl("bjs_PublicGreeter_deinit") -public func _bjs_PublicGreeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_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) - Unmanaged.fromOpaque(pointer).release() + PropertyHolder.bridgeJSLiftParameter(_self).intValue = Int.bridgeJSLiftParameter(value) #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()) - } +@_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 } -#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 { +@_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 -@inline(never) fileprivate func _bjs_PublicGreeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_PublicGreeter_wrap_extern(pointer) + #endif } -@_expose(wasm, "bjs_PackageGreeter_deinit") -@_cdecl("bjs_PackageGreeter_deinit") -public func _bjs_PackageGreeter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_PropertyHolder_doubleValue_get") +@_cdecl("bjs_PropertyHolder_doubleValue_get") +public func _bjs_PropertyHolder_doubleValue_get(_ _self: UnsafeMutableRawPointer) -> Float64 { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + let ret = PropertyHolder.bridgeJSLiftParameter(_self).doubleValue + return ret.bridgeJSLowerReturn() #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()) - } +@_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 } -#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 { +@_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 } -#endif -@inline(never) fileprivate func _bjs_PackageGreeter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_PackageGreeter_wrap_extern(pointer) + +@_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_Utils_Converter_init") -@_cdecl("bjs_Utils_Converter_init") -public func _bjs_Utils_Converter_init() -> UnsafeMutableRawPointer { +@_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 = Utils.Converter() + let ret = PropertyHolder.bridgeJSLiftParameter(_self).stringValue 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 { +@_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) - let ret = Utils.Converter.bridgeJSLiftParameter(_self).toString(value: Int.bridgeJSLiftParameter(value)) - return ret.bridgeJSLowerReturn() + PropertyHolder.bridgeJSLiftParameter(_self).stringValue = String.bridgeJSLiftParameter(valueBytes, valueLength) #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 { +@_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 = Utils.Converter.bridgeJSLiftParameter(_self).precision + let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyInt 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 { +@_expose(wasm, "bjs_PropertyHolder_readonlyFloat_get") +@_cdecl("bjs_PropertyHolder_readonlyFloat_get") +public func _bjs_PropertyHolder_readonlyFloat_get(_ _self: UnsafeMutableRawPointer) -> Float32 { #if arch(wasm32) - Utils.Converter.bridgeJSLiftParameter(_self).precision = Int.bridgeJSLiftParameter(value) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyFloat + return ret.bridgeJSLowerReturn() #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 { +@_expose(wasm, "bjs_PropertyHolder_readonlyDouble_get") +@_cdecl("bjs_PropertyHolder_readonlyDouble_get") +public func _bjs_PropertyHolder_readonlyDouble_get(_ _self: UnsafeMutableRawPointer) -> Float64 { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyDouble + return ret.bridgeJSLowerReturn() #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()) - } +@_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 } -#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 { +@_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 -@inline(never) fileprivate func _bjs_Utils_Converter_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_Utils_Converter_wrap_extern(pointer) + #endif } -@_expose(wasm, "bjs_Networking_API_HTTPServer_init") -@_cdecl("bjs_Networking_API_HTTPServer_init") -public func _bjs_Networking_API_HTTPServer_init() -> UnsafeMutableRawPointer { +@_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 = Networking.API.HTTPServer() + let ret = PropertyHolder.bridgeJSLiftParameter(_self).jsObject 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 { +@_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) - Networking.API.HTTPServer.bridgeJSLiftParameter(_self).call(_: Networking.API.Method.bridgeJSLiftParameter(method)) + PropertyHolder.bridgeJSLiftParameter(_self).jsObject = JSObject.bridgeJSLiftParameter(value) #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 { +@_expose(wasm, "bjs_PropertyHolder_sibling_get") +@_cdecl("bjs_PropertyHolder_sibling_get") +public func _bjs_PropertyHolder_sibling_get(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + let ret = PropertyHolder.bridgeJSLiftParameter(_self).sibling + return ret.bridgeJSLowerReturn() #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 { +@_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 -@inline(never) fileprivate func _bjs_Networking_API_HTTPServer_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_Networking_API_HTTPServer_wrap_extern(pointer) + #endif } -@_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 { +@_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 = UUID(value: String.bridgeJSLiftParameter(valueBytes, valueLength)) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).lazyValue 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 { +@_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) - let ret = UUID.bridgeJSLiftParameter(_self).uuidString() - return ret.bridgeJSLowerReturn() + PropertyHolder.bridgeJSLiftParameter(_self).lazyValue = String.bridgeJSLiftParameter(valueBytes, valueLength) #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 { +@_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 = UUID.fromValue(_: String.bridgeJSLiftParameter(valueBytes, valueLength)) + let ret = PropertyHolder.bridgeJSLiftParameter(_self).computedReadonly 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 { +@_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 = UUID.placeholder + let ret = PropertyHolder.bridgeJSLiftParameter(_self).computedReadWrite 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 { +@_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) - Unmanaged.fromOpaque(pointer).release() + PropertyHolder.bridgeJSLiftParameter(_self).computedReadWrite = String.bridgeJSLiftParameter(valueBytes, valueLength) #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 { +@_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 = Internal.TestServer() + let ret = PropertyHolder.bridgeJSLiftParameter(_self).observedProperty 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 { +@_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) - Internal.TestServer.bridgeJSLiftParameter(_self).call(_: Internal.SupportedMethod.bridgeJSLiftParameter(method)) + PropertyHolder.bridgeJSLiftParameter(_self).observedProperty = Int.bridgeJSLiftParameter(value) #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 { +@_expose(wasm, "bjs_PropertyHolder_deinit") +@_cdecl("bjs_PropertyHolder_deinit") +public func _bjs_PropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -extension Internal.TestServer: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { +extension PropertyHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_Networking_APIV2_Internal_TestServer_wrap(Unmanaged.passRetained(self).toOpaque())))) + return .object(JSObject(id: UInt32(bitPattern: _bjs_PropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) } consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_Networking_APIV2_Internal_TestServer_wrap(Unmanaged.passRetained(self).toOpaque()) + _bjs_PropertyHolder_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 +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_PropertyHolder_wrap") +fileprivate func _bjs_PropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func _bjs_Networking_APIV2_Internal_TestServer_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func _bjs_PropertyHolder_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) +@inline(never) fileprivate func _bjs_PropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_PropertyHolder_wrap_extern(pointer) } -@_expose(wasm, "bjs_SimplePropertyHolder_init") -@_cdecl("bjs_SimplePropertyHolder_init") -public func _bjs_SimplePropertyHolder_init(_ value: Int32) -> UnsafeMutableRawPointer { +@_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 = SimplePropertyHolder(value: Int.bridgeJSLiftParameter(value)) + 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_SimplePropertyHolder_value_get") -@_cdecl("bjs_SimplePropertyHolder_value_get") -public func _bjs_SimplePropertyHolder_value_get(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_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 = SimplePropertyHolder.bridgeJSLiftParameter(_self).value + 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_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 { +@_expose(wasm, "bjs_MathUtils_deinit") +@_cdecl("bjs_MathUtils_deinit") +public func _bjs_MathUtils_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -extension SimplePropertyHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { +extension MathUtils: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_SimplePropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) + return .object(JSObject(id: UInt32(bitPattern: _bjs_MathUtils_wrap(Unmanaged.passRetained(self).toOpaque())))) } consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_SimplePropertyHolder_wrap(Unmanaged.passRetained(self).toOpaque()) + _bjs_MathUtils_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 +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_MathUtils_wrap") +fileprivate func _bjs_MathUtils_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func _bjs_SimplePropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func _bjs_MathUtils_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) +@inline(never) fileprivate func _bjs_MathUtils_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_MathUtils_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 { +@_expose(wasm, "bjs_StaticPropertyHolder_init") +@_cdecl("bjs_StaticPropertyHolder_init") +public func _bjs_StaticPropertyHolder_init() -> 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)) + let ret = StaticPropertyHolder() 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 { +@_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 = PropertyHolder.bridgeJSLiftParameter(_self).getAllValues() + let ret = StaticPropertyHolder.staticConstant 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 { +@_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 = PropertyHolder.bridgeJSLiftParameter(_self).intValue + let ret = StaticPropertyHolder.staticVariable 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 { +@_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) - PropertyHolder.bridgeJSLiftParameter(_self).intValue = Int.bridgeJSLiftParameter(value) + StaticPropertyHolder.staticVariable = 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 { +@_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 = PropertyHolder.bridgeJSLiftParameter(_self).floatValue + let ret = StaticPropertyHolder.staticString 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 { +@_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) - PropertyHolder.bridgeJSLiftParameter(_self).floatValue = Float.bridgeJSLiftParameter(value) + StaticPropertyHolder.staticString = String.bridgeJSLiftParameter(valueBytes, valueLength) #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 { +@_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 = PropertyHolder.bridgeJSLiftParameter(_self).doubleValue + let ret = StaticPropertyHolder.staticBool 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 { +@_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) - PropertyHolder.bridgeJSLiftParameter(_self).doubleValue = Double.bridgeJSLiftParameter(value) + StaticPropertyHolder.staticBool = Bool.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 { + +@_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 = PropertyHolder.bridgeJSLiftParameter(_self).boolValue + let ret = StaticPropertyHolder.staticFloat 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 { +@_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) - PropertyHolder.bridgeJSLiftParameter(_self).boolValue = Bool.bridgeJSLiftParameter(value) + StaticPropertyHolder.staticFloat = Float.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 { +@_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 = PropertyHolder.bridgeJSLiftParameter(_self).stringValue + let ret = StaticPropertyHolder.staticDouble 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 { +@_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) - PropertyHolder.bridgeJSLiftParameter(_self).stringValue = String.bridgeJSLiftParameter(valueBytes, valueLength) + StaticPropertyHolder.staticDouble = Double.bridgeJSLiftParameter(value) #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 { +@_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 = PropertyHolder.bridgeJSLiftParameter(_self).readonlyInt + let ret = StaticPropertyHolder.computedProperty 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 { +@_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) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyFloat - return ret.bridgeJSLowerReturn() + StaticPropertyHolder.computedProperty = String.bridgeJSLiftParameter(valueBytes, valueLength) #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 { +@_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 = PropertyHolder.bridgeJSLiftParameter(_self).readonlyDouble + let ret = StaticPropertyHolder.readOnlyComputed 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 { +@_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 = PropertyHolder.bridgeJSLiftParameter(_self).readonlyBool + let ret = StaticPropertyHolder.optionalString 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 { +@_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) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).readonlyString - return ret.bridgeJSLowerReturn() + StaticPropertyHolder.optionalString = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) #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 { +@_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 = PropertyHolder.bridgeJSLiftParameter(_self).jsObject + let ret = StaticPropertyHolder.optionalInt 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 { +@_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) - PropertyHolder.bridgeJSLiftParameter(_self).jsObject = JSObject.bridgeJSLiftParameter(value) + StaticPropertyHolder.optionalInt = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) #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 { +@_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 = PropertyHolder.bridgeJSLiftParameter(_self).sibling + let ret = StaticPropertyHolder.jsObjectProperty 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 { +@_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) - PropertyHolder.bridgeJSLiftParameter(_self).sibling = SimplePropertyHolder.bridgeJSLiftParameter(value) + StaticPropertyHolder.jsObjectProperty = JSObject.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 { +@_expose(wasm, "bjs_StaticPropertyHolder_deinit") +@_cdecl("bjs_StaticPropertyHolder_deinit") +public func _bjs_StaticPropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).lazyValue - return ret.bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() #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 +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 +} +#endif +@inline(never) fileprivate func _bjs_StaticPropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_StaticPropertyHolder_wrap_extern(pointer) } -@_expose(wasm, "bjs_PropertyHolder_computedReadonly_get") -@_cdecl("bjs_PropertyHolder_computedReadonly_get") -public func _bjs_PropertyHolder_computedReadonly_get(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_DataProcessorManager_init") +@_cdecl("bjs_DataProcessorManager_init") +public func _bjs_DataProcessorManager_init(_ processor: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).computedReadonly + let ret = DataProcessorManager(processor: AnyDataProcessor.bridgeJSLiftParameter(processor)) 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 { +@_expose(wasm, "bjs_DataProcessorManager_incrementByAmount") +@_cdecl("bjs_DataProcessorManager_incrementByAmount") +public func _bjs_DataProcessorManager_incrementByAmount(_ _self: UnsafeMutableRawPointer, _ amount: Int32) -> Void { #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).computedReadWrite - return ret.bridgeJSLowerReturn() + DataProcessorManager.bridgeJSLiftParameter(_self).incrementByAmount(_: Int.bridgeJSLiftParameter(amount)) #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 { +@_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) - PropertyHolder.bridgeJSLiftParameter(_self).computedReadWrite = String.bridgeJSLiftParameter(valueBytes, valueLength) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorLabel(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength), _: String.bridgeJSLiftParameter(suffixBytes, suffixLength)) #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 { +@_expose(wasm, "bjs_DataProcessorManager_isProcessorEven") +@_cdecl("bjs_DataProcessorManager_isProcessorEven") +public func _bjs_DataProcessorManager_isProcessorEven(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = PropertyHolder.bridgeJSLiftParameter(_self).observedProperty + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).isProcessorEven() 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 { +@_expose(wasm, "bjs_DataProcessorManager_getProcessorLabel") +@_cdecl("bjs_DataProcessorManager_getProcessorLabel") +public func _bjs_DataProcessorManager_getProcessorLabel(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - PropertyHolder.bridgeJSLiftParameter(_self).observedProperty = Int.bridgeJSLiftParameter(value) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorLabel() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_PropertyHolder_deinit") -@_cdecl("bjs_PropertyHolder_deinit") -public func _bjs_PropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_DataProcessorManager_getCurrentValue") +@_cdecl("bjs_DataProcessorManager_getCurrentValue") +public func _bjs_DataProcessorManager_getCurrentValue(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getCurrentValue() + return ret.bridgeJSLowerReturn() #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 { +@_expose(wasm, "bjs_DataProcessorManager_incrementBoth") +@_cdecl("bjs_DataProcessorManager_incrementBoth") +public func _bjs_DataProcessorManager_incrementBoth(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = MathUtils.add(a: Int.bridgeJSLiftParameter(a), b: Int.bridgeJSLiftParameter(b)) - return ret.bridgeJSLowerReturn() + DataProcessorManager.bridgeJSLiftParameter(_self).incrementBoth() #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 { +@_expose(wasm, "bjs_DataProcessorManager_getBackupValue") +@_cdecl("bjs_DataProcessorManager_getBackupValue") +public func _bjs_DataProcessorManager_getBackupValue(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = MathUtils.substract(a: Int.bridgeJSLiftParameter(a), b: Int.bridgeJSLiftParameter(b)) + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getBackupValue() 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 { +@_expose(wasm, "bjs_DataProcessorManager_hasBackup") +@_cdecl("bjs_DataProcessorManager_hasBackup") +public func _bjs_DataProcessorManager_hasBackup(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).hasBackup() + return ret.bridgeJSLowerReturn() #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 { +@_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 } -#endif -@inline(never) fileprivate func _bjs_MathUtils_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_MathUtils_wrap_extern(pointer) + +@_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_StaticPropertyHolder_init") -@_cdecl("bjs_StaticPropertyHolder_init") -public func _bjs_StaticPropertyHolder_init() -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_DataProcessorManager_getProcessorOptionalCount") +@_cdecl("bjs_DataProcessorManager_getProcessorOptionalCount") +public func _bjs_DataProcessorManager_getProcessorOptionalCount(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = StaticPropertyHolder() + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorOptionalCount() 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 { +@_expose(wasm, "bjs_DataProcessorManager_setProcessorOptionalCount") +@_cdecl("bjs_DataProcessorManager_setProcessorOptionalCount") +public func _bjs_DataProcessorManager_setProcessorOptionalCount(_ _self: UnsafeMutableRawPointer, _ countIsSome: Int32, _ countValue: Int32) -> Void { #if arch(wasm32) - let ret = StaticPropertyHolder.staticConstant - return ret.bridgeJSLowerReturn() + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorOptionalCount(_: Optional.bridgeJSLiftParameter(countIsSome, countValue)) #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 { +@_expose(wasm, "bjs_DataProcessorManager_getProcessorDirection") +@_cdecl("bjs_DataProcessorManager_getProcessorDirection") +public func _bjs_DataProcessorManager_getProcessorDirection(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = StaticPropertyHolder.staticVariable + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorDirection() 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 { +@_expose(wasm, "bjs_DataProcessorManager_setProcessorDirection") +@_cdecl("bjs_DataProcessorManager_setProcessorDirection") +public func _bjs_DataProcessorManager_setProcessorDirection(_ _self: UnsafeMutableRawPointer, _ directionIsSome: Int32, _ directionValue: Int32) -> Void { #if arch(wasm32) - StaticPropertyHolder.staticVariable = Int.bridgeJSLiftParameter(value) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorDirection(_: Optional.bridgeJSLiftParameter(directionIsSome, directionValue)) #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 { +@_expose(wasm, "bjs_DataProcessorManager_getProcessorTheme") +@_cdecl("bjs_DataProcessorManager_getProcessorTheme") +public func _bjs_DataProcessorManager_getProcessorTheme(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = StaticPropertyHolder.staticString + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorTheme() 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 { +@_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) - StaticPropertyHolder.staticString = String.bridgeJSLiftParameter(valueBytes, valueLength) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorTheme(_: Optional.bridgeJSLiftParameter(themeIsSome, themeBytes, themeLength)) #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 { +@_expose(wasm, "bjs_DataProcessorManager_getProcessorHttpStatus") +@_cdecl("bjs_DataProcessorManager_getProcessorHttpStatus") +public func _bjs_DataProcessorManager_getProcessorHttpStatus(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = StaticPropertyHolder.staticBool + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorHttpStatus() 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 { +@_expose(wasm, "bjs_DataProcessorManager_setProcessorHttpStatus") +@_cdecl("bjs_DataProcessorManager_setProcessorHttpStatus") +public func _bjs_DataProcessorManager_setProcessorHttpStatus(_ _self: UnsafeMutableRawPointer, _ statusIsSome: Int32, _ statusValue: Int32) -> Void { #if arch(wasm32) - StaticPropertyHolder.staticBool = Bool.bridgeJSLiftParameter(value) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorHttpStatus(_: Optional.bridgeJSLiftParameter(statusIsSome, statusValue)) #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 { +@_expose(wasm, "bjs_DataProcessorManager_getProcessorAPIResult") +@_cdecl("bjs_DataProcessorManager_getProcessorAPIResult") +public func _bjs_DataProcessorManager_getProcessorAPIResult(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = StaticPropertyHolder.staticFloat + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorAPIResult() 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 { +@_expose(wasm, "bjs_DataProcessorManager_setProcessorAPIResult") +@_cdecl("bjs_DataProcessorManager_setProcessorAPIResult") +public func _bjs_DataProcessorManager_setProcessorAPIResult(_ _self: UnsafeMutableRawPointer, _ apiResultIsSome: Int32, _ apiResultCaseId: Int32) -> Void { #if arch(wasm32) - StaticPropertyHolder.staticFloat = Float.bridgeJSLiftParameter(value) + DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorAPIResult(_: Optional.bridgeJSLiftParameter(apiResultIsSome, apiResultCaseId)) #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 { +@_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 = StaticPropertyHolder.staticDouble - return ret.bridgeJSLowerReturn() + let ret = DataProcessorManager.bridgeJSLiftParameter(_self).processor as! _BridgedSwiftProtocolExportable + return ret.bridgeJSLowerAsProtocolReturn() #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 { +@_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) - StaticPropertyHolder.staticDouble = Double.bridgeJSLiftParameter(value) + DataProcessorManager.bridgeJSLiftParameter(_self).processor = AnyDataProcessor.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 { +@_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 = StaticPropertyHolder.computedProperty - return ret.bridgeJSLowerReturn() + 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_StaticPropertyHolder_static_computedProperty_set") -@_cdecl("bjs_StaticPropertyHolder_static_computedProperty_set") -public func _bjs_StaticPropertyHolder_static_computedProperty_set(_ valueBytes: Int32, _ valueLength: Int32) -> Void { +@_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) - StaticPropertyHolder.computedProperty = String.bridgeJSLiftParameter(valueBytes, valueLength) + DataProcessorManager.bridgeJSLiftParameter(_self).backupProcessor = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) #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 { +@_expose(wasm, "bjs_DataProcessorManager_deinit") +@_cdecl("bjs_DataProcessorManager_deinit") +public func _bjs_DataProcessorManager_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = StaticPropertyHolder.readOnlyComputed - return ret.bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() #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 { +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 = StaticPropertyHolder.optionalString + let ret = SwiftDataProcessor() 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 { +@_expose(wasm, "bjs_SwiftDataProcessor_increment") +@_cdecl("bjs_SwiftDataProcessor_increment") +public func _bjs_SwiftDataProcessor_increment(_ _self: UnsafeMutableRawPointer, _ amount: Int32) -> Void { #if arch(wasm32) - StaticPropertyHolder.optionalString = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) + SwiftDataProcessor.bridgeJSLiftParameter(_self).increment(by: Int.bridgeJSLiftParameter(amount)) #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 { +@_expose(wasm, "bjs_SwiftDataProcessor_getValue") +@_cdecl("bjs_SwiftDataProcessor_getValue") +public func _bjs_SwiftDataProcessor_getValue(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = StaticPropertyHolder.optionalInt + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).getValue() 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 { +@_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) - StaticPropertyHolder.optionalInt = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + SwiftDataProcessor.bridgeJSLiftParameter(_self).setLabelElements(_: String.bridgeJSLiftParameter(labelPrefixBytes, labelPrefixLength), _: String.bridgeJSLiftParameter(labelSuffixBytes, labelSuffixLength)) #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 { +@_expose(wasm, "bjs_SwiftDataProcessor_getLabel") +@_cdecl("bjs_SwiftDataProcessor_getLabel") +public func _bjs_SwiftDataProcessor_getLabel(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = StaticPropertyHolder.jsObjectProperty + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).getLabel() 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 { +@_expose(wasm, "bjs_SwiftDataProcessor_isEven") +@_cdecl("bjs_SwiftDataProcessor_isEven") +public func _bjs_SwiftDataProcessor_isEven(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - StaticPropertyHolder.jsObjectProperty = JSObject.bridgeJSLiftParameter(value) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).isEven() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_StaticPropertyHolder_deinit") -@_cdecl("bjs_StaticPropertyHolder_deinit") -public func _bjs_StaticPropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_SwiftDataProcessor_processGreeter") +@_cdecl("bjs_SwiftDataProcessor_processGreeter") +public func _bjs_SwiftDataProcessor_processGreeter(_ _self: UnsafeMutableRawPointer, _ greeter: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).processGreeter(_: Greeter.bridgeJSLiftParameter(greeter)) + return ret.bridgeJSLowerReturn() #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()) - } +@_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 } -#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 { +@_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 -@inline(never) fileprivate func _bjs_StaticPropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_StaticPropertyHolder_wrap_extern(pointer) + #endif } -@_expose(wasm, "bjs_DataProcessorManager_init") -@_cdecl("bjs_DataProcessorManager_init") -public func _bjs_DataProcessorManager_init(_ processor: Int32) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_SwiftDataProcessor_createOptionalGreeter") +@_cdecl("bjs_SwiftDataProcessor_createOptionalGreeter") +public func _bjs_SwiftDataProcessor_createOptionalGreeter(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = DataProcessorManager(processor: AnyDataProcessor.bridgeJSLiftParameter(processor)) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).createOptionalGreeter() 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 { +@_expose(wasm, "bjs_SwiftDataProcessor_handleAPIResult") +@_cdecl("bjs_SwiftDataProcessor_handleAPIResult") +public func _bjs_SwiftDataProcessor_handleAPIResult(_ _self: UnsafeMutableRawPointer, _ resultIsSome: Int32, _ resultCaseId: Int32) -> Void { #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).incrementByAmount(_: Int.bridgeJSLiftParameter(amount)) + SwiftDataProcessor.bridgeJSLiftParameter(_self).handleAPIResult(_: Optional.bridgeJSLiftParameter(resultIsSome, resultCaseId)) #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 { +@_expose(wasm, "bjs_SwiftDataProcessor_getAPIResult") +@_cdecl("bjs_SwiftDataProcessor_getAPIResult") +public func _bjs_SwiftDataProcessor_getAPIResult(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorLabel(_: String.bridgeJSLiftParameter(prefixBytes, prefixLength), _: String.bridgeJSLiftParameter(suffixBytes, suffixLength)) + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).getAPIResult() + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_DataProcessorManager_isProcessorEven") -@_cdecl("bjs_DataProcessorManager_isProcessorEven") -public func _bjs_DataProcessorManager_isProcessorEven(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_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 = DataProcessorManager.bridgeJSLiftParameter(_self).isProcessorEven() + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).count 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 { +@_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) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorLabel() + 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_DataProcessorManager_getCurrentValue") -@_cdecl("bjs_DataProcessorManager_getCurrentValue") -public func _bjs_DataProcessorManager_getCurrentValue(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_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 = DataProcessorManager.bridgeJSLiftParameter(_self).getCurrentValue() + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTag 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 { +@_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) - DataProcessorManager.bridgeJSLiftParameter(_self).incrementBoth() + SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTag = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_DataProcessorManager_getBackupValue") -@_cdecl("bjs_DataProcessorManager_getBackupValue") -public func _bjs_DataProcessorManager_getBackupValue(_ _self: UnsafeMutableRawPointer) -> Void { +@_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 = DataProcessorManager.bridgeJSLiftParameter(_self).getBackupValue() + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalCount 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 { +@_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) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).hasBackup() - return ret.bridgeJSLowerReturn() + SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalCount = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_DataProcessorManager_getProcessorOptionalTag") -@_cdecl("bjs_DataProcessorManager_getProcessorOptionalTag") -public func _bjs_DataProcessorManager_getProcessorOptionalTag(_ _self: UnsafeMutableRawPointer) -> Void { +@_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 = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorOptionalTag() + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).direction 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 { +@_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) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorOptionalTag(_: Optional.bridgeJSLiftParameter(tagIsSome, tagBytes, tagLength)) + SwiftDataProcessor.bridgeJSLiftParameter(_self).direction = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_DataProcessorManager_getProcessorOptionalCount") -@_cdecl("bjs_DataProcessorManager_getProcessorOptionalCount") -public func _bjs_DataProcessorManager_getProcessorOptionalCount(_ _self: UnsafeMutableRawPointer) -> Void { +@_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 = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorOptionalCount() + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTheme 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 { +@_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) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorOptionalCount(_: Optional.bridgeJSLiftParameter(countIsSome, countValue)) + SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTheme = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_DataProcessorManager_getProcessorDirection") -@_cdecl("bjs_DataProcessorManager_getProcessorDirection") -public func _bjs_DataProcessorManager_getProcessorDirection(_ _self: UnsafeMutableRawPointer) -> Void { +@_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 = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorDirection() + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).httpStatus 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 { +@_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) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorDirection(_: Optional.bridgeJSLiftParameter(directionIsSome, directionValue)) + SwiftDataProcessor.bridgeJSLiftParameter(_self).httpStatus = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_DataProcessorManager_getProcessorTheme") -@_cdecl("bjs_DataProcessorManager_getProcessorTheme") -public func _bjs_DataProcessorManager_getProcessorTheme(_ _self: UnsafeMutableRawPointer) -> Void { +@_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 = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorTheme() + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).apiResult 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 { +@_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) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorTheme(_: Optional.bridgeJSLiftParameter(themeIsSome, themeBytes, themeLength)) + SwiftDataProcessor.bridgeJSLiftParameter(_self).apiResult = Optional.bridgeJSLiftParameter(valueIsSome, valueCaseId) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_DataProcessorManager_getProcessorHttpStatus") -@_cdecl("bjs_DataProcessorManager_getProcessorHttpStatus") -public func _bjs_DataProcessorManager_getProcessorHttpStatus(_ _self: UnsafeMutableRawPointer) -> Void { +@_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 = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorHttpStatus() + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).helper 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 { +@_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) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorHttpStatus(_: Optional.bridgeJSLiftParameter(statusIsSome, statusValue)) + SwiftDataProcessor.bridgeJSLiftParameter(_self).helper = Greeter.bridgeJSLiftParameter(value) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_DataProcessorManager_getProcessorAPIResult") -@_cdecl("bjs_DataProcessorManager_getProcessorAPIResult") -public func _bjs_DataProcessorManager_getProcessorAPIResult(_ _self: UnsafeMutableRawPointer) -> Void { +@_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 = DataProcessorManager.bridgeJSLiftParameter(_self).getProcessorAPIResult() + let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalHelper 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 { +@_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) - DataProcessorManager.bridgeJSLiftParameter(_self).setProcessorAPIResult(_: Optional.bridgeJSLiftParameter(apiResultIsSome, apiResultCaseId)) + SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalHelper = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) #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 { +@_expose(wasm, "bjs_SwiftDataProcessor_deinit") +@_cdecl("bjs_SwiftDataProcessor_deinit") +public func _bjs_SwiftDataProcessor_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).processor as! _BridgedSwiftProtocolExportable + 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_DataProcessorManager_processor_set") -@_cdecl("bjs_DataProcessorManager_processor_set") -public func _bjs_DataProcessorManager_processor_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void { +@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessorOptional") +@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessorOptional") +public func _bjs_ProtocolReturnTests_static_createNativeProcessorOptional() -> Void { #if arch(wasm32) - DataProcessorManager.bridgeJSLiftParameter(_self).processor = AnyDataProcessor.bridgeJSLiftParameter(value) + 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_DataProcessorManager_backupProcessor_get") -@_cdecl("bjs_DataProcessorManager_backupProcessor_get") -public func _bjs_DataProcessorManager_backupProcessor_get(_ _self: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessorNil") +@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessorNil") +public func _bjs_ProtocolReturnTests_static_createNativeProcessorNil() -> Void { #if arch(wasm32) - let ret = DataProcessorManager.bridgeJSLiftParameter(_self).backupProcessor + let ret = ProtocolReturnTests.createNativeProcessorNil() if let ret { _swift_js_return_optional_object(1, (ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) } else { @@ -10870,1153 +12494,1302 @@ public func _bjs_DataProcessorManager_backupProcessor_get(_ _self: UnsafeMutable #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 { +@_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) - DataProcessorManager.bridgeJSLiftParameter(_self).backupProcessor = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + 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_DataProcessorManager_deinit") -@_cdecl("bjs_DataProcessorManager_deinit") -public func _bjs_DataProcessorManager_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_ProtocolReturnTests_deinit") +@_cdecl("bjs_ProtocolReturnTests_deinit") +public func _bjs_ProtocolReturnTests_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -extension DataProcessorManager: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { +extension ProtocolReturnTests: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_DataProcessorManager_wrap(Unmanaged.passRetained(self).toOpaque())))) + return .object(JSObject(id: UInt32(bitPattern: _bjs_ProtocolReturnTests_wrap(Unmanaged.passRetained(self).toOpaque())))) } consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_DataProcessorManager_wrap(Unmanaged.passRetained(self).toOpaque()) + _bjs_ProtocolReturnTests_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 +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ProtocolReturnTests_wrap") +fileprivate func _bjs_ProtocolReturnTests_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func _bjs_DataProcessorManager_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func _bjs_ProtocolReturnTests_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) +@inline(never) fileprivate func _bjs_ProtocolReturnTests_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_ProtocolReturnTests_wrap_extern(pointer) } -@_expose(wasm, "bjs_SwiftDataProcessor_init") -@_cdecl("bjs_SwiftDataProcessor_init") -public func _bjs_SwiftDataProcessor_init() -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_TextProcessor_init") +@_cdecl("bjs_TextProcessor_init") +public func _bjs_TextProcessor_init(_ transform: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = SwiftDataProcessor() + let ret = TextProcessor(transform: _BJS_Closure_20BridgeJSRuntimeTestsSS_SS.bridgeJSLift(transform)) 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 { +@_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 = SwiftDataProcessor.bridgeJSLiftParameter(_self).getValue() + let ret = TextProcessor.bridgeJSLiftParameter(_self).process(_: String.bridgeJSLiftParameter(textBytes, textLength)) 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 { +@_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 = SwiftDataProcessor.bridgeJSLiftParameter(_self).getLabel() + 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_SwiftDataProcessor_isEven") -@_cdecl("bjs_SwiftDataProcessor_isEven") -public func _bjs_SwiftDataProcessor_isEven(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_TextProcessor_getTransform") +@_cdecl("bjs_TextProcessor_getTransform") +public func _bjs_TextProcessor_getTransform(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).isEven() - return ret.bridgeJSLowerReturn() + let ret = TextProcessor.bridgeJSLiftParameter(_self).getTransform() + return JSTypedClosure(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 { +@_expose(wasm, "bjs_TextProcessor_processOptionalString") +@_cdecl("bjs_TextProcessor_processOptionalString") +public func _bjs_TextProcessor_processOptionalString(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).processGreeter(_: Greeter.bridgeJSLiftParameter(greeter)) + 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_SwiftDataProcessor_createGreeter") -@_cdecl("bjs_SwiftDataProcessor_createGreeter") -public func _bjs_SwiftDataProcessor_createGreeter(_ _self: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer { +@_expose(wasm, "bjs_TextProcessor_processOptionalInt") +@_cdecl("bjs_TextProcessor_processOptionalInt") +public func _bjs_TextProcessor_processOptionalInt(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).createGreeter() + 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_SwiftDataProcessor_processOptionalGreeter") -@_cdecl("bjs_SwiftDataProcessor_processOptionalGreeter") -public func _bjs_SwiftDataProcessor_processOptionalGreeter(_ _self: UnsafeMutableRawPointer, _ greeterIsSome: Int32, _ greeterValue: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_TextProcessor_processOptionalGreeter") +@_cdecl("bjs_TextProcessor_processOptionalGreeter") +public func _bjs_TextProcessor_processOptionalGreeter(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).processOptionalGreeter(_: Optional.bridgeJSLiftParameter(greeterIsSome, greeterValue)) + 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_SwiftDataProcessor_createOptionalGreeter") -@_cdecl("bjs_SwiftDataProcessor_createOptionalGreeter") -public func _bjs_SwiftDataProcessor_createOptionalGreeter(_ _self: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_TextProcessor_makeOptionalStringFormatter") +@_cdecl("bjs_TextProcessor_makeOptionalStringFormatter") +public func _bjs_TextProcessor_makeOptionalStringFormatter(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).createOptionalGreeter() - return ret.bridgeJSLowerReturn() + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeOptionalStringFormatter() + return JSTypedClosure(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 { +@_expose(wasm, "bjs_TextProcessor_makeOptionalGreeterCreator") +@_cdecl("bjs_TextProcessor_makeOptionalGreeterCreator") +public func _bjs_TextProcessor_makeOptionalGreeterCreator(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).handleAPIResult(_: Optional.bridgeJSLiftParameter(resultIsSome, resultCaseId)) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeOptionalGreeterCreator() + return JSTypedClosure(ret).bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_SwiftDataProcessor_getAPIResult") -@_cdecl("bjs_SwiftDataProcessor_getAPIResult") -public func _bjs_SwiftDataProcessor_getAPIResult(_ _self: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_TextProcessor_processDirection") +@_cdecl("bjs_TextProcessor_processDirection") +public func _bjs_TextProcessor_processDirection(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).getAPIResult() + 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_SwiftDataProcessor_count_get") -@_cdecl("bjs_SwiftDataProcessor_count_get") -public func _bjs_SwiftDataProcessor_count_get(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_TextProcessor_processTheme") +@_cdecl("bjs_TextProcessor_processTheme") +public func _bjs_TextProcessor_processTheme(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).count + 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_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 { +@_expose(wasm, "bjs_TextProcessor_processHttpStatus") +@_cdecl("bjs_TextProcessor_processHttpStatus") +public func _bjs_TextProcessor_processHttpStatus(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Int32 { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).name + 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_SwiftDataProcessor_optionalTag_get") -@_cdecl("bjs_SwiftDataProcessor_optionalTag_get") -public func _bjs_SwiftDataProcessor_optionalTag_get(_ _self: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_TextProcessor_processAPIResult") +@_cdecl("bjs_TextProcessor_processAPIResult") +public func _bjs_TextProcessor_processAPIResult(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTag + 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_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 { +@_expose(wasm, "bjs_TextProcessor_makeDirectionChecker") +@_cdecl("bjs_TextProcessor_makeDirectionChecker") +public func _bjs_TextProcessor_makeDirectionChecker(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalCount - return ret.bridgeJSLowerReturn() + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeDirectionChecker() + return JSTypedClosure(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 { +@_expose(wasm, "bjs_TextProcessor_makeThemeValidator") +@_cdecl("bjs_TextProcessor_makeThemeValidator") +public func _bjs_TextProcessor_makeThemeValidator(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalCount = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeThemeValidator() + return JSTypedClosure(ret).bridgeJSLowerReturn() #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 { +@_expose(wasm, "bjs_TextProcessor_makeStatusCodeExtractor") +@_cdecl("bjs_TextProcessor_makeStatusCodeExtractor") +public func _bjs_TextProcessor_makeStatusCodeExtractor(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).direction - return ret.bridgeJSLowerReturn() + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeStatusCodeExtractor() + return JSTypedClosure(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 { +@_expose(wasm, "bjs_TextProcessor_makeAPIResultHandler") +@_cdecl("bjs_TextProcessor_makeAPIResultHandler") +public func _bjs_TextProcessor_makeAPIResultHandler(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).direction = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeAPIResultHandler() + return JSTypedClosure(ret).bridgeJSLowerReturn() #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 { +@_expose(wasm, "bjs_TextProcessor_processOptionalDirection") +@_cdecl("bjs_TextProcessor_processOptionalDirection") +public func _bjs_TextProcessor_processOptionalDirection(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTheme + 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_SwiftDataProcessor_optionalTheme_set") -@_cdecl("bjs_SwiftDataProcessor_optionalTheme_set") -public func _bjs_SwiftDataProcessor_optionalTheme_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { +@_expose(wasm, "bjs_TextProcessor_processOptionalTheme") +@_cdecl("bjs_TextProcessor_processOptionalTheme") +public func _bjs_TextProcessor_processOptionalTheme(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalTheme = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) + 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_SwiftDataProcessor_httpStatus_get") -@_cdecl("bjs_SwiftDataProcessor_httpStatus_get") -public func _bjs_SwiftDataProcessor_httpStatus_get(_ _self: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_TextProcessor_processOptionalAPIResult") +@_cdecl("bjs_TextProcessor_processOptionalAPIResult") +public func _bjs_TextProcessor_processOptionalAPIResult(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).httpStatus + 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_SwiftDataProcessor_httpStatus_set") -@_cdecl("bjs_SwiftDataProcessor_httpStatus_set") -public func _bjs_SwiftDataProcessor_httpStatus_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { +@_expose(wasm, "bjs_TextProcessor_makeOptionalDirectionFormatter") +@_cdecl("bjs_TextProcessor_makeOptionalDirectionFormatter") +public func _bjs_TextProcessor_makeOptionalDirectionFormatter(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).httpStatus = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeOptionalDirectionFormatter() + return JSTypedClosure(ret).bridgeJSLowerReturn() #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 { +@_expose(wasm, "bjs_TextProcessor_processDataProcessor") +@_cdecl("bjs_TextProcessor_processDataProcessor") +public func _bjs_TextProcessor_processDataProcessor(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).apiResult + 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_SwiftDataProcessor_apiResult_set") -@_cdecl("bjs_SwiftDataProcessor_apiResult_set") -public func _bjs_SwiftDataProcessor_apiResult_set(_ _self: UnsafeMutableRawPointer, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void { +@_expose(wasm, "bjs_TextProcessor_makeDataProcessorFactory") +@_cdecl("bjs_TextProcessor_makeDataProcessorFactory") +public func _bjs_TextProcessor_makeDataProcessorFactory(_ _self: UnsafeMutableRawPointer) -> Int32 { #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).apiResult = Optional.bridgeJSLiftParameter(valueIsSome, valueCaseId) + let ret = TextProcessor.bridgeJSLiftParameter(_self).makeDataProcessorFactory() + return JSTypedClosure(ret).bridgeJSLowerReturn() #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 { +@_expose(wasm, "bjs_TextProcessor_roundtripDataProcessor") +@_cdecl("bjs_TextProcessor_roundtripDataProcessor") +public func _bjs_TextProcessor_roundtripDataProcessor(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Int32 { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).helper - return ret.bridgeJSLowerReturn() + 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_SwiftDataProcessor_helper_set") -@_cdecl("bjs_SwiftDataProcessor_helper_set") -public func _bjs_SwiftDataProcessor_helper_set(_ _self: UnsafeMutableRawPointer, _ value: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_TextProcessor_processOptionalDataProcessor") +@_cdecl("bjs_TextProcessor_processOptionalDataProcessor") +public func _bjs_TextProcessor_processOptionalDataProcessor(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).helper = Greeter.bridgeJSLiftParameter(value) + 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_SwiftDataProcessor_optionalHelper_get") -@_cdecl("bjs_SwiftDataProcessor_optionalHelper_get") -public func _bjs_SwiftDataProcessor_optionalHelper_get(_ _self: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_TextProcessor_processVector") +@_cdecl("bjs_TextProcessor_processVector") +public func _bjs_TextProcessor_processVector(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Float64 { #if arch(wasm32) - let ret = SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalHelper + let ret = TextProcessor.bridgeJSLiftParameter(_self).processVector(_: _BJS_Closure_20BridgeJSRuntimeTestsSd_8Vector2DV.bridgeJSLift(callback)) 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 { +@_expose(wasm, "bjs_TextProcessor_processOptionalVector") +@_cdecl("bjs_TextProcessor_processOptionalVector") +public func _bjs_TextProcessor_processOptionalVector(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { #if arch(wasm32) - SwiftDataProcessor.bridgeJSLiftParameter(_self).optionalHelper = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) + let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalVector(_: _BJS_Closure_20BridgeJSRuntimeTestsSd_Sq8Vector2DV.bridgeJSLift(callback)) + return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_SwiftDataProcessor_deinit") -@_cdecl("bjs_SwiftDataProcessor_deinit") -public func _bjs_SwiftDataProcessor_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_TextProcessor_deinit") +@_cdecl("bjs_TextProcessor_deinit") +public func _bjs_TextProcessor_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -extension SwiftDataProcessor: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { +extension TextProcessor: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_SwiftDataProcessor_wrap(Unmanaged.passRetained(self).toOpaque())))) + return .object(JSObject(id: UInt32(bitPattern: _bjs_TextProcessor_wrap(Unmanaged.passRetained(self).toOpaque())))) } consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_SwiftDataProcessor_wrap(Unmanaged.passRetained(self).toOpaque()) + _bjs_TextProcessor_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 +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TextProcessor_wrap") +fileprivate func _bjs_TextProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func _bjs_SwiftDataProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func _bjs_TextProcessor_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) +@inline(never) fileprivate func _bjs_TextProcessor_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_TextProcessor_wrap_extern(pointer) } -@_expose(wasm, "bjs_ProtocolReturnTests_static_createNativeProcessor") -@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessor") -public func _bjs_ProtocolReturnTests_static_createNativeProcessor() -> Int32 { +@_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 = ProtocolReturnTests.createNativeProcessor() as! _BridgedSwiftProtocolExportable - return ret.bridgeJSLowerAsProtocolReturn() + 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_ProtocolReturnTests_static_createNativeProcessorOptional") -@_cdecl("bjs_ProtocolReturnTests_static_createNativeProcessorOptional") -public func _bjs_ProtocolReturnTests_static_createNativeProcessorOptional() -> Void { +@_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 = ProtocolReturnTests.createNativeProcessorOptional() - if let ret { - _swift_js_return_optional_object(1, (ret as! _BridgedSwiftProtocolExportable).bridgeJSLowerAsProtocolReturn()) - } else { - _swift_js_return_optional_object(0, 0) - } + let ret = OptionalHolder.bridgeJSLiftParameter(_self).nullableGreeter + return ret.bridgeJSLowerReturn() #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 { +@_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) - 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) - } + OptionalHolder.bridgeJSLiftParameter(_self).nullableGreeter = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) #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 { +@_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 = 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)) + let ret = OptionalHolder.bridgeJSLiftParameter(_self).undefinedNumber + return ret.bridgeJSLowerReturn() #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 { +@_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) - 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)) + OptionalHolder.bridgeJSLiftParameter(_self).undefinedNumber = JSUndefinedOr.bridgeJSLiftParameter(valueIsSome, valueValue) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_ProtocolReturnTests_deinit") -@_cdecl("bjs_ProtocolReturnTests_deinit") -public func _bjs_ProtocolReturnTests_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { +@_expose(wasm, "bjs_OptionalHolder_deinit") +@_cdecl("bjs_OptionalHolder_deinit") +public func _bjs_OptionalHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - Unmanaged.fromOpaque(pointer).release() + Unmanaged.fromOpaque(pointer).release() #else fatalError("Only available on WebAssembly") #endif } -extension ProtocolReturnTests: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { +extension OptionalHolder: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { var jsValue: JSValue { - return .object(JSObject(id: UInt32(bitPattern: _bjs_ProtocolReturnTests_wrap(Unmanaged.passRetained(self).toOpaque())))) + return .object(JSObject(id: UInt32(bitPattern: _bjs_OptionalHolder_wrap(Unmanaged.passRetained(self).toOpaque())))) } consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { - _bjs_ProtocolReturnTests_wrap(Unmanaged.passRetained(self).toOpaque()) + _bjs_OptionalHolder_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 +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalHolder_wrap") +fileprivate func _bjs_OptionalHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 #else -fileprivate func _bjs_ProtocolReturnTests_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func _bjs_OptionalHolder_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) +@inline(never) fileprivate func _bjs_OptionalHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_OptionalHolder_wrap_extern(pointer) } -@_expose(wasm, "bjs_TextProcessor_init") -@_cdecl("bjs_TextProcessor_init") -public func _bjs_TextProcessor_init(_ transform: Int32) -> UnsafeMutableRawPointer { +@_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 = TextProcessor(transform: _BJS_Closure_20BridgeJSRuntimeTestsSS_SS.bridgeJSLift(transform)) + let ret = OptionalPropertyHolder(optionalName: Optional.bridgeJSLiftParameter(optionalNameIsSome, optionalNameBytes, optionalNameLength)) 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 { +@_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 = TextProcessor.bridgeJSLiftParameter(_self).process(_: String.bridgeJSLiftParameter(textBytes, textLength)) + let ret = OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalName 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 { +@_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) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processWithCustom(_: String.bridgeJSLiftParameter(textBytes, textLength), customTransform: _BJS_Closure_20BridgeJSRuntimeTestsSiSSSd_SS.bridgeJSLift(customTransform)) - return ret.bridgeJSLowerReturn() + OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalName = Optional.bridgeJSLiftParameter(valueIsSome, valueBytes, valueLength) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TextProcessor_getTransform") -@_cdecl("bjs_TextProcessor_getTransform") -public func _bjs_TextProcessor_getTransform(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_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 = TextProcessor.bridgeJSLiftParameter(_self).getTransform() - return JSTypedClosure(ret).bridgeJSLowerReturn() + let ret = OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalAge + return 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 { +@_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) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalString(_: _BJS_Closure_20BridgeJSRuntimeTestsSqSS_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() + OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalAge = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) #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 { +@_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 = TextProcessor.bridgeJSLiftParameter(_self).processOptionalInt(_: _BJS_Closure_20BridgeJSRuntimeTestsSqSi_SS.bridgeJSLift(callback)) + let ret = OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalGreeter 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 { +@_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) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalGreeter(_: _BJS_Closure_20BridgeJSRuntimeTestsSq7GreeterC_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() + OptionalPropertyHolder.bridgeJSLiftParameter(_self).optionalGreeter = Optional.bridgeJSLiftParameter(valueIsSome, valueValue) #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TextProcessor_makeOptionalStringFormatter") -@_cdecl("bjs_TextProcessor_makeOptionalStringFormatter") -public func _bjs_TextProcessor_makeOptionalStringFormatter(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_OptionalPropertyHolder_deinit") +@_cdecl("bjs_OptionalPropertyHolder_deinit") +public func _bjs_OptionalPropertyHolder_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).makeOptionalStringFormatter() - return JSTypedClosure(ret).bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() #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 +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 +} +#endif +@inline(never) fileprivate func _bjs_OptionalPropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_OptionalPropertyHolder_wrap_extern(pointer) } -@_expose(wasm, "bjs_TextProcessor_processDirection") -@_cdecl("bjs_TextProcessor_processDirection") -public func _bjs_TextProcessor_processDirection(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { +@_expose(wasm, "bjs_Container_init") +@_cdecl("bjs_Container_init") +public func _bjs_Container_init() -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processDirection(_: _BJS_Closure_20BridgeJSRuntimeTests9DirectionO_SS.bridgeJSLift(callback)) + 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_TextProcessor_processTheme") -@_cdecl("bjs_TextProcessor_processTheme") -public func _bjs_TextProcessor_processTheme(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { +@_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 = TextProcessor.bridgeJSLiftParameter(_self).processTheme(_: _BJS_Closure_20BridgeJSRuntimeTests5ThemeO_SS.bridgeJSLift(callback)) + let ret = Container.bridgeJSLiftParameter(_self).location 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 { +@_expose(wasm, "bjs_Container_location_set") +@_cdecl("bjs_Container_location_set") +public func _bjs_Container_location_set(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processHttpStatus(_: _BJS_Closure_20BridgeJSRuntimeTests10HttpStatusO_Si.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() + Container.bridgeJSLiftParameter(_self).location = DataPoint.bridgeJSLiftParameter() #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 { +@_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 = TextProcessor.bridgeJSLiftParameter(_self).processAPIResult(_: _BJS_Closure_20BridgeJSRuntimeTests9APIResultO_SS.bridgeJSLift(callback)) + let ret = Container.bridgeJSLiftParameter(_self).config 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 { +@_expose(wasm, "bjs_Container_config_set") +@_cdecl("bjs_Container_config_set") +public func _bjs_Container_config_set(_ _self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).makeDirectionChecker() - return JSTypedClosure(ret).bridgeJSLowerReturn() + Container.bridgeJSLiftParameter(_self).config = Optional.bridgeJSLiftParameter() #else fatalError("Only available on WebAssembly") #endif } -@_expose(wasm, "bjs_TextProcessor_makeThemeValidator") -@_cdecl("bjs_TextProcessor_makeThemeValidator") -public func _bjs_TextProcessor_makeThemeValidator(_ _self: UnsafeMutableRawPointer) -> Int32 { +@_expose(wasm, "bjs_Container_deinit") +@_cdecl("bjs_Container_deinit") +public func _bjs_Container_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).makeThemeValidator() - return JSTypedClosure(ret).bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() #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 +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()) + } } -@_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 +#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 +} +#endif +@inline(never) fileprivate func _bjs_Container_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Container_wrap_extern(pointer) } -@_expose(wasm, "bjs_TextProcessor_processOptionalDirection") -@_cdecl("bjs_TextProcessor_processOptionalDirection") -public func _bjs_TextProcessor_processOptionalDirection(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { +@_expose(wasm, "bjs_LeakCheck_init") +@_cdecl("bjs_LeakCheck_init") +public func _bjs_LeakCheck_init() -> UnsafeMutableRawPointer { #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalDirection(_: _BJS_Closure_20BridgeJSRuntimeTestsSq9DirectionO_SS.bridgeJSLift(callback)) + let ret = LeakCheck() 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 { +@_expose(wasm, "bjs_LeakCheck_deinit") +@_cdecl("bjs_LeakCheck_deinit") +public func _bjs_LeakCheck_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalTheme(_: _BJS_Closure_20BridgeJSRuntimeTestsSq5ThemeO_SS.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() + Unmanaged.fromOpaque(pointer).release() #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 +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 +} +#endif +@inline(never) fileprivate func _bjs_LeakCheck_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_LeakCheck_wrap_extern(pointer) } -@_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 +@JSFunction func Promise_reject(_ promise: JSObject, _ value: JSValue) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_reject_BridgeJSRuntimeTests") +fileprivate func promise_reject_BridgeJSRuntimeTests_extern(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void +#else +fileprivate func promise_reject_BridgeJSRuntimeTests_extern(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_reject_BridgeJSRuntimeTests(_ promise: Int32, _ valueKind: Int32, _ valuePayload1: Int32, _ valuePayload2: Float64) -> Void { + return promise_reject_BridgeJSRuntimeTests_extern(promise, valueKind, valuePayload1, valuePayload2) } -@_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 +func _$Promise_reject(_ promise: JSObject, _ value: JSValue) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let (valueKind, valuePayload1, valuePayload2) = value.bridgeJSLowerParameter() + promise_reject_BridgeJSRuntimeTests(promiseValue, valueKind, valuePayload1, valuePayload2) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_SS(_ promise: JSObject, _ value: String) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_SS") +fileprivate func promise_resolve_BridgeJSRuntimeTests_SS_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_SS_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_SS(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_SS_extern(promise, valueBytes, valueLength) } -@_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 +func _$Promise_resolve_SS(_ promise: JSObject, _ value: String) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + value.bridgeJSWithLoweredParameter { (valueBytes, valueLength) in + promise_resolve_BridgeJSRuntimeTests_SS(promiseValue, valueBytes, valueLength) + } + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_y(_ promise: JSObject) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_y") +fileprivate func promise_resolve_BridgeJSRuntimeTests_y_extern(_ promise: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_y_extern(_ promise: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_y(_ promise: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_y_extern(promise) } -@_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 +func _$Promise_resolve_y(_ promise: JSObject) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_y(promiseValue) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_Si(_ promise: JSObject, _ value: Int) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Si") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Si_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Si_extern(_ promise: Int32, _ value: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Si(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Si_extern(promise, value) } -@_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 +func _$Promise_resolve_Si(_ promise: JSObject, _ value: Int) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueValue = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Si(promiseValue, valueValue) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_Sf(_ promise: JSObject, _ value: Float) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sf") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sf_extern(_ promise: Int32, _ value: Float32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sf_extern(_ promise: Int32, _ value: Float32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sf(_ promise: Int32, _ value: Float32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sf_extern(promise, value) } -@_expose(wasm, "bjs_TextProcessor_processVector") -@_cdecl("bjs_TextProcessor_processVector") -public func _bjs_TextProcessor_processVector(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Float64 { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processVector(_: _BJS_Closure_20BridgeJSRuntimeTestsSd_8Vector2DV.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else +func _$Promise_resolve_Sf(_ promise: JSObject, _ value: Float) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueValue = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sf(promiseValue, valueValue) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_Sd(_ promise: JSObject, _ value: Double) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sd") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sd_extern(_ promise: Int32, _ value: Float64) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sd_extern(_ promise: Int32, _ value: Float64) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sd(_ promise: Int32, _ value: Float64) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sd_extern(promise, value) } -@_expose(wasm, "bjs_TextProcessor_processOptionalVector") -@_cdecl("bjs_TextProcessor_processOptionalVector") -public func _bjs_TextProcessor_processOptionalVector(_ _self: UnsafeMutableRawPointer, _ callback: Int32) -> Void { - #if arch(wasm32) - let ret = TextProcessor.bridgeJSLiftParameter(_self).processOptionalVector(_: _BJS_Closure_20BridgeJSRuntimeTestsSd_Sq8Vector2DV.bridgeJSLift(callback)) - return ret.bridgeJSLowerReturn() - #else +func _$Promise_resolve_Sd(_ promise: JSObject, _ value: Double) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueValue = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sd(promiseValue, valueValue) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_Sb(_ promise: JSObject, _ value: Bool) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sb") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sb_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sb_extern(_ promise: Int32, _ value: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sb(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sb_extern(promise, value) +} + +func _$Promise_resolve_Sb(_ promise: JSObject, _ value: Bool) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueValue = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sb(promiseValue, valueValue) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_7GreeterC(_ promise: JSObject, _ value: Greeter) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_7GreeterC") +fileprivate func promise_resolve_BridgeJSRuntimeTests_7GreeterC_extern(_ promise: Int32, _ value: UnsafeMutableRawPointer) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_7GreeterC_extern(_ promise: Int32, _ value: UnsafeMutableRawPointer) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_7GreeterC(_ promise: Int32, _ value: UnsafeMutableRawPointer) -> Void { + return promise_resolve_BridgeJSRuntimeTests_7GreeterC_extern(promise, value) +} + +func _$Promise_resolve_7GreeterC(_ promise: JSObject, _ value: Greeter) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valuePointer = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_7GreeterC(promiseValue, valuePointer) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_8JSObjectC(_ promise: JSObject, _ value: JSObject) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_8JSObjectC") +fileprivate func promise_resolve_BridgeJSRuntimeTests_8JSObjectC_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_8JSObjectC_extern(_ promise: Int32, _ value: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_8JSObjectC(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_8JSObjectC_extern(promise, value) } -@_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 +func _$Promise_resolve_8JSObjectC(_ promise: JSObject, _ value: JSObject) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueValue = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_8JSObjectC(promiseValue, valueValue) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_5ThemeO(_ promise: JSObject, _ value: Theme) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_5ThemeO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_5ThemeO_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_5ThemeO_extern(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_5ThemeO(_ promise: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_5ThemeO_extern(promise, valueBytes, valueLength) } -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()) +func _$Promise_resolve_5ThemeO(_ promise: JSObject, _ value: Theme) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + value.bridgeJSWithLoweredParameter { (valueBytes, valueLength) in + promise_resolve_BridgeJSRuntimeTests_5ThemeO(promiseValue, valueBytes, valueLength) } + if let error = _swift_js_take_exception() { throw error } } +@JSFunction func Promise_resolve_9DirectionO(_ promise: JSObject, _ value: Direction) throws(JSException) + #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_TextProcessor_wrap") -fileprivate func _bjs_TextProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_9DirectionO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_9DirectionO_extern(_ promise: Int32, _ value: Int32) -> Void #else -fileprivate func _bjs_TextProcessor_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func promise_resolve_BridgeJSRuntimeTests_9DirectionO_extern(_ promise: Int32, _ value: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_TextProcessor_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_TextProcessor_wrap_extern(pointer) +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_9DirectionO(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_9DirectionO_extern(promise, value) } -@_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 +func _$Promise_resolve_9DirectionO(_ promise: JSObject, _ value: Direction) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueValue = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_9DirectionO(promiseValue, valueValue) + if let error = _swift_js_take_exception() { throw error } } -@_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 +@JSFunction func Promise_resolve_Sq5ThemeO(_ promise: JSObject, _ value: Optional) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO(_ promise: Int32, _ valueIsSome: Int32, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO_extern(promise, valueIsSome, valueBytes, valueLength) } -@_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 +func _$Promise_resolve_Sq5ThemeO(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + value.bridgeJSWithLoweredParameter { (valueIsSome, valueBytes, valueLength) in + promise_resolve_BridgeJSRuntimeTests_Sq5ThemeO(promiseValue, valueIsSome, valueBytes, valueLength) + } + if let error = _swift_js_take_exception() { throw error } } -@_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 +@JSFunction func Promise_resolve_Sq9DirectionO(_ promise: JSObject, _ value: Optional) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO_extern(promise, valueIsSome, valueValue) } -@_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 +func _$Promise_resolve_Sq9DirectionO(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let (valueIsSome, valueValue) = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sq9DirectionO(promiseValue, valueIsSome, valueValue) + if let error = _swift_js_take_exception() { throw error } } -@_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 +@JSFunction func Promise_resolve_Sa9DirectionO(_ promise: JSObject, _ value: [Direction]) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO_extern(_ promise: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO_extern(_ promise: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO(_ promise: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO_extern(promise) } -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()) - } +func _$Promise_resolve_Sa9DirectionO(_ promise: JSObject, _ value: [Direction]) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let _ = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sa9DirectionO(promiseValue) + if let error = _swift_js_take_exception() { throw error } } +@JSFunction func Promise_resolve_SD9DirectionO(_ promise: JSObject, _ value: [String: Direction]) throws(JSException) + #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalHolder_wrap") -fileprivate func _bjs_OptionalHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_SD9DirectionO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_SD9DirectionO_extern(_ promise: Int32) -> Void #else -fileprivate func _bjs_OptionalHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func promise_resolve_BridgeJSRuntimeTests_SD9DirectionO_extern(_ promise: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_OptionalHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_OptionalHolder_wrap_extern(pointer) +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_SD9DirectionO(_ promise: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_SD9DirectionO_extern(promise) } -@_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 +func _$Promise_resolve_SD9DirectionO(_ promise: JSObject, _ value: [String: Direction]) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let _ = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_SD9DirectionO(promiseValue) + if let error = _swift_js_take_exception() { throw error } } -@_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 +@JSFunction func Promise_resolve_Sa5ThemeO(_ promise: JSObject, _ value: [Theme]) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO_extern(_ promise: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO_extern(_ promise: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO(_ promise: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO_extern(promise) } -@_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 +func _$Promise_resolve_Sa5ThemeO(_ promise: JSObject, _ value: [Theme]) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let _ = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sa5ThemeO(promiseValue) + if let error = _swift_js_take_exception() { throw error } } -@_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 +@JSFunction func Promise_resolve_SD5ThemeO(_ promise: JSObject, _ value: [String: Theme]) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_SD5ThemeO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_SD5ThemeO_extern(_ promise: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_SD5ThemeO_extern(_ promise: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_SD5ThemeO(_ promise: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_SD5ThemeO_extern(promise) } -@_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 +func _$Promise_resolve_SD5ThemeO(_ promise: JSObject, _ value: [String: Theme]) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let _ = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_SD5ThemeO(promiseValue) + if let error = _swift_js_take_exception() { throw error } } -@_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 +@JSFunction func Promise_resolve_8FileSizeO(_ promise: JSObject, _ value: FileSize) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_8FileSizeO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_8FileSizeO_extern(_ promise: Int32, _ value: Int64) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_8FileSizeO_extern(_ promise: Int32, _ value: Int64) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_8FileSizeO(_ promise: Int32, _ value: Int64) -> Void { + return promise_resolve_BridgeJSRuntimeTests_8FileSizeO_extern(promise, value) } -@_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 +func _$Promise_resolve_8FileSizeO(_ promise: JSObject, _ value: FileSize) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueValue = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_8FileSizeO(promiseValue, valueValue) + if let error = _swift_js_take_exception() { throw error } } -@_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 +@JSFunction func Promise_resolve_Sq8FileSizeO(_ promise: JSObject, _ value: Optional) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int64) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int64) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO(_ promise: Int32, _ valueIsSome: Int32, _ valueValue: Int64) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO_extern(promise, valueIsSome, valueValue) } -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()) - } +func _$Promise_resolve_Sq8FileSizeO(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let (valueIsSome, valueValue) = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sq8FileSizeO(promiseValue, valueIsSome, valueValue) + if let error = _swift_js_take_exception() { throw error } } +@JSFunction func Promise_resolve_18AsyncPayloadResultO(_ promise: JSObject, _ value: AsyncPayloadResult) throws(JSException) + #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalPropertyHolder_wrap") -fileprivate func _bjs_OptionalPropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO_extern(_ promise: Int32, _ value: Int32) -> Void #else -fileprivate func _bjs_OptionalPropertyHolder_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO_extern(_ promise: Int32, _ value: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_OptionalPropertyHolder_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_OptionalPropertyHolder_wrap_extern(pointer) +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO_extern(promise, value) } -@_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 +func _$Promise_resolve_18AsyncPayloadResultO(_ promise: JSObject, _ value: AsyncPayloadResult) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueCaseId = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_18AsyncPayloadResultO(promiseValue, valueCaseId) + if let error = _swift_js_take_exception() { throw error } } -@_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 +@JSFunction func Promise_resolve_Sq18AsyncPayloadResultO(_ promise: JSObject, _ value: Optional) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO_extern(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO(_ promise: Int32, _ valueIsSome: Int32, _ valueCaseId: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO_extern(promise, valueIsSome, valueCaseId) } -@_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 +func _$Promise_resolve_Sq18AsyncPayloadResultO(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let (valueIsSome, valueCaseId) = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sq18AsyncPayloadResultO(promiseValue, valueIsSome, valueCaseId) + if let error = _swift_js_take_exception() { throw error } } -@_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 +@JSFunction func Promise_resolve_11PublicPointV(_ promise: JSObject, _ value: PublicPoint) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_11PublicPointV") +fileprivate func promise_resolve_BridgeJSRuntimeTests_11PublicPointV_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_11PublicPointV_extern(_ promise: Int32, _ value: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_11PublicPointV(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_11PublicPointV_extern(promise, value) } -@_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 +func _$Promise_resolve_11PublicPointV(_ promise: JSObject, _ value: PublicPoint) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueObjectId = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_11PublicPointV(promiseValue, valueObjectId) + if let error = _swift_js_take_exception() { throw error } } -@_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 +@JSFunction func Promise_resolve_7ContactV(_ promise: JSObject, _ value: Contact) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_7ContactV") +fileprivate func promise_resolve_BridgeJSRuntimeTests_7ContactV_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_7ContactV_extern(_ promise: Int32, _ value: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_7ContactV(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_7ContactV_extern(promise, value) } -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()) - } +func _$Promise_resolve_7ContactV(_ promise: JSObject, _ value: Contact) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueObjectId = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_7ContactV(promiseValue, valueObjectId) + if let error = _swift_js_take_exception() { throw error } } +@JSFunction func Promise_resolve_Sa11PublicPointV(_ promise: JSObject, _ value: [PublicPoint]) throws(JSException) + #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Container_wrap") -fileprivate func _bjs_Container_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV_extern(_ promise: Int32) -> Void #else -fileprivate func _bjs_Container_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV_extern(_ promise: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_Container_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_Container_wrap_extern(pointer) +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV(_ promise: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV_extern(promise) } -@_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 +func _$Promise_resolve_Sa11PublicPointV(_ promise: JSObject, _ value: [PublicPoint]) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let _ = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sa11PublicPointV(promiseValue) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_Sq11PublicPointV(_ promise: JSObject, _ value: Optional) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV") +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV_extern(_ promise: Int32, _ value: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV_extern(_ promise: Int32, _ value: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV_extern(promise, value) } -@_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 +func _$Promise_resolve_Sq11PublicPointV(_ promise: JSObject, _ value: Optional) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueIsSome = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_Sq11PublicPointV(promiseValue, valueIsSome) + if let error = _swift_js_take_exception() { throw error } +} + +@JSFunction func Promise_resolve_SD11PublicPointV(_ promise: JSObject, _ value: [String: PublicPoint]) throws(JSException) + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV") +fileprivate func promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV_extern(_ promise: Int32) -> Void +#else +fileprivate func promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV_extern(_ promise: Int32) -> Void { fatalError("Only available on WebAssembly") - #endif +} +#endif +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV(_ promise: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV_extern(promise) } -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()) - } +func _$Promise_resolve_SD11PublicPointV(_ promise: JSObject, _ value: [String: PublicPoint]) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let _ = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_SD11PublicPointV(promiseValue) + if let error = _swift_js_take_exception() { throw error } } +@JSFunction func Promise_resolve_9DataPointV(_ promise: JSObject, _ value: DataPoint) throws(JSException) + #if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_LeakCheck_wrap") -fileprivate func _bjs_LeakCheck_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +@_extern(wasm, module: "bjs", name: "promise_resolve_BridgeJSRuntimeTests_9DataPointV") +fileprivate func promise_resolve_BridgeJSRuntimeTests_9DataPointV_extern(_ promise: Int32, _ value: Int32) -> Void #else -fileprivate func _bjs_LeakCheck_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { +fileprivate func promise_resolve_BridgeJSRuntimeTests_9DataPointV_extern(_ promise: Int32, _ value: Int32) -> Void { fatalError("Only available on WebAssembly") } #endif -@inline(never) fileprivate func _bjs_LeakCheck_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { - return _bjs_LeakCheck_wrap_extern(pointer) +@inline(never) fileprivate func promise_resolve_BridgeJSRuntimeTests_9DataPointV(_ promise: Int32, _ value: Int32) -> Void { + return promise_resolve_BridgeJSRuntimeTests_9DataPointV_extern(promise, value) +} + +func _$Promise_resolve_9DataPointV(_ promise: JSObject, _ value: DataPoint) throws(JSException) -> Void { + let promiseValue = promise.bridgeJSLowerParameter() + let valueObjectId = value.bridgeJSLowerParameter() + promise_resolve_BridgeJSRuntimeTests_9DataPointV(promiseValue, valueObjectId) + if let error = _swift_js_take_exception() { throw error } } +extension Polygon: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +extension Tag: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +extension TagHolder: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +extension Coordinate: _BridgedSwiftAlias, _BridgedSwiftStruct {} + +extension Priority: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +extension Alert: _BridgedSwiftAlias, _BridgedSwiftCaseEnum {} + +extension UserId: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +extension Tagged: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +extension Canvas: _BridgedSwiftAlias, _BridgedSwiftStackType {} + +extension AliasedTag: _BridgedSwiftAlias, _BridgedSwiftAssociatedValueEnum {} + +extension Boxed: _BridgedSwiftAlias, _BridgedSwiftStackType {} + #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_Surface_init") fileprivate func bjs_Surface_init_extern(_ labelBytes: Int32, _ labelLength: Int32) -> Int32 @@ -12134,8 +13907,32 @@ fileprivate func bjs_AliasImports_jsRoundTripCoordinate_static_extern(_ value: I return bjs_AliasImports_jsRoundTripCoordinate_static_extern(value) } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AliasImports_jsRoundTripUserId_static") +fileprivate func bjs_AliasImports_jsRoundTripUserId_static_extern(_ value: Int32) -> Int32 +#else +fileprivate func bjs_AliasImports_jsRoundTripUserId_static_extern(_ value: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AliasImports_jsRoundTripUserId_static(_ value: Int32) -> Int32 { + return bjs_AliasImports_jsRoundTripUserId_static_extern(value) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AliasImports_jsRoundTripOptionalUserId_static") +fileprivate func bjs_AliasImports_jsRoundTripOptionalUserId_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void +#else +fileprivate func bjs_AliasImports_jsRoundTripOptionalUserId_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AliasImports_jsRoundTripOptionalUserId_static(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { + return bjs_AliasImports_jsRoundTripOptionalUserId_static_extern(valueIsSome, valueValue) +} + func _$AliasImports_jsRoundTripTagged(_ value: Tagged) throws(JSException) -> Tagged { - let ret0 = value.bridgeToJS().bridgeJSWithLoweredParameter { (valueBytes, valueLength) in + let ret0 = value.bridgeJSWithLoweredParameter { (valueBytes, valueLength) in let ret = bjs_AliasImports_jsRoundTripTagged_static(valueBytes, valueLength) return ret } @@ -12143,21 +13940,17 @@ func _$AliasImports_jsRoundTripTagged(_ value: Tagged) throws(JSException) -> Ta if let error = _swift_js_take_exception() { throw error } - return Tagged.bridgeFromJS(String.bridgeJSLiftReturn(ret)) + return Tagged.bridgeJSLiftReturn(ret) } func _$AliasImports_jsRoundTripOptionalTagged(_ value: Optional) throws(JSException) -> Optional { - value.map { - $0.bridgeToJS() - } .bridgeJSWithLoweredParameter { (valueIsSome, valueBytes, valueLength) in + value.bridgeJSWithLoweredParameter { (valueIsSome, valueBytes, valueLength) in bjs_AliasImports_jsRoundTripOptionalTagged_static(valueIsSome, valueBytes, valueLength) } if let error = _swift_js_take_exception() { throw error } - return Optional.bridgeJSLiftReturnFromSideChannel().map { - Tagged.bridgeFromJS($0) - } + return Optional.bridgeJSLiftReturnFromSideChannel() } func _$AliasImports_jsProduceOptionalCanvas(_ label: Optional) throws(JSException) -> Optional { @@ -12167,44 +13960,52 @@ func _$AliasImports_jsProduceOptionalCanvas(_ label: Optional) throws(JS if let error = _swift_js_take_exception() { throw error } - return Optional.bridgeJSLiftReturn().map { - Canvas.bridgeFromJS($0) - } + return Optional.bridgeJSLiftReturn() } func _$AliasImports_jsRoundTripAliasedTags(_ values: [Optional]) throws(JSException) -> [Optional] { - let _ = values.map { - $0.map { - $0.bridgeToJS() - } - } .bridgeJSLowerParameter() + let _ = values.bridgeJSLowerParameter() bjs_AliasImports_jsRoundTripAliasedTags_static() if let error = _swift_js_take_exception() { throw error } - return [Optional].bridgeJSLiftReturn().map { - $0.map { - AliasedTag.bridgeFromJS($0) - } - } + return [Optional].bridgeJSLiftReturn() } func _$AliasImports_jsRoundTripPolygon(_ value: Polygon) throws(JSException) -> Polygon { - let valuePointer = value.bridgeToJS().bridgeJSLowerParameter() + let valuePointer = value.bridgeJSLowerParameter() let ret = bjs_AliasImports_jsRoundTripPolygon_static(valuePointer) if let error = _swift_js_take_exception() { throw error } - return Polygon.bridgeFromJS(PolygonReference.bridgeJSLiftReturn(ret)) + return Polygon.bridgeJSLiftReturn(ret) } func _$AliasImports_jsRoundTripCoordinate(_ value: Coordinate) throws(JSException) -> Coordinate { - let valueObjectId = value.bridgeToJS().bridgeJSLowerParameter() + let valueObjectId = value.bridgeJSLowerParameter() let ret = bjs_AliasImports_jsRoundTripCoordinate_static(valueObjectId) if let error = _swift_js_take_exception() { throw error } - return Coordinate.bridgeFromJS(JSCoordinate.bridgeJSLiftReturn(ret)) + return Coordinate.bridgeJSLiftReturn(ret) +} + +func _$AliasImports_jsRoundTripUserId(_ value: UserId) throws(JSException) -> UserId { + let valueValue = value.bridgeJSLowerParameter() + let ret = bjs_AliasImports_jsRoundTripUserId_static(valueValue) + if let error = _swift_js_take_exception() { + throw error + } + return UserId.bridgeJSLiftReturn(ret) +} + +func _$AliasImports_jsRoundTripOptionalUserId(_ value: Optional) throws(JSException) -> Optional { + let (valueIsSome, valueValue) = value.bridgeJSLowerParameter() + bjs_AliasImports_jsRoundTripOptionalUserId_static(valueIsSome, valueValue) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturnFromSideChannel() } #if arch(wasm32) @@ -12726,6 +14527,30 @@ fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_exter return bjs_AsyncImportImports_jsAsyncRoundTripFeatureFlag_static_extern(resolveRef, rejectRef, vBytes, vLength) } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static(_ resolveRef: Int32, _ rejectRef: Int32, _ v: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static_extern(resolveRef, rejectRef, v) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static") +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vCaseId: Int32) -> Void +#else +fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vCaseId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static(_ resolveRef: Int32, _ rejectRef: Int32, _ vIsSome: Int32, _ vCaseId: Int32) -> Void { + return bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static_extern(resolveRef, rejectRef, vIsSome, vCaseId) +} + func _$AsyncImportImports_jsAsyncRoundTripVoid() async throws(JSException) -> Void { try await _bjs_awaitPromise(makeResolveClosure: { JSTypedClosure<() -> Void>($0) @@ -12847,6 +14672,52 @@ func _$AsyncImportImports_jsAsyncRoundTripFeatureFlag(_ v: FeatureFlag) async th return resolved } +func _$AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum(_ v: AsyncImportedPayloadResult) async throws(JSException) -> AsyncImportedPayloadResult { + let resolved = try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<(sending AsyncImportedPayloadResult) -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + let vCaseId = v.bridgeJSLowerParameter() + bjs_AsyncImportImports_jsAsyncRoundTripAssociatedValueEnum_static(resolveRef, rejectRef, vCaseId) + } + return resolved +} + +func _$AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum(_ 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, vCaseId) = v.bridgeJSLowerParameter() + bjs_AsyncImportImports_jsAsyncRoundTripOptionalAssociatedValueEnum_static(resolveRef, rejectRef, vIsSome, vCaseId) + } + return resolved +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureAsyncImports_runJsClosureAsyncTests_static") +fileprivate func bjs_ClosureAsyncImports_runJsClosureAsyncTests_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void +#else +fileprivate func bjs_ClosureAsyncImports_runJsClosureAsyncTests_static_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureAsyncImports_runJsClosureAsyncTests_static(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { + return bjs_ClosureAsyncImports_runJsClosureAsyncTests_static_extern(resolveRef, rejectRef) +} + +func _$ClosureAsyncImports_runJsClosureAsyncTests() async throws(JSException) -> Void { + try await _bjs_awaitPromise(makeResolveClosure: { + JSTypedClosure<() -> Void>($0) + }, makeRejectClosure: { + JSTypedClosure<(sending JSValue) -> Void>($0) + }) { resolveRef, rejectRef in + bjs_ClosureAsyncImports_runJsClosureAsyncTests_static(resolveRef, rejectRef) + } +} + #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureSupportImports_jsApplyVoid_static") fileprivate func bjs_ClosureSupportImports_jsApplyVoid_static_extern(_ callback: Int32) -> Void @@ -13229,6 +15100,25 @@ func _$ClosureSupportImports_runJsClosureSupportTests() throws(JSException) -> V } } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_ClosureThrowsImports_runJsClosureThrowsTests_static") +fileprivate func bjs_ClosureThrowsImports_runJsClosureThrowsTests_static_extern() -> Void +#else +fileprivate func bjs_ClosureThrowsImports_runJsClosureThrowsTests_static_extern() -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_ClosureThrowsImports_runJsClosureThrowsTests_static() -> Void { + return bjs_ClosureThrowsImports_runJsClosureThrowsTests_static_extern() +} + +func _$ClosureThrowsImports_runJsClosureThrowsTests() throws(JSException) -> Void { + bjs_ClosureThrowsImports_runJsClosureThrowsTests_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 @@ -13674,28 +15564,6 @@ func _$runAsyncWorks() async throws(JSException) -> Void { } } -#if arch(wasm32) -@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_runAliasAsyncWorks") -fileprivate func bjs_runAliasAsyncWorks_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void -#else -fileprivate func bjs_runAliasAsyncWorks_extern(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - fatalError("Only available on WebAssembly") -} -#endif -@inline(never) fileprivate func bjs_runAliasAsyncWorks(_ resolveRef: Int32, _ rejectRef: Int32) -> Void { - return bjs_runAliasAsyncWorks_extern(resolveRef, rejectRef) -} - -func _$runAliasAsyncWorks() async throws(JSException) -> Void { - try await _bjs_awaitPromise(makeResolveClosure: { - JSTypedClosure<() -> Void>($0) - }, makeRejectClosure: { - JSTypedClosure<(sending JSValue) -> Void>($0) - }) { resolveRef, rejectRef in - bjs_runAliasAsyncWorks(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 @@ -14385,6 +16253,69 @@ func _$Animal_getIsCat(_ self: JSObject) throws(JSException) -> Bool { return Bool.bridgeJSLiftReturn(ret) } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripLightColor") +fileprivate func bjs_jsRoundTripLightColor_extern(_ value: Int32) -> Int32 +#else +fileprivate func bjs_jsRoundTripLightColor_extern(_ value: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripLightColor(_ value: Int32) -> Int32 { + return bjs_jsRoundTripLightColor_extern(value) +} + +func _$jsRoundTripLightColor(_ value: LightColor) throws(JSException) -> LightColor { + let valueValue = value.bridgeJSLowerParameter() + let ret = bjs_jsRoundTripLightColor(valueValue) + if let error = _swift_js_take_exception() { + throw error + } + return LightColor.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripImportedPayloadSignal") +fileprivate func bjs_jsRoundTripImportedPayloadSignal_extern(_ value: Int32) -> Int32 +#else +fileprivate func bjs_jsRoundTripImportedPayloadSignal_extern(_ value: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripImportedPayloadSignal(_ value: Int32) -> Int32 { + return bjs_jsRoundTripImportedPayloadSignal_extern(value) +} + +func _$jsRoundTripImportedPayloadSignal(_ value: ImportedPayloadSignal) throws(JSException) -> ImportedPayloadSignal { + let valueCaseId = value.bridgeJSLowerParameter() + let ret = bjs_jsRoundTripImportedPayloadSignal(valueCaseId) + if let error = _swift_js_take_exception() { + throw error + } + return ImportedPayloadSignal.bridgeJSLiftReturn(ret) +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripOptionalImportedPayloadSignal") +fileprivate func bjs_jsRoundTripOptionalImportedPayloadSignal_extern(_ valueIsSome: Int32, _ valueCaseId: Int32) -> Int32 +#else +fileprivate func bjs_jsRoundTripOptionalImportedPayloadSignal_extern(_ valueIsSome: Int32, _ valueCaseId: Int32) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripOptionalImportedPayloadSignal(_ valueIsSome: Int32, _ valueCaseId: Int32) -> Int32 { + return bjs_jsRoundTripOptionalImportedPayloadSignal_extern(valueIsSome, valueCaseId) +} + +func _$jsRoundTripOptionalImportedPayloadSignal(_ value: Optional) throws(JSException) -> Optional { + let (valueIsSome, valueCaseId) = value.bridgeJSLowerParameter() + let ret = bjs_jsRoundTripOptionalImportedPayloadSignal(valueIsSome, valueCaseId) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn(ret) +} + #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsTranslatePoint") fileprivate func bjs_jsTranslatePoint_extern(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 @@ -14408,6 +16339,27 @@ func _$jsTranslatePoint(_ point: Point, _ dx: Int, _ dy: Int) throws(JSException return Point.bridgeJSLiftReturn(ret) } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_jsRoundTripOptionalPoint") +fileprivate func bjs_jsRoundTripOptionalPoint_extern(_ point: Int32) -> Void +#else +fileprivate func bjs_jsRoundTripOptionalPoint_extern(_ point: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_jsRoundTripOptionalPoint(_ point: Int32) -> Void { + return bjs_jsRoundTripOptionalPoint_extern(point) +} + +func _$jsRoundTripOptionalPoint(_ point: Optional) throws(JSException) -> Optional { + let pointIsSome = point.bridgeJSLowerParameter() + bjs_jsRoundTripOptionalPoint(pointIsSome) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn() +} + #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_IntegerTypesSupportImports_jsRoundTripInt_static") fileprivate func bjs_IntegerTypesSupportImports_jsRoundTripInt_static_extern(_ v: Int32) -> Int32 @@ -15205,6 +17157,18 @@ fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDic return bjs_OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefined_static_extern(v) } +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static") +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void +#else +fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static_extern(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static(_ valueIsSome: Int32, _ valueValue: Int32) -> Void { + return bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static_extern(valueIsSome, valueValue) +} + #if arch(wasm32) @_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_OptionalSupportImports_runJsOptionalSupportTests_static") fileprivate func bjs_OptionalSupportImports_runJsOptionalSupportTests_static_extern() -> Void @@ -15291,6 +17255,15 @@ func _$OptionalSupportImports_jsRoundTripOptionalStringToStringDictionaryUndefin return JSUndefinedOr<[String: String]>.bridgeJSLiftReturn() } +func _$OptionalSupportImports_jsRoundTripOptionalJSObjectNull(_ value: Optional) throws(JSException) -> Optional { + let (valueIsSome, valueValue) = value.bridgeJSLowerParameter() + bjs_OptionalSupportImports_jsRoundTripOptionalJSObjectNull_static(valueIsSome, valueValue) + if let error = _swift_js_take_exception() { + throw error + } + return Optional.bridgeJSLiftReturn() +} + func _$OptionalSupportImports_runJsOptionalSupportTests() throws(JSException) -> Void { bjs_OptionalSupportImports_runJsOptionalSupportTests_static() if let error = _swift_js_take_exception() { diff --git a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json index fb6286e97..25fd27d9f 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json @@ -17,14 +17,6 @@ } } }, - { - "swiftCallName" : "Token", - "underlying" : { - "swiftHeapObject" : { - "_0" : "TokenReference" - } - } - }, { "swiftCallName" : "TagHolder", "underlying" : { @@ -58,10 +50,13 @@ } }, { - "swiftCallName" : "Session", + "swiftCallName" : "UserId", "underlying" : { - "swiftStruct" : { - "_0" : "SessionState" + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, @@ -88,6 +83,14 @@ "_0" : "InnerTag" } } + }, + { + "swiftCallName" : "Boxed", + "underlying" : { + "jsValue" : { + + } + } } ], "classes" : [ @@ -287,57 +290,6 @@ ], "swiftCallName" : "TagReference" }, - { - "constructor" : { - "abiName" : "bjs_TokenReference_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "value", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ] - }, - "methods" : [ - { - "abiName" : "bjs_TokenReference_read", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "read", - "parameters" : [ - - ], - "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "name" : "TokenReference", - "properties" : [ - - ], - "swiftCallName" : "TokenReference" - }, { "constructor" : { "abiName" : "bjs_TagHolderReference_init", @@ -1461,6 +1413,46 @@ } } } + }, + { + "abiName" : "bjs_Calculator_asyncMakePoint", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncMakePoint", + "parameters" : [ + { + "label" : "x", + "name" : "x", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "y", + "name" : "y", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } } ], "name" : "Calculator", @@ -7167,6 +7159,53 @@ "swiftCallName" : "ArraySupportExports", "tsFullPath" : "ArraySupportExports" }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + + ], + "name" : "idle" + } + ], + "emitStyle" : "const", + "name" : "AsyncImportedPayloadResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "AsyncImportedPayloadResult", + "tsFullPath" : "AsyncImportedPayloadResult" + }, { "cases" : [ @@ -8332,6 +8371,53 @@ "swiftCallName" : "TSTheme", "tsFullPath" : "TSTheme" }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "success" + }, + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "failure" + }, + { + "associatedValues" : [ + + ], + "name" : "idle" + } + ], + "emitStyle" : "const", + "name" : "AsyncPayloadResult", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "AsyncPayloadResult", + "tsFullPath" : "AsyncPayloadResult" + }, { "cases" : [ @@ -9911,6 +9997,85 @@ "swiftCallName" : "NestedStructGroupB", "tsFullPath" : "NestedStructGroupB" }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "red" + }, + { + "associatedValues" : [ + + ], + "name" : "yellow" + }, + { + "associatedValues" : [ + + ], + "name" : "green" + } + ], + "emitStyle" : "const", + "name" : "LightColor", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "LightColor", + "tsFullPath" : "LightColor" + }, + { + "cases" : [ + { + "associatedValues" : [ + { + "type" : { + "string" : { + + } + } + } + ], + "name" : "start" + }, + { + "associatedValues" : [ + { + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "name" : "stop" + }, + { + "associatedValues" : [ + + ], + "name" : "idle" + } + ], + "emitStyle" : "const", + "name" : "ImportedPayloadSignal", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "ImportedPayloadSignal", + "tsFullPath" : "ImportedPayloadSignal" + }, { "cases" : [ @@ -12392,81 +12557,13 @@ } }, { - "abiName" : "bjs_incrementToken", + "abiName" : "bjs_makePolygonInspector", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "incrementToken", - "parameters" : [ - { - "label" : "_", - "name" : "token", - "type" : { - "alias" : { - "name" : "Token", - "underlying" : { - "swiftHeapObject" : { - "_0" : "TokenReference" - } - } - } - } - } - ], - "returnType" : { - "alias" : { - "name" : "Token", - "underlying" : { - "swiftHeapObject" : { - "_0" : "TokenReference" - } - } - } - } - }, - { - "abiName" : "bjs_makeToken", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeToken", - "parameters" : [ - { - "label" : "_", - "name" : "value", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - ], - "returnType" : { - "alias" : { - "name" : "Token", - "underlying" : { - "swiftHeapObject" : { - "_0" : "TokenReference" - } - } - } - } - }, - { - "abiName" : "bjs_makePolygonInspector", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makePolygonInspector", + "name" : "makePolygonInspector", "parameters" : [ ], @@ -12503,36 +12600,6 @@ } } }, - { - "abiName" : "bjs_asyncMakePolygon", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : false - }, - "name" : "asyncMakePolygon", - "parameters" : [ - { - "label" : "_", - "name" : "label", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "alias" : { - "name" : "Polygon", - "underlying" : { - "swiftHeapObject" : { - "_0" : "PolygonReference" - } - } - } - } - }, { "abiName" : "bjs_roundTripOptionalPolygonArray", "effects" : { @@ -12763,71 +12830,6 @@ } } }, - { - "abiName" : "bjs_roundTripSession", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "roundTripSession", - "parameters" : [ - { - "label" : "_", - "name" : "session", - "type" : { - "alias" : { - "name" : "Session", - "underlying" : { - "swiftStruct" : { - "_0" : "SessionState" - } - } - } - } - } - ], - "returnType" : { - "alias" : { - "name" : "Session", - "underlying" : { - "swiftStruct" : { - "_0" : "SessionState" - } - } - } - } - }, - { - "abiName" : "bjs_makeSession", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "makeSession", - "parameters" : [ - { - "label" : "_", - "name" : "token", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "alias" : { - "name" : "Session", - "underlying" : { - "swiftStruct" : { - "_0" : "SessionState" - } - } - } - } - }, { "abiName" : "bjs_roundTripShape", "effects" : { @@ -12901,314 +12903,1295 @@ } }, { - "abiName" : "bjs_roundTripVoid", + "abiName" : "bjs_roundTripUserId", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripVoid", + "name" : "roundTripUserId", "parameters" : [ - + { + "label" : "_", + "name" : "id", + "type" : { + "alias" : { + "name" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } ], "returnType" : { - "void" : { - + "alias" : { + "name" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } } } }, { - "abiName" : "bjs_roundTripFloat", + "abiName" : "bjs_roundTripOptionalUserId", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripFloat", + "name" : "roundTripOptionalUserId", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "id", "type" : { - "float" : { - + "nullable" : { + "_0" : { + "alias" : { + "name" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" } } } ], "returnType" : { - "float" : { - + "nullable" : { + "_0" : { + "alias" : { + "name" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_roundTripDouble", + "abiName" : "bjs_roundTripUserIdArray", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripDouble", + "name" : "roundTripUserIdArray", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "ids", "type" : { - "double" : { - + "array" : { + "_0" : { + "alias" : { + "name" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } } } } ], "returnType" : { - "double" : { - + "array" : { + "_0" : { + "alias" : { + "name" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } } } }, { - "abiName" : "bjs_roundTripBool", + "abiName" : "bjs_roundTripBoxed", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripBool", + "name" : "roundTripBoxed", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "boxed", "type" : { - "bool" : { + "alias" : { + "name" : "Boxed", + "underlying" : { + "jsValue" : { + } + } } } } ], "returnType" : { - "bool" : { - - } + "alias" : { + "name" : "Boxed", + "underlying" : { + "jsValue" : { + + } + } + } + } + }, + { + "abiName" : "bjs_roundTripOptionalBoxed", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalBoxed", + "parameters" : [ + { + "label" : "_", + "name" : "boxed", + "type" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Boxed", + "underlying" : { + "jsValue" : { + + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "Boxed", + "underlying" : { + "jsValue" : { + + } + } + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_awaitAsyncCallback", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "awaitAsyncCallback", + "parameters" : [ + { + "label" : "_", + "name" : "fetch", + "type" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsYaKSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_makeAsyncParser", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAsyncParser", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsYaKSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_makeAsyncEcho", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAsyncEcho", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsYaSS_SS", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "string" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_makeAsyncRecorder", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAsyncRecorder", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsYaKSS_y", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "void" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_lastRecordedValue", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "lastRecordedValue", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_makeAsyncPayloadLoader", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAsyncPayloadLoader", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "bool" : { + + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_awaitPayloadCallback", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "awaitPayloadCallback", + "parameters" : [ + { + "label" : "_", + "name" : "load", + "type" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsYaKSb_18AsyncPayloadResultO", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "bool" : { + + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "string" : { + + } + } + }, + { + "abiName" : "bjs_makeAsyncPointMaker", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeAsyncPointMaker", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : true, + "isThrows" : false, + "mangleName" : "20BridgeJSRuntimeTestsYaSd_9DataPointV", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "double" : { + + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "DataPoint" + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_makeThrowingParser", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "makeThrowingParser", + "parameters" : [ + + ], + "returnType" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsKSS_Si", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : true + } + } + }, + { + "abiName" : "bjs_runValidator", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runValidator", + "parameters" : [ + { + "label" : "_", + "name" : "validate", + "type" : { + "closure" : { + "_0" : { + "isAsync" : false, + "isThrows" : true, + "mangleName" : "20BridgeJSRuntimeTestsKSS_Sb", + "moduleName" : "BridgeJSRuntimeTests", + "parameters" : [ + { + "string" : { + + } + } + ], + "returnType" : { + "bool" : { + + } + }, + "sendingParameters" : false + }, + "useJSTypedClosure" : false + } + } + } + ], + "returnType" : { + "bool" : { + + } + } + }, + { + "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_roundTripString", + "abiName" : "bjs_roundTripOptionalDictionaryExport", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripString", + "name" : "roundTripOptionalDictionaryExport", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "string" : { + "nullable" : { + "_0" : { + "dictionary" : { + "_0" : { + "string" : { + } + } + } + }, + "_1" : "null" } } } ], "returnType" : { - "string" : { + "nullable" : { + "_0" : { + "dictionary" : { + "_0" : { + "string" : { + } + } + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_roundTripSwiftHeapObject", + "abiName" : "bjs_roundTripJSValue", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripSwiftHeapObject", + "name" : "roundTripJSValue", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "jsValue" : { + } } } ], "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "jsValue" : { + } } }, { - "abiName" : "bjs_roundTripUnsafeRawPointer", + "abiName" : "bjs_roundTripOptionalJSValue", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripUnsafeRawPointer", + "name" : "roundTripOptionalJSValue", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "unsafePointer" : { + "nullable" : { "_0" : { - "kind" : "unsafeRawPointer" - } + "jsValue" : { + + } + }, + "_1" : "null" } } } ], "returnType" : { - "unsafePointer" : { + "nullable" : { "_0" : { - "kind" : "unsafeRawPointer" - } + "jsValue" : { + + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_roundTripUnsafeMutableRawPointer", + "abiName" : "bjs_roundTripOptionalJSValueArray", "effects" : { "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripUnsafeMutableRawPointer", + "name" : "roundTripOptionalJSValueArray", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "unsafePointer" : { + "nullable" : { "_0" : { - "kind" : "unsafeMutableRawPointer" + "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" : { - "unsafePointer" : { + "jsObject" : { + "_0" : "Foo" + } + } + }, + { + "abiName" : "bjs_roundTripOptionalImportedClass", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "roundTripOptionalImportedClass", + "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "jsObject" : { + "_0" : "Foo" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { "_0" : { - "kind" : "unsafeMutableRawPointer" + "jsObject" : { + "_0" : "Foo" + } + }, + "_1" : "null" + } + } + }, + { + "abiName" : "bjs_throwsSwiftError", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "throwsSwiftError", + "parameters" : [ + { + "label" : "shouldThrow", + "name" : "shouldThrow", + "type" : { + "bool" : { + + } } } + ], + "returnType" : { + "void" : { + + } } }, { - "abiName" : "bjs_roundTripOpaquePointer", + "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" : false + "isThrows" : true }, - "name" : "roundTripOpaquePointer", + "name" : "throwsWithFloatResult", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" - } - } - } - } + ], "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "opaquePointer" - } + "float" : { + } } }, { - "abiName" : "bjs_roundTripUnsafePointer", + "abiName" : "bjs_throwsWithDoubleResult", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "roundTripUnsafePointer", + "name" : "throwsWithDoubleResult", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" - } - } - } - } + ], "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafePointer", - "pointee" : "UInt8" - } + "double" : { + } } }, { - "abiName" : "bjs_roundTripUnsafeMutablePointer", + "abiName" : "bjs_throwsWithSwiftHeapObjectResult", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "roundTripUnsafeMutablePointer", + "name" : "throwsWithSwiftHeapObjectResult", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" - } - } - } - } + ], "returnType" : { - "unsafePointer" : { - "_0" : { - "kind" : "unsafeMutablePointer", - "pointee" : "UInt8" - } + "swiftHeapObject" : { + "_0" : "Greeter" } } }, { - "abiName" : "bjs_roundTripJSObject", + "abiName" : "bjs_throwsWithJSObjectResult", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "roundTripJSObject", + "name" : "throwsWithJSObjectResult", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "jsObject" : { - } - } - } ], "returnType" : { "jsObject" : { @@ -13217,353 +14200,348 @@ } }, { - "abiName" : "bjs_roundTripDictionaryExport", + "abiName" : "bjs_zeroArgAsyncThrows", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, - "isThrows" : false + "isThrows" : true }, - "name" : "roundTripDictionaryExport", + "name" : "zeroArgAsyncThrows", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "dictionary" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - } - } - } + ], "returnType" : { - "dictionary" : { - "_0" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } + "string" : { + } } }, { - "abiName" : "bjs_roundTripOptionalDictionaryExport", + "abiName" : "bjs_asyncRoundTripVoid", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripOptionalDictionaryExport", + "name" : "asyncRoundTripVoid", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "nullable" : { - "_0" : { - "dictionary" : { - "_0" : { - "string" : { - } - } - } - }, - "_1" : "null" - } - } - } ], "returnType" : { - "nullable" : { - "_0" : { - "dictionary" : { - "_0" : { - "string" : { + "void" : { - } - } - } - }, - "_1" : "null" } } }, { - "abiName" : "bjs_roundTripJSValue", + "abiName" : "bjs_asyncRoundTripInt", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripJSValue", + "name" : "asyncRoundTripInt", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "jsValue" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } } ], "returnType" : { - "jsValue" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_roundTripOptionalJSValue", + "abiName" : "bjs_asyncRoundTripFloat", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripOptionalJSValue", + "name" : "asyncRoundTripFloat", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "nullable" : { - "_0" : { - "jsValue" : { + "float" : { - } - }, - "_1" : "null" } } } ], "returnType" : { - "nullable" : { - "_0" : { - "jsValue" : { + "float" : { - } - }, - "_1" : "null" } } }, { - "abiName" : "bjs_roundTripOptionalJSValueArray", + "abiName" : "bjs_asyncRoundTripDouble", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripOptionalJSValueArray", + "name" : "asyncRoundTripDouble", "parameters" : [ { "label" : "v", "name" : "v", "type" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "jsValue" : { + "double" : { - } - } - } - }, - "_1" : "null" } } } ], "returnType" : { - "nullable" : { - "_0" : { - "array" : { - "_0" : { - "jsValue" : { + "double" : { - } - } - } - }, - "_1" : "null" } } }, { - "abiName" : "bjs_makeImportedFoo", + "abiName" : "bjs_asyncRoundTripBool", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "makeImportedFoo", + "name" : "asyncRoundTripBool", "parameters" : [ { - "label" : "value", - "name" : "value", + "label" : "v", + "name" : "v", "type" : { - "string" : { + "bool" : { } } } ], "returnType" : { - "jsObject" : { - "_0" : "Foo" + "bool" : { + } } }, { - "abiName" : "bjs_throwsSwiftError", + "abiName" : "bjs_asyncRoundTripString", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsSwiftError", + "name" : "asyncRoundTripString", "parameters" : [ { - "label" : "shouldThrow", - "name" : "shouldThrow", + "label" : "v", + "name" : "v", "type" : { - "bool" : { + "string" : { } } } ], "returnType" : { - "void" : { + "string" : { } } }, { - "abiName" : "bjs_throwsWithIntResult", + "abiName" : "bjs_asyncRoundTripSwiftHeapObject", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithIntResult", + "name" : "asyncRoundTripSwiftHeapObject", "parameters" : [ - + { + "label" : "v", + "name" : "v", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } ], "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "swiftHeapObject" : { + "_0" : "Greeter" } } }, { - "abiName" : "bjs_throwsWithStringResult", + "abiName" : "bjs_asyncRoundTripJSObject", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithStringResult", + "name" : "asyncRoundTripJSObject", "parameters" : [ + { + "label" : "v", + "name" : "v", + "type" : { + "jsObject" : { + } + } + } ], "returnType" : { - "string" : { + "jsObject" : { } } }, { - "abiName" : "bjs_throwsWithBoolResult", + "abiName" : "bjs_takeGreeter", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithBoolResult", + "name" : "takeGreeter", "parameters" : [ + { + "label" : "g", + "name" : "g", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + }, + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + } + } + } ], "returnType" : { - "bool" : { + "void" : { } } }, { - "abiName" : "bjs_throwsWithFloatResult", + "abiName" : "bjs_createCalculator", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithFloatResult", + "name" : "createCalculator", "parameters" : [ ], "returnType" : { - "float" : { - + "swiftHeapObject" : { + "_0" : "Calculator" } } }, { - "abiName" : "bjs_throwsWithDoubleResult", + "abiName" : "bjs_useCalculator", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithDoubleResult", + "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" : { - "double" : { - + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } } } }, { - "abiName" : "bjs_throwsWithSwiftHeapObjectResult", + "abiName" : "bjs_testGreeterToJSValue", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithSwiftHeapObjectResult", + "name" : "testGreeterToJSValue", "parameters" : [ ], "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "jsObject" : { + } } }, { - "abiName" : "bjs_throwsWithJSObjectResult", + "abiName" : "bjs_testCalculatorToJSValue", "effects" : { "isAsync" : false, "isStatic" : false, - "isThrows" : true + "isThrows" : false }, - "name" : "throwsWithJSObjectResult", + "name" : "testCalculatorToJSValue", "parameters" : [ ], @@ -13574,474 +14552,523 @@ } }, { - "abiName" : "bjs_asyncRoundTripVoid", + "abiName" : "bjs_testSwiftClassAsJSValue", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripVoid", + "name" : "testSwiftClassAsJSValue", "parameters" : [ - + { + "label" : "greeter", + "name" : "greeter", + "type" : { + "swiftHeapObject" : { + "_0" : "Greeter" + } + } + } ], "returnType" : { - "void" : { + "jsObject" : { } } }, { - "abiName" : "bjs_asyncRoundTripInt", + "abiName" : "bjs_setDirection", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripInt", + "name" : "setDirection", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "direction", "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "caseEnum" : { + "_0" : "Direction" } } } ], "returnType" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } + "caseEnum" : { + "_0" : "Direction" } } }, { - "abiName" : "bjs_asyncRoundTripFloat", + "abiName" : "bjs_getDirection", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripFloat", + "name" : "getDirection", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "float" : { - } - } - } ], "returnType" : { - "float" : { - + "caseEnum" : { + "_0" : "Direction" } } }, { - "abiName" : "bjs_asyncRoundTripDouble", + "abiName" : "bjs_processDirection", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripDouble", + "name" : "processDirection", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "input", "type" : { - "double" : { - + "caseEnum" : { + "_0" : "Direction" } } } ], "returnType" : { - "double" : { - + "caseEnum" : { + "_0" : "Status" } } }, { - "abiName" : "bjs_asyncRoundTripBool", + "abiName" : "bjs_setTheme", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripBool", + "name" : "setTheme", "parameters" : [ { - "label" : "v", - "name" : "v", + "label" : "_", + "name" : "theme", "type" : { - "bool" : { - + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" } } } ], "returnType" : { - "bool" : { - + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" } } }, { - "abiName" : "bjs_asyncRoundTripString", + "abiName" : "bjs_getTheme", "effects" : { - "isAsync" : true, + "isAsync" : false, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripString", + "name" : "getTheme", "parameters" : [ - { - "label" : "v", - "name" : "v", - "type" : { - "string" : { - } - } - } ], "returnType" : { - "string" : { - + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" } } }, { - "abiName" : "bjs_asyncRoundTripSwiftHeapObject", + "abiName" : "bjs_asyncRoundTripTheme", "effects" : { "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripSwiftHeapObject", + "name" : "asyncRoundTripTheme", "parameters" : [ { - "label" : "v", + "label" : "_", "name" : "v", "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" } } } ], "returnType" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" } } }, { - "abiName" : "bjs_asyncRoundTripJSObject", + "abiName" : "bjs_asyncRoundTripDirection", "effects" : { "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "asyncRoundTripJSObject", + "name" : "asyncRoundTripDirection", "parameters" : [ { - "label" : "v", + "label" : "_", "name" : "v", "type" : { - "jsObject" : { - + "caseEnum" : { + "_0" : "Direction" } } } ], "returnType" : { - "jsObject" : { - + "caseEnum" : { + "_0" : "Direction" } } }, { - "abiName" : "bjs_takeGreeter", + "abiName" : "bjs_asyncRoundTripOptionalTheme", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "takeGreeter", + "name" : "asyncRoundTripOptionalTheme", "parameters" : [ { - "label" : "g", - "name" : "g", - "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" - } - } - }, - { - "label" : "name", - "name" : "name", + "label" : "_", + "name" : "v", "type" : { - "string" : { - + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" } } } ], "returnType" : { - "void" : { - + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_createCalculator", + "abiName" : "bjs_asyncRoundTripOptionalDirection", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "createCalculator", + "name" : "asyncRoundTripOptionalDirection", "parameters" : [ - + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" + } + } + } ], "returnType" : { - "swiftHeapObject" : { - "_0" : "Calculator" + "nullable" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_useCalculator", + "abiName" : "bjs_asyncRoundTripDirectionArray", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "useCalculator", + "name" : "asyncRoundTripDirectionArray", "parameters" : [ { - "label" : "calc", - "name" : "calc", - "type" : { - "swiftHeapObject" : { - "_0" : "Calculator" - } - } - }, - { - "label" : "x", - "name" : "x", - "type" : { - "integer" : { - "_0" : { - "isSigned" : true, - "width" : "word" - } - } - } - }, - { - "label" : "y", - "name" : "y", + "label" : "_", + "name" : "v", "type" : { - "integer" : { + "array" : { "_0" : { - "isSigned" : true, - "width" : "word" + "caseEnum" : { + "_0" : "Direction" + } } } } } ], "returnType" : { - "integer" : { + "array" : { "_0" : { - "isSigned" : true, - "width" : "word" + "caseEnum" : { + "_0" : "Direction" + } } } } }, { - "abiName" : "bjs_testGreeterToJSValue", + "abiName" : "bjs_asyncRoundTripDirectionDict", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "testGreeterToJSValue", + "name" : "asyncRoundTripDirectionDict", "parameters" : [ - - ], - "returnType" : { - "jsObject" : { - + { + "label" : "_", + "name" : "v", + "type" : { + "dictionary" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } + } + } } - } - }, - { - "abiName" : "bjs_testCalculatorToJSValue", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "name" : "testCalculatorToJSValue", - "parameters" : [ - ], "returnType" : { - "jsObject" : { - + "dictionary" : { + "_0" : { + "caseEnum" : { + "_0" : "Direction" + } + } } } }, { - "abiName" : "bjs_testSwiftClassAsJSValue", + "abiName" : "bjs_asyncRoundTripThemeArray", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "testSwiftClassAsJSValue", + "name" : "asyncRoundTripThemeArray", "parameters" : [ { - "label" : "greeter", - "name" : "greeter", + "label" : "_", + "name" : "v", "type" : { - "swiftHeapObject" : { - "_0" : "Greeter" + "array" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } } } } ], "returnType" : { - "jsObject" : { - + "array" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } } } }, { - "abiName" : "bjs_setDirection", + "abiName" : "bjs_asyncRoundTripThemeDict", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "setDirection", + "name" : "asyncRoundTripThemeDict", "parameters" : [ { "label" : "_", - "name" : "direction", + "name" : "v", "type" : { - "caseEnum" : { - "_0" : "Direction" + "dictionary" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } } } } ], "returnType" : { - "caseEnum" : { - "_0" : "Direction" + "dictionary" : { + "_0" : { + "rawValueEnum" : { + "_0" : "Theme", + "_1" : "String" + } + } } } }, { - "abiName" : "bjs_getDirection", + "abiName" : "bjs_asyncRoundTripFileSize", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "getDirection", + "name" : "asyncRoundTripFileSize", "parameters" : [ - + { + "label" : "_", + "name" : "v", + "type" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + } + } ], "returnType" : { - "caseEnum" : { - "_0" : "Direction" + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" } } }, { - "abiName" : "bjs_processDirection", + "abiName" : "bjs_asyncRoundTripOptionalFileSize", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "processDirection", + "name" : "asyncRoundTripOptionalFileSize", "parameters" : [ { "label" : "_", - "name" : "input", + "name" : "v", "type" : { - "caseEnum" : { - "_0" : "Direction" + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + }, + "_1" : "null" } } } ], "returnType" : { - "caseEnum" : { - "_0" : "Status" + "nullable" : { + "_0" : { + "rawValueEnum" : { + "_0" : "FileSize", + "_1" : "Int64" + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_setTheme", + "abiName" : "bjs_asyncRoundTripAssociatedValueEnum", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "setTheme", + "name" : "asyncRoundTripAssociatedValueEnum", "parameters" : [ { "label" : "_", - "name" : "theme", + "name" : "v", "type" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" } } } ], "returnType" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" } } }, { - "abiName" : "bjs_getTheme", + "abiName" : "bjs_asyncRoundTripOptionalAssociatedValueEnum", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "getTheme", + "name" : "asyncRoundTripOptionalAssociatedValueEnum", "parameters" : [ - + { + "label" : "_", + "name" : "v", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + }, + "_1" : "null" + } + } + } ], "returnType" : { - "rawValueEnum" : { - "_0" : "Theme", - "_1" : "String" + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "AsyncPayloadResult" + } + }, + "_1" : "null" } } }, @@ -15769,71 +16796,306 @@ "isStatic" : false, "isThrows" : false }, - "name" : "nestedCartToJSObject", + "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_asyncRoundTripPublicPoint", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripPublicPoint", + "parameters" : [ + { + "label" : "_", + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + }, + { + "abiName" : "bjs_asyncRoundTripPublicPointThrows", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "asyncRoundTripPublicPointThrows", + "parameters" : [ + { + "label" : "_", + "name" : "point", + "type" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + }, + { + "abiName" : "bjs_asyncStructOrThrow", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "asyncStructOrThrow", + "parameters" : [ + { + "label" : "_", + "name" : "shouldThrow", + "type" : { + "bool" : { + + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + }, + { + "abiName" : "bjs_asyncCombinePublicPoints", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncCombinePublicPoints", + "parameters" : [ + { + "label" : "_", + "name" : "a", + "type" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + }, + { + "label" : "_", + "name" : "b", + "type" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } + }, + { + "abiName" : "bjs_asyncRoundTripContact", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripContact", + "parameters" : [ + { + "label" : "_", + "name" : "contact", + "type" : { + "swiftStruct" : { + "_0" : "Contact" + } + } + } + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Contact" + } + } + }, + { + "abiName" : "bjs_asyncRoundTripPublicPointArray", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : false + }, + "name" : "asyncRoundTripPublicPointArray", "parameters" : [ { "label" : "_", - "name" : "cart", + "name" : "points", "type" : { - "swiftStruct" : { - "_0" : "CopyableNestedCart" + "array" : { + "_0" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } } } } ], "returnType" : { - "jsObject" : { - + "array" : { + "_0" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } } } }, { - "abiName" : "bjs_roundTripDataPoint", + "abiName" : "bjs_asyncRoundTripOptionalPublicPoint", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripDataPoint", + "name" : "asyncRoundTripOptionalPublicPoint", "parameters" : [ { "label" : "_", - "name" : "data", + "name" : "point", "type" : { - "swiftStruct" : { - "_0" : "DataPoint" + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + }, + "_1" : "null" } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "DataPoint" + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + }, + "_1" : "null" } } }, { - "abiName" : "bjs_roundTripPublicPoint", + "abiName" : "bjs_asyncRoundTripPublicPointDict", "effects" : { - "isAsync" : false, + "isAsync" : true, "isStatic" : false, "isThrows" : false }, - "name" : "roundTripPublicPoint", + "name" : "asyncRoundTripPublicPointDict", "parameters" : [ { "label" : "_", - "name" : "point", + "name" : "points", "type" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "dictionary" : { + "_0" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } } } } ], "returnType" : { - "swiftStruct" : { - "_0" : "PublicPoint" + "dictionary" : { + "_0" : { + "swiftStruct" : { + "_0" : "PublicPoint" + } + } } } }, @@ -16696,44 +17958,6 @@ ], "swiftCallName" : "JSCoordinate" }, - { - "constructor" : { - "abiName" : "bjs_SessionState_init", - "effects" : { - "isAsync" : false, - "isStatic" : false, - "isThrows" : false - }, - "parameters" : [ - { - "label" : "token", - "name" : "token", - "type" : { - "string" : { - - } - } - } - ] - }, - "methods" : [ - - ], - "name" : "SessionState", - "properties" : [ - { - "isReadonly" : true, - "isStatic" : false, - "name" : "token", - "type" : { - "string" : { - - } - } - } - ], - "swiftCallName" : "SessionState" - }, { "methods" : [ @@ -18711,6 +19935,96 @@ } } } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripUserId", + "parameters" : [ + { + "name" : "value", + "type" : { + "alias" : { + "name" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + } + ], + "returnType" : { + "alias" : { + "name" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalUserId", + "parameters" : [ + { + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "alias" : { + "name" : "UserId", + "underlying" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + }, + "_1" : "null" + } + } } ] } @@ -19609,31 +20923,137 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsAsyncRoundTripStringArray", + "name" : "jsAsyncRoundTripStringArray", + "parameters" : [ + { + "name" : "values", + "type" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + } + ], + "returnType" : { + "array" : { + "_0" : { + "string" : { + + } + } + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripFeatureFlag", + "parameters" : [ + { + "name" : "v", + "type" : { + "rawValueEnum" : { + "_0" : "FeatureFlag", + "_1" : "String" + } + } + } + ], + "returnType" : { + "rawValueEnum" : { + "_0" : "FeatureFlag", + "_1" : "String" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripAssociatedValueEnum", + "parameters" : [ + { + "name" : "v", + "type" : { + "associatedValueEnum" : { + "_0" : "AsyncImportedPayloadResult" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "AsyncImportedPayloadResult" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : true, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsAsyncRoundTripOptionalAssociatedValueEnum", "parameters" : [ { - "name" : "values", + "name" : "v", "type" : { - "array" : { + "nullable" : { "_0" : { - "string" : { - + "associatedValueEnum" : { + "_0" : "AsyncImportedPayloadResult" } - } + }, + "_1" : "null" } } } ], "returnType" : { - "array" : { + "nullable" : { "_0" : { - "string" : { - + "associatedValueEnum" : { + "_0" : "AsyncImportedPayloadResult" } - } + }, + "_1" : "null" } } - }, + } + ] + } + ] + }, + { + "functions" : [ + + ], + "types" : [ + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "ClosureAsyncImports", + "setters" : [ + + ], + "staticMethods" : [ { "accessLevel" : "internal", "effects" : { @@ -19641,22 +21061,13 @@ "isStatic" : false, "isThrows" : true }, - "name" : "jsAsyncRoundTripFeatureFlag", + "name" : "runJsClosureAsyncTests", "parameters" : [ - { - "name" : "v", - "type" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" - } - } - } + ], "returnType" : { - "rawValueEnum" : { - "_0" : "FeatureFlag", - "_1" : "String" + "void" : { + } } } @@ -20485,6 +21896,45 @@ { "functions" : [ + ], + "types" : [ + { + "accessLevel" : "internal", + "getters" : [ + + ], + "methods" : [ + + ], + "name" : "ClosureThrowsImports", + "setters" : [ + + ], + "staticMethods" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "runJsClosureThrowsTests", + "parameters" : [ + + ], + "returnType" : { + "void" : { + + } + } + } + ] + } + ] + }, + { + "functions" : [ + ], "types" : [ { @@ -21047,23 +22497,6 @@ } } }, - { - "accessLevel" : "internal", - "effects" : { - "isAsync" : true, - "isStatic" : false, - "isThrows" : true - }, - "name" : "runAliasAsyncWorks", - "parameters" : [ - - ], - "returnType" : { - "void" : { - - } - } - }, { "accessLevel" : "internal", "effects" : { @@ -21615,6 +23048,95 @@ } ] }, + { + "functions" : [ + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripLightColor", + "parameters" : [ + { + "name" : "value", + "type" : { + "caseEnum" : { + "_0" : "LightColor" + } + } + } + ], + "returnType" : { + "caseEnum" : { + "_0" : "LightColor" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripImportedPayloadSignal", + "parameters" : [ + { + "name" : "value", + "type" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } + } + } + ], + "returnType" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } + } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalImportedPayloadSignal", + "parameters" : [ + { + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "associatedValueEnum" : { + "_0" : "ImportedPayloadSignal" + } + }, + "_1" : "null" + } + } + } + ], + "types" : [ + + ] + }, { "functions" : [ { @@ -21662,6 +23184,40 @@ "_0" : "Point" } } + }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalPoint", + "parameters" : [ + { + "name" : "point", + "type" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "Point" + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "swiftStruct" : { + "_0" : "Point" + } + }, + "_1" : "null" + } + } } ], "types" : [ @@ -22929,6 +24485,40 @@ } } }, + { + "accessLevel" : "internal", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : true + }, + "name" : "jsRoundTripOptionalJSObjectNull", + "parameters" : [ + { + "name" : "value", + "type" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + } + ], + "returnType" : { + "nullable" : { + "_0" : { + "jsObject" : { + + } + }, + "_1" : "null" + } + } + }, { "accessLevel" : "internal", "effects" : { diff --git a/Tests/BridgeJSRuntimeTests/JavaScript/AliasTests.mjs b/Tests/BridgeJSRuntimeTests/JavaScript/AliasTests.mjs index db6225b21..af5fe8cc8 100644 --- a/Tests/BridgeJSRuntimeTests/JavaScript/AliasTests.mjs +++ b/Tests/BridgeJSRuntimeTests/JavaScript/AliasTests.mjs @@ -31,6 +31,12 @@ export function getImports(importsContext) { jsRoundTripCoordinate: (value) => { return { ...value }; }, + jsRoundTripUserId: (value) => { + return value; + }, + jsRoundTripOptionalUserId: (value) => { + return value ?? null; + }, }; } @@ -45,21 +51,17 @@ export function runAliasWorks(exports) { runMultipleAliases(exports); runArrays(exports); runThrows(exports); - runNonCopyable(exports); + runJSValueAlias(exports); + runScalarAlias(exports); runClosureWithAliasParameter(exports); runOptionalInArray(exports); runClassPropertyAndInitWithAlias(exports); runAssociatedValueEnumPayload(exports); runStructToStructAlias(exports); runStructToEnumAlias(exports); - runClassToStructAlias(exports); runEnumToClassAlias(exports); } -export async function runAliasAsyncWorks(exports) { - await runAsyncReturningAlias(exports); -} - /** * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -194,15 +196,28 @@ function runThrows(exports) { /** * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ -function runNonCopyable(exports) { - const seed = exports.makeToken(7); - assert.equal(seed.read(), 7); +function runJSValueAlias(exports) { + assert.equal(exports.roundTripBoxed(42), 42); + assert.equal(exports.roundTripBoxed("hello"), "hello"); + assert.deepStrictEqual(exports.roundTripBoxed({ a: 1 }), { a: 1 }); - const next = exports.incrementToken(seed); - assert.equal(next.read(), 8); + assert.equal(exports.roundTripOptionalBoxed(null), null); + assert.equal(exports.roundTripOptionalBoxed("present"), "present"); +} - next.release(); - seed.release(); +/** + * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports + */ +function runScalarAlias(exports) { + assert.equal(exports.roundTripUserId(42), 42); + assert.equal(exports.roundTripUserId(-1), -1); + + assert.equal(exports.roundTripOptionalUserId(null), null); + assert.equal(exports.roundTripOptionalUserId(0), 0); + assert.equal(exports.roundTripOptionalUserId(7), 7); + + assert.deepStrictEqual(exports.roundTripUserIdArray([]), []); + assert.deepStrictEqual(exports.roundTripUserIdArray([1, 2, 3]), [1, 2, 3]); } /** @@ -319,17 +334,6 @@ function runStructToEnumAlias(exports) { assert.equal(echoed, exports.Severity.Error); } -/** - * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports - */ -function runClassToStructAlias(exports) { - const made = exports.makeSession("hello"); - assert.deepStrictEqual(made, { token: "hello" }); - - const echoed = exports.roundTripSession({ token: "world" }); - assert.deepStrictEqual(echoed, { token: "world" }); -} - /** * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports */ @@ -345,13 +349,3 @@ function runEnumToClassAlias(exports) { seed.release(); echoed.release(); } - -/** - * @param {import('../../../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.d.ts').Exports} exports - */ -async function runAsyncReturningAlias(exports) { - const result = await exports.asyncMakePolygon("async"); - assert.equal(result.vertexCount(), 2); - assert.equal(result.summary(), "async(2)"); - result.release(); -} diff --git a/Tests/BridgeJSRuntimeTests/bridge-js.d.ts b/Tests/BridgeJSRuntimeTests/bridge-js.d.ts index 582113df1..9fef391c1 100644 --- a/Tests/BridgeJSRuntimeTests/bridge-js.d.ts +++ b/Tests/BridgeJSRuntimeTests/bridge-js.d.ts @@ -26,8 +26,6 @@ export class JsGreeter { export function runAsyncWorks(): Promise; -export function runAliasAsyncWorks(): Promise; - export interface WeatherData { temperature: number; description: string; diff --git a/Tests/prelude.mjs b/Tests/prelude.mjs index 5b6f8b39f..f431209dd 100644 --- a/Tests/prelude.mjs +++ b/Tests/prelude.mjs @@ -5,7 +5,7 @@ import { } from '../.build/plugins/PackageToJS/outputs/PackageTests/bridge-js.js'; import { ImportedFoo } from './BridgeJSRuntimeTests/JavaScript/Types.mjs'; import { runJsOptionalSupportTests } from './BridgeJSRuntimeTests/JavaScript/OptionalSupportTests.mjs'; -import { runAliasWorks, runAliasAsyncWorks, getImports as getAliasImports, Surface } from './BridgeJSRuntimeTests/JavaScript/AliasTests.mjs'; +import { runAliasWorks, getImports as getAliasImports, Surface } from './BridgeJSRuntimeTests/JavaScript/AliasTests.mjs'; import { getImports as getClosureSupportImports } from './BridgeJSRuntimeTests/JavaScript/ClosureSupportTests.mjs'; import { getImports as getClosureThrowsImports } from './BridgeJSRuntimeTests/JavaScript/ClosureThrowsTests.mjs'; import { getImports as getClosureAsyncImports } from './BridgeJSRuntimeTests/JavaScript/ClosureAsyncTests.mjs'; @@ -143,14 +143,6 @@ export async function setupOptions(options, context) { await runAsyncWorksTests(exports); return; }, - runAliasAsyncWorks: async () => { - const exports = importsContext.getExports(); - if (!exports) { - throw new Error("No exports!?"); - } - await runAliasAsyncWorks(exports); - return; - }, AsyncImportImports: getAsyncImportImports(importsContext), fetchWeatherData: (city) => { return Promise.resolve({ From 76d11c0738f2abe8d15cff981e910d32b9c0845e Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Wed, 24 Jun 2026 11:51:57 +0200 Subject: [PATCH 13/20] BridgeJS: Address @JS(as:) review feedback Follow-up to the review on #750: - ImportTS: give the unreachable `.alias` cases in loweringParameterInfo / liftingReturnInfo a message stating the `.unaliased` invariant, so a future change that breaks it fails loudly instead of trapping silently. - JSGlueGen: in `optionalConvention` and `wasmParams`, delegate `.alias` to its underlying type rather than `preconditionFailure()`. These switch on `self` (not `.unaliased`), so this removes a latent crash for alias-wrapped values and matches how abiReturnType / mangleTypeName already handle `.alias`. - SwiftToSkeleton: diagnose `@JS(as:)` combined with `namespace:` instead of silently dropping the namespace; an alias adopts its representation's placement. Adds a diagnostics test. - BridgeJSSkeleton: note why alias mangling uses the (unique) swiftCallName only. - Docs: add an "Exporting a Type With a Custom JS Representation" article and link it from the exporting topics. --- .../Sources/BridgeJSCore/ImportTS.swift | 4 +- .../BridgeJSCore/SwiftToSkeleton.swift | 17 ++- .../Sources/BridgeJSLink/JSGlueGen.swift | 8 +- .../BridgeJSSkeleton/BridgeJSSkeleton.swift | 2 + .../BridgeJSToolTests/DiagnosticsTests.swift | 21 ++++ .../BridgeJSCodegenTests/DocComments.json | 3 + .../__Snapshots__/BridgeJSLinkTests/Alias.js | 5 +- .../BridgeJSLinkTests/AliasInClosure.js | 7 +- .../BridgeJSLinkTests/EnumAlias.js | 5 +- .../BridgeJS/Exporting-Swift-to-JavaScript.md | 1 + .../Exporting-Swift-Custom-Representation.md | 114 ++++++++++++++++++ 11 files changed, 171 insertions(+), 16 deletions(-) create mode 100644 Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Custom-Representation.md diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift index c15d974f8..7a37b17f0 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift @@ -958,7 +958,7 @@ extension BridgeType { case .array, .dictionary: return LoweringParameterInfo(loweredParameters: []) case .alias: - preconditionFailure() + preconditionFailure("`.alias` must be resolved by `.unaliased` before reaching loweringParameterInfo") } } @@ -1032,7 +1032,7 @@ extension BridgeType { case .array, .dictionary: return LiftingReturnInfo(valueToLift: nil) case .alias: - preconditionFailure() + preconditionFailure("`.alias` must be resolved by `.unaliased` before reaching liftingReturnInfo") } } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift index 36ff44cbc..5b5155fdc 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift @@ -1635,7 +1635,7 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { } if let aliasTarget = parent.extractAliasTarget(from: jsAttribute) { - recordAlias(node: node, aliasTarget: aliasTarget) + recordAlias(node: node, jsAttribute: jsAttribute, aliasTarget: aliasTarget) return .skipChildren } @@ -1739,9 +1739,20 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { private func recordAlias( node: some SyntaxProtocol & NamedDeclSyntax, + jsAttribute: AttributeSyntax, aliasTarget: TypeSyntax ) { let swiftCallName = SwiftToSkeleton.computeSwiftCallName(for: node, itemName: node.name.text) + if extractNamespace(from: jsAttribute) != nil { + errors.append( + DiagnosticError( + node: node, + message: "`namespace` is not supported on `@JS(as:)` types", + hint: "Remove the `namespace:` argument; an alias adopts its target's representation" + ) + ) + return + } var lookupErrors: [DiagnosticError] = [] guard let aliasBridgeType = parent.aliasType( @@ -1774,7 +1785,7 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { } if let aliasTarget = parent.extractAliasTarget(from: jsAttribute) { - recordAlias(node: node, aliasTarget: aliasTarget) + recordAlias(node: node, jsAttribute: jsAttribute, aliasTarget: aliasTarget) return .skipChildren } @@ -1962,7 +1973,7 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor { } if let aliasTarget = parent.extractAliasTarget(from: jsAttribute) { - recordAlias(node: node, aliasTarget: aliasTarget) + recordAlias(node: node, jsAttribute: jsAttribute, aliasTarget: aliasTarget) return .skipChildren } diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift index a94c780ed..6e7bd7628 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift @@ -2685,8 +2685,8 @@ private extension BridgeType { return .stackABI case .nullable(let wrapped, _): return wrapped.optionalConvention - case .alias: - preconditionFailure() + case .alias(_, let underlying): + return underlying.optionalConvention } } @@ -2783,8 +2783,8 @@ private extension BridgeType { return [] case .nullable(let wrapped, _): return wrapped.wasmParams - case .alias: - preconditionFailure() + case .alias(_, let underlying): + return underlying.wasmParams } } diff --git a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift index d2c506e6a..7f45b6c39 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift @@ -1770,6 +1770,8 @@ extension BridgeType { // Dictionary mangling: "SD" prefix followed by value type (key is always String) return "SD\(valueType.mangleTypeName)" case .alias(let name, _): + // `name` is the namespace-qualified swiftCallName (unique), so the underlying + // representation isn't mangled in - aliases bridge via their JS type's ABI. return "Al\(name.count)\(name)" } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift index 2db9ac2d7..79ea47ebd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/DiagnosticsTests.swift @@ -426,6 +426,27 @@ import Testing } } + @Test + func jsAsWithNamespaceDiagnostic() throws { + let source = """ + @JS final class Box { @JS init() {} } + @JS(as: Box.self, namespace: "Foo") struct Wrapped { + consuming func bridgeToJS() -> Box { fatalError() } + static func bridgeFromJS(_ value: consuming Box) -> Wrapped { fatalError() } + } + """ + let swiftAPI = SwiftToSkeleton( + progress: .silent, + moduleName: "TestModule", + exposeToGlobal: false, + externalModuleIndex: .empty + ) + swiftAPI.addSourceFile(Parser.parse(source: source), inputFilePath: "test.swift") + #expect(throws: BridgeJSCoreDiagnosticError.self) { + _ = try swiftAPI.finalize() + } + } + @Test func omitsNextLineWhenErrorIsOnLastLine() throws { let source = """ diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.json index c69fca509..ce4a2190a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DocComments.json @@ -1,5 +1,8 @@ { "exported" : { + "aliases" : [ + + ], "classes" : [ { "constructor" : { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js index a24c0754b..8f9511e86 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js @@ -78,14 +78,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -345,6 +345,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js index dc6e6ccd3..bc7575fbc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js @@ -39,7 +39,7 @@ export async function createInstantiator(options, swift) { const state = { pointer, file, line, unregistered: false }; const real = (...args) => { if (state.unregistered) { - const bytes = new Uint8Array(memory.buffer, state.file); + const bytes = new Uint8Array(memory.buffer, state.file >>> 0); let length = 0; while (bytes[length] !== 0) { length += 1; } const fileID = decodeString(state.file, length); @@ -70,14 +70,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -312,6 +312,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js index 2a2e89f8c..ccf57601b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js @@ -45,14 +45,14 @@ export async function createInstantiator(options, swift) { 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); + const bytes = new Uint8Array(memory.buffer, bytesPtr >>> 0); 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); + const target = new Uint8Array(memory.buffer, ptr >>> 0, len >>> 0); target.set(tmpRetBytes); tmpRetBytes = undefined; } @@ -237,6 +237,7 @@ 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) { + pointer = pointer >>> 0; const makeFresh = (identityMap) => { const obj = Object.create(prototype); const state = { pointer, deinit, hasReleased: false, identityMap }; 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..38a47ffdc 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 @@ -22,6 +22,7 @@ Configure your package and build for JavaScript as described in - - +- - - - diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Custom-Representation.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Custom-Representation.md new file mode 100644 index 000000000..7d3826e01 --- /dev/null +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Custom-Representation.md @@ -0,0 +1,114 @@ +# Exporting a Type With a Custom JS Representation + +Learn how to give a Swift type a different representation on the JavaScript side using `@JS(as:)`. + +## Overview + +> Tip: You can quickly preview what interfaces will be exposed on the Swift/JavaScript/TypeScript sides using the [BridgeJS Playground](https://swiftwasm.org/JavaScriptKit/PlayBridgeJS/). + +BridgeJS picks a sensible default representation for each exported type - structs cross by copy, classes by reference, and so on. Sometimes that default is a poor fit: + +- A struct copied at the boundary is expensive when it holds a large payload (for example a polygon with thousands of vertices). +- A type uses a feature BridgeJS does not export directly (for example a dictionary with integer keys). + +`@JS(as:)` is the escape hatch. It lets a Swift type keep its idiomatic shape while being bridged to JavaScript through a different `@JS` type that you control, without duplicating the surrounding API. + +Mark the type with `@JS(as: OtherType.self)` and provide two conversions: + +```swift +import JavaScriptKit + +@JS(as: JSPolygon.self) struct Polygon { + var vertices: [Point] + + consuming func bridgeToJS() -> JSPolygon { + JSPolygon(underlying: self) + } + + static func bridgeFromJS(_ value: consuming JSPolygon) -> Polygon { + value.underlying + } +} + +@JS final class JSPolygon { + var underlying: Polygon + + @JS init(underlying: Polygon) { + self.underlying = underlying + } + + @JS var vertexCount: Int { underlying.vertices.count } +} + +@JS func merge(_ a: Polygon, _ b: Polygon) -> Polygon +``` + +Existing Swift code keeps using the idiomatic `Polygon`. Anywhere `Polygon` crosses the boundary - parameters, return values, optionals, arrays - BridgeJS substitutes `JSPolygon`, so JavaScript sees the reference type and avoids copying. + +The generated TypeScript declarations refer to the representation type: + +```typescript +export interface JSPolygon extends SwiftHeapObject { + readonly vertexCount: number; +} + +export type Exports = { + JSPolygon: { + new(underlying: JSPolygon): JSPolygon; + } + merge(a: JSPolygon, b: JSPolygon): JSPolygon; +} +``` + +## The Bridging Contract + +A type marked `@JS(as: R.self)` must provide both halves of the conversion to and from its representation `R`: + +```swift +consuming func bridgeToJS() -> R +static func bridgeFromJS(_ value: consuming R) -> Self +``` + +BridgeJS inserts a call to `bridgeToJS()` at the first opportunity when a value leaves Swift, and `bridgeFromJS(_:)` at the last opportunity when one enters. The rest of the generated glue just uses `R`'s ABI, so the conversions are the only code you write. + +## Wrapping a Primitive + +The representation does not have to be a class. A small wrapper over a primitive is a common case - for example exposing a strongly-typed identifier as a plain string: + +```swift +@JS(as: String.self) struct UUID { + var rawValue: String + + consuming func bridgeToJS() -> String { rawValue } + static func bridgeFromJS(_ value: consuming String) -> UUID { UUID(rawValue: value) } +} + +@JS func currentUser() -> UUID +``` + +JavaScript sees a `string`, while Swift keeps the distinct `UUID` type. + +## Supported Representations + +The representation type (the `as:` target) must itself be a type BridgeJS can export by value or reference: + +| Representation | Status | +|:---------------|:-------| +| `@JS class` | ✅ | +| `@JSClass` (imported) | ✅ | +| `@JS struct` | ✅ | +| Primitives (`Int`, `Double`, `Float`, `Bool`, `String`) | ✅ | +| `JSValue` | ✅ | +| Case enums and associated-value enums | ✅ | +| Raw-value enums | ❌ | +| `@JS protocol` | ❌ | +| Another `@JS(as:)` type (chained aliases) | ❌ | +| Closures, arrays, dictionaries, optionals as the direct target | ❌ | + +`@JS(as:)` cannot be combined with `namespace:` - an aliased type adopts its representation's placement. + +## See Also + +- +- +- From 84624af11aa737e607a0ae1369865f76925a0167 Mon Sep 17 00:00:00 2001 From: William Taylor Date: Tue, 30 Jun 2026 09:55:30 +1000 Subject: [PATCH 14/20] BridgeJS: Merge nested types correctly --- .../Sources/BridgeJSLink/BridgeJSLink.swift | 565 ++++++++++-------- .../MacroSwift/ClassWithNestedTypes.swift | 34 ++ .../MacroSwift/StructWithNestedTypes.swift | 52 ++ .../ClassWithNestedTypes.json | 218 +++++++ .../ClassWithNestedTypes.swift | 177 ++++++ .../StructWithNestedTypes.json | 337 +++++++++++ .../StructWithNestedTypes.swift | 249 ++++++++ .../BridgeJSLinkTests/Alias.d.ts | 14 +- .../__Snapshots__/BridgeJSLinkTests/Alias.js | 4 +- .../BridgeJSLinkTests/AliasInClosure.d.ts | 6 +- .../BridgeJSLinkTests/AliasInClosure.js | 2 +- .../BridgeJSLinkTests/ArrayTypes.d.ts | 10 +- .../BridgeJSLinkTests/ArrayTypes.js | 4 +- .../ClassWithNestedTypes.d.ts | 51 ++ .../BridgeJSLinkTests/ClassWithNestedTypes.js | 375 ++++++++++++ .../BridgeJSLinkTests/DefaultParameters.d.ts | 34 +- .../BridgeJSLinkTests/DefaultParameters.js | 6 +- .../BridgeJSLinkTests/DictionaryTypes.d.ts | 4 +- .../BridgeJSLinkTests/DictionaryTypes.js | 2 +- .../BridgeJSLinkTests/DocComments.d.ts | 14 +- .../BridgeJSLinkTests/DocComments.js | 2 +- .../BridgeJSLinkTests/EnumAlias.d.ts | 4 +- .../BridgeJSLinkTests/EnumAlias.js | 2 +- .../EnumAssociatedValue.d.ts | 4 +- .../BridgeJSLinkTests/EnumAssociatedValue.js | 2 +- .../EnumNamespace.Global.d.ts | 32 +- .../BridgeJSLinkTests/EnumNamespace.Global.js | 4 +- .../BridgeJSLinkTests/EnumNamespace.d.ts | 12 +- .../BridgeJSLinkTests/EnumNamespace.js | 4 +- .../IdentityModeClass.ConfigPointer.d.ts | 10 +- .../IdentityModeClass.ConfigPointer.js | 2 +- .../IdentityModeClass.PerClass.d.ts | 10 +- .../IdentityModeClass.PerClass.js | 2 +- .../BridgeJSLinkTests/IdentityModeClass.d.ts | 10 +- .../BridgeJSLinkTests/IdentityModeClass.js | 2 +- .../BridgeJSLinkTests/JSValue.d.ts | 6 +- .../BridgeJSLinkTests/JSValue.js | 2 +- .../BridgeJSLinkTests/MixedGlobal.d.ts | 4 +- .../BridgeJSLinkTests/MixedGlobal.js | 2 +- .../BridgeJSLinkTests/MixedModules.d.ts | 10 +- .../BridgeJSLinkTests/MixedModules.js | 4 +- .../BridgeJSLinkTests/MixedPrivate.d.ts | 4 +- .../BridgeJSLinkTests/MixedPrivate.js | 2 +- .../BridgeJSLinkTests/Namespaces.Global.d.ts | 8 +- .../BridgeJSLinkTests/Namespaces.d.ts | 8 +- .../BridgeJSLinkTests/NestedType.d.ts | 6 +- .../BridgeJSLinkTests/NestedType.js | 6 +- .../BridgeJSLinkTests/Optionals.d.ts | 12 +- .../BridgeJSLinkTests/Optionals.js | 4 +- .../BridgeJSLinkTests/PropertyTypes.d.ts | 6 +- .../BridgeJSLinkTests/PropertyTypes.js | 2 +- .../BridgeJSLinkTests/Protocol.d.ts | 18 +- .../BridgeJSLinkTests/Protocol.js | 6 +- .../BridgeJSLinkTests/ProtocolInClosure.d.ts | 6 +- .../BridgeJSLinkTests/ProtocolInClosure.js | 2 +- .../StaticFunctions.Global.d.ts | 6 +- .../StaticFunctions.Global.js | 2 +- .../BridgeJSLinkTests/StaticFunctions.d.ts | 6 +- .../BridgeJSLinkTests/StaticFunctions.js | 2 +- .../StaticProperties.Global.d.ts | 4 +- .../StaticProperties.Global.js | 2 +- .../BridgeJSLinkTests/StaticProperties.d.ts | 4 +- .../BridgeJSLinkTests/StaticProperties.js | 2 +- .../StructWithNestedTypes.d.ts | 73 +++ .../StructWithNestedTypes.js | 364 +++++++++++ .../BridgeJSLinkTests/SwiftClass.d.ts | 10 +- .../BridgeJSLinkTests/SwiftClass.js | 6 +- .../BridgeJSLinkTests/SwiftClosure.d.ts | 14 +- .../BridgeJSLinkTests/SwiftClosure.js | 4 +- .../BridgeJSLinkTests/SwiftStruct.d.ts | 18 +- .../BridgeJSLinkTests/SwiftStruct.js | 42 +- .../BridgeJSLinkTests/UnsafePointer.d.ts | 2 +- .../BridgeJSRuntimeTests/ExportAPITests.swift | 21 + .../Generated/BridgeJS.swift | 113 ++++ .../Generated/JavaScript/BridgeJS.json | 111 ++++ Tests/prelude.mjs | 8 + 76 files changed, 2706 insertions(+), 486 deletions(-) create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/ClassWithNestedTypes.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/StructWithNestedTypes.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.json create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.swift create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ClassWithNestedTypes.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ClassWithNestedTypes.js create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StructWithNestedTypes.d.ts create mode 100644 Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StructWithNestedTypes.js diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index ed9eb950f..4706b14a4 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -168,7 +168,6 @@ public struct BridgeJSLink { var classLines: [String] = [] var dtsExportLines: [String] = [] var dtsClassLines: [String] = [] - var namespacedClassDtsExportEntries: [String: [String]] = [:] var topLevelTypeLines: [String] = [] var topLevelDtsTypeLines: [String] = [] var importObjectBuilders: [ImportObjectBuilder] = [] @@ -198,16 +197,9 @@ public struct BridgeJSLink { guard let skeleton = unified.exported else { continue } // Process classes for klass in skeleton.classes { - let (jsType, dtsType, dtsExportEntry) = try renderExportedClass(klass) + let (jsType, dtsType) = try renderExportedClass(klass) data.classLines.append(contentsOf: jsType) data.dtsClassLines.append(contentsOf: dtsType) - - if klass.namespace == nil { - data.exportsLines.append("\(klass.name),") - data.dtsExportLines.append(contentsOf: dtsExportEntry) - } else { - data.namespacedClassDtsExportEntries[klass.name] = dtsExportEntry - } } // Process enums - collect top-level definitions and export entries @@ -230,16 +222,10 @@ public struct BridgeJSLink { } } - var structExportEntries: [(js: [String], dts: [String])] = [] - for structDefinition in skeleton.structs { - let (jsStruct, dtsType, dtsExportEntry) = try renderExportedStruct(structDefinition) - if structDefinition.namespace == nil { - data.topLevelDtsTypeLines.append(contentsOf: dtsType) - } - - if structDefinition.namespace == nil && (!jsStruct.isEmpty || !dtsExportEntry.isEmpty) { - structExportEntries.append((js: jsStruct, dts: dtsExportEntry)) - } + for structDefinition in skeleton.structs where structDefinition.namespace == nil { + data.topLevelDtsTypeLines.append( + contentsOf: renderExportedStructInterface(structDefinition) + ) } // Process functions @@ -257,11 +243,6 @@ public struct BridgeJSLink { data.exportsLines.append(contentsOf: entry.js) data.dtsExportLines.append(contentsOf: entry.dts) } - - for entry in structExportEntries { - data.exportsLines.append(contentsOf: entry.js) - data.dtsExportLines.append(contentsOf: entry.dts) - } } // Process imported skeletons @@ -1014,6 +995,12 @@ public struct BridgeJSLink { }, renderDocCallback: { documentation, parameters in self.renderJSDoc(documentation: documentation, parameters: parameters) + }, + renderStructInterface: { structDef in + self.renderExportedStructInterface(structDef) + }, + renderClassDeclaration: { klass in + self.renderExportedClassDeclaration(klass) } ) printer.write(lines: namespaceDeclarationsLines) @@ -1027,7 +1014,10 @@ public struct BridgeJSLink { let hierarchicalExportLines = namespaceBuilder.buildHierarchicalExportsType( exportedSkeletons: exportedSkeletons, renderClassEntry: { klass in - data.namespacedClassDtsExportEntries[klass.name] ?? [] + self.renderExportedClassExportEntryBody(klass) + }, + renderStructEntry: { structDef in + self.renderExportedStructExportEntry(structDef) }, renderFunctionEntry: { function in self.renderJSDoc(documentation: function.documentation, parameters: function.parameters) @@ -1341,6 +1331,9 @@ public struct BridgeJSLink { renderFunctionImpl: { function in let (js, _) = try self.renderExportedFunction(function: function) return js + }, + renderStructImpl: { structDef in + try self.renderExportedStructJsBody(structDef) } ) printer.write(lines: hierarchicalLines) @@ -1599,22 +1592,16 @@ public struct BridgeJSLink { .replacingOccurrences(of: "\"", with: "\\\"") } - func renderExportedStruct( + func renderExportedStructInterface( _ structDefinition: ExportedStruct - ) throws -> (js: [String], dtsType: [String], dtsExportEntry: [String]) { - let structName = structDefinition.name - let hasConstructor = structDefinition.constructor != nil - let staticMethods = structDefinition.methods.filter { $0.effects.isStatic } - let staticProperties = structDefinition.properties.filter { $0.isStatic } - + ) -> [String] { let dtsTypePrinter = CodeFragmentPrinter() for line in renderJSDoc(documentation: structDefinition.documentation, parameters: []) { dtsTypePrinter.write(line) } - dtsTypePrinter.write("export interface \(structName) {") - let instanceProps = structDefinition.properties.filter { !$0.isStatic } + dtsTypePrinter.write("export interface \(structDefinition.name) {") dtsTypePrinter.indent { - for property in instanceProps { + for property in structDefinition.properties where !property.isStatic { let tsType = resolveTypeScriptType(property.type) for line in renderJSDoc(documentation: property.documentation, parameters: []) { dtsTypePrinter.write(line) @@ -1636,87 +1623,78 @@ public struct BridgeJSLink { } } dtsTypePrinter.write("}") + return dtsTypePrinter.lines + } - guard hasConstructor || !staticMethods.isEmpty || !staticProperties.isEmpty else { - return (js: [], dtsType: dtsTypePrinter.lines, dtsExportEntry: []) + func renderExportedStructExportEntry( + _ structDefinition: ExportedStruct + ) -> [String] { + let dtsExportEntryPrinter = CodeFragmentPrinter() + if let constructor = structDefinition.constructor { + let jsDocLines = renderJSDoc(documentation: constructor.documentation, parameters: constructor.parameters) + dtsExportEntryPrinter.write(lines: jsDocLines) + dtsExportEntryPrinter.write( + "init\(renderTSSignature(parameters: constructor.parameters, returnType: .swiftStruct(structDefinition.swiftCallName), effects: constructor.effects));" + ) + } + for property in structDefinition.properties where property.isStatic { + let readonly = property.isReadonly ? "readonly " : "" + dtsExportEntryPrinter.write(lines: renderJSDoc(documentation: property.documentation, parameters: [])) + dtsExportEntryPrinter.write("\(readonly)\(property.name): \(resolveTypeScriptType(property.type));") + } + for method in structDefinition.methods where method.effects.isStatic { + let jsDocLines = renderJSDoc(documentation: method.documentation, parameters: method.parameters) + dtsExportEntryPrinter.write(lines: jsDocLines) + dtsExportEntryPrinter.write( + "\(method.name)\(renderTSSignature(parameters: method.parameters, returnType: method.returnType, effects: method.effects));" + ) } - let jsPrinter = CodeFragmentPrinter() - jsPrinter.write("\(structName): {") - try jsPrinter.indent { - // Constructor as 'init' function - if let constructor = structDefinition.constructor { - let thunkBuilder = ExportedThunkBuilder( - effects: constructor.effects, - intrinsicRegistry: intrinsicRegistry - ) - for param in constructor.parameters { - try thunkBuilder.lowerParameter(param: param) - } - let returnExpr = try thunkBuilder.call( - abiName: constructor.abiName, - returnType: .swiftStruct(structDefinition.swiftCallName) - ) + return dtsExportEntryPrinter.lines + } - let constructorPrinter = CodeFragmentPrinter() - let paramList = DefaultValueUtils.formatParameterList(constructor.parameters) - constructorPrinter.write("init: function(\(paramList)) {") - constructorPrinter.indent { - thunkBuilder.renderFunctionBody(into: constructorPrinter, returnExpr: returnExpr) - } - constructorPrinter.write("},") - jsPrinter.write(lines: constructorPrinter.lines) + func renderExportedStructJsBody( + _ structDefinition: ExportedStruct + ) throws -> [String] { + let jsPrinter = CodeFragmentPrinter() + // Constructor as 'init' function + if let constructor = structDefinition.constructor { + let thunkBuilder = ExportedThunkBuilder( + effects: constructor.effects, + intrinsicRegistry: intrinsicRegistry + ) + for param in constructor.parameters { + try thunkBuilder.lowerParameter(param: param) } + let returnExpr = try thunkBuilder.call( + abiName: constructor.abiName, + returnType: .swiftStruct(structDefinition.swiftCallName) + ) - for property in staticProperties { - let propertyLines = try renderStaticPropertyForExportObject( - property: property, - className: structName - ) - jsPrinter.write(lines: propertyLines) + let constructorPrinter = CodeFragmentPrinter() + let paramList = DefaultValueUtils.formatParameterList(constructor.parameters) + constructorPrinter.write("init: function(\(paramList)) {") + constructorPrinter.indent { + thunkBuilder.renderFunctionBody(into: constructorPrinter, returnExpr: returnExpr) } + constructorPrinter.write("},") + jsPrinter.write(lines: constructorPrinter.lines) + } - for method in staticMethods { - let methodLines = try renderStaticMethodForExportObject(method: method) - jsPrinter.write(lines: methodLines) - } + for property in structDefinition.properties where property.isStatic { + let propertyLines = try renderStaticPropertyForExportObject( + property: property, + className: structDefinition.name + ) + jsPrinter.write(lines: propertyLines) } - jsPrinter.write("},") - let dtsExportEntryPrinter = CodeFragmentPrinter() - dtsExportEntryPrinter.write("\(structName): {") - dtsExportEntryPrinter.indent { - if let constructor = structDefinition.constructor { - let jsDocLines = renderJSDoc( - documentation: constructor.documentation, - parameters: constructor.parameters - ) - dtsExportEntryPrinter.write(lines: jsDocLines) - dtsExportEntryPrinter.write( - "init\(renderTSSignature(parameters: constructor.parameters, returnType: .swiftStruct(structDefinition.swiftCallName), effects: constructor.effects));" - ) - } - for property in staticProperties { - let readonly = property.isReadonly ? "readonly " : "" - for line in renderJSDoc(documentation: property.documentation, parameters: []) { - dtsExportEntryPrinter.write(line) - } - dtsExportEntryPrinter.write("\(readonly)\(property.name): \(resolveTypeScriptType(property.type));") - } - for method in staticMethods { - let jsDocLines = renderJSDoc( - documentation: method.documentation, - parameters: method.parameters - ) - dtsExportEntryPrinter.write(lines: jsDocLines) - dtsExportEntryPrinter.write( - "\(method.name)\(renderTSSignature(parameters: method.parameters, returnType: method.returnType, effects: method.effects));" - ) - } + for method in structDefinition.methods where method.effects.isStatic { + let methodLines = try renderStaticMethodForExportObject(method: method) + jsPrinter.write(lines: methodLines) } - dtsExportEntryPrinter.write("}") - return (js: jsPrinter.lines, dtsType: dtsTypePrinter.lines, dtsExportEntry: dtsExportEntryPrinter.lines) + return jsPrinter.lines } func renderExportedEnum( @@ -2118,16 +2096,14 @@ extension BridgeJSLink { func renderExportedClass( _ klass: ExportedClass - ) throws -> (js: [String], dtsType: [String], dtsExportEntry: [String]) { + ) throws -> (js: [String], dtsType: [String]) { let jsPrinter = CodeFragmentPrinter() let dtsTypePrinter = CodeFragmentPrinter() - let dtsExportEntryPrinter = CodeFragmentPrinter() for line in renderJSDoc(documentation: klass.documentation, parameters: []) { dtsTypePrinter.write(line) } 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 @@ -2176,19 +2152,6 @@ extension BridgeJSLink { } jsPrinter.write("}") } - - dtsExportEntryPrinter.indent { - let jsDocLines = renderJSDoc( - documentation: constructor.documentation, - parameters: constructor.parameters - ) - for line in jsDocLines { - dtsExportEntryPrinter.write(line) - } - dtsExportEntryPrinter.write( - "new\(renderTSSignature(parameters: constructor.parameters, returnType: .swiftHeapObject(klass.name), effects: constructor.effects));" - ) - } } for method in klass.methods { @@ -2212,18 +2175,6 @@ extension BridgeJSLink { ) ) } - - dtsExportEntryPrinter.indent { - for line in renderJSDoc( - documentation: method.documentation, - parameters: method.parameters - ) { - dtsExportEntryPrinter.write(line) - } - dtsExportEntryPrinter.write( - "\(method.name)\(renderTSSignature(parameters: method.parameters, returnType: method.returnType, effects: method.effects));" - ) - } } else { let thunkBuilder = ExportedThunkBuilder( effects: method.effects, @@ -2267,15 +2218,76 @@ extension BridgeJSLink { className: klass.abiName, isStatic: property.isStatic, jsPrinter: jsPrinter, - dtsPrinter: property.isStatic ? dtsExportEntryPrinter : dtsTypePrinter + dtsPrinter: dtsTypePrinter ) } jsPrinter.write("}") dtsTypePrinter.write("}") - dtsExportEntryPrinter.write("}") - return (jsPrinter.lines, dtsTypePrinter.lines, dtsExportEntryPrinter.lines) + return (jsPrinter.lines, dtsTypePrinter.lines) + } + + func renderExportedClassExportEntryBody( + _ klass: ExportedClass + ) -> [String] { + let printer = CodeFragmentPrinter() + if let constructor = klass.constructor { + printer.write( + lines: renderJSDoc(documentation: constructor.documentation, parameters: constructor.parameters) + ) + printer.write( + "new\(renderTSSignature(parameters: constructor.parameters, returnType: .swiftHeapObject(klass.name), effects: constructor.effects));" + ) + } + for method in klass.methods where method.effects.isStatic { + printer.write(lines: renderJSDoc(documentation: method.documentation, parameters: method.parameters)) + printer.write( + "\(method.name)\(renderTSSignature(parameters: method.parameters, returnType: method.returnType, effects: method.effects));" + ) + } + for property in klass.properties where property.isStatic { + let readonly = property.isReadonly ? "readonly " : "" + printer.write(lines: renderJSDoc(documentation: property.documentation, parameters: [])) + printer.write("\(readonly)\(property.name): \(resolveTypeScriptType(property.type));") + } + return printer.lines + } + + func renderExportedClassDeclaration( + _ klass: ExportedClass + ) -> [String] { + let printer = CodeFragmentPrinter() + printer.write(lines: renderJSDoc(documentation: klass.documentation, parameters: [])) + printer.write("class \(klass.name) {") + printer.indent { + if let constructor = klass.constructor { + let paramSignatures = constructor.parameters.map { param in + let optional = param.hasDefault ? "?" : "" + return "\(param.name)\(optional): \(param.type.tsType)" + } + printer.write( + lines: renderJSDoc(documentation: constructor.documentation, parameters: constructor.parameters) + ) + printer.write("constructor(\(paramSignatures.joined(separator: ", ")));") + } + for method in klass.methods.sorted(by: { $0.name < $1.name }) { + let staticKeyword = method.effects.isStatic ? "static " : "" + printer.write(lines: renderJSDoc(documentation: method.documentation, parameters: method.parameters)) + printer.write( + "\(staticKeyword)\(method.name)\(renderTSSignature(parameters: method.parameters, returnType: method.returnType, effects: method.effects));" + ) + } + for property in klass.properties.sorted(by: { $0.name < $1.name }) { + let staticKeyword = property.isStatic ? "static " : "" + let readonly = property.isReadonly ? "readonly " : "" + printer.write(lines: renderJSDoc(documentation: property.documentation, parameters: [])) + printer.write("\(staticKeyword)\(readonly)\(property.name): \(resolveTypeScriptType(property.type));") + } + printer.write("release(): void;") + } + printer.write("}") + return printer.lines } private func renderClassProperty( @@ -2338,12 +2350,14 @@ extension BridgeJSLink { } // Add instance property to TypeScript interface definition - let readonly = property.isReadonly ? "readonly " : "" - dtsPrinter.indent { - for line in renderJSDoc(documentation: property.documentation, parameters: []) { - dtsPrinter.write(line) + if !isStatic { + let readonly = property.isReadonly ? "readonly " : "" + dtsPrinter.indent { + for line in renderJSDoc(documentation: property.documentation, parameters: []) { + dtsPrinter.write(line) + } + dtsPrinter.write("\(readonly)\(property.name): \(resolveTypeScriptType(property.type));") } - dtsPrinter.write("\(readonly)\(property.name): \(property.type.tsType);") } } @@ -2760,17 +2774,27 @@ extension BridgeJSLink { return printer.lines } + private enum NodeDeclaration { + case classType(ExportedClass) + case structType(ExportedStruct) + } + private struct NamespaceContent { + // The declaration this node represents + var declaration: NodeDeclaration? + + // Contents var functions: [ExportedFunction] = [] - var classes: [ExportedClass] = [] var enums: [ExportedEnum] = [] - var structs: [ExportedStruct] = [] var staticProperties: [ExportedProperty] = [] + + // Output var functionJsLines: [(name: String, lines: [String])] = [] var functionDtsLines: [(name: String, lines: [String])] = [] - var classDtsLines: [(name: String, lines: [String])] = [] + var declarationDtsLines: [String] = [] var enumDtsLines: [(name: String, line: String)] = [] var staticPropertyDtsLines: [(name: String, lines: [String])] = [] + var structJsLines: [String] = [] var propertyJsLines: [String] = [] } @@ -2791,6 +2815,16 @@ extension BridgeJSLink { children[childName] = newChild return newChild } + + var classDeclaration: ExportedClass? { + if case .classType(let klass) = content.declaration { return klass } + return nil + } + + var structDeclaration: ExportedStruct? { + if case .structType(let structDef) = content.declaration { return structDef } + return nil + } } private func buildExportsTree( @@ -2806,20 +2840,20 @@ extension BridgeJSLink { currentNode.content.functions.append(function) } - for klass in skeleton.classes where klass.namespace != nil { + for klass in skeleton.classes { var currentNode = rootNode - for part in klass.namespace! { + for part in (klass.namespace ?? []) + [klass.name] { currentNode = currentNode.addChild(part) } - currentNode.content.classes.append(klass) + currentNode.content.declaration = .classType(klass) } - for structDef in skeleton.structs where structDef.namespace != nil { + for structDef in skeleton.structs { var currentNode = rootNode - for part in structDef.namespace! { + for part in (structDef.namespace ?? []) + [structDef.name] { currentNode = currentNode.addChild(part) } - currentNode.content.structs.append(structDef) + currentNode.content.declaration = .structType(structDef) } for enumDef in skeleton.enums where enumDef.namespace != nil && enumDef.enumType != .namespace { @@ -2854,6 +2888,7 @@ extension BridgeJSLink { fileprivate func buildHierarchicalExportsType( exportedSkeletons: [ExportedSkeleton], renderClassEntry: (ExportedClass) -> [String], + renderStructEntry: (ExportedStruct) -> [String], renderFunctionEntry: (ExportedFunction) -> [String], renderPropertyEntry: (ExportedProperty) -> [String] ) -> [String] { @@ -2866,6 +2901,7 @@ extension BridgeJSLink { populateTypeScriptExportLines( node: node, renderClassEntry: renderClassEntry, + renderStructEntry: renderStructEntry, renderFunctionEntry: renderFunctionEntry, renderPropertyEntry: renderPropertyEntry ) @@ -2879,6 +2915,7 @@ extension BridgeJSLink { private func populateTypeScriptExportLines( node: NamespaceNode, renderClassEntry: (ExportedClass) -> [String], + renderStructEntry: (ExportedStruct) -> [String], renderFunctionEntry: (ExportedFunction) -> [String], renderPropertyEntry: (ExportedProperty) -> [String] ) { @@ -2886,9 +2923,13 @@ extension BridgeJSLink { node.content.functionDtsLines.append((function.name, renderFunctionEntry(function))) } - for klass in node.content.classes { - let entry = renderClassEntry(klass) - node.content.classDtsLines.append((klass.name, entry)) + switch node.content.declaration { + case .classType(let klass): + node.content.declarationDtsLines = renderClassEntry(klass) + case .structType(let structDef): + node.content.declarationDtsLines = renderStructEntry(structDef) + case nil: + break } for property in node.content.staticProperties { @@ -2903,6 +2944,7 @@ extension BridgeJSLink { populateTypeScriptExportLines( node: childNode, renderClassEntry: renderClassEntry, + renderStructEntry: renderStructEntry, renderFunctionEntry: renderFunctionEntry, renderPropertyEntry: renderPropertyEntry ) @@ -2912,36 +2954,52 @@ extension BridgeJSLink { fileprivate func buildHierarchicalExportsObject( exportedSkeletons: [ExportedSkeleton], intrinsicRegistry: JSIntrinsicRegistry, - renderFunctionImpl: (ExportedFunction) throws -> [String] + renderFunctionImpl: (ExportedFunction) throws -> [String], + renderStructImpl: (ExportedStruct) throws -> [String] ) throws -> [String] { let printer = CodeFragmentPrinter() let rootNode = NamespaceNode(name: "") buildExportsTree(rootNode: rootNode, exportedSkeletons: exportedSkeletons) - try populateJavaScriptExportLines(node: rootNode, renderFunctionImpl: renderFunctionImpl) + try populateJavaScriptExportLines( + node: rootNode, + renderFunctionImpl: renderFunctionImpl, + renderStructImpl: renderStructImpl + ) try populatePropertyImplementations( node: rootNode, intrinsicRegistry: intrinsicRegistry ) - printExportsObjectHierarchy(node: rootNode, printer: printer, currentPath: []) + printExportsObjectHierarchy(node: rootNode, printer: printer) return printer.lines } private func populateJavaScriptExportLines( node: NamespaceNode, - renderFunctionImpl: (ExportedFunction) throws -> [String] + renderFunctionImpl: (ExportedFunction) throws -> [String], + renderStructImpl: (ExportedStruct) throws -> [String] ) throws { for function in node.content.functions { let impl = try renderFunctionImpl(function) node.content.functionJsLines.append((function.name, impl)) } + switch node.content.declaration { + case .structType(let structDef): + node.content.structJsLines = try renderStructImpl(structDef) + case .classType, nil: break + } + for (_, childNode) in node.children { - try populateJavaScriptExportLines(node: childNode, renderFunctionImpl: renderFunctionImpl) + try populateJavaScriptExportLines( + node: childNode, + renderFunctionImpl: renderFunctionImpl, + renderStructImpl: renderStructImpl + ) } } @@ -3011,9 +3069,21 @@ extension BridgeJSLink { } private func hasExportContent(node: NamespaceNode) -> Bool { - if !node.content.classDtsLines.isEmpty || !node.content.enumDtsLines.isEmpty - || !node.content.functionDtsLines.isEmpty || !node.content.staticProperties.isEmpty - { + let content = node.content + switch content.declaration { + case .classType: + return true + case .structType(let structDef): + if structDef.constructor != nil + || structDef.properties.contains(where: \.isStatic) + || structDef.methods.contains(where: \.effects.isStatic) + { + return true + } + case nil: + break + } + if !content.enums.isEmpty || !content.functions.isEmpty || !content.staticProperties.isEmpty { return true } return node.children.values.contains(where: { hasExportContent(node: $0) }) @@ -3024,9 +3094,7 @@ extension BridgeJSLink { guard hasExportContent(node: childNode) else { continue } printer.write("\(childName): {") printer.indent { - for (_, lines) in childNode.content.classDtsLines.sorted(by: { $0.name < $1.name }) { - printer.write(lines: lines) - } + printer.write(lines: childNode.content.declarationDtsLines) for (_, line) in childNode.content.enumDtsLines.sorted(by: { $0.name < $1.name }) { printer.write(line) @@ -3050,36 +3118,51 @@ extension BridgeJSLink { private func printExportsObjectHierarchy( node: NamespaceNode, - printer: CodeFragmentPrinter, - currentPath: [String] = [] + printer: CodeFragmentPrinter ) { for (childName, childNode) in node.children.sorted(by: { $0.key < $1.key }) { - let newPath = currentPath + [childName] - printer.write("\(childName): {") - printer.indent { - for klass in childNode.content.classes.sorted(by: { $0.name < $1.name }) { - printer.write("\(klass.name),") + guard hasExportContent(node: childNode) else { continue } + if case .classType = childNode.content.declaration { + let body = CodeFragmentPrinter() + writeExportsObjectBody(node: childNode, into: body) + if body.lines.isEmpty { + printer.write("\(childName),") + } else { + printer.write("\(childName): Object.assign(\(childName), {") + printer.indent { + printer.write(lines: body.lines) + } + printer.write("}),") } - - for enumDef in childNode.content.enums.sorted(by: { $0.name < $1.name }) { - printer.write("\(enumDef.name): \(enumDef.valuesName),") + } else { + printer.write("\(childName): {") + printer.indent { + writeExportsObjectBody(node: childNode, into: printer) } + printer.write("},") + } + } + } - // Print function and property implementations - printer.write(lines: childNode.content.propertyJsLines) - for (name, lines) in childNode.content.functionJsLines.sorted(by: { $0.name < $1.name }) { - var modifiedLines = lines - if !modifiedLines.isEmpty { - modifiedLines[0] = "\(name): " + modifiedLines[0] - modifiedLines[modifiedLines.count - 1] += "," - } - printer.write(lines: modifiedLines) - } + private func writeExportsObjectBody(node: NamespaceNode, into printer: CodeFragmentPrinter) { + printer.write(lines: node.content.structJsLines) + + for enumDef in node.content.enums.sorted(by: { $0.name < $1.name }) { + printer.write("\(enumDef.name): \(enumDef.valuesName),") + } - printExportsObjectHierarchy(node: childNode, printer: printer, currentPath: newPath) + // Print function and property implementations + printer.write(lines: node.content.propertyJsLines) + for (name, lines) in node.content.functionJsLines.sorted(by: { $0.name < $1.name }) { + var modifiedLines = lines + if !modifiedLines.isEmpty { + modifiedLines[0] = "\(name): " + modifiedLines[0] + modifiedLines[modifiedLines.count - 1] += "," } - printer.write("},") + printer.write(lines: modifiedLines) } + + printExportsObjectHierarchy(node: node, printer: printer) } /// Generates TypeScript declarations for all namespaces @@ -3100,7 +3183,9 @@ extension BridgeJSLink { func namespaceDeclarations( exportedSkeletons: [ExportedSkeleton], renderTSSignatureCallback: @escaping ([Parameter], BridgeType, Effects) -> String, - renderDocCallback: @escaping (String?, [Parameter]) -> [String] + renderDocCallback: @escaping (String?, [Parameter]) -> [String], + renderStructInterface: @escaping (ExportedStruct) -> [String], + renderClassDeclaration: @escaping (ExportedClass) -> [String] ) -> [String] { let printer = CodeFragmentPrinter() @@ -3118,12 +3203,14 @@ extension BridgeJSLink { printer.indent() generateNamespaceDeclarationsForNode( node: globalRootNode, - depth: 1, + inNamespaceScope: false, printer: printer, exposeToGlobal: true, exportedSkeletons: exportedSkeletons, renderTSSignatureCallback: renderTSSignatureCallback, - renderDocCallback: renderDocCallback + renderDocCallback: renderDocCallback, + renderStructInterface: renderStructInterface, + renderClassDeclaration: renderClassDeclaration ) printer.unindent() printer.write("}") @@ -3138,12 +3225,14 @@ extension BridgeJSLink { if !localRootNode.children.isEmpty { generateNamespaceDeclarationsForNode( node: localRootNode, - depth: 1, + inNamespaceScope: false, printer: printer, exposeToGlobal: false, exportedSkeletons: exportedSkeletons, renderTSSignatureCallback: renderTSSignatureCallback, - renderDocCallback: renderDocCallback + renderDocCallback: renderDocCallback, + renderStructInterface: renderStructInterface, + renderClassDeclaration: renderClassDeclaration ) } } @@ -3153,22 +3242,27 @@ extension BridgeJSLink { private func generateNamespaceDeclarationsForNode( node: NamespaceNode, - depth: Int, + inNamespaceScope: Bool, printer: CodeFragmentPrinter, exposeToGlobal: Bool, exportedSkeletons: [ExportedSkeleton], renderTSSignatureCallback: @escaping ([Parameter], BridgeType, Effects) -> String, - renderDocCallback: @escaping (String?, [Parameter]) -> [String] + renderDocCallback: @escaping (String?, [Parameter]) -> [String], + renderStructInterface: @escaping (ExportedStruct) -> [String], + renderClassDeclaration: @escaping (ExportedClass) -> [String] ) { func hasContent(node: NamespaceNode) -> Bool { // Enums and structs are always included - if !node.content.enums.isEmpty || !node.content.structs.isEmpty { + if !node.content.enums.isEmpty + || node.children.values.contains(where: { $0.structDeclaration != nil }) + { return true } // When exposeToGlobal is true, classes, functions, and properties are included if exposeToGlobal { - if !node.content.classes.isEmpty || !node.content.functions.isEmpty + if node.children.values.contains(where: { $0.classDeclaration != nil }) + || !node.content.functions.isEmpty || !node.content.staticProperties.isEmpty { return true @@ -3185,10 +3279,19 @@ extension BridgeJSLink { return false } - func generateNamespaceDeclarations(node: NamespaceNode, depth: Int) { + func generateNamespaceDeclarations(node: NamespaceNode) { let sortedChildren = node.children.sorted { $0.key < $1.key } for (childName, childNode) in sortedChildren { + if inNamespaceScope { + if exposeToGlobal, let klass = childNode.classDeclaration { + printer.write(lines: renderClassDeclaration(klass)) + } + if let structDef = childNode.structDeclaration { + printer.write(lines: renderStructInterface(structDef)) + } + } + // Skip empty namespaces guard hasContent(node: childNode) else { continue @@ -3198,51 +3301,6 @@ extension BridgeJSLink { printer.write("\(exportKeyword)namespace \(childName) {") printer.indent() - // Only include classes when exposeToGlobal is true - if exposeToGlobal { - let sortedClasses = childNode.content.classes.sorted { $0.name < $1.name } - for klass in sortedClasses { - printer.write(lines: renderDocCallback(klass.documentation, [])) - printer.write("class \(klass.name) {") - printer.indent { - if let constructor = klass.constructor { - let paramSignatures = constructor.parameters.map { param in - let optional = param.hasDefault ? "?" : "" - return "\(param.name)\(optional): \(param.type.tsType)" - } - let constructorSignature = - "constructor(\(paramSignatures.joined(separator: ", ")));" - printer.write( - lines: renderDocCallback(constructor.documentation, constructor.parameters) - ) - printer.write(constructorSignature) - } - - let sortedMethods = klass.methods.sorted { $0.name < $1.name } - for method in sortedMethods { - let staticKeyword = method.effects.isStatic ? "static " : "" - let methodSignature = - "\(staticKeyword)\(method.name)\(renderTSSignatureCallback(method.parameters, method.returnType, method.effects));" - printer.write(lines: renderDocCallback(method.documentation, method.parameters)) - printer.write(methodSignature) - } - - let sortedProperties = klass.properties.sorted { $0.name < $1.name } - for property in sortedProperties { - let staticKeyword = property.isStatic ? "static " : "" - let readonly = property.isReadonly ? "readonly " : "" - printer.write(lines: renderDocCallback(property.documentation, [])) - printer.write( - "\(staticKeyword)\(readonly)\(property.name): \(property.type.tsType);" - ) - } - - printer.write("release(): void;") - } - printer.write("}") - } - } - // Generate enum definitions within declare global namespace let sortedEnums = childNode.content.enums.sorted { $0.name < $1.name } for enumDefinition in sortedEnums { @@ -3351,25 +3409,6 @@ extension BridgeJSLink { } } - // Generate struct interface definitions - let sortedStructs = childNode.content.structs.sorted { $0.name < $1.name } - for structDef in sortedStructs { - let instanceProps = structDef.properties.filter { !$0.isStatic } - printer.write(lines: renderDocCallback(structDef.documentation, [])) - printer.write("export interface \(structDef.name) {") - printer.indent { - for property in instanceProps { - let tsType = BridgeJSLink.resolveTypeScriptType( - property.type, - exportedSkeletons: exportedSkeletons - ) - printer.write(lines: renderDocCallback(property.documentation, [])) - printer.write("\(property.name): \(tsType);") - } - } - printer.write("}") - } - // Only include functions and properties when exposeToGlobal is true if exposeToGlobal { let sortedFunctions = childNode.content.functions.sorted { $0.name < $1.name } @@ -3389,12 +3428,14 @@ extension BridgeJSLink { generateNamespaceDeclarationsForNode( node: childNode, - depth: depth + 1, + inNamespaceScope: true, printer: printer, exposeToGlobal: exposeToGlobal, exportedSkeletons: exportedSkeletons, renderTSSignatureCallback: renderTSSignatureCallback, - renderDocCallback: renderDocCallback + renderDocCallback: renderDocCallback, + renderStructInterface: renderStructInterface, + renderClassDeclaration: renderClassDeclaration ) printer.unindent() @@ -3402,7 +3443,7 @@ extension BridgeJSLink { } } - generateNamespaceDeclarations(node: node, depth: depth) + generateNamespaceDeclarations(node: node) } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/ClassWithNestedTypes.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/ClassWithNestedTypes.swift new file mode 100644 index 000000000..7971283d2 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/ClassWithNestedTypes.swift @@ -0,0 +1,34 @@ +@JS class Account { + @JS enum Role: String { + case admin + case guest + } + + @JS struct Credentials { + var token: String + + @JS init(token: String) { + self.token = token + } + + @JS static var maxLength: Int { 64 } + + @JS static func empty() -> Credentials { + Credentials(token: "") + } + } + + @JS var name: String + + @JS var role: Role { .admin } + + @JS static var defaultRole: Role { .guest } + + @JS init(name: String) { + self.name = name + } + + @JS func describe() -> String { + name + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/StructWithNestedTypes.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/StructWithNestedTypes.swift new file mode 100644 index 000000000..d8e5973c1 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/StructWithNestedTypes.swift @@ -0,0 +1,52 @@ +@JS struct Shape { + @JS enum Kind: String { + case circle + case square + } + + var label: String + + @JS init(label: String) { + self.label = label + } +} + +@JS struct Widget { + @JS enum Variant: String { + case button + case slider + } + + @JS struct Layout { + @JS enum Alignment: String { + case leading + case trailing + } + + var padding: Int + } + + @JS struct Bounds { + var width: Int + var height: Int + + @JS init(width: Int, height: Int) { + self.width = width + self.height = height + } + + @JS static var dimensions: Int { + 2 + } + + @JS static func zero() -> Bounds { + Bounds(width: 0, height: 0) + } + } + + var name: String + + @JS init(name: String) { + self.name = name + } +} diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.json new file mode 100644 index 000000000..0aa78c471 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.json @@ -0,0 +1,218 @@ +{ + "exported" : { + "aliases" : [ + + ], + "classes" : [ + { + "constructor" : { + "abiName" : "bjs_Account_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_Account_describe", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "describe", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "Account", + "properties" : [ + { + "isReadonly" : false, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "role", + "type" : { + "rawValueEnum" : { + "_0" : "Account.Role", + "_1" : "String" + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "defaultRole", + "staticContext" : { + "className" : { + "_0" : "Account" + } + }, + "type" : { + "rawValueEnum" : { + "_0" : "Account.Role", + "_1" : "String" + } + } + } + ], + "swiftCallName" : "Account" + } + ], + "enums" : [ + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "admin" + }, + { + "associatedValues" : [ + + ], + "name" : "guest" + } + ], + "emitStyle" : "const", + "name" : "Role", + "namespace" : [ + "Account" + ], + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Account.Role", + "tsFullPath" : "Account.Role" + } + ], + "exposeToGlobal" : false, + "functions" : [ + + ], + "protocols" : [ + + ], + "structs" : [ + { + "constructor" : { + "abiName" : "bjs_Account_Credentials_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "token", + "name" : "token", + "type" : { + "string" : { + + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_Account_Credentials_static_empty", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "empty", + "parameters" : [ + + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Account.Credentials" + } + }, + "staticContext" : { + "structName" : { + "_0" : "Account_Credentials" + } + } + } + ], + "name" : "Credentials", + "namespace" : [ + "Account" + ], + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "token", + "namespace" : [ + "Account" + ], + "type" : { + "string" : { + + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "maxLength", + "staticContext" : { + "structName" : { + "_0" : "Account_Credentials" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "Account.Credentials" + } + ] + }, + "moduleName" : "TestModule", + "usedExternalModules" : [ + + ] +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.swift new file mode 100644 index 000000000..3ae08e13a --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.swift @@ -0,0 +1,177 @@ +extension Account.Role: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension Account.Credentials: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Account.Credentials { + let token = String.bridgeJSStackPop() + return Account.Credentials(token: token) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.token.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Account_Credentials(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Account_Credentials())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Account_Credentials") +fileprivate func _bjs_struct_lower_Account_Credentials_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Account_Credentials_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Account_Credentials(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Account_Credentials_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Account_Credentials") +fileprivate func _bjs_struct_lift_Account_Credentials_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Account_Credentials_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Account_Credentials() -> Int32 { + return _bjs_struct_lift_Account_Credentials_extern() +} + +@_expose(wasm, "bjs_Account_Credentials_init") +@_cdecl("bjs_Account_Credentials_init") +public func _bjs_Account_Credentials_init(_ tokenBytes: Int32, _ tokenLength: Int32) -> Void { + #if arch(wasm32) + let ret = Account.Credentials(token: String.bridgeJSLiftParameter(tokenBytes, tokenLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Account_Credentials_static_maxLength_get") +@_cdecl("bjs_Account_Credentials_static_maxLength_get") +public func _bjs_Account_Credentials_static_maxLength_get() -> Int32 { + #if arch(wasm32) + let ret = Account_Credentials.maxLength + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Account_Credentials_static_empty") +@_cdecl("bjs_Account_Credentials_static_empty") +public func _bjs_Account_Credentials_static_empty() -> Void { + #if arch(wasm32) + let ret = Account.Credentials.empty() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Account_init") +@_cdecl("bjs_Account_init") +public func _bjs_Account_init(_ nameBytes: Int32, _ nameLength: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = Account(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Account_describe") +@_cdecl("bjs_Account_describe") +public func _bjs_Account_describe(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = Account.bridgeJSLiftParameter(_self).describe() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Account_name_get") +@_cdecl("bjs_Account_name_get") +public func _bjs_Account_name_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = Account.bridgeJSLiftParameter(_self).name + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Account_name_set") +@_cdecl("bjs_Account_name_set") +public func _bjs_Account_name_set(_ _self: UnsafeMutableRawPointer, _ valueBytes: Int32, _ valueLength: Int32) -> Void { + #if arch(wasm32) + Account.bridgeJSLiftParameter(_self).name = String.bridgeJSLiftParameter(valueBytes, valueLength) + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Account_role_get") +@_cdecl("bjs_Account_role_get") +public func _bjs_Account_role_get(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = Account.bridgeJSLiftParameter(_self).role + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Account_static_defaultRole_get") +@_cdecl("bjs_Account_static_defaultRole_get") +public func _bjs_Account_static_defaultRole_get() -> Void { + #if arch(wasm32) + let ret = Account.defaultRole + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Account_deinit") +@_cdecl("bjs_Account_deinit") +public func _bjs_Account_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Account: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_Account_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_Account_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "TestModule", name: "bjs_Account_wrap") +fileprivate func _bjs_Account_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_Account_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_Account_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_Account_wrap_extern(pointer) +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.json new file mode 100644 index 000000000..ec470b65f --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.json @@ -0,0 +1,337 @@ +{ + "exported" : { + "aliases" : [ + + ], + "classes" : [ + + ], + "enums" : [ + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "circle" + }, + { + "associatedValues" : [ + + ], + "name" : "square" + } + ], + "emitStyle" : "const", + "name" : "Kind", + "namespace" : [ + "Shape" + ], + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Shape.Kind", + "tsFullPath" : "Shape.Kind" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "button" + }, + { + "associatedValues" : [ + + ], + "name" : "slider" + } + ], + "emitStyle" : "const", + "name" : "Variant", + "namespace" : [ + "Widget" + ], + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Widget.Variant", + "tsFullPath" : "Widget.Variant" + }, + { + "cases" : [ + { + "associatedValues" : [ + + ], + "name" : "leading" + }, + { + "associatedValues" : [ + + ], + "name" : "trailing" + } + ], + "emitStyle" : "const", + "name" : "Alignment", + "namespace" : [ + "Widget", + "Layout" + ], + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "Widget.Layout.Alignment", + "tsFullPath" : "Widget.Layout.Alignment" + } + ], + "exposeToGlobal" : false, + "functions" : [ + + ], + "protocols" : [ + + ], + "structs" : [ + { + "constructor" : { + "abiName" : "bjs_Shape_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "label", + "name" : "label", + "type" : { + "string" : { + + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "Shape", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "label", + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "Shape" + }, + { + "constructor" : { + "abiName" : "bjs_Widget_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "name", + "name" : "name", + "type" : { + "string" : { + + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "Widget", + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "name", + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "Widget" + }, + { + "methods" : [ + + ], + "name" : "Layout", + "namespace" : [ + "Widget" + ], + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "padding", + "namespace" : [ + "Widget" + ], + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "Widget.Layout" + }, + { + "constructor" : { + "abiName" : "bjs_Widget_Bounds_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "width", + "name" : "width", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "label" : "height", + "name" : "height", + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ] + }, + "methods" : [ + { + "abiName" : "bjs_Widget_Bounds_static_zero", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "zero", + "parameters" : [ + + ], + "returnType" : { + "swiftStruct" : { + "_0" : "Widget.Bounds" + } + }, + "staticContext" : { + "structName" : { + "_0" : "Widget_Bounds" + } + } + } + ], + "name" : "Bounds", + "namespace" : [ + "Widget" + ], + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "width", + "namespace" : [ + "Widget" + ], + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : false, + "name" : "height", + "namespace" : [ + "Widget" + ], + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "dimensions", + "staticContext" : { + "structName" : { + "_0" : "Widget_Bounds" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } + } + ], + "swiftCallName" : "Widget.Bounds" + } + ] + }, + "moduleName" : "TestModule", + "usedExternalModules" : [ + + ] +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.swift new file mode 100644 index 000000000..f8843b7cd --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.swift @@ -0,0 +1,249 @@ +extension Shape.Kind: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension Widget.Variant: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension Widget.Layout.Alignment: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + +extension Shape: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Shape { + let label = String.bridgeJSStackPop() + return Shape(label: label) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.label.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Shape(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Shape())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Shape") +fileprivate func _bjs_struct_lower_Shape_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Shape_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Shape(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Shape_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Shape") +fileprivate func _bjs_struct_lift_Shape_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Shape_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Shape() -> Int32 { + return _bjs_struct_lift_Shape_extern() +} + +@_expose(wasm, "bjs_Shape_init") +@_cdecl("bjs_Shape_init") +public func _bjs_Shape_init(_ labelBytes: Int32, _ labelLength: Int32) -> Void { + #if arch(wasm32) + let ret = Shape(label: String.bridgeJSLiftParameter(labelBytes, labelLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Widget: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Widget { + let name = String.bridgeJSStackPop() + return Widget(name: name) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.name.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Widget(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Widget())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Widget") +fileprivate func _bjs_struct_lower_Widget_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Widget_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Widget(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Widget_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Widget") +fileprivate func _bjs_struct_lift_Widget_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Widget_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Widget() -> Int32 { + return _bjs_struct_lift_Widget_extern() +} + +@_expose(wasm, "bjs_Widget_init") +@_cdecl("bjs_Widget_init") +public func _bjs_Widget_init(_ nameBytes: Int32, _ nameLength: Int32) -> Void { + #if arch(wasm32) + let ret = Widget(name: String.bridgeJSLiftParameter(nameBytes, nameLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension Widget.Layout: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Widget.Layout { + let padding = Int.bridgeJSStackPop() + return Widget.Layout(padding: padding) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.padding.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Widget_Layout(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Widget_Layout())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Widget_Layout") +fileprivate func _bjs_struct_lower_Widget_Layout_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Widget_Layout_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Widget_Layout(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Widget_Layout_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Widget_Layout") +fileprivate func _bjs_struct_lift_Widget_Layout_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Widget_Layout_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Widget_Layout() -> Int32 { + return _bjs_struct_lift_Widget_Layout_extern() +} + +extension Widget.Bounds: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Widget.Bounds { + let height = Int.bridgeJSStackPop() + let width = Int.bridgeJSStackPop() + return Widget.Bounds(width: width, height: height) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.width.bridgeJSStackPush() + self.height.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_Widget_Bounds(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Widget_Bounds())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Widget_Bounds") +fileprivate func _bjs_struct_lower_Widget_Bounds_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_Widget_Bounds_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_Widget_Bounds(_ objectId: Int32) -> Void { + return _bjs_struct_lower_Widget_Bounds_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Widget_Bounds") +fileprivate func _bjs_struct_lift_Widget_Bounds_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_Widget_Bounds_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_Widget_Bounds() -> Int32 { + return _bjs_struct_lift_Widget_Bounds_extern() +} + +@_expose(wasm, "bjs_Widget_Bounds_init") +@_cdecl("bjs_Widget_Bounds_init") +public func _bjs_Widget_Bounds_init(_ width: Int32, _ height: Int32) -> Void { + #if arch(wasm32) + let ret = Widget.Bounds(width: Int.bridgeJSLiftParameter(width), height: Int.bridgeJSLiftParameter(height)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Widget_Bounds_static_dimensions_get") +@_cdecl("bjs_Widget_Bounds_static_dimensions_get") +public func _bjs_Widget_Bounds_static_dimensions_get() -> Int32 { + #if arch(wasm32) + let ret = Widget_Bounds.dimensions + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_Widget_Bounds_static_zero") +@_cdecl("bjs_Widget_Bounds_static_zero") +public func _bjs_Widget_Bounds_static_zero() -> Void { + #if arch(wasm32) + let ret = Widget.Bounds.zero() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.d.ts index 3ee338254..e3092afb3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.d.ts @@ -37,13 +37,6 @@ export interface Surface { readonly label: string; } export type Exports = { - PolygonReference: { - new(underlying: PolygonReference): PolygonReference; - origin(): PolygonReference; - } - TagReference: { - new(underlying: TagReference): TagReference; - } roundtripPolygon(polygon: PolygonReference): PolygonReference; optionalPolygon(polygon: PolygonReference | null): PolygonReference | null; polygonArray(polygons: PolygonReference[]): PolygonReference[]; @@ -52,6 +45,13 @@ export type Exports = { roundtripTags(xs: (InnerTagTag | null)[]): (InnerTagTag | null)[]; describeUser(owner: HasOptionalUserId): HasOptionalUserId; InnerTag: InnerTagObject + PolygonReference: { + new(underlying: PolygonReference): PolygonReference; + origin(): PolygonReference; + }, + TagReference: { + new(underlying: TagReference): TagReference; + }, } export type Imports = { acceptTagged(tagged: string): void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js index 8f9511e86..0b922111b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js @@ -421,8 +421,6 @@ export async function createInstantiator(options, swift) { enumHelpers.InnerTag = InnerTagHelpers; const exports = { - PolygonReference, - TagReference, roundtripPolygon: function bjs_roundtripPolygon(polygon) { const ret = instance.exports.bjs_roundtripPolygon(polygon.pointer); return PolygonReference.__construct(ret); @@ -517,6 +515,8 @@ export async function createInstantiator(options, swift) { return ret1; }, InnerTag: InnerTagValues, + PolygonReference, + TagReference, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.d.ts index f1d5d5fa9..73ea3b570 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.d.ts @@ -14,11 +14,11 @@ export interface SwiftHeapObject { export interface PolygonReference extends SwiftHeapObject { } export type Exports = { - PolygonReference: { - new(sides: number): PolygonReference; - } makePolygonFactory(): () => PolygonReference; makePolygonInspector(): (arg0: PolygonReference) => number; + PolygonReference: { + new(sides: number): PolygonReference; + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js index bc7575fbc..a38fa118e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/AliasInClosure.js @@ -363,7 +363,6 @@ export async function createInstantiator(options, swift) { } } const exports = { - PolygonReference, makePolygonFactory: function bjs_makePolygonFactory() { const ret = instance.exports.bjs_makePolygonFactory(); return swift.memory.getObject(ret); @@ -372,6 +371,7 @@ export async function createInstantiator(options, swift) { const ret = instance.exports.bjs_makePolygonInspector(); return swift.memory.getObject(ret); }, + PolygonReference, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts index 255249eef..f48189956 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.d.ts @@ -41,11 +41,6 @@ export interface MultiArrayContainer extends SwiftHeapObject { readonly strings: string[]; } export type Exports = { - Item: { - } - MultiArrayContainer: { - new(nums: number[], strs: string[]): MultiArrayContainer; - } processIntArray(values: number[]): number[]; processStringArray(values: string[]): string[]; processDoubleArray(values: number[]): number[]; @@ -76,6 +71,11 @@ export type Exports = { multiOptionalArrayParams(a: number[] | null, b: string[] | null): number; Direction: DirectionObject Status: StatusObject + Item: { + }, + MultiArrayContainer: { + new(nums: number[], strs: string[]): MultiArrayContainer; + }, } export type Imports = { checkArray(a: any): void; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js index 7978d1522..419cf15d5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js @@ -493,8 +493,6 @@ export async function createInstantiator(options, swift) { structHelpers.Point = PointHelpers; const exports = { - Item, - MultiArrayContainer, processIntArray: function bjs_processIntArray(values) { for (const elem of values) { i32Stack.push((elem | 0)); @@ -1201,6 +1199,8 @@ export async function createInstantiator(options, swift) { }, Direction: DirectionValues, Status: StatusValues, + Item, + MultiArrayContainer, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ClassWithNestedTypes.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ClassWithNestedTypes.d.ts new file mode 100644 index 000000000..5537696c4 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ClassWithNestedTypes.d.ts @@ -0,0 +1,51 @@ +// 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 type RoleObject = typeof Account.RoleValues; + +export namespace Account { + const RoleValues: { + readonly Admin: "admin"; + readonly Guest: "guest"; + }; + type RoleTag = typeof RoleValues[keyof typeof RoleValues]; + export interface Credentials { + token: string; + } +} +/// 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 Account extends SwiftHeapObject { + describe(): string; + name: string; + readonly role: Account.RoleTag; +} +export type Exports = { + Account: { + new(name: string): Account; + readonly defaultRole: Account.RoleTag; + Role: RoleObject + Credentials: { + init(token: string): Account.Credentials; + readonly maxLength: number; + empty(): Account.Credentials; + }, + }, +} +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/ClassWithNestedTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ClassWithNestedTypes.js new file mode 100644 index 000000000..272bb8c49 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ClassWithNestedTypes.js @@ -0,0 +1,375 @@ +// 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 const RoleValues = { + Admin: "admin", + Guest: "guest", +}; + +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 = []; + let taStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + const __bjs_createAccount_CredentialsHelpers = () => ({ + lower: (value) => { + const bytes = textEncoder.encode(value.token); + const id = swift.memory.retain(bytes); + i32Stack.push(bytes.length); + i32Stack.push(id); + }, + lift: () => { + const string = strStack.pop(); + return { token: string }; + } + }); + + 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 >>> 0); + 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 >>> 0, len >>> 0); + 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(); + } + const taCtors = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; + bjs["swift_js_push_typed_array"] = function(kind, ptr, count) { + const Ctor = taCtors[kind]; + const byteLen = count * Ctor.BYTES_PER_ELEMENT; + const copy = memory.buffer.slice(ptr, ptr + byteLen); + taStack.push(Array.from(new Ctor(copy))); + } + bjs["swift_js_struct_lower_Account_Credentials"] = function(objectId) { + structHelpers.Account_Credentials.lower(swift.memory.getObject(objectId)); + } + bjs["swift_js_struct_lift_Account_Credentials"] = function() { + const value = structHelpers.Account_Credentials.lift(); + return swift.memory.retain(value); + } + const __bjs_promiseSettlers = Symbol("JavaScriptKit.promiseSettlers"); + bjs["swift_js_make_promise"] = function() { + let resolve, reject; + const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); + promise[__bjs_promiseSettlers] = { resolve, reject }; + return swift.memory.retain(promise); + } + 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_Account_wrap"] = function(pointer) { + const obj = _exports['Account'].__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) { + pointer = pointer >>> 0; + 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 Account extends SwiftHeapObject { + static __construct(ptr) { + return SwiftHeapObject.__wrap(ptr, instance.exports.bjs_Account_deinit, Account.prototype, null); + } + + constructor(name) { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + const ret = instance.exports.bjs_Account_init(nameId, nameBytes.length); + return Account.__construct(ret); + } + describe() { + instance.exports.bjs_Account_describe(this.pointer); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + } + get name() { + instance.exports.bjs_Account_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_Account_name_set(this.pointer, valueId, valueBytes.length); + } + get role() { + instance.exports.bjs_Account_role_get(this.pointer); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + } + static get defaultRole() { + instance.exports.bjs_Account_static_defaultRole_get(); + const ret = tmpRetString; + tmpRetString = undefined; + return ret; + } + } + const Account_CredentialsHelpers = __bjs_createAccount_CredentialsHelpers(); + structHelpers.Account_Credentials = Account_CredentialsHelpers; + + const exports = { + Account: Object.assign(Account, { + Role: RoleValues, + Credentials: { + init: function(token) { + const tokenBytes = textEncoder.encode(token); + const tokenId = swift.memory.retain(tokenBytes); + instance.exports.bjs_Account_Credentials_init(tokenId, tokenBytes.length); + const structValue = structHelpers.Account_Credentials.lift(); + return structValue; + }, + get maxLength() { + const ret = instance.exports.bjs_Account_Credentials_static_maxLength_get(); + return ret; + }, + empty: function() { + instance.exports.bjs_Account_Credentials_static_empty(); + const structValue = structHelpers.Account_Credentials.lift(); + return structValue; + }, + }, + }), + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts index ac5658eb3..961b9fa5b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.d.ts @@ -46,22 +46,6 @@ export interface ConstructorDefaults extends SwiftHeapObject { tag: string | null; } export type Exports = { - DefaultGreeter: { - new(name: string): DefaultGreeter; - } - EmptyGreeter: { - new(): EmptyGreeter; - } - ConstructorDefaults: { - /** - * @param name - Optional parameter (default: "Default") - * @param count - Optional parameter (default: 42) - * @param enabled - Optional parameter (default: true) - * @param status - Optional parameter (default: Status.Active) - * @param tag - Optional parameter (default: null) - */ - new(name?: string, count?: number, enabled?: boolean, status?: StatusTag, tag?: string | null): ConstructorDefaults; - } /** * @param message - Optional parameter (default: "Hello World") */ @@ -143,6 +127,22 @@ export type Exports = { */ testMixedWithArrayDefault(name?: string, values?: number[], enabled?: boolean): string; Status: StatusObject + ConstructorDefaults: { + /** + * @param name - Optional parameter (default: "Default") + * @param count - Optional parameter (default: 42) + * @param enabled - Optional parameter (default: true) + * @param status - Optional parameter (default: Status.Active) + * @param tag - Optional parameter (default: null) + */ + new(name?: string, count?: number, enabled?: boolean, status?: StatusTag, tag?: string | null): ConstructorDefaults; + }, + DefaultGreeter: { + new(name: string): DefaultGreeter; + }, + EmptyGreeter: { + new(): EmptyGreeter; + }, MathOperations: { /** * @param baseValue - Optional parameter (default: 0.0) @@ -152,7 +152,7 @@ export type Exports = { * @param b - Optional parameter (default: 5.0) */ subtract(a: number, b?: number): number; - } + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index 0c6bfbec8..b7f67fe15 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -456,9 +456,6 @@ export async function createInstantiator(options, swift) { structHelpers.MathOperations = MathOperationsHelpers; const exports = { - DefaultGreeter, - EmptyGreeter, - ConstructorDefaults, testStringDefault: function bjs_testStringDefault(message = "Hello World") { const messageBytes = textEncoder.encode(message); const messageId = swift.memory.retain(messageBytes); @@ -675,6 +672,9 @@ export async function createInstantiator(options, swift) { return ret; }, Status: StatusValues, + ConstructorDefaults, + DefaultGreeter, + EmptyGreeter, MathOperations: { init: function(baseValue = 0.0) { instance.exports.bjs_MathOperations_init(baseValue); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts index f14b29aa4..652177cd8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.d.ts @@ -18,14 +18,14 @@ export interface SwiftHeapObject { export interface Box extends SwiftHeapObject { } export type Exports = { - Box: { - } mirrorDictionary(values: Record): Record; optionalDictionary(values: Record | null): Record | null; nestedDictionary(values: Record): Record; boxDictionary(boxes: Record): Record; optionalBoxDictionary(boxes: Record): Record; roundtripCounters(counters: Counters): Counters; + Box: { + }, } export type Imports = { importMirrorDictionary(values: Record): Record; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js index 104472a02..d0ac5307f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js @@ -360,7 +360,6 @@ export async function createInstantiator(options, swift) { structHelpers.Counters = CountersHelpers; const exports = { - Box, mirrorDictionary: function bjs_mirrorDictionary(values) { const entries = Object.entries(values); for (const entry of entries) { @@ -513,6 +512,7 @@ export async function createInstantiator(options, swift) { const structValue = structHelpers.Counters.lift(); return structValue; }, + Box, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.d.ts index 359d719d1..196ef73fe 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.d.ts @@ -77,13 +77,6 @@ export interface Greeter extends SwiftHeapObject { name: string; } export type Exports = { - Greeter: { - /** - * Create a greeter. - * @param name The name to greet. - */ - new(name: string): Greeter; - } /** * Returns a greeting for a user. * @param name The user's name. @@ -120,6 +113,13 @@ export type Exports = { */ terminator(): string; Color: ColorObject + Greeter: { + /** + * Create a greeter. + * @param name The name to greet. + */ + new(name: string): Greeter; + }, MathUtils: { /** * Doubles a value, in a namespace. diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.js index 07e8673bf..f29814675 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DocComments.js @@ -351,7 +351,6 @@ export async function createInstantiator(options, swift) { structHelpers.Point = PointHelpers; const exports = { - Greeter, greet: function bjs_greet(name, greeting = "Hello") { const nameBytes = textEncoder.encode(name); const nameId = swift.memory.retain(nameBytes); @@ -407,6 +406,7 @@ export async function createInstantiator(options, swift) { return ret; } }, + Greeter, MathUtils: { double: function bjs_MathUtils_double(value) { const ret = instance.exports.bjs_MathUtils_double(value); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.d.ts index 9525038e6..d2772fa8b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.d.ts @@ -14,10 +14,10 @@ export interface SwiftHeapObject { export interface ColorBox extends SwiftHeapObject { } export type Exports = { + roundtripColor(color: ColorBox): ColorBox; ColorBox: { new(name: string): ColorBox; - } - roundtripColor(color: ColorBox): ColorBox; + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js index ccf57601b..42f3fd958 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAlias.js @@ -290,11 +290,11 @@ export async function createInstantiator(options, swift) { } } const exports = { - ColorBox, roundtripColor: function bjs_roundtripColor(color) { const ret = instance.exports.bjs_roundtripColor(color.pointer); return ColorBox.__construct(ret); }, + ColorBox, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts index 13f77ae08..36fc92474 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.d.ts @@ -153,8 +153,6 @@ export interface SwiftHeapObject { export interface User extends SwiftHeapObject { } export type Exports = { - User: { - } handle(result: APIResultTag): void; getResult(): APIResultTag; roundtripAPIResult(result: APIResultTag): APIResultTag; @@ -184,6 +182,8 @@ export type Exports = { API: { NetworkingResult: NetworkingResultObject }, + User: { + }, Utilities: { Result: ResultObject }, diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js index 35b05fe61..8ff3dd90d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js @@ -1061,7 +1061,6 @@ export async function createInstantiator(options, swift) { enumHelpers.OptionalAllTypesResult = OptionalAllTypesResultHelpers; const exports = { - User, handle: function bjs_handle(result) { const resultCaseId = enumHelpers.APIResult.lower(result); instance.exports.bjs_handle(resultCaseId); @@ -1255,6 +1254,7 @@ export async function createInstantiator(options, swift) { API: { NetworkingResult: NetworkingResultValues, }, + User, Utilities: { Result: ResultValues, }, 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..0ca8b16b9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts @@ -39,11 +39,6 @@ declare global { } namespace Networking { namespace API { - class HTTPServer { - constructor(); - call(method: Networking.API.MethodTag): void; - release(): void; - } const MethodValues: { readonly Get: 0; readonly Post: 1; @@ -51,19 +46,24 @@ declare global { readonly Delete: 3; }; type MethodTag = typeof MethodValues[keyof typeof MethodValues]; + class HTTPServer { + constructor(); + call(method: Networking.API.MethodTag): void; + release(): void; + } } namespace APIV2 { namespace Internal { - class TestServer { - constructor(); - call(method: Networking.APIV2.Internal.SupportedMethodTag): void; - release(): void; - } const SupportedMethodValues: { readonly Get: 0; readonly Post: 1; }; type SupportedMethodTag = typeof SupportedMethodValues[keyof typeof SupportedMethodValues]; + class TestServer { + constructor(); + call(method: Networking.APIV2.Internal.SupportedMethodTag): void; + release(): void; + } } } } @@ -114,21 +114,21 @@ export type Exports = { Formatting: { Converter: { new(): Converter; - } + }, }, Networking: { API: { + Method: MethodObject HTTPServer: { new(): HTTPServer; - } - Method: MethodObject + }, }, APIV2: { Internal: { + SupportedMethod: SupportedMethodObject TestServer: { new(): TestServer; - } - SupportedMethod: SupportedMethodObject + }, }, }, }, @@ -144,7 +144,7 @@ export type Exports = { Utils: { Converter: { new(): Converter; - } + }, }, } export type Imports = { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js index 1a8f5662f..6c45f0333 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.js @@ -438,13 +438,13 @@ export async function createInstantiator(options, swift) { }, Networking: { API: { - HTTPServer, Method: MethodValues, + HTTPServer, }, APIV2: { Internal: { - TestServer, SupportedMethod: SupportedMethodValues, + TestServer, }, }, }, diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts index 23d872d27..b5a85a082 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.d.ts @@ -75,21 +75,21 @@ export type Exports = { Formatting: { Converter: { new(): Converter; - } + }, }, Networking: { API: { + Method: MethodObject HTTPServer: { new(): HTTPServer; - } - Method: MethodObject + }, }, APIV2: { Internal: { + SupportedMethod: SupportedMethodObject TestServer: { new(): TestServer; - } - SupportedMethod: SupportedMethodObject + }, }, }, }, @@ -105,7 +105,7 @@ export type Exports = { Utils: { Converter: { new(): Converter; - } + }, }, } export type Imports = { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js index 9196e99b3..2a9e7948a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.js @@ -389,13 +389,13 @@ export async function createInstantiator(options, swift) { }, Networking: { API: { - HTTPServer, Method: MethodValues, + HTTPServer, }, APIV2: { Internal: { - TestServer, SupportedMethod: SupportedMethodValues, + TestServer, }, }, }, diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.d.ts index e5e2a3a84..02d17c011 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.d.ts @@ -23,13 +23,13 @@ export interface ExplicitlyUncachedModel extends SwiftHeapObject { export type Exports = { CachedModel: { new(name: string): CachedModel; - } - UncachedModel: { - new(value: number): UncachedModel; - } + }, ExplicitlyUncachedModel: { new(count: number): ExplicitlyUncachedModel; - } + }, + UncachedModel: { + new(value: number): UncachedModel; + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js index 36728f890..83f53d8a6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.ConfigPointer.js @@ -348,8 +348,8 @@ export async function createInstantiator(options, swift) { } const exports = { CachedModel, - UncachedModel, ExplicitlyUncachedModel, + UncachedModel, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.d.ts index e5e2a3a84..02d17c011 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.d.ts @@ -23,13 +23,13 @@ export interface ExplicitlyUncachedModel extends SwiftHeapObject { export type Exports = { CachedModel: { new(name: string): CachedModel; - } - UncachedModel: { - new(value: number): UncachedModel; - } + }, ExplicitlyUncachedModel: { new(count: number): ExplicitlyUncachedModel; - } + }, + UncachedModel: { + new(value: number): UncachedModel; + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js index ed180c1c8..bb6f36902 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.PerClass.js @@ -346,8 +346,8 @@ export async function createInstantiator(options, swift) { } const exports = { CachedModel, - UncachedModel, ExplicitlyUncachedModel, + UncachedModel, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.d.ts index e5e2a3a84..02d17c011 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.d.ts @@ -23,13 +23,13 @@ export interface ExplicitlyUncachedModel extends SwiftHeapObject { export type Exports = { CachedModel: { new(name: string): CachedModel; - } - UncachedModel: { - new(value: number): UncachedModel; - } + }, ExplicitlyUncachedModel: { new(count: number): ExplicitlyUncachedModel; - } + }, + UncachedModel: { + new(value: number): UncachedModel; + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js index ed180c1c8..bb6f36902 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeClass.js @@ -346,8 +346,8 @@ export async function createInstantiator(options, swift) { } const exports = { CachedModel, - UncachedModel, ExplicitlyUncachedModel, + UncachedModel, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts index f4c13c610..85109479e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.d.ts @@ -19,13 +19,13 @@ export interface JSValueHolder extends SwiftHeapObject { optionalValue: any | null; } export type Exports = { - JSValueHolder: { - new(value: any, optionalValue: any | null): JSValueHolder; - } roundTripJSValue(value: any): any; roundTripOptionalJSValue(value: any | null): any | null; roundTripJSValueArray(values: any[]): any[]; roundTripOptionalJSValueArray(values: any[] | null): any[] | null; + JSValueHolder: { + new(value: any, optionalValue: any | null): JSValueHolder; + }, } export type Imports = { jsEchoJSValue(value: any): any; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js index d47fd3e85..ae59008ba 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/JSValue.js @@ -527,7 +527,6 @@ export async function createInstantiator(options, swift) { } } const exports = { - JSValueHolder, roundTripJSValue: function bjs_roundTripJSValue(value) { const [valueKind, valuePayload1, valuePayload2] = __bjs_jsValueLower(value); instance.exports.bjs_roundTripJSValue(valueKind, valuePayload1, valuePayload2); @@ -627,6 +626,7 @@ export async function createInstantiator(options, swift) { } return optResult; }, + JSValueHolder, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts index 7b4cc95e6..c7ff9a39c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.d.ts @@ -16,10 +16,10 @@ export interface GlobalClass extends SwiftHeapObject { } export type Exports = { GlobalAPI: { + globalFunction(): string; GlobalClass: { new(): GlobalClass; - } - globalFunction(): string; + }, }, } export type Imports = { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js index 577fa0ca7..39ecf8d99 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.js @@ -295,13 +295,13 @@ export async function createInstantiator(options, swift) { } const exports = { GlobalAPI: { - GlobalClass, globalFunction: function bjs_GlobalAPI_globalFunction() { instance.exports.bjs_GlobalAPI_globalFunction(); const ret = tmpRetString; tmpRetString = undefined; return ret; }, + GlobalClass, }, }; _exports = exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts index 88485232e..01a392e91 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts @@ -8,12 +8,12 @@ export {}; declare global { namespace GlobalAPI { + function globalFunction(): string; class GlobalClass { constructor(); greet(): string; release(): void; } - function globalFunction(): string; } } @@ -32,16 +32,16 @@ export interface PrivateClass extends SwiftHeapObject { } export type Exports = { GlobalAPI: { + globalFunction(): string; GlobalClass: { new(): GlobalClass; - } - globalFunction(): string; + }, }, PrivateAPI: { + privateFunction(): string; PrivateClass: { new(): PrivateClass; - } - privateFunction(): string; + }, }, } export type Imports = { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js index e15c7bcfb..62d7651e8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.js @@ -322,22 +322,22 @@ export async function createInstantiator(options, swift) { } const exports = { GlobalAPI: { - GlobalClass, globalFunction: function bjs_GlobalAPI_globalFunction() { instance.exports.bjs_GlobalAPI_globalFunction(); const ret = tmpRetString; tmpRetString = undefined; return ret; }, + GlobalClass, }, PrivateAPI: { - PrivateClass, privateFunction: function bjs_PrivateAPI_privateFunction() { instance.exports.bjs_PrivateAPI_privateFunction(); const ret = tmpRetString; tmpRetString = undefined; return ret; }, + PrivateClass, }, }; _exports = exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts index 193857072..89aad5c32 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.d.ts @@ -16,10 +16,10 @@ export interface PrivateClass extends SwiftHeapObject { } export type Exports = { PrivateAPI: { + privateFunction(): string; PrivateClass: { new(): PrivateClass; - } - privateFunction(): string; + }, }, } export type Imports = { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js index e1605fb10..69bfe5ff1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedPrivate.js @@ -295,13 +295,13 @@ export async function createInstantiator(options, swift) { } const exports = { PrivateAPI: { - PrivateClass, privateFunction: function bjs_PrivateAPI_privateFunction() { instance.exports.bjs_PrivateAPI_privateFunction(); const ret = tmpRetString; tmpRetString = undefined; return ret; }, + PrivateClass, }, }; _exports = exports; 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 ae792be4c..ac9ea13c4 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts @@ -89,7 +89,7 @@ export type Exports = { Collections: { Container: { new(): Container; - } + }, }, MyModule: { Utils: { @@ -104,7 +104,7 @@ export type Exports = { Converters: { Converter: { new(): Converter; - } + }, }, }, __Swift: { @@ -113,9 +113,9 @@ export type Exports = { new(name: string): Greeter; makeDefault(): Greeter; readonly defaultGreeting: string; - } + }, UUID: { - } + }, }, }, } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts index 4c02c18b3..debd3ffcf 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.d.ts @@ -36,7 +36,7 @@ export type Exports = { Collections: { Container: { new(): Container; - } + }, }, MyModule: { Utils: { @@ -51,7 +51,7 @@ export type Exports = { Converters: { Converter: { new(): Converter; - } + }, }, }, __Swift: { @@ -60,9 +60,9 @@ export type Exports = { new(name: string): Greeter; makeDefault(): Greeter; readonly defaultGreeting: string; - } + }, UUID: { - } + }, }, }, } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.d.ts index 4e966661e..c418ed8a5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.d.ts @@ -30,10 +30,10 @@ export interface Player extends SwiftHeapObject { getTag(): string; } export type Exports = { - User: { - } Player: { - } + }, + User: { + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js index 1fb339f32..972f9ae74 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/NestedType.js @@ -351,12 +351,8 @@ export async function createInstantiator(options, swift) { structHelpers.Player_Stats = Player_StatsHelpers; const exports = { - User, Player, - Player: { - }, - User: { - }, + User, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts index c4a22ac0c..0f64324cd 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.d.ts @@ -42,12 +42,6 @@ export interface WithOptionalJSClass { childOrNull: WithOptionalJSClass | null; } export type Exports = { - Greeter: { - new(name: string | null): Greeter; - } - OptionalPropertyHolder: { - new(): OptionalPropertyHolder; - } roundTripOptionalClass(value: Greeter | null): Greeter | null; testOptionalPropertyRoundtrip(holder: OptionalPropertyHolder | null): OptionalPropertyHolder | null; roundTripExportedOptionalJSObject(value: any | null): any | null; @@ -71,6 +65,12 @@ export type Exports = { roundTripAlias(age: number | null): number | null; roundTripOptionalAlias(name: string | null): string | null; testMixedOptionals(firstName: string | null, lastName: string | null, age: number | null, active: boolean): string | null; + Greeter: { + new(name: string | null): Greeter; + }, + OptionalPropertyHolder: { + new(): OptionalPropertyHolder; + }, } export type Imports = { WithOptionalJSClass: { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js index 956582377..5a253cdc0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Optionals.js @@ -685,8 +685,6 @@ export async function createInstantiator(options, swift) { } } const exports = { - Greeter, - OptionalPropertyHolder, roundTripOptionalClass: function bjs_roundTripOptionalClass(value) { const isSome = value != null; let result; @@ -972,6 +970,8 @@ export async function createInstantiator(options, swift) { tmpRetString = undefined; return optResult; }, + Greeter, + OptionalPropertyHolder, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts index 8f65849ab..5872a3020 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.d.ts @@ -31,11 +31,11 @@ export interface PropertyHolder extends SwiftHeapObject { observedProperty: number; } export type Exports = { - PropertyHolder: { - new(intValue: number, floatValue: number, doubleValue: number, boolValue: boolean, stringValue: string, jsObject: any): PropertyHolder; - } createPropertyHolder(intValue: number, floatValue: number, doubleValue: number, boolValue: boolean, stringValue: string, jsObject: any): PropertyHolder; testPropertyHolder(holder: PropertyHolder): string; + PropertyHolder: { + new(intValue: number, floatValue: number, doubleValue: number, boolValue: boolean, stringValue: string, jsObject: any): PropertyHolder; + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js index 0070d0dbe..61560134a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PropertyTypes.js @@ -406,7 +406,6 @@ export async function createInstantiator(options, swift) { } } const exports = { - PropertyHolder, createPropertyHolder: function bjs_createPropertyHolder(intValue, floatValue, doubleValue, boolValue, stringValue, jsObject) { const stringValueBytes = textEncoder.encode(stringValue); const stringValueId = swift.memory.retain(stringValueBytes); @@ -419,6 +418,7 @@ export async function createInstantiator(options, swift) { tmpRetString = undefined; return ret; }, + PropertyHolder, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts index 27cd9212b..a413fa500 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.d.ts @@ -96,21 +96,21 @@ export interface DelegateManager extends SwiftHeapObject { delegatesByName: Record; } export type Exports = { - Helper: { - new(value: number): Helper; - } - MyViewController: { - new(delegate: MyViewControllerDelegate): MyViewController; - } - DelegateManager: { - new(delegates: MyViewControllerDelegate[]): DelegateManager; - } processDelegates(delegates: MyViewControllerDelegate[]): MyViewControllerDelegate[]; processDelegatesByName(delegates: Record): Record; Direction: DirectionObject ExampleEnum: ExampleEnumObject Result: ResultObject Priority: PriorityObject + DelegateManager: { + new(delegates: MyViewControllerDelegate[]): DelegateManager; + }, + Helper: { + new(value: number): Helper; + }, + MyViewController: { + new(delegate: MyViewControllerDelegate): MyViewController; + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js index 999210eb5..b2a894ffa 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Protocol.js @@ -793,9 +793,6 @@ export async function createInstantiator(options, swift) { enumHelpers.Result = ResultHelpers; const exports = { - Helper, - MyViewController, - DelegateManager, processDelegates: function bjs_processDelegates(delegates) { for (const elem of delegates) { const objId = swift.memory.retain(elem); @@ -847,6 +844,9 @@ export async function createInstantiator(options, swift) { ExampleEnum: ExampleEnumValues, Result: ResultValues, Priority: PriorityValues, + DelegateManager, + Helper, + MyViewController, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts index 6b7a9d28d..7d5a3c9aa 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.d.ts @@ -19,13 +19,13 @@ export interface Widget extends SwiftHeapObject { name: string; } export type Exports = { - Widget: { - new(name: string): Widget; - } processRenderable(item: Renderable, transform: (arg0: Renderable) => string): string; makeRenderableFactory(defaultName: string): () => Renderable; roundtripRenderable(callback: (arg0: Renderable) => Renderable): (arg0: Renderable) => Renderable; processOptionalRenderable(callback: (arg0: Renderable | null) => string): string; + Widget: { + new(name: string): Widget; + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js index d9c31ed1d..01f9fe0e1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ProtocolInClosure.js @@ -447,7 +447,6 @@ export async function createInstantiator(options, swift) { } } const exports = { - Widget, processRenderable: function bjs_processRenderable(item, transform) { const callbackId = swift.memory.retain(transform); instance.exports.bjs_processRenderable(swift.memory.retain(item), callbackId); @@ -473,6 +472,7 @@ export async function createInstantiator(options, swift) { tmpRetString = undefined; return ret; }, + Widget, }; _exports = exports; return exports; 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..e5602e42d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts @@ -51,15 +51,15 @@ export interface MathUtils extends SwiftHeapObject { multiply(x: number, y: number): number; } export type Exports = { + Calculator: CalculatorObject + APIResult: APIResultObject MathUtils: { new(): MathUtils; subtract(a: number, b: number): number; add(a: number, b: number): number; divide(a: number, b: number): number; readonly pi: number; - } - Calculator: CalculatorObject - APIResult: APIResultObject + }, Utils: { String: { uppercase(text: string): string; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js index d626e9adf..25f989a00 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.js @@ -361,7 +361,6 @@ export async function createInstantiator(options, swift) { globalThis.Utils.String = {}; } const exports = { - MathUtils, Calculator: { ...CalculatorValues, square: function(value) { @@ -388,6 +387,7 @@ export async function createInstantiator(options, swift) { return ret; } }, + MathUtils, Utils: { String: { uppercase: function bjs_Utils_String_static_uppercase(text) { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts index c9cb26910..a168f3ad1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.d.ts @@ -41,15 +41,15 @@ export interface MathUtils extends SwiftHeapObject { multiply(x: number, y: number): number; } export type Exports = { + Calculator: CalculatorObject + APIResult: APIResultObject MathUtils: { new(): MathUtils; subtract(a: number, b: number): number; add(a: number, b: number): number; divide(a: number, b: number): number; readonly pi: number; - } - Calculator: CalculatorObject - APIResult: APIResultObject + }, Utils: { String: { uppercase(text: string): string; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js index 93f1e7ec7..ca4093992 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.js @@ -355,7 +355,6 @@ export async function createInstantiator(options, swift) { enumHelpers.APIResult = APIResultHelpers; const exports = { - MathUtils, Calculator: { ...CalculatorValues, square: function(value) { @@ -382,6 +381,7 @@ export async function createInstantiator(options, swift) { return ret; } }, + MathUtils, Utils: { String: { uppercase: function bjs_Utils_String_static_uppercase(text) { 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..b54e14def 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.d.ts @@ -40,6 +40,7 @@ export interface SwiftHeapObject { export interface PropertyClass extends SwiftHeapObject { } export type Exports = { + PropertyEnum: PropertyEnumObject PropertyClass: { new(): PropertyClass; readonly staticConstant: string; @@ -49,8 +50,7 @@ export type Exports = { computedProperty: string; readonly readOnlyComputed: number; optionalProperty: string | null; - } - PropertyEnum: PropertyEnumObject + }, PropertyNamespace: { readonly namespaceConstant: string; namespaceProperty: string; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js index edf069178..63dd9cba5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.Global.js @@ -367,7 +367,6 @@ export async function createInstantiator(options, swift) { globalThis.PropertyNamespace.Nested = {}; } const exports = { - PropertyClass, PropertyEnum: { ...PropertyEnumValues, get enumProperty() { @@ -397,6 +396,7 @@ export async function createInstantiator(options, swift) { instance.exports.bjs_PropertyEnum_static_computedEnum_set(valueId, valueBytes.length); } }, + PropertyClass, PropertyNamespace: { get namespaceProperty() { instance.exports.bjs_PropertyNamespace_static_namespaceProperty_get(); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts index 4ce689edb..aea927c79 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.d.ts @@ -26,6 +26,7 @@ export interface SwiftHeapObject { export interface PropertyClass extends SwiftHeapObject { } export type Exports = { + PropertyEnum: PropertyEnumObject PropertyClass: { new(): PropertyClass; readonly staticConstant: string; @@ -35,8 +36,7 @@ export type Exports = { computedProperty: string; readonly readOnlyComputed: number; optionalProperty: string | null; - } - PropertyEnum: PropertyEnumObject + }, PropertyNamespace: { readonly namespaceConstant: string; namespaceProperty: string; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js index 64132a3c2..b5680b9b0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticProperties.js @@ -361,7 +361,6 @@ export async function createInstantiator(options, swift) { } } const exports = { - PropertyClass, PropertyEnum: { ...PropertyEnumValues, get enumProperty() { @@ -391,6 +390,7 @@ export async function createInstantiator(options, swift) { instance.exports.bjs_PropertyEnum_static_computedEnum_set(valueId, valueBytes.length); } }, + PropertyClass, PropertyNamespace: { get namespaceProperty() { instance.exports.bjs_PropertyNamespace_static_namespaceProperty_get(); diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StructWithNestedTypes.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StructWithNestedTypes.d.ts new file mode 100644 index 000000000..fe4708fd8 --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StructWithNestedTypes.d.ts @@ -0,0 +1,73 @@ +// 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 interface Shape { + label: string; +} +export interface Widget { + name: string; +} +export type KindObject = typeof Shape.KindValues; + +export type VariantObject = typeof Widget.VariantValues; + +export type AlignmentObject = typeof Widget.Layout.AlignmentValues; + +export namespace Shape { + const KindValues: { + readonly Circle: "circle"; + readonly Square: "square"; + }; + type KindTag = typeof KindValues[keyof typeof KindValues]; +} +export namespace Widget { + const VariantValues: { + readonly Button: "button"; + readonly Slider: "slider"; + }; + type VariantTag = typeof VariantValues[keyof typeof VariantValues]; + export interface Bounds { + width: number; + height: number; + } + export interface Layout { + padding: number; + } + export namespace Layout { + const AlignmentValues: { + readonly Leading: "leading"; + readonly Trailing: "trailing"; + }; + type AlignmentTag = typeof AlignmentValues[keyof typeof AlignmentValues]; + } +} +export type Exports = { + Shape: { + init(label: string): Shape; + Kind: KindObject + }, + Widget: { + init(name: string): Widget; + Variant: VariantObject + Bounds: { + init(width: number, height: number): Widget.Bounds; + readonly dimensions: number; + zero(): Widget.Bounds; + }, + Layout: { + Alignment: AlignmentObject + }, + }, +} +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/StructWithNestedTypes.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StructWithNestedTypes.js new file mode 100644 index 000000000..ee5cc0a3e --- /dev/null +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StructWithNestedTypes.js @@ -0,0 +1,364 @@ +// 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 const KindValues = { + Circle: "circle", + Square: "square", +}; + +export const VariantValues = { + Button: "button", + Slider: "slider", +}; + +export const AlignmentValues = { + Leading: "leading", + Trailing: "trailing", +}; + +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 = []; + let taStack = []; + const enumHelpers = {}; + const structHelpers = {}; + + let _exports = null; + let bjs = null; + const __bjs_createShapeHelpers = () => ({ + lower: (value) => { + const bytes = textEncoder.encode(value.label); + const id = swift.memory.retain(bytes); + i32Stack.push(bytes.length); + i32Stack.push(id); + }, + lift: () => { + const string = strStack.pop(); + return { label: string }; + } + }); + const __bjs_createWidgetHelpers = () => ({ + lower: (value) => { + const bytes = textEncoder.encode(value.name); + const id = swift.memory.retain(bytes); + i32Stack.push(bytes.length); + i32Stack.push(id); + }, + lift: () => { + const string = strStack.pop(); + return { name: string }; + } + }); + const __bjs_createWidget_LayoutHelpers = () => ({ + lower: (value) => { + i32Stack.push((value.padding | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + return { padding: int }; + } + }); + const __bjs_createWidget_BoundsHelpers = () => ({ + lower: (value) => { + i32Stack.push((value.width | 0)); + i32Stack.push((value.height | 0)); + }, + lift: () => { + const int = i32Stack.pop(); + const int1 = i32Stack.pop(); + return { width: int1, height: int }; + } + }); + + 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 >>> 0); + 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 >>> 0, len >>> 0); + 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(); + } + const taCtors = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; + bjs["swift_js_push_typed_array"] = function(kind, ptr, count) { + const Ctor = taCtors[kind]; + const byteLen = count * Ctor.BYTES_PER_ELEMENT; + const copy = memory.buffer.slice(ptr, ptr + byteLen); + taStack.push(Array.from(new Ctor(copy))); + } + bjs["swift_js_struct_lower_Shape"] = function(objectId) { + structHelpers.Shape.lower(swift.memory.getObject(objectId)); + } + bjs["swift_js_struct_lift_Shape"] = function() { + const value = structHelpers.Shape.lift(); + return swift.memory.retain(value); + } + bjs["swift_js_struct_lower_Widget"] = function(objectId) { + structHelpers.Widget.lower(swift.memory.getObject(objectId)); + } + bjs["swift_js_struct_lift_Widget"] = function() { + const value = structHelpers.Widget.lift(); + return swift.memory.retain(value); + } + bjs["swift_js_struct_lower_Widget_Layout"] = function(objectId) { + structHelpers.Widget_Layout.lower(swift.memory.getObject(objectId)); + } + bjs["swift_js_struct_lift_Widget_Layout"] = function() { + const value = structHelpers.Widget_Layout.lift(); + return swift.memory.retain(value); + } + bjs["swift_js_struct_lower_Widget_Bounds"] = function(objectId) { + structHelpers.Widget_Bounds.lower(swift.memory.getObject(objectId)); + } + bjs["swift_js_struct_lift_Widget_Bounds"] = function() { + const value = structHelpers.Widget_Bounds.lift(); + return swift.memory.retain(value); + } + const __bjs_promiseSettlers = Symbol("JavaScriptKit.promiseSettlers"); + bjs["swift_js_make_promise"] = function() { + let resolve, reject; + const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); + promise[__bjs_promiseSettlers] = { resolve, reject }; + return swift.memory.retain(promise); + } + 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) {} + }, + 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 ShapeHelpers = __bjs_createShapeHelpers(); + structHelpers.Shape = ShapeHelpers; + + const WidgetHelpers = __bjs_createWidgetHelpers(); + structHelpers.Widget = WidgetHelpers; + + const Widget_LayoutHelpers = __bjs_createWidget_LayoutHelpers(); + structHelpers.Widget_Layout = Widget_LayoutHelpers; + + const Widget_BoundsHelpers = __bjs_createWidget_BoundsHelpers(); + structHelpers.Widget_Bounds = Widget_BoundsHelpers; + + const exports = { + Shape: { + init: function(label) { + const labelBytes = textEncoder.encode(label); + const labelId = swift.memory.retain(labelBytes); + instance.exports.bjs_Shape_init(labelId, labelBytes.length); + const structValue = structHelpers.Shape.lift(); + return structValue; + }, + Kind: KindValues, + }, + Widget: { + init: function(name) { + const nameBytes = textEncoder.encode(name); + const nameId = swift.memory.retain(nameBytes); + instance.exports.bjs_Widget_init(nameId, nameBytes.length); + const structValue = structHelpers.Widget.lift(); + return structValue; + }, + Variant: VariantValues, + Bounds: { + init: function(width, height) { + instance.exports.bjs_Widget_Bounds_init(width, height); + const structValue = structHelpers.Widget_Bounds.lift(); + return structValue; + }, + get dimensions() { + const ret = instance.exports.bjs_Widget_Bounds_static_dimensions_get(); + return ret; + }, + zero: function() { + instance.exports.bjs_Widget_Bounds_static_zero(); + const structValue = structHelpers.Widget_Bounds.lift(); + return structValue; + }, + }, + Layout: { + Alignment: AlignmentValues, + }, + }, + }; + _exports = exports; + return exports; + }, + } +} \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts index 6d590950c..2f56a1cb8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.d.ts @@ -23,16 +23,16 @@ export interface PublicGreeter extends SwiftHeapObject { export interface PackageGreeter extends SwiftHeapObject { } export type Exports = { + takeGreeter(greeter: Greeter): void; Greeter: { new(name: string): Greeter; greetAnonymously(): string; readonly defaultGreeting: string; - } - PublicGreeter: { - } + }, PackageGreeter: { - } - takeGreeter(greeter: Greeter): void; + }, + PublicGreeter: { + }, } export type Imports = { jsRoundTripGreeter(greeter: Greeter): Greeter; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js index 7f9fb8a20..be63f59be 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js @@ -374,12 +374,12 @@ export async function createInstantiator(options, swift) { } const exports = { - Greeter, - PublicGreeter, - PackageGreeter, takeGreeter: function bjs_takeGreeter(greeter) { instance.exports.bjs_takeGreeter(greeter.pointer); }, + Greeter, + PackageGreeter, + PublicGreeter, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts index be62eeedd..70f23c11a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts @@ -64,12 +64,6 @@ export interface Person extends SwiftHeapObject { export interface TestProcessor extends SwiftHeapObject { } export type Exports = { - Person: { - new(name: string): Person; - } - TestProcessor: { - new(transform: (arg0: string) => string): TestProcessor; - } roundtripAnimal(animalClosure: (arg0: Animal) => Animal): (arg0: Animal) => Animal; roundtripOptionalAnimal(animalClosure: (arg0: Animal | null) => Animal | null): (arg0: Animal | null) => Animal | null; roundtripString(stringClosure: (arg0: string) => string): (arg0: string) => string; @@ -105,7 +99,13 @@ export type Exports = { APIResult: APIResultObject Animal: { init(type: string): Animal; - } + }, + Person: { + new(name: string): Person; + }, + TestProcessor: { + new(transform: (arg0: string) => string): TestProcessor; + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js index f5912b3f5..f3b9d987c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.js @@ -1422,8 +1422,6 @@ export async function createInstantiator(options, swift) { enumHelpers.APIResult = APIResultHelpers; const exports = { - Person, - TestProcessor, roundtripAnimal: function bjs_roundtripAnimal(animalClosure) { const callbackId = swift.memory.retain(animalClosure); const ret = instance.exports.bjs_roundtripAnimal(callbackId); @@ -1576,6 +1574,8 @@ export async function createInstantiator(options, swift) { return structValue; }, }, + Person, + TestProcessor, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts index bf4ebc71f..14ddf714e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts @@ -63,24 +63,24 @@ export interface Greeter extends SwiftHeapObject { name: string; } export type Exports = { - Greeter: { - new(name: string): Greeter; - } roundtrip(session: Person): Person; roundtripContainer(container: Container): Container; Precision: PrecisionObject - DataPoint: { - init(x: number, y: number, label: string, optCount: number | null, optFlag: boolean | null): DataPoint; - readonly dimensions: number; - origin(): DataPoint; - } ConfigStruct: { readonly maxRetries: number; defaultConfig: string; timeout: number; readonly computedSetting: string; update(timeout: number): number; - } + }, + DataPoint: { + init(x: number, y: number, label: string, optCount: number | null, optFlag: boolean | null): DataPoint; + readonly dimensions: number; + origin(): DataPoint; + }, + Greeter: { + new(name: string): Greeter; + }, } export type Imports = { } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js index b25010a23..44ae8a39d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js @@ -600,7 +600,6 @@ export async function createInstantiator(options, swift) { structHelpers.Vector2D = Vector2DHelpers; const exports = { - Greeter, roundtrip: function bjs_roundtrip(session) { structHelpers.Person.lower(session); instance.exports.bjs_roundtrip(); @@ -614,26 +613,6 @@ export async function createInstantiator(options, swift) { return structValue; }, Precision: PrecisionValues, - DataPoint: { - init: function(x, y, label, optCount, optFlag) { - const labelBytes = textEncoder.encode(label); - const labelId = swift.memory.retain(labelBytes); - const isSome = optCount != null; - const isSome1 = optFlag != null; - instance.exports.bjs_DataPoint_init(x, y, labelId, labelBytes.length, +isSome, isSome ? optCount : 0, +isSome1, isSome1 ? optFlag ? 1 : 0 : 0); - const structValue = structHelpers.DataPoint.lift(); - return structValue; - }, - get dimensions() { - const ret = instance.exports.bjs_DataPoint_static_dimensions_get(); - return ret; - }, - origin: function() { - instance.exports.bjs_DataPoint_static_origin(); - const structValue = structHelpers.DataPoint.lift(); - return structValue; - }, - }, ConfigStruct: { get maxRetries() { const ret = instance.exports.bjs_ConfigStruct_static_maxRetries_get(); @@ -668,6 +647,27 @@ export async function createInstantiator(options, swift) { return ret; }, }, + DataPoint: { + init: function(x, y, label, optCount, optFlag) { + const labelBytes = textEncoder.encode(label); + const labelId = swift.memory.retain(labelBytes); + const isSome = optCount != null; + const isSome1 = optFlag != null; + instance.exports.bjs_DataPoint_init(x, y, labelId, labelBytes.length, +isSome, isSome ? optCount : 0, +isSome1, isSome1 ? optFlag ? 1 : 0 : 0); + const structValue = structHelpers.DataPoint.lift(); + return structValue; + }, + get dimensions() { + const ret = instance.exports.bjs_DataPoint_static_dimensions_get(); + return ret; + }, + origin: function() { + instance.exports.bjs_DataPoint_static_origin(); + const structValue = structHelpers.DataPoint.lift(); + return structValue; + }, + }, + Greeter, }; _exports = exports; return exports; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts index 4f9aa4e4a..5a4ee78ce 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/UnsafePointer.d.ts @@ -25,7 +25,7 @@ export type Exports = { roundTripPointerFields(value: PointerFields): PointerFields; PointerFields: { init(raw: number, mutRaw: number, opaque: number, ptr: number, mutPtr: number): PointerFields; - } + }, } export type Imports = { } diff --git a/Tests/BridgeJSRuntimeTests/ExportAPITests.swift b/Tests/BridgeJSRuntimeTests/ExportAPITests.swift index 282b7cc60..92bf7ff68 100644 --- a/Tests/BridgeJSRuntimeTests/ExportAPITests.swift +++ b/Tests/BridgeJSRuntimeTests/ExportAPITests.swift @@ -1359,6 +1359,27 @@ enum GraphOperations { @JS static func roundtripMetadata(_ m: Metadata) -> Metadata { m } } +@JS class NestedTypeHost { + @JS enum Variant: String { + case primary + case secondary + } + + @JS struct Label { + var text: String + + @JS init(text: String) { + self.text = text + } + } + + @JS init() {} + + @JS func describe() -> String { + "host" + } +} + class ExportAPITests: XCTestCase { func testAll() { var hasDeinitGreeter = false diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift index 8968773a4..ff22e7fbe 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift @@ -5797,6 +5797,9 @@ public func _bjs_NestedStructGroupB_static_roundtripMetadata() -> Void { #endif } +extension NestedTypeHost.Variant: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum { +} + extension LightColor: _BridgedSwiftCaseEnum { @_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 { return bridgeJSRawValue @@ -6573,6 +6576,63 @@ fileprivate func _bjs_struct_lift_NestedStructGroupB_Metadata_extern() -> Int32 return _bjs_struct_lift_NestedStructGroupB_Metadata_extern() } +extension NestedTypeHost.Label: _BridgedSwiftStruct { + @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> NestedTypeHost.Label { + let text = String.bridgeJSStackPop() + return NestedTypeHost.Label(text: text) + } + + @_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() { + self.text.bridgeJSStackPush() + } + + init(unsafelyCopying jsObject: JSObject) { + _bjs_struct_lower_NestedTypeHost_Label(jsObject.bridgeJSLowerParameter()) + self = Self.bridgeJSStackPop() + } + + func toJSObject() -> JSObject { + let __bjs_self = self + __bjs_self.bridgeJSStackPush() + return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_NestedTypeHost_Label())) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_NestedTypeHost_Label") +fileprivate func _bjs_struct_lower_NestedTypeHost_Label_extern(_ objectId: Int32) -> Void +#else +fileprivate func _bjs_struct_lower_NestedTypeHost_Label_extern(_ objectId: Int32) -> Void { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lower_NestedTypeHost_Label(_ objectId: Int32) -> Void { + return _bjs_struct_lower_NestedTypeHost_Label_extern(objectId) +} + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_NestedTypeHost_Label") +fileprivate func _bjs_struct_lift_NestedTypeHost_Label_extern() -> Int32 +#else +fileprivate func _bjs_struct_lift_NestedTypeHost_Label_extern() -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_struct_lift_NestedTypeHost_Label() -> Int32 { + return _bjs_struct_lift_NestedTypeHost_Label_extern() +} + +@_expose(wasm, "bjs_NestedTypeHost_Label_init") +@_cdecl("bjs_NestedTypeHost_Label_init") +public func _bjs_NestedTypeHost_Label_init(_ textBytes: Int32, _ textLength: Int32) -> Void { + #if arch(wasm32) + let ret = NestedTypeHost.Label(text: String.bridgeJSLiftParameter(textBytes, textLength)) + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + extension Point: _BridgedSwiftStruct { @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Point { let y = Int.bridgeJSStackPop() @@ -12882,6 +12942,59 @@ fileprivate func _bjs_TextProcessor_wrap_extern(_ pointer: UnsafeMutableRawPoint return _bjs_TextProcessor_wrap_extern(pointer) } +@_expose(wasm, "bjs_NestedTypeHost_init") +@_cdecl("bjs_NestedTypeHost_init") +public func _bjs_NestedTypeHost_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = NestedTypeHost() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NestedTypeHost_describe") +@_cdecl("bjs_NestedTypeHost_describe") +public func _bjs_NestedTypeHost_describe(_ _self: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + let ret = NestedTypeHost.bridgeJSLiftParameter(_self).describe() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NestedTypeHost_deinit") +@_cdecl("bjs_NestedTypeHost_deinit") +public func _bjs_NestedTypeHost_deinit(_ pointer: UnsafeMutableRawPointer) -> Void { + #if arch(wasm32) + Unmanaged.fromOpaque(pointer).release() + #else + fatalError("Only available on WebAssembly") + #endif +} + +extension NestedTypeHost: ConvertibleToJSValue, _BridgedSwiftHeapObject, _BridgedSwiftProtocolExportable { + var jsValue: JSValue { + return .object(JSObject(id: UInt32(bitPattern: _bjs_NestedTypeHost_wrap(Unmanaged.passRetained(self).toOpaque())))) + } + consuming func bridgeJSLowerAsProtocolReturn() -> Int32 { + _bjs_NestedTypeHost_wrap(Unmanaged.passRetained(self).toOpaque()) + } +} + +#if arch(wasm32) +@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_NestedTypeHost_wrap") +fileprivate func _bjs_NestedTypeHost_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 +#else +fileprivate func _bjs_NestedTypeHost_wrap_extern(_ pointer: UnsafeMutableRawPointer) -> Int32 { + fatalError("Only available on WebAssembly") +} +#endif +@inline(never) fileprivate func _bjs_NestedTypeHost_wrap(_ pointer: UnsafeMutableRawPointer) -> Int32 { + return _bjs_NestedTypeHost_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 { diff --git a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json index 25fd27d9f..018eceded 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json @@ -4705,6 +4705,43 @@ ], "swiftCallName" : "TextProcessor" }, + { + "constructor" : { + "abiName" : "bjs_NestedTypeHost_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_NestedTypeHost_describe", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "describe", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } + } + ], + "name" : "NestedTypeHost", + "properties" : [ + + ], + "swiftCallName" : "NestedTypeHost" + }, { "constructor" : { "abiName" : "bjs_OptionalHolder_init", @@ -10002,6 +10039,36 @@ { "associatedValues" : [ + ], + "name" : "primary" + }, + { + "associatedValues" : [ + + ], + "name" : "secondary" + } + ], + "emitStyle" : "const", + "name" : "Variant", + "namespace" : [ + "NestedTypeHost" + ], + "rawType" : "String", + "staticMethods" : [ + + ], + "staticProperties" : [ + + ], + "swiftCallName" : "NestedTypeHost.Variant", + "tsFullPath" : "NestedTypeHost.Variant" + }, + { + "cases" : [ + { + "associatedValues" : [ + ], "name" : "red" }, @@ -18037,6 +18104,50 @@ ], "swiftCallName" : "NestedStructGroupB.Metadata" }, + { + "constructor" : { + "abiName" : "bjs_NestedTypeHost_Label_init", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "parameters" : [ + { + "label" : "text", + "name" : "text", + "type" : { + "string" : { + + } + } + } + ] + }, + "methods" : [ + + ], + "name" : "Label", + "namespace" : [ + "NestedTypeHost" + ], + "properties" : [ + { + "isReadonly" : true, + "isStatic" : false, + "name" : "text", + "namespace" : [ + "NestedTypeHost" + ], + "type" : { + "string" : { + + } + } + } + ], + "swiftCallName" : "NestedTypeHost.Label" + }, { "methods" : [ diff --git a/Tests/prelude.mjs b/Tests/prelude.mjs index f431209dd..1bd824da5 100644 --- a/Tests/prelude.mjs +++ b/Tests/prelude.mjs @@ -683,6 +683,14 @@ function BridgeJSRuntimeTests_runJsWorks(instance, exports) { testServer.call(exports.Networking.APIV2.Internal.SupportedMethod.Post); testServer.release(); + const nestedHost = new exports.NestedTypeHost(); + assert.equal(nestedHost.describe(), "host"); + assert.equal(exports.NestedTypeHost.Variant.Primary, "primary"); + assert.equal(exports.NestedTypeHost.Variant.Secondary, "secondary"); + const hostLabel = exports.NestedTypeHost.Label.init("Save"); + assert.equal(hostLabel.text, "Save"); + nestedHost.release(); + const s1 = { tag: exports.APIResult.Tag.Success, param0: "Cześć 🙋‍♂️" }; const f1 = { tag: exports.APIResult.Tag.Failure, param0: 42 }; const i1 = { tag: APIResultValues.Tag.Info }; From 22905075f8b61834810babe5fb9a2f613f22f398 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Wed, 1 Jul 2026 12:59:09 +0100 Subject: [PATCH 15/20] Fix `JavaScriptEventLoop` for Embedded Swift in `main` toolchain snapshots (#784) --- .../JavaScriptEventLoop+ExecutorFactory.swift | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/Sources/JavaScriptEventLoop/JavaScriptEventLoop+ExecutorFactory.swift b/Sources/JavaScriptEventLoop/JavaScriptEventLoop+ExecutorFactory.swift index 17aedca3b..d00672059 100644 --- a/Sources/JavaScriptEventLoop/JavaScriptEventLoop+ExecutorFactory.swift +++ b/Sources/JavaScriptEventLoop/JavaScriptEventLoop+ExecutorFactory.swift @@ -40,22 +40,13 @@ extension JavaScriptEventLoop: SchedulingExecutor { tolerance: C.Duration?, clock: C ) { - #if hasFeature(Embedded) - #if compiler(>=6.4) - // In Embedded Swift, ContinuousClock and SuspendingClock are unavailable. - // Hand-off the scheduling work to the Clock implementation for custom clocks. - clock.enqueue( - job, - on: self, - at: clock.now.advanced(by: delay), - tolerance: tolerance - ) + #if $Embedded + // ContinuousClock and SuspendingClock are unavailable in Embedded Swift, + // but Swift.Duration is, and every standard clock uses it. + guard let duration = delay as? Duration else { + fatalError("Unsupported clock type; only Duration-based clocks are supported in Embedded Swift") + } #else - fatalError( - "Delayed enqueue requires Swift 6.4+ in Embedded mode" - ) - #endif // #if compiler(>=6.4) (Embedded) - #else // #if hasFeature(Embedded) let duration: Duration if let _ = clock as? ContinuousClock { duration = delay as! ContinuousClock.Duration @@ -64,12 +55,12 @@ extension JavaScriptEventLoop: SchedulingExecutor { } else { fatalError("Unsupported clock type; only ContinuousClock and SuspendingClock are supported") } + #endif let milliseconds = Self.delayInMilliseconds(from: duration) self.enqueue( UnownedJob(job), withDelay: milliseconds ) - #endif // #if hasFeature(Embedded) } private static func delayInMilliseconds(from swiftDuration: Duration) -> Double { From 86097064bb078276cbd314e56141655465e9ddf9 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Wed, 1 Jul 2026 23:46:02 +0200 Subject: [PATCH 16/20] BridgeJS: Fix static property call expression for nested structs and enums --- Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift | 4 ++-- .../BridgeJSCodegenTests/ClassWithNestedTypes.swift | 2 +- .../BridgeJSCodegenTests/StructWithNestedTypes.swift | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index 663c2362e..2cc551857 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -560,7 +560,7 @@ public class ExportSwift { func callName(for property: ExportedProperty) -> String { switch self { case .enumStatic(let enumDef): - return property.callName(prefix: enumDef.swiftCallName) + return "\(enumDef.swiftCallName).\(property.name)" case .classStatic(let klass): // property.callName() would use staticContext (the ABI name) as prefix; // use swiftCallName directly so the emitted expression is valid Swift. @@ -568,7 +568,7 @@ public class ExportSwift { case .classInstance: return property.callName() case .structStatic(let structDef): - return property.callName(prefix: structDef.swiftCallName) + return "\(structDef.swiftCallName).\(property.name)" } } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.swift index 3ae08e13a..52c633045 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ClassWithNestedTypes.swift @@ -62,7 +62,7 @@ public func _bjs_Account_Credentials_init(_ tokenBytes: Int32, _ tokenLength: In @_cdecl("bjs_Account_Credentials_static_maxLength_get") public func _bjs_Account_Credentials_static_maxLength_get() -> Int32 { #if arch(wasm32) - let ret = Account_Credentials.maxLength + let ret = Account.Credentials.maxLength return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.swift index f8843b7cd..ad99f0a03 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/StructWithNestedTypes.swift @@ -230,7 +230,7 @@ public func _bjs_Widget_Bounds_init(_ width: Int32, _ height: Int32) -> Void { @_cdecl("bjs_Widget_Bounds_static_dimensions_get") public func _bjs_Widget_Bounds_static_dimensions_get() -> Int32 { #if arch(wasm32) - let ret = Widget_Bounds.dimensions + let ret = Widget.Bounds.dimensions return ret.bridgeJSLowerReturn() #else fatalError("Only available on WebAssembly") From 79a58f210b6a66e1e171f3d7d564d8faafb9b099 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Wed, 1 Jul 2026 23:46:02 +0200 Subject: [PATCH 17/20] BridgeJS: Add runtime coverage for nested static members --- .../BridgeJSRuntimeTests/ExportAPITests.swift | 6 +++ .../Generated/BridgeJS.swift | 22 +++++++++++ .../Generated/JavaScript/BridgeJS.json | 39 +++++++++++++++++++ Tests/prelude.mjs | 2 + 4 files changed, 69 insertions(+) diff --git a/Tests/BridgeJSRuntimeTests/ExportAPITests.swift b/Tests/BridgeJSRuntimeTests/ExportAPITests.swift index 92bf7ff68..5a852a23d 100644 --- a/Tests/BridgeJSRuntimeTests/ExportAPITests.swift +++ b/Tests/BridgeJSRuntimeTests/ExportAPITests.swift @@ -1371,6 +1371,12 @@ enum GraphOperations { @JS init(text: String) { self.text = text } + + @JS static var maxLength: Int { 64 } + + @JS static func untitled() -> Label { + Label(text: "untitled") + } } @JS init() {} diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift index ff22e7fbe..a3104e685 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift @@ -6633,6 +6633,28 @@ public func _bjs_NestedTypeHost_Label_init(_ textBytes: Int32, _ textLength: Int #endif } +@_expose(wasm, "bjs_NestedTypeHost_Label_static_maxLength_get") +@_cdecl("bjs_NestedTypeHost_Label_static_maxLength_get") +public func _bjs_NestedTypeHost_Label_static_maxLength_get() -> Int32 { + #if arch(wasm32) + let ret = NestedTypeHost.Label.maxLength + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_NestedTypeHost_Label_static_untitled") +@_cdecl("bjs_NestedTypeHost_Label_static_untitled") +public func _bjs_NestedTypeHost_Label_static_untitled() -> Void { + #if arch(wasm32) + let ret = NestedTypeHost.Label.untitled() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + extension Point: _BridgedSwiftStruct { @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Point { let y = Int.bridgeJSStackPop() diff --git a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json index 018eceded..451a3213d 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json +++ b/Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json @@ -18125,7 +18125,28 @@ ] }, "methods" : [ + { + "abiName" : "bjs_NestedTypeHost_Label_static_untitled", + "effects" : { + "isAsync" : false, + "isStatic" : true, + "isThrows" : false + }, + "name" : "untitled", + "parameters" : [ + ], + "returnType" : { + "swiftStruct" : { + "_0" : "NestedTypeHost.Label" + } + }, + "staticContext" : { + "structName" : { + "_0" : "NestedTypeHost_Label" + } + } + } ], "name" : "Label", "namespace" : [ @@ -18144,6 +18165,24 @@ } } + }, + { + "isReadonly" : true, + "isStatic" : true, + "name" : "maxLength", + "staticContext" : { + "structName" : { + "_0" : "NestedTypeHost_Label" + } + }, + "type" : { + "integer" : { + "_0" : { + "isSigned" : true, + "width" : "word" + } + } + } } ], "swiftCallName" : "NestedTypeHost.Label" diff --git a/Tests/prelude.mjs b/Tests/prelude.mjs index 1bd824da5..887510e65 100644 --- a/Tests/prelude.mjs +++ b/Tests/prelude.mjs @@ -689,6 +689,8 @@ function BridgeJSRuntimeTests_runJsWorks(instance, exports) { assert.equal(exports.NestedTypeHost.Variant.Secondary, "secondary"); const hostLabel = exports.NestedTypeHost.Label.init("Save"); assert.equal(hostLabel.text, "Save"); + assert.equal(exports.NestedTypeHost.Label.maxLength, 64); + assert.equal(exports.NestedTypeHost.Label.untitled().text, "untitled"); nestedHost.release(); const s1 = { tag: exports.APIResult.Tag.Success, param0: "Cześć 🙋‍♂️" }; From bc356b5385c618bd30927c2ef0b9f8165751d006 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Wed, 8 Jul 2026 17:21:53 +0200 Subject: [PATCH 18/20] BridgeJS: Unify optional stack encoding to presence-flag form --- .../Sources/BridgeJSLink/JSGlueGen.swift | 59 ------------------- .../__Snapshots__/BridgeJSLinkTests/Alias.js | 10 ++-- .../BridgeJSLinkTests/EnumAssociatedValue.js | 10 ++-- .../JavaScriptKit/BridgeJSIntrinsics.swift | 24 ++------ 4 files changed, 16 insertions(+), 87 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift index 6e7bd7628..8ef7bbeb4 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift @@ -2195,35 +2195,6 @@ struct IntrinsicJSFragment: Sendable { wrappedType: BridgeType, kind: JSOptionalKind ) throws -> IntrinsicJSFragment { - if case .associatedValueEnum(let fullName) = wrappedType { - let base = fullName.components(separatedBy: ".").last ?? fullName - let absenceLiteral = kind.absenceLiteral - return IntrinsicJSFragment( - parameters: [], - printCode: { arguments, context in - let (scope, printer) = (context.scope, context.printer) - let caseIdVar = scope.variable("caseId") - let resultVar = scope.variable("optValue") - - printer.write("const \(caseIdVar) = \(scope.popI32());") - printer.write("let \(resultVar);") - printer.write("if (\(caseIdVar) === -1) {") - printer.indent { - printer.write("\(resultVar) = \(absenceLiteral);") - } - printer.write("} else {") - printer.indent { - printer.write( - "\(resultVar) = \(JSGlueVariableScope.reservedEnumHelpers).\(base).lift(\(caseIdVar));" - ) - } - printer.write("}") - - return [resultVar] - } - ) - } - let absenceLiteral = kind.absenceLiteral return IntrinsicJSFragment( parameters: [], @@ -2261,36 +2232,6 @@ struct IntrinsicJSFragment: Sendable { wrappedType: BridgeType, kind: JSOptionalKind ) throws -> IntrinsicJSFragment { - if case .associatedValueEnum(let fullName) = wrappedType { - let base = fullName.components(separatedBy: ".").last ?? fullName - return IntrinsicJSFragment( - parameters: ["value"], - printCode: { arguments, context in - let (scope, printer) = (context.scope, context.printer) - let value = arguments[0] - let isSomeVar = scope.variable("isSome") - let presenceExpr = kind.presenceCheck(value: value) - - printer.write("const \(isSomeVar) = \(presenceExpr) ? 1 : 0;") - printer.write("if (\(isSomeVar)) {") - printer.indent { - let caseIdVar = scope.variable("caseId") - printer.write( - "const \(caseIdVar) = \(JSGlueVariableScope.reservedEnumHelpers).\(base).lower(\(value));" - ) - scope.emitPushI32Parameter(caseIdVar, printer: printer) - } - printer.write("} else {") - printer.indent { - scope.emitPushI32Parameter("-1", printer: printer) - } - printer.write("}") - - return [] - } - ) - } - return IntrinsicJSFragment( parameters: ["value"], printCode: { arguments, context in diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js index 0b922111b..92fb5a109 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Alias.js @@ -482,9 +482,8 @@ export async function createInstantiator(options, swift) { if (isSome) { const caseId = enumHelpers.InnerTag.lower(elem); i32Stack.push(caseId); - } else { - i32Stack.push(-1); } + i32Stack.push(isSome); } i32Stack.push(xs.length); instance.exports.bjs_roundtripTags(); @@ -495,12 +494,13 @@ export async function createInstantiator(options, swift) { } else { arrayResult = []; for (let i = 0; i < arrayLen; i++) { - const caseId1 = i32Stack.pop(); + const isSome1 = i32Stack.pop(); let optValue; - if (caseId1 === -1) { + if (isSome1 === 0) { optValue = null; } else { - optValue = enumHelpers.InnerTag.lift(caseId1); + const enumValue = enumHelpers.InnerTag.lift(i32Stack.pop()); + optValue = enumValue; } arrayResult.push(optValue); } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js index 8ff3dd90d..36683fd58 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.js @@ -676,9 +676,8 @@ export async function createInstantiator(options, swift) { if (isSome) { const caseId = enumHelpers.APIResult.lower(value.param0); i32Stack.push(caseId); - } else { - i32Stack.push(-1); } + i32Stack.push(isSome); return OptionalAllTypesResultValues.Tag.OptNestedEnum; } case OptionalAllTypesResultValues.Tag.OptArray: { @@ -738,12 +737,13 @@ export async function createInstantiator(options, swift) { return { tag: OptionalAllTypesResultValues.Tag.OptJSObject, param0: optValue }; } case OptionalAllTypesResultValues.Tag.OptNestedEnum: { - const caseId = i32Stack.pop(); + const isSome = i32Stack.pop(); let optValue; - if (caseId === -1) { + if (isSome === 0) { optValue = null; } else { - optValue = enumHelpers.APIResult.lift(caseId); + const enumValue = enumHelpers.APIResult.lift(i32Stack.pop()); + optValue = enumValue; } return { tag: OptionalAllTypesResultValues.Tag.OptNestedEnum, param0: optValue }; } diff --git a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift index 1fbdff0b8..a07ca0152 100644 --- a/Sources/JavaScriptKit/BridgeJSIntrinsics.swift +++ b/Sources/JavaScriptKit/BridgeJSIntrinsics.swift @@ -1100,23 +1100,6 @@ extension _BridgedSwiftAssociatedValueEnum { _swift_js_push_i32(bridgeJSStackPushPayload()) } - public static func bridgeJSStackPopAsOptional() -> Self? { - let discriminator = _swift_js_pop_i32() - if discriminator == -1 { - return nil - } - return bridgeJSStackPopPayload(discriminator) - } - - public static func bridgeJSStackPushAsOptional(_ value: consuming Self?) { - switch consume value { - case .none: - _swift_js_push_i32(-1) - case .some(let value): - _swift_js_push_i32(value.bridgeJSStackPushPayload()) - } - } - @_spi(BridgeJS) public static func bridgeJSLiftParameter(_ caseId: Int32) -> Self { return bridgeJSStackPopPayload(caseId) } @@ -2378,7 +2361,12 @@ extension _BridgedAsOptional where Wrapped: _BridgedSwiftAssociatedValueEnum { } @_spi(BridgeJS) public consuming func bridgeJSLowerReturn() { - Wrapped.bridgeJSStackPushAsOptional(asOptional) + switch asOptional { + case .none: + _swift_js_push_i32(-1) + case .some(let value): + _swift_js_push_i32(value.bridgeJSStackPushPayload()) + } } } From 0717703097059655013ddd9303995f61d9b9dea3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jul 2026 19:10:49 +0100 Subject: [PATCH 19/20] Bump actions/setup-node from 6 to 7 (#790) Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6 to 7. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e19fed6f2..0458dec5d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -81,7 +81,7 @@ jobs: steps: - uses: actions/checkout@v7 - name: Setup Node.js - uses: actions/setup-node@v6 + uses: actions/setup-node@v7 with: node-version: '20' - name: Install TypeScript @@ -117,7 +117,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: actions/setup-node@v6 + - uses: actions/setup-node@v7 with: node-version: '20' - run: npm install From 0e35c39017edfa6a18d2570bdfc06ebfdcca73be Mon Sep 17 00:00:00 2001 From: William Taylor Date: Tue, 21 Jul 2026 04:11:03 +1000 Subject: [PATCH 20/20] BridgeJS: Fix syntax error in generated JS (#789) --- .../Sources/BridgeJSLink/JSGlueGen.swift | 10 +++------- .../Inputs/MacroSwift/SwiftStruct.swift | 4 ++++ .../BridgeJSCodegenTests/SwiftStruct.json | 17 +++++++++++++++++ .../BridgeJSCodegenTests/SwiftStruct.swift | 11 +++++++++++ .../BridgeJSLinkTests/DefaultParameters.js | 4 ++-- .../BridgeJSLinkTests/SwiftStruct.d.ts | 1 + .../BridgeJSLinkTests/SwiftStruct.js | 9 ++++++++- 7 files changed, 46 insertions(+), 10 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift index 8ef7bbeb4..782988751 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift @@ -2381,14 +2381,10 @@ struct IntrinsicJSFragment: Sendable { if method.returnType == .void { printer.write("\(callExpr);") } else { - printer.write("const ret = \(callExpr);") - } - - // Lift return value if needed - if method.returnType != .void { let liftFragment = try IntrinsicJSFragment.liftReturn(type: method.returnType) - let liftArgs = liftFragment.parameters.isEmpty ? [] : ["ret"] - let lifted = try liftFragment.printCode(liftArgs, context) + let returnVariable = context.scope.variable("ret") + printer.write("const \(returnVariable) = \(callExpr);") + let lifted = try liftFragment.printCode([returnVariable], context) if let liftedValue = lifted.first { printer.write("return \(liftedValue);") } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftStruct.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftStruct.swift index 63bb0ff8d..4d2a84763 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftStruct.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/SwiftStruct.swift @@ -74,6 +74,10 @@ extension Vector2D { @JS func scaled(by factor: Double) -> Vector2D { return Vector2D(dx: dx * factor, dy: dy * factor) } + + @JS func describe() -> String { + return "Vector2D(\(dx), \(dy))" + } } extension DataPoint { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.json b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.json index d1a4b6882..2fcab7cb0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.json +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.json @@ -686,6 +686,23 @@ "_0" : "Vector2D" } } + }, + { + "abiName" : "bjs_Vector2D_describe", + "effects" : { + "isAsync" : false, + "isStatic" : false, + "isThrows" : false + }, + "name" : "describe", + "parameters" : [ + + ], + "returnType" : { + "string" : { + + } + } } ], "name" : "Vector2D", diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.swift index 9f671c711..f98038b45 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.swift @@ -525,6 +525,17 @@ public func _bjs_Vector2D_scaled(_ factor: Float64) -> Void { #endif } +@_expose(wasm, "bjs_Vector2D_describe") +@_cdecl("bjs_Vector2D_describe") +public func _bjs_Vector2D_describe() -> Void { + #if arch(wasm32) + let ret = Vector2D.bridgeJSLiftParameter().describe() + return ret.bridgeJSLowerReturn() + #else + fatalError("Only available on WebAssembly") + #endif +} + @_expose(wasm, "bjs_roundtrip") @_cdecl("bjs_roundtrip") public func _bjs_roundtrip() -> Void { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js index b7f67fe15..ba2b7cc77 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.js @@ -67,8 +67,8 @@ export async function createInstantiator(options, swift) { }.bind(instance1); instance1.multiply = function(a, b) { structHelpers.MathOperations.lower(this); - const ret = instance.exports.bjs_MathOperations_multiply(a, b); - return ret; + const ret1 = instance.exports.bjs_MathOperations_multiply(a, b); + return ret1; }.bind(instance1); return instance1; } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts index 14ddf714e..3b394fb06 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.d.ts @@ -48,6 +48,7 @@ export interface Vector2D { dy: number; magnitude(): number; scaled(factor: number): Vector2D; + describe(): string; } export type PrecisionObject = typeof PrecisionValues; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js index 44ae8a39d..92a99becb 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js @@ -237,10 +237,17 @@ export async function createInstantiator(options, swift) { }.bind(instance1); instance1.scaled = function(factor) { structHelpers.Vector2D.lower(this); - const ret = instance.exports.bjs_Vector2D_scaled(factor); + const ret1 = instance.exports.bjs_Vector2D_scaled(factor); const structValue = structHelpers.Vector2D.lift(); return structValue; }.bind(instance1); + instance1.describe = function() { + structHelpers.Vector2D.lower(this); + const ret2 = instance.exports.bjs_Vector2D_describe(); + const ret3 = tmpRetString; + tmpRetString = undefined; + return ret3; + }.bind(instance1); return instance1; } });